| @@ -1,22 +1,35 @@ | ||
| 1 | 1 | <?php |
| 2 | -defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); | |
| 2 | +defined( 'ABSPATH' ) || exit; | |
| 3 | 3 | |
| 4 | 4 | $settings = Imagify_Settings::get_instance(); |
| 5 | 5 | $options = Imagify_Options::get_instance(); |
| 6 | 6 | $option_name = $options->get_option_name(); |
| 7 | 7 | $hidden_class = Imagify_Requirements::is_api_key_valid() ? '' : ' hidden'; |
| 8 | -$lang = imagify_get_current_lang_in( array( 'de', 'es', 'fr', 'it' ) ); | |
| 8 | +$lang = imagify_get_current_lang_in( [ 'de', 'es', 'fr', 'it' ] ); | |
| 9 | 9 | |
| 10 | 10 | /* Ads notice */ |
| 11 | -$notice = 'wp-rocket'; | |
| 12 | -$user_id = get_current_user_id(); | |
| 13 | -$notices = get_user_meta( $user_id, '_imagify_ignore_ads', true ); | |
| 14 | -$notices = $notices && is_array( $notices ) ? array_flip( $notices ) : array(); | |
| 15 | -$wrapper_class = isset( $notices[ $notice ] ) || defined( 'WP_ROCKET_VERSION' ) ? 'imagify-have-rocket' : 'imagify-dont-have-rocket'; | |
| 11 | +$plugins_list = get_plugins(); | |
| 12 | +$notice = 'wp-rocket'; | |
| 13 | +$user_id = get_current_user_id(); | |
| 14 | +$notices = get_user_meta( $user_id, '_imagify_ignore_ads', true ); | |
| 15 | +$notices = $notices && is_array( $notices ) ? array_flip( $notices ) : []; | |
| 16 | +$wrapper_class = isset( $notices[ $notice ] ) || isset( $plugins_list['wp-rocket/wp-rocket.php'] ) ? 'imagify-have-rocket' : 'imagify-dont-have-rocket'; | |
| 16 | 17 | ?> |
| 17 | -<div class="wrap imagify-settings <?php echo $wrapper_class; ?> imagify-clearfix"> | |
| 18 | +<div class="wrap imagify-settings <?php echo esc_attr( $wrapper_class ); ?> imagify-clearfix"> | |
| 18 | 19 | |
| 20 | + <?php | |
| 21 | + /** | |
| 22 | + * Core only requires `options-head.php` (which calls `settings_errors()`) when the page | |
| 23 | + * parent is `options-general.php`. That is the case when Imagify is registered with | |
| 24 | + * `add_options_page()`, but not when it is network-activated and registered with | |
| 25 | + * `add_menu_page()`/`add_submenu_page()`. Print the notices ourselves in that case. | |
| 26 | + */ | |
| 27 | + if ( 'options-general.php' !== ( isset( $GLOBALS['parent_file'] ) ? $GLOBALS['parent_file'] : '' ) ) { | |
| 28 | + settings_errors(); | |
| 29 | + } | |
| 30 | + ?> | |
| 31 | + | |
| 19 | 32 | <div class="imagify-col imagify-main"> |
| 20 | 33 | |
| 21 | 34 | <?php $this->print_template( 'part-settings-header' ); ?> |
| 22 | 35 | <div class="imagify-main-content"> |
| @@ -34,94 +47,58 @@ | ||
| 34 | 47 | $this->print_template( 'part-settings-footer' ); |
| 35 | 48 | } |
| 36 | 49 | ?> |
| 37 | 50 | |
| 38 | - <div class="imagify-col imagify-shared-with-account-col<?php echo $hidden_class; ?>"> | |
| 51 | + <div class="imagify-col imagify-shared-with-account-col<?php echo esc_attr( $hidden_class ); ?>"> | |
| 39 | 52 | <div class="imagify-settings-section"> |
| 40 | 53 | |
| 41 | - <h2 class="imagify-options-title"><?php _e( 'General Settings', 'imagify' ); ?></h2> | |
| 54 | + <h2 class="imagify-options-title"><?php esc_html_e( 'General Settings', 'imagify' ); ?></h2> | |
| 42 | 55 | |
| 43 | - <p class="imagify-options-subtitle" id="imagify-optimization-level-label"> | |
| 44 | - <?php _e( 'Optimization Level', 'imagify' ); ?> | |
| 45 | - | |
| 46 | - <span class="imagify-info"> | |
| 47 | - <span class="dashicons dashicons-info"></span> | |
| 48 | - <a href="#imagify-more-info" class="imagify-modal-trigger"><?php _e( 'More info?', 'imagify' ); ?></a> | |
| 49 | - </span> | |
| 50 | - </p> | |
| 51 | - | |
| 52 | - <div class="imagify-setting-optim-level"> | |
| 53 | - <p class="imagify-inline-options"> | |
| 54 | - <input type="radio" id="imagify-optimization_level_normal" name="<?php echo $option_name; ?>[optimization_level]" value="0" <?php checked( $options->get( 'optimization_level' ), 0 ); ?> aria-describedby="imagify-optimization-level-label"> | |
| 55 | - <label for="imagify-optimization_level_normal"> | |
| 56 | - <?php _e( 'Normal', 'imagify' ); ?> | |
| 57 | - </label> | |
| 58 | - | |
| 59 | - <input type="radio" id="imagify-optimization_level_aggro" name="<?php echo $option_name; ?>[optimization_level]" value="1" <?php checked( $options->get( 'optimization_level' ), 1 ); ?> aria-describedby="imagify-optimization-level-label"> | |
| 60 | - <label for="imagify-optimization_level_aggro"> | |
| 61 | - <?php _e( 'Aggressive', 'imagify' ); ?> | |
| 62 | - </label> | |
| 63 | - | |
| 64 | - <input type="radio" id="imagify-optimization_level_ultra" name="<?php echo $option_name; ?>[optimization_level]" value="2" <?php checked( $options->get( 'optimization_level' ), 2 ); ?> aria-describedby="imagify-optimization-level-label"> | |
| 65 | - <label for="imagify-optimization_level_ultra"> | |
| 66 | - <?php _e( 'Ultra', 'imagify' ); ?> | |
| 67 | - </label> | |
| 68 | - </p> | |
| 69 | - | |
| 70 | - <p class="imagify-visual-comparison-text"> | |
| 71 | - <?php | |
| 72 | - printf( | |
| 73 | - /* translators: 1 is a button tag start, 2 is the button tag end. */ | |
| 74 | - __( 'Need help to choose? %1$sTry the Visual Comparison%2$s', 'imagify' ), | |
| 75 | - '<button type="button" class="button button-primary button-mini-flat imagify-visual-comparison-btn imagify-modal-trigger" data-target="#imagify-visual-comparison">', | |
| 76 | - '</button>' | |
| 77 | - ); | |
| 78 | - ?> | |
| 79 | - </p> | |
| 80 | - </div> | |
| 81 | - | |
| 82 | 56 | <p class="imagify-setting-line"> |
| 83 | 57 | <?php |
| 84 | - $settings->field_checkbox( array( | |
| 85 | - 'option_name' => 'auto_optimize', | |
| 86 | - 'label' => __( 'Auto-Optimize images on upload', 'imagify' ), | |
| 87 | - 'info' => __( 'Automatically optimize every image you upload to WordPress.', 'imagify' ), | |
| 88 | - ) ); | |
| 58 | + $settings->field_checkbox( | |
| 59 | + [ | |
| 60 | + 'option_name' => 'auto_optimize', | |
| 61 | + 'label' => __( 'Auto-Optimize images on upload', 'imagify' ), | |
| 62 | + 'info' => __( 'Automatically optimize every image you upload to WordPress.', 'imagify' ), | |
| 63 | + ] | |
| 64 | + ); | |
| 89 | 65 | ?> |
| 90 | 66 | </p> |
| 91 | 67 | |
| 92 | 68 | <p class="imagify-setting-line"> |
| 93 | 69 | <?php |
| 94 | - $settings->field_checkbox( array( | |
| 95 | - 'option_name' => 'backup', | |
| 96 | - 'label' => __( 'Backup original images', 'imagify' ), | |
| 97 | - 'info' => __( 'Keep your original images in a separate folder before optimization process.', 'imagify' ), | |
| 98 | - ) ); | |
| 70 | + $settings->field_checkbox( | |
| 71 | + [ | |
| 72 | + 'option_name' => 'backup', | |
| 73 | + 'label' => __( 'Backup original images', 'imagify' ), | |
| 74 | + 'info' => __( 'Keep your original images in a separate folder before optimization process.', 'imagify' ), | |
| 75 | + ] | |
| 76 | + ); | |
| 99 | 77 | |
| 100 | 78 | $backup_error_class = $options->get( 'backup' ) && ! Imagify_Requirements::attachments_backup_dir_is_writable() ? '' : ' hidden'; |
| 101 | 79 | ?> |
| 102 | - <br/><strong id="backup-dir-is-writable" class="imagify-error<?php echo $backup_error_class; ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'imagify_check_backup_dir_is_writable' ) ); ?>"> | |
| 80 | + <br/><strong id="backup-dir-is-writable" class="imagify-error<?php echo esc_attr( $backup_error_class ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'imagify_check_backup_dir_is_writable' ) ); ?>"> | |
| 103 | 81 | <?php |
| 104 | 82 | $backup_path = $this->filesystem->make_path_relative( get_imagify_backup_dir_path( true ) ); |
| 105 | 83 | /* translators: %s is a file path. */ |
| 106 | - printf( __( 'The backup folder %s cannot be created or is not writable by the server, original images cannot be saved!', 'imagify' ), "<code>$backup_path</code>" ); | |
| 84 | + printf( esc_html__( 'The backup folder %s cannot be created or is not writable by the server, original images cannot be saved!', 'imagify' ), "<code>$backup_path</code>" ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 107 | 85 | ?> |
| 108 | 86 | </strong> |
| 109 | 87 | </p> |
| 110 | 88 | |
| 111 | 89 | <p class="imagify-setting-line"> |
| 112 | - <?php | |
| 113 | - $info = __( 'EXIF data is information stored in your pictures like shutter speed, exposure compensation, ISO, etc...', 'imagify' ); | |
| 114 | - $info .= ' <a href="' . esc_url( imagify_get_external_url( 'exif' ) ) . '" target="_blank">' . __( 'Learn more', 'imagify' ) . '</a><br/><br/>'; | |
| 115 | - $info .= __( 'If you are a photographer, you may be interested in this option if you are displaying info like the model of your camera on your pages. Also, keeping EXIF data can fix some colorimetric problems.', 'imagify' ); | |
| 116 | - | |
| 117 | - $settings->field_checkbox( array( | |
| 118 | - 'option_name' => 'exif', | |
| 119 | - 'label' => __( 'Keep all EXIF data from your images', 'imagify' ), | |
| 120 | - 'info' => $info, | |
| 121 | - ) ); | |
| 122 | - ?> | |
| 90 | + <?php | |
| 91 | + $settings->field_checkbox( | |
| 92 | + [ | |
| 93 | + 'option_name' => 'lossless', | |
| 94 | + 'label' => __( 'Lossless compression', 'imagify' ), | |
| 95 | + 'info' => __( 'By default, Imagify optimizes your images by using a smart compression to get the best compression rate with an optimal quality.', 'imagify' ) . '<br><br>' . __( 'If you are a photographer or focus on the quality of your images rather than the performance, you may be interested in this option to make sure not a single pixel looks different in the optimized image compared with the original.', 'imagify' ), | |
| 96 | + ] | |
| 97 | + ); | |
| 98 | + ?> | |
| 123 | 99 | </p> |
| 100 | + <?php do_action( 'imagify_settings_after_lossless' ); ?> | |
| 124 | 101 | </div> |
| 125 | 102 | </div> |
| 126 | 103 | |
| 127 | 104 | <?php if ( Imagify_Requirements::is_api_key_valid() ) { ?> |
| @@ -130,12 +107,12 @@ | ||
| 130 | 107 | </div> |
| 131 | 108 | <?php } ?> |
| 132 | 109 | </div> |
| 133 | 110 | |
| 134 | - <div class="imagify-settings-main-content<?php echo $hidden_class; ?>"> | |
| 111 | + <div class="imagify-settings-main-content<?php echo esc_attr( $hidden_class ); ?>"> | |
| 135 | 112 | |
| 136 | 113 | <div class="imagify-settings-section imagify-clear"> |
| 137 | - <h2 class="imagify-options-title"><?php _e( 'Optimization', 'imagify' ); ?></h2> | |
| 114 | + <h2 class="imagify-options-title"><?php esc_html_e( 'Optimization', 'imagify' ); ?></h2> | |
| 138 | 115 | <?php |
| 139 | 116 | $this->print_template( 'part-settings-webp' ); |
| 140 | 117 | $this->print_template( 'part-settings-library' ); |
| 141 | 118 | $this->print_template( 'part-settings-custom-folders' ); |
| @@ -142,31 +119,48 @@ | ||
| 142 | 119 | ?> |
| 143 | 120 | </div> |
| 144 | 121 | </div> |
| 145 | 122 | |
| 146 | - <div class="imagify-settings-main-content imagify-pb0<?php echo $hidden_class; ?>"> | |
| 147 | - <div class="imagify-settings-section imagify-clear"> | |
| 123 | + <div class="imagify-settings-main-content imagify-pb0<?php echo esc_attr( $hidden_class ); ?>"> | |
| 124 | + <?php if ( ! $data['hide_plugin_family'] ) : ?> | |
| 125 | + <div class="imagify-settings-section imagify-clear imagify-plugin-family-section"> | |
| 148 | 126 | <div> |
| 149 | - <h2 class="imagify-options-title"><?php _e( 'Display Options', 'imagify' ); ?></h2> | |
| 150 | - | |
| 151 | - <p class="imagify-options-subtitle"><?php _e( 'Show Toolbar Menu', 'imagify' ); ?></p> | |
| 152 | - | |
| 153 | - <div class="imagify-col"> | |
| 154 | - <p> | |
| 127 | + <h2 class="imagify-options-title"><?php esc_html_e( 'Our Plugins', 'imagify' ); ?></h2> | |
| 128 | + <p class="imagify-options-subtitle"><?php esc_html_e( 'Build better, faster, safer', 'imagify' ); ?></p> | |
| 129 | + <p class=""> | |
| 155 | 130 | <?php |
| 156 | - $settings->field_checkbox( array( | |
| 157 | - 'option_name' => 'admin_bar_menu', | |
| 158 | - 'label' => __( 'I want this awesome quick access menu on my Toolbar.', 'imagify' ), | |
| 159 | - ) ); | |
| 131 | + esc_html_e( 'Beyond Imagify, there\'s a whole family of plugins designed to help you build better, faster, and safer websites. Each one is crafted with our unique blend of expertise, simplicity, and outstanding support. Combine our plugins below to build incredible WordPress websites!', 'imagify' ); | |
| 160 | 132 | ?> |
| 161 | - </p> | |
| 133 | + </p> | |
| 134 | + <div class="imagify-plugin-family-cards"> | |
| 135 | + <?php foreach ( $data['plugin_family'] as $plugin_name => $plugin_data ) : ?> | |
| 136 | + <div class="imagify-plugin-family-col"> | |
| 137 | + <div class="imagify-card"> | |
| 138 | + <div class="imagify-card-header"> | |
| 139 | + <div class="imagify-card-logo"> | |
| 140 | + <img src="<?php echo esc_url( IMAGIFY_ASSETS_IMG_URL . $plugin_data['logo']['file'] ); ?>" loading="lazy" style="width: <?php echo esc_attr( $plugin_data['logo']['width'] ); ?>"> | |
| 141 | + </div> | |
| 142 | + <h4><?php echo esc_html( $plugin_data['title'] ); ?></h4> | |
| 143 | + </div> | |
| 144 | + <div class="imagify-card-body"> | |
| 145 | + <p> | |
| 146 | + <?php echo esc_html( $plugin_data['desc'] ); ?> | |
| 147 | + </p> | |
| 148 | + </div> | |
| 149 | + <div class="imagify-card-footer"> | |
| 150 | + <?php if ( '#' === $plugin_data['cta']['url'] ) : ?> | |
| 151 | + <span><?php echo esc_html( $plugin_data['cta']['text'] ); ?></span><span class="dashicons dashicons-yes"></span> | |
| 152 | + <?php else : ?> | |
| 153 | + <a href="<?php echo esc_url( $plugin_data['cta']['url'] ); ?>" class="imagify-card-btn imagify-btn-cta" <?php echo 'Get it Now' === $plugin_data['cta']['text'] ? 'target="_blank"' : ''; ?> rel="noopener"><?php echo esc_html( $plugin_data['cta']['text'] ); ?></a> | |
| 154 | + <a href="<?php echo esc_url( $plugin_data['link'] ); ?>" target="_blank" rel="noopener"><?php echo esc_html( 'Learn more' ); ?></a> | |
| 155 | + <?php endif; ?> | |
| 156 | + </div> | |
| 157 | + </div> | |
| 158 | + </div> | |
| 159 | + <?php | |
| 160 | + endforeach; | |
| 161 | + ?> | |
| 162 | 162 | </div> |
| 163 | - <div class="imagify-col"> | |
| 164 | - <p> | |
| 165 | - <img class="imagify-menu-bar-img" src="<?php echo esc_url( IMAGIFY_ASSETS_IMG_URL . 'imagify-menu-bar-' . $lang . '.jpg' ); ?>" width="273" height="239" alt=""> | |
| 166 | - </p> | |
| 167 | - </div> | |
| 168 | - | |
| 169 | 163 | <?php |
| 170 | 164 | /** |
| 171 | 165 | * List of partners affected by this option. |
| 172 | 166 | * For internal use only. |
| @@ -176,27 +170,28 @@ | ||
| 176 | 170 | * |
| 177 | 171 | * @param array $partners An array of partner names. |
| 178 | 172 | * @return array |
| 179 | 173 | */ |
| 180 | - $partners = apply_filters( 'imagify_deactivatable_partners', array() ); | |
| 174 | + $partners = apply_filters( 'imagify_deactivatable_partners', [] ); | |
| 181 | 175 | |
| 182 | 176 | if ( $partners ) { |
| 183 | 177 | ?> |
| 178 | + <h2 class="imagify-options-title"><?php esc_html_e( 'Partners', 'imagify' ); ?></h2> | |
| 184 | 179 | <p class="imagify-options-subtitle" id="imagify-partners-label"> |
| 185 | - <?php esc_html_e( 'Partners', 'imagify' ); ?> | |
| 186 | - | |
| 187 | 180 | <span class="imagify-info"> |
| 188 | 181 | <span class="dashicons dashicons-info"></span> |
| 189 | - <a href="#imagify-partners-info" class="imagify-modal-trigger"><?php _e( 'More info?', 'imagify' ); ?></a> | |
| 182 | + <a href="#imagify-partners-info" class="imagify-modal-trigger"><?php esc_html_e( 'More info?', 'imagify' ); ?></a> | |
| 190 | 183 | </span> |
| 191 | 184 | </p> |
| 192 | 185 | |
| 193 | 186 | <p> |
| 194 | 187 | <?php |
| 195 | - $settings->field_checkbox( array( | |
| 196 | - 'option_name' => 'partner_links', | |
| 197 | - 'label' => __( 'Display Partner Links', 'imagify' ), | |
| 198 | - ) ); | |
| 188 | + $settings->field_checkbox( | |
| 189 | + [ | |
| 190 | + 'option_name' => 'partner_links', | |
| 191 | + 'label' => __( 'Display Partner Links', 'imagify' ), | |
| 192 | + ] | |
| 193 | + ); | |
| 199 | 194 | ?> |
| 200 | 195 | </p> |
| 201 | 196 | <?php |
| 202 | 197 | } |
| @@ -202,11 +197,12 @@ | ||
| 202 | 197 | } |
| 203 | 198 | ?> |
| 204 | 199 | </div> |
| 205 | 200 | </div> |
| 206 | - | |
| 201 | + <?php endif; ?> | |
| 207 | 202 | <?php |
| 208 | 203 | if ( Imagify_Requirements::is_api_key_valid() ) { |
| 204 | + $this->print_template( 'part-settings-tools' ); | |
| 209 | 205 | $this->print_template( 'part-settings-footer' ); |
| 210 | 206 | } |
| 211 | 207 | ?> |
| 212 | 208 | </div> |
| @@ -218,9 +214,8 @@ | ||
| 218 | 214 | $this->print_template( 'part-rocket-ad' ); |
| 219 | 215 | $this->print_template( 'modal-settings-infos' ); |
| 220 | 216 | $this->print_template( 'modal-settings-partners-infos' ); |
| 221 | 217 | $this->print_template( 'modal-settings-visual-comparison' ); |
| 222 | - $this->print_template( 'modal-payment' ); | |
| 223 | 218 | ?> |
| 224 | 219 | |
| 225 | 220 | </div> |
| 226 | -<?php | |
| 221 | + | |