From 20b816d4b7e054306559e9f4eacc4f92057cec88 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Fri, 15 May 2020 11:45:17 -0400 Subject: [PATCH 01/28] Disable off option in Autoplay when necessary --- .../js/src/components/settings-page.js | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js index 6c638d976..acbed1bb3 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js @@ -1,5 +1,26 @@ (function() { + // Disable the "off" dropdown option for Autoplay if + // the player isn't set to Cloudinary or if Show Controls if unchecked. + const disableAutoplayOff = function() { + const player = jQuery( '#field-video_player' ).val(); + const showControls = jQuery( '#field-video_controls' ).prop( 'checked' ); + + if ( player === 'cld' && showControls ) { + jQuery( '#field-video_autoplay_mode option[value="off"]' ) + .attr( 'disabled', 'disabled' ) + .prop( 'disabled', 'disabled' ); + } else { + jQuery( '#field-video_autoplay_mode option[value="off"]' ) + .removeAttr( 'disabled' ) + .prop( 'disabled', false ); + } + } + + disableAutoplayOff(); + jQuery( document ).on( 'change', '#field-video_player', disableAutoplayOff ); + jQuery( document ).on( 'change', '#field-video_controls', disableAutoplayOff ); + jQuery( document ).ready( function( $ ) { // Initilize instance events From f5af42101f5b8bd39472c515f7de97e34589f9df Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Fri, 22 May 2020 14:39:07 -0400 Subject: [PATCH 02/28] Fix the logic on disabling the 'off' option --- .../css/cloudinary.css | 339 ++++++++++++++++- .../js/block-editor.js | 353 +++++++++++++++++- .../js/cloudinary.js | 183 ++++++++- .../js/src/components/settings-page.js | 14 +- 4 files changed, 879 insertions(+), 10 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css index ab2783e7d..ec9c7c7c4 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css @@ -1 +1,338 @@ -@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.eot);src:url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.ttf) format("truetype"),url(../css/fonts/cloudinary.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.warning:before{content:"\e902"}.dashicons-cloudinary.warning{color:#fd9d2c}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0078ff}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file +@font-face { + font-family: 'cloudinary'; + src: url(../css/fonts/cloudinary.eot); + src: url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"), url(../css/fonts/cloudinary.ttf) format("truetype"), url(../css/fonts/cloudinary.woff) format("woff"), url(../css/cloudinary.svg#cloudinary) format("svg"); + font-weight: normal; + font-style: normal; } + +.dashicons-cloudinary { + /* use !important to prevent issues with browser extensions that change fonts */ + speak: none; + font-style: normal; + font-weight: normal; + font-variant: normal; + text-transform: none; + line-height: 1; + /* Better Font Rendering =========== */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; } + .dashicons-cloudinary:before { + font-family: 'cloudinary' !important; + content: '\e900'; } + .dashicons-cloudinary.success { + color: #558b2f; } + .dashicons-cloudinary.error { + color: #dd2c00; } + .dashicons-cloudinary.error:before { + content: '\e901'; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + .dashicons-cloudinary.warning:before { + content: '\e902'; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + .dashicons-cloudinary.warning { + color: #fd9d2c; } + +.column-cld_status { + width: 5.5em; } + .column-cld_status .dashicons-cloudinary { + display: inline-block; } + .column-cld_status .dashicons-cloudinary:before { + font-size: 1.8rem; } + +.form-field .error-notice, .form-table .error-notice { + display: none; + color: #dd2c00; } + +.form-field input.cld-field:invalid, .form-table input.cld-field:invalid { + border-color: #dd2c00; } + .form-field input.cld-field:invalid + .error-notice, .form-table input.cld-field:invalid + .error-notice { + display: inline-block; } + +.cloudinary-welcome { + background-image: url(../css/logo.svg); + background-repeat: no-repeat; + background-size: 153px; + background-position: top 12px right 20px; } + +.cloudinary-stats { + display: inline-block; + margin-left: 25px; } + +.cloudinary-stat { + cursor: help; } + +.cloudinary-percent { + font-size: 0.8em; + vertical-align: top; + color: #0078ff; } + +.settings-image { + max-width: 100%; + padding-top: 5px; } + +.settings-tabs > li { + display: inline-block; } + .settings-tabs > li a { + padding: .6em; } + .settings-tabs > li a.active { + background-color: #ffffff; } + +.settings-tab-section { + padding: 20px 0 0 0; + max-width: 1030px; + position: relative; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard { + display: flex; + align-items: flex-start; + align-content: flex-start; + margin-top: 40px; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description { + width: 55%; + margin: 0 auto 0 0; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content { + width: 35%; + margin: 0 auto; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons { + color: #9EA3A8; } + .settings-tab-section.cloudinary-welcome .settings-tab-section-card { + margin-top: 0; } + .settings-tab-section-fields .field-heading th { + display: block; + width: auto; + color: #23282d; + font-size: 1.1em; + margin: 1em 0; } + .settings-tab-section-fields .field-heading td { + display: none; + visibility: hidden; } + .settings-tab-section-fields .regular-textarea { + width: 100%; + height: 60px; } + .settings-tab-section-fields .dashicons { + text-decoration: none; + vertical-align: middle; } + .settings-tab-section-fields a .dashicons { + color: #5F5F5F; } + .settings-tab-section-fields-dashboard-error { + font-size: 1.2em; + color: #5F5F5F; } + .settings-tab-section-fields-dashboard-error .dashicons { + color: #AC0000; } + .settings-tab-section-fields-dashboard-error .button { + font-size: 1.1em; + height: 40px; + line-height: 40px; + padding-right: 40px; + padding-left: 40px; } + .settings-tab-section-fields-dashboard-success { + font-size: 1.2em; + color: #23282d; } + .settings-tab-section-fields-dashboard-success.expanded { + padding-top: 40px; } + .settings-tab-section-fields-dashboard-success .dashicons { + color: #4FB651; } + .settings-tab-section-fields-dashboard-success .button { + font-size: 1.1em; + height: 40px; + line-height: 40px; + padding-right: 40px; + padding-left: 40px; } + .settings-tab-section-fields-dashboard-success .description { + color: #5F5F5F; + font-weight: normal; + margin-top: 12px; } + .settings-tab-section-card { + box-sizing: border-box; + border: 1px solid #E5E5E5; + background-color: #FFFFFF; + box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.07); + padding: 20px 23px; + margin-top: 12px; } + .settings-tab-section-card .dashicons { + font-size: 1.4em; } + .settings-tab-section-card h2 { + font-size: 1.8em; + font-weight: normal; + margin-top: 0; } + .settings-tab-section-card.pull-right { + width: 450px; + padding: 12px; + float: right; + position: relative; + z-index: 10; } + .settings-tab-section-card.pull-right img.settings-image { + box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5); + border: 1px solid #979797; + margin-top: 12px; } + .settings-tab-section-card.pull-right h4, .settings-tab-section-card.pull-right h3 { + margin-top: 0; } + .settings-tab-section .field-row-cloudinary_url, .settings-tab-section .field-row-signup { + display: block; } + .settings-tab-section .field-row-cloudinary_url td, .settings-tab-section .field-row-cloudinary_url th, .settings-tab-section .field-row-signup td, .settings-tab-section .field-row-signup th { + display: block; + width: auto; + padding: 10px 0 0; } + .settings-tab-section .field-row-cloudinary_url td .sign-up, .settings-tab-section .field-row-cloudinary_url th .sign-up, .settings-tab-section .field-row-signup td .sign-up, .settings-tab-section .field-row-signup th .sign-up { + vertical-align: baseline; } + .settings-tab-section.connect .form-table { + display: inline-block; + width: auto; + max-width: 580px; } + +.settings-valid { + color: #558b2f; + font-size: 30px; } + .settings-valid-field { + border-color: #558b2f !important; } + +.settings-invalid-field { + border-color: #dd2c00 !important; } + +.sync .spinner { + display: inline-block; + visibility: visible; + float: none; + margin: 0 5px 0 0; } + +.sync-media { + display: none; } + .sync-media-progress { + display: none; } + .sync-media-progress-outer { + height: 20px; + margin: 20px 0 10px; + width: 500px; + background-color: #e5e5e5; + position: relative; } + .sync-media-progress-outer .progress-bar { + width: 0; + height: 20px; + background-color: #558b2f; + transition: width 250ms; } + .sync-media-progress-notice { + color: #dd2c00; } + .sync-media-resource { + width: 100px; + display: inline-block; } + .sync-media-error { + color: #dd2c00; } + +.sync-count { + font-weight: bold; } + +.sync-details { + margin-top: 10px; } + +.sync .button.stop-sync, .sync .button.start-sync { + display: none; + padding: 0 16px; } + .sync .button.stop-sync .dashicons, .sync .button.start-sync .dashicons { + line-height: 2.2em; } + +.sync .progress-text { + padding: 12px 4px 12px 12px; + display: inline-block; + font-weight: bold; } + +.sync .completed { + max-width: 300px; + display: none; } + +.sync-status-disabled { + color: #dd2c00; } + +.sync-status-enabled { + color: #558b2f; } + +.sync-status-button.button { + vertical-align: baseline; } + +.cloudinary-widget { + height: 100%; } + .cloudinary-widget-wrapper { + height: 100%; + overflow: hidden; + background-image: url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbCiAgICAgIEBrZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhGRjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OEZGOyB9CiAgICAgIH0KCiAgICAgIEBrZXlmcmFtZXMgZGFzaCB7CiAgICAgICAwJSB7IHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgIDUwJSB7CiAgICAgICAgICBzdHJva2UtZGFzaG9mZnNldDogMDsKICAgICAgIH0KICAgICAgIDEwMCUgeyAgIHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgfQogICAgICBALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhmZjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OGZmOyB9CiAgICAgIH0KCiAgICAgIEAtd2Via2l0LWtleWZyYW1lcyBkYXNoIHsKICAgICAgIDAlIHsgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsgfQogICAgICAgNTAlIHsKICAgICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgfQogICAgICAgMTAwJSB7ICAgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsKICAgICAgIH0KICAgICAgfQogICAgICAucGF0aCB7CiAgICAgICAgc3Ryb2tlLWRhc2hhcnJheTogMjgwOwogICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgIHRyYW5zZm9ybS1vcmlnaW46IGNlbnRlcjsKICAgICAgICAtd2Via2l0LWFuaW1hdGlvbjoKICAgICAgICAgIGRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsIGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZTsKICAgICAgICBhbmltYXRpb246CiAgICAgICAgICBkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLCBjb2xvcnMgOHMgZWFzZS1pbi1vdXQgaW5maW5pdGU7CiAgICAgIH0KICAgIF1dPjwvc3R5bGU+CiAgPHBhdGggY2xhc3M9InBhdGgiIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K"); + background-repeat: no-repeat; + background-position: center; + background-size: 150px; } + +.attachment-info .edit-attachment { + display: none; } + +.attachment-actions .button.edit-attachment { + display: none; } + +.global-transformations-preview { + position: relative; + max-width: 600px; } + +.global-transformations-spinner { + display: none; } + +.global-transformations-button.button-primary { + display: none; + position: absolute; + z-index: 100; } + +.global-transformations-url { + margin-bottom: 5px; + margin-top: 5px; } + .global-transformations-url-transformation { + max-width: 100px; + overflow: hidden; + text-overflow: ellipsis; + color: #51A3FF; } + .global-transformations-url-file { + color: #f2d864; } + .global-transformations-url-link { + display: block; + padding: 16px; + background-color: #262c35; + text-decoration: none; + color: #fff; + border-radius: 6px; + overflow: hidden; + text-overflow: ellipsis; } + .global-transformations-url-link:hover { + color: #888888; + text-decoration: underline; } + +.cld-tax-order-list-item { + border: 1px solid #efefef; + padding: 4px; + margin: 0 0 -1px; + background-color: #ffffff; } + .cld-tax-order-list-item.no-items { + color: #888; + text-align: center; + display: none; } + .cld-tax-order-list-item.no-items:last-child { + display: block; } + .cld-tax-order-list-item.ui-sortable-helper { + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); } + .cld-tax-order-list-item-placeholder { + background-color: #efefef; + height: 45px; + margin: 0; } + .cld-tax-order-list-item-handle { + cursor: grab; + margin-right: 4px; + color: #999; } + +.cld-tax-order-list-type { + width: 45%; + display: inline-block; + margin-right: 8px; } + .cld-tax-order-list-type input { + margin-right: 4px !important; } + +.cloudinary-media-library { + position: relative; + margin-left: -20px; } + @media screen and (max-width: 782px) { + .cloudinary-media-library { + margin-left: -10px; } } + diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js index 38488de8c..f3bce37b8 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js @@ -1 +1,352 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e,r){var n=r(5);t.exports=function(t){for(var e=1;e=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,r=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,e.percent<100?(this.barSyncCount.innerText=e.total,this.progressCount.innerText=e.done,this.progress.style.display=this.show):(this.completed.style.display=this.show,this.progress.style.display=this.hide)},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var r=a;a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var o=i(1),l=i.n(o);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),r=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${r})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var p=u;const m={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=m;m._init();i(2);i.d(t,"cloudinary",(function(){return f}));window.$=window.jQuery;const f={settings:s.a,sync:r,widget:l.a,Global_Transformations:c,Terms_Order:p,Media_Library:h}}]); \ No newline at end of file +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./js/src/main.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./css/src/main.scss": +/*!***************************!*\ + !*** ./css/src/main.scss ***! + \***************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("// extracted by mini-css-extract-plugin\n\n//# sourceURL=webpack:///./css/src/main.scss?"); + +/***/ }), + +/***/ "./js/src/components/global-transformations.js": +/*!*****************************************************!*\ + !*** ./js/src/components/global-transformations.js ***! + \*****************************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\nconst Global_Transformations = {\n\tsample: {\n\t\timage: document.getElementById( 'transformation-sample-image' ),\n\t\tvideo: document.getElementById( 'transformation-sample-video' ),\n\t},\n\tpreview: {\n\t\timage: document.getElementById( 'sample-image' ),\n\t\tvideo: document.getElementById( 'sample-video' ),\n\t},\n\tfields: document.getElementsByClassName( 'cld-field' ),\n\tbutton: {\n\t\timage: document.getElementById( 'refresh-image-preview' ),\n\t\tvideo: document.getElementById( 'refresh-video-preview' ),\n\t},\n\tspinner: {\n\t\timage : document.getElementById( 'image-loader' ),\n\t\tvideo : document.getElementById( 'video-loader' ),\n\t},\n\tactiveItem: null,\n\telements: {\n\t\timage: [],\n\t\tvideo: [],\n\t},\n\t_placeItem: function( item ) {\n\t\tif ( null !== item ) {\n\t\t\titem.style.display = 'block';\n\t\t\titem.style.visibility = 'visible';\n\t\t\titem.style.position = 'absolute';\n\t\t\titem.style.top = (item.parentElement.clientHeight / 2) - (item.clientHeight / 2) + 'px';\n\t\t\titem.style.left = (item.parentElement.clientWidth / 2) - (item.clientWidth / 2) + 'px';\n\t\t}\n\t},\n\t_setLoading: function( type ) {\n\t\tthis.button[ type ].style.display = 'block';\n\t\tthis._placeItem( this.button[ type ] );\n\t\tthis.preview[ type ].style.opacity = '0.1';\n\n\t\t},\n\t_build: function( type ) {\n\t\tthis.sample[ type ].innerHTML = '';\n\t\tthis.elements[ type ] = [];\n\t\tfor (let item of this.fields) {\n\t\t\tif( type !== item.dataset.context ){\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet value = item.value.trim();\n\t\t\tif ( value.length ) {\n\n\t\t\t\tif ( 'select-one' === item.type ) {\n\t\t\t\t\tif ( 'none' === value ) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tvalue = item.dataset.meta + '_' + value;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tlet type = item.dataset.context;\n\t\t\t\t\tvalue = this._transformations( value, type, true );\n\t\t\t\t}\n\t\t\t\t// Apply value if valid.\n\t\t\t\tif( value ) {\n\t\t\t\t\tthis.elements[ type ].push( value );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tlet transformations = '';\n\t\tif ( this.elements[ type ].length ) {\n\t\t\ttransformations = '/' + this.elements[ type ].join( ',' ).replace( / /g, '%20' );\n\t\t}\n\t\tthis.sample[ type ].textContent = transformations;\n\t\tthis.sample[ type ].parentElement.href = 'https://res.cloudinary.com/demo/' + this.sample[ type ].parentElement.innerText.trim().replace('../', '').replace( / /g, '%20' );\n\t},\n\t_clearLoading: function( type ) {\n\t\tthis.spinner[ type ].style.visibility = 'hidden';\n\t\tthis.activeItem = null;\n\t\tthis.preview[ type ].style.opacity = 1;\n\t},\n\t_refresh: function( e, type ) {\n\t\tif( e ) {\n\t\t\te.preventDefault();\n\t\t}\n\t\tlet self = this;\n\t\tlet new_src = CLD_GLOBAL_TRANSFORMATIONS[ type ].preview_url + self.elements[ type ].join( ',' ) + CLD_GLOBAL_TRANSFORMATIONS[ type ].file;\n\t\tthis.button[ type ].style.display = 'none';\n\t\tthis._placeItem( this.spinner[ type ] );\n\t\tif ( type === 'image' ) {\n\t\t\tlet newImg = new Image;\n\t\t\tnewImg.onload = function() {\n\t\t\t\tself.preview[ type ].src = this.src;\n\t\t\t\tself._clearLoading( type );\n\t\t\t\tnewImg.remove();\n\t\t\t};\n\t\t\tnewImg.onerror = function() {\n\t\t\t\talert( CLD_GLOBAL_TRANSFORMATIONS[type].error );\n\t\t\t\tself._clearLoading( type );\n\t\t\t};\n\t\t\tnewImg.src = new_src;\n\t\t}else{\n\t\t\tlet transformations = self._transformations( self.elements[ type ].join( ',' ), type );\n\t\t\tsamplePlayer.source( { publicId: 'dog', transformation: transformations } );\n\t\t\tself._clearLoading( type );\n\t\t}\n\t},\n\t_transformations : function( input, type, string = false ){\n\t\tlet set = CLD_GLOBAL_TRANSFORMATIONS[ type ].valid_types;\n\t\tlet value = null;\n\t\tlet elements = input.split( '/' );\n\t\tlet valid_elements = [];\n\t\tfor (let i = 0; i < elements.length; i++) {\n\t\t\tlet parts = elements[ i ].split(',');\n\t\t\tlet valid_parts;\n\t\t\tif( true === string ) {\n\t\t\t\tvalid_parts = [];\n\t\t\t}else{\n\t\t\t\tvalid_parts = {};\n\t\t\t}\n\t\t\tfor (let p = 0; p < parts.length; p++) {\n\t\t\t\tlet key_val = parts[ p ].trim().split('_');\n\t\t\t\tif( key_val.length <= 1 || typeof set[ key_val[0] ] === 'undefined' ){\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tlet option = key_val.shift();\n\t\t\t\tlet instruct = key_val.join( '_' );\n\t\t\t\tif( true === string ) {\n\t\t\t\t\tif( 'f' === option || 'q' === option ){\n\t\t\t\t\t\tfor( let t in this.elements[ type ] ){\n\t\t\t\t\t\t\tif( option + '_' === this.elements[ type ][ t ].substr(0,2 ) ){\n\t\t\t\t\t\t\t\tthis.elements[ type ].splice(t,1);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tvalid_parts.push( parts[ p ] );\n\t\t\t\t}else{\n\t\t\t\t\tvalid_parts[ set[ option ] ] = instruct.trim();\n\t\t\t\t}\n\t\t\t}\n\t\t\tlet length = 0;\n\t\t\tif( true === string ) {\n\t\t\t\tlength = valid_parts.length;\n\t\t\t}else{\n\t\t\t\tlength = Object.keys( valid_parts ).length;\n\t\t\t}\n\t\t\tif ( length ) {\n\t\t\t\tif( true === string ) {\n\t\t\t\t\tvalid_parts = valid_parts.join( ',' );\n\t\t\t\t}\n\t\t\t\tvalid_elements.push( valid_parts );\n\t\t\t}\n\t\t}\n\n\t\tif ( valid_elements.length ) {\n\t\t\tif( true === string ) {\n\t\t\t\tvalue = valid_elements.join( '/' ).trim();\n\t\t\t}else{\n\t\t\t\tvalue = valid_elements;\n\t\t\t}\n\t\t}\n\n\t\treturn value;\n\t},\n\t_reset: function() {\n\t\tfor (let item of this.fields) {\n\t\t\titem.value = null;\n\t\t}\n\t\tfor( let type in this.button ) {\n\t\t\tthis._build( type );\n\t\t\tthis._refresh( null, type );\n\t\t}\n\t},\n\t_input: function( input ){\n\t\tif( typeof input.dataset.context !== 'undefined' && input.dataset.context.length ) {\n\t\t\tlet type = input.dataset.context;\n\t\t\tthis._setLoading( type );\n\t\t\tthis._build( type );\n\t\t}\n\t},\n\t_init: function() {\n\n\t\tif ( typeof CLD_GLOBAL_TRANSFORMATIONS !== 'undefined' ) {\n\t\t\tlet self = this;\n\n\t\t\tdocument.addEventListener( 'DOMContentLoaded', function( ev ) {\n\t\t\t\tfor( let type in self.button ) {\n\t\t\t\t\tif( self.button[ type ] ) {\n\t\t\t\t\t\tself.button[ type ].addEventListener( 'click', function( e ) {\n\t\t\t\t\t\t\tself._refresh( e, type );\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfor (let item of self.fields) {\n\t\t\t\t\titem.addEventListener( 'input', function(){\n\t\t\t\t\t\tself._input( this );\n\t\t\t\t\t} );\n\t\t\t\t\titem.addEventListener( 'change', function() {\n\t\t\t\t\t\tself._input( this );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\t// Init.\n\t\t\t\tfor( let type in CLD_GLOBAL_TRANSFORMATIONS ) {\n\t\t\t\t\tself._build( type );\n\t\t\t\t\tself._refresh( null, type );\n\t\t\t\t}\n\t\t\t} );\n\t\t\t// listen to AJAX add-tag complete\n\t\t\tjQuery(document).ajaxComplete(function(event, xhr, settings) {\n\n\t\t\t\t// bail early if is other ajax call\n\t\t\t\tif( settings.data.indexOf('action=add-tag') === -1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// bail early if response contains error\n\t\t\t\tif( xhr.responseText.indexOf('wp_error') !== -1 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tself._reset();\n\t\t\t});\n\t\t}\n\t},\n};\n\n// Init.\nGlobal_Transformations._init();\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Global_Transformations);\n\n\n//# sourceURL=webpack:///./js/src/components/global-transformations.js?"); + +/***/ }), + +/***/ "./js/src/components/media-library.js": +/*!********************************************!*\ + !*** ./js/src/components/media-library.js ***! + \********************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\nconst Media_Library = {\n\twpWrap: document.getElementById( 'wpwrap' ),\n\twpContent: document.getElementById( 'wpbody-content' ),\n\tlibraryWrap: document.getElementById( 'cloudinary-embed' ),\n\t_init: function() {\n\t\tlet self = this;\n\t\tif ( typeof CLD_ML !== 'undefined' ) {\n\n\t\t\tcloudinary.openMediaLibrary( CLD_ML.mloptions, {\n\t\t\t\t\tinsertHandler: function( data ) {\n\t\t\t\t\t\t// @todo: Determin what to do here.\n\t\t\t\t\t\talert( 'Import is not yet implemented.' );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\n\t\t\twindow.addEventListener( 'resize', function( ev ) {\n\t\t\t\tself._resize();\n\t\t\t} );\n\n\t\t\tself._resize();\n\t\t}\n\t},\n\t_resize: function() {\n\t\tlet style = getComputedStyle( this.wpContent );\n\t\tthis.libraryWrap.style.height = (this.wpWrap.offsetHeight - parseInt( style.getPropertyValue( 'padding-bottom' ) )) + 'px';\n\t},\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Media_Library);\n\n// Init.\nMedia_Library._init();\n\n\n//# sourceURL=webpack:///./js/src/components/media-library.js?"); + +/***/ }), + +/***/ "./js/src/components/settings-page.js": +/*!********************************************!*\ + !*** ./js/src/components/settings-page.js ***! + \********************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("(function() {\n\n\t// Disable the \"off\" dropdown option for Autoplay if\n\t// the player isn't set to Cloudinary or if Show Controls if unchecked.\n\tconst disableAutoplayOff = function() {\n\t\tconst player = jQuery( '#field-video_player' ).val();\n\t\tconst showControls = jQuery( '#field-video_controls' ).prop( 'checked' );\n\t\tconst offSelection = jQuery( '#field-video_autoplay_mode option[value=\"off\"]' );\n\n\t\tif ( player === 'cld' && ! showControls ) {\n\t\t\toffSelection.prop( 'disabled', true );\n\t\t\tif ( offSelection.prop( 'selected' ) ) {\n\t\t\t\toffSelection.next().prop( 'selected', true );\n\t\t\t}\n\t\t} else {\n\t\t\toffSelection.prop( 'disabled', false );\n\t\t}\n\t}\n\n\tdisableAutoplayOff();\n\tjQuery( document ).on( 'change', '#field-video_player', disableAutoplayOff );\n\tjQuery( document ).on( 'change', '#field-video_controls', disableAutoplayOff );\n\n\tjQuery( document ).ready( function( $ ) {\n\n\t\t// Initilize instance events\n\t\t$( document ).on( 'tabs.init', function() {\n\n\t\t\tvar tabs = $( '.settings-tab-trigger' ),\n\t\t\t sections = $( '.settings-tab-section' );\n\n\t\t\t// Create instance bindings\n\t\t\t$( this ).on( 'click', '.settings-tab-trigger', function( e ) {\n\t\t\t\tvar clicked = $( this ),\n\t\t\t\t target = $( clicked.attr( 'href' ) );\n\n\t\t\t\t// Trigger an instance action.\n\t\t\t\te.preventDefault();\n\n\t\t\t\ttabs.removeClass( 'active' );\n\t\t\t\tsections.removeClass( 'active' );\n\n\t\t\t\tclicked.addClass( 'active' );\n\t\t\t\ttarget.addClass( 'active' );\n\n\t\t\t\t// Trigger the tabbed event.\n\t\t\t\t$( document ).trigger( 'settings.tabbed', clicked );\n\n\t\t\t} );\n\n\t\t\t// Bind conditions.\n\t\t\t$( '.cld-field' ).not( '[data-condition=\"false\"]' ).each( function() {\n\t\t\t\tconst field = $(this);\n\t\t\t\tconst condition = field.data('condition');\n\t\t\t\tfor (let f in condition) {\n\t\t\t\t\tconst value = condition[ f ];\n\t\t\t\t\tconst target = $( '#field-' + f );\n\t\t\t\t\tconst wrapper = field.closest('tr');\n\t\t\t\t\ttarget.on('change init', function(){\n\t\t\t\t\t\tif( this.value === value || this.checked ){\n\t\t\t\t\t\t\twrapper.show();\n\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\twrapper.hide();\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\ttarget.trigger('init');\n\t\t\t\t}\n\t\t\t} );\n\n\t\t\t$('#field-cloudinary_url').on('input change', function(){\n\t\t\t\tlet field = $(this),\n\t\t\t\t\tvalue = field.val();\n\n\t\t\t\tlet reg = new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\\/\\/){1}(\\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g );\n\t\t\t\tif( reg.test( value ) ){\n\t\t\t\t\tfield.addClass( 'settings-valid-field' );\n\t\t\t\t\tfield.removeClass( 'settings-invalid-field' );\n\t\t\t\t}else{\n\t\t\t\t\tfield.removeClass( 'settings-valid-field' );\n\t\t\t\t\tfield.addClass( 'settings-invalid-field' );\n\t\t\t\t}\n\t\t\t}).trigger('change' );\n\n\n\t\t} );\n\n\t\t// On Ready, find all render trigger elements and fire their events.\n\t\t$( '.render-trigger[data-event]' ).each( function() {\n\t\t\tvar trigger = $( this ),\n\t\t\t event = trigger.data( 'event' );\n\t\t\ttrigger.trigger( event, this );\n\t\t} );\n\t} );\n\n})( window, jQuery );\n\n\n//# sourceURL=webpack:///./js/src/components/settings-page.js?"); + +/***/ }), + +/***/ "./js/src/components/sync.js": +/*!***********************************!*\ + !*** ./js/src/components/sync.js ***! + \***********************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp */\n\nconst Sync = {\n\tprogress: document.getElementById( 'progress-wrapper' ),\n\tsubmitButton: document.getElementById( 'submit' ),\n\tstopButton: document.getElementById( 'stop-sync' ),\n\tprogressCount: document.getElementById( 'sync-progress' ),\n\tbarSyncCount: document.getElementById( 'sync-total' ),\n\tcompleted: document.getElementById( 'completed-notice' ),\n\tshow: 'inline-block',\n\thide: 'none',\n\tgetStatus: function getStatus() {\n\t\tvar self = this,\n\t\t\tresourceType = [],\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/attachments',\n\t\t\tparams;\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\ttype: 'GET',\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} ).done( function( data ) {\n\t\t\tif ( data.done < data.total ) {\n\t\t\t\tsetTimeout( Sync.getStatus, 2000 );\n\t\t\t}\n\t\t\tSync._updateUI( data );\n\t\t} );\n\t},\n\tstopSync: function stopSync() {\n\t\tvar self = this,\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/sync';\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\tdata: {\n\t\t\t\tstop: true,\n\t\t\t},\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} ).done( function( data ) {\n\t\t\tSync._updateUI( data );\n\t\t} );\n\t},\n\tpushAttachments: function pushAttachments() {\n\t\tvar self = this,\n\t\t\turl = cloudinaryApi.restUrl + 'cloudinary/v1/sync';\n\n\t\twp.ajax.send( {\n\t\t\turl: url,\n\t\t\tbeforeSend: function( request ) {\n\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', cloudinaryApi.nonce );\n\t\t\t},\n\t\t} );\n\t},\n\t_updateUI: function _updateUI( data ) {\n\t\tif ( data.percent < 100 && typeof data.started !== 'undefined' ) {\n\t\t\tthis.submitButton.style.display = this.hide;\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse if ( data.percent >= 100 && typeof data.started !== 'undefined' ) {\n\t\t\tthis.submitButton.style.display = this.hide;\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse if ( data.pending > 0 ) {\n\t\t\tthis.submitButton.style.display = this.show;\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\t\telse if ( data.processing > 0 ) {\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\n\t\tif ( data.percent < 100 ) {\n\t\t\tthis.barSyncCount.innerText = data.total;\n\t\t\tthis.progressCount.innerText = data.done;\n\t\t\tthis.progress.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.completed.style.display = this.show;\n\t\t\tthis.progress.style.display = this.hide;\n\t\t}\n\t},\n\t_start: function _start( e ) {\n\t\te.preventDefault();\n\t\tSync.stopButton.style.display = Sync.show;\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.pushAttachments();\n\t},\n\t_reset: function _reset( e ) {\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.getStatus();\n\t},\n\t_init: function( fn ) {\n\n\t\tif ( typeof cloudinaryApi !== 'undefined' ) {\n\t\t\tif ( document.attachEvent ? document.readyState === 'complete' : document.readyState !== 'loading' ) {\n\t\t\t\tfn();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdocument.addEventListener( 'DOMContentLoaded', fn );\n\t\t\t}\n\t\t}\n\t},\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Sync);\n\n// Init.\nSync._init( function() {\n\tSync._reset();\n\tSync.submitButton.addEventListener( 'click', Sync._start );\n\tSync.stopButton.addEventListener( 'click', Sync.stopSync );\n} );\n\n\n//# sourceURL=webpack:///./js/src/components/sync.js?"); + +/***/ }), + +/***/ "./js/src/components/terms_order.js": +/*!******************************************!*\ + !*** ./js/src/components/terms_order.js ***! + \******************************************/ +/*! exports provided: default */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp wpAjax */\n\nconst Terms_Order = {\n template: '',\n tags: jQuery( '#cld-tax-items' ),\n tagDelimiter: ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ',',\n startId: null,\n _init: function() {\n // Check that we found the tax-items.\n if ( !this.tags.length ) {\n return;\n }\n\n const self = this;\n this._sortable();\n\n // Setup ajax overrides.\n if ( typeof wpAjax !== 'undefined' ) {\n wpAjax.procesParseAjaxResponse = wpAjax.parseAjaxResponse;\n wpAjax.parseAjaxResponse = function( response, settingsResponse, element ) {\n let newResponse = wpAjax.procesParseAjaxResponse( response, settingsResponse, element );\n if ( !newResponse.errors && newResponse.responses[ 0 ] ) {\n if ( jQuery( '[data-taxonomy=\"' + newResponse.responses[ 0 ].what + '\"]' ).length ) {\n const data = jQuery( newResponse.responses[ 0 ].data );\n const text = data.find( 'label' ).last().text().trim();\n self._pushItem( newResponse.responses[ 0 ].what, text );\n }\n }\n\n return newResponse;\n };\n }\n\n if ( typeof window.tagBox !== 'undefined' ) {\n window.tagBox.processflushTags = window.tagBox.flushTags;\n window.tagBox.flushTags = function( el, a, f ) {\n if ( typeof f === 'undefined' ) {\n let text, list;\n const taxonomy = el.prop( 'id' );\n const newTag = jQuery( 'input.newtag', el );\n\n a = a || false;\n\n text = a ? jQuery( a ).text() : newTag.val();\n list = window.tagBox.clean( text ).split( self.tagDelimiter );\n for ( var i in list ) {\n var tag = taxonomy + ':' + list[ i ];\n if ( !jQuery( '[data-item=\"' + tag + '\"]' ).length ) {\n self._pushItem( tag, list[ i ] );\n }\n }\n }\n\n return this.processflushTags( el, a, f );\n };\n\n window.tagBox.processTags = window.tagBox.parseTags;\n\n window.tagBox.parseTags = function( el ) {\n const id = el.id;\n const num = id.split( '-check-num-' )[ 1 ];\n const taxonomy = id.split( '-check-num-' )[ 0 ];\n const taxBox = jQuery( el ).closest( '.tagsdiv' );\n const tagsTextarea = taxBox.find( '.the-tags' );\n const tagToRemove = window.tagBox.clean( tagsTextarea.val() ).split( self.tagDelimiter )[ num ];\n\n new wp.api.collections.Tags()\n .fetch( { data: { slug: tagToRemove } } )\n .done( ( tag ) => {\n const tagFromDatabase = tag.length ? jQuery( '[data-item=\"' + taxonomy + ':' + tag[ 0 ].id + '\"]' ) : false;\n\n if ( tagFromDatabase.length ) {\n tagFromDatabase.remove();\n }\n else {\n jQuery( `.cld-tax-order-list-item:contains(${ tagToRemove })` ).remove();\n --self.startId;\n }\n this.processTags( el );\n } );\n };\n }\n\n jQuery( 'body' ).on( 'change', '.selectit input', function() {\n const clickedItem = jQuery( this );\n const id = clickedItem.val();\n const checked = clickedItem.is( ':checked' );\n const text = clickedItem.parent().text().trim();\n\n if ( true === checked ) {\n if( ! self.tags.find(`[data-item=\"category:${ id }\"]`).length ) {\n self._pushItem( `category:${ id }`, text );\n }\n }\n else {\n self.tags.find( `[data-item=\"category:${ id }\"]` ).remove();\n }\n } );\n },\n _createItem: function( id, name ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li.addClass( 'cld-tax-order-list-item' ).attr( 'data-item', id );\n input.addClass( 'cld-tax-order-list-item-input' ).attr( 'type', 'hidden' ).attr( 'name', 'cld_tax_order[]' ).val( id );\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n },\n _pushItem: function( id, text ) {\n let item = this._createItem( id, text );\n this.tags.append( item ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n },\n _sortable: function() {\n const items = jQuery( '.cld-tax-order-list' );\n\n items.sortable( {\n connectWith: '.cld-tax-order',\n axis: 'y',\n handle: '.cld-tax-order-list-item-handle',\n placeholder: 'cld-tax-order-list-item-placeholder',\n forcePlaceholderSize: true,\n helper: 'clone',\n } );\n }\n};\n\nif ( typeof window.CLDN !== 'undefined' ) {\n Terms_Order._init();\n // Init checked categories.\n jQuery( '[data-wp-lists] .selectit input[checked]' ).map( ( ord, check ) => {\n jQuery( check ).trigger( 'change' );\n } );\n}\n\n// Gutenberg.\nif ( wp.data && wp.data.select( 'core/editor' ) ) {\n const orderSet = {};\n wp.data.subscribe( function() {\n let taxonomies = wp.data.select( 'core' ).getTaxonomies();\n\n if ( taxonomies ) {\n for ( let t in taxonomies ) {\n const set = wp.data.select( 'core/editor' ).getEditedPostAttribute( taxonomies[ t ].rest_base );\n orderSet[ taxonomies[ t ].slug ] = set;\n }\n }\n } );\n\n const el = wp.element.createElement;\n const CustomizeTaxonomySelector = ( OriginalComponent ) => {\n class CustomHandler extends OriginalComponent {\n constructor( props ) {\n super( props );\n\n this.currentItems = jQuery( '.cld-tax-order-list-item' )\n .map( ( _, taxonomy ) => jQuery( taxonomy ).data( 'item' ) ).get();\n }\n\n makeItem( item ) {\n // Prevent duplicates in the tax order box\n if ( this.currentItems.includes( this.getId( item ) ) ) {\n return;\n }\n\n const row = this.makeElement( item );\n const box = jQuery( '#cld-tax-items' );\n box.append( row ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n }\n\n removeItem( item ) {\n const elementWithId = jQuery( `[data-item=\"${ this.getId( item ) }\"]` );\n\n if ( elementWithId.length ) {\n elementWithId.remove();\n\n this.currentItems = this.currentItems.filter( ( taxIdentifier ) => {\n return taxIdentifier !== this.getId( item );\n } );\n }\n }\n\n findOrCreateTerm( termName ) {\n termName = super.findOrCreateTerm( termName );\n termName.then( ( item ) => this.makeItem( item ) );\n\n return termName;\n }\n\n onChange( event ) {\n super.onChange( event );\n const item = this.pickItem( event );\n\n if ( item ) {\n if ( orderSet[ this.props.slug ].includes( item.id ) ) {\n this.makeItem( item );\n }\n else {\n this.removeItem( item );\n }\n }\n }\n\n pickItem( event ) {\n if ( typeof event === 'object' ) {\n if ( event.target ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === parseInt( event.target.value ) ) {\n return this.state.availableTerms[ p ];\n }\n }\n // Tags that are already registered need to be selected\n // separately as its expected that they return back\n // with an \"id\" property.\n }\n else if ( Array.isArray( event ) ) {\n // Figure out the diff between the current state and\n // the event and determine which tag is getting removed\n let enteredTag = this.state.selectedTerms.filter( flatItem => !event.includes( flatItem ) )[ 0 ];\n\n if ( typeof enteredTag === 'undefined' ) {\n // If the above returns undefined, then we presume\n // the user is adding, so reverse the logic to\n // figure out the new item\n enteredTag = event.filter( flatItem => !this.state.selectedTerms.includes( flatItem ) )[ 0 ];\n }\n\n return this.state.availableTerms.find( ( item ) => item.name === enteredTag );\n }\n }\n else if ( typeof event === 'number' ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === event ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n else {\n let text;\n\n // add or remove.\n if ( event.length > this.state.selectedTerms.length ) {\n // Added.\n for ( let o in event ) {\n if ( this.state.selectedTerms.indexOf( event[ o ] ) === -1 ) {\n text = event[ o ];\n }\n }\n }\n else {\n // removed.\n for ( let o in this.state.selectedTerms ) {\n if ( event.indexOf( this.state.selectedTerms[ o ] ) === -1 ) {\n text = this.state.selectedTerms[ o ];\n }\n }\n }\n\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].name === text ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n }\n\n getId( item ) {\n return `${ this.props.slug }:${ item.id }`;\n }\n\n makeElement( item ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li\n .addClass( 'cld-tax-order-list-item' )\n .attr( 'data-item', this.getId( item ) );\n\n input\n .addClass( 'cld-tax-order-list-item-input' )\n .attr( 'type', 'hidden' )\n .attr( 'name', 'cld_tax_order[]' ).val( this.getId( item ) );\n\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( item.name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n }\n }\n\n return ( props ) => el( CustomHandler, props );\n };\n\n wp.hooks.addFilter(\n 'editor.PostTaxonomyType',\n 'cld',\n CustomizeTaxonomySelector\n );\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Terms_Order);\n\n\n//# sourceURL=webpack:///./js/src/components/terms_order.js?"); + +/***/ }), + +/***/ "./js/src/components/widget.js": +/*!*************************************!*\ + !*** ./js/src/components/widget.js ***! + \*************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("/* global window wp Backbone */\nif ( wp.media && window.CLDN ) {\n\n\twp.media.events.on( 'editor:image-edit', function( props ){\n\t\tprops.metadata.cldoverwrite = null;\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( classes.indexOf('cld-overwrite' ) >= 0 ){\n\t\t\tprops.metadata.cldoverwrite = 'true';\n\t\t}\n\t} );\n\twp.media.events.on( 'editor:image-update', function( props ){\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) === -1 ) {\n\t\t\tclasses.push( 'cld-overwrite' );\n\t\t} else if( ! props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) >= 0 ) {\n\t\t\tdelete classes[ classes.indexOf('cld-overwrite' ) ];\n\t\t}\n\n\t\tprops.image.className = classes.join( ' ' );\n\t} );\n\n\t// Intercept props and inject cld-overwrite class.\n\tlet currentOverwrite = null;\n\tlet imageProps = wp.media.string.props;\n\twp.media.string.props = function( props, asset ){\n\t\tif( props.cldoverwrite ){\n\t\t\tprops.classes = [ 'cld-overwrite' ];\n\t\t\tcurrentOverwrite = true;\n\t\t}\n\t\tlet newProps = imageProps( props, asset );\n\t\treturn newProps;\n\t}\n\t// Intercept ajax post, and send the cld-overwrite flag, and transformations.\n\twp.media.post = function( action, data ) {\n\n\t\tif ( 'send-attachment-to-editor' === action ) {\n\t\t\tlet state = wp.media.editor.get().state();\n\t\t\tlet attach = state.get( 'selection' ).get( data.attachment );\n\t\t\tif ( attach.attributes.transformations ) {\n\t\t\t\tdata.attachment.transformations = attach.attributes.transformations;\n\t\t\t}\n\t\t\tif( data.html.indexOf('cld-overwrite') > -1 || true === currentOverwrite ){\n\t\t\t\tdata.attachment.cldoverwrite = true;\n\t\t\t\tcurrentOverwrite = null;\n\t\t\t}\n\n\t\t}\n\t\t// Return the original.\n\t\treturn wp.ajax.post( action, data );\n\t};\n\n\tlet Library = wp.media.controller.Library;\n\tlet MediaFrame = wp.media.view.MediaFrame.Select;\n\tlet MediaFramePost = wp.media.view.MediaFrame.Post;\n\tlet MediaFrameImageDetails = wp.media.view.MediaFrame.ImageDetails;\n\tlet MediaFrameVideoDetails = wp.media.view.MediaFrame.VideoDetails;\n\tlet Cloudinary = wp.media.View.extend( {\n\t\ttagName: 'div',\n\t\tclassName: 'cloudinary-widget',\n\t\ttemplate: wp.template( 'cloudinary-dam' ),\n\t\tactive: false,\n\t\ttoolbar: null,\n\t\tframe: null,\n\t\tready: function() {\n\t\t\tlet controller = this.controller;\n\t\t\tlet selection = this.model.get( 'selection' );\n\t\t\tlet library = this.model.get( 'library' );\n\t\t\tlet attachment = wp.media.model.Attachment;\n\t\t\t// Set widget to same as model.\n\t\t\tCLDN.mloptions.multiple = controller.options.multiple;\n\t\t\tif ( this.cid !== this.active ) {\n\t\t\t\tCLDN.mloptions.inline_container = '#cloudinary-dam-' + controller.cid;\n\t\t\t\tif ( 1 === selection.length ) {\n\t\t\t\t\tvar att = attachment.get( selection.models[ 0 ].id );\n\t\t\t\t\tif ( typeof att.attributes.public_id !== 'undefined' ) {\n\t\t\t\t\t\tCLDN.mloptions.asset = {resource_id: att.attributes.public_id };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tCLDN.mloptions.asset = null;\n\t\t\t\t}\n\t\t\t\twindow.ml = cloudinary.openMediaLibrary( CLDN.mloptions, {\n\t\t\t\t\t\tinsertHandler: function( data ) {\n\t\t\t\t\t\t\tfor (let i = 0; i < data.assets.length; i++) {\n\t\t\t\t\t\t\t\tlet temp = data.assets[ i ];\n\t\t\t\t\t\t\t\twp.media.post( 'cloudinary-down-sync', {\n\t\t\t\t\t\t\t\t\tnonce: CLDN.nonce,\n\t\t\t\t\t\t\t\t\tasset: temp,\n\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\tlet update_asset = function( asset, attach ){\n\t\t\t\t\t\t\t\t\t\tasset.uploading = false;\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.remove( attach );\n\t\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( typeof asset.fetch !== 'undefined' ) {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.attachment_id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tlibrary.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.ajax.send( {\n\t\t\t\t\t\t\t\t\t\t\turl: asset.fetch,\n\t\t\t\t\t\t\t\t\t\t\tbeforeSend: function( request ) {\n\t\t\t\t\t\t\t\t\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', CLDN.nonce );\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\t\tsrc: asset.url,\n\t\t\t\t\t\t\t\t\t\t\t\tfilename: asset.filename,\n\t\t\t\t\t\t\t\t\t\t\t\tattachment_id: asset.attachment_id,\n\t\t\t\t\t\t\t\t\t\t\t\ttransformations: asset.transformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t} ).fail( function( data ) {\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t\tlibrary.remove( attach );\n\t\t\t\t\t\t\t\t\t\t\tselection.remove( attach );\n\n\t\t\t\t\t\t\t\t\t\t\tif( typeof data === 'string' ) {\n\t\t\t\t\t\t\t\t\t\t\t\talert( data );\n\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t\tif( data.status === 500 ){\n\t\t\t\t\t\t\t\t\t\t\t\t\talert('HTTP error.');\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tselection.add( attach );\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontroller.content.mode( 'browse' );\n\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tdocument.querySelectorAll( '.dam-cloudinary' )[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.active = this.cid;\n\t\t\treturn this;\n\t\t},\n\t} );\n\tlet extend_type = function( type ) {\n\t\tlet obj = {\n\n\t\t\t/**\n\t\t\t * Bind region mode event callbacks.\n\t\t\t *\n\t\t\t * @see media.controller.Region.render\n\t\t\t */\n\t\t\tbindHandlers: function() {\n\t\t\t\ttype.prototype.bindHandlers.apply( this, arguments );\n\t\t\t\tthis.on( 'content:render:cloudinary', this.cloudinaryContent, this );\n\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Render callback for the router region in the `browse` mode.\n\t\t\t *\n\t\t\t * @param {wp.media.view.Router} routerView\n\t\t\t */\n\t\t\tbrowseRouter: function( routerView ) {\n\n\t\t\t\ttype.prototype.browseRouter.apply( this, arguments );\n\t\t\t\tlet state_id = this.state().get( 'id' );\n\t\t\t\trouterView.set( {\n\t\t\t\t\tcloudinary: {\n\t\t\t\t\t\ttext: 'Cloudinary',\n\t\t\t\t\t\tpriority: 60\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t/**\n\t\t\t * Render callback for the content region in the `upload` mode.\n\t\t\t */\n\t\t\tcloudinaryContent: function( contentRegion ) {\n\t\t\t\tlet state = this.state();\n\t\t\t\tlet view = new Cloudinary( {\n\t\t\t\t\tcontroller: this,\n\t\t\t\t\tmodel: state,\n\t\t\t\t} ).render();\n\t\t\t\tthis.content.set( view );\n\t\t\t},\n\t\t};\n\n\t\treturn obj;\n\t};\n\t// Extending the current media library frames to add a new tab to each area.\n\twp.media.view.MediaFrame.Select = MediaFrame.extend( extend_type( MediaFrame ) );\n\twp.media.view.MediaFrame.Post = MediaFramePost.extend( extend_type( MediaFramePost ) );\n\twp.media.view.MediaFrame.ImageDetails = MediaFrameImageDetails.extend( extend_type( MediaFrameImageDetails ) );\n\twp.media.view.MediaFrame.VideoDetails = MediaFrameVideoDetails.extend( extend_type( MediaFrameVideoDetails ) );\n\n}\n\n\n//# sourceURL=webpack:///./js/src/components/widget.js?"); + +/***/ }), + +/***/ "./js/src/main.js": +/*!************************!*\ + !*** ./js/src/main.js ***! + \************************/ +/*! exports provided: cloudinary */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"cloudinary\", function() { return cloudinary; });\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/settings-page */ \"./js/src/components/settings-page.js\");\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_components_settings_page__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _components_sync__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/sync */ \"./js/src/components/sync.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/widget */ \"./js/src/components/widget.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_components_widget__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/global-transformations */ \"./js/src/components/global-transformations.js\");\n/* harmony import */ var _components_terms_order__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/terms_order */ \"./js/src/components/terms_order.js\");\n/* harmony import */ var _components_media_library__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/media-library */ \"./js/src/components/media-library.js\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../css/src/main.scss */ \"./css/src/main.scss\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__);\n/* global window */\n/**\n * Main JS.\n */\n\n// Components\n\n\n\n\n\n\n\n\n\n// jQuery, because reasons.\nconst $ = window.$ = window.jQuery;\n\n// Global Constants\nconst cloudinary = {\n\tsettings: (_components_settings_page__WEBPACK_IMPORTED_MODULE_0___default()),\n\tsync: _components_sync__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n\twidget: (_components_widget__WEBPACK_IMPORTED_MODULE_2___default()),\n\tGlobal_Transformations: _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n\tTerms_Order: _components_terms_order__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n\tMedia_Library: _components_media_library__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n};\n\n\n\n//# sourceURL=webpack:///./js/src/main.js?"); + +/***/ }) + +/******/ }); \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js index acbed1bb3..3deccf322 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/src/components/settings-page.js @@ -5,15 +5,15 @@ const disableAutoplayOff = function() { const player = jQuery( '#field-video_player' ).val(); const showControls = jQuery( '#field-video_controls' ).prop( 'checked' ); + const offSelection = jQuery( '#field-video_autoplay_mode option[value="off"]' ); - if ( player === 'cld' && showControls ) { - jQuery( '#field-video_autoplay_mode option[value="off"]' ) - .attr( 'disabled', 'disabled' ) - .prop( 'disabled', 'disabled' ); + if ( player === 'cld' && ! showControls ) { + offSelection.prop( 'disabled', true ); + if ( offSelection.prop( 'selected' ) ) { + offSelection.next().prop( 'selected', true ); + } } else { - jQuery( '#field-video_autoplay_mode option[value="off"]' ) - .removeAttr( 'disabled' ) - .prop( 'disabled', false ); + offSelection.prop( 'disabled', false ); } } From dac7a5ca3044ac0a36053b6a7a73612fd96fac9b Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Sat, 23 May 2020 16:28:29 -0400 Subject: [PATCH 03/28] Production build js assets --- .../css/cloudinary.css | 339 +---------------- .../js/block-editor.js | 353 +----------------- .../js/cloudinary.js | 183 +-------- 3 files changed, 3 insertions(+), 872 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css index ec9c7c7c4..ab2783e7d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css @@ -1,338 +1 @@ -@font-face { - font-family: 'cloudinary'; - src: url(../css/fonts/cloudinary.eot); - src: url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"), url(../css/fonts/cloudinary.ttf) format("truetype"), url(../css/fonts/cloudinary.woff) format("woff"), url(../css/cloudinary.svg#cloudinary) format("svg"); - font-weight: normal; - font-style: normal; } - -.dashicons-cloudinary { - /* use !important to prevent issues with browser extensions that change fonts */ - speak: none; - font-style: normal; - font-weight: normal; - font-variant: normal; - text-transform: none; - line-height: 1; - /* Better Font Rendering =========== */ - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; } - .dashicons-cloudinary:before { - font-family: 'cloudinary' !important; - content: '\e900'; } - .dashicons-cloudinary.success { - color: #558b2f; } - .dashicons-cloudinary.error { - color: #dd2c00; } - .dashicons-cloudinary.error:before { - content: '\e901'; } - .dashicons-cloudinary.warning { - color: #fd9d2c; } - .dashicons-cloudinary.warning:before { - content: '\e902'; } - .dashicons-cloudinary.warning { - color: #fd9d2c; } - .dashicons-cloudinary.warning { - color: #fd9d2c; } - -.column-cld_status { - width: 5.5em; } - .column-cld_status .dashicons-cloudinary { - display: inline-block; } - .column-cld_status .dashicons-cloudinary:before { - font-size: 1.8rem; } - -.form-field .error-notice, .form-table .error-notice { - display: none; - color: #dd2c00; } - -.form-field input.cld-field:invalid, .form-table input.cld-field:invalid { - border-color: #dd2c00; } - .form-field input.cld-field:invalid + .error-notice, .form-table input.cld-field:invalid + .error-notice { - display: inline-block; } - -.cloudinary-welcome { - background-image: url(../css/logo.svg); - background-repeat: no-repeat; - background-size: 153px; - background-position: top 12px right 20px; } - -.cloudinary-stats { - display: inline-block; - margin-left: 25px; } - -.cloudinary-stat { - cursor: help; } - -.cloudinary-percent { - font-size: 0.8em; - vertical-align: top; - color: #0078ff; } - -.settings-image { - max-width: 100%; - padding-top: 5px; } - -.settings-tabs > li { - display: inline-block; } - .settings-tabs > li a { - padding: .6em; } - .settings-tabs > li a.active { - background-color: #ffffff; } - -.settings-tab-section { - padding: 20px 0 0 0; - max-width: 1030px; - position: relative; } - .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard { - display: flex; - align-items: flex-start; - align-content: flex-start; - margin-top: 40px; } - .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description { - width: 55%; - margin: 0 auto 0 0; } - .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content { - width: 35%; - margin: 0 auto; } - .settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons { - color: #9EA3A8; } - .settings-tab-section.cloudinary-welcome .settings-tab-section-card { - margin-top: 0; } - .settings-tab-section-fields .field-heading th { - display: block; - width: auto; - color: #23282d; - font-size: 1.1em; - margin: 1em 0; } - .settings-tab-section-fields .field-heading td { - display: none; - visibility: hidden; } - .settings-tab-section-fields .regular-textarea { - width: 100%; - height: 60px; } - .settings-tab-section-fields .dashicons { - text-decoration: none; - vertical-align: middle; } - .settings-tab-section-fields a .dashicons { - color: #5F5F5F; } - .settings-tab-section-fields-dashboard-error { - font-size: 1.2em; - color: #5F5F5F; } - .settings-tab-section-fields-dashboard-error .dashicons { - color: #AC0000; } - .settings-tab-section-fields-dashboard-error .button { - font-size: 1.1em; - height: 40px; - line-height: 40px; - padding-right: 40px; - padding-left: 40px; } - .settings-tab-section-fields-dashboard-success { - font-size: 1.2em; - color: #23282d; } - .settings-tab-section-fields-dashboard-success.expanded { - padding-top: 40px; } - .settings-tab-section-fields-dashboard-success .dashicons { - color: #4FB651; } - .settings-tab-section-fields-dashboard-success .button { - font-size: 1.1em; - height: 40px; - line-height: 40px; - padding-right: 40px; - padding-left: 40px; } - .settings-tab-section-fields-dashboard-success .description { - color: #5F5F5F; - font-weight: normal; - margin-top: 12px; } - .settings-tab-section-card { - box-sizing: border-box; - border: 1px solid #E5E5E5; - background-color: #FFFFFF; - box-shadow: 0 1px 1px 0 rgba(0, 0, 0, 0.07); - padding: 20px 23px; - margin-top: 12px; } - .settings-tab-section-card .dashicons { - font-size: 1.4em; } - .settings-tab-section-card h2 { - font-size: 1.8em; - font-weight: normal; - margin-top: 0; } - .settings-tab-section-card.pull-right { - width: 450px; - padding: 12px; - float: right; - position: relative; - z-index: 10; } - .settings-tab-section-card.pull-right img.settings-image { - box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.5); - border: 1px solid #979797; - margin-top: 12px; } - .settings-tab-section-card.pull-right h4, .settings-tab-section-card.pull-right h3 { - margin-top: 0; } - .settings-tab-section .field-row-cloudinary_url, .settings-tab-section .field-row-signup { - display: block; } - .settings-tab-section .field-row-cloudinary_url td, .settings-tab-section .field-row-cloudinary_url th, .settings-tab-section .field-row-signup td, .settings-tab-section .field-row-signup th { - display: block; - width: auto; - padding: 10px 0 0; } - .settings-tab-section .field-row-cloudinary_url td .sign-up, .settings-tab-section .field-row-cloudinary_url th .sign-up, .settings-tab-section .field-row-signup td .sign-up, .settings-tab-section .field-row-signup th .sign-up { - vertical-align: baseline; } - .settings-tab-section.connect .form-table { - display: inline-block; - width: auto; - max-width: 580px; } - -.settings-valid { - color: #558b2f; - font-size: 30px; } - .settings-valid-field { - border-color: #558b2f !important; } - -.settings-invalid-field { - border-color: #dd2c00 !important; } - -.sync .spinner { - display: inline-block; - visibility: visible; - float: none; - margin: 0 5px 0 0; } - -.sync-media { - display: none; } - .sync-media-progress { - display: none; } - .sync-media-progress-outer { - height: 20px; - margin: 20px 0 10px; - width: 500px; - background-color: #e5e5e5; - position: relative; } - .sync-media-progress-outer .progress-bar { - width: 0; - height: 20px; - background-color: #558b2f; - transition: width 250ms; } - .sync-media-progress-notice { - color: #dd2c00; } - .sync-media-resource { - width: 100px; - display: inline-block; } - .sync-media-error { - color: #dd2c00; } - -.sync-count { - font-weight: bold; } - -.sync-details { - margin-top: 10px; } - -.sync .button.stop-sync, .sync .button.start-sync { - display: none; - padding: 0 16px; } - .sync .button.stop-sync .dashicons, .sync .button.start-sync .dashicons { - line-height: 2.2em; } - -.sync .progress-text { - padding: 12px 4px 12px 12px; - display: inline-block; - font-weight: bold; } - -.sync .completed { - max-width: 300px; - display: none; } - -.sync-status-disabled { - color: #dd2c00; } - -.sync-status-enabled { - color: #558b2f; } - -.sync-status-button.button { - vertical-align: baseline; } - -.cloudinary-widget { - height: 100%; } - .cloudinary-widget-wrapper { - height: 100%; - overflow: hidden; - background-image: url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxzdHlsZSB0eXBlPSJ0ZXh0L2NzcyI+PCFbQ0RBVEFbCiAgICAgIEBrZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhGRjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OEZGOyB9CiAgICAgIH0KCiAgICAgIEBrZXlmcmFtZXMgZGFzaCB7CiAgICAgICAwJSB7IHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgIDUwJSB7CiAgICAgICAgICBzdHJva2UtZGFzaG9mZnNldDogMDsKICAgICAgIH0KICAgICAgIDEwMCUgeyAgIHN0cm9rZS1kYXNob2Zmc2V0OiA1NjA7IH0KICAgICAgfQogICAgICBALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzIHsKICAgICAgICAwJSB7IHN0cm9rZTogIzAwNzhmZjsgfQogICAgICAgICAgNTAlIHsgc3Ryb2tlOiAjMGUyZjVhOyB9CiAgICAgICAgICAxMDAlIHsgc3Ryb2tlOiAjMDA3OGZmOyB9CiAgICAgIH0KCiAgICAgIEAtd2Via2l0LWtleWZyYW1lcyBkYXNoIHsKICAgICAgIDAlIHsgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsgfQogICAgICAgNTAlIHsKICAgICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgfQogICAgICAgMTAwJSB7ICAgc3Ryb2tlLWRhc2hvZmZzZXQ6IDU2MDsKICAgICAgIH0KICAgICAgfQogICAgICAucGF0aCB7CiAgICAgICAgc3Ryb2tlLWRhc2hhcnJheTogMjgwOwogICAgICAgIHN0cm9rZS1kYXNob2Zmc2V0OiAwOwogICAgICAgIHRyYW5zZm9ybS1vcmlnaW46IGNlbnRlcjsKICAgICAgICAtd2Via2l0LWFuaW1hdGlvbjoKICAgICAgICAgIGRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsIGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZTsKICAgICAgICBhbmltYXRpb246CiAgICAgICAgICBkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLCBjb2xvcnMgOHMgZWFzZS1pbi1vdXQgaW5maW5pdGU7CiAgICAgIH0KICAgIF1dPjwvc3R5bGU+CiAgPHBhdGggY2xhc3M9InBhdGgiIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPgo8L3N2Zz4K"); - background-repeat: no-repeat; - background-position: center; - background-size: 150px; } - -.attachment-info .edit-attachment { - display: none; } - -.attachment-actions .button.edit-attachment { - display: none; } - -.global-transformations-preview { - position: relative; - max-width: 600px; } - -.global-transformations-spinner { - display: none; } - -.global-transformations-button.button-primary { - display: none; - position: absolute; - z-index: 100; } - -.global-transformations-url { - margin-bottom: 5px; - margin-top: 5px; } - .global-transformations-url-transformation { - max-width: 100px; - overflow: hidden; - text-overflow: ellipsis; - color: #51A3FF; } - .global-transformations-url-file { - color: #f2d864; } - .global-transformations-url-link { - display: block; - padding: 16px; - background-color: #262c35; - text-decoration: none; - color: #fff; - border-radius: 6px; - overflow: hidden; - text-overflow: ellipsis; } - .global-transformations-url-link:hover { - color: #888888; - text-decoration: underline; } - -.cld-tax-order-list-item { - border: 1px solid #efefef; - padding: 4px; - margin: 0 0 -1px; - background-color: #ffffff; } - .cld-tax-order-list-item.no-items { - color: #888; - text-align: center; - display: none; } - .cld-tax-order-list-item.no-items:last-child { - display: block; } - .cld-tax-order-list-item.ui-sortable-helper { - box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); } - .cld-tax-order-list-item-placeholder { - background-color: #efefef; - height: 45px; - margin: 0; } - .cld-tax-order-list-item-handle { - cursor: grab; - margin-right: 4px; - color: #999; } - -.cld-tax-order-list-type { - width: 45%; - display: inline-block; - margin-right: 8px; } - .cld-tax-order-list-type input { - margin-right: 4px !important; } - -.cloudinary-media-library { - position: relative; - margin-left: -20px; } - @media screen and (max-width: 782px) { - .cloudinary-media-library { - margin-left: -10px; } } - +@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.eot);src:url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.ttf) format("truetype"),url(../css/fonts/cloudinary.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.warning:before{content:"\e902"}.dashicons-cloudinary.warning{color:#fd9d2c}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0078ff}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js index f3bce37b8..38488de8c 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/block-editor.js @@ -1,352 +1 @@ -/******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = "./js/src/blocks.js"); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ "./js/src/blocks.js": -/*!**************************!*\ - !*** ./js/src/blocks.js ***! - \**************************/ -/*! exports provided: cloudinaryBlocks */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cloudinaryBlocks", function() { return cloudinaryBlocks; }); -/* harmony import */ var _components_video__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/video */ "./js/src/components/video.js"); -/* global window */ - -/** - * Main JS. - */ -// Components - // jQuery, because reasons. - -var $ = window.$ = window.jQuery; // Global Constants - -var cloudinaryBlocks = { - Video: _components_video__WEBPACK_IMPORTED_MODULE_0__["default"] -}; - -/***/ }), - -/***/ "./js/src/components/video.js": -/*!************************************!*\ - !*** ./js/src/components/video.js ***! - \************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @babel/runtime/helpers/objectSpread */ "./node_modules/@babel/runtime/helpers/objectSpread.js"); -/* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @wordpress/element */ "@wordpress/element"); -/* harmony import */ var _wordpress_element__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @wordpress/i18n */ "@wordpress/i18n"); -/* harmony import */ var _wordpress_i18n__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @wordpress/data */ "@wordpress/data"); -/* harmony import */ var _wordpress_data__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @wordpress/components */ "@wordpress/components"); -/* harmony import */ var _wordpress_components__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__); - - - -/* global window wp */ - - - - -var Video = { - _init: function _init() { - if (typeof CLD_VIDEO_PLAYER === 'undefined') { - return; - } // Gutenberg Video Settings - - - wp.hooks.addFilter('blocks.registerBlockType', 'Cloudinary/Media/Video', function (settings, name) { - if (name === 'core/video') { - if ('off' !== CLD_VIDEO_PLAYER.video_autoplay_mode) { - settings.attributes.autoplay.default = true; - } - - if ('on' === CLD_VIDEO_PLAYER.video_loop) { - settings.attributes.loop.default = true; - } - - if ('off' === CLD_VIDEO_PLAYER.video_controls) { - settings.attributes.controls.default = false; - } - } - - return settings; - }); - } -}; -/* harmony default export */ __webpack_exports__["default"] = (Video); // Init. - -Video._init(); - -var cldAddToggle = function cldAddToggle(settings, name) { - if ('core/image' === name || 'core/video' === name) { - if (!settings.attributes) { - settings.attributes = {}; - } - - settings.attributes.overwrite_transformations = { - type: 'boolean' - }; - settings.attributes.transformations = { - type: 'boolean' - }; - } - - return settings; -}; - -wp.hooks.addFilter('blocks.registerBlockType', 'cloudinary/addAttributes', cldAddToggle); -/** - * Get AMP Lightbox toggle control. - * - * @param {Object} props Props. - * - * @return {Component} Element. - */ - -var TransformationsToggle = function TransformationsToggle(props) { - var _props$attributes = props.attributes, - overwrite_transformations = _props$attributes.overwrite_transformations, - transformations = _props$attributes.transformations, - setAttributes = props.setAttributes; - return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["PanelBody"], { - title: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Transformations', 'cloudinary') - }, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_components__WEBPACK_IMPORTED_MODULE_4__["ToggleControl"], { - label: Object(_wordpress_i18n__WEBPACK_IMPORTED_MODULE_2__["__"])('Overwrite Transformations', 'cloudinary'), - checked: overwrite_transformations, - onChange: function onChange(value) { - setAttributes({ - overwrite_transformations: value - }); - } - })); -}; - -var ImageInspectorControls = function ImageInspectorControls(props) { - var setAttributes = props.setAttributes, - media = props.media; - var InspectorControls = wp.editor.InspectorControls; - - if (media && media.transformations) { - setAttributes({ - transformations: true - }); - } - - return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(InspectorControls, null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(TransformationsToggle, props)); -}; - -ImageInspectorControls = Object(_wordpress_data__WEBPACK_IMPORTED_MODULE_3__["withSelect"])(function (select, ownProps) { - return _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({}, ownProps, { - media: ownProps.attributes.id ? select('core').getMedia(ownProps.attributes.id) : null - }); -})(ImageInspectorControls); - -var cldFilterBlocksEdit = function cldFilterBlocksEdit(BlockEdit) { - return function (props) { - var name = props.name; - var shouldDisplayInspector = 'core/image' === name || 'core/video' === name; - return Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["Fragment"], null, shouldDisplayInspector ? Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(ImageInspectorControls, props) : null, Object(_wordpress_element__WEBPACK_IMPORTED_MODULE_1__["createElement"])(BlockEdit, props)); - }; -}; - -wp.hooks.addFilter('editor.BlockEdit', 'cloudinary/filterEdit', cldFilterBlocksEdit, 20); - -/***/ }), - -/***/ "./node_modules/@babel/runtime/helpers/defineProperty.js": -/*!***************************************************************!*\ - !*** ./node_modules/@babel/runtime/helpers/defineProperty.js ***! - \***************************************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -module.exports = _defineProperty; - -/***/ }), - -/***/ "./node_modules/@babel/runtime/helpers/objectSpread.js": -/*!*************************************************************!*\ - !*** ./node_modules/@babel/runtime/helpers/objectSpread.js ***! - \*************************************************************/ -/*! no static exports found */ -/***/ (function(module, exports, __webpack_require__) { - -var defineProperty = __webpack_require__(/*! ./defineProperty */ "./node_modules/@babel/runtime/helpers/defineProperty.js"); - -function _objectSpread(target) { - for (var i = 1; i < arguments.length; i++) { - var source = arguments[i] != null ? Object(arguments[i]) : {}; - var ownKeys = Object.keys(source); - - if (typeof Object.getOwnPropertySymbols === 'function') { - ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { - return Object.getOwnPropertyDescriptor(source, sym).enumerable; - })); - } - - ownKeys.forEach(function (key) { - defineProperty(target, key, source[key]); - }); - } - - return target; -} - -module.exports = _objectSpread; - -/***/ }), - -/***/ "@wordpress/components": -/*!*********************************************!*\ - !*** external {"this":["wp","components"]} ***! - \*********************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["components"]; }()); - -/***/ }), - -/***/ "@wordpress/data": -/*!***************************************!*\ - !*** external {"this":["wp","data"]} ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["data"]; }()); - -/***/ }), - -/***/ "@wordpress/element": -/*!******************************************!*\ - !*** external {"this":["wp","element"]} ***! - \******************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["element"]; }()); - -/***/ }), - -/***/ "@wordpress/i18n": -/*!***************************************!*\ - !*** external {"this":["wp","i18n"]} ***! - \***************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -(function() { module.exports = this["wp"]["i18n"]; }()); - -/***/ }) - -/******/ }); -//# sourceMappingURL=block-editor.js.map \ No newline at end of file +!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=6)}([function(t,e){!function(){t.exports=this.wp.element}()},function(t,e){!function(){t.exports=this.wp.i18n}()},function(t,e){!function(){t.exports=this.wp.components}()},function(t,e,r){var n=r(5);t.exports=function(t){for(var e=1;e= 100 && typeof data.started !== 'undefined' ) {\n\t\t\tthis.submitButton.style.display = this.hide;\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse if ( data.pending > 0 ) {\n\t\t\tthis.submitButton.style.display = this.show;\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\t\telse if ( data.processing > 0 ) {\n\t\t\tthis.stopButton.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.stopButton.style.display = this.hide;\n\t\t}\n\n\t\tif ( data.percent < 100 ) {\n\t\t\tthis.barSyncCount.innerText = data.total;\n\t\t\tthis.progressCount.innerText = data.done;\n\t\t\tthis.progress.style.display = this.show;\n\t\t}\n\t\telse {\n\t\t\tthis.completed.style.display = this.show;\n\t\t\tthis.progress.style.display = this.hide;\n\t\t}\n\t},\n\t_start: function _start( e ) {\n\t\te.preventDefault();\n\t\tSync.stopButton.style.display = Sync.show;\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.pushAttachments();\n\t},\n\t_reset: function _reset( e ) {\n\t\tSync.submitButton.style.display = Sync.hide;\n\t\tSync.getStatus();\n\t},\n\t_init: function( fn ) {\n\n\t\tif ( typeof cloudinaryApi !== 'undefined' ) {\n\t\t\tif ( document.attachEvent ? document.readyState === 'complete' : document.readyState !== 'loading' ) {\n\t\t\t\tfn();\n\t\t\t}\n\t\t\telse {\n\t\t\t\tdocument.addEventListener( 'DOMContentLoaded', fn );\n\t\t\t}\n\t\t}\n\t},\n};\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Sync);\n\n// Init.\nSync._init( function() {\n\tSync._reset();\n\tSync.submitButton.addEventListener( 'click', Sync._start );\n\tSync.stopButton.addEventListener( 'click', Sync.stopSync );\n} );\n\n\n//# sourceURL=webpack:///./js/src/components/sync.js?"); - -/***/ }), - -/***/ "./js/src/components/terms_order.js": -/*!******************************************!*\ - !*** ./js/src/components/terms_order.js ***! - \******************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* global window wp wpAjax */\n\nconst Terms_Order = {\n template: '',\n tags: jQuery( '#cld-tax-items' ),\n tagDelimiter: ( window.tagsSuggestL10n && window.tagsSuggestL10n.tagDelimiter ) || ',',\n startId: null,\n _init: function() {\n // Check that we found the tax-items.\n if ( !this.tags.length ) {\n return;\n }\n\n const self = this;\n this._sortable();\n\n // Setup ajax overrides.\n if ( typeof wpAjax !== 'undefined' ) {\n wpAjax.procesParseAjaxResponse = wpAjax.parseAjaxResponse;\n wpAjax.parseAjaxResponse = function( response, settingsResponse, element ) {\n let newResponse = wpAjax.procesParseAjaxResponse( response, settingsResponse, element );\n if ( !newResponse.errors && newResponse.responses[ 0 ] ) {\n if ( jQuery( '[data-taxonomy=\"' + newResponse.responses[ 0 ].what + '\"]' ).length ) {\n const data = jQuery( newResponse.responses[ 0 ].data );\n const text = data.find( 'label' ).last().text().trim();\n self._pushItem( newResponse.responses[ 0 ].what, text );\n }\n }\n\n return newResponse;\n };\n }\n\n if ( typeof window.tagBox !== 'undefined' ) {\n window.tagBox.processflushTags = window.tagBox.flushTags;\n window.tagBox.flushTags = function( el, a, f ) {\n if ( typeof f === 'undefined' ) {\n let text, list;\n const taxonomy = el.prop( 'id' );\n const newTag = jQuery( 'input.newtag', el );\n\n a = a || false;\n\n text = a ? jQuery( a ).text() : newTag.val();\n list = window.tagBox.clean( text ).split( self.tagDelimiter );\n for ( var i in list ) {\n var tag = taxonomy + ':' + list[ i ];\n if ( !jQuery( '[data-item=\"' + tag + '\"]' ).length ) {\n self._pushItem( tag, list[ i ] );\n }\n }\n }\n\n return this.processflushTags( el, a, f );\n };\n\n window.tagBox.processTags = window.tagBox.parseTags;\n\n window.tagBox.parseTags = function( el ) {\n const id = el.id;\n const num = id.split( '-check-num-' )[ 1 ];\n const taxonomy = id.split( '-check-num-' )[ 0 ];\n const taxBox = jQuery( el ).closest( '.tagsdiv' );\n const tagsTextarea = taxBox.find( '.the-tags' );\n const tagToRemove = window.tagBox.clean( tagsTextarea.val() ).split( self.tagDelimiter )[ num ];\n\n new wp.api.collections.Tags()\n .fetch( { data: { slug: tagToRemove } } )\n .done( ( tag ) => {\n const tagFromDatabase = tag.length ? jQuery( '[data-item=\"' + taxonomy + ':' + tag[ 0 ].id + '\"]' ) : false;\n\n if ( tagFromDatabase.length ) {\n tagFromDatabase.remove();\n }\n else {\n jQuery( `.cld-tax-order-list-item:contains(${ tagToRemove })` ).remove();\n --self.startId;\n }\n this.processTags( el );\n } );\n };\n }\n\n jQuery( 'body' ).on( 'change', '.selectit input', function() {\n const clickedItem = jQuery( this );\n const id = clickedItem.val();\n const checked = clickedItem.is( ':checked' );\n const text = clickedItem.parent().text().trim();\n\n if ( true === checked ) {\n if( ! self.tags.find(`[data-item=\"category:${ id }\"]`).length ) {\n self._pushItem( `category:${ id }`, text );\n }\n }\n else {\n self.tags.find( `[data-item=\"category:${ id }\"]` ).remove();\n }\n } );\n },\n _createItem: function( id, name ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li.addClass( 'cld-tax-order-list-item' ).attr( 'data-item', id );\n input.addClass( 'cld-tax-order-list-item-input' ).attr( 'type', 'hidden' ).attr( 'name', 'cld_tax_order[]' ).val( id );\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n },\n _pushItem: function( id, text ) {\n let item = this._createItem( id, text );\n this.tags.append( item ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n },\n _sortable: function() {\n const items = jQuery( '.cld-tax-order-list' );\n\n items.sortable( {\n connectWith: '.cld-tax-order',\n axis: 'y',\n handle: '.cld-tax-order-list-item-handle',\n placeholder: 'cld-tax-order-list-item-placeholder',\n forcePlaceholderSize: true,\n helper: 'clone',\n } );\n }\n};\n\nif ( typeof window.CLDN !== 'undefined' ) {\n Terms_Order._init();\n // Init checked categories.\n jQuery( '[data-wp-lists] .selectit input[checked]' ).map( ( ord, check ) => {\n jQuery( check ).trigger( 'change' );\n } );\n}\n\n// Gutenberg.\nif ( wp.data && wp.data.select( 'core/editor' ) ) {\n const orderSet = {};\n wp.data.subscribe( function() {\n let taxonomies = wp.data.select( 'core' ).getTaxonomies();\n\n if ( taxonomies ) {\n for ( let t in taxonomies ) {\n const set = wp.data.select( 'core/editor' ).getEditedPostAttribute( taxonomies[ t ].rest_base );\n orderSet[ taxonomies[ t ].slug ] = set;\n }\n }\n } );\n\n const el = wp.element.createElement;\n const CustomizeTaxonomySelector = ( OriginalComponent ) => {\n class CustomHandler extends OriginalComponent {\n constructor( props ) {\n super( props );\n\n this.currentItems = jQuery( '.cld-tax-order-list-item' )\n .map( ( _, taxonomy ) => jQuery( taxonomy ).data( 'item' ) ).get();\n }\n\n makeItem( item ) {\n // Prevent duplicates in the tax order box\n if ( this.currentItems.includes( this.getId( item ) ) ) {\n return;\n }\n\n const row = this.makeElement( item );\n const box = jQuery( '#cld-tax-items' );\n box.append( row ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n }\n\n removeItem( item ) {\n const elementWithId = jQuery( `[data-item=\"${ this.getId( item ) }\"]` );\n\n if ( elementWithId.length ) {\n elementWithId.remove();\n\n this.currentItems = this.currentItems.filter( ( taxIdentifier ) => {\n return taxIdentifier !== this.getId( item );\n } );\n }\n }\n\n findOrCreateTerm( termName ) {\n termName = super.findOrCreateTerm( termName );\n termName.then( ( item ) => this.makeItem( item ) );\n\n return termName;\n }\n\n onChange( event ) {\n super.onChange( event );\n const item = this.pickItem( event );\n\n if ( item ) {\n if ( orderSet[ this.props.slug ].includes( item.id ) ) {\n this.makeItem( item );\n }\n else {\n this.removeItem( item );\n }\n }\n }\n\n pickItem( event ) {\n if ( typeof event === 'object' ) {\n if ( event.target ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === parseInt( event.target.value ) ) {\n return this.state.availableTerms[ p ];\n }\n }\n // Tags that are already registered need to be selected\n // separately as its expected that they return back\n // with an \"id\" property.\n }\n else if ( Array.isArray( event ) ) {\n // Figure out the diff between the current state and\n // the event and determine which tag is getting removed\n let enteredTag = this.state.selectedTerms.filter( flatItem => !event.includes( flatItem ) )[ 0 ];\n\n if ( typeof enteredTag === 'undefined' ) {\n // If the above returns undefined, then we presume\n // the user is adding, so reverse the logic to\n // figure out the new item\n enteredTag = event.filter( flatItem => !this.state.selectedTerms.includes( flatItem ) )[ 0 ];\n }\n\n return this.state.availableTerms.find( ( item ) => item.name === enteredTag );\n }\n }\n else if ( typeof event === 'number' ) {\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].id === event ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n else {\n let text;\n\n // add or remove.\n if ( event.length > this.state.selectedTerms.length ) {\n // Added.\n for ( let o in event ) {\n if ( this.state.selectedTerms.indexOf( event[ o ] ) === -1 ) {\n text = event[ o ];\n }\n }\n }\n else {\n // removed.\n for ( let o in this.state.selectedTerms ) {\n if ( event.indexOf( this.state.selectedTerms[ o ] ) === -1 ) {\n text = this.state.selectedTerms[ o ];\n }\n }\n }\n\n for ( let p in this.state.availableTerms ) {\n if ( this.state.availableTerms[ p ].name === text ) {\n return this.state.availableTerms[ p ];\n }\n }\n }\n }\n\n getId( item ) {\n return `${ this.props.slug }:${ item.id }`;\n }\n\n makeElement( item ) {\n const li = jQuery( '
  • ' );\n const icon = jQuery( '' );\n const input = jQuery( '' );\n\n li\n .addClass( 'cld-tax-order-list-item' )\n .attr( 'data-item', this.getId( item ) );\n\n input\n .addClass( 'cld-tax-order-list-item-input' )\n .attr( 'type', 'hidden' )\n .attr( 'name', 'cld_tax_order[]' ).val( this.getId( item ) );\n\n icon.addClass( 'dashicons dashicons-menu cld-tax-order-list-item-handle' );\n\n li.append( icon ).append( item.name ).append( input ); // phpcs:ignore\n // WordPressVIPMinimum.JS.HTMLExecutingFunctions.append\n\n return li;\n }\n }\n\n return ( props ) => el( CustomHandler, props );\n };\n\n wp.hooks.addFilter(\n 'editor.PostTaxonomyType',\n 'cld',\n CustomizeTaxonomySelector\n );\n}\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (Terms_Order);\n\n\n//# sourceURL=webpack:///./js/src/components/terms_order.js?"); - -/***/ }), - -/***/ "./js/src/components/widget.js": -/*!*************************************!*\ - !*** ./js/src/components/widget.js ***! - \*************************************/ -/*! no static exports found */ -/***/ (function(module, exports) { - -eval("/* global window wp Backbone */\nif ( wp.media && window.CLDN ) {\n\n\twp.media.events.on( 'editor:image-edit', function( props ){\n\t\tprops.metadata.cldoverwrite = null;\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( classes.indexOf('cld-overwrite' ) >= 0 ){\n\t\t\tprops.metadata.cldoverwrite = 'true';\n\t\t}\n\t} );\n\twp.media.events.on( 'editor:image-update', function( props ){\n\t\tlet classes = props.image.className.split( ' ' );\n\t\tif( props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) === -1 ) {\n\t\t\tclasses.push( 'cld-overwrite' );\n\t\t} else if( ! props.metadata.cldoverwrite && classes.indexOf('cld-overwrite' ) >= 0 ) {\n\t\t\tdelete classes[ classes.indexOf('cld-overwrite' ) ];\n\t\t}\n\n\t\tprops.image.className = classes.join( ' ' );\n\t} );\n\n\t// Intercept props and inject cld-overwrite class.\n\tlet currentOverwrite = null;\n\tlet imageProps = wp.media.string.props;\n\twp.media.string.props = function( props, asset ){\n\t\tif( props.cldoverwrite ){\n\t\t\tprops.classes = [ 'cld-overwrite' ];\n\t\t\tcurrentOverwrite = true;\n\t\t}\n\t\tlet newProps = imageProps( props, asset );\n\t\treturn newProps;\n\t}\n\t// Intercept ajax post, and send the cld-overwrite flag, and transformations.\n\twp.media.post = function( action, data ) {\n\n\t\tif ( 'send-attachment-to-editor' === action ) {\n\t\t\tlet state = wp.media.editor.get().state();\n\t\t\tlet attach = state.get( 'selection' ).get( data.attachment );\n\t\t\tif ( attach.attributes.transformations ) {\n\t\t\t\tdata.attachment.transformations = attach.attributes.transformations;\n\t\t\t}\n\t\t\tif( data.html.indexOf('cld-overwrite') > -1 || true === currentOverwrite ){\n\t\t\t\tdata.attachment.cldoverwrite = true;\n\t\t\t\tcurrentOverwrite = null;\n\t\t\t}\n\n\t\t}\n\t\t// Return the original.\n\t\treturn wp.ajax.post( action, data );\n\t};\n\n\tlet Library = wp.media.controller.Library;\n\tlet MediaFrame = wp.media.view.MediaFrame.Select;\n\tlet MediaFramePost = wp.media.view.MediaFrame.Post;\n\tlet MediaFrameImageDetails = wp.media.view.MediaFrame.ImageDetails;\n\tlet MediaFrameVideoDetails = wp.media.view.MediaFrame.VideoDetails;\n\tlet Cloudinary = wp.media.View.extend( {\n\t\ttagName: 'div',\n\t\tclassName: 'cloudinary-widget',\n\t\ttemplate: wp.template( 'cloudinary-dam' ),\n\t\tactive: false,\n\t\ttoolbar: null,\n\t\tframe: null,\n\t\tready: function() {\n\t\t\tlet controller = this.controller;\n\t\t\tlet selection = this.model.get( 'selection' );\n\t\t\tlet library = this.model.get( 'library' );\n\t\t\tlet attachment = wp.media.model.Attachment;\n\t\t\t// Set widget to same as model.\n\t\t\tCLDN.mloptions.multiple = controller.options.multiple;\n\t\t\tif ( this.cid !== this.active ) {\n\t\t\t\tCLDN.mloptions.inline_container = '#cloudinary-dam-' + controller.cid;\n\t\t\t\tif ( 1 === selection.length ) {\n\t\t\t\t\tvar att = attachment.get( selection.models[ 0 ].id );\n\t\t\t\t\tif ( typeof att.attributes.public_id !== 'undefined' ) {\n\t\t\t\t\t\tCLDN.mloptions.asset = {resource_id: att.attributes.public_id };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tCLDN.mloptions.asset = null;\n\t\t\t\t}\n\t\t\t\twindow.ml = cloudinary.openMediaLibrary( CLDN.mloptions, {\n\t\t\t\t\t\tinsertHandler: function( data ) {\n\t\t\t\t\t\t\tfor (let i = 0; i < data.assets.length; i++) {\n\t\t\t\t\t\t\t\tlet temp = data.assets[ i ];\n\t\t\t\t\t\t\t\twp.media.post( 'cloudinary-down-sync', {\n\t\t\t\t\t\t\t\t\tnonce: CLDN.nonce,\n\t\t\t\t\t\t\t\t\tasset: temp,\n\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\tlet update_asset = function( asset, attach ){\n\t\t\t\t\t\t\t\t\t\tasset.uploading = false;\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.remove( attach );\n\t\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( typeof asset.fetch !== 'undefined' ) {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.attachment_id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tlibrary.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.add( attach );\n\t\t\t\t\t\t\t\t\t\twp.ajax.send( {\n\t\t\t\t\t\t\t\t\t\t\turl: asset.fetch,\n\t\t\t\t\t\t\t\t\t\t\tbeforeSend: function( request ) {\n\t\t\t\t\t\t\t\t\t\t\t\trequest.setRequestHeader( 'X-WP-Nonce', CLDN.nonce );\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\t\t\t\t\t\tsrc: asset.url,\n\t\t\t\t\t\t\t\t\t\t\t\tfilename: asset.filename,\n\t\t\t\t\t\t\t\t\t\t\t\tattachment_id: asset.attachment_id,\n\t\t\t\t\t\t\t\t\t\t\t\ttransformations: asset.transformations\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t} ).done( function( asset ) {\n\t\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t} ).fail( function( data ) {\n\t\t\t\t\t\t\t\t\t\t\tupdate_asset( asset, attach );\n\t\t\t\t\t\t\t\t\t\t\tlibrary.remove( attach );\n\t\t\t\t\t\t\t\t\t\t\tselection.remove( attach );\n\n\t\t\t\t\t\t\t\t\t\t\tif( typeof data === 'string' ) {\n\t\t\t\t\t\t\t\t\t\t\t\talert( data );\n\t\t\t\t\t\t\t\t\t\t\t}else{\n\t\t\t\t\t\t\t\t\t\t\t\tif( data.status === 500 ){\n\t\t\t\t\t\t\t\t\t\t\t\t\talert('HTTP error.');\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\telse {\n\n\t\t\t\t\t\t\t\t\t\tlet attach = attachment.get( asset.id );\n\t\t\t\t\t\t\t\t\t\tattach.set( asset );\n\t\t\t\t\t\t\t\t\t\tselection.add( attach );\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tif ( wp.Uploader.queue.length === 0 ) {\n\t\t\t\t\t\t\t\t\t\twp.Uploader.queue.reset();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcontroller.content.mode( 'browse' );\n\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tdocument.querySelectorAll( '.dam-cloudinary' )[ 0 ]\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.active = this.cid;\n\t\t\treturn this;\n\t\t},\n\t} );\n\tlet extend_type = function( type ) {\n\t\tlet obj = {\n\n\t\t\t/**\n\t\t\t * Bind region mode event callbacks.\n\t\t\t *\n\t\t\t * @see media.controller.Region.render\n\t\t\t */\n\t\t\tbindHandlers: function() {\n\t\t\t\ttype.prototype.bindHandlers.apply( this, arguments );\n\t\t\t\tthis.on( 'content:render:cloudinary', this.cloudinaryContent, this );\n\n\t\t\t},\n\n\t\t\t/**\n\t\t\t * Render callback for the router region in the `browse` mode.\n\t\t\t *\n\t\t\t * @param {wp.media.view.Router} routerView\n\t\t\t */\n\t\t\tbrowseRouter: function( routerView ) {\n\n\t\t\t\ttype.prototype.browseRouter.apply( this, arguments );\n\t\t\t\tlet state_id = this.state().get( 'id' );\n\t\t\t\trouterView.set( {\n\t\t\t\t\tcloudinary: {\n\t\t\t\t\t\ttext: 'Cloudinary',\n\t\t\t\t\t\tpriority: 60\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t},\n\t\t\t/**\n\t\t\t * Render callback for the content region in the `upload` mode.\n\t\t\t */\n\t\t\tcloudinaryContent: function( contentRegion ) {\n\t\t\t\tlet state = this.state();\n\t\t\t\tlet view = new Cloudinary( {\n\t\t\t\t\tcontroller: this,\n\t\t\t\t\tmodel: state,\n\t\t\t\t} ).render();\n\t\t\t\tthis.content.set( view );\n\t\t\t},\n\t\t};\n\n\t\treturn obj;\n\t};\n\t// Extending the current media library frames to add a new tab to each area.\n\twp.media.view.MediaFrame.Select = MediaFrame.extend( extend_type( MediaFrame ) );\n\twp.media.view.MediaFrame.Post = MediaFramePost.extend( extend_type( MediaFramePost ) );\n\twp.media.view.MediaFrame.ImageDetails = MediaFrameImageDetails.extend( extend_type( MediaFrameImageDetails ) );\n\twp.media.view.MediaFrame.VideoDetails = MediaFrameVideoDetails.extend( extend_type( MediaFrameVideoDetails ) );\n\n}\n\n\n//# sourceURL=webpack:///./js/src/components/widget.js?"); - -/***/ }), - -/***/ "./js/src/main.js": -/*!************************!*\ - !*** ./js/src/main.js ***! - \************************/ -/*! exports provided: cloudinary */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"cloudinary\", function() { return cloudinary; });\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./components/settings-page */ \"./js/src/components/settings-page.js\");\n/* harmony import */ var _components_settings_page__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_components_settings_page__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _components_sync__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./components/sync */ \"./js/src/components/sync.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./components/widget */ \"./js/src/components/widget.js\");\n/* harmony import */ var _components_widget__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_components_widget__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./components/global-transformations */ \"./js/src/components/global-transformations.js\");\n/* harmony import */ var _components_terms_order__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./components/terms_order */ \"./js/src/components/terms_order.js\");\n/* harmony import */ var _components_media_library__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/media-library */ \"./js/src/components/media-library.js\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../css/src/main.scss */ \"./css/src/main.scss\");\n/* harmony import */ var _css_src_main_scss__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_css_src_main_scss__WEBPACK_IMPORTED_MODULE_6__);\n/* global window */\n/**\n * Main JS.\n */\n\n// Components\n\n\n\n\n\n\n\n\n\n// jQuery, because reasons.\nconst $ = window.$ = window.jQuery;\n\n// Global Constants\nconst cloudinary = {\n\tsettings: (_components_settings_page__WEBPACK_IMPORTED_MODULE_0___default()),\n\tsync: _components_sync__WEBPACK_IMPORTED_MODULE_1__[\"default\"],\n\twidget: (_components_widget__WEBPACK_IMPORTED_MODULE_2___default()),\n\tGlobal_Transformations: _components_global_transformations__WEBPACK_IMPORTED_MODULE_3__[\"default\"],\n\tTerms_Order: _components_terms_order__WEBPACK_IMPORTED_MODULE_4__[\"default\"],\n\tMedia_Library: _components_media_library__WEBPACK_IMPORTED_MODULE_5__[\"default\"],\n};\n\n\n\n//# sourceURL=webpack:///./js/src/main.js?"); - -/***/ }) - -/******/ }); \ No newline at end of file +!function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3)}([function(e,t){!function(){const e=function(){const e=jQuery("#field-video_player").val(),t=jQuery("#field-video_controls").prop("checked"),i=jQuery('#field-video_autoplay_mode option[value="off"]');"cld"!==e||t?i.prop("disabled",!1):(i.prop("disabled",!0),i.prop("selected")&&i.next().prop("selected",!0))};e(),jQuery(document).on("change","#field-video_player",e),jQuery(document).on("change","#field-video_controls",e),jQuery(document).ready((function(e){e(document).on("tabs.init",(function(){var t=e(".settings-tab-trigger"),i=e(".settings-tab-section");e(this).on("click",".settings-tab-trigger",(function(n){var s=e(this),a=e(s.attr("href"));n.preventDefault(),t.removeClass("active"),i.removeClass("active"),s.addClass("active"),a.addClass("active"),e(document).trigger("settings.tabbed",s)})),e(".cld-field").not('[data-condition="false"]').each((function(){const t=e(this),i=t.data("condition");for(let n in i){const s=i[n],a=e("#field-"+n),o=t.closest("tr");a.on("change init",(function(){this.value===s||this.checked?o.show():o.hide()})),a.trigger("init")}})),e("#field-cloudinary_url").on("input change",(function(){let t=e(this),i=t.val();new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\/\/){1}(\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g).test(i)?(t.addClass("settings-valid-field"),t.removeClass("settings-invalid-field")):(t.removeClass("settings-valid-field"),t.addClass("settings-invalid-field"))})).trigger("change")})),e(".render-trigger[data-event]").each((function(){var t=e(this),i=t.data("event");t.trigger(i,this)}))}))}(window,jQuery)},function(e,t){if(wp.media&&window.CLDN){wp.media.events.on("editor:image-edit",(function(e){e.metadata.cldoverwrite=null,e.image.className.split(" ").indexOf("cld-overwrite")>=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,o=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,e.percent<100?(this.barSyncCount.innerText=e.total,this.progressCount.innerText=e.done,this.progress.style.display=this.show):(this.completed.style.display=this.show,this.progress.style.display=this.hide)},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var o=a;a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var r=i(1),l=i.n(r);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),o=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${o})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var p=u;const m={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=m;m._init();i(2);i.d(t,"cloudinary",(function(){return f}));window.$=window.jQuery;const f={settings:s.a,sync:o,widget:l.a,Global_Transformations:c,Terms_Order:p,Media_Library:h}}]); \ No newline at end of file From d108b8ccb66cdd3d260baa4cc77dc36300eb2cd1 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Sat, 30 May 2020 16:57:56 -0400 Subject: [PATCH 04/28] Fixes bug where fetched images don't load --- .../php/class-media.php | 2 +- .../php/connect/class-api.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php index 3a697c70f..543e91caa 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-media.php @@ -1021,7 +1021,7 @@ public function down_sync_asset() { if ( $format !== $file_info['extension'] ) { // Format transformation. $this->set_transformation( $transformations, 'fetch_format', $file_info['extension'] ); - $url = $file_info['dirname'] . '/' . $file_info['filename'] . '.' . $format; + $url = $file_info['dirname'] . '/' . $file_info['filename'] . '.' . $file_info['extension']; } // Try to find the Attachment ID in context meta data. $attachment_id = $this->get_id_from_sync_key( $sync_key ); diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php index 75c0bbb27..b8b1a04a4 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php @@ -240,9 +240,11 @@ public function cloudinary_url( $public_id, $args = array(), $size = array(), $c 'https:/', $this->url( $args['resource_type'], 'upload' ), ); + if ( ! empty( $args['transformation'] ) ) { $url_parts[] = self::generate_transformation_string( $args['transformation'] ); } + // Add size. if ( ! empty( $size ) && is_array( $size ) ) { if ( true === $clean ) { @@ -258,7 +260,15 @@ public function cloudinary_url( $public_id, $args = array(), $size = array(), $c // Clear out empty parts. $url_parts = array_filter( $url_parts ); - return implode( '/', $url_parts ); + $final_url = implode( '/', $url_parts ); + + // Determine if we're dealing with a fetched + // ...or uploaded image and update the URL accordingly. + if ( 1 < substr_count( $final_url, 'http' ) ) { + $final_url = str_replace( '/upload/', '/fetch/', $final_url ); + } + + return $final_url; } /** From 731758c3b9247d5c724fc21485dc8dade269c493 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Sat, 30 May 2020 19:27:58 -0400 Subject: [PATCH 05/28] Implement a cleaner fix --- .../php/connect/class-api.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php index b8b1a04a4..203df4f00 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php @@ -236,9 +236,13 @@ public function cloudinary_url( $public_id, $args = array(), $size = array(), $c $args['version'] = 'v1'; } + // Determine if we're dealing with a fetched + // ...or uploaded image and update the URL accordingly. + $asset_endpoint = filter_var( $public_id, FILTER_VALIDATE_URL ) ? 'fetch' : 'upload'; + $url_parts = array( 'https:/', - $this->url( $args['resource_type'], 'upload' ), + $this->url( $args['resource_type'], $asset_endpoint ), ); if ( ! empty( $args['transformation'] ) ) { @@ -254,21 +258,13 @@ public function cloudinary_url( $public_id, $args = array(), $size = array(), $c } $url_parts[] = $args['version']; - + $url_parts[] = $public_id; // Clear out empty parts. $url_parts = array_filter( $url_parts ); - $final_url = implode( '/', $url_parts ); - - // Determine if we're dealing with a fetched - // ...or uploaded image and update the URL accordingly. - if ( 1 < substr_count( $final_url, 'http' ) ) { - $final_url = str_replace( '/upload/', '/fetch/', $final_url ); - } - - return $final_url; + return implode( '/', $url_parts ); } /** From 769c43298120cc14c547b842a8a86864b4dc9ca1 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Thu, 4 Jun 2020 19:36:24 -0400 Subject: [PATCH 06/28] Ensure does not become part of final front url --- .../php/connect/class-api.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php index 203df4f00..279a7da93 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/connect/class-api.php @@ -189,14 +189,17 @@ function ( $item ) use ( $transformation_index ) { if ( is_string ( $item ) ) { return $item; } + foreach ( $item as $type => $value ) { // phpcs:ignore $key = array_search( $type, $transformation_index, true ); - if ( 'wpsize' === $type ) { + if ( false !== strpos( $type, 'wpsize' ) ) { if ( ! empty( $item['clean'] ) ) { continue; } + $value = '!' . $value . '!'; } + if ( false !== $key ) { $transform[] = $key . '_' . $value; } @@ -258,7 +261,6 @@ public function cloudinary_url( $public_id, $args = array(), $size = array(), $c } $url_parts[] = $args['version']; - $url_parts[] = $public_id; // Clear out empty parts. From 7d93b0cf1c087d510cf322eba504770d50a4b474 Mon Sep 17 00:00:00 2001 From: Marco Pereirinha Date: Fri, 5 Jun 2020 12:37:39 +0100 Subject: [PATCH 07/28] Update PR From 14acc067028b2b9d5dbd0b956f8252894d9f7e66 Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Sat, 13 Jun 2020 15:59:59 -0400 Subject: [PATCH 08/28] Add overwrite_transformation check for global transformations --- .../php/media/class-video.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php index f971948dd..472a45ee7 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-video.php @@ -228,6 +228,7 @@ public function filter_video_shortcode( $html, $attr ) { if ( ! empty( $transformations ) ) { $args['transformation'] = $transformations; } + $args['overwrite_transformations'] = $overwrite_transformations; // Size settings. $size = ''; if ( ! empty( $attr['width'] ) ) { @@ -307,6 +308,8 @@ public function filter_video_tags( $content ) { if ( false !== strpos( $classes, 'cld-overwrite' ) ) { $overwrite_transformations = true; } + $args['overwrite_transformations'] = $overwrite_transformations; + $cloudinary_url = $this->media->cloudinary_url( $attachment_id, false, false, null, $overwrite_transformations ); $transformations = $this->media->get_transformations_from_string( $cloudinary_url, 'video' ); if ( ! empty( $transformations ) ) { @@ -384,15 +387,19 @@ public function print_video_scripts() { if ( videoElement.length === 1 ) { videoElement = videoElement[0]; videoElement.style.width = '100%'; - config['video_freeform'] ): ?> - if ( videoElement.src.indexOf( 'config['video_freeform'] ) ?>' ) === -1 ) { - videoElement.src = videoElement.src.replace( - 'upload/', - 'upload/config['video_freeform'] ) ?>/' - ); - } + + if ( + videoElement.src.indexOf( 'config['video_freeform'] ) ?>' ) === -1 && + ! cldVideos[videoInstance]['overwrite_transformations'] + ) { + videoElement.src = videoElement.src.replace( + 'upload/', + 'upload/config['video_freeform'] ) ?>/' + ); + } + } } } ); From 70596d233d4e311ff67b416ff5595f226d396646 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 23 Jun 2020 11:44:02 +0200 Subject: [PATCH 09/28] add rename sync type --- .../php/sync/class-push-sync.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 892e86a50..66d7d2874 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -58,9 +58,10 @@ public function __construct( \Cloudinary\Plugin $plugin ) { // Define the sync types and their option keys. $sync_types = array( 'file' => 'upload', + 'public_id' => 'rename', 'breakpoints' => 'explicit', 'options' => 'context', - 'folder' => 'upload', + 'folder' => 'rename', 'cloud_name' => 'upload', ); $this->sync_types = apply_filters( 'cloudinary_sync_types', $sync_types ); @@ -570,6 +571,13 @@ public function push_attachments( $attachments ) { $args['context'] = $upload['options']['context']; } $result = $this->plugin->components['connect']->api->explicit( $args ); + } elseif ( 'rename' === $sync_type ) { + // Rename an asset. + $args = array( + 'from_public_id' => $this->plugin->components['media']->get_post_meta( $attachment->ID, Sync::META_KEYS['public_id'] ), + 'to_public_id' => $upload['public_id'], + ); + $result = $this->plugin->components['connect']->api->{$upload['options']['resource_type']}( 'rename', 'POST', $args ); } else { // dynamic sync type.. $result = $this->plugin->components['connect']->api->{$sync_type}( $upload['file'], $upload['options'] ); From f5f4e6a544c39fda1d1eb3889ef842bff3eac76e Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 23 Jun 2020 11:45:19 +0200 Subject: [PATCH 10/28] add public_id sync state --- .../php/sync/class-push-sync.php | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 66d7d2874..3d8a75d82 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -390,25 +390,17 @@ public function prepare_upload( $post, $down_sync = false ) { } // If it's got a public ID, then this is an explicit update. + $settings = $this->plugin->config['settings']; $public_id = $post->{Sync::META_KEYS['public_id']}; // use the __get method on the \WP_Post to get post_meta. - $dirs = wp_get_upload_dir(); - $cld_folder = false; - $folder = trailingslashit( $dirs['cloudinary_folder'] ); - if ( '/' === $dirs['cloudinary_folder'] ) { - $folder = ''; - } + $cld_folder = trailingslashit( $settings['sync_media']['cloudinary_folder'] ); if ( empty( $public_id ) ) { $file_info = pathinfo( $file ); - $public_id = $folder . $file_info['filename']; - } - - // Check if cloudinary folder is in public_id. - $parts = explode( '/', $public_id ); - if ( untrailingslashit( $dirs['cloudinary_folder'] ) === $parts[0] ) { - $cld_folder = $dirs['cloudinary_folder']; + $public_id = $file_info['filename']; + } else { + $public_id_parts = pathinfo( $public_id ); + $public_id = $public_id_parts['basename']; } - // Prepare upload options. $options = array( 'unique_filename' => false, @@ -475,14 +467,19 @@ public function prepare_upload( $post, $down_sync = false ) { $breakpoints['context'] = http_build_query( $breakpoints['context'], null, '|' ); } + // Stage folder to public_id. + $public_id = $cld_folder . $options['public_id']; $return = array( 'file' => $file, 'folder' => $cld_folder, + 'public_id' => $public_id, 'breakpoints' => array(), 'options' => $options, ); + $return['options']['public_id'] = $public_id; if ( ! empty( $breakpoints ) ) { $return['breakpoints'] = $breakpoints; + $return['breakpoints']['public_id'] = $public_id; // Stage public ID to folder for breakpoints. } $this->upload_options[ $post->ID ] = $return; @@ -561,7 +558,7 @@ public function push_attachments( $attachments ) { if ( 'explicit' === $sync_type ) { // Explicit update. $args = array( - 'public_id' => $upload['options']['public_id'], + 'public_id' => $upload['public_id'], 'type' => 'upload', ); if ( ! empty( $upload['options']['responsive_breakpoints'] ) ) { From 82a0b49ad0fc2e4dae8df43bc1388b50e73b20dc Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 23 Jun 2020 11:49:03 +0200 Subject: [PATCH 11/28] fix upgrade check to return if v2 meta exists. --- .../php/media/class-upgrade.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php index 55517a0db..53a165d5e 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php @@ -46,7 +46,10 @@ public function __construct( \Cloudinary\Media $media ) { public function check_cloudinary_version( $cloudinary_id, $attachment_id ) { if ( false === $cloudinary_id ) { // Backwards compat. - $meta = wp_get_attachment_metadata( $attachment_id ); + $meta = wp_get_attachment_metadata( $attachment_id ); + if ( ! empty( $meta[ Sync::META_KEYS['cloudinary'] ] ) ) { + return $cloudinary_id; // Current version. + } $public_id = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['public_id'], true ); /* From d245cef999cc02c97ef1ebcc59c297ac2a3a1522 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 23 Jun 2020 11:49:27 +0200 Subject: [PATCH 12/28] cleanup meta checking --- .../php/sync/class-push-sync.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 3d8a75d82..1939e8846 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -304,7 +304,7 @@ private function get_sync_type( $attachment ) { $type = 'upload'; // Check for explicit (has public_id, but no breakpoints). - $attachment_signature = $attachment->{Sync::META_KEYS['signature']}; + $attachment_signature = $this->plugin->components['media']->get_post_meta( $attachment->ID, Sync::META_KEYS['signature'] ); if ( empty( $attachment_signature ) ) { if ( ! empty( $attachment->{Sync::META_KEYS['public_id']} ) ) { // Has a public id but no signature, explicit update to complete download. From 43355d3abdf2e64120ef3cc2c22470cfe1341ea7 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 23 Jun 2020 11:49:43 +0200 Subject: [PATCH 13/28] cleanup settings use. --- .../php/sync/class-push-sync.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 1939e8846..2ab91531c 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -429,13 +429,13 @@ public function prepare_upload( $post, $down_sync = false ) { } $max_width = $this->plugin->components['media']->get_max_width(); // Add breakpoints request options. - if ( ! empty( $this->plugin->config['settings']['global_transformations']['enable_breakpoints'] ) ) { + if ( ! empty( $settings['global_transformations']['enable_breakpoints'] ) ) { $options['responsive_breakpoints'] = array( 'create_derived' => true, - 'bytes_step' => $this->plugin->config['settings']['global_transformations']['bytes_step'], - 'max_images' => $this->plugin->config['settings']['global_transformations']['breakpoints'], + 'bytes_step' => $settings['global_transformations']['bytes_step'], + 'max_images' => $settings['global_transformations']['breakpoints'], 'max_width' => $meta['width'] < $max_width ? $meta['width'] : $max_width, - 'min_width' => $this->plugin->config['settings']['global_transformations']['min_width'], + 'min_width' => $settings['global_transformations']['min_width'], ); $transformations = $this->plugin->components['media']->get_transformation_from_meta( $post->ID ); if ( ! empty( $transformations ) ) { From 9a9ab05ed7ac7cbec338c3a419f99bd6881bc8a2 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Thu, 25 Jun 2020 13:13:45 +0200 Subject: [PATCH 14/28] use the generated signature as a default for stored. --- .../php/sync/class-push-sync.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 2ab91531c..4929640b4 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -312,8 +312,10 @@ private function get_sync_type( $attachment ) { } // fallback to upload. } else { - // Has signature. Compare and find if different. + // Has signature find differences. $required_signature = $this->plugin->components['sync']->generate_signature( $attachment->ID ); + // Apply the generated asset signature as a default. To allow for signature extensions that may not exist. + $attachment_signature = wp_parse_args( $attachment_signature, $required_signature ); foreach ( $required_signature as $key => $signature ) { if ( ( ! isset( $attachment_signature[ $key ] ) || $attachment_signature[ $key ] !== $signature ) && isset( $this->sync_types[ $key ] ) ) { return $this->sync_types[ $key ]; From 3d720c6cc067b91018be803aa6e223c8a8f73989 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Thu, 25 Jun 2020 13:23:10 +0200 Subject: [PATCH 15/28] move to get_signature method. --- .../php/class-sync.php | 20 ++++++++++++++++++- .../php/sync/class-push-sync.php | 10 +++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index a2bcd3745..4e31188f2 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -100,7 +100,7 @@ public function is_active() { */ public function is_synced( $post_id ) { $return = false; - $signature = $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['signature'], true ); + $signature = $this->get_signature( $post_id ); if ( ! empty( $signature ) && $this->generate_signature( $post_id ) === $signature ) { $return = $signature; } @@ -133,6 +133,24 @@ function ( $item ) { return $return; } + /** + * Get the current sync signature of an asset. + * + * @param int $post_id The post ID. + * + * @return array|bool + */ + public function get_signature( $post_id ) { + $return = false; + $signature = $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['signature'], true ); + if ( ! empty( $signature ) ) { + $base_signatures = $this->generate_signature( $post_id ); + $return = wp_parse_args( $signature, $base_signatures ); + } + + return $return; + } + /** * Additional component setup. */ diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 4929640b4..24712c3dd 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -304,7 +304,7 @@ private function get_sync_type( $attachment ) { $type = 'upload'; // Check for explicit (has public_id, but no breakpoints). - $attachment_signature = $this->plugin->components['media']->get_post_meta( $attachment->ID, Sync::META_KEYS['signature'] ); + $attachment_signature = $this->plugin->components['sync']->generate_signature( $attachment->ID ); if ( empty( $attachment_signature ) ) { if ( ! empty( $attachment->{Sync::META_KEYS['public_id']} ) ) { // Has a public id but no signature, explicit update to complete download. @@ -400,7 +400,7 @@ public function prepare_upload( $post, $down_sync = false ) { $public_id = $file_info['filename']; } else { $public_id_parts = pathinfo( $public_id ); - $public_id = $public_id_parts['basename']; + $public_id = $public_id_parts['basename']; } // Prepare upload options. @@ -470,8 +470,8 @@ public function prepare_upload( $post, $down_sync = false ) { } // Stage folder to public_id. - $public_id = $cld_folder . $options['public_id']; - $return = array( + $public_id = $cld_folder . $options['public_id']; + $return = array( 'file' => $file, 'folder' => $cld_folder, 'public_id' => $public_id, @@ -480,7 +480,7 @@ public function prepare_upload( $post, $down_sync = false ) { ); $return['options']['public_id'] = $public_id; if ( ! empty( $breakpoints ) ) { - $return['breakpoints'] = $breakpoints; + $return['breakpoints'] = $breakpoints; $return['breakpoints']['public_id'] = $public_id; // Stage public ID to folder for breakpoints. } $this->upload_options[ $post->ID ] = $return; From c71b2e00170f875fe9469ae59390043f13262292 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Thu, 25 Jun 2020 13:29:39 +0200 Subject: [PATCH 16/28] cache signatures and cleanup. --- .../php/class-sync.php | 17 ++++++++++++----- .../php/sync/class-push-sync.php | 6 ++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index 4e31188f2..56f7dc5fd 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -141,11 +141,18 @@ function ( $item ) { * @return array|bool */ public function get_signature( $post_id ) { - $return = false; - $signature = $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['signature'], true ); - if ( ! empty( $signature ) ) { - $base_signatures = $this->generate_signature( $post_id ); - $return = wp_parse_args( $signature, $base_signatures ); + static $signatures = array(); // Cache signatures already fetched. + + $return = false; + if ( ! empty( $signatures[ $post_id ] ) ) { + $return = $signatures[ $post_id ]; + } else { + $signature = $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['signature'], true ); + if ( ! empty( $signature ) ) { + $base_signatures = $this->generate_signature( $post_id ); + $signatures[ $post_id ] = wp_parse_args( $signature, $base_signatures ); + $return = $signatures[ $post_id ]; + } } return $return; diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 24712c3dd..a2ac8fd55 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -304,7 +304,7 @@ private function get_sync_type( $attachment ) { $type = 'upload'; // Check for explicit (has public_id, but no breakpoints). - $attachment_signature = $this->plugin->components['sync']->generate_signature( $attachment->ID ); + $attachment_signature = $this->plugin->components['sync']->get_signature( $attachment->ID ); if ( empty( $attachment_signature ) ) { if ( ! empty( $attachment->{Sync::META_KEYS['public_id']} ) ) { // Has a public id but no signature, explicit update to complete download. @@ -312,10 +312,8 @@ private function get_sync_type( $attachment ) { } // fallback to upload. } else { - // Has signature find differences. + // Has signature find differences and use specific sync method. $required_signature = $this->plugin->components['sync']->generate_signature( $attachment->ID ); - // Apply the generated asset signature as a default. To allow for signature extensions that may not exist. - $attachment_signature = wp_parse_args( $attachment_signature, $required_signature ); foreach ( $required_signature as $key => $signature ) { if ( ( ! isset( $attachment_signature[ $key ] ) || $attachment_signature[ $key ] !== $signature ) && isset( $this->sync_types[ $key ] ) ) { return $this->sync_types[ $key ]; From 3722a90570da29e38194b164158f2eb4a8a25e2d Mon Sep 17 00:00:00 2001 From: Dukagjin Surdulli Date: Thu, 25 Jun 2020 10:18:54 -0400 Subject: [PATCH 17/28] Add usage warning to transformation spots in the plugin --- .../css/src/components/_settings.scss | 8 ++++++++ .../tabs/settings-global-transformations.php | 5 +++-- .../tabs/settings-global-video-transformations.php | 5 +++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_settings.scss b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_settings.scss index 43e543615..235997bab 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_settings.scss +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/src/components/_settings.scss @@ -208,3 +208,11 @@ } } } + +.settings-warning { + display: inline-block; + padding: 5px 7px; + background-color: #ffea98; + border-left: 4px solid #ffcc00; + box-shadow: 0px 0px 5px 0px rgba(112,112,112,0.4); +} \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-transformations.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-transformations.php index 77f96bed7..28329ff27 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-transformations.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-transformations.php @@ -136,9 +136,10 @@ 'label' => __( 'Image Transformation String', 'cloudinary' ), 'description' => sprintf( // translators: Placeholders are tags. - __( 'The set of transformations to apply to all image assets, as a URL transformation string. %1$sImage transformation reference%2$s.', 'cloudinary' ), + __( 'The set of transformations to apply to all image assets, as a URL transformation string. %1$sImage transformation reference%2$s.%3$sNote: When updating transformations, all relevant assets will have new transformations applied; This may cause an increase in your Cloudinary usage.', 'cloudinary' ), '
    ', - '' + '', + '

    ' ), 'contextual' => true, // Flags the field to be used in a contextual basis. i.e. taxonomies. 'context' => 'image', diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php index 2976aff2b..edbf2da54 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/ui-definitions/tabs/settings-global-video-transformations.php @@ -96,9 +96,10 @@ 'label' => __( 'Video Transformation String', 'cloudinary' ), 'description' => sprintf( // translators: Placeholders are tags. - __( 'The set of transformations to apply to all video assets, as a URL transformation string. %1$sVideo transformation reference%2$s.', 'cloudinary' ), + __( 'The set of transformations to apply to all video assets, as a URL transformation string. %1$sVideo transformation reference%2$s.%3$sNote: When updating transformations, all relevant assets will have new transformations applied; This may cause an increase in your Cloudinary usage.', 'cloudinary' ), '
    ', - '' + '', + '

    ' ), 'type' => 'textarea', 'contextual' => true, // Flags the field to be used in a contextual basis. i.e. taxonomies. From 383a22fb8fc86d1569b6856323f210f32cf164a3 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 29 Jun 2020 12:11:49 +0200 Subject: [PATCH 18/28] add calculation based percentages for credit types --- .../php/class-connect.php | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php index 39bab567d..9dcf3a68a 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-connect.php @@ -363,7 +363,8 @@ public function get_usage_stat( $type, $stat = null ) { if ( 'limit' === $stat && isset( $this->usage[ $type ]['usage'] ) ) { $value = $this->usage[ $type ]['usage']; } elseif ( 'used_percent' === $stat && isset( $this->usage[ $type ]['credits_usage'] ) ) { - $value = $this->usage[ $type ]['credits_usage']; + // Calculate percentage based on credit limit and usage. + $value = round( $this->usage[ $type ]['credits_usage']/$this->usage['credits']['limit'] * 100, 2 ); } } } @@ -432,28 +433,27 @@ public function get_config() { */ public function usage_notices() { if ( ! empty( $this->usage ) ) { - $usage_type = 'used_percent'; - if ( isset( $this->usage['credits'] ) ) { - $usage_type = 'credits_usage'; - } foreach ( $this->usage as $stat => $values ) { - if ( ! is_array( $values ) || ! isset( $values[ $usage_type ] ) || 0 > $values[ $usage_type ] ) { + if ( ! is_array( $values ) ) { + continue; + } + $usage = $this->get_usage_stat( $stat, 'used_percent' ); + if ( empty ( $usage ) ) { continue; } - $link = null; $link_text = null; - if ( 90 <= $values[ $usage_type ] ) { + if ( 90 <= $usage ) { // 90% used - show error. $level = 'error'; $link = 'https://cloudinary.com/console/lui/upgrade_options'; $link_text = __( 'upgrade your account', 'cloudinary' ); - } elseif ( 80 <= $values[ $usage_type ] ) { - $level = 'warning'; + } elseif ( 80 <= $usage ) { + $level = 'warning'; $link_text = __( 'upgrade your account', 'cloudinary' ); - } elseif ( 70 <= $values[ $usage_type ] ) { - $level = 'neutral'; + } elseif ( 70 <= $usage ) { + $level = 'neutral'; $link_text = __( 'upgrade your account', 'cloudinary' ); } else { continue; @@ -465,7 +465,7 @@ public function usage_notices() { 'cloudinary' ), ucwords( $stat ), - $values[ $usage_type ] . '%', + $usage . '%', $link, $link_text ); From 502337192f07fa39b9f3e93622f67eed813e45a0 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Mon, 29 Jun 2020 14:04:13 +0200 Subject: [PATCH 19/28] use the public id's synced path rather than folder set. --- .../php/class-sync.php | 3 ++- .../php/sync/class-push-sync.php | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index 56f7dc5fd..f64230e4d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -101,7 +101,8 @@ public function is_active() { public function is_synced( $post_id ) { $return = false; $signature = $this->get_signature( $post_id ); - if ( ! empty( $signature ) && $this->generate_signature( $post_id ) === $signature ) { + $expecting = $this->generate_signature( $post_id ); + if ( ! empty( $signature ) && $expecting === $signature ) { $return = $signature; } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index a2ac8fd55..1f2045c1c 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -61,7 +61,7 @@ public function __construct( \Cloudinary\Plugin $plugin ) { 'public_id' => 'rename', 'breakpoints' => 'explicit', 'options' => 'context', - 'folder' => 'rename', + 'folder' => 'upload', 'cloud_name' => 'upload', ); $this->sync_types = apply_filters( 'cloudinary_sync_types', $sync_types ); @@ -395,17 +395,25 @@ public function prepare_upload( $post, $down_sync = false ) { $cld_folder = trailingslashit( $settings['sync_media']['cloudinary_folder'] ); if ( empty( $public_id ) ) { $file_info = pathinfo( $file ); - $public_id = $file_info['filename']; + $public_id = $cld_folder . $file_info['filename']; + } + + if ( false !== strpos( $public_id, '/' ) ) { + // Split the public_id into path and filename to allow filtering just the ID and not giving access to the path. + $public_id_info = pathinfo( $public_id ); + $public_id_folder = trailingslashit( $public_id_info['dirname'] ); + $public_id_file = $public_id_info['filename']; } else { - $public_id_parts = pathinfo( $public_id ); - $public_id = $public_id_parts['basename']; + // File is in the root of cloudinary. + $public_id_folder = ''; + $public_id_file = $public_id; } // Prepare upload options. $options = array( 'unique_filename' => false, 'resource_type' => $resource_type, - 'public_id' => $public_id, + 'public_id' => $public_id_file, 'context' => array( 'caption' => esc_attr( $post->post_title ), 'alt' => $post->_wp_attachment_image_alt, @@ -467,8 +475,8 @@ public function prepare_upload( $post, $down_sync = false ) { $breakpoints['context'] = http_build_query( $breakpoints['context'], null, '|' ); } - // Stage folder to public_id. - $public_id = $cld_folder . $options['public_id']; + // Restructure the path to the filename to allow correct placement in Cloudinary. + $public_id = $public_id_folder . $options['public_id']; $return = array( 'file' => $file, 'folder' => $cld_folder, From 562affe48d149fd55b4771dbe91898262a1921d8 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 30 Jun 2020 13:47:49 +0200 Subject: [PATCH 20/28] reorganise sync types in logicial order --- .../php/sync/class-push-sync.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 1f2045c1c..7376d973a 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -57,12 +57,12 @@ public function __construct( \Cloudinary\Plugin $plugin ) { // Define the sync types and their option keys. $sync_types = array( + 'cloud_name' => 'upload', + 'folder' => 'upload', 'file' => 'upload', 'public_id' => 'rename', 'breakpoints' => 'explicit', 'options' => 'context', - 'folder' => 'upload', - 'cloud_name' => 'upload', ); $this->sync_types = apply_filters( 'cloudinary_sync_types', $sync_types ); From 10c11fff5c30507fa7351eaff6d9ec1a4d916807 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 30 Jun 2020 13:53:55 +0200 Subject: [PATCH 21/28] simplify public_id / folder split --- .../php/sync/class-push-sync.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 7376d973a..0e765c519 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -398,15 +398,16 @@ public function prepare_upload( $post, $down_sync = false ) { $public_id = $cld_folder . $file_info['filename']; } + // Assume that the public_id is a root item. + $public_id_folder = ''; + $public_id_file = $public_id; + + // Check if in a lower level. if ( false !== strpos( $public_id, '/' ) ) { // Split the public_id into path and filename to allow filtering just the ID and not giving access to the path. $public_id_info = pathinfo( $public_id ); $public_id_folder = trailingslashit( $public_id_info['dirname'] ); $public_id_file = $public_id_info['filename']; - } else { - // File is in the root of cloudinary. - $public_id_folder = ''; - $public_id_file = $public_id; } // Prepare upload options. From 043b82c8bf1177876355507014edcf61a80be839 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 30 Jun 2020 15:52:24 +0200 Subject: [PATCH 22/28] add folder_sync to maintain sync structure and cleanup code --- .../php/class-sync.php | 1 + .../php/sync/class-download-sync.php | 10 ++++++ .../php/sync/class-push-sync.php | 32 +++++++++++++------ .../php/sync/class-upload-sync.php | 1 + 4 files changed, 34 insertions(+), 10 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index f64230e4d..44968e555 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -48,6 +48,7 @@ class Sync implements Setup, Assets { 'transformation' => '_transformations', 'sync_error' => '_sync_error', 'cloudinary' => '_cloudinary_v2', + 'folder_sync' => '_folder_sync', ); /** diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php index cb4c9e6c6..cf7c65a99 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-download-sync.php @@ -157,6 +157,16 @@ function ( $val ) use ( $media ) { $public_id = strstr( $public_id, '.' . $path['extension'], true ); // Save public ID. $media->update_post_meta( $attachment_id, Sync::META_KEYS['public_id'], $public_id ); + // Check if the asset is in the same folder as the defined Cloudinary folder. + if ( false !== strpos( $public_id, '/' ) ) { + $path = pathinfo( $public_id ); + $asset_folder = trailingslashit( $path['dirname'] ); + $cloudinary_folder = trailingslashit( $this->plugin->config['settings']['sync_media']['cloudinary_folder'] ); + if ( $asset_folder === $cloudinary_folder ) { + // The asset folder matches the defined cloudinary folder, flag it as being in a folder sync. + $media->update_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], true ); + } + } return $this->download_asset( $attachment_id, $file, basename( $file ), $media->get_transformations_from_string( $file ) ); } diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index 0e765c519..da9238bae 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -351,6 +351,9 @@ public function prepare_upload( $post, $down_sync = false ) { return new \WP_Error( 'attachment_post_expected', __( 'An attachment post was expected.', 'cloudinary' ) ); } + // Get the media component. + $media = $this->plugin->components['media']; + // First check if this has a file and it can be uploaded. $file = get_attached_file( $post->ID ); $file_size = 0; @@ -359,7 +362,7 @@ public function prepare_upload( $post, $down_sync = false ) { } elseif ( ! file_exists( $file ) ) { // May be an old upload type. $src = get_post_meta( $post->ID, '_wp_attached_file', true ); - if ( $this->plugin->components['media']->is_cloudinary_url( $src ) ) { + if ( $media->is_cloudinary_url( $src ) ) { // Download first maybe. if ( true === $down_sync ) { $download = $this->plugin->components['sync']->managers['download']->down_sync( $post->ID ); @@ -384,7 +387,7 @@ public function prepare_upload( $post, $down_sync = false ) { // translators: variable is file size. $error = sprintf( __( 'File size exceeds the maximum of %s. This media asset will be served from WordPress.', 'cloudinary' ), $max_size_hr ); - $this->plugin->components['media']->delete_post_meta( $post->ID, Sync::META_KEYS['pending'] ); // Remove Flag. + $media->delete_post_meta( $post->ID, Sync::META_KEYS['pending'] ); // Remove Flag. return new \WP_Error( 'upload_error', $error ); } @@ -409,7 +412,14 @@ public function prepare_upload( $post, $down_sync = false ) { $public_id_folder = trailingslashit( $public_id_info['dirname'] ); $public_id_file = $public_id_info['filename']; } - + // Check if this asset is a folder sync. + $folder_sync = $media->get_post_meta( $post->ID, Sync::META_KEYS['folder_sync'], true ); + if ( ! empty( $folder_sync ) ) { + $public_id_folder = $cld_folder; // Ensure the public ID folder is constant. + } else { + // Not folder synced, so set the folder to the folder that the asset originally came from. + $cld_folder = $public_id_folder; + } // Prepare upload options. $options = array( 'unique_filename' => false, @@ -436,7 +446,7 @@ public function prepare_upload( $post, $down_sync = false ) { $imagesize = getimagesize( $file ); $meta['width'] = $imagesize[0]; } - $max_width = $this->plugin->components['media']->get_max_width(); + $max_width = $media->get_max_width(); // Add breakpoints request options. if ( ! empty( $settings['global_transformations']['enable_breakpoints'] ) ) { $options['responsive_breakpoints'] = array( @@ -446,7 +456,7 @@ public function prepare_upload( $post, $down_sync = false ) { 'max_width' => $meta['width'] < $max_width ? $meta['width'] : $max_width, 'min_width' => $settings['global_transformations']['min_width'], ); - $transformations = $this->plugin->components['media']->get_transformation_from_meta( $post->ID ); + $transformations = $media->get_transformation_from_meta( $post->ID ); if ( ! empty( $transformations ) ) { $options['responsive_breakpoints']['transformation'] = Api::generate_transformation_string( $transformations ); } @@ -526,6 +536,8 @@ public function push_attachments( $attachments ) { 'total' => count( $attachments ), 'processed' => 0, ); + // Get media component. + $media = $this->plugin->components['media']; // Go over each attachment. foreach ( $attachments as $attachment ) { @@ -580,7 +592,7 @@ public function push_attachments( $attachments ) { } elseif ( 'rename' === $sync_type ) { // Rename an asset. $args = array( - 'from_public_id' => $this->plugin->components['media']->get_post_meta( $attachment->ID, Sync::META_KEYS['public_id'] ), + 'from_public_id' => $media->get_post_meta( $attachment->ID, Sync::META_KEYS['public_id'] ), 'to_public_id' => $upload['public_id'], ); $result = $this->plugin->components['connect']->api->{$upload['options']['resource_type']}( 'rename', 'POST', $args ); @@ -597,7 +609,7 @@ public function push_attachments( $attachments ) { if ( is_wp_error( $result ) ) { $error = $result->get_error_message(); $stats['fail'][] = $error; - $this->plugin->components['media']->update_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], $error ); + $media->update_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], $error ); continue; } @@ -611,8 +623,8 @@ public function push_attachments( $attachments ) { if ( ! empty( $result['version'] ) ) { $meta_data[ Sync::META_KEYS['version'] ] = $result['version']; } - $this->plugin->components['media']->delete_post_meta( $attachment->ID, Sync::META_KEYS['pending'] ); - $this->plugin->components['media']->delete_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], false ); + $media->delete_post_meta( $attachment->ID, Sync::META_KEYS['pending'] ); + $media->delete_post_meta( $attachment->ID, Sync::META_KEYS['sync_error'], false ); if ( ! empty( $this->plugin->config['settings']['global_transformations']['enable_breakpoints'] ) ) { if ( ! empty( $result['responsive_breakpoints'] ) ) { // Images only. $meta_data[ Sync::META_KEYS['breakpoints'] ] = $result['responsive_breakpoints'][0]['breakpoints']; @@ -633,7 +645,7 @@ public function push_attachments( $attachments ) { $meta = wp_get_attachment_metadata( $attachment->ID, true ); $meta[ Sync::META_KEYS['cloudinary'] ] = $meta_data; wp_update_attachment_metadata( $attachment->ID, $meta ); - $this->plugin->components['media']->update_post_meta( $attachment->ID, Sync::META_KEYS['public_id'], $upload['options']['public_id'] ); + $media->update_post_meta( $attachment->ID, Sync::META_KEYS['public_id'], $upload['options']['public_id'] ); // Search and update link references in content. $content_search = new \WP_Query( array( 's' => 'wp-image-' . $attachment->ID, 'fields' => 'ids', 'posts_per_page' => 1000 ) ); if ( ! empty( $content_search->found_posts ) ) { diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index cd9272c2d..f3a8bfcce 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -261,6 +261,7 @@ public function add_to_sync( $attachment_id ) { if ( ! in_array( $attachment_id, $this->to_sync, true ) ) { // Flag image as pending to prevent duplicate upload. update_post_meta( $attachment_id, Sync::META_KEYS['pending'], time() ); + $this->plugin->components['media']->update_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], true ); $this->to_sync[] = $attachment_id; } } From e124f2d9c87a049596205fc22d82d022f6ac1d27 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 30 Jun 2020 16:56:10 +0200 Subject: [PATCH 23/28] add folder_sync upgrade script for 1.2.1 and below. --- .../php/media/class-upgrade.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php index 53a165d5e..1051bc668 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/media/class-upgrade.php @@ -62,6 +62,24 @@ public function check_cloudinary_version( $cloudinary_id, $attachment_id ) { // Has public ID, but not fully down synced. $cloudinary_id = $public_id; } + } else { + // Backwards compat. + $folder_sync = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], true ); + if ( 0 === strlen( $folder_sync ) ) { + // Does not exist, add it to be compatible with v1.2.2. + $public_id = $this->media->get_post_meta( $attachment_id, Sync::META_KEYS['public_id'], true ); + // Set the folder sync to 0 to flag it by default as not synced. + $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], '0' ); + if ( false !== strpos( $public_id, '/' ) ) { + $path = pathinfo( $public_id ); + $asset_folder = trailingslashit( $path['dirname'] ); + $cloudinary_folder = trailingslashit( $this->media->plugin->config['settings']['sync_media']['cloudinary_folder'] ); + if ( $asset_folder === $cloudinary_folder ) { + // The asset folder matches the defined cloudinary folder, flag it as being in a folder sync. + $this->media->update_post_meta( $attachment_id, Sync::META_KEYS['folder_sync'], '1' ); + } + } + } } return $cloudinary_id; From ec80adc0b950134353a688bebea225b04d8bcab1 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Tue, 30 Jun 2020 21:54:44 +0200 Subject: [PATCH 24/28] rebuild assets --- .../css/cloudinary.css | 2 +- .../js/cloudinary.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css index ab2783e7d..4c230a50a 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/css/cloudinary.css @@ -1 +1 @@ -@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.eot);src:url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.ttf) format("truetype"),url(../css/fonts/cloudinary.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.warning:before{content:"\e902"}.dashicons-cloudinary.warning{color:#fd9d2c}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0078ff}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file +@font-face{font-family:cloudinary;src:url(../css/fonts/cloudinary.eot);src:url(../css/fonts/cloudinary.eot#iefix) format("embedded-opentype"),url(../css/fonts/cloudinary.ttf) format("truetype"),url(../css/fonts/cloudinary.woff) format("woff"),url(../css/cloudinary.svg#cloudinary) format("svg");font-weight:400;font-style:normal}.dashicons-cloudinary{speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.dashicons-cloudinary:before{font-family:cloudinary!important;content:"\e900"}.dashicons-cloudinary.success{color:#558b2f}.dashicons-cloudinary.error{color:#dd2c00}.dashicons-cloudinary.error:before{content:"\e901"}.dashicons-cloudinary.warning:before{content:"\e902"}.dashicons-cloudinary.warning{color:#fd9d2c}.column-cld_status{width:5.5em}.column-cld_status .dashicons-cloudinary{display:inline-block}.column-cld_status .dashicons-cloudinary:before{font-size:1.8rem}.form-field .error-notice,.form-table .error-notice{display:none;color:#dd2c00}.form-field input.cld-field:invalid,.form-table input.cld-field:invalid{border-color:#dd2c00}.form-field input.cld-field:invalid+.error-notice,.form-table input.cld-field:invalid+.error-notice{display:inline-block}.cloudinary-welcome{background-image:url(../css/logo.svg);background-repeat:no-repeat;background-size:153px;background-position:top 12px right 20px}.cloudinary-stats{display:inline-block;margin-left:25px}.cloudinary-stat{cursor:help}.cloudinary-percent{font-size:.8em;vertical-align:top;color:#0078ff}.settings-image{max-width:100%;padding-top:5px}.settings-tabs>li{display:inline-block}.settings-tabs>li a{padding:.6em}.settings-tabs>li a.active{background-color:#fff}.settings-tab-section{padding:20px 0 0;max-width:1030px;position:relative}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard{display:flex;align-items:flex-start;align-content:flex-start;margin-top:40px}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-description{width:55%;margin:0 auto 0 0}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content{width:35%;margin:0 auto}.settings-tab-section.cloudinary-welcome .settings-tab-section-fields-dashboard-content .dashicons{color:#9ea3a8}.settings-tab-section.cloudinary-welcome .settings-tab-section-card{margin-top:0}.settings-tab-section-fields .field-heading th{display:block;width:auto;color:#23282d;font-size:1.1em;margin:1em 0}.settings-tab-section-fields .field-heading td{display:none;visibility:hidden}.settings-tab-section-fields .regular-textarea{width:100%;height:60px}.settings-tab-section-fields .dashicons{text-decoration:none;vertical-align:middle}.settings-tab-section-fields a .dashicons{color:#5f5f5f}.settings-tab-section-fields-dashboard-error{font-size:1.2em;color:#5f5f5f}.settings-tab-section-fields-dashboard-error .dashicons{color:#ac0000}.settings-tab-section-fields-dashboard-error .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success{font-size:1.2em;color:#23282d}.settings-tab-section-fields-dashboard-success.expanded{padding-top:40px}.settings-tab-section-fields-dashboard-success .dashicons{color:#4fb651}.settings-tab-section-fields-dashboard-success .button{font-size:1.1em;height:40px;line-height:40px;padding-right:40px;padding-left:40px}.settings-tab-section-fields-dashboard-success .description{color:#5f5f5f;font-weight:400;margin-top:12px}.settings-tab-section-card{box-sizing:border-box;border:1px solid #e5e5e5;background-color:#fff;box-shadow:0 1px 1px 0 rgba(0,0,0,.07);padding:20px 23px;margin-top:12px}.settings-tab-section-card .dashicons{font-size:1.4em}.settings-tab-section-card h2{font-size:1.8em;font-weight:400;margin-top:0}.settings-tab-section-card.pull-right{width:450px;padding:12px;float:right;position:relative;z-index:10}.settings-tab-section-card.pull-right img.settings-image{box-shadow:0 2px 4px 0 rgba(0,0,0,.5);border:1px solid #979797;margin-top:12px}.settings-tab-section-card.pull-right h3,.settings-tab-section-card.pull-right h4{margin-top:0}.settings-tab-section .field-row-cloudinary_url,.settings-tab-section .field-row-signup{display:block}.settings-tab-section .field-row-cloudinary_url td,.settings-tab-section .field-row-cloudinary_url th,.settings-tab-section .field-row-signup td,.settings-tab-section .field-row-signup th{display:block;width:auto;padding:10px 0 0}.settings-tab-section .field-row-cloudinary_url td .sign-up,.settings-tab-section .field-row-cloudinary_url th .sign-up,.settings-tab-section .field-row-signup td .sign-up,.settings-tab-section .field-row-signup th .sign-up{vertical-align:baseline}.settings-tab-section.connect .form-table{display:inline-block;width:auto;max-width:580px}.settings-valid{color:#558b2f;font-size:30px}.settings-valid-field{border-color:#558b2f!important}.settings-invalid-field{border-color:#dd2c00!important}.settings-warning{display:inline-block;padding:5px 7px;background-color:#ffea98;border-left:4px solid #fc0;box-shadow:0 0 5px 0 hsla(0,0%,43.9%,.4)}.sync .spinner{display:inline-block;visibility:visible;float:none;margin:0 5px 0 0}.sync-media,.sync-media-progress{display:none}.sync-media-progress-outer{height:20px;margin:20px 0 10px;width:500px;background-color:#e5e5e5;position:relative}.sync-media-progress-outer .progress-bar{width:0;height:20px;background-color:#558b2f;transition:width .25s}.sync-media-progress-notice{color:#dd2c00}.sync-media-resource{width:100px;display:inline-block}.sync-media-error{color:#dd2c00}.sync-count{font-weight:700}.sync-details{margin-top:10px}.sync .button.start-sync,.sync .button.stop-sync{display:none;padding:0 16px}.sync .button.start-sync .dashicons,.sync .button.stop-sync .dashicons{line-height:2.2em}.sync .progress-text{padding:12px 4px 12px 12px;display:inline-block;font-weight:700}.sync .completed{max-width:300px;display:none}.sync-status-disabled{color:#dd2c00}.sync-status-enabled{color:#558b2f}.sync-status-button.button{vertical-align:baseline}.cloudinary-widget{height:100%}.cloudinary-widget-wrapper{height:100%;overflow:hidden;background-image:url("data:image/svg+xml;base64,PHN2ZyBjbGFzcz0ic3Bpbm5lciIgdmlld0JveD0iLTQgLTQgMTUxIDEwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48c3R5bGU+QGtleWZyYW1lcyBjb2xvcnN7MCUsdG97c3Ryb2tlOiMwMDc4ZmZ9NTAle3N0cm9rZTojMGUyZjVhfX1Aa2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX1ALXdlYmtpdC1rZXlmcmFtZXMgY29sb3JzezAlLHRve3N0cm9rZTojMDA3OGZmfTUwJXtzdHJva2U6IzBlMmY1YX19QC13ZWJraXQta2V5ZnJhbWVzIGRhc2h7MCUsdG97c3Ryb2tlLWRhc2hvZmZzZXQ6NTYwfTUwJXtzdHJva2UtZGFzaG9mZnNldDowfX08L3N0eWxlPjxwYXRoIGQ9Ik0xMjEuNjYzIDkwLjYzOGMtMS43OTYgMC05OS4zMy0uNDk4LTEwMS40NzQtMS40NzhDOC42ODUgODMuODc3IDEuMjUgNzIuMTk2IDEuMjUgNTkuMzk2YzAtMTYuNjU2IDEyLjc5Ny0zMC42MSAyOS4wNTItMzIuMzIzIDcuNDktMTUuNzA2IDIzLjE4Ni0yNS43MDcgNDAuNzE0LTI1LjcwNyAyMC45OCAwIDM5LjIxNSAxNC43NTIgNDMuOTQ1IDM0LjkwNyAxNS4wOS4yNDUgMjcuMjkgMTIuNjMgMjcuMjkgMjcuODIyIDAgMTEuOTY4LTcuNzM4IDIyLjU1LTE5LjI1NiAyNi4zMyIgc3Ryb2tlLXdpZHRoPSI5IiBzdHJva2UtbGluZWNhcD0icm91bmQiIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3R5bGU9InRyYW5zZm9ybS1vcmlnaW46Y2VudGVyOy13ZWJraXQtYW5pbWF0aW9uOmRhc2ggMnMgZWFzZS1pbi1vdXQgaW5maW5pdGUsY29sb3JzIDhzIGVhc2UtaW4tb3V0IGluZmluaXRlO2FuaW1hdGlvbjpkYXNoIDJzIGVhc2UtaW4tb3V0IGluZmluaXRlLGNvbG9ycyA4cyBlYXNlLWluLW91dCBpbmZpbml0ZSIgc3Ryb2tlLWRhc2hhcnJheT0iMjgwIi8+PC9zdmc+");background-repeat:no-repeat;background-position:50%;background-size:150px}.attachment-actions .button.edit-attachment,.attachment-info .edit-attachment{display:none}.global-transformations-preview{position:relative;max-width:600px}.global-transformations-spinner{display:none}.global-transformations-button.button-primary{display:none;position:absolute;z-index:100}.global-transformations-url{margin-bottom:5px;margin-top:5px}.global-transformations-url-transformation{max-width:100px;overflow:hidden;text-overflow:ellipsis;color:#51a3ff}.global-transformations-url-file{color:#f2d864}.global-transformations-url-link{display:block;padding:16px;background-color:#262c35;text-decoration:none;color:#fff;border-radius:6px;overflow:hidden;text-overflow:ellipsis}.global-transformations-url-link:hover{color:#888;text-decoration:underline}.cld-tax-order-list-item{border:1px solid #efefef;padding:4px;margin:0 0 -1px;background-color:#fff}.cld-tax-order-list-item.no-items{color:#888;text-align:center;display:none}.cld-tax-order-list-item.no-items:last-child{display:block}.cld-tax-order-list-item.ui-sortable-helper{box-shadow:0 2px 5px rgba(0,0,0,.2)}.cld-tax-order-list-item-placeholder{background-color:#efefef;height:45px;margin:0}.cld-tax-order-list-item-handle{cursor:grab;margin-right:4px;color:#999}.cld-tax-order-list-type{width:45%;display:inline-block;margin-right:8px}.cld-tax-order-list-type input{margin-right:4px!important}.cloudinary-media-library{position:relative;margin-left:-20px}@media screen and (max-width:782px){.cloudinary-media-library{margin-left:-10px}} \ No newline at end of file diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js index 1c6d3ecbb..a0b8b63f0 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/js/cloudinary.js @@ -1 +1 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3)}([function(e,t){!function(){const e=function(){const e=jQuery("#field-video_player").val(),t=jQuery("#field-video_controls").prop("checked"),i=jQuery('#field-video_autoplay_mode option[value="off"]');"cld"!==e||t?i.prop("disabled",!1):(i.prop("disabled",!0),i.prop("selected")&&i.next().prop("selected",!0))};e(),jQuery(document).on("change","#field-video_player",e),jQuery(document).on("change","#field-video_controls",e),jQuery(document).ready((function(e){e(document).on("tabs.init",(function(){var t=e(".settings-tab-trigger"),i=e(".settings-tab-section");e(this).on("click",".settings-tab-trigger",(function(n){var s=e(this),a=e(s.attr("href"));n.preventDefault(),t.removeClass("active"),i.removeClass("active"),s.addClass("active"),a.addClass("active"),e(document).trigger("settings.tabbed",s)})),e(".cld-field").not('[data-condition="false"]').each((function(){const t=e(this),i=t.data("condition");for(let n in i){const s=i[n],a=e("#field-"+n),o=t.closest("tr");a.on("change init",(function(){this.value===s||this.checked?o.show():o.hide()})),a.trigger("init")}})),e("#field-cloudinary_url").on("input change",(function(){let t=e(this),i=t.val();new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\/\/){1}(\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g).test(i)?(t.addClass("settings-valid-field"),t.removeClass("settings-invalid-field")):(t.removeClass("settings-valid-field"),t.addClass("settings-invalid-field"))})).trigger("change")})),e(".render-trigger[data-event]").each((function(){var t=e(this),i=t.data("event");t.trigger(i,this)}))}))}(window,jQuery)},function(e,t){if(wp.media&&window.CLDN){wp.media.events.on("editor:image-edit",(function(e){e.metadata.cldoverwrite=null,e.image.className.split(" ").indexOf("cld-overwrite")>=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,o=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,e.percent<100?(this.barSyncCount.innerText=e.total,this.progressCount.innerText=e.done,this.progress.style.display=this.show):(this.completed.style.display=this.show,this.progress.style.display=this.hide)},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var o=a;a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var r=i(1),l=i.n(r);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),o=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${o})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var p=u;const m={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=m;m._init();i(2);i.d(t,"cloudinary",(function(){return f}));window.$=window.jQuery;const f={settings:s.a,sync:o,widget:l.a,Global_Transformations:c,Terms_Order:p,Media_Library:h}}]); \ No newline at end of file +!function(e){var t={};function i(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)i.d(n,s,function(t){return e[t]}.bind(null,s));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=3)}([function(e,t){!function(){const e=function(){const e=jQuery("#field-video_player").val(),t=jQuery("#field-video_controls").prop("checked"),i=jQuery('#field-video_autoplay_mode option[value="off"]');"cld"!==e||t?i.prop("disabled",!1):(i.prop("disabled",!0),i.prop("selected")&&i.next().prop("selected",!0))};e(),jQuery(document).on("change","#field-video_player",e),jQuery(document).on("change","#field-video_controls",e),jQuery(document).ready((function(e){e(document).on("tabs.init",(function(){var t=e(".settings-tab-trigger"),i=e(".settings-tab-section");e(this).on("click",".settings-tab-trigger",(function(n){var s=e(this),a=e(s.attr("href"));n.preventDefault(),t.removeClass("active"),i.removeClass("active"),s.addClass("active"),a.addClass("active"),e(document).trigger("settings.tabbed",s)})),e(".cld-field").not('[data-condition="false"]').each((function(){const t=e(this),i=t.data("condition");for(let n in i){const s=i[n],a=e("#field-"+n),o=t.closest("tr");a.on("change init",(function(){this.value===s||this.checked?o.show():o.hide()})),a.trigger("init")}})),e("#field-cloudinary_url").on("input change",(function(){let t=e(this),i=t.val();new RegExp(/^(?:CLOUDINARY_URL=)?(cloudinary:\/\/){1}(\d)*[:]{1}[^:@]*[@]{1}[^@]*$/g).test(i)?(t.addClass("settings-valid-field"),t.removeClass("settings-invalid-field")):(t.removeClass("settings-valid-field"),t.addClass("settings-invalid-field"))})).trigger("change")})),e(".render-trigger[data-event]").each((function(){var t=e(this),i=t.data("event");t.trigger(i,this)}))}))}(window,jQuery)},function(e,t){if(wp.media&&window.CLDN){wp.media.events.on("editor:image-edit",(function(e){e.metadata.cldoverwrite=null,e.image.className.split(" ").indexOf("cld-overwrite")>=0&&(e.metadata.cldoverwrite="true")})),wp.media.events.on("editor:image-update",(function(e){let t=e.image.className.split(" ");e.metadata.cldoverwrite&&-1===t.indexOf("cld-overwrite")?t.push("cld-overwrite"):!e.metadata.cldoverwrite&&t.indexOf("cld-overwrite")>=0&&delete t[t.indexOf("cld-overwrite")],e.image.className=t.join(" ")}));let e=null,t=wp.media.string.props;wp.media.string.props=function(i,n){return i.cldoverwrite&&(i.classes=["cld-overwrite"],e=!0),t(i,n)},wp.media.post=function(t,i){if("send-attachment-to-editor"===t){let t=wp.media.editor.get().state().get("selection").get(i.attachment);t.attributes.transformations&&(i.attachment.transformations=t.attributes.transformations),(i.html.indexOf("cld-overwrite")>-1||!0===e)&&(i.attachment.cldoverwrite=!0,e=null)}return wp.ajax.post(t,i)};wp.media.controller.Library;let i=wp.media.view.MediaFrame.Select,n=wp.media.view.MediaFrame.Post,s=wp.media.view.MediaFrame.ImageDetails,a=wp.media.view.MediaFrame.VideoDetails,o=wp.media.View.extend({tagName:"div",className:"cloudinary-widget",template:wp.template("cloudinary-dam"),active:!1,toolbar:null,frame:null,ready:function(){let e=this.controller,t=this.model.get("selection"),i=this.model.get("library"),n=wp.media.model.Attachment;if(CLDN.mloptions.multiple=e.options.multiple,this.cid!==this.active){if(CLDN.mloptions.inline_container="#cloudinary-dam-"+e.cid,1===t.length){var s=n.get(t.models[0].id);void 0!==s.attributes.public_id&&(CLDN.mloptions.asset={resource_id:s.attributes.public_id})}else CLDN.mloptions.asset=null;window.ml=cloudinary.openMediaLibrary(CLDN.mloptions,{insertHandler:function(s){for(let a=0;a=100&&void 0!==e.started?(this.submitButton.style.display=this.hide,this.stopButton.style.display=this.show):e.pending>0?(this.submitButton.style.display=this.show,this.stopButton.style.display=this.hide):e.processing>0?this.stopButton.style.display=this.show:this.stopButton.style.display=this.hide,100===e.percent&&(this.completed.style.display=this.show),this.isRunning?this.progress.style.display=this.show:this.progress.style.display=this.hide},_start:function(e){e.preventDefault(),a.stopButton.style.display=a.show,a.submitButton.style.display=a.hide,a.pushAttachments()},_reset:function(e){a.submitButton.style.display=a.hide,a.getStatus()},_init:function(e){"undefined"!=typeof cloudinaryApi&&((document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?e():document.addEventListener("DOMContentLoaded",e))}};var o=a;a._init((function(){a._reset(),a.submitButton.addEventListener("click",a._start),a.stopButton.addEventListener("click",a.stopSync)}));var r=i(1),l=i.n(r);const d={sample:{image:document.getElementById("transformation-sample-image"),video:document.getElementById("transformation-sample-video")},preview:{image:document.getElementById("sample-image"),video:document.getElementById("sample-video")},fields:document.getElementsByClassName("cld-field"),button:{image:document.getElementById("refresh-image-preview"),video:document.getElementById("refresh-video-preview")},spinner:{image:document.getElementById("image-loader"),video:document.getElementById("video-loader")},activeItem:null,elements:{image:[],video:[]},_placeItem:function(e){null!==e&&(e.style.display="block",e.style.visibility="visible",e.style.position="absolute",e.style.top=e.parentElement.clientHeight/2-e.clientHeight/2+"px",e.style.left=e.parentElement.clientWidth/2-e.clientWidth/2+"px")},_setLoading:function(e){this.button[e].style.display="block",this._placeItem(this.button[e]),this.preview[e].style.opacity="0.1"},_build:function(e){this.sample[e].innerHTML="",this.elements[e]=[];for(let t of this.fields){if(e!==t.dataset.context)continue;let i=t.value.trim();if(i.length){if("select-one"===t.type){if("none"===i)continue;i=t.dataset.meta+"_"+i}else{let e=t.dataset.context;i=this._transformations(i,e,!0)}i&&this.elements[e].push(i)}}let t="";this.elements[e].length&&(t="/"+this.elements[e].join(",").replace(/ /g,"%20")),this.sample[e].textContent=t,this.sample[e].parentElement.href="https://res.cloudinary.com/demo/"+this.sample[e].parentElement.innerText.trim().replace("../","").replace(/ /g,"%20")},_clearLoading:function(e){this.spinner[e].style.visibility="hidden",this.activeItem=null,this.preview[e].style.opacity=1},_refresh:function(e,t){e&&e.preventDefault();let i=this,n=CLD_GLOBAL_TRANSFORMATIONS[t].preview_url+i.elements[t].join(",")+CLD_GLOBAL_TRANSFORMATIONS[t].file;if(this.button[t].style.display="none",this._placeItem(this.spinner[t]),"image"===t){let e=new Image;e.onload=function(){i.preview[t].src=this.src,i._clearLoading(t),e.remove()},e.onerror=function(){alert(CLD_GLOBAL_TRANSFORMATIONS[t].error),i._clearLoading(t)},e.src=n}else{let e=i._transformations(i.elements[t].join(","),t);samplePlayer.source({publicId:"dog",transformation:e}),i._clearLoading(t)}},_transformations:function(e,t,i=!1){let n=CLD_GLOBAL_TRANSFORMATIONS[t].valid_types,s=null,a=e.split("/"),o=[];for(let e=0;e{const n=!!i.length&&jQuery('[data-item="'+s+":"+i[0].id+'"]');n.length?n.remove():(jQuery(`.cld-tax-order-list-item:contains(${o})`).remove(),--e.startId),this.processTags(t)})}),jQuery("body").on("change",".selectit input",(function(){const t=jQuery(this),i=t.val(),n=t.is(":checked"),s=t.parent().text().trim();!0===n?e.tags.find(`[data-item="category:${i}"]`).length||e._pushItem(`category:${i}`,s):e.tags.find(`[data-item="category:${i}"]`).remove()}))},_createItem:function(e,t){const i=jQuery("
  • "),n=jQuery(""),s=jQuery("");return i.addClass("cld-tax-order-list-item").attr("data-item",e),s.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(e),n.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),i.append(n).append(t).append(s),i},_pushItem:function(e,t){let i=this._createItem(e,t);this.tags.append(i)},_sortable:function(){jQuery(".cld-tax-order-list").sortable({connectWith:".cld-tax-order",axis:"y",handle:".cld-tax-order-list-item-handle",placeholder:"cld-tax-order-list-item-placeholder",forcePlaceholderSize:!0,helper:"clone"})}};if(void 0!==window.CLDN&&(u._init(),jQuery("[data-wp-lists] .selectit input[checked]").map((e,t)=>{jQuery(t).trigger("change")})),wp.data&&wp.data.select("core/editor")){const e={};wp.data.subscribe((function(){let t=wp.data.select("core").getTaxonomies();if(t)for(let i in t){const n=wp.data.select("core/editor").getEditedPostAttribute(t[i].rest_base);e[t[i].slug]=n}}));const t=wp.element.createElement,i=i=>{class n extends i{constructor(e){super(e),this.currentItems=jQuery(".cld-tax-order-list-item").map((e,t)=>jQuery(t).data("item")).get()}makeItem(e){if(this.currentItems.includes(this.getId(e)))return;const t=this.makeElement(e);jQuery("#cld-tax-items").append(t)}removeItem(e){const t=jQuery(`[data-item="${this.getId(e)}"]`);t.length&&(t.remove(),this.currentItems=this.currentItems.filter(t=>t!==this.getId(e)))}findOrCreateTerm(e){return(e=super.findOrCreateTerm(e)).then(e=>this.makeItem(e)),e}onChange(t){super.onChange(t);const i=this.pickItem(t);i&&(e[this.props.slug].includes(i.id)?this.makeItem(i):this.removeItem(i))}pickItem(e){if("object"==typeof e){if(e.target){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===parseInt(e.target.value))return this.state.availableTerms[t]}else if(Array.isArray(e)){let t=this.state.selectedTerms.filter(t=>!e.includes(t))[0];return void 0===t&&(t=e.filter(e=>!this.state.selectedTerms.includes(e))[0]),this.state.availableTerms.find(e=>e.name===t)}}else if("number"==typeof e){for(let t in this.state.availableTerms)if(this.state.availableTerms[t].id===e)return this.state.availableTerms[t]}else{let t;if(e.length>this.state.selectedTerms.length)for(let i in e)-1===this.state.selectedTerms.indexOf(e[i])&&(t=e[i]);else for(let i in this.state.selectedTerms)-1===e.indexOf(this.state.selectedTerms[i])&&(t=this.state.selectedTerms[i]);for(let e in this.state.availableTerms)if(this.state.availableTerms[e].name===t)return this.state.availableTerms[e]}}getId(e){return`${this.props.slug}:${e.id}`}makeElement(e){const t=jQuery("
  • "),i=jQuery(""),n=jQuery("");return t.addClass("cld-tax-order-list-item").attr("data-item",this.getId(e)),n.addClass("cld-tax-order-list-item-input").attr("type","hidden").attr("name","cld_tax_order[]").val(this.getId(e)),i.addClass("dashicons dashicons-menu cld-tax-order-list-item-handle"),t.append(i).append(e.name).append(n),t}}return e=>t(n,e)};wp.hooks.addFilter("editor.PostTaxonomyType","cld",i)}var p=u;const m={wpWrap:document.getElementById("wpwrap"),wpContent:document.getElementById("wpbody-content"),libraryWrap:document.getElementById("cloudinary-embed"),_init:function(){let e=this;"undefined"!=typeof CLD_ML&&(cloudinary.openMediaLibrary(CLD_ML.mloptions,{insertHandler:function(e){alert("Import is not yet implemented.")}}),window.addEventListener("resize",(function(t){e._resize()})),e._resize())},_resize:function(){let e=getComputedStyle(this.wpContent);this.libraryWrap.style.height=this.wpWrap.offsetHeight-parseInt(e.getPropertyValue("padding-bottom"))+"px"}};var h=m;m._init();i(2);i.d(t,"cloudinary",(function(){return f}));window.$=window.jQuery;const f={settings:s.a,sync:o,widget:l.a,Global_Transformations:c,Terms_Order:p,Media_Library:h}}]); \ No newline at end of file From 1208e2696d63d1bd4960200ed9946e55f1db6ef2 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Wed, 1 Jul 2020 07:06:03 +0200 Subject: [PATCH 25/28] Handle error from prepare_upload. --- .../php/class-sync.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index 44968e555..d846e4568 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -115,10 +115,15 @@ public function is_synced( $post_id ) { * * @param int $post_id The post id to generate a signature for. * - * @return string + * @return string|bool */ public function generate_signature( $post_id ) { - $upload = $this->managers['push']->prepare_upload( $post_id ); + $upload = $this->managers['push']->prepare_upload( $post_id ); + // Check if has an error (ususally due to file quotas). + if ( is_wp_error( $upload ) ) { + $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['sync_error'], $upload->get_error_message() ); + return false; + } $credentials = $this->plugin->components['connect']->get_credentials(); $upload['cloud_name'] = $credentials['cloud_name']; $return = array_map( From cd38003c412ec20dec2343be56929eda2c519efe Mon Sep 17 00:00:00 2001 From: David Cramer Date: Wed, 1 Jul 2020 07:21:31 +0200 Subject: [PATCH 26/28] return not synced if exeeding --- .../php/class-sync.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php index d846e4568..7f2c9816e 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/class-sync.php @@ -103,7 +103,7 @@ public function is_synced( $post_id ) { $return = false; $signature = $this->get_signature( $post_id ); $expecting = $this->generate_signature( $post_id ); - if ( ! empty( $signature ) && $expecting === $signature ) { + if ( ! empty( $signature ) && ! empty( $expecting ) && $expecting === $signature ) { $return = $signature; } @@ -122,6 +122,7 @@ public function generate_signature( $post_id ) { // Check if has an error (ususally due to file quotas). if ( is_wp_error( $upload ) ) { $this->plugin->components['media']->get_post_meta( $post_id, self::META_KEYS['sync_error'], $upload->get_error_message() ); + return false; } $credentials = $this->plugin->components['connect']->get_credentials(); From 3d3e28a3fb45492abc43d2a6fcaef33aa25f9288 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Wed, 1 Jul 2020 10:02:19 +0200 Subject: [PATCH 27/28] version bump --- .../cloudinary.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php index e3c28c44f..cc57f687c 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/cloudinary.php @@ -3,7 +3,7 @@ * Plugin Name: Cloudinary * Plugin URI: https://cloudinary.com/documentation/wordpress_integration * Description: With the Cloudinary plugin, you can upload and manage your media assets in the cloud, then deliver them to your users through a fast content delivery network, improving your website’s loading speed and overall user experience. Apply multiple transformations and take advantage of a full digital asset management solution without leaving WordPress. - * Version: 2.1.2 + * Version: 2.1.3 * Author: Cloudinary Ltd., XWP * Author URI: https://cloudinary.com/ * License: GPLv2+ From 48d84a4bcf64cd2b1c4492cb0e88c041c0e687f6 Mon Sep 17 00:00:00 2001 From: David Cramer Date: Wed, 1 Jul 2020 12:44:55 +0200 Subject: [PATCH 28/28] ltrim forward slashes on public ID --- .../php/sync/class-push-sync.php | 2 +- .../php/sync/class-upload-sync.php | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php index da9238bae..3a8539b1d 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-push-sync.php @@ -487,7 +487,7 @@ public function prepare_upload( $post, $down_sync = false ) { } // Restructure the path to the filename to allow correct placement in Cloudinary. - $public_id = $public_id_folder . $options['public_id']; + $public_id = ltrim( $public_id_folder . $options['public_id'], '/' ); $return = array( 'file' => $file, 'folder' => $cld_folder, diff --git a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php index f3a8bfcce..60f3cf7c8 100644 --- a/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php +++ b/cloudinary-image-management-and-manipulation-in-the-cloud-cdn/php/sync/class-upload-sync.php @@ -72,7 +72,7 @@ private function register_hooks() { // Hook for on demand upload push. add_action( 'shutdown', array( $this, 'init_background_upload' ) ); // Hook into auto upload sync. - add_filter( 'cloudinary_on_demand_sync_enabled', array( $this, 'auto_sync_enabled' ) ); + add_filter( 'cloudinary_on_demand_sync_enabled', array( $this, 'auto_sync_enabled' ), 10, 2 ); // Handle bulk and inline actions. add_filter( 'handle_bulk_actions-upload', array( $this, 'handle_bulk_actions' ), 10, 3 ); // Add inline action. @@ -160,14 +160,20 @@ public function handle_bulk_actions( $location, $action, $post_ids ) { * Check if auto-sync is enabled. * * @param bool $enabled Flag to determine if autosync is enabled. + * @param int $post_id The post id currently processing. * * @return bool */ - public function auto_sync_enabled( $enabled ) { + public function auto_sync_enabled( $enabled, $post_id ) { if ( isset( $this->plugin->config['settings']['sync_media']['auto_sync'] ) && 'on' === $this->plugin->config['settings']['sync_media']['auto_sync'] ) { $enabled = true; } + // Check if it was synced before to allow re-sync for changes. + if ( ! empty( $this->plugin->components['sync']->get_signature( $post_id ) ) ) { + $enabled = true; + } + return $enabled; } @@ -211,7 +217,7 @@ public function prep_on_demand_upload( $cloudinary_id, $attachment_id ) { $attachment_id = intval( $attachment_id ); if ( $attachment_id && false === $cloudinary_id ) { // Check that this has not already been prepared for upload. - if ( ! $this->is_pending( $attachment_id ) && apply_filters( 'cloudinary_on_demand_sync_enabled', $this->enabled ) ) { + if ( ! $this->is_pending( $attachment_id ) && apply_filters( 'cloudinary_on_demand_sync_enabled', $this->enabled, $attachment_id ) ) { $max_size = ( wp_attachment_is_image( $attachment_id ) ? 'max_image_size' : 'max_video_size' ); $file = get_attached_file( $attachment_id ); // Get the file size to make sure it can exist in cloudinary.