From 4e61cd4b3235ac5b6e28504442875ff4f131de4e Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 15 Jun 2018 00:32:58 +0200 Subject: [PATCH 01/39] Improved opcache reset on plugin upgrade. Introduced `imagify_reset_opcache()`. --- inc/admin/upgrader.php | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/inc/admin/upgrader.php b/inc/admin/upgrader.php index 6937397c4..d39c2fd7a 100755 --- a/inc/admin/upgrader.php +++ b/inc/admin/upgrader.php @@ -310,21 +310,37 @@ function imagify_maybe_reset_opcache( $wp_upgrader, $hook_extra ) { return; } - if ( ! isset( $can_reset ) ) { - $can_reset = true; + imagify_reset_opcache(); +} + +/** + * Reset PHP opcache. + * + * @since 1.8.1 + * @author Grégory Viguier + */ +function imagify_reset_opcache() { + static $can_reset; + if ( ! isset( $can_reset ) ) { if ( ! function_exists( 'opcache_reset' ) ) { $can_reset = false; + return; } $restrict_api = ini_get( 'opcache.restrict_api' ); if ( $restrict_api && strpos( __FILE__, $restrict_api ) !== 0 ) { $can_reset = false; + return; } + + $can_reset = true; } - if ( $can_reset ) { - opcache_reset(); + if ( ! $can_reset ) { + return; } + + opcache_reset(); } From 5abc33298037eabfeada4e4eade0148ff42c1e56 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 15 Jun 2018 01:03:13 +0200 Subject: [PATCH 02/39] Improved column width in media list. --- assets/css/admin.css | 9 +- assets/css/admin.min.css | 1470 +++++++++++++++++++++++++++++++++++++- 2 files changed, 1474 insertions(+), 5 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 174ea28ae..b9c97e7c4 100755 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -1028,12 +1028,12 @@ p.imagify-section-title.imagify-section-title { vertical-align: middle; } .column-imagify_optimized_file > * { - max-width: 235px; + max-width: 21em; margin: 0 auto; } @media (min-width: 1151px) and (max-width: 1800px) { .column-imagify_optimized_file.column-imagify_optimized_file { - width: 235px; + width: 21em; } } @media (min-width: 783px) and (max-width: 1150px) { @@ -1097,14 +1097,15 @@ li.imagify-data-item { ul.imagify-datas-list .imagify-data-item span.data, ul.imagify-datas-list .imagify-data-item strong { float: left; - width: 50%; + width: 38%; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } ul.imagify-datas-list .imagify-data-item span.data { - text-align: left; + width: 62%; padding-right: 5px; + text-align: left; } .compat-field-imagify .imagify-datas-list .imagify-data-item .data { width: 130px; diff --git a/assets/css/admin.min.css b/assets/css/admin.min.css index e7dc5989c..b9c97e7c4 100755 --- a/assets/css/admin.min.css +++ b/assets/css/admin.min.css @@ -1 +1,1469 @@ -.imagify-count-list li,.imagify-flex{display:-webkit-box;display:-ms-flexbox}.imagify-oh,body.imagify-modal-is-open{overflow:hidden}.imagify-flex{display:flex}.imagify-vcenter{-webkit-box-align:center;-ms-flex-align:center;align-items:center}.imagify-noshrink{-ms-flex-negative:0;flex-shrink:0}.imagify-nogrow{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0}.imagify-wauto{width:auto}.imagify-hauto{height:auto}.imagify-full-width{width:100%}.imagify-start{float:left}.imagify-end{float:right}.imagify-txt-start.imagify-txt-start.imagify-txt-start{text-align:left}.imagify-txt-center.imagify-txt-center.imagify-txt-center{text-align:center}.imagify-txt-end.imagify-txt-end.imagify-txt-end{text-align:right}.imagify-mt0.imagify-mt0{margin-top:0}.imagify-mt1.imagify-mt1{margin-top:1em}.imagify-mt2.imagify-mt2{margin-top:2em}.imagify-mt3.imagify-mt3{margin-top:3em}.imagify-mb0.imagify-mb0{margin-bottom:0}.imagify-mb1.imagify-mb1{margin-bottom:1em}.imagify-mr1.imagify-mr1{margin-right:1em}.imagify-ml2.imagify-ml2{margin-left:2em}.imagify-mr2.imagify-mr2{margin-right:2em}.imagify-pl0.imagify-pl0.imagify-pl0{padding-left:0}.imagify-pb0.imagify-pb0{padding-bottom:0}.imagify-pr1.imagify-pr1{padding-right:1em}.imagify-pr2.imagify-pr2{padding-right:2em}.imagify-clear{clear:both}.imagify-clearfix:after,.imagify-inline-options:after,.imagify-settings-main-content:after,.imagify-settings-section:after{content:"";display:table;width:100%;clear:both}.imagify-setting-optim-level .imagify-inline-options:after{display:none}.imagify-divider{height:1px;margin:20px 0;background:#D2D3D6}.imagify-pipe{display:inline-block;margin:0 .75em;vertical-align:middle;height:15px;width:1px;background:#979797}.imagify-cell,.imagify-cell.va-top,.va-top .imagify-cell{vertical-align:top}.imagify-h3-like.imagify-h3-like.imagify-h3-like{margin-bottom:0;font-size:19px;font-weight:500;color:#1F2332}.imagify-h4-like.imagify-h4-like.imagify-h4-like{font-size:14px;font-weight:700;color:#2E3243}.imagify-count.imagify-count{counter-reset:num}.imagify-count .imagify-count-title{font-weight:700}.imagify-default-settings{color:#73818c;font-weight:400}.imagify-count .imagify-count-title:before{counter-increment:num 1;content:counter(num) ". "}.imagify-count-list{counter-reset:listcount}.imagify-count-list li{display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.imagify-count-list li+li{margin-top:.5em}.imagify-count-list li:before{display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-preferred-size:24px;flex-basis:24px;-ms-flex-negative:0;flex-shrink:0;-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;margin-right:16px;border:2px solid #40b1d0;width:24px;height:24px;counter-increment:listcount 1;content:counter(listcount);color:#40b1d0;border-radius:50%}.imagify-table{display:table;width:100%}.imagify-cell{display:table-cell;padding:10px}.imagify-bulk-submit .imagify-cell{padding-top:0}.imagify-spinner{display:inline-block;width:20px;height:20px;margin-right:5px;vertical-align:middle;background:url(../images/spinner.gif) 0 0/20px 20px no-repeat rgba(0,0,0,0);opacity:.7}.spinner.imagify-hidden{width:0;margin:4px 0 0}.imagify-primary.imagify-primary.imagify-primary{color:#40b1d0}.imagify-secondary.imagify-secondary.imagify-secondary,.imagify-valid{color:#8BC34A}.misc-pub-section.misc-pub-imagify h4{font-size:14px;margin-top:5px;margin-bottom:0}.imagify-chart{position:relative;top:1px;display:inline-block;vertical-align:middle}.imagify-chart-container{position:relative;display:inline-block;margin-right:5px}.imagify-chart-container canvas{display:block}.imagify-settings .button,.imagify-settings a,.imagify-settings input,.imagify-welcome .button,.imagify-welcome a,.imagify-weolcome input{-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}.imagify-settings a{color:#40b1d0}.imagify-settings,.imagify-settings p,.imagify-settings th{color:#5F758E}.imagify-button-primary.imagify-button-primary,.imagify-button-secondary.imagify-button-secondary,.imagify-button.imagify-button,.imagify-notice .button,.imagify-settings .button,.imagify-welcome .button{height:auto;padding:11px 22px;border:0;font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:.01em;word-spacing:.01em;-webkit-box-shadow:0 3px 0 rgba(0,0,0,.15);box-shadow:0 3px 0 rgba(0,0,0,.15);border-radius:3px;cursor:pointer;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}.button-primary.button-mini{padding:2px 10px}.imagify-settings .button.button-mini-flat{padding:3px 6px 5px;font-size:12px;-webkit-box-shadow:none!important;box-shadow:none!important;line-height:1.2}.imagify-settings .button.button-mini-flat:focus,.imagify-settings .button.button-mini-flat:hover{-webkit-box-shadow:none!important;box-shadow:none!important}.imagify-button-ghost.imagify-button-ghost,.imagify-title .button-ghost.button-ghost{padding:2px 9px;border:1px solid #40B1D0;font-size:12px;font-weight:400;color:#40B1D0;background:0 0;-webkit-box-shadow:none;box-shadow:none}.imagify-button-ghost.imagify-button-ghost:focus,.imagify-button-ghost.imagify-button-ghost:hover,.imagify-title .button-ghost.button-ghost:focus,.imagify-title .button-ghost.button-ghost:hover{border-color:transparent;color:#000;background:#40B1D0}.imagify-button-ghost.imagify-button-ghost:focus,.imagify-button-ghost.imagify-button-ghost:hover{color:#FFF}.imagify-button-medium.imagify-button-medium{text-transform:uppercase;letter-spacing:.1em;padding:3px 10px;font-weight:700}.imagify-button-medium.imagify-button-ghost{border-width:2px}[class*=imagify-] .button .dashicons{margin-right:5px;vertical-align:middle}.imagify-button-primary.imagify-button-primary,.imagify-settings .button-primary.button-primary,.imagify-welcome .button-primary.button-primary{background:#40B1D0;color:#FFF;-webkit-box-shadow:0 3px 0 rgba(51,142,166,1);box-shadow:0 3px 0 rgba(51,142,166,1);text-shadow:0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799!important}.imagify-button-secondary.imagify-button-secondary{background:#8BC34A;color:#FFF;-webkit-box-shadow:0 3px 0 #6F9C3B;box-shadow:0 3px 0 #6F9C3B;text-shadow:0 -1px 1px #6F9C3B,1px 0 1px #6F9C3B,0 1px 1px #6F9C3B!important}.imagify-button-primary.imagify-button-primary:focus,.imagify-button-primary.imagify-button-primary:hover,.imagify-settings .button-primary:focus,.imagify-settings .button-primary:hover,.imagify-welcome .button-primary:focus,.imagify-welcome .button-primary:hover{background:#338ea6;-webkit-box-shadow:0 3px 0 #1f7a92;box-shadow:0 3px 0 #1f7a92}.imagify-button-secondary.imagify-button-secondary:focus,.imagify-button-secondary.imagify-button-secondary:hover{background:#6F9C3B;color:#FFF}.imagify-button-light.imagify-button-light{background:#FFF;color:#4a4a4a;-webkit-box-shadow:0 2px 0 rgba(0,0,0,.2);box-shadow:0 2px 0 rgba(0,0,0,.2)}.imagify-block-secondary .imagify-button-light.imagify-button-light{color:#6F9C3B}.imagify-button-light.imagify-button-light:focus,.imagify-button-light.imagify-button-light:hover{color:#FFF;background:rgba(0,0,0,.2)}.button.imagify-button-clean,.imagify-button-clean{padding:0;background:0 0;-webkit-box-shadow:none;box-shadow:none}.imagify-button-clean .dashicons-plus{width:32px;height:25px}.imagify-button-clean .dashicons-plus:before{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;width:25px;height:22px;margin-left:2px;padding-top:3px;font-size:17px;background:#40B1D0;color:#FFF;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}.button.imagify-button-clean:active,.button.imagify-button-clean:focus,.button.imagify-button-clean:hover,.button.imagify-button-clean[disabled]{background:0 0!important;color:#343A49;-webkit-box-shadow:none;box-shadow:none}.button.imagify-button-clean:focus .dashicons-plus:before,.button.imagify-button-clean:hover .dashicons-plus:before{background:#343A49}button.imagify-link-like{border:0;padding:0;color:inherit;text-decoration:underline;font-size:13px;-webkit-box-shadow:none;box-shadow:none;background:0 0;cursor:pointer}.imagify-section-positive .imagify-button-light{color:#709A41}.imagify-button.imagify-button-big{font-size:15px;padding:11px 30px}.imagify-button-big .dashicons{font-size:1.45em;margin-right:6px;margin-left:-4px}.imagify-button-primary.imagify-button-primary .dashicons,.imagify-button-secondary.imagify-button-secondary .dashicons,.imagify-button.imagify-button .dashicons,.imagify-notice .button .dashicons,.imagify-settings .button .dashicons,.imagify-welcome .button .dashicons{vertical-align:middle}[class*=imagify-] .button-text{display:inline-block;vertical-align:middle}.media-frame-content .imagify-button-primary,.wp_attachment_image .imagify-button-primary{padding:0 10px 1px;margin:0 5px 2px 0;font-size:13px;line-height:26px;-webkit-box-shadow:0 3px 0 rgba(51,142,166,1);box-shadow:0 3px 0 rgba(51,142,166,1)}.wp_attachment_image .imagify-button-primary{float:left}.imagify-title.imagify-title{position:relative;padding:10px 30px;font-size:23px;background:#1F2332;color:#FFF}.imagify-welcome .imagify-logo{opacity:1}.imagify-welcome .imagify-title{display:-webkit-box;display:-ms-flexbox;display:flex;padding:20px 30px}.imagify-settings .imagify-title{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:justify;-ms-flex-pack:justify;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.imagify-settings .imagify-logo-block{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-negative:0;flex-shrink:0;-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;padding:0;margin-right:35px;color:inherit}.imagify-logo-block sup{color:#1F2332}.imagify-settings .imagify-title+.imagify-notice{margin:0;border-right:1px solid #D9D9D9;padding-top:15px;padding-bottom:15px}.imagify-title .title-text{font-size:28px;font-weight:700;color:#FFF}.imagify-lb-icon{padding-right:18px}.imagify-lb-text img{margin-bottom:.15em}.imagify-lb-text{font-size:23px;font-weight:700;color:#FFF}.imagify-logo{display:block;vertical-align:top;opacity:.4}.imagify-section,.imagify-settings div.submit,.imagify-sub-header,.imagify-sub-title.imagify-sub-title{margin:0;padding:20px;background:#F2F5F7}.imagify-section-positive,.imagify-sub-title.imagify-sub-title{padding-left:40px}.imagify-section-positive{background:#8cc152;color:#FFF}.imagify-section-positive p{color:#FFF}.imagify-section-gray{background:#D9E4EB}.imagify-section-gray .imagify-count-title{color:#4a4a4a}.imagify-section p:first-child{margin-top:0}.imagify-section p:last-child{margin-bottom:0}.imagify-settings .imagify-documentation-link-box{display:-webkit-box;display:-ms-flexbox;display:flex;padding:12px 13px 14px;border:1px solid #40b1d0;color:#E5EBEF;border-radius:3px}.imagify-documentation-link-icon{width:23px;height:31px;font-size:2.6em;margin-right:15px;line-height:1.3}.imagify-documentation-link-box span{font-size:12px}.imagify-documentation-link-box a{font-weight:700}@media (max-width:1120px){.imagify-settings .imagify-title{-ms-flex-wrap:wrap;flex-wrap:wrap}}.imagify-settings-section{padding:10px 20px}.imagify-account-info-col .imagify-settings-section{padding-right:0}.imagify-settings-main-content,.imagify-welcome .imagify-settings-section{border:1px solid #D9D9D9;border-top-width:0;background:#FFF}.imagify-settings-main-content{padding-bottom:20px}.imagify-settings-main-content p{font-size:14px}.imagify-settings-main-content+.imagify-settings-main-content{margin-top:20px;border-top-width:1px}.imagify-br{line-height:2}p.imagify-section-title.imagify-section-title{font-size:20px;margin-top:-.3em;margin-bottom:-.6em}.imagify-rate-us.imagify-rate-us{text-align:right;margin:-1em -2.4em -1em 0;color:#FFF}.imagify-rate-us a{color:#40B1D0}.imagify-rate-us .stars{display:inline-block;margin:2px 0 0 10px;text-decoration:none;letter-spacing:.2em;vertical-align:-1px}.imagify-rate-us .stars .dashicons:before{font-size:18px}.imagify-rate-us a:focus,.imagify-rate-us a:hover{color:#FEE102}@media (max-width:1220px){.imagify-rate-us.imagify-rate-us{position:static;margin-bottom:0;text-align:left}.imagify-rate-us.imagify-rate-us br{display:none}.imagify-rate-us .stars{display:block;margin-left:0}}.imagify-important{color:#F5A623}.imagify-settings .imagify-success,.imagify-success{color:#8BC34A}.imagify-info,.imagify-info a{color:#7A8996;font-size:12px}.imagify-info{position:relative;display:inline-block;padding-left:25px}.imagify-info .dashicons{position:absolute;left:0;top:0;color:#40B1D0}.imagify-checkbox.imagify-checkbox:checked,.imagify-checkbox.imagify-checkbox:not(:checked),.imagify-settings.imagify-settings [type=checkbox]:checked,.imagify-settings.imagify-settings [type=checkbox]:not(:checked){position:absolute;opacity:.01}.imagify-checkbox.imagify-checkbox:checked:focus,.imagify-checkbox.imagify-checkbox:not(:checked):focus,.imagify-settings.imagify-settings [type=checkbox]:checked:focus,.imagify-settings.imagify-settings [type=checkbox]:not(:checked):focus{-webkit-box-shadow:none!important;box-shadow:none!important;outline:0!important;border:0!important}.imagify-checkbox.imagify-checkbox:checked+label,.imagify-checkbox.imagify-checkbox:not(:checked)+label,.imagify-settings [type=checkbox]:checked+label,.imagify-settings [type=checkbox]:not(:checked)+label{position:relative;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;min-height:24px;padding-left:40px;cursor:pointer;font-size:14px;font-weight:700;color:#2E3243}.imagify-checkbox.imagify-checkbox:checked+label:before,.imagify-checkbox.imagify-checkbox:not(:checked)+label:before,.imagify-settings [type=checkbox]:checked+label:before,.imagify-settings [type=checkbox]:not(:checked)+label:before{content:'';position:absolute;left:0;top:0;width:22px;height:22px;border:2px solid #8BA6B4;background:#FFF;border-radius:3px}.imagify-checkbox.imagify-checkbox:checked+label:after,.imagify-checkbox.imagify-checkbox:not(:checked)+label:after,.imagify-settings [type=checkbox]:checked+label:after,.imagify-settings [type=checkbox]:not(:checked)+label:after{content:"✓";position:absolute;font-size:1.4em;top:-2px;left:4.5px;color:#8BA6B4;font-weight:400;-webkit-transition:all .2s;-o-transition:all .2s;transition:all .2s}.imagify-checkbox.imagify-checkbox[disabled]:checked+label:before,.imagify-checkbox.imagify-checkbox[disabled]:not(:checked)+label:before,.imagify-settings [type=checkbox][disabled]:checked+label:before,.imagify-settings [type=checkbox][disabled]:not(:checked)+label:before{border-color:#ccc;background:#ddd}.imagify-checkbox.imagify-checkbox:not(:checked)+label:after,.imagify-settings [type=checkbox]:not(:checked)+label:after{opacity:0;-webkit-transform:scale(0);-ms-transform:scale(0);transform:scale(0)}.imagify-checkbox.imagify-checkbox:checked+label:after,.imagify-settings [type=checkbox]:checked+label:after{opacity:1;-webkit-transform:scale(1);-ms-transform:scale(1);transform:scale(1)}.medium.imagify-checkbox:checked+label:before,.medium.imagify-checkbox:not(:checked)+label:before{width:22px;height:22px;border-width:1.5px;border-radius:2px;margin-top:0}.medium.imagify-checkbox:checked+label:after,.medium.imagify-checkbox:not(:checked)+label:after{font-size:1.1em;left:-17px;top:3px}.imagify-settings .mini[type=checkbox]:checked+label:before,.imagify-settings .mini[type=checkbox]:not(:checked)+label:before,.mini.imagify-checkbox:checked+label:before,.mini.imagify-checkbox:not(:checked)+label:before{width:15px;height:15px;border-width:1px;border-radius:2px;margin-top:0}.imagify-settings .mini[type=checkbox]:checked+label:after,.imagify-settings .mini[type=checkbox]:not(:checked)+label:after,.mini.imagify-checkbox:checked+label:after,.mini.imagify-checkbox:not(:checked)+label:after{font-size:.9em;left:-21px;top:-.5px}.imagify-checkbox.imagify-checkbox:checked:focus+label:before,.imagify-checkbox.imagify-checkbox:not(:checked):focus+label:before,.imagify-settings [type=checkbox]:checked:focus+label:before,.imagify-settings [type=checkbox]:not(:checked):focus+label:before{border-style:dotted;border-color:#40b1d0}.imagify-check-group{padding-left:2px;margin-bottom:0}.imagify-check-group.imagify-is-scrollable{max-height:15em;overflow-y:auto;padding:8px;margin:1.5em 0 0 -8px;background:#F4F7F9;border:1px solid #D2D3D6;border-radius:3px}.imagify-is-scrollable legend+p{margin-top:0}.imagify-is-scrollable [type=checkbox]:checked+label:before,.imagify-is-scrollable [type=checkbox]:not(:checked)+label:before{background:#F4F7F9}.imagify-settings .imagify-check-group.imagify-check-group label{color:#338EA6;font-weight:500}.imagify-inline-options{position:relative;display:table;width:100%;max-width:600px;border-collapse:collapse}.imagify-inline-options input[type=radio]:checked,.imagify-inline-options input[type=radio]:not(:checked){position:absolute;left:5px;top:5px;display:none}.imagify-inline-options input[type=radio]:checked+label,.imagify-inline-options input[type=radio]:not(:checked)+label{position:relative;display:table-cell;padding:13px 10px;text-align:center;font-weight:600;font-size:16px;text-transform:uppercase;letter-spacing:.1em;color:#FFF;background:#2E3243;-webkit-box-shadow:0 -3px 0 rgba(0,0,0,.1) inset;box-shadow:0 -3px 0 rgba(0,0,0,.1) inset;z-index:2;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}.imagify-inline-options input[type=radio]:checked+label:first-of-type,.imagify-inline-options input[type=radio]:not(:checked)+label:first-of-type{border-radius:3px 0 0 3px}.imagify-inline-options input[type=radio]:checked+label:last-of-type,.imagify-inline-options input[type=radio]:not(:checked)+label:last-of-type{border-radius:0 3px 3px 0}.imagify-inline-options input[type=radio]:checked+label{background:#8BC34A}.imagify-inline-options .imagify-info{margin-top:15px}.imagify-account-info-col,.imagify-col.imagify-col.imagify-account-info-col{width:380px;max-width:100%;padding:0 20px 0 0}.imagify-col.imagify-col.imagify-shared-with-account-col,.imagify-shared-with-account-col{width:calc(100% - 380px);padding:0}.imagify-account-info-col .imagify-options-title{padding:24px 26px;color:#FFF;background:#1F2332}.imagify-block-secondary{padding:26px 26px 35px;border:1px solid #75A345;background:#8BC34A;border-radius:3px;color:#FFF}.imagify-account-info-col .imagify-block-secondary.imagify-block-secondary h3,.imagify-block-secondary.imagify-block-secondary p{color:inherit}.imagify-account-info-col .imagify-col-content h3:first-child{margin-top:0}.imagify-account-info-col .imagify-col-content h3{font-size:19px}.imagify-account-info-col .imagify-col-content p{margin:1.5em 0}.imagify-account-info-col .imagify-col-content p:first-child{margin-top:0}.imagify-user-plan-label{float:right;margin-top:-4px;padding:2px 10px;border:2px solid #40B1D0;font-size:14px;text-transform:uppercase;letter-spacing:.02em;color:#40B1D0;border-radius:3px}.imagify-modal .h2,.imagify-modal .h3{letter-spacing:.075em;text-align:center;font-weight:400}.imagify-user-plan-label:empty{display:none}.imagify-columns{overflow:hidden;padding:15px 0;counter-reset:cols}.imagify-columns [class^=col-]{float:left;-webkit-box-sizing:border-box;box-sizing:border-box}.imagify-columns .col-1-3{width:33.333%;padding-left:28px}.imagify-columns .col-2-3{width:66.666%;padding-left:28px}.imagify-columns .col-1-2{width:50%;padding:0 20px}@media (max-width:830px){.imagify-columns [class^=col-]{float:none;margin-bottom:1.5em}.imagify-columns .col-1-2,.imagify-columns .col-1-3{width:auto;padding:0 28px;clear:both;padding-top:1em}}.column-imagify_optimized_file.column-imagify_optimized_file{width:300px;text-align:center;vertical-align:middle}.column-imagify_optimized_file>*{max-width:235px;margin:0 auto}@media (min-width:1151px) and (max-width:1800px){.column-imagify_optimized_file.column-imagify_optimized_file{width:235px}}@media (min-width:783px) and (max-width:1150px){.column-imagify_optimized_file.column-imagify_optimized_file{width:13em}table.media .column-title .has-media-icon~.row-actions.row-actions{margin-left:0}}@media (max-width:782px){table.media .column-imagify_optimized_file.column-imagify_optimized_file{text-align:left}table.media .imagify-datas-actions-links,table.media .imagify-datas-more-action{text-align:center}table.media .column-imagify_optimized_file .imagify-datas-actions-links a,table.media .column-imagify_optimized_file>*{max-width:100%;margin-left:0}}@media (min-width:783px) and (max-width:1150px),(max-width:360px){table.media .imagify-hide-if-small{position:absolute;margin:-1px;padding:0;height:1px;width:1px;overflow:hidden;clip:rect(0 0 0 0);border:0;word-wrap:normal!important}}.compat-field-imagify .label{vertical-align:top}.compat-field-imagify ul.imagify-datas-list{margin-top:7px;font-size:11px}ul.imagify-datas-list.imagify-datas-list{margin:0 auto;color:#555;font-size:10px}ul.imagify-datas-list .big{font-size:12px;color:#40B1D0}.imagify-data-item{overflow:hidden}li.imagify-data-item{clear:both;margin-bottom:2px}ul.imagify-datas-list .imagify-data-item span.data,ul.imagify-datas-list .imagify-data-item strong{float:left;width:50%;-webkit-box-sizing:border-box;box-sizing:border-box}ul.imagify-datas-list .imagify-data-item span.data{text-align:left;padding-right:5px}.compat-field-imagify .imagify-datas-list .imagify-data-item .data{width:130px;text-align:left;font-weight:700}ul.imagify-datas-list .imagify-data-item strong{text-align:left;padding-left:5px}.media-sidebar .imagify-datas-list .imagify-data-item .data{width:auto;float:none}.media-sidebar .imagify-datas-list .imagify-data-item strong{display:inline-block;width:auto;float:none}.media-sidebar .imagify-datas-list .imagify-data-item .imagify-chart{float:left}.imagify-datas-more-action.imagify-datas-more-action{margin:.4em auto;background:-webkit-gradient(linear,left top,left bottom,from(transparent),color-stop(49%,transparent),color-stop(50%,rgba(0,0,0,.075)),color-stop(58%,rgba(0,0,0,.075)),color-stop(58%,transparent),to(transparent));background:-o-linear-gradient(top,transparent,transparent 49%,rgba(0,0,0,.075) 50%,rgba(0,0,0,.075) 58%,transparent 58%,transparent);background:linear-gradient(to bottom,transparent,transparent 49%,rgba(0,0,0,.075) 50%,rgba(0,0,0,.075) 58%,transparent 58%,transparent)}.imagify-datas-more-action a{display:inline-block;padding:0 5px;background:#40B1D0;color:#FFF;text-transform:uppercase;font-size:9px;font-weight:700;line-height:1.9;text-decoration:none}.imagify-datas-more-action a.is-open{background:#555}.imagify-datas-more-action a.is-open .dashicons{-webkit-transform:rotate(180deg);-ms-transform:rotate(180deg);transform:rotate(180deg)}.imagify-datas-more-action a .dashicons{font-size:14px;vertical-align:middle;line-height:.8}.imagify-datas-more-action a .dashicons:before{vertical-align:middle;line-height:20px}.imagify-datas-more-action .the-text{display:inline-block;vertical-align:middle;height:auto;line-height:inherit}ul.imagify-datas-details.imagify-datas-details{margin:.7em auto}.imagify-datas-details strong{color:#40B1D0}.imagify-datas-details .original{color:#555}.imagify-datas-actions-links{overflow:hidden;border-top:2px solid transparent;padding-top:5px;font-size:8px}.nggform .imagify-datas-actions-links{position:relative;z-index:2}.nggform .row-actions{z-index:1}.imagify-datas-actions-links a{position:relative;display:inline-block;padding-left:17px;text-decoration:none;font-weight:600}.compat-field-imagify .imagify-datas-actions-links{max-width:300px}.misc-pub-imagify .imagify-datas-actions-links{border-top:2px solid #f2f2f2;padding-bottom:5px}.column-imagify_optimized_file .imagify-datas-actions-links a{margin:0 .7em;padding-left:15px}.compat-field-imagify .imagify-datas-actions-links a,.misc-pub-imagify .imagify-datas-actions-links a{font-size:10px;float:left;width:50%}.media-sidebar .compat-field-imagify .imagify-datas-actions-links a,.submitbox .misc-pub-imagify .imagify-datas-actions-links a{display:block;width:auto;float:none}.imagify-datas-actions-links a:only-child{float:none;width:auto}.imagify-datas-details.is-open+.imagify-datas-actions-links{border-top-color:rgba(0,0,0,.075)}.imagify-datas-actions-links .dashicons{position:absolute;left:0;top:4px;width:12px;margin-right:2px;font-size:11px}.imagify-account,.imagify-account-link{padding-right:15px}.imagify-meteo-icon{display:inline-block;height:38px;vertical-align:middle;margin-right:10px}.imagify-user-plan{color:#40b1d0}.imagify-meteo-title.imagify-meteo-title{color:#FFF;font-size:17px}.imagify-space-left>p{color:#FFF}[class^=imagify-bar-]{position:relative;height:8px;width:100%;background:#60758D;color:#FFF;font-size:10px}.imagify-progress{height:8px;-webkit-transition:width .3s;-o-transition:width .3s;transition:width .3s}.imagify-bar-positive .imagify-progress{background:#8CC152}.imagify-bar-positive .imagify-barnb{color:#8CC152}.imagify-bar-primary .imagify-progress{background:#40B1D0}.imagify-bar-primary .imagify-barnb{color:#40B1D0}.imagify-bar-negative .imagify-progress{background:#D2D3D6}.imagify-bar-negative .imagify-barnb{color:#7A8996}.imagify-bar-neutral .imagify-progress{background:#F5A623}.imagify-space-left .imagify-bar-negative .imagify-progress{background:#C51162}.imagify-btn-ghost{display:inline-block;height:auto;padding:7px 10px;border:1px solid #FFF;text-align:center;background:0 0;color:#FFF;border-radius:3px;-webkit-transition:all .275s;-o-transition:all .275s;transition:all .275s}.imagify-btn-ghost:focus,.imagify-btn-ghost:hover{background:#FFF;color:#888}.imagify-error{background:#D0021B;color:#FFF}.imagify-settings-section .imagify-error{display:inline-block;padding:7px 10px;margin:10px 0 0 45px;border-radius:3px}.imagify-settings-section .imagify-error code{font-weight:400}.imagify-settings-section .imagify-error.hidden{display:none}.imagify-warning{background:#f5a623;color:#FFF;text-shadow:0 0 2px rgba(0,0,0,.2)}.imagify-modal{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.js .imagify-modal{display:none;position:fixed;top:0;right:0;bottom:0;left:0;background-color:#1F2332;background-color:rgba(31,35,50,.95);z-index:99999}.imagify-modal-content{-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;width:800px;max-width:95%;max-height:90vw;overflow:auto;padding:20px 25px;margin:1em auto;background:#FFF;-webkit-box-shadow:1px 1px 4px rgba(0,0,0,.7);box-shadow:1px 1px 4px rgba(0,0,0,.7);border-radius:3px}#imagify-visual-comparison .imagify-modal-content,.imagify-visual-comparison .imagify-modal-content{max-width:1400px;background:0 0;padding:5px;-webkit-box-shadow:none;box-shadow:none;border-radius:0}.imagify-modal .h2{margin:.5em 0;color:#8ba6b4;font-size:24px}.imagify-modal .h3{color:#40b1d0;font-size:18px}.imagify-modal .close-btn{display:none;visibility:hidden;position:absolute;right:20px;top:20px;font-size:1.2em;border:0;background:0 0;border-radius:0;cursor:pointer}.imagify-modal .close-btn i{margin-left:-2px}.imagify-modal .close-btn:focus,.imagify-modal .close-btn:hover{color:#40b1d0}.js .imagify-modal .close-btn{display:block;visibility:visible}.imagify-visual-comparison .close-btn,.wp_attachment_image #imagify-visual-comparison .close-btn{top:0}.imagify-visual-comparison .imagify-modal-content,.wp_attachment_image #imagify-visual-comparison .imagify-modal-content{padding-top:40px}.imagify-col{float:left;width:50%;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-preferred-size:50%;flex-basis:50%;padding-right:20px}.imagify-col+.imagify-col{padding-right:0;padding-left:20px}.imagify-col:target{-webkit-animation:hello 1s 3 linear backwards;animation:hello 1s 3 linear backwards}@-webkit-keyframes hello{0%,100%{background:#FFF}50%{background:#F4F7F9}}@keyframes hello{0%,100%{background:#FFF}50%{background:#F4F7F9}} \ No newline at end of file +/** + * == Utilities Classes + */ + +/* Util: Flexbox */ +.imagify-flex { + display: flex; +} +.imagify-vcenter { + align-items: center; +} +.imagify-noshrink { + flex-shrink: 0; +} +.imagify-nogrow { + flex-grow: 0; +} + +/* Util: dimension */ +.imagify-wauto { + width: auto; +} +.imagify-hauto { + height: auto; +} +.imagify-full-width { + width: 100%; +} + +/* Util: float */ +.imagify-start { + float: left; +} +.imagify-end { + float: right; +} + +/* Util: text-align */ +.imagify-txt-start.imagify-txt-start.imagify-txt-start { + text-align: left; +} +.imagify-txt-center.imagify-txt-center.imagify-txt-center { + text-align: center; +} +.imagify-txt-end.imagify-txt-end.imagify-txt-end { + text-align: right; +} + +/* Util: margin/padding */ +.imagify-mt0.imagify-mt0 { + margin-top: 0; +} +.imagify-mt1.imagify-mt1 { + margin-top: 1em; +} +.imagify-mt2.imagify-mt2 { + margin-top: 2em; +} +.imagify-mt3.imagify-mt3 { + margin-top: 3em; +} +.imagify-mb0.imagify-mb0 { + margin-bottom: 0; +} +.imagify-mb1.imagify-mb1 { + margin-bottom: 1em; +} +.imagify-mr1.imagify-mr1 { + margin-right: 1em; +} +.imagify-ml2.imagify-ml2 { + margin-left: 2em; +} +.imagify-mr2.imagify-mr2 { + margin-right: 2em; +} + +.imagify-pl0.imagify-pl0.imagify-pl0 { + padding-left: 0; +} +.imagify-pb0.imagify-pb0 { + padding-bottom: 0; +} +.imagify-pr1.imagify-pr1 { + padding-right: 1em; +} +.imagify-pr2.imagify-pr2 { + padding-right: 2em; +} + +/* Util: Overflow */ +.imagify-oh { + overflow: hidden; +} +.imagify-clear { + clear: both; +} +.imagify-clearfix:after, +.imagify-inline-options:after, +.imagify-settings-main-content:after, +.imagify-settings-section:after { + content: ""; + display: table; + width: 100%; + clear: both; +} +.imagify-setting-optim-level .imagify-inline-options:after { + display: none; +} + +/* Util: Dividers */ +.imagify-divider { + height: 1px; + margin: 20px 0; + background: #D2D3D6; +} +.imagify-pipe { + display: inline-block; + margin: 0 .75em; + vertical-align: middle; + height: 15px; + width: 1px; + background: #979797; +} + +/* Titles */ +.imagify-h3-like.imagify-h3-like.imagify-h3-like { + margin-bottom: 0; + font-size: 19px; + font-weight: 500; + color: #1F2332; +} +.imagify-h4-like.imagify-h4-like.imagify-h4-like { + font-size: 14px; + font-weight: bold; + color: #2E3243; +} + +/* Default counter */ +.imagify-count.imagify-count { + counter-reset: num; +} +.imagify-count .imagify-count-title { + font-weight: bold; +} +.imagify-default-settings { + color: #73818c; + font-weight: normal; +} +.imagify-count .imagify-count-title:before { + counter-increment: num 1; + content: counter(num) ". "; +} + +/* List counter */ +.imagify-count-list { + counter-reset: listcount; +} +.imagify-count-list li { + display: flex; + align-items: center; +} +.imagify-count-list li + li { + margin-top: .5em; +} +.imagify-count-list li:before { + display: flex; + flex-basis: 24px; + flex-shrink: 0; + flex-grow: 0; + align-items: center; + justify-content: center; + margin-right: 16px; + border: 2px solid #40b1d0; + width: 24px; + height: 24px; + counter-increment: listcount 1; + content: counter(listcount); + color: #40b1d0; + border-radius: 50%; +} + +/* Table layout */ +.imagify-table { + display: table; + width: 100%; +} +.imagify-cell { + display: table-cell; + padding: 10px; + vertical-align: top; +} +.imagify-cell.va-top, +.va-top .imagify-cell { + vertical-align: top; +} + +.imagify-bulk-submit .imagify-cell { + padding-top: 0; +} + +/* When an "Imagify" modal is open in a page */ +body.imagify-modal-is-open { + overflow: hidden; +} + +/* Loader/Spinner */ +.imagify-spinner { + display: inline-block; + width: 20px; + height: 20px; + margin-right: 5px; + vertical-align: middle; + background: rgba(0, 0, 0, 0) url("../images/spinner.gif") no-repeat scroll 0 0 / 20px 20px; + opacity: 0.7; +} +.spinner.imagify-hidden { + width: 0; + margin: 4px 0 0 0; +} + +/* Some basic colors */ +.imagify-primary.imagify-primary.imagify-primary { + color: #40b1d0; +} +.imagify-secondary.imagify-secondary.imagify-secondary, +.imagify-valid { + color: #8BC34A; +} + +/* Informations in column (media popin, media details) */ +.misc-pub-section.misc-pub-imagify h4 { + font-size: 14px; + margin-top: 5px; + margin-bottom: 0; +} + +/* Doughnut */ +.imagify-chart { + position: relative; + top: 1px; + display: inline-block; + vertical-align: middle; +} +.imagify-chart-container { + position: relative; + display: inline-block; + margin-right: 5px; +} +.imagify-chart-container canvas { + display: block; +} + +/** + * + * == Settings page + * + */ + + +/* Basic HTML elements for Options and Bulk pages */ +.imagify-settings a, +.imagify-settings .button, +.imagify-settings input, +.imagify-welcome a, +.imagify-welcome .button, +.imagify-weolcome input { + -webkit-transition: all .275s; + transition: all .275s; +} +.imagify-settings a { + color: #40b1d0; +} + +.imagify-settings, +.imagify-settings p, +.imagify-settings th { + color: #5F758E; +} + +/* Buttons */ +.imagify-settings .button, +.imagify-welcome .button, +.imagify-notice .button, +.imagify-button.imagify-button, +.imagify-button-primary.imagify-button-primary, +.imagify-button-secondary.imagify-button-secondary { + height: auto; + padding: 11px 22px; + border: 0 none; + font-size: 14px; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.01em; + word-spacing: 0.01em; + box-shadow: 0 3px 0 rgba(0, 0, 0, .15); + border-radius: 3px; + cursor: pointer; + transition: all .275s; +} + +.button-primary.button-mini { + padding: 2px 10px; +} +.imagify-settings .button.button-mini-flat { + padding: 3px 6px 5px; + font-size: 12px; + box-shadow: none!important; + line-height: 1.2; +} +.imagify-settings .button.button-mini-flat:hover, +.imagify-settings .button.button-mini-flat:focus { + box-shadow: none!important; +} + +.imagify-title .button-ghost.button-ghost, +.imagify-button-ghost.imagify-button-ghost { + padding: 2px 9px; + border: 1px solid #40B1D0; + font-size: 12px; + font-weight: normal; + color: #40B1D0; + background: transparent; + box-shadow: none; +} +.imagify-title .button-ghost.button-ghost:hover, +.imagify-title .button-ghost.button-ghost:focus, +.imagify-button-ghost.imagify-button-ghost:hover, +.imagify-button-ghost.imagify-button-ghost:focus { + border-color: transparent; + color: #000; + background: #40B1D0; +} +.imagify-button-ghost.imagify-button-ghost:hover, +.imagify-button-ghost.imagify-button-ghost:focus { + color: #FFF; +} +.imagify-button-medium.imagify-button-medium { + text-transform: uppercase; + letter-spacing: 0.1em; + padding: 3px 10px; + font-weight: bold; +} +.imagify-button-medium.imagify-button-ghost { + border-width: 2px; +} +[class*="imagify-"] .button .dashicons { + margin-right: 5px; + vertical-align: middle; +} + +.imagify-settings .button-primary.button-primary, +.imagify-welcome .button-primary.button-primary, +.imagify-button-primary.imagify-button-primary { + background: #40B1D0; + color: #FFF; + box-shadow: 0 3px 0 rgba(51, 142, 166, 1); + text-shadow: 0 -1px 1px #006799, 1px 0 1px #006799, 0 1px 1px #006799!important; +} +.imagify-button-secondary.imagify-button-secondary { + background: #8BC34A; + color: #FFF; + box-shadow: 0 3px 0 #6F9C3B; + text-shadow: 0 -1px 1px #6F9C3B, 1px 0 1px #6F9C3B, 0 1px 1px #6F9C3B!important; +} +.imagify-settings .button-primary:hover, +.imagify-settings .button-primary:focus, +.imagify-welcome .button-primary:hover, +.imagify-welcome .button-primary:focus, +.imagify-button-primary.imagify-button-primary:hover, +.imagify-button-primary.imagify-button-primary:focus { + background: rgb(51, 142, 166); + box-shadow: 0 3px 0 rgb(31, 122, 146); +} +.imagify-button-secondary.imagify-button-secondary:hover, +.imagify-button-secondary.imagify-button-secondary:focus { + background: #6F9C3B; + color: #FFF; +} + +.imagify-button-light.imagify-button-light { + background: #FFF; + color: #4a4a4a; + box-shadow: 0 2px 0 rgba(0, 0, 0, .2); +} +.imagify-block-secondary .imagify-button-light.imagify-button-light { + color: #6F9C3B; +} +.imagify-button-light.imagify-button-light:hover, +.imagify-button-light.imagify-button-light:focus { + color: #FFF; + background: rgba(0, 0, 0, .2); +} + +/* Buttons clean */ +.button.imagify-button-clean, +.imagify-button-clean { + padding: 0; + background: transparent; + box-shadow: none; +} +.imagify-button-clean .dashicons-plus { + width: 32px; + height: 25px; +} +.imagify-button-clean .dashicons-plus:before { + display: flex; + align-items: center; + justify-content: center; + width: 25px; + height: 22px; + margin-left: 2px; + padding-top: 3px; + font-size: 17px; + background: #40B1D0; + color: #FFF; + transition: all .275s; +} +.button.imagify-button-clean:hover, +.button.imagify-button-clean:focus, +.button.imagify-button-clean:active, +.button.imagify-button-clean[disabled] { + background: transparent!important; + color: #343A49; + box-shadow: none; +} +.button.imagify-button-clean:hover .dashicons-plus:before, +.button.imagify-button-clean:focus .dashicons-plus:before { + background: #343A49; +} + +/* Buttons link-like */ +button.imagify-link-like { + border: 0; + padding: 0; + color: inherit; + text-decoration: underline; + font-size: 13px; + box-shadow: none; + background: transparent; + cursor: pointer; +} + +/* Modifier */ +.imagify-section-positive .imagify-button-light { + color: #709A41; +} +.imagify-button.imagify-button-big { + font-size: 15px; + padding: 11px 30px; +} +.imagify-button-big .dashicons { + font-size: 1.45em; + margin-right: 6px; + margin-left: -4px; +} + +.imagify-settings .button .dashicons, +.imagify-welcome .button .dashicons, +.imagify-notice .button .dashicons, +.imagify-button.imagify-button .dashicons, +.imagify-button-primary.imagify-button-primary .dashicons, +.imagify-button-secondary.imagify-button-secondary .dashicons { + vertical-align: middle; +} + +[class*="imagify-"] .button-text { + display: inline-block; + vertical-align: middle; +} + +/* Exception in Media edition page and post Edition pages (insert media popin) */ +.wp_attachment_image .imagify-button-primary, +.media-frame-content .imagify-button-primary { + padding: 0 10px 1px; + margin: 0 5px 2px 0; + font-size: 13px; + line-height: 26px; + box-shadow: 0 3px 0 rgba(51, 142, 166, 1); +} +.wp_attachment_image .imagify-button-primary { + float: left; +} + +/** + * == Header & Subheader & Sections + * + * (options, Welcome Notice, Bulk) + */ +.imagify-title.imagify-title { + position: relative; + padding: 10px 30px; + font-size: 23px; + background: #1F2332; + color: #FFF; +} +.imagify-welcome .imagify-logo { + opacity: 1; +} +.imagify-welcome .imagify-title { + display: flex; + padding: 20px 30px; +} +.imagify-settings .imagify-title { /* (options and bulk) */ + display: flex; + justify-content: space-between; + align-items: center; +} +.imagify-settings .imagify-logo-block { + display: flex; + align-items: center; + flex-shrink: 0; + flex-grow: 0; + padding: 0; + margin-right: 35px; + color: inherit; +} +.imagify-logo-block sup { + color: #1F2332; +} +.imagify-settings .imagify-title + .imagify-notice { + margin: 0; + border-right: 1px solid #D9D9D9; + padding-top: 15px; + padding-bottom: 15px; +} +.imagify-title .title-text { + font-size: 28px; + font-weight: bold; + color: #FFF; +} +.imagify-lb-icon { + padding-right: 18px; +} +.imagify-lb-text img { + margin-bottom: .15em; +} +.imagify-lb-text { + font-size: 23px; + font-weight: bold; + color: #FFF; +} +.imagify-logo { + display: block; + vertical-align: top; + opacity: .4; +} +.imagify-sub-header, +.imagify-sub-title.imagify-sub-title, /* heavier is better */ +.imagify-settings div.submit, +.imagify-section { + margin: 0; + padding: 20px; + background: #F2F5F7; +} +.imagify-sub-title.imagify-sub-title, +.imagify-section-positive { + padding-left: 40px; +} +.imagify-section-positive { + background: #8cc152; + color: #FFF; +} +.imagify-section-positive p { + color: #FFF +} +.imagify-section-gray { + background: #D9E4EB; +} +.imagify-section-gray .imagify-count-title { + color: #4a4a4a; +} +.imagify-section p:first-child { + margin-top: 0; +} +.imagify-section p:last-child { + margin-bottom: 0; +} + +/* Documentation link */ +.imagify-settings .imagify-documentation-link-box { + display: flex; + padding: 12px 13px 14px; + border: 1px solid #40b1d0; + color: #E5EBEF; + border-radius: 3px; +} +.imagify-documentation-link-icon { + width: 23px; + height: 31px; + font-size: 2.6em; + margin-right: 15px; + line-height: 1.3; +} +.imagify-documentation-link-box span { + font-size: 12px; +} +.imagify-documentation-link-box a { + font-weight: bold; +} + +@media (max-width: 1120px) { + .imagify-settings .imagify-title { + flex-wrap: wrap; + } +} + +.imagify-settings-section { + padding: 10px 20px; +} +.imagify-account-info-col .imagify-settings-section { + padding-right: 0; +} +.imagify-settings-main-content, +.imagify-welcome .imagify-settings-section { + border: 1px solid #D9D9D9; + border-top-width: 0; + background: #FFF; +} + +.imagify-settings-main-content { + padding-bottom: 20px; +} +.imagify-settings-main-content p { + font-size: 14px; +} + +.imagify-settings-main-content + .imagify-settings-main-content { + margin-top: 20px; + border-top-width: 1px; +} + +.imagify-br { + line-height: 2; +} + +/* New to imagify, title */ +p.imagify-section-title.imagify-section-title { + font-size: 20px; + margin-top: -.3em; + margin-bottom: -.6em; +} + +/** + * == Rating (Notice + Settings) + */ +.imagify-rate-us.imagify-rate-us { + text-align: right; + margin: -1em -2.4em -1em 0; + color: #FFF; +} +.imagify-rate-us a { + color: #40B1D0; +} +.imagify-rate-us .stars { + display: inline-block; + margin: 2px 0 0 10px; + text-decoration: none; + letter-spacing: .2em; + vertical-align: -1px; +} +.imagify-rate-us .stars .dashicons:before { + font-size: 18px; +} +.imagify-rate-us a:hover, +.imagify-rate-us a:focus { + color: #FEE102; +} +@media (max-width: 1220px) { + .imagify-rate-us.imagify-rate-us { + position: static; + margin-bottom: 0; + text-align: left; + } + .imagify-rate-us.imagify-rate-us br { + display: none; + } + .imagify-rate-us .stars { + display: block; + margin-left: 0; + } +} + +/** + * == Messages & infos + */ +.imagify-important { + color: #F5A623; +} +.imagify-success, +.imagify-settings .imagify-success { + color: #8BC34A; +} +.imagify-info, +.imagify-info a { + color: #7A8996; + font-size: 12px; +} +.imagify-info { + position: relative; + display: inline-block; + padding-left: 25px; +} +.imagify-info .dashicons { + position: absolute; + left: 0; top: 0; + color: #40B1D0; +} + +/* Custom checkboxes in CSS */ +.imagify-settings.imagify-settings [type="checkbox"]:not(:checked), +.imagify-settings.imagify-settings [type="checkbox"]:checked, +.imagify-checkbox.imagify-checkbox:not(:checked), +.imagify-checkbox.imagify-checkbox:checked { + position: absolute; + opacity: 0.01; +} +.imagify-settings.imagify-settings [type="checkbox"]:not(:checked):focus, +.imagify-settings.imagify-settings [type="checkbox"]:checked:focus, +.imagify-checkbox.imagify-checkbox:not(:checked):focus, +.imagify-checkbox.imagify-checkbox:checked:focus { + box-shadow: none!important; /* system value to override */ + outline: none!important; + border: 0 none!important; +} + +.imagify-settings [type="checkbox"]:not(:checked) + label, +.imagify-settings [type="checkbox"]:checked + label, +.imagify-checkbox.imagify-checkbox:not(:checked) + label, +.imagify-checkbox.imagify-checkbox:checked + label { + position: relative; + display: flex; + align-items: center; + min-height: 24px; + padding-left: 40px; + cursor: pointer; + font-size: 14px; + font-weight: bold; + color: #2E3243; +} + +/* checkbox aspect */ +.imagify-settings [type="checkbox"]:not(:checked) + label:before, +.imagify-settings [type="checkbox"]:checked + label:before, +.imagify-checkbox.imagify-checkbox:not(:checked) + label:before, +.imagify-checkbox.imagify-checkbox:checked + label:before { + content: ''; + position: absolute; + left: 0; top: 0; + width: 22px; height: 22px; + border: 2px solid #8BA6B4; + background: #FFFFFF; + border-radius: 3px; +} +/* checked mark aspect */ +.imagify-settings [type="checkbox"]:not(:checked) + label:after, +.imagify-settings [type="checkbox"]:checked + label:after, +.imagify-checkbox.imagify-checkbox:not(:checked) + label:after, +.imagify-checkbox.imagify-checkbox:checked + label:after { + content: "✓"; + position: absolute; + font-size: 1.4em; + top: -2px; left: 4.5px; + color: #8BA6B4; + font-weight: normal; + -webkit-transition: all .2s; + -moz-transition: all .2s; + -ms-transition: all .2s; + transition: all .2s; +} +/* disabled aspect */ +.imagify-settings [type="checkbox"][disabled]:not(:checked) + label:before, +.imagify-settings [type="checkbox"][disabled]:checked + label:before, +.imagify-checkbox.imagify-checkbox[disabled]:not(:checked) + label:before, +.imagify-checkbox.imagify-checkbox[disabled]:checked + label:before { + border-color: #ccc; + background: #ddd; +} +/* checked mark aspect changes */ +.imagify-settings [type="checkbox"]:not(:checked) + label:after, +.imagify-checkbox.imagify-checkbox:not(:checked) + label:after { + opacity: 0; + -webkit-transform: scale(0); + -moz-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); +} +.imagify-settings [type="checkbox"]:checked + label:after, +.imagify-checkbox.imagify-checkbox:checked + label:after { + opacity: 1; + -webkit-transform: scale(1); + -moz-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); +} + +/* medium version */ +.medium.imagify-checkbox:not(:checked) + label:before, +.medium.imagify-checkbox:checked + label:before { + width: 22px; + height: 22px; + border-width: 1.5px; + border-radius: 2px; + margin-top: 0; +} +.medium.imagify-checkbox:not(:checked) + label:after, +.medium.imagify-checkbox:checked + label:after { + font-size: 1.1em; + left: -17px; + top: 3px; +} + +/* mini version */ +.imagify-settings .mini[type="checkbox"]:not(:checked) + label:before, +.imagify-settings .mini[type="checkbox"]:checked + label:before, +.mini.imagify-checkbox:not(:checked) + label:before, +.mini.imagify-checkbox:checked + label:before { + width: 15px; + height: 15px; + border-width: 1px; + border-radius: 2px; + margin-top: 0; +} +.imagify-settings .mini[type="checkbox"]:not(:checked) + label:after, +.imagify-settings .mini[type="checkbox"]:checked + label:after, +.mini.imagify-checkbox:not(:checked) + label:after, +.mini.imagify-checkbox:checked + label:after { + font-size: .9em; + left: -21px; + top: -0.5px; +} +/* focus aspect */ +.imagify-settings [type="checkbox"]:not(:checked):focus + label:before, +.imagify-settings [type="checkbox"]:checked:focus + label:before, +.imagify-checkbox.imagify-checkbox:not(:checked):focus + label:before, +.imagify-checkbox.imagify-checkbox:checked:focus + label:before { + border-style: dotted; + border-color: #40b1d0; +} + +/* Checkbox groups */ +.imagify-check-group { + padding-left: 2px; + margin-bottom: 0; +} +.imagify-check-group.imagify-is-scrollable { + max-height: 15em; + overflow-y: auto; + padding: 8px; + margin: 1.5em 0 0 -8px; + background: #F4F7F9; + border: 1px solid #D2D3D6; + border-radius: 3px; +} +.imagify-is-scrollable legend + p { + margin-top: 0; +} +.imagify-is-scrollable [type="checkbox"]:not(:checked) + label:before, +.imagify-is-scrollable [type="checkbox"]:checked + label:before { + background: #F4F7F9; +} +.imagify-settings .imagify-check-group.imagify-check-group label { + color: #338EA6; + font-weight: 500; +} + +/* Custom radio in CSS */ +.imagify-inline-options { + position: relative; + display: table; + width: 100%; + max-width: 600px; + border-collapse: collapse; +} + +.imagify-inline-options input[type="radio"]:not(:checked), +.imagify-inline-options input[type="radio"]:checked { + position: absolute; + left: 5px; top: 5px; + display: none; +} + +.imagify-inline-options input[type="radio"]:not(:checked) + label, +.imagify-inline-options input[type="radio"]:checked + label { + position: relative; + display: table-cell; + padding: 13px 10px; + text-align: center; + + font-weight: 600; + font-size: 16px; + text-transform: uppercase; + letter-spacing: 0.1em; + color: #FFF; + background: #2E3243; + box-shadow: 0 -3px 0 rgba(0, 0, 0, 0.1) inset; + z-index: 2; + -webkit-transition: all .275s; + transition: all .275s; +} + +.imagify-inline-options input[type="radio"]:not(:checked) + label:first-of-type, +.imagify-inline-options input[type="radio"]:checked + label:first-of-type { + border-radius: 3px 0 0 3px; +} + +.imagify-inline-options input[type="radio"]:not(:checked) + label:last-of-type, +.imagify-inline-options input[type="radio"]:checked + label:last-of-type { + border-radius: 0 3px 3px 0; +} + +.imagify-inline-options input[type="radio"]:checked + label { + background: #8BC34A +} + +.imagify-inline-options .imagify-info { + margin-top: 15px; +} + +/** + * Account information columns (Settings & Bulk) + */ +.imagify-col.imagify-col.imagify-account-info-col, +.imagify-account-info-col { + width: 380px; + max-width: 100%; + padding: 0 20px 0 0; +} +.imagify-col.imagify-col.imagify-shared-with-account-col, +.imagify-shared-with-account-col { + width: calc(100% - 380px); + padding: 0; +} + +.imagify-account-info-col .imagify-options-title { + padding: 24px 26px; + color: #FFF; + background: #1F2332; +} +.imagify-block-secondary { + padding: 26px 26px 35px; + border: 1px solid #75A345; + background: #8BC34A; + border-radius: 3px; + color: #FFF; +} +.imagify-block-secondary.imagify-block-secondary p, +.imagify-account-info-col .imagify-block-secondary.imagify-block-secondary h3 { + color: inherit; +} +.imagify-account-info-col .imagify-col-content h3:first-child { + margin-top: 0; +} +.imagify-account-info-col .imagify-col-content h3 { + font-size: 19px; +} +.imagify-account-info-col .imagify-col-content p { + margin: 1.5em 0; +} +.imagify-account-info-col .imagify-col-content p:first-child { + margin-top: 0; +} + +.imagify-user-plan-label { + float: right; + margin-top: -4px; + padding: 2px 10px; + border: 2px solid #40B1D0; + font-size: 14px; + text-transform: uppercase; + letter-spacing: 0.02em; + color: #40B1D0; + border-radius: 3px; +} + +/* Content given after remote answer, avoid "flash" effect on content */ +.imagify-user-plan-label:empty { + display: none; +} + +/** + * == Columns + */ +.imagify-columns { + overflow: hidden; + padding: 15px 0; + counter-reset: cols; +} +.imagify-columns [class^="col-"] { + float: left; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +.imagify-columns .col-1-3 { + width: 33.333%; + padding-left: 28px; +} +.imagify-columns .col-2-3 { + width: 66.666%; + padding-left: 28px +} +.imagify-columns .col-1-2 { + width: 50%; + padding: 0 20px; +} + +@media (max-width: 830px) { + .imagify-columns [class^="col-"] { + float: none; + margin-bottom: 1.5em; + } + .imagify-columns .col-1-3, + .imagify-columns .col-1-2 { + width: auto; + padding: 0 28px; + clear: both; + padding-top: 1em; + } +} + +/** + * == Custom column & Metabox + */ +.column-imagify_optimized_file.column-imagify_optimized_file { + width: 300px; + text-align: center; + vertical-align: middle; +} +.column-imagify_optimized_file > * { + max-width: 21em; + margin: 0 auto; +} +@media (min-width: 1151px) and (max-width: 1800px) { + .column-imagify_optimized_file.column-imagify_optimized_file { + width: 21em; + } +} +@media (min-width: 783px) and (max-width: 1150px) { + .column-imagify_optimized_file.column-imagify_optimized_file { + width: 13em; + } + table.media .column-title .has-media-icon ~ .row-actions.row-actions { + margin-left: 0; + } +} +@media (max-width: 782px) { + table.media .column-imagify_optimized_file.column-imagify_optimized_file { + text-align: left; + } + table.media .imagify-datas-more-action, + table.media .imagify-datas-actions-links { + text-align: center; + } + table.media .column-imagify_optimized_file > *, + table.media .column-imagify_optimized_file .imagify-datas-actions-links a { + max-width: 100%; + margin-left: 0; + } +} +@media (min-width: 783px) and (max-width: 1150px), (max-width: 360px) { + table.media .imagify-hide-if-small { + position: absolute; + margin: -1px; + padding: 0; + height: 1px; + width: 1px; + overflow: hidden; + clip: rect(0 0 0 0); + border: 0; + word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */ + } +} +.compat-field-imagify .label { + vertical-align: top; +} +.compat-field-imagify ul.imagify-datas-list { + margin-top: 7px; + font-size: 11px; +} +ul.imagify-datas-list.imagify-datas-list { + margin: 0 auto; + color: #555; + font-size: 10px; +} +ul.imagify-datas-list .big { + font-size: 12px; + color: #40B1D0; +} +.imagify-data-item { + overflow: hidden; +} +li.imagify-data-item { + clear: both; + margin-bottom: 2px; +} +ul.imagify-datas-list .imagify-data-item span.data, +ul.imagify-datas-list .imagify-data-item strong { + float: left; + width: 38%; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; +} +ul.imagify-datas-list .imagify-data-item span.data { + width: 62%; + padding-right: 5px; + text-align: left; +} +.compat-field-imagify .imagify-datas-list .imagify-data-item .data { + width: 130px; + text-align: left; + font-weight: bold; +} +ul.imagify-datas-list .imagify-data-item strong { + text-align: left; + padding-left: 5px; +} +.media-sidebar .imagify-datas-list .imagify-data-item .data { + width: auto; + float: none; +} +.media-sidebar .imagify-datas-list .imagify-data-item strong { + display: inline-block; + width: auto; + float: none; +} +.media-sidebar .imagify-datas-list .imagify-data-item .imagify-chart { + float: left; +} +.imagify-datas-more-action.imagify-datas-more-action { + margin: .4em auto; + background: linear-gradient(to bottom, transparent, transparent 49%, rgba(0,0,0,.075) 50%, rgba(0,0,0,.075) 58%, transparent 58%, transparent); +} +.imagify-datas-more-action a { + display: inline-block; + padding: 0 5px; + background: #40B1D0; + color: #FFF; + text-transform: uppercase; + font-size: 9px; + font-weight: bold; + line-height: 1.9; + text-decoration: none; +} +.imagify-datas-more-action a.is-open { + background: #555; +} +.imagify-datas-more-action a.is-open .dashicons { + transform: rotate(180deg); +} +.imagify-datas-more-action a .dashicons { + font-size: 14px; + vertical-align: middle; + line-height: .8; +} +.imagify-datas-more-action a .dashicons:before { + vertical-align: middle; + line-height: 20px; +} +.imagify-datas-more-action .the-text { + display: inline-block; + vertical-align: middle; + height: auto; + line-height: inherit; +} + +ul.imagify-datas-details.imagify-datas-details { + margin: .7em auto; +} +.imagify-datas-details strong { + color: #40B1D0; +} +.imagify-datas-details .original { + color: #555; +} + +.imagify-datas-actions-links { + overflow: hidden; + border-top: 2px solid transparent; + padding-top: 5px; + font-size: 8px; +} +.nggform .imagify-datas-actions-links { + position: relative; + z-index: 2; +} +.nggform .row-actions { + z-index: 1; +} +.imagify-datas-actions-links a { + position: relative; + display: inline-block; + padding-left: 17px; + text-decoration: none; + font-weight: 600; +} +.compat-field-imagify .imagify-datas-actions-links { + max-width: 300px; +} +.misc-pub-imagify .imagify-datas-actions-links { + border-top: 2px solid #f2f2f2; + padding-bottom: 5px; +} +/* Library */ +.column-imagify_optimized_file .imagify-datas-actions-links a { + margin: 0 .7em; + padding-left: 15px; +} + +/* Media edition */ +.compat-field-imagify .imagify-datas-actions-links a, +.misc-pub-imagify .imagify-datas-actions-links a { + font-size: 10px; + float: left; + width: 50%; +} +.media-sidebar .compat-field-imagify .imagify-datas-actions-links a, +.submitbox .misc-pub-imagify .imagify-datas-actions-links a { + display: block; + width: auto; + float: none; +} +.imagify-datas-actions-links a:only-child { + float: none; + width: auto; +} +.imagify-datas-details.is-open + .imagify-datas-actions-links { + border-top-color: rgba(0,0,0,.075); +} +.imagify-datas-actions-links .dashicons { + position: absolute; + left: 0; top: 4px; + width: 12px; + margin-right: 2px; + font-size: 11px; +} + +/** + * == Bulk page + */ + +.imagify-account, +.imagify-account-link { + padding-right: 15px; +} +.imagify-meteo-icon { + display: inline-block; + height: 38px; + vertical-align: middle; + margin-right: 10px; +} +.imagify-user-plan { + color: #40b1d0; +} + +.imagify-meteo-title.imagify-meteo-title { + color: #FFF; + font-size: 17px; +} +.imagify-space-left > p { + color: #FFF; +} +[class^="imagify-bar-"] { + position: relative; + height: 8px; + width: 100%; + background: #60758D; + color: #FFF; + font-size: 10px; +} + +.imagify-progress { + height: 8px; +} +.imagify-progress { + transition: width .3s; +} +.imagify-bar-positive .imagify-progress { + background: #8CC152; +} +.imagify-bar-positive .imagify-barnb { + color: #8CC152; +} +.imagify-bar-primary .imagify-progress { + background: #40B1D0; +} +.imagify-bar-primary .imagify-barnb { + color: #40B1D0; +} +.imagify-bar-negative .imagify-progress { + background: #D2D3D6; +} +.imagify-bar-negative .imagify-barnb { + color: #7A8996; +} +.imagify-bar-neutral .imagify-progress { + background: #F5A623; +} +.imagify-space-left .imagify-bar-negative .imagify-progress { + background: #C51162; +} + +.imagify-btn-ghost { + display: inline-block; + height: auto; + padding: 7px 10px; + border: 1px solid #FFF; + text-align: center; + background: transparent; + color: #FFF; + border-radius: 3px; + transition: all .275s; +} + +.imagify-btn-ghost:hover, +.imagify-btn-ghost:focus { + background: #FFF; + color: #888; +} + +/* Some Errors */ +.imagify-error { + background: #D0021B; + color: #FFF; +} +.imagify-settings-section .imagify-error { + display: inline-block; + padding: 7px 10px; + margin: 10px 0 0 45px; + border-radius: 3px; +} +.imagify-settings-section .imagify-error code { + font-weight: normal; +} +.imagify-settings-section .imagify-error.hidden { + display: none; +} +.imagify-warning { + background: #f5a623; + color: #FFF; + text-shadow: 0 0 2px rgba(0, 0, 0, 0.2); +} + +/* Imagify Modal (is everywhere) */ +.imagify-modal { + display: -webkit-box; + display: -ms-flexbox; + display: flex; + -webkit-box-orient: vertical; + -webkit-box-direction: normal; + -ms-flex-direction: column; + flex-direction: column; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -ms-flex-pack: center; + justify-content: center; +} +.js .imagify-modal { + display: none; + position: fixed; + top: 0; right: 0; bottom: 0; left: 0; + background-color: #1F2332; + background-color: rgba(31,35,50,.95); + z-index: 99999; +} +.imagify-modal-content { + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + position: relative; + width: 800px; + max-width: 95%; + max-height: 90vw; + overflow: auto; + padding: 20px 25px; + margin: 1em auto; + background: #FFF; + box-shadow: 1px 1px 4px rgba(0,0,0,.7); + border-radius: 3px; +} +#imagify-visual-comparison .imagify-modal-content, +.imagify-visual-comparison .imagify-modal-content { + max-width: 1400px; + background: transparent; + padding: 5px; + box-shadow: none; + border-radius: 0; +} +.imagify-modal .h2 { + margin: .5em 0; + color: #8ba6b4; + font-weight: normal; + font-size: 24px; + letter-spacing: 0.075em; + text-align: center; +} +.imagify-modal .h3 { + color: #40b1d0; + font-weight: normal; + font-size: 18px; + letter-spacing: 0.075em; + text-align: center; +} +.imagify-modal .close-btn { + display: none; + visibility: hidden; + position: absolute; + right: 20px; top: 20px; + font-size: 1.2em; + border: 0; + background: transparent none; + border-radius: 0; + cursor: pointer; +} +.imagify-modal .close-btn i { + margin-left: -2px; +} +.imagify-modal .close-btn:hover, +.imagify-modal .close-btn:focus { + color: #40b1d0; +} +.js .imagify-modal .close-btn { + display: block; + visibility: visible; +} + +/* Attachments specifics */ +.wp_attachment_image #imagify-visual-comparison .close-btn, +.imagify-visual-comparison .close-btn { + top: 0; +} + +.wp_attachment_image #imagify-visual-comparison .imagify-modal-content, +.imagify-visual-comparison .imagify-modal-content { + padding-top: 40px; +} + +/* Col, behavior depending on parent */ +.imagify-col { + float: left; + width: 50%; + box-sizing: border-box; + -webkit-flex-basis: 50%; + -ms-flex-preferred-size: 50%; + flex-basis: 50%; +} +.imagify-col { + padding-right: 20px; +} +.imagify-col + .imagify-col { + padding-right: 0; + padding-left: 20px; +} + +.imagify-col:target { + animation: hello 1s 3 linear backwards; +} + +@keyframes hello { + 0%, 100% { + background: #FFF; + } + 50% { + background: #F4F7F9; + } +} From 2d55ec61d75ea1b720789fcbf082626ebec4a2eb Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 15 Jun 2018 01:10:02 +0200 Subject: [PATCH 03/39] Use the CSS class `imagify-clear` instead of `clear` to prevent other plugins and themes to mess with it. --- views/page-settings.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/page-settings.php b/views/page-settings.php index 4c4a76743..c18d63442 100755 --- a/views/page-settings.php +++ b/views/page-settings.php @@ -132,7 +132,7 @@
-
+

print_template( 'part-settings-library' ); @@ -142,7 +142,7 @@
-
+

From 02b52483b1085479d16257e82b7a118e384a3e1e Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 15 Jun 2018 01:18:06 +0200 Subject: [PATCH 04/39] Use `FILTER_VALIDATE_INT` instead of `FILTER_SANITIZE_NUMBER_INT`. There's still one `FILTER_SANITIZE_NUMBER_INT` left, because the value is not required. --- inc/classes/class-imagify-admin-ajax-post.php | 6 +++--- inc/classes/class-imagify-files-list-table.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/classes/class-imagify-admin-ajax-post.php b/inc/classes/class-imagify-admin-ajax-post.php index 1ac225cc3..77a452edb 100755 --- a/inc/classes/class-imagify-admin-ajax-post.php +++ b/inc/classes/class-imagify-admin-ajax-post.php @@ -377,7 +377,7 @@ public function imagify_bulk_optimize_file_callback() { imagify_check_nonce( 'imagify-bulk-upload' ); imagify_check_user_capacity( 'optimize-file' ); - $file_id = (int) filter_input( INPUT_POST, 'image', FILTER_SANITIZE_NUMBER_INT ); + $file_id = filter_input( INPUT_POST, 'image', FILTER_VALIDATE_INT ); $context = imagify_sanitize_context( filter_input( INPUT_POST, 'context', FILTER_SANITIZE_STRING ) ); $context = ! $context || 'wp' === strtolower( $context ) ? 'File' : $context; @@ -553,7 +553,7 @@ public function imagify_scan_custom_folders_callback() { imagify_check_nonce( 'imagify_scan_custom_folders' ); imagify_check_user_capacity( 'optimize-file' ); - $folder = (int) filter_input( INPUT_GET, 'folder', FILTER_SANITIZE_NUMBER_INT ); + $folder = filter_input( INPUT_GET, 'folder', FILTER_VALIDATE_INT ); if ( $folder > 0 ) { // A specific custom folder (selected or not). @@ -1515,7 +1515,7 @@ public function check_can_optimize() { * @return object A Imagify_File_Attachment object. */ protected function get_file_to_optimize( $identifier ) { - $file_id = (int) filter_input( INPUT_GET, 'id', FILTER_SANITIZE_NUMBER_INT ); + $file_id = filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT ); if ( ! $file_id ) { imagify_die( __( 'Invalid request', 'imagify' ) ); diff --git a/inc/classes/class-imagify-files-list-table.php b/inc/classes/class-imagify-files-list-table.php index b0d91d896..c4c81abdb 100755 --- a/inc/classes/class-imagify-files-list-table.php +++ b/inc/classes/class-imagify-files-list-table.php @@ -1010,7 +1010,7 @@ public static function get_folder_filter() { static $filter; if ( ! isset( $filter ) ) { - $filter = (int) filter_input( INPUT_GET, 'folder-filter', FILTER_SANITIZE_NUMBER_INT ); + $filter = filter_input( INPUT_GET, 'folder-filter', FILTER_VALIDATE_INT ); $filter = max( 0, $filter ); } From d798c023807fc441eb36d524dad8a70996074bce Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 15 Jun 2018 14:32:48 +0200 Subject: [PATCH 05/39] Added some missing escapes in SQL. --- inc/admin/upgrader.php | 2 +- uninstall.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/admin/upgrader.php b/inc/admin/upgrader.php index 6937397c4..3d6f80f05 100755 --- a/inc/admin/upgrader.php +++ b/inc/admin/upgrader.php @@ -253,7 +253,7 @@ function _imagify_new_upgrade( $network_version, $site_version ) { // 1.4.5 if ( version_compare( $site_version, '1.4.5' ) < 0 ) { // Delete all transients used for async optimization. - $wpdb->query( 'DELETE from ' . $wpdb->options . ' WHERE option_name LIKE "_transient_imagify-async-in-progress-%"' ); + $wpdb->query( $wpdb->prepare( "DELETE from $wpdb->options WHERE option_name LIKE %s", Imagify_DB::esc_like( '_transient_imagify-async-in-progress-' ) . '%' ) ); } // 1.7 diff --git a/uninstall.php b/uninstall.php index 83c8af625..4d18511c3 100755 --- a/uninstall.php +++ b/uninstall.php @@ -27,10 +27,10 @@ // Delete transients. $transients = implode( '" OR option_name LIKE "', array( - '_transient_%imagify-async-in-progress-%', - '_transient_%imagify-ngg-async-in-progress-%', - '_site_transient_%imagify-file-async-in-progress-%', - '_transient_%imagify_rpc_%', + '\_transient\_%imagify-async-in-progress-%', + '\_transient\_%imagify-ngg-async-in-progress-%', + '\_site\_transient\_%imagify-file-async-in-progress-%', + '\_transient\_%imagify\_rpc\_%', ) ); $wpdb->query( 'DELETE from ' . $wpdb->options . ' WHERE option_name LIKE "' . $transients . '"' ); // WPCS: unprepared SQL ok. From 333ef3ae185e9938d8fd59030675c2137a7ffe47 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Mon, 18 Jun 2018 15:49:04 +0200 Subject: [PATCH 06/39] Improved API key validation cache. --- inc/classes/class-imagify-requirements.php | 24 +++++++++++++++------- inc/classes/class-imagify-settings.php | 14 ++++++++----- inc/classes/class-imagify.php | 5 +++++ 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/inc/classes/class-imagify-requirements.php b/inc/classes/class-imagify-requirements.php index fe581a9eb..d0ffb509b 100644 --- a/inc/classes/class-imagify-requirements.php +++ b/inc/classes/class-imagify-requirements.php @@ -268,7 +268,15 @@ public static function is_api_up( $reset_cache = false ) { * @return bool */ public static function is_api_key_valid( $reset_cache = false ) { - if ( ! $reset_cache && isset( self::$supports['api_key_valid'] ) ) { + if ( $reset_cache ) { + unset( self::$supports['api_key_valid'] ); + + if ( get_site_transient( 'imagify_check_licence_1' ) ) { + delete_site_transient( 'imagify_check_licence_1' ); + } + } + + if ( isset( self::$supports['api_key_valid'] ) ) { return self::$supports['api_key_valid']; } @@ -277,7 +285,7 @@ public static function is_api_key_valid( $reset_cache = false ) { return self::$supports['api_key_valid']; } - if ( ! $reset_cache && get_site_transient( 'imagify_check_licence_1' ) ) { + if ( get_site_transient( 'imagify_check_licence_1' ) ) { self::$supports['api_key_valid'] = true; return self::$supports['api_key_valid']; } @@ -332,11 +340,13 @@ public static function is_over_quota( $reset_cache = false ) { public static function reset_cache( $cache_key ) { unset( self::$supports[ $cache_key ] ); - if ( 'api_up' === $cache_key ) { - delete_site_transient( 'imagify_check_api_version' ); - } - elseif ( 'api_key_valid' === $cache_key ) { - delete_site_transient( 'imagify_check_licence_1' ); + $transients = array( + 'api_up' => 'imagify_check_api_version', + 'api_key_valid' => 'imagify_check_licence_1', + ); + + if ( isset( $transients[ $cache_key ] ) && get_site_transient( $transients[ $cache_key ] ) ) { + delete_site_transient( $transients[ $cache_key ] ); } } } diff --git a/inc/classes/class-imagify-settings.php b/inc/classes/class-imagify-settings.php index 8ab17dd49..3a2261d02 100644 --- a/inc/classes/class-imagify-settings.php +++ b/inc/classes/class-imagify-settings.php @@ -361,15 +361,18 @@ public function after_save_network_options( $option, $value, $old_value ) { * @param mixed $value The new option value. */ public function after_save_options( $old_value, $value ) { - if ( ! $value || isset( $old_value['api_key'], $value['api_key'] ) && $old_value['api_key'] === $value['api_key'] ) { + $old_key = isset( $old_value['api_key'] ) ? $old_value['api_key'] : ''; + $new_key = isset( $value['api_key'] ) ? $value['api_key'] : ''; + + if ( $old_key === $new_key ) { return; } - if ( is_wp_error( get_imagify_user() ) ) { - Imagify_Notices::renew_notice( 'wrong-api-key' ); - delete_site_transient( 'imagify_check_licence_1' ); - } else { + // Handle API key validation cache and notices. + if ( Imagify_Requirements::is_api_key_valid( true ) ) { Imagify_Notices::dismiss_notice( 'wrong-api-key' ); + } else { + Imagify_Notices::renew_notice( 'wrong-api-key' ); } } @@ -385,6 +388,7 @@ public function update_site_option_on_network() { return; } + /** This filter is documented in /wp-admin/options.php. */ $capability = apply_filters( 'option_page_capability_' . $this->settings_group, 'manage_network_options' ); if ( ! current_user_can( $capability ) ) { diff --git a/inc/classes/class-imagify.php b/inc/classes/class-imagify.php index 140f95b8c..ffa0cbc25 100644 --- a/inc/classes/class-imagify.php +++ b/inc/classes/class-imagify.php @@ -532,6 +532,11 @@ private function curl_http_call( $url, $args = array() ) { private function handle_response( $response, $http_code, $error = '' ) { $response = json_decode( $response ); + if ( 401 === $http_code ) { + // Reset the API validity cache if the API key is not valid. + Imagify_Requirements::reset_cache( 'api_key_valid' ); + } + if ( 200 !== $http_code && ! empty( $response->code ) ) { if ( ! empty( $response->detail ) ) { return new WP_Error( $http_code, $response->detail ); From 502074ebab75e5a0795309fd66d3fb7c612e0541 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Mon, 18 Jun 2018 15:52:04 +0200 Subject: [PATCH 07/39] Use `reset_cache()` in `is_api_key_valid()` instead of duplicating code. --- inc/classes/class-imagify-requirements.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/inc/classes/class-imagify-requirements.php b/inc/classes/class-imagify-requirements.php index d0ffb509b..fc6cf4930 100644 --- a/inc/classes/class-imagify-requirements.php +++ b/inc/classes/class-imagify-requirements.php @@ -269,11 +269,7 @@ public static function is_api_up( $reset_cache = false ) { */ public static function is_api_key_valid( $reset_cache = false ) { if ( $reset_cache ) { - unset( self::$supports['api_key_valid'] ); - - if ( get_site_transient( 'imagify_check_licence_1' ) ) { - delete_site_transient( 'imagify_check_licence_1' ); - } + self::reset_cache( 'api_key_valid' ); } if ( isset( self::$supports['api_key_valid'] ) ) { From 048610b5962e58ee0b66c9e125b5d2fdfb91662f Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Mon, 18 Jun 2018 16:45:57 +0200 Subject: [PATCH 08/39] Hotfix: don't export .eslintrc.json file. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 44c5da448..403fdfa9e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,4 +1,5 @@ .editorconfig export-ignore +.eslintrc.json export-ignore .gitattributes export-ignore .gitignore export-ignore .jshintrc export-ignore From bc9d4addea038487ea3af8bd1dbffda6e1ade384 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Tue, 19 Jun 2018 01:45:01 +0200 Subject: [PATCH 09/39] Hotfix: Re-optimize links on media page. Somehow the "Re-optimize" links were not displaying anymore if the attachment is already optimized. --- inc/admin/meta-boxes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin/meta-boxes.php b/inc/admin/meta-boxes.php index 85397dc1f..ed98821ef 100755 --- a/inc/admin/meta-boxes.php +++ b/inc/admin/meta-boxes.php @@ -33,7 +33,7 @@ function _imagify_attachment_submitbox_misc_actions() { echo '' . __( 'Check your Settings', 'imagify' ) . ''; echo '
'; - } elseif ( $attachment->is_optimized() || $attachment->has_error() ) { + } elseif ( $attachment->is_optimized() || $attachment->is_already_optimized() || $attachment->has_error() ) { echo '

' . __( 'Imagify', 'imagify' ) . '

'; echo get_imagify_attachment_optimization_text( $attachment ); From e927eef54eddcb76a25baec88281dc5c35f7632c Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Thu, 21 Jun 2018 23:39:12 +0200 Subject: [PATCH 10/39] Introduced Imagify_Filesystem::get_site_root() Also introduced methods `has_wp_its_own_directory()`, `get_site_root_url()`, and `is_site_root()`. While at it, fixed an issue in `get_abspath()` with a non existing class in oantic WP versions. --- inc/classes/class-imagify-filesystem.php | 149 ++++++++++++++++++++--- 1 file changed, 130 insertions(+), 19 deletions(-) diff --git a/inc/classes/class-imagify-filesystem.php b/inc/classes/class-imagify-filesystem.php index e0dad2164..15581ef69 100644 --- a/inc/classes/class-imagify-filesystem.php +++ b/inc/classes/class-imagify-filesystem.php @@ -17,7 +17,7 @@ class Imagify_Filesystem extends WP_Filesystem_Direct { * * @var string */ - const VERSION = '1.1'; + const VERSION = '1.2'; /** * Delimiter used for regex patterns. @@ -209,15 +209,15 @@ public function make_dir( $path ) { return $this->is_dir( $path ) && $this->is_writable( $path ); } - $abspath = $this->get_abspath(); + $site_root = $this->get_site_root(); - if ( strpos( $path, $abspath ) !== 0 ) { + if ( strpos( $path, $site_root ) !== 0 ) { return false; } - $bits = str_replace( $abspath, '', $path ); + $bits = str_replace( $site_root, '', $path ); $bits = explode( '/', $bits ); - $path = untrailingslashit( $abspath ); + $path = untrailingslashit( $site_root ); foreach ( $bits as $bit ) { $path .= '/' . $bit; @@ -337,7 +337,7 @@ public function get_date( $file_path ) { * @return bool */ public function is_symlinked( $file_path ) { - static $abspath; + static $site_root; static $plugin_paths = array(); global $wp_plugin_paths; @@ -351,13 +351,13 @@ public function is_symlinked( $file_path ) { return false; } - if ( ! isset( $abspath ) ) { - $abspath = $this->normalize_path_for_comparison( $this->get_abspath() ); + if ( ! isset( $site_root ) ) { + $site_root = $this->normalize_path_for_comparison( $this->get_site_root() ); } $lower_file_path = $this->normalize_path_for_comparison( $real_path ); - if ( strpos( $lower_file_path, $abspath ) !== 0 ) { + if ( strpos( $lower_file_path, $site_root ) !== 0 ) { return true; } @@ -604,19 +604,14 @@ public function get_image_exif( $file_path, $sections = null, $arrays = false, $ * @return string|bool A relative path. Can return the absolute path or false in case of a failure. */ public function make_path_relative( $file_path, $base = '' ) { - static $abspath; global $wp_plugin_paths; if ( ! $file_path ) { return false; } - if ( ! isset( $abspath ) ) { - $abspath = wp_normalize_path( ABSPATH ); - } - $file_path = wp_normalize_path( $file_path ); - $base = $base ? $this->normalize_dir_path( $base ) : $abspath; + $base = $base ? $this->normalize_dir_path( $base ) : $this->get_site_root(); $pos = strpos( $file_path, $base ); if ( false === $pos && $wp_plugin_paths && is_array( $wp_plugin_paths ) ) { @@ -675,6 +670,20 @@ public function normalize_path_for_comparison( $file_path ) { /** SOME WELL KNOWN PATHS AND URLS ========================================================== */ /** ----------------------------------------------------------------------------------------- */ + /** + * Tell if WordPress is installed in its own directory: aka WP's path !== site's path. + * + * @since 1.8.1 + * @access public + * @see https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory + * @author Grégory Viguier + * + * @return string + */ + public function has_wp_its_own_directory() { + return $this->get_abspath() !== $this->get_site_root(); + } + /** * The path to the server's root is not always '/', it can also be '//' or 'C://'. * I am get_root. @@ -692,7 +701,7 @@ public function get_root() { return $groot; } - $groot = preg_replace( '@^((?:.:)?/+).*@', '$1', $this->get_abspath() ); + $groot = preg_replace( '@^((?:.:)?/+).*@', '$1', $this->get_site_root() ); return $groot; } @@ -713,7 +722,109 @@ public function is_root( $path ) { } /** - * Get a clean value of ABSPATH that can be used in string replacements. + * Get the path to the site's root. + * + * @since 1.8.1 + * @access public + * @see get_home_path() + * @author Grégory Viguier + * + * @return string + */ + public function get_site_root() { + static $root_path; + + if ( isset( $root_path ) ) { + return $root_path; + } + + $home = set_url_scheme( get_option( 'home' ), 'http' ); + $siteurl = set_url_scheme( get_option( 'siteurl' ), 'http' ); + + if ( ! empty( $home ) && 0 !== strcasecmp( $home, $siteurl ) ) { + $wp_path_rel_to_home = str_ireplace( $home, '', $siteurl ); /* $siteurl - $home */ + $pos = strripos( str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ), trailingslashit( $wp_path_rel_to_home ) ); + $root_path = substr( $_SERVER['SCRIPT_FILENAME'], 0, $pos ); + $root_path = trailingslashit( str_replace( '\\', '/', $root_path ) ); + return $root_path; + } + + if ( ! defined( 'PATH_CURRENT_SITE' ) || ! is_multisite() || is_main_site() ) { + $root_path = str_replace( '\\', '/', ABSPATH ); + return $root_path; + } + + // For a multisite in its own directory, get_home_path() returns the expected path only for the main site. + $script_filename = str_replace( '\\', '/', $_SERVER['SCRIPT_FILENAME'] ); + $path_current_site = '/' . trim( str_replace( '\\', '/', PATH_CURRENT_SITE ), '/' ) . '/'; + $pos = strripos( $script_filename, $path_current_site ); + + if ( false === $pos ) { + $root_path = str_replace( '\\', '/', ABSPATH ); + return $root_path; + } + + $root_path = substr( $script_filename, 0, $pos ) . $path_current_site; + return $root_path; + } + + /** + * Get the URL of the site's root. It corresponds to the main site's home page URL. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + * + * @return string + */ + public function get_site_root_url() { + static $root_url; + + if ( isset( $root_url ) ) { + return $root_url; + } + + if ( ! is_multisite() || is_main_site() ) { + $root_url = home_url( '/' ); + return $root_url; + } + + $current_network = false; + + if ( function_exists( 'get_network' ) ) { + $current_network = get_network(); + } elseif ( function_exists( 'get_current_site' ) ) { + $current_network = get_current_site(); + } + + if ( ! $current_network ) { + $root_url = home_url( '/' ); + return $root_url; + } + + $root_url = is_ssl() ? 'https' : 'http'; + $root_url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $root_url ); + $root_url = trailingslashit( $root_url ); + + return $root_url; + } + + /** + * Tell if a path is the site's root. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + * + * @param string $path The path. + * @return bool + */ + public function is_site_root( $path ) { + return $this->normalize_dir_path( $path ) === $this->get_site_root(); + } + + /** + * Get a clean value of ABSPATH. * * @since 1.7.1 * @access public @@ -740,7 +851,7 @@ public function get_abspath() { } elseif ( false === $pos && class_exists( 'ReflectionClass' ) ) { // Imagify is symlinked (dude, you look for trouble). - $reflector = new ReflectionClass( 'Requests' ); + $reflector = new ReflectionClass( 'WP' ); $test_file = $reflector->getFileName(); $pos = strpos( $test_file, $abspath ); @@ -760,7 +871,7 @@ public function get_abspath() { } /** - * Tell if a path is the site's root (ABSPATH). + * Tell if a path is WP's root (ABSPATH). * * @since 1.7.1 * @access public From 21066e4044be56b6599e3401722ecb28017a6cfc Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Thu, 21 Jun 2018 23:49:40 +0200 Subject: [PATCH 11/39] Replaced all root placeholders for custom folders For custom folders, replaced all `{{ABSPATH}}/` placeholders by `{{ROOT}}/`. --- inc/classes/class-imagify-admin-ajax-post.php | 10 +++---- inc/classes/class-imagify-custom-folders.php | 27 ++++++++++--------- .../class-imagify-files-list-table.php | 11 +++++--- inc/classes/class-imagify-files-scan.php | 14 +++++----- views/part-settings-custom-folders.php | 4 +-- views/part-settings-row-custom-folder.php | 2 +- 6 files changed, 37 insertions(+), 31 deletions(-) diff --git a/inc/classes/class-imagify-admin-ajax-post.php b/inc/classes/class-imagify-admin-ajax-post.php index 1ac225cc3..2c39eb093 100755 --- a/inc/classes/class-imagify-admin-ajax-post.php +++ b/inc/classes/class-imagify-admin-ajax-post.php @@ -16,7 +16,7 @@ class Imagify_Admin_Ajax_Post { * @since 1.6.11 * @author Grégory Viguier */ - const VERSION = '1.0.4'; + const VERSION = '1.0.5'; /** * Actions to be triggered on admin ajax and admin post. @@ -1355,7 +1355,7 @@ public function imagify_get_files_tree_callback() { } $folder = trailingslashit( sanitize_text_field( $_POST['folder'] ) ); - $folder = realpath( $this->filesystem->get_abspath() . ltrim( $folder, '/' ) ); + $folder = realpath( $this->filesystem->get_site_root() . ltrim( $folder, '/' ) ); if ( ! $folder ) { imagify_die( __( 'This folder doesn\'t exist.', 'imagify' ) ); @@ -1376,13 +1376,13 @@ public function imagify_get_files_tree_callback() { $views = Imagify_Views::get_instance(); $output = ''; - if ( $this->filesystem->is_abspath( $folder ) ) { + if ( $this->filesystem->is_site_root( $folder ) ) { $output .= $views->get_template( 'part-settings-files-tree-row', array( 'relative_path' => '/', // Value #///# Label. - 'checkbox_value' => '{{ABSPATH}}/#///#' . esc_attr__( 'Site\'s root', 'imagify' ), + 'checkbox_value' => '{{ROOT}}/#///#' . esc_attr__( 'Site\'s root', 'imagify' ), 'checkbox_id' => 'ABSPATH', - 'checkbox_selected' => isset( $selected['{{ABSPATH}}/'] ), + 'checkbox_selected' => isset( $selected['{{ROOT}}/'] ), 'label' => __( 'Site\'s root', 'imagify' ), 'no_button' => true, ) ); diff --git a/inc/classes/class-imagify-custom-folders.php b/inc/classes/class-imagify-custom-folders.php index b61b5ce5e..ccd452d0a 100644 --- a/inc/classes/class-imagify-custom-folders.php +++ b/inc/classes/class-imagify-custom-folders.php @@ -14,7 +14,7 @@ class Imagify_Custom_Folders { * * @var string */ - const VERSION = '1.0.2'; + const VERSION = '1.0.3'; /** ----------------------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ public static function get_backup_dir_path() { } $filesystem = imagify_get_filesystem(); - $backup_dir = $filesystem->get_abspath() . 'imagify-backup/'; + $backup_dir = $filesystem->get_site_root() . 'imagify-backup/'; /** * Filter the backup directory path (custom folders). @@ -79,14 +79,14 @@ public static function backup_dir_is_writable() { */ public static function get_file_backup_path( $file_path ) { $file_path = wp_normalize_path( (string) $file_path ); - $abspath = imagify_get_filesystem()->get_abspath(); + $site_root = imagify_get_filesystem()->get_site_root(); $backup_dir = self::get_backup_dir_path(); if ( ! $file_path ) { return false; } - return str_replace( $abspath, $backup_dir, $file_path ); + return str_replace( $site_root, $backup_dir, $file_path ); } @@ -402,7 +402,7 @@ public static function refresh_file( $file, $is_folder_active = null ) { * Array( * [7] => Array( * [folder_id] => 7 - * [path] => {{ABSPATH}}/custom-path/ + * [path] => {{ROOT}}/custom-path/ * [active] => 1 * [folder_path] => /absolute/path/to/custom-path/ * ) @@ -478,7 +478,7 @@ public static function get_folders( $args = array() ) { * [_2] => Array( * [file_id] => 2 * [folder_id] => 7 - * [path] => {{ABSPATH}}/custom-path/image-1.jpg + * [path] => {{ROOT}}/custom-path/image-1.jpg * [optimization_level] => null * [status] => null * [file_path] => /absolute/path/to/custom-path/image-1.jpg @@ -486,7 +486,7 @@ public static function get_folders( $args = array() ) { * [_3] => Array( * [file_id] => 3 * [folder_id] => 7 - * [path] => {{ABSPATH}}/custom-path/image-2.jpg + * [path] => {{ROOT}}/custom-path/image-2.jpg * [optimization_level] => 2 * [status] => success * [file_path] => /absolute/path/to/custom-path/image-2.jpg @@ -1017,14 +1017,15 @@ public static function reassign_inactive_files() { } $active_folder_ids = array(); - $has_abspath = false; + $has_site_root = false; foreach ( $active_folders as $i => $active_folder ) { $active_folders[ $i ] = $folders_db->cast_row( $active_folder ); $active_folder_ids[] = $active_folders[ $i ][ $folders_key ]; - if ( '{{ABSPATH}}/' === $active_folders[ $i ]['path'] ) { - $has_abspath = true; + if ( '{{ROOT}}/' === $active_folders[ $i ]['path'] ) { + $has_site_root = true; + break; } } @@ -1044,7 +1045,7 @@ public static function reassign_inactive_files() { $inactive_file = $files_db->cast_row( $inactive_file ); $inactive_file['full_path'] = Imagify_Files_Scan::remove_placeholder( $inactive_file['path'] ); - if ( $has_abspath ) { + if ( $has_site_root ) { $inactive_file['dirname'] = $filesystem->dir_path( $inactive_file['full_path'] ); } @@ -1060,7 +1061,7 @@ public static function reassign_inactive_files() { $file_ids_by_folder[ $folder_id ] = array(); } - if ( '{{ABSPATH}}/' === $active_folder['path'] ) { + if ( '{{ROOT}}/' === $active_folder['path'] ) { // For the site's root: only direct childs. if ( $inactive_file['dirname'] === $active_folder['full_path'] ) { // This file is in the site's root folder. @@ -1199,7 +1200,7 @@ public static function remove_sub_paths( $placeholders ) { sort( $placeholders ); foreach ( $placeholders as $i => $placeholder_path ) { - if ( '{{ABSPATH}}/' === $placeholder_path ) { + if ( '{{ROOT}}/' === $placeholder_path ) { continue; } diff --git a/inc/classes/class-imagify-files-list-table.php b/inc/classes/class-imagify-files-list-table.php index b0d91d896..be3c0c4a4 100755 --- a/inc/classes/class-imagify-files-list-table.php +++ b/inc/classes/class-imagify-files-list-table.php @@ -17,7 +17,7 @@ class Imagify_Files_List_Table extends WP_List_Table { * @since 1.7 * @author Grégory Viguier */ - const VERSION = '1.0.1'; + const VERSION = '1.0.2'; /** * Class version. @@ -309,7 +309,7 @@ public function views() { $counts = $wpdb->get_results( "SELECT folder_id, COUNT( $files_key_esc ) AS count FROM $files_table GROUP BY folder_id", OBJECT_K ); // WPCS: unprepared SQL ok. foreach ( $folders as $folder ) { - if ( '{{ABSPATH}}/' === $folder->path ) { + if ( '{{ROOT}}/' === $folder->path ) { $root_id = $folder->folder_id; $folder_filters[ $folder->folder_id ] = '/'; } else { @@ -363,7 +363,10 @@ public function views() { $status_filter = self::get_status_filter(); // Display the filters. - $this->screen->render_screen_reader_content( 'heading_views' ); + if ( method_exists( $this->screen, 'render_screen_reader_content' ) ) { + // Introduced in WP 4.4. + $this->screen->render_screen_reader_content( 'heading_views' ); + } ?>
@@ -566,7 +569,7 @@ public function column_folder( $item ) { $format = '%s'; } - if ( '{{ABSPATH}}/' === $item->folder_path ) { + if ( '{{ROOT}}/' === $item->folder_path ) { // It's the site's root. printf( $format, __( 'Site\'s root', 'imagify' ) ); } else { diff --git a/inc/classes/class-imagify-files-scan.php b/inc/classes/class-imagify-files-scan.php index a2e0e3689..e6429cc27 100644 --- a/inc/classes/class-imagify-files-scan.php +++ b/inc/classes/class-imagify-files-scan.php @@ -16,7 +16,7 @@ class Imagify_Files_Scan { * @since 1.7 * @author Grégory Viguier */ - const VERSION = '1.1'; + const VERSION = '1.1.1'; /** * Get files (optimizable by Imagify) recursively from a specific folder. @@ -51,7 +51,7 @@ public static function get_files_from_folder( $folder ) { } // Finally we made all our validations. - if ( $filesystem->is_abspath( $folder ) ) { + if ( $filesystem->is_site_root( $folder ) ) { // For the site's root, we don't look in sub-folders. $dir = new DirectoryIterator( $folder ); $dir = new Imagify_Files_Iterator( $dir, false ); @@ -169,10 +169,11 @@ public static function get_forbidden_folders() { } $filesystem = imagify_get_filesystem(); + $site_root = $filesystem->get_site_root(); $abspath = $filesystem->get_abspath(); $folders = array( // Server. - $abspath . 'cgi-bin', // `cgi-bin` + $site_root . 'cgi-bin', // `cgi-bin` // WordPress. $abspath . 'wp-admin', // `wp-admin` $abspath . WPINC, // `wp-includes` @@ -451,7 +452,7 @@ public static function get_placeholder_paths() { '{{THEMES}}/' => WP_CONTENT_DIR . '/themes', '{{UPLOADS}}/' => $filesystem->get_main_upload_basedir(), '{{CONTENT}}/' => WP_CONTENT_DIR, - '{{ABSPATH}}/' => ABSPATH, + '{{ROOT}}/' => $filesystem->get_site_root(), ); $replacements = array_map( array( $filesystem, 'normalize_dir_path' ), $replacements ); @@ -474,13 +475,14 @@ public static function get_placeholder_urls() { return $replacements; } + $filesystem = imagify_get_filesystem(); $replacements = array( '{{PLUGINS}}/' => plugins_url( '/' ), '{{MU_PLUGINS}}/' => plugins_url( '/', WPMU_PLUGIN_DIR . '/.' ), '{{THEMES}}/' => content_url( 'themes/' ), - '{{UPLOADS}}/' => imagify_get_filesystem()->get_main_upload_baseurl(), + '{{UPLOADS}}/' => $filesystem->get_main_upload_baseurl(), '{{CONTENT}}/' => content_url( '/' ), - '{{ABSPATH}}/' => site_url( '/' ), + '{{ROOT}}/' => $filesystem->get_site_root_url(), ); return $replacements; diff --git a/views/part-settings-custom-folders.php b/views/part-settings-custom-folders.php index dfa08d377..ac894eca7 100755 --- a/views/part-settings-custom-folders.php +++ b/views/part-settings-custom-folders.php @@ -22,8 +22,8 @@ natcasesort( $custom_folders ); $custom_folders = array_map( 'trailingslashit', $custom_folders ); - if ( isset( $custom_folders['{{ABSPATH}}/'] ) ) { - $custom_folders['{{ABSPATH}}/'] = __( 'Site\'s root', 'imagify' ); + if ( isset( $custom_folders['{{ROOT}}/'] ) ) { + $custom_folders['{{ROOT}}/'] = __( 'Site\'s root', 'imagify' ); } } diff --git a/views/part-settings-row-custom-folder.php b/views/part-settings-row-custom-folder.php index dcd9d0c22..42a6187e9 100755 --- a/views/part-settings-row-custom-folder.php +++ b/views/part-settings-row-custom-folder.php @@ -1,7 +1,7 @@ -

+

From 85836d38800cebc066e7a324f0ba4cd03f891ab7 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Thu, 21 Jun 2018 23:50:40 +0200 Subject: [PATCH 12/39] On plugin upgrade, replace all `{{ABSPATH}}/` placeholders by `{{ROOT}}/` in the database. --- inc/admin/upgrader.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/inc/admin/upgrader.php b/inc/admin/upgrader.php index 6937397c4..27be8b804 100755 --- a/inc/admin/upgrader.php +++ b/inc/admin/upgrader.php @@ -269,6 +269,22 @@ function _imagify_new_upgrade( $network_version, $site_version ) { // Rename the option that stores the NGG table version. Since the table is also updated in 1.7, let's simply delete the option. delete_option( $wpdb->prefix . 'ngg_imagify_data_db_version' ); } + + // 1.8.1 + if ( version_compare( $site_version, '1.8.1' ) < 0 ) { + // Custom folders: replace `{{ABSPATH}}/` by `{{ROOT}}/`. + $filesystem = imagify_get_filesystem(); + $replacement = '{{ROOT}}/'; + + if ( $filesystem->has_wp_its_own_directory() ) { + $replacement .= str_replace( $filesystem->get_site_root(), '', $filesystem->get_abspath() ); + } + + $replacement = Imagify_DB::esc_like( $replacement ); + + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->base_prefix}imagify_files SET path = REPLACE( path, '{{ABSPATH}}/', %s ) WHERE path LIKE %s", $replacement, '{{ABSPATH}}/%' ) ); + $wpdb->query( $wpdb->prepare( "UPDATE {$wpdb->base_prefix}imagify_folders SET path = REPLACE( path, '{{ABSPATH}}/', %s ) WHERE path LIKE %s", $replacement, '{{ABSPATH}}/%' ) ); + } } add_action( 'upgrader_process_complete', 'imagify_maybe_reset_opcache', 20, 2 ); From 149b7c88e831bde6dc3c17629d8b1d8500709e45 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 22 Jun 2018 00:03:19 +0200 Subject: [PATCH 13/39] Hotfix: removed useless enqueue_style() Since `enqueue_script()` already does it, no need to add it in `enqueue_assets()`. --- inc/classes/class-imagify-assets.php | 1 - 1 file changed, 1 deletion(-) diff --git a/inc/classes/class-imagify-assets.php b/inc/classes/class-imagify-assets.php index e9ef247b1..5a7edaed9 100755 --- a/inc/classes/class-imagify-assets.php +++ b/inc/classes/class-imagify-assets.php @@ -619,7 +619,6 @@ public function enqueue_assets( $handles ) { $handles = (array) $handles; foreach ( $handles as $handle ) { - $this->enqueue_style( $handle ); $this->enqueue_script( $handle ); } From 1fa38e46bfc8a2a11306be341a074fe2addab36d Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 22 Jun 2018 00:04:16 +0200 Subject: [PATCH 14/39] Hotfix: compatibility fix in imagify.template() --- assets/js/admin.js | 2 +- assets/js/admin.min.js | 104 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 2 deletions(-) diff --git a/assets/js/admin.js b/assets/js/admin.js index ff0296b0f..984ec1a43 100755 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -38,7 +38,7 @@ jQuery.extend( window.imagify, { }; return function() { - compiled = compiled || _.template( jQuery( '#tmpl-' + id ).html(), options ); + compiled = compiled || _.template( jQuery( '#tmpl-' + id ).html(), null, options ); data = data || {}; return compiled( data ); }; diff --git a/assets/js/admin.min.js b/assets/js/admin.min.js index b586230e1..984ec1a43 100755 --- a/assets/js/admin.min.js +++ b/assets/js/admin.min.js @@ -1 +1,103 @@ -window.imagify=window.imagify||{},jQuery.extend(window.imagify,{concat:ajaxurl.indexOf("?")>0?"&":"?",log:function(a){void 0!==console&&console.log(a)},info:function(a){void 0!==console&&console.info(a)},openModal:function(a){var b=a.data("target")||a.attr("href");jQuery(b).css("display","flex").hide().fadeIn(400).attr({"aria-hidden":"false",tabindex:"0"}).focus().removeAttr("tabindex").addClass("modal-is-open"),jQuery("body").addClass("imagify-modal-is-open")},template:function(a){return void 0===_?"":_.memoize(function(b){var c,d={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^}]+?)\}\}(?!\})/g,variable:"data"};return function(){return c=c||_.template(jQuery("#tmpl-"+a).html(),d),b=b||{},c(b)}})},humanSize:function(a){var b,c=["B","kB","MB"];return 0===a?"0 kB":(b=parseInt(Math.floor(Math.log(a)/Math.log(1024)),10),(a/Math.pow(1024,b)).toFixed(2)+" "+c[b])}}),function(a,b,c,d){a(".imagify-modal").attr("aria-hidden","true"),a(b).on("click.imagify",".imagify-modal-trigger",function(b){b.preventDefault(),c.imagify.openModal(a(this))}).on("click.imagify",".imagify-modal .close-btn",function(){a(this).closest(".imagify-modal").fadeOut(400).attr("aria-hidden","true").removeClass("modal-is-open").trigger("modalClosed.imagify"),a("body").removeClass("imagify-modal-is-open")}).on("blur.imagify",".imagify-modal .close-btn",function(){var b=a(this).closest(".imagify-modal");"false"===b.attr("aria-hidden")&&b.attr("tabindex","0").focus().removeAttr("tabindex")}).on("click.imagify",".imagify-modal",function(b){a(b.target).filter(".modal-is-open").find(".close-btn").trigger("click.imagify")}).on("keydown.imagify",function(b){27===b.keyCode&&a(".imagify-modal.modal-is-open").length>0&&(b.preventDefault(),a(".imagify-modal.modal-is-open").find(".close-btn").trigger("click.imagify"))})}(jQuery,document,window); \ No newline at end of file +window.imagify = window.imagify || {}; + +jQuery.extend( window.imagify, { + concat: ajaxurl.indexOf( '?' ) > 0 ? '&' : '?', + log: function( content ) { + if ( undefined !== console ) { + console.log( content ); // eslint-disable-line no-console + } + }, + info: function( content ) { + if ( undefined !== console ) { + console.info( content ); // eslint-disable-line no-console + } + }, + openModal: function( $link ) { + var target = $link.data( 'target' ) || $link.attr( 'href' ); + + jQuery( target ).css( 'display', 'flex' ).hide().fadeIn( 400 ).attr( { + 'aria-hidden': 'false', + 'tabindex': '0' + } ).focus().removeAttr( 'tabindex' ).addClass( 'modal-is-open' ); + + jQuery( 'body' ).addClass( 'imagify-modal-is-open' ); + }, + template: function( id ) { + if ( undefined === _ ) { + // No need to load underscore everywhere if we don't use it. + return ''; + } + + return _.memoize( function( data ) { + var compiled, + options = { + evaluate: /<#([\s\S]+?)#>/g, + interpolate: /\{\{\{([\s\S]+?)\}\}\}/g, + escape: /\{\{([^}]+?)\}\}(?!\})/g, + variable: 'data' + }; + + return function() { + compiled = compiled || _.template( jQuery( '#tmpl-' + id ).html(), null, options ); + data = data || {}; + return compiled( data ); + }; + } ); + }, + humanSize: function( bytes ) { + var sizes = ['B', 'kB', 'MB'], + i; + + if ( 0 === bytes ) { + return '0\xA0kB'; + } + + i = parseInt( Math.floor( Math.log( bytes ) / Math.log( 1024 ) ), 10 ); + + return ( bytes / Math.pow( 1024, i ) ).toFixed( 2 ) + '\xA0' + sizes[ i ]; + } +} ); + + +// Imagify light modal ============================================================================= +(function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names + + // Accessibility. + $( '.imagify-modal' ).attr( 'aria-hidden', 'true' ); + + $( d ) + // On click on modal trigger, open modal. + .on( 'click.imagify', '.imagify-modal-trigger', function( e ) { + e.preventDefault(); + w.imagify.openModal( $( this ) ); + } ) + // On click on close button, close modal. + .on( 'click.imagify', '.imagify-modal .close-btn', function() { + var $modal = $( this ).closest( '.imagify-modal' ); + + $modal.fadeOut( 400 ).attr( 'aria-hidden', 'true' ).removeClass( 'modal-is-open' ).trigger( 'modalClosed.imagify' ); + + $( 'body' ).removeClass( 'imagify-modal-is-open' ); + } ) + // On close button blur, improve accessibility. + .on( 'blur.imagify', '.imagify-modal .close-btn', function() { + var $modal = $( this ).closest( '.imagify-modal' ); + + if ( $modal.attr( 'aria-hidden' ) === 'false' ) { + $modal.attr( 'tabindex', '0' ).focus().removeAttr( 'tabindex' ); + } + } ) + // On click on dropped layer of modal, close modal. + .on( 'click.imagify', '.imagify-modal', function( e ) { + $( e.target ).filter( '.modal-is-open' ).find( '.close-btn' ).trigger( 'click.imagify' ); + } ) + // `Esc` key binding, close modal. + .on( 'keydown.imagify', function( e ) { + if ( 27 === e.keyCode && $( '.imagify-modal.modal-is-open' ).length > 0 ) { + e.preventDefault(); + // Trigger the event. + $( '.imagify-modal.modal-is-open' ).find( '.close-btn' ).trigger( 'click.imagify' ); + } + } ); + +} )(jQuery, document, window); From abf55a167153edcab46ec2729be2ba984f1fac1e Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 22 Jun 2018 00:07:11 +0200 Subject: [PATCH 15/39] Hotfix: compatibility with old jQuery versions. --- assets/js/options.js | 85 ++++--- assets/js/options.min.js | 473 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 511 insertions(+), 47 deletions(-) diff --git a/assets/js/options.js b/assets/js/options.js index b90666174..47992ec7d 100755 --- a/assets/js/options.js +++ b/assets/js/options.js @@ -259,47 +259,44 @@ selected.push( this.value ); } ); - $.post( { - url: imagifyOptions.getFilesTree, - dataType: 'json', - data: { - folder: '/', - selected: selected - } - } ).done( function( response ) { - if ( ! response.success ) { - swal( { - title: imagifyOptions.labels.error, - html: response.data || '', - type: 'error', - padding: 0, - customClass: 'imagify-sweet-alert' - } ); - return; - } - - swal( { - title: imagifyOptions.labels.filesTreeTitle, - html: '

' + imagifyOptions.labels.filesTreeSubTitle + '

' + imagifyOptions.labels.cleaningInfo + '

    ' + response.data + '
', - type: '', - customClass: 'imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection', - showCancelButton: true, - padding: 0, - confirmButtonText: imagifyOptions.labels.confirmFilesTreeBtn, - cancelButtonText: imagifySwal.labels.cancelButtonText, - reverseButtons: true - } ).then( function() { - var values = $( '#imagify-folders-tree input' ).serializeArray(); // Don't do `$( '#imagify-folders-tree' ).find( 'input' )`, it won't work. - - if ( ! values.length ) { + $.post( imagifyOptions.getFilesTree, { + folder: '/', + selected: selected + }, null, 'json' ) + .done( function( response ) { + if ( ! response.success ) { + swal( { + title: imagifyOptions.labels.error, + html: response.data || '', + type: 'error', + padding: 0, + customClass: 'imagify-sweet-alert' + } ); return; } - $.each( values, function( i, v ) { - imagifyInsertFolderRow( v.value ); - } ); - } ).catch( swal.noop ); - } ) + swal( { + title: imagifyOptions.labels.filesTreeTitle, + html: '
' + imagifyOptions.labels.filesTreeSubTitle + '

' + imagifyOptions.labels.cleaningInfo + '

    ' + response.data + '
', + type: '', + customClass: 'imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection', + showCancelButton: true, + padding: 0, + confirmButtonText: imagifyOptions.labels.confirmFilesTreeBtn, + cancelButtonText: imagifySwal.labels.cancelButtonText, + reverseButtons: true + } ).then( function() { + var values = $( '#imagify-folders-tree input' ).serializeArray(); // Don't do `$( '#imagify-folders-tree' ).find( 'input' )`, it won't work. + + if ( ! values.length ) { + return; + } + + $.each( values, function( i, v ) { + imagifyInsertFolderRow( v.value ); + } ); + } ).catch( swal.noop ); + } ) .fail( function() { swal( { title: imagifyOptions.labels.error, @@ -341,14 +338,10 @@ selected.push( this.value ); } ); - $.post( { - url: imagifyOptions.getFilesTree, - dataType: 'json', - data: { - folder: $button.data( 'folder' ), - selected: selected - } - } ) + $.post( imagifyOptions.getFilesTree, { + folder: $button.data( 'folder' ), + selected: selected + }, null, 'json' ) .done( function( response ) { if ( ! response.success ) { swal( { diff --git a/assets/js/options.min.js b/assets/js/options.min.js index 1b4dc8058..47992ec7d 100755 --- a/assets/js/options.min.js +++ b/assets/js/options.min.js @@ -1 +1,472 @@ -!function(a,b,c,d){var e=!1,f=!1;a("#imagify-settings #api_key").on("blur",function(){var b=a(this),d=b.val();return""!==a.trim(d)&&(a("#check_api_key").val()===d?(a("#imagify-check-api-container").html(' '+imagifyOptions.labels.ValidApiKeyText),!1):(!0===e?f.abort():(a("#imagify-check-api-container").remove(),b.after(''+imagifyOptions.labels.waitApiKeyCheckText+"")),e=!0,void(f=a.get(ajaxurl+c.imagify.concat+"action=imagify_check_api_key_validity&api_key="+b.val()+"&imagifycheckapikeynonce="+a("#imagifycheckapikeynonce").val()).done(function(b){b.success?(a("#imagify-check-api-container").remove(),swal({title:imagifyOptions.labels.ApiKeyCheckSuccessTitle,html:imagifyOptions.labels.ApiKeyCheckSuccessText,type:"success",padding:0,customClass:"imagify-sweet-alert"}).then(function(){location.reload()})):a("#imagify-check-api-container").html(' '+b.data),e=!1}))))}),a(".imagify-options-line").css("cursor","pointer").on("click",function(b){if("INPUT"!==b.target.nodeName)return a('input[aria-describedby="'+a(this).attr("id")+'"]').trigger("click"),!1}),a(".imagify-settings th span").on("click",function(){var b=a(this).parent().next("td").find("input:checkbox");1===b.length&&b.trigger("click")}),a(".imagify-options-line").find("input").on("change focus",function(){var b=a(this).closest(".imagify-options-line").prev("label").prev("input");b[0].checked||b.prop("checked",!0)}),a(".imagify-settings-section").find("#imagify_backup").on("change",function(){var b=a(this),c=b.siblings("#backup-dir-is-writable"),d={action:"imagify_check_backup_dir_is_writable",_wpnonce:c.data("nonce")};if(b.is(":checked"))return void a.getJSON(ajaxurl,d).done(function(b){a.isPlainObject(b)&&b.success&&(b.data.is_writable?c.addClass("hidden"):c.removeClass("hidden"))});swal({title:imagifyOptions.labels.noBackupTitle,html:imagifyOptions.labels.noBackupText,type:"warning",customClass:"imagify-sweet-alert",padding:0,showCancelButton:!0,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){c.addClass("hidden")},function(){b.prop("checked",!0)})})}(jQuery,document,window),function(a,b,c,d){a.imagifyUser&&c.getJSON(ajaxurl,a.imagifyUser).done(function(a){c.isPlainObject(a)&&a.success&&(a.data.id=null,a.data.plan_id=null,a.data.is=[],c.each(a.data,function(b,d){var e=".imagify-user-"+b.replace(/_/g,"-");0===b.indexOf("is_")?d&&a.data.is.push(e):"is"!==b&&c(e).text(d)}),a.data.is.push("best-plan"),c(a.data.is.join(",")).removeClass("hidden"))})}(window,document,jQuery),function(a,b,c,d){function e(b){var d,e,f,g,h,i=!1,j=null;b&&(f=c("#imagify-custom-folders-selected"),g=f.find(".imagify-custom-folder-line"),h=g.find('[value="'+b+'"]'),h.length||(b=b.split("#///#"),d=b[1].replace(/\/+$/,"").toLowerCase(),e=a.imagify.template("imagify-custom-folder"),g.each(function(){var a=c(this),h=a.data("path").replace(/\/+$/,"").toLowerCase();return""!==h&&0===d.indexOf(h)?(i=!0,!1):d'+imagifyOptions.labels.filesTreeSubTitle+'

'+imagifyOptions.labels.cleaningInfo+'

    '+a.data+"
",type:"",customClass:"imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection",showCancelButton:!0,padding:0,confirmButtonText:imagifyOptions.labels.confirmFilesTreeBtn,cancelButtonText:imagifySwal.labels.cancelButtonText,reverseButtons:!0}).then(function(){var a=c("#imagify-folders-tree input").serializeArray();a.length&&c.each(a,function(a,b){e(b.value)})}).catch(swal.noop)}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",customClass:"imagify-sweet-alert",padding:0})}).always(function(){b.removeAttr("disabled").next("img").attr("aria-hidden","true")}))}),c(b).on("click.imagify","#imagify-folders-tree [data-folder]",function(){var a=c(this),b=a.nextAll(".imagify-folders-sub-tree"),d=[];if(!a.attr("disabled")&&!a.siblings(":checkbox").is(":checked")){if(a.attr("disabled","disabled"),b.length)return a.hasClass("imagify-is-open")?(b.addClass("hidden"),a.removeClass(" imagify-is-open")):(b.removeClass("hidden"),a.addClass(" imagify-is-open")),void a.removeAttr("disabled");c("#imagify-custom-folders-selected").find("input").each(function(){d.push(this.value)}),c.post({url:imagifyOptions.getFilesTree,dataType:"json",data:{folder:a.data("folder"),selected:d}}).done(function(b){if(!b.success)return void swal({title:imagifyOptions.labels.error,html:b.data||"",type:"error",padding:0,customClass:"imagify-sweet-alert"});a.addClass("imagify-is-open").parent().append('
    '+b.data+"
")}).fail(function(){swal({title:imagifyOptions.labels.error,type:"error",padding:0,customClass:"imagify-sweet-alert"})}).always(function(){a.removeAttr("disabled")})}}),c("#imagify-custom-folders").on("click.imagify",".imagify-custom-folders-remove",function(){var b=c(this).closest(".imagify-custom-folder-line").addClass("imagify-will-remove");a.setTimeout(function(){b.remove(),c("#imagify-custom-folders-selected").siblings(".imagify-success.hidden").removeClass("hidden")},750)}),c("#imagify-add-themes-to-custom-folder").on("click.imagify",function(){var a=c(this);e(a.data("theme")),e(a.data("theme-parent")),a.replaceWith("

"+imagifyOptions.labels.themesAdded+"

")}))}(window,document,jQuery),function(a,b,c,d){var e=c.propHooks.checked;c.propHooks.checked={set:function(a,b,d){var f;return f=void 0===e?a[d]=b:e(a,b,d),c(a).trigger("change.imagify"),f}},c(".imagify-select-all").on("click.imagify",function(){var a=c(this),b=a.data("action"),d=a.closest(".imagify-select-all-buttons"),e=d.prev(".imagify-check-group"),f="imagify-is-inactive";if(a.hasClass(f))return!1;d.find(".imagify-select-all").removeClass(f).attr("aria-disabled","false"),a.addClass(f).attr("aria-disabled","true"),e.find(".imagify-row-check").prop("checked",function(){return!c(this).is(":hidden,:disabled")&&"select"===b})}),c(".imagify-check-group .imagify-row-check").on("change.imagify",function(){var a=c(this).closest(".imagify-check-group"),b=a.find(".imagify-row-check"),d=b.filter(":visible:enabled").length,e=b.filter(":visible:enabled:checked").length,f=a.next(".imagify-select-all-buttons"),g="imagify-is-inactive";0===e&&f.find('[data-action="unselect"]').addClass(g).attr("aria-disabled","true"),e===d&&f.find('[data-action="select"]').addClass(g).attr("aria-disabled","true"),e!==d&&e>0&&f.find(".imagify-select-all").removeClass(g).attr("aria-disabled","false")})}(window,document,jQuery); \ No newline at end of file +(function($, d, w, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names + /* + * Process an API key check validity. + */ + var busy = false, + xhr = false; + + $( '#imagify-settings #api_key' ).on( 'blur', function() { + var obj = $( this ), + value = obj.val(); + + if ( $.trim( value ) === '' ) { + return false; + } + + if ( $( '#check_api_key' ).val() === value ) { + $( '#imagify-check-api-container' ).html( ' ' + imagifyOptions.labels.ValidApiKeyText ); + return false; + } + + if ( true === busy ) { + xhr.abort(); + } else { + $( '#imagify-check-api-container' ).remove(); + obj.after( '' + imagifyOptions.labels.waitApiKeyCheckText + '' ); + } + + busy = true; + + xhr = $.get( ajaxurl + w.imagify.concat + 'action=imagify_check_api_key_validity&api_key=' + obj.val() + '&imagifycheckapikeynonce=' + $( '#imagifycheckapikeynonce' ).val() ) + .done( function( response ) { + if ( ! response.success ) { + $( '#imagify-check-api-container' ).html( ' ' + response.data ); + } else { + // Success, the API key is valid. + $( '#imagify-check-api-container' ).remove(); + swal( { + title: imagifyOptions.labels.ApiKeyCheckSuccessTitle, + html: imagifyOptions.labels.ApiKeyCheckSuccessText, + type: 'success', + padding: 0, + customClass: 'imagify-sweet-alert' + } ).then( function() { + location.reload(); + } ); + } + + busy = false; + } ); + } ); + + /** + * Check the boxes by clicking "labels" (aria-describedby items). + */ + $( '.imagify-options-line' ).css( 'cursor', 'pointer' ).on( 'click', function( e ) { + if ( 'INPUT' === e.target.nodeName ) { + return; + } + $( 'input[aria-describedby="' + $( this ).attr( 'id' ) + '"]' ).trigger( 'click' ); + return false; + } ); + + $( '.imagify-settings th span' ).on( 'click', function() { + var $input = $( this ).parent().next( 'td' ).find( 'input:checkbox' ); + + if ( 1 === $input.length ) { + $input.trigger( 'click' ); + } + } ); + + /** + * Auto check on options-line input value change. + */ + $( '.imagify-options-line' ).find( 'input' ).on( 'change focus', function() { + var $checkbox = $( this ).closest( '.imagify-options-line' ).prev( 'label' ).prev( 'input' ); + + if ( ! $checkbox[0].checked ) { + $checkbox.prop( 'checked', true ); + } + } ); + + /** + * Imagify Backup alert. + */ + $( '.imagify-settings-section' ).find( '#imagify_backup' ).on( 'change', function() { + var $_this = $( this ), + $backupMessage = $_this.siblings( '#backup-dir-is-writable' ), + params = { + 'action': 'imagify_check_backup_dir_is_writable', + '_wpnonce': $backupMessage.data( 'nonce' ) + }; + + if ( $_this.is( ':checked' ) ) { + $.getJSON( ajaxurl, params ) + .done( function( r ) { + if ( $.isPlainObject( r ) && r.success ) { + if ( r.data.is_writable ) { + // Hide the error message. + $backupMessage.addClass( 'hidden' ); + } else { + // Show the error message. + $backupMessage.removeClass( 'hidden' ); + } + } + } ); + return; + } + + // Are you sure? No backup? + swal( { + title: imagifyOptions.labels.noBackupTitle, + html: imagifyOptions.labels.noBackupText, + type: 'warning', + customClass: 'imagify-sweet-alert', + padding: 0, + showCancelButton: true, + cancelButtonText: imagifySwal.labels.cancelButtonText, + reverseButtons: true + } ).then( + function() { + // Leave it unchecked, hide the error message. + $backupMessage.addClass( 'hidden' ); + }, + function() { + // Re-check. + $_this.prop( 'checked', true ); + } + ); + } ); + +} )(jQuery, document, window); + + +// Display Imagify User data ======================================================================= +(function(w, d, $, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names + + if ( ! w.imagifyUser ) { + return; + } + + $.getJSON( ajaxurl, w.imagifyUser ) + .done( function( r ) { + if ( $.isPlainObject( r ) && r.success ) { + r.data.id = null; + r.data.plan_id = null; + r.data.is = []; + + $.each( r.data, function( k, v ) { + var htmlClass = '.imagify-user-' + k.replace( /_/g, '-' ); + + if ( k.indexOf( 'is_' ) === 0 ) { + if ( v ) { + r.data.is.push( htmlClass ); + } + } else if ( 'is' !== k ) { + $( htmlClass ).text( v ); + } + } ); + + r.data.is.push( 'best-plan' ); + + $( r.data.is.join( ',' ) ).removeClass( 'hidden' ); + } + } ); + +} )(window, document, jQuery); + + +// Files tree for "custom folders" ================================================================= +(function(w, d, $, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names + + if ( ! imagifyOptions.getFilesTree ) { + return; + } + + function imagifyInsertFolderRow( value ) { + var added = false, + prevPath = null, + valueTest, template, $wrap, $rows, $field; + + if ( ! value ) { + return; + } + + $wrap = $( '#imagify-custom-folders-selected' ); + $rows = $wrap.find( '.imagify-custom-folder-line' ); + $field = $rows.find( '[value="' + value + '"]' ); + + if ( $field.length ) { + // Shouldn't happen. + return; + } + + // Path #///# Label. + value = value.split( '#///#' ); + valueTest = value[1].replace( /\/+$/,'' ).toLowerCase(); + template = w.imagify.template( 'imagify-custom-folder' ); + + $rows.each( function() { + var $this = $( this ), + thisValueTest = $this.data( 'path' ).replace( /\/+$/,'' ).toLowerCase(); + + if ( '' !== thisValueTest && valueTest.indexOf( thisValueTest ) === 0 ) { + // We try to add a sub-folder of an already selected folder. It shouldn't happen though, since it can't be selected. + added = true; + return false; + } else if ( valueTest < thisValueTest ) { + $this.before( template( { + value: value[0], + label: value[1] + } ) ); + $rows = $wrap.find( '.imagify-custom-folder-line' ); + added = true; + return false; + } + } ); + + if ( ! added ) { + $wrap.append( template( { + value: value[0], + label: value[1] + } ) ); + $rows = $wrap.find( '.imagify-custom-folder-line' ); + } + + // Remove sub-paths: if 'a/b/' and 'a/b/c/' are in the array, we keep only the "parent" 'a/b/'. + if ( '' !== valueTest ) { + $rows.each( function() { + var $this = $( this ), + thisPath = $this.data( 'path' ).toLowerCase(); + + if ( null !== prevPath && thisPath.indexOf( prevPath ) === 0 ) { + $this.find( '.imagify-custom-folders-remove' ).trigger( 'click.imagify' ); + } else { + prevPath = thisPath; + } + } ); + } + + // Display a message. + $wrap.next( '.hidden' ).removeClass( 'hidden' ); + } + + // Clicking the main button: fetch site's root folders and files, then display them in a modal. + $( '#imagify-add-custom-folder' ).on( 'click.imagify', function() { + var $button = $( this ), + selected = [], + $folders; + + if ( $button.attr( 'disabled' ) ) { + return; + } + + $button.attr( 'disabled', 'disabled' ).next( 'img' ).attr( 'aria-hidden', 'false' ); + + $folders = $( '#imagify-custom-folders-selected' ); + + $folders.find( 'input' ).each( function() { + selected.push( this.value ); + } ); + + $.post( imagifyOptions.getFilesTree, { + folder: '/', + selected: selected + }, null, 'json' ) + .done( function( response ) { + if ( ! response.success ) { + swal( { + title: imagifyOptions.labels.error, + html: response.data || '', + type: 'error', + padding: 0, + customClass: 'imagify-sweet-alert' + } ); + return; + } + + swal( { + title: imagifyOptions.labels.filesTreeTitle, + html: '
' + imagifyOptions.labels.filesTreeSubTitle + '

' + imagifyOptions.labels.cleaningInfo + '

    ' + response.data + '
', + type: '', + customClass: 'imagify-sweet-alert imagify-swal-has-subtitle imagify-folders-selection', + showCancelButton: true, + padding: 0, + confirmButtonText: imagifyOptions.labels.confirmFilesTreeBtn, + cancelButtonText: imagifySwal.labels.cancelButtonText, + reverseButtons: true + } ).then( function() { + var values = $( '#imagify-folders-tree input' ).serializeArray(); // Don't do `$( '#imagify-folders-tree' ).find( 'input' )`, it won't work. + + if ( ! values.length ) { + return; + } + + $.each( values, function( i, v ) { + imagifyInsertFolderRow( v.value ); + } ); + } ).catch( swal.noop ); + } ) + .fail( function() { + swal( { + title: imagifyOptions.labels.error, + type: 'error', + customClass: 'imagify-sweet-alert', + padding: 0 + } ); + } ) + .always( function(){ + $button.removeAttr( 'disabled' ).next( 'img' ).attr( 'aria-hidden', 'true' ); + } ); + } ); + + // Clicking a folder icon in the modal: fetch the folder's sub-folders and files, then display them. + $( d ).on( 'click.imagify', '#imagify-folders-tree [data-folder]', function() { + var $button = $( this ), + $tree = $button.nextAll( '.imagify-folders-sub-tree' ), + selected = []; + + if ( $button.attr( 'disabled' ) || $button.siblings( ':checkbox' ).is( ':checked' ) ) { + return; + } + + $button.attr( 'disabled', 'disabled' ); + + if ( $tree.length ) { + if ( $button.hasClass( 'imagify-is-open' ) ) { + $tree.addClass( 'hidden' ); + $button.removeClass(' imagify-is-open' ); + } else { + $tree.removeClass( 'hidden' ); + $button.addClass(' imagify-is-open' ); + } + $button.removeAttr( 'disabled' ); + return; + } + + $( '#imagify-custom-folders-selected' ).find( 'input' ).each( function() { + selected.push( this.value ); + } ); + + $.post( imagifyOptions.getFilesTree, { + folder: $button.data( 'folder' ), + selected: selected + }, null, 'json' ) + .done( function( response ) { + if ( ! response.success ) { + swal( { + title: imagifyOptions.labels.error, + html: response.data || '', + type: 'error', + padding: 0, + customClass: 'imagify-sweet-alert' + } ); + return; + } + + $button.addClass( 'imagify-is-open' ).parent().append( '
    ' + response.data + '
' ); + } ) + .fail( function(){ + swal( { + title: imagifyOptions.labels.error, + type: 'error', + padding: 0, + customClass: 'imagify-sweet-alert' + } ); + } ) + .always( function(){ + $button.removeAttr( 'disabled' ); + } ); + } ); + + // Clicking a Remove folder button make it disappear. + $( '#imagify-custom-folders' ).on( 'click.imagify', '.imagify-custom-folders-remove', function() { + var $row = $( this ).closest( '.imagify-custom-folder-line' ).addClass( 'imagify-will-remove' ); + + w.setTimeout( function() { + $row.remove(); + // Display a message. + $( '#imagify-custom-folders-selected' ).siblings( '.imagify-success.hidden' ).removeClass( 'hidden' ); + }, 750 ); + } ); + + // Clicking the "add themes to folders" button. + $( '#imagify-add-themes-to-custom-folder' ).on( 'click.imagify', function() { + var $this = $( this ); + + imagifyInsertFolderRow( $this.data( 'theme' ) ); + imagifyInsertFolderRow( $this.data( 'theme-parent' ) ); + + // Remove clicked button. + $this.replaceWith( '

' + imagifyOptions.labels.themesAdded + '

' ); + } ); + +} )(window, document, jQuery); + + +// "Select all" checkboxes ========================================================================= +(function(w, d, $, undefined) { // eslint-disable-line no-unused-vars, no-shadow, no-shadow-restricted-names + + var jqPropHookChecked = $.propHooks.checked; + + // Force `.prop()` to trigger a `change` event. + $.propHooks.checked = { + set: function( elem, value, name ) { + var ret; + + if ( undefined === jqPropHookChecked ) { + ret = ( elem[ name ] = value ); + } else { + ret = jqPropHookChecked( elem, value, name ); + } + + $( elem ).trigger( 'change.imagify' ); + + return ret; + } + }; + + // Check all checkboxes. + $( '.imagify-select-all' ).on( 'click.imagify', function() { + var $_this = $(this), + action = $_this.data( 'action' ), + $btns = $_this.closest( '.imagify-select-all-buttons' ), + $group = $btns.prev( '.imagify-check-group' ), + inactive = 'imagify-is-inactive'; + + if ( $_this.hasClass( inactive ) ) { + return false; + } + + $btns.find( '.imagify-select-all' ).removeClass( inactive ).attr( 'aria-disabled', 'false' ); + $_this.addClass( inactive ).attr( 'aria-disabled', 'true' ); + + $group.find( '.imagify-row-check' ) + .prop( 'checked', function() { + var $this = $( this ); + + if ( $this.is( ':hidden,:disabled' ) ) { + return false; + } + + if ( action === 'select' ) { + return true; + } + + return false; + } ); + + } ); + + // Change buttons status on checkboxes interation. + $( '.imagify-check-group .imagify-row-check' ).on( 'change.imagify', function() { + var $group = $( this ).closest( '.imagify-check-group' ), + $checks = $group.find( '.imagify-row-check' ), + could_be = $checks.filter( ':visible:enabled' ).length, + are_checked = $checks.filter( ':visible:enabled:checked' ).length, + $btns = $group.next( '.imagify-select-all-buttons' ), + inactive = 'imagify-is-inactive'; + + // Toggle status of "check all" buttons. + if ( are_checked === 0 ) { + $btns.find( '[data-action="unselect"]' ).addClass( inactive ).attr( 'aria-disabled', 'true' ); + } + if ( are_checked === could_be ) { + $btns.find( '[data-action="select"]' ).addClass( inactive ).attr( 'aria-disabled', 'true' ); + } + if ( are_checked !== could_be && are_checked > 0 ) { + $btns.find( '.imagify-select-all' ).removeClass( inactive ).attr( 'aria-disabled', 'false' ); + } + } ); + +} )(window, document, jQuery); From f613f4893943cc77398ef184d58e254c757663ff Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 22 Jun 2018 00:42:23 +0200 Subject: [PATCH 16/39] Use $wpdb->esc_like() Since next release will require WP 4.0, revert the `Imagify_DB::esc_like()` to previous `$wpdb->esc_like()`, so the class is not modified anymore. --- inc/classes/class-wp-background-process.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/classes/class-wp-background-process.php b/inc/classes/class-wp-background-process.php index 92af346b5..0daf36b8b 100755 --- a/inc/classes/class-wp-background-process.php +++ b/inc/classes/class-wp-background-process.php @@ -195,7 +195,7 @@ protected function is_queue_empty() { $column = 'meta_key'; } - $key = Imagify_DB::esc_like( $this->identifier . '_batch_' ) . '%'; + $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; $count = $wpdb->get_var( $wpdb->prepare( " SELECT COUNT(*) @@ -270,7 +270,7 @@ protected function get_batch() { $value_column = 'meta_value'; } - $key = Imagify_DB::esc_like( $this->identifier . '_batch_' ) . '%'; + $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; $query = $wpdb->get_row( $wpdb->prepare( " SELECT * From a880aa909ee9e8749618fd60099b892ca58831c0 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Fri, 22 Jun 2018 22:40:08 +0200 Subject: [PATCH 17/39] Introduced class Imagify_Abstract_Background_Process This is an abstract class that extends `WP_Background_Process`: - It makes sure the method `cancel_process()` exists. - It makes sure the cron healthcheck is unscheduled on plugin deactivation (it should not be necessary, it's just in case something went wrong). - It sets a default `$prefix` property value. Unfortunately, `get_instance()` must recreated in child classes because of php 5.2 (`static` !== `self`). --- ...-dynamic-thumbnails-background-process.php | 14 +- .../nextgen-gallery/nextgen-gallery.php | 2 +- ...ss-imagify-abstract-background-process.php | 139 ++++++++++++++++++ inc/classes/class-wp-async-request.php | 2 + inc/classes/class-wp-background-process.php | 2 + inc/functions/common.php | 63 ++++---- 6 files changed, 178 insertions(+), 44 deletions(-) create mode 100755 inc/classes/class-imagify-abstract-background-process.php diff --git a/inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-dynamic-thumbnails-background-process.php b/inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-dynamic-thumbnails-background-process.php index 0addd9280..f3b8b4672 100755 --- a/inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-dynamic-thumbnails-background-process.php +++ b/inc/3rd-party/nextgen-gallery/inc/classes/class-imagify-ngg-dynamic-thumbnails-background-process.php @@ -7,7 +7,7 @@ * @since 1.8 * @author Grégory Viguier */ -class Imagify_NGG_Dynamic_Thumbnails_Background_Process extends WP_Background_Process { +class Imagify_NGG_Dynamic_Thumbnails_Background_Process extends Imagify_Abstract_Background_Process { /** * Class version. @@ -16,17 +16,7 @@ class Imagify_NGG_Dynamic_Thumbnails_Background_Process extends WP_Background_Pr * @since 1.8 * @author Grégory Viguier */ - const VERSION = '1.0'; - - /** - * Prefix used to build the global process identifier. - * - * @var string - * @since 1.8 - * @access protected - * @author Grégory Viguier - */ - protected $prefix = 'imagify'; + const VERSION = '1.1'; /** * Action. diff --git a/inc/3rd-party/nextgen-gallery/nextgen-gallery.php b/inc/3rd-party/nextgen-gallery/nextgen-gallery.php index d8abf9175..120d45d5f 100755 --- a/inc/3rd-party/nextgen-gallery/nextgen-gallery.php +++ b/inc/3rd-party/nextgen-gallery/nextgen-gallery.php @@ -19,7 +19,7 @@ Imagify_NGG::get_instance()->init(); Imagify_NGG_DB::get_instance()->init(); -Imagify_NGG_Dynamic_Thumbnails_Background_Process::get_instance(); +Imagify_NGG_Dynamic_Thumbnails_Background_Process::get_instance()->init(); if ( is_admin() ) { require( IMAGIFY_NGG_ADMIN_PATH . 'enqueue.php' ); diff --git a/inc/classes/class-imagify-abstract-background-process.php b/inc/classes/class-imagify-abstract-background-process.php new file mode 100755 index 000000000..3d065e131 --- /dev/null +++ b/inc/classes/class-imagify-abstract-background-process.php @@ -0,0 +1,139 @@ +cancel_process(); + } else { + add_action( self::get_deactivation_hook_name(), array( $this, 'cancel_process' ) ); + } + } + + + /** ----------------------------------------------------------------------------------------- */ + /** COMPAT ================================================================================== */ + /** ----------------------------------------------------------------------------------------- */ + + /** + * Cancel Process. + * Stop processing queue items, clear cronjob and delete batch. + * This is a copy of the parent's method, in case an older version of WP_Background_Process is loaded instead of this one (an old version without this method). + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + */ + public function cancel_process() { + if ( method_exists( $this, 'cancel_process' ) ) { + parent::cancel_process(); + return; + } + + if ( ! $this->is_queue_empty() ) { + $batch = $this->get_batch(); + + $this->delete( $batch->key ); + + wp_clear_scheduled_hook( $this->get_event_name() ); + } + } + + + /** ----------------------------------------------------------------------------------------- */ + /** TOOLS =================================================================================== */ + /** ----------------------------------------------------------------------------------------- */ + + /** + * Get the cron name. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + * + * @return string + */ + public function get_event_name() { + return $this->cron_hook_identifier; + } + + /** + * Get the cron name. + * + * @since 1.8.1 + * @access public + * @author Grégory Viguier + * + * @return string + */ + public static function get_deactivation_hook_name() { + static $deactivation_hook; + + if ( ! isset( $deactivation_hook ) ) { + $deactivation_hook = 'deactivate_' . plugin_basename( IMAGIFY_FILE ); + } + + return $deactivation_hook; + } +} diff --git a/inc/classes/class-wp-async-request.php b/inc/classes/class-wp-async-request.php index f1bef8344..098e60ef8 100755 --- a/inc/classes/class-wp-async-request.php +++ b/inc/classes/class-wp-async-request.php @@ -1,4 +1,6 @@ 1, - 'Imagify_Abstract_Cron' => 1, - 'Imagify_Abstract_DB' => 1, - 'Imagify_Abstract_Options' => 1, - 'Imagify_Admin_Ajax_Post' => 1, - 'Imagify_Assets' => 1, - 'Imagify_Attachment' => 1, - 'Imagify_Cron_Library_Size' => 1, - 'Imagify_Cron_Rating' => 1, - 'Imagify_Cron_Sync_Files' => 1, - 'Imagify_Custom_Folders' => 1, - 'Imagify_Data' => 1, - 'Imagify_DB' => 1, - 'Imagify_File_Attachment' => 1, - 'Imagify_Files_DB' => 1, - 'Imagify_Files_Iterator' => 1, - 'Imagify_Files_List_Table' => 1, - 'Imagify_Files_Recursive_Iterator' => 1, - 'Imagify_Files_Scan' => 1, - 'Imagify_Files_Stats' => 1, - 'Imagify_Filesystem' => 1, - 'Imagify_Folders_DB' => 1, - 'Imagify_Notices' => 1, - 'Imagify_Options' => 1, - 'Imagify_Requirements' => 1, - 'Imagify_Settings' => 1, - 'Imagify_User' => 1, - 'Imagify_Views' => 1, - 'Imagify' => 1, - 'WP_Async_Request' => 1, - 'WP_Background_Process' => 1, + 'Imagify_Abstract_Attachment' => 1, + 'Imagify_Abstract_Background_Process' => 1, + 'Imagify_Abstract_Cron' => 1, + 'Imagify_Abstract_DB' => 1, + 'Imagify_Abstract_Options' => 1, + 'Imagify_Admin_Ajax_Post' => 1, + 'Imagify_Assets' => 1, + 'Imagify_Attachment' => 1, + 'Imagify_Cron_Library_Size' => 1, + 'Imagify_Cron_Rating' => 1, + 'Imagify_Cron_Sync_Files' => 1, + 'Imagify_Custom_Folders' => 1, + 'Imagify_Data' => 1, + 'Imagify_DB' => 1, + 'Imagify_File_Attachment' => 1, + 'Imagify_Files_DB' => 1, + 'Imagify_Files_Iterator' => 1, + 'Imagify_Files_List_Table' => 1, + 'Imagify_Files_Recursive_Iterator' => 1, + 'Imagify_Files_Scan' => 1, + 'Imagify_Files_Stats' => 1, + 'Imagify_Filesystem' => 1, + 'Imagify_Folders_DB' => 1, + 'Imagify_Notices' => 1, + 'Imagify_Options' => 1, + 'Imagify_Requirements' => 1, + 'Imagify_Settings' => 1, + 'Imagify_User' => 1, + 'Imagify_Views' => 1, + 'Imagify' => 1, + 'WP_Async_Request' => 1, + 'WP_Background_Process' => 1, ); if ( isset( $classes[ $class ] ) ) { From 8861acba67ed7d87aead062c67a0aac9827aec93 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Tue, 26 Jun 2018 00:55:09 +0200 Subject: [PATCH 18/39] Hotfix: in `Imagify_Abstract_Attachment::resize()`, surround the resizing by the add/remove `image_strip_meta` filter. This prevents returning without removing the filter. Also use a "random" priority for this filter, preventing messing with another identical hook from another plugin. --- assets/css/pricing-modal.css | 6 +++++- assets/js/pricing-modal.js | 8 ++++---- inc/classes/class-imagify-abstract-attachment.php | 15 +++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/assets/css/pricing-modal.css b/assets/css/pricing-modal.css index d2c6c0a6e..edd681963 100755 --- a/assets/css/pricing-modal.css +++ b/assets/css/pricing-modal.css @@ -525,6 +525,10 @@ span.imagify-price-by { border-color: #FFF; background: #40B1D0; } +.imagify-offer-selected .imagify-checkbox.imagify-checkbox:not(:checked) + label:after, +.imagify-offer-selected .imagify-checkbox.imagify-checkbox:checked + label:after { + color: #FFF; +} .imagify-offer-selected .imagify-offer-by { color: #2E3243; } @@ -1143,4 +1147,4 @@ p.imagify-modal-sidebar-title { color: #40b1d0; float: right; font-weight: bold; -} \ No newline at end of file +} diff --git a/assets/js/pricing-modal.js b/assets/js/pricing-modal.js index f483344c7..d917910f2 100755 --- a/assets/js/pricing-modal.js +++ b/assets/js/pricing-modal.js @@ -152,7 +152,7 @@ quo = datas.quota, // 1000 (MB) - 5000 images (monthly/onetime) cos = datas.cost, // 3.49 (onetime) name = ( quo >= 1000 ? quo / 1000 + ' GB' : quo + ' MB' ), - pcs = type === 'monthly' ? { monthly: mon, yearly: Math.round( ann / 12 * 100 ) / 100 } : cos, + pcs = 'monthly' === type ? { monthly: mon, yearly: Math.round( ann / 12 * 100 ) / 100 } : cos, pcsd = pcs, // Used if discount is active. percent, $datas_c, datas_content; @@ -163,7 +163,7 @@ } if ( typeof classes !== 'undefined' ) { - $offer.addClass( 'imagify-' + type + '-' + lab + classes); + $offer.addClass( 'imagify-' + type + '-' + lab + classes ); } // Name. @@ -363,10 +363,10 @@ // Switch offers title is < 25mb. if ( mo_user_cons < 25 && ot_user_cons < 25 ) { $( '.imagify-pre-checkout-offers .imagify-modal-title' ).addClass( 'imagify-enough-free' ); - $( '.imagify-offer-selected' ).removeClass( 'imagify-offer-selected' ).find( '.imagify-checkbox' ).removeAttr( 'checked' ); + $( '.imagify-offer-selected' ).removeClass( 'imagify-offer-selected' ).find( '.imagify-checkbox' ).prop( 'checked', false ); } else { $( '.imagify-enough-free' ).removeClass( 'imagify-enough-free' ); - $( '.imagify-offer-selected' ).addClass( 'imagify-offer-selected' ).find( '.imagify-checkbox' ).attr( 'checked', 'checked' ); + $( '.imagify-offer-line' ).addClass( 'imagify-offer-selected' ).find( '.imagify-checkbox' ).prop( 'checked', true ); } // Don't create prices table if something went wrong during request. diff --git a/inc/classes/class-imagify-abstract-attachment.php b/inc/classes/class-imagify-abstract-attachment.php index 3b40b2f86..2cd30ebaa 100644 --- a/inc/classes/class-imagify-abstract-attachment.php +++ b/inc/classes/class-imagify-abstract-attachment.php @@ -1024,17 +1024,13 @@ public function resize( $attachment_path, $attachment_sizes, $max_width ) { return ''; } - // Prevent removal of the exif/meta data when resizing (only works with Imagick). - add_filter( 'image_strip_meta', '__return_false' ); - - $new_sizes = wp_constrain_dimensions( $attachment_sizes['width'], $attachment_sizes['height'], $max_width ); - $editor = $this->get_editor( $attachment_path ); if ( is_wp_error( $editor ) ) { return $editor; } + $new_sizes = wp_constrain_dimensions( $attachment_sizes['width'], $attachment_sizes['height'], $max_width ); $image_type = strtolower( (string) $this->filesystem->path_info( $attachment_path, 'extension' ) ); // Try to correct for auto-rotation if the info is available. @@ -1054,8 +1050,14 @@ public function resize( $attachment_path, $attachment_sizes, $max_width ) { } } + // Prevent removal of the exif data when resizing (only works with Imagick). + add_filter( 'image_strip_meta', '__return_false', 789 ); + $resized = $editor->resize( $new_sizes[0], $new_sizes[1], false ); + // Remove the filter when we're done to prevent any conflict. + remove_filter( 'image_strip_meta', '__return_false', 789 ); + if ( is_wp_error( $resized ) ) { return $resized; } @@ -1067,9 +1069,6 @@ public function resize( $attachment_path, $attachment_sizes, $max_width ) { return $resized_image_saved; } - // Remove the filter when we're done to prevent any conflict. - remove_filter( 'image_strip_meta', '__return_false' ); - return $resized_image_path; } From 55d1c6e5b9426eef9fec8512c5a5f0c0dfa713b6 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Wed, 27 Jun 2018 23:36:10 +0200 Subject: [PATCH 19/39] Improved `imagify_size_format()` by introducing "automatic" decimals In that case, 0 decimals if `$bytes` <= 1GB, or 1 if > 1GB. --- inc/functions/formatting.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/inc/functions/formatting.php b/inc/functions/formatting.php index e0f145fc7..5083d86db 100755 --- a/inc/functions/formatting.php +++ b/inc/functions/formatting.php @@ -38,13 +38,20 @@ function imagify_round_half_five( $number ) { * This is a clone of size_format(), but with a non-breaking space. * * @since 1.7 + * @since 1.8.1 Automatic $decimals. * @author Grégory Viguier * * @param int|string $bytes Number of bytes. Note max integer size for integers. - * @param int $decimals Optional. Precision of number of decimal places. Default 0. + * @param int $decimals Optional. Precision of number of decimal places. + * If negative or not an integer, $decimals value is "automatic": 0 if $bytes <= 1GB, or 1 if > 1GB. * @return string|false False on failure. Number string on success. */ -function imagify_size_format( $bytes, $decimals = 0 ) { +function imagify_size_format( $bytes, $decimals = -1 ) { + + if ( $decimals < 0 || ! is_int( $decimals ) ) { + $decimals = $bytes > pow( 1024, 3 ) ? 1 : 0; + } + $bytes = @size_format( $bytes, $decimals ); return str_replace( ' ', ' ', $bytes ); } From 4d552f4edf5fbc376eea208c355c7a084b60cd41 Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Wed, 27 Jun 2018 23:39:18 +0200 Subject: [PATCH 20/39] Use `pow( 1024, 2 )` instead of `1048576` for better understanding --- inc/classes/class-imagify-admin-ajax-post.php | 2 +- inc/functions/admin.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/classes/class-imagify-admin-ajax-post.php b/inc/classes/class-imagify-admin-ajax-post.php index 1ac225cc3..a08b6825f 100755 --- a/inc/classes/class-imagify-admin-ajax-post.php +++ b/inc/classes/class-imagify-admin-ajax-post.php @@ -1149,7 +1149,7 @@ public function imagify_get_admin_bar_profile_callback() { $message .= '

' . sprintf( /* translators: 1 is a data quota, 2 is a date. */ __( 'You have consumed all your credit for this month. You will have %1$s back on %2$s.', 'imagify' ), - imagify_size_format( $user->quota * 1048576 ), + imagify_size_format( $user->quota * pow( 1024, 2 ) ), date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) ) ) . '

'; $message .= '

' . __( 'Upgrade My Subscription', 'imagify' ) . '

'; diff --git a/inc/functions/admin.php b/inc/functions/admin.php index 314770a02..d4682be62 100755 --- a/inc/functions/admin.php +++ b/inc/functions/admin.php @@ -467,7 +467,7 @@ function imagify_cache_user() { } } - $data->quota_formatted = imagify_size_format( $user->quota * 1048576 ); + $data->quota_formatted = imagify_size_format( $user->quota * pow( 1024, 2 ) ); $data->next_date_update_formatted = date_i18n( get_option( 'date_format' ), strtotime( $user->next_date_update ) ); if ( imagify_is_active_for_network() ) { From 6c9782408f5cd2c58bc7d3af0b6014cf586dd3bc Mon Sep 17 00:00:00 2001 From: Git I Hate You Date: Wed, 27 Jun 2018 23:42:59 +0200 Subject: [PATCH 21/39] Simpler payment modal "template": no need to use real values --- views/modal-payment.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/views/modal-payment.php b/views/modal-payment.php index 0742fc65f..16b2d55ed 100755 --- a/views/modal-payment.php +++ b/views/modal-payment.php @@ -1,19 +1,19 @@