CMS Project Sync
This commit is contained in:
+336
@@ -0,0 +1,336 @@
|
||||
<?php
|
||||
/**
|
||||
* Bulk compress page.
|
||||
*
|
||||
* @since 2.9.0
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Summary_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use Smush\Core\Array_Utils;
|
||||
use Smush\Core\Core;
|
||||
use Smush\Core\Directory\Directory_UI_Controller;
|
||||
use Smush\Core\Hub_Connector;
|
||||
use Smush\Core\Media\Media_Item_Query;
|
||||
use Smush\Core\Media_Library\Background_Media_Library_Scanner;
|
||||
use Smush\Core\Membership\Membership;
|
||||
use Smush\Core\Modules\Background\Background_Pre_Flight_Controller;
|
||||
use Smush\Core\Settings;
|
||||
use Smush\Core\Smush\Smush_Settings_UI_Controller;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Bulk
|
||||
*/
|
||||
class Bulk extends Abstract_Summary_Page implements Interface_Page {
|
||||
/**
|
||||
* Function triggered when the page is loaded before render any content.
|
||||
*/
|
||||
public function on_load() {
|
||||
parent::on_load();
|
||||
|
||||
Core::should_continue_smush( true );
|
||||
add_action( 'smush_setting_column_tag', array( $this, 'add_pro_tag' ) );
|
||||
|
||||
$smush_settings_ui_controller = new Smush_Settings_UI_Controller();
|
||||
$smush_settings_ui_controller->init();
|
||||
$directory_ui_controller = new Directory_UI_Controller();
|
||||
$directory_ui_controller->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the bulk smush page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render() {
|
||||
|
||||
if ( Hub_Connector::should_render() ) {
|
||||
Hub_Connector::render();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Membership::get_instance()->is_api_hub_access_required() ) {
|
||||
$this->open_page_wrapper();
|
||||
$this->render_modals();
|
||||
$this->render_inner_content();
|
||||
$this->close_page_wrapper();
|
||||
return;
|
||||
}
|
||||
|
||||
parent::render();
|
||||
}
|
||||
|
||||
public function enqueue_scripts( $hook ) {
|
||||
parent::enqueue_scripts( $hook );
|
||||
|
||||
$this->enqueue_lib_scanner_scripts();
|
||||
}
|
||||
|
||||
protected function enqueue_lib_scanner_scripts() {
|
||||
wp_enqueue_script(
|
||||
'smush-library-scanner',
|
||||
WP_SMUSH_URL . 'app/assets/js/smush-library-scanner.min.js',
|
||||
array( 'wp-i18n' ),
|
||||
WP_SMUSH_VERSION,
|
||||
true
|
||||
);
|
||||
|
||||
wp_localize_script(
|
||||
'smush-library-scanner',
|
||||
'mediaLibraryScan',
|
||||
array(
|
||||
'nonce' => wp_create_nonce( 'wp_smush_media_library_scanner' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function render_hub_connection_prompt() {
|
||||
$media_item_query = new Media_Item_Query();
|
||||
$attachment_count = (int) $media_item_query->get_image_attachment_count();
|
||||
$smushed_count = (int) $media_item_query->get_smushed_count();
|
||||
$remaining_count = $attachment_count - $smushed_count;
|
||||
|
||||
$this->view(
|
||||
'bulk/hub-connect',
|
||||
array(
|
||||
'images_count' => $remaining_count,
|
||||
'connect_url' => \Smush\Core\Hub_Connector::get_connect_site_url( 'smush-bulk', 'smush_bulk_smush_connect' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
|
||||
if ( Membership::get_instance()->is_api_hub_access_required() ) {
|
||||
$this->add_meta_box(
|
||||
'smush-hub-connect',
|
||||
'',
|
||||
array( $this, 'render_hub_connection_prompt' ),
|
||||
null,
|
||||
null,
|
||||
'main',
|
||||
array(
|
||||
'box_content_class' => false,
|
||||
)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
$this->add_meta_box(
|
||||
'ajax-bulk-smush-in-progressing-notice',
|
||||
null,
|
||||
array( $this, 'ajax_bulk_smush_in_progressing_notice' ),
|
||||
null,
|
||||
null,
|
||||
'main',
|
||||
array(
|
||||
'box_class' => 'sui-box ajax-bulk-smush-in-progressing-notice sui-hidden',
|
||||
'box_content_class' => false,
|
||||
)
|
||||
);
|
||||
|
||||
$background_health = Background_Pre_Flight_Controller::get_instance();
|
||||
if ( ! $background_health->is_cron_healthy() ) {
|
||||
$this->add_meta_box(
|
||||
'cron-disabled-notice',
|
||||
null,
|
||||
array( $this, 'cron_disabled_notice_meta_box' ),
|
||||
null,
|
||||
null,
|
||||
'main',
|
||||
array(
|
||||
'box_class' => 'sui-box wp-smush-cron-disabled-notice-box',
|
||||
'box_content_class' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_meta_box(
|
||||
'recheck-images-notice',
|
||||
null,
|
||||
array( $this, 'recheck_images_notice_meta_box' ),
|
||||
null,
|
||||
null,
|
||||
'main',
|
||||
array(
|
||||
'box_class' => 'sui-box wp-smush-recheck-images-notice-box sui-hidden',
|
||||
'box_content_class' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
parent::register_meta_boxes();
|
||||
|
||||
if ( ! is_network_admin() ) {
|
||||
$this->add_meta_box(
|
||||
'bulk',
|
||||
__( 'Bulk Smush', 'wp-smushit' ),
|
||||
array( $this, 'bulk_smush_metabox' ),
|
||||
null,
|
||||
null,
|
||||
'main',
|
||||
array(
|
||||
'box_class' => 'sui-box bulk-smush-wrapper',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_meta_box(
|
||||
'bulk-settings',
|
||||
__( 'Settings', 'wp-smushit' ),
|
||||
array( $this, 'bulk_settings_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'main',
|
||||
array(
|
||||
'box_class' => 'sui-box smush-settings-wrapper',
|
||||
)
|
||||
);
|
||||
|
||||
$restore_ids = WP_Smush::get_instance()->core()->mod->backup->get_attachments_with_backups();
|
||||
$this->modals['restore-images'] = array(
|
||||
'restore_image_count' => count( $restore_ids ),
|
||||
);
|
||||
$this->modals['disable-backup-original-image'] = array();
|
||||
}
|
||||
|
||||
/**************************
|
||||
* META BOXES
|
||||
*/
|
||||
|
||||
/**
|
||||
* Common footer meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function common_meta_box_footer() {
|
||||
$this->view( 'meta-box-footer', array(), 'common' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk smush meta box.
|
||||
*
|
||||
* Container box to handle bulk smush actions. Show progress bars,
|
||||
* bulk smush action buttons etc. in this box.
|
||||
*/
|
||||
public function bulk_smush_metabox() {
|
||||
$core = WP_Smush::get_instance()->core();
|
||||
$global_stats = $core->get_global_stats();
|
||||
$array_utils = new Array_Utils();
|
||||
|
||||
$bulk_upgrade_url = $this->get_utm_link(
|
||||
array(
|
||||
'utm_campaign' => 'smush_bulk_smush_complete_global',
|
||||
)
|
||||
);
|
||||
$in_progress_upsell_url = $this->get_utm_link(
|
||||
array(
|
||||
'utm_campaign' => 'smush_bulk_smush_progress_BO',
|
||||
)
|
||||
);
|
||||
$upsell_cdn_url = $this->get_utm_link(
|
||||
array(
|
||||
'utm_campaign' => 'smush_bulksmush_cdn',
|
||||
)
|
||||
);
|
||||
$upsell_text = sprintf(
|
||||
/* translators: 1: Open the link, 2: Close the link */
|
||||
__( 'Want to close this tab? Smush Pro lets you optimize in the background — %1$sGet Smush Pro!%2$s', 'wp-smushit' ),
|
||||
'<a class="smush-upsell-link" target="_blank" href="' . esc_url( $in_progress_upsell_url ) . '">',
|
||||
'</a>'
|
||||
);
|
||||
$in_processing_notice = sprintf(
|
||||
/* translators: %s: Upsell text */
|
||||
__( 'Bulk Smush is currently running. Please keep this page open until the process is complete. %s', 'wp-smushit' ),
|
||||
$upsell_text
|
||||
);
|
||||
|
||||
$this->view(
|
||||
'bulk/meta-box',
|
||||
array(
|
||||
'core' => $core,
|
||||
'unsmushed_count' => (int) $array_utils->get_array_value( $global_stats, 'count_unsmushed' ),
|
||||
'resmush_count' => (int) $array_utils->get_array_value( $global_stats, 'count_resmush' ),
|
||||
'remaining_count' => (int) $array_utils->get_array_value( $global_stats, 'remaining_count' ),
|
||||
'total_count' => (int) $array_utils->get_array_value( $global_stats, 'count_total' ),
|
||||
'bulk_upgrade_url' => $bulk_upgrade_url,
|
||||
'upsell_cdn_url' => $upsell_cdn_url,
|
||||
'in_processing_notice' => $in_processing_notice,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings meta box.
|
||||
*
|
||||
* Free and pro version settings are shown in same section. For free users, pro settings won't be shown.
|
||||
* To print full size smush, resize and backup in group, we hook at `smush_setting_column_right_end`.
|
||||
*/
|
||||
public function bulk_settings_meta_box() {
|
||||
$fields = $this->settings->get_bulk_fields();
|
||||
|
||||
// Remove backups setting, as it's added separately.
|
||||
$key = array_search( 'backup', $fields, true );
|
||||
if ( false !== $key ) {
|
||||
unset( $fields[ $key ] );
|
||||
}
|
||||
|
||||
// Remove no_scale setting, as it's added separately.
|
||||
$key = array_search( 'no_scale', $fields, true );
|
||||
if ( false !== $key ) {
|
||||
unset( $fields[ $key ] );
|
||||
}
|
||||
|
||||
$this->view(
|
||||
'bulk-settings/meta-box',
|
||||
array(
|
||||
'basic_features' => Settings::$basic_features,
|
||||
'cdn_enabled' => $this->settings->get( 'cdn' ),
|
||||
'grouped_settings' => $fields,
|
||||
'settings' => $this->settings->get(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function add_pro_tag( $name ) {
|
||||
$settings = Settings::get_instance();
|
||||
if ( ! $settings->is_pro_field( $name ) ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<span class="sui-tag sui-tag-pro"><?php esc_html_e( 'Pro', 'wp-smushit' ); ?></span>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function recheck_images_notice_meta_box() {
|
||||
$this->view(
|
||||
'recheck-images-notice',
|
||||
array(),
|
||||
'common'
|
||||
);
|
||||
}
|
||||
|
||||
public function ajax_bulk_smush_in_progressing_notice() {
|
||||
$this->view(
|
||||
'ajax-bulk-smush-in-progressing-notice',
|
||||
array(),
|
||||
'views/bulk'
|
||||
);
|
||||
}
|
||||
|
||||
public function cron_disabled_notice_meta_box() {
|
||||
$this->view( 'bulk/cron-disabled-notice' );
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* CDN page.
|
||||
*
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Summary_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use Smush\Core\CDN\CDN_Helper;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class CDN
|
||||
*/
|
||||
class CDN extends Abstract_Summary_Page implements Interface_Page {
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
parent::register_meta_boxes();
|
||||
|
||||
$this->add_meta_box(
|
||||
'cdn/upsell',
|
||||
__( 'CDN', 'wp-smushit' )
|
||||
);
|
||||
}
|
||||
}
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
<?php
|
||||
/**
|
||||
* Dashboard page class: Dashboard extends Abstract_Page.
|
||||
*
|
||||
* @since 3.8.6
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Summary_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use Smush\Core\Array_Utils;
|
||||
use Smush\Core\CDN\CDN_Helper;
|
||||
use Smush\Core\Settings;
|
||||
use Smush\Core\Media_Library\Background_Media_Library_Scanner;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Dashboard
|
||||
*/
|
||||
class Dashboard extends Abstract_Summary_Page implements Interface_Page {
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $hook Hook from where the call is made.
|
||||
*/
|
||||
public function enqueue_scripts( $hook ) {
|
||||
// Scripts for Configs.
|
||||
$this->enqueue_configs_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
if ( ! is_multisite() || ( is_multisite() && ! is_network_admin() ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/summary',
|
||||
null,
|
||||
array( $this, 'summary_meta_box' ),
|
||||
null,
|
||||
null,
|
||||
'summary',
|
||||
array(
|
||||
'box_class' => 'sui-box sui-summary sui-summary-smush-metabox',
|
||||
'box_content_class' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta boxes on the left side.
|
||||
*/
|
||||
|
||||
if ( self::should_render( 'bulk' ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/bulk',
|
||||
__( 'Bulk Smush', 'wp-smushit' ),
|
||||
array( $this, 'bulk_compress_meta_box' ),
|
||||
array( $this, 'bulk_meta_box_header' ),
|
||||
null,
|
||||
'box-dashboard-left'
|
||||
);
|
||||
}
|
||||
|
||||
if ( self::should_render( 'integrations' ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/integrations',
|
||||
__( 'Integrations', 'wp-smushit' ),
|
||||
array( $this, 'integrations_meta_box' ),
|
||||
null,
|
||||
null,
|
||||
'box-dashboard-left'
|
||||
);
|
||||
}
|
||||
|
||||
if ( self::should_render( 'cdn' ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/cdn',
|
||||
__( 'CDN', 'wp-smushit' ),
|
||||
array( $this, 'cdn_meta_box' ),
|
||||
array( $this, 'cdn_meta_box_header' ),
|
||||
null,
|
||||
'box-dashboard-left'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Meta boxes on the right side.
|
||||
*/
|
||||
$this->add_meta_box(
|
||||
'dashboard/upsell/upsell',
|
||||
__( 'Smush Pro', 'wp-smushit' ),
|
||||
array( $this, 'upsell_meta_box' ),
|
||||
array( $this, 'upsell_meta_box_header' ),
|
||||
null,
|
||||
'box-dashboard-right'
|
||||
);
|
||||
|
||||
if ( self::should_render( Settings::get_lazy_preload_module_name() ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/lazy-preload',
|
||||
__( 'Lazy Load & Preload', 'wp-smushit' ),
|
||||
array( $this, 'lazy_preload_meta_box' ),
|
||||
null,
|
||||
null,
|
||||
'box-dashboard-right'
|
||||
);
|
||||
}
|
||||
|
||||
if ( self::should_render( 'next-gen' ) ) {
|
||||
$this->add_meta_box(
|
||||
'dashboard/next-gen',
|
||||
__( 'Next-Gen Formats', 'wp-smushit' ),
|
||||
array( $this, 'local_next_gen_meta_box' ),
|
||||
array( $this, 'local_next_gen_meta_box_header' ),
|
||||
null,
|
||||
'box-dashboard-right'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Summary meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function summary_meta_box() {
|
||||
$upsell_url_cdn = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'smush',
|
||||
'utm_medium' => 'plugin',
|
||||
'utm_campaign' => 'summary_cdn',
|
||||
),
|
||||
$this->upgrade_url
|
||||
);
|
||||
|
||||
$core = WP_Smush::get_instance()->core();
|
||||
$array_utils = new Array_Utils();
|
||||
$global_stats = $core->get_global_stats();
|
||||
$args = array(
|
||||
'human_bytes' => $array_utils->get_array_value( $global_stats, 'human_bytes' ),
|
||||
'cdn_status' => CDN_Helper::get_instance()->get_cdn_status_string(),
|
||||
'is_cdn' => $this->settings->get( 'cdn' ),
|
||||
'is_lazy_load' => $this->settings->get( 'lazy_load' ),
|
||||
'resize_count' => $array_utils->get_array_value( $global_stats, 'count_resize' ),
|
||||
'total_optimized' => $array_utils->get_array_value( $global_stats, 'count_images' ),
|
||||
'stats_percent' => $array_utils->get_array_value( $global_stats, 'savings_percent' ),
|
||||
'upsell_url_cdn' => $upsell_url_cdn,
|
||||
'percent_grade' => $array_utils->get_array_value( $global_stats, 'percent_grade' ),
|
||||
'percent_metric' => $array_utils->get_array_value( $global_stats, 'percent_metric' ),
|
||||
'percent_optimized' => $array_utils->get_array_value( $global_stats, 'percent_optimized' ),
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/summary-meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk compress meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function bulk_compress_meta_box() {
|
||||
$array_utils = new Array_Utils();
|
||||
$core = WP_Smush::get_instance()->core();
|
||||
$global_stats = $core->get_global_stats();
|
||||
$upsell_url = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'smush',
|
||||
'utm_medium' => 'plugin',
|
||||
'utm_campaign' => 'dashboard_bulk_smush',
|
||||
),
|
||||
$this->upgrade_url
|
||||
);
|
||||
|
||||
$background_scan_status = Background_Media_Library_Scanner::get_instance()->get_background_process()->get_status();
|
||||
|
||||
$args = array(
|
||||
'total_count' => (int) $array_utils->get_array_value( $global_stats, 'count_total' ),
|
||||
'uncompressed' => (int) $array_utils->get_array_value( $global_stats, 'remaining_count' ),
|
||||
'upsell_url' => $upsell_url,
|
||||
'scan_background_process_dead' => $background_scan_status->is_dead(),
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/bulk/meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrations meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function integrations_meta_box() {
|
||||
$upsell_url = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'smush',
|
||||
'utm_medium' => 'plugin',
|
||||
'utm_campaign' => 'dashboard_integrations',
|
||||
),
|
||||
$this->upgrade_url
|
||||
);
|
||||
|
||||
$integration_fields = $this->settings->get_integrations_fields();
|
||||
|
||||
$key = array_search( 'js_builder', $integration_fields, true );
|
||||
if ( $key ) {
|
||||
unset( $integration_fields[ $key ] );
|
||||
}
|
||||
|
||||
$args = array(
|
||||
'basic_features' => Settings::$basic_features,
|
||||
'fields' => $integration_fields,
|
||||
'settings' => $this->settings->get(),
|
||||
'upsell_url' => $upsell_url,
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/integrations-meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Next-Gen Formats meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function local_next_gen_meta_box() {
|
||||
$this->view( 'dashboard/next-gen/meta-box' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Next-Gen Formats meta box footer.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function local_next_gen_meta_box_header() {
|
||||
$this->view( 'dashboard/next-gen/meta-box-header' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Toole meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function tools_meta_box() {
|
||||
$is_resize_detection = $this->settings->get( 'detection' );
|
||||
$this->view( 'dashboard/tools-meta-box', compact( 'is_resize_detection' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Directory compress meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function directory_compress_meta_box() {
|
||||
$images = WP_Smush::get_instance()->core()->mod->dir->get_image_errors();
|
||||
|
||||
$args = array(
|
||||
'images' => array_slice( $images, 0, 4 ),
|
||||
'errors' => WP_Smush::get_instance()->core()->mod->dir->get_image_errors_count(),
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/directory-meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upsell meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function upsell_meta_box() {
|
||||
$upsell_url = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'smush',
|
||||
'utm_medium' => 'plugin',
|
||||
'utm_campaign' => 'smush-dashboard-upsell',
|
||||
),
|
||||
$this->upgrade_url
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/upsell/meta-box', compact( 'upsell_url' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Upsell meta box header.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function upsell_meta_box_header() {
|
||||
$title = esc_html__( 'Smush Pro', 'wp-smushit' );
|
||||
$this->view( 'dashboard/upsell/meta-box-header', compact( 'title' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy load meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function lazy_preload_meta_box() {
|
||||
$args = array(
|
||||
'is_lazy_load_active' => $this->settings->get( 'lazy_load' ),
|
||||
'is_preload_active' => $this->settings->is_lcp_preload_enabled(),
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/lazy-load-meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* CDN meta box.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function cdn_meta_box() {
|
||||
$upsell_url = add_query_arg(
|
||||
array(
|
||||
'utm_source' => 'smush',
|
||||
'utm_medium' => 'plugin',
|
||||
'utm_campaign' => 'smush-dashboard-cdn-upsell',
|
||||
),
|
||||
$this->upgrade_url
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'cdn_status' => CDN_Helper::get_instance()->get_cdn_status_string(),
|
||||
'upsell_url' => $upsell_url,
|
||||
);
|
||||
|
||||
$this->view( 'dashboard/cdn/meta-box', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* CDN meta box header.
|
||||
*
|
||||
* @since 3.8.6
|
||||
*/
|
||||
public function cdn_meta_box_header() {
|
||||
$title = esc_html__( 'CDN', 'wp-smushit' );
|
||||
$this->view( 'dashboard/cdn/meta-box-header', compact( 'title' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk meta box header.
|
||||
*
|
||||
* @since 3.22.0
|
||||
*/
|
||||
public function bulk_meta_box_header() {
|
||||
$title = esc_html__( 'Bulk Smush', 'wp-smushit' );
|
||||
$this->view( 'dashboard/bulk/meta-box-header', compact( 'title' ) );
|
||||
}
|
||||
}
|
||||
+91
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Integrations page.
|
||||
*
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use Smush\Core\Settings;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Integrations
|
||||
*/
|
||||
class Integrations extends Abstract_Page implements Interface_Page {
|
||||
/**
|
||||
* Function triggered when the page is loaded before render any content.
|
||||
*/
|
||||
public function on_load() {
|
||||
add_action( 'smush_setting_column_right_inside', array( $this, 'settings_desc' ), 10, 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
$class = 'smush-integrations-wrapper';
|
||||
|
||||
$this->add_meta_box(
|
||||
'integrations',
|
||||
__( 'Integrations', 'wp-smushit' ),
|
||||
array( $this, 'integrations_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'main',
|
||||
array(
|
||||
'box_class' => "sui-box {$class}",
|
||||
'box_content_class' => 'sui-box-body sui-upsell-items',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common footer meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function common_meta_box_footer() {
|
||||
$this->view( 'meta-box-footer', array(), 'common' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrations meta box.
|
||||
*
|
||||
* Free and pro version settings are shown in same section. For free users, pro settings won't be shown.
|
||||
* To print full size smush, resize and backup in group, we hook at `smush_setting_column_right_end`.
|
||||
*/
|
||||
public function integrations_meta_box() {
|
||||
$this->view(
|
||||
'integrations/meta-box',
|
||||
array(
|
||||
'basic_features' => Settings::$basic_features,
|
||||
'integration_group' => $this->settings->get_integrations_fields(),
|
||||
'settings' => $this->settings->get(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show additional descriptions for settings.
|
||||
*
|
||||
* @param string $setting_key Setting key.
|
||||
*/
|
||||
public function settings_desc( $setting_key = '' ) {
|
||||
if ( empty( $setting_key ) || 's3' !== $setting_key ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<span class="sui-description sui-toggle-description" id="s3-desc">
|
||||
<?php esc_html_e( 'Note: For this process to happen automatically you need automatic smushing enabled.', 'wp-smushit' ); ?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Lazy load & Preload page.
|
||||
*
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Summary_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Lazy_Preload
|
||||
*/
|
||||
class Lazy_Preload extends Abstract_Summary_Page implements Interface_Page {
|
||||
|
||||
public function on_load() {
|
||||
parent::on_load();
|
||||
// Init the tabs.
|
||||
$this->tabs = array(
|
||||
'lazy_load' => __( 'Lazy Load', 'wp-smushit' ),
|
||||
'preload' => __( 'Preload', 'wp-smushit' ),
|
||||
);
|
||||
|
||||
add_action( 'wp_smush_admin_after_tab_smush-lazy-preload', array( $this, 'lazy_preload_add_new_tag' ) );
|
||||
add_action( 'wp_smush_admin_page_before_sidenav', array( $this, 'render_summary_meta_box' ) );
|
||||
}
|
||||
|
||||
public function render_summary_meta_box() {
|
||||
$this->do_meta_boxes( 'main' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
parent::register_meta_boxes();
|
||||
|
||||
$this->add_meta_box(
|
||||
'preload',
|
||||
__( 'Preload Critical Images', 'wp-smushit' ),
|
||||
array( $this, 'preload_meta_box' ),
|
||||
array( $this, 'preload_header_meta_box' ),
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'preload',
|
||||
array(
|
||||
'box_class' => 'sui-box sui-no-padding',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! $this->settings->get( 'lazy_load' ) ) {
|
||||
$this->add_meta_box(
|
||||
'lazyload/disabled',
|
||||
__( 'Lazy Load', 'wp-smushit' ),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
'lazy_load',
|
||||
array(
|
||||
'box_class' => 'sui-box sui-message sui-no-padding',
|
||||
)
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->add_meta_box(
|
||||
'lazyload',
|
||||
__( 'Lazy Load', 'wp-smushit' ),
|
||||
array( $this, 'lazy_load_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'lazy_load'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common footer meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function common_meta_box_footer() {
|
||||
$current_tab = $this->get_current_tab();
|
||||
$is_submit_enabled = 'lazy_load' === $current_tab;
|
||||
$this->view(
|
||||
'meta-box-footer',
|
||||
array(
|
||||
'is_submit_enabled' => $is_submit_enabled,
|
||||
),
|
||||
'common'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy loading meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function lazy_load_meta_box() {
|
||||
$this->view(
|
||||
'lazyload/meta-box',
|
||||
array(
|
||||
'conflicts' => get_transient( 'wp-smush-conflict_check' ),
|
||||
'settings' => $this->settings->get_setting( 'wp-smush-lazy_load' ),
|
||||
'cpts' => get_post_types( // custom post types.
|
||||
array(
|
||||
'public' => true,
|
||||
'_builtin' => false,
|
||||
),
|
||||
'objects'
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function preload_meta_box() {
|
||||
$this->view(
|
||||
'preload/meta-box',
|
||||
array(
|
||||
'lcp_preload_enabled' => false,
|
||||
'preload_settings' => array(),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function lazy_preload_add_new_tag( $tab_id ) {
|
||||
if ( 'preload' !== $tab_id ) {
|
||||
return $this->lazyload_add_new_tag();
|
||||
}
|
||||
|
||||
echo '<span class="sui-tag sui-tag-pro" style="right:11px; top:11px">' . esc_html__( 'Pro', 'wp-smushit' ) . '</span>';
|
||||
}
|
||||
|
||||
public function lazyload_add_new_tag() {
|
||||
if ( ! self::should_show_new_feature_hotspot() ) {
|
||||
return;
|
||||
}
|
||||
echo '<span class="smush-new-feature-dot" style="transform: translate(-8px, -21px);"></span>';
|
||||
}
|
||||
|
||||
public function preload_header_meta_box() {
|
||||
$this->view(
|
||||
'preload/meta-box-header'
|
||||
);
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Local WebP page.
|
||||
*
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Summary_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use Smush\Core\Webp\Webp_Configuration;
|
||||
use Smush\Core\Next_Gen\Next_Gen_Manager;
|
||||
use Smush\Core\Next_Gen\Next_Gen_Settings_Ui_Controller;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Next_Gen
|
||||
*/
|
||||
class Next_Gen extends Abstract_Summary_Page implements Interface_Page {
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
parent::register_meta_boxes();
|
||||
|
||||
$this->add_meta_box(
|
||||
'next-gen/upsell',
|
||||
__( 'Next-Gen Formats', 'wp-smushit' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the wizard should be displayed.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function is_wizard() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
/**
|
||||
* Settings page.
|
||||
*
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Page;
|
||||
use Smush\App\Interface_Page;
|
||||
use WP_Smush;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Settings
|
||||
*/
|
||||
class Settings extends Abstract_Page implements Interface_Page {
|
||||
/**
|
||||
* Function triggered when the page is loaded before render any content.
|
||||
*/
|
||||
public function on_load() {
|
||||
// Init the tabs.
|
||||
$this->tabs = apply_filters(
|
||||
'smush_setting_tabs',
|
||||
array(
|
||||
'general' => __( 'General', 'wp-smushit' ),
|
||||
'configs' => __( 'Configs', 'wp-smushit' ),
|
||||
'permissions' => __( 'Permissions', 'wp-smushit' ),
|
||||
'data' => __( 'Data & Settings', 'wp-smushit' ),
|
||||
'accessibility' => __( 'Accessibility', 'wp-smushit' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Disabled on all subsites.
|
||||
if ( ! is_multisite() || ! is_network_admin() ) {
|
||||
unset( $this->tabs['permissions'] );
|
||||
}
|
||||
|
||||
add_action( 'smush_setting_column_right_inside', array( $this, 'usage_settings' ), 25, 2 );
|
||||
add_action( 'wp_smush_render_general_setting_rows', array( $this, 'render_tracking_settings' ), 40 );
|
||||
add_action( 'wp_smush_render_general_setting_rows', array( $this, 'render_image_resize_detection_settings' ), 10 );
|
||||
add_action( 'smush_setting_column_right_inside', array( $this, 'detection_settings' ), 25, 2 );
|
||||
add_action( 'wp_smush_render_general_setting_rows', array( $this, 'render_translations_settings' ), 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue scripts.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param string $hook Hook from where the call is made.
|
||||
*/
|
||||
public function enqueue_scripts( $hook ) {
|
||||
// Scripts for Configs.
|
||||
$this->enqueue_configs_scripts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register meta boxes.
|
||||
*/
|
||||
public function register_meta_boxes() {
|
||||
$this->add_meta_box(
|
||||
'settings/general',
|
||||
__( 'General', 'wp-smushit' ),
|
||||
array( $this, 'general_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'general'
|
||||
);
|
||||
|
||||
if ( is_multisite() && is_network_admin() ) {
|
||||
$this->add_meta_box(
|
||||
'settings/permissions',
|
||||
__( 'Permissions', 'wp-smushit' ),
|
||||
array( $this, 'permissions_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'permissions'
|
||||
);
|
||||
}
|
||||
|
||||
$this->add_meta_box(
|
||||
'settings/data',
|
||||
__( 'Data & Settings', 'wp-smushit' ),
|
||||
array( $this, 'data_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'data'
|
||||
);
|
||||
|
||||
$this->add_meta_box(
|
||||
'settings/accessibility',
|
||||
__( 'Accessibility', 'wp-smushit' ),
|
||||
array( $this, 'accessibility_meta_box' ),
|
||||
null,
|
||||
array( $this, 'common_meta_box_footer' ),
|
||||
'accessibility'
|
||||
);
|
||||
|
||||
if ( 'data' === $this->get_current_tab() ) {
|
||||
$this->modals['reset-settings'] = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a description in Settings - Usage Tracking.
|
||||
*
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @param string $name Setting name.
|
||||
*/
|
||||
public function usage_settings( $name ) {
|
||||
// Add only to full size settings.
|
||||
if ( 'usage' !== $name ) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
|
||||
<span class="sui-description sui-toggle-description">
|
||||
<?php
|
||||
esc_html_e( 'Note: Usage tracking is completely anonymous. We are only tracking what features you are/aren’t using to make our feature decisions more informed.', 'wp-smushit' );
|
||||
?>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a description in Settings - Image Resize Detection.
|
||||
*
|
||||
* @since 3.2.1
|
||||
*
|
||||
* @param string $name Setting name.
|
||||
*/
|
||||
public function detection_settings( $name ) {
|
||||
// Add only to full size settings.
|
||||
if ( 'detection' !== $name ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$detection_enabled = $this->settings->get( 'detection' );
|
||||
$is_lazyload_enabled = $this->settings->is_lazyload_active();
|
||||
$is_auto_resize_enabled = $this->settings->is_auto_resizing_active();
|
||||
$notice_css_class = '';
|
||||
|
||||
if ( $is_lazyload_enabled && $is_auto_resize_enabled ) {
|
||||
$notice_message = esc_html(
|
||||
$this->whitelabel->whitelabel_string(
|
||||
__( 'Images served via the Automatic Resizing feature will be skipped.', 'wp-smushit' )
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$notice_css_class = 'sui-notice-info';
|
||||
$notice_message = sprintf(
|
||||
/* translators: %1$s: opening anchor tag, %2$s: closing anchor tag */
|
||||
esc_html__(
|
||||
'Incorrect image size highlighting is active. %1$sView the frontend%2$s of your website to see if any images aren\'t the correct size for their containers.',
|
||||
'wp-smushit'
|
||||
),
|
||||
'<a href="' . esc_url( home_url() ) . '" target="_blank" rel="noopener">',
|
||||
'</a>'
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<span class="sui-description sui-toggle-description">
|
||||
<?php esc_html_e( 'Note: The highlighting will only be visible to administrators – visitors won\'t see the highlighting.', 'wp-smushit' ); ?>
|
||||
|
||||
<div class="sui-notice <?php echo esc_attr( $notice_css_class ); ?> smush-highlighting-notice" <?php echo $detection_enabled ? '' : 'style="display: none;"'; ?>>
|
||||
<div class="sui-notice-content">
|
||||
<div class="sui-notice-message">
|
||||
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
|
||||
<p>
|
||||
<?php echo wp_kses_post( $notice_message ); ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php // Warning notice (shown when detection is checked but not saved). ?>
|
||||
<div class="sui-notice sui-notice-warning smush-highlighting-warning" style="display: none;">
|
||||
<div class="sui-notice-content">
|
||||
<div class="sui-notice-message">
|
||||
<i class="sui-notice-icon sui-icon-info sui-md" aria-hidden="true"></i>
|
||||
<p><?php esc_html_e( 'Almost there! To finish activating this feature you must save your settings.', 'wp-smushit' ); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Common footer meta box.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function common_meta_box_footer() {
|
||||
$this->view( 'meta-box-footer', array(), 'common' );
|
||||
}
|
||||
|
||||
/**
|
||||
* General settings meta box.
|
||||
*/
|
||||
public function general_meta_box() {
|
||||
$this->view( 'settings/general-meta-box' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Permissions meta box.
|
||||
*/
|
||||
public function permissions_meta_box() {
|
||||
$this->view(
|
||||
'settings/permissions-meta-box',
|
||||
array(
|
||||
'networkwide' => get_site_option( 'wp-smush-networkwide' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data & Settings meta box.
|
||||
*/
|
||||
public function data_meta_box() {
|
||||
$this->view(
|
||||
'settings/data-meta-box',
|
||||
array(
|
||||
'keep_data' => (bool) $this->settings->get( 'keep_data' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accessibility meta box.
|
||||
*/
|
||||
public function accessibility_meta_box() {
|
||||
$this->view(
|
||||
'settings/accessibility-meta-box',
|
||||
array(
|
||||
'accessible_colors' => (bool) $this->settings->get( 'accessible_colors' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render image resize detection settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_image_resize_detection_settings() {
|
||||
do_action( 'wp_smush_render_setting_row', 'detection', $this->settings->get( 'detection' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Render translations settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_translations_settings() {
|
||||
$translation_link = 'https://translate.wordpress.org/projects/wp-plugins/wp-smushit';
|
||||
|
||||
$site_locale = get_locale();
|
||||
|
||||
if ( 'en' === $site_locale || 'en_US' === $site_locale ) {
|
||||
$site_language = 'English';
|
||||
} else {
|
||||
require_once ABSPATH . 'wp-admin/includes/translation-install.php';
|
||||
$translations = wp_get_available_translations();
|
||||
$site_language = isset( $translations[ $site_locale ] ) ? $translations[ $site_locale ]['native_name'] : __( 'Error detecting language', 'wp-smushit' );
|
||||
}
|
||||
?>
|
||||
<div class="sui-box-settings-row" id="general-translations-settings-row">
|
||||
<div class="sui-box-settings-col-1">
|
||||
<span class="sui-settings-label "><?php esc_html_e( 'Translations', 'wp-smushit' ); ?></span>
|
||||
<span class="sui-description">
|
||||
<?php
|
||||
printf( /* translators: %1$s: opening a tag, %2$s: closing a tag */
|
||||
esc_html__( 'By default, Smush will use the language you’d set in your %1$sWordPress Admin Settings%2$s if a matching translation is available.', 'wp-smushit' ),
|
||||
'<a href="' . esc_html( admin_url( 'options-general.php' ) ) . '">',
|
||||
'</a>'
|
||||
);
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
<div class="sui-box-settings-col-2">
|
||||
<div class="sui-form-field">
|
||||
<label for="language-input" class="sui-label">
|
||||
<?php esc_html_e( 'Active Translation', 'wp-smushit' ); ?>
|
||||
</label>
|
||||
<input type="text" id="language-input" class="sui-form-control" disabled="disabled" placeholder="<?php echo esc_attr( $site_language ); ?>">
|
||||
<span class="sui-description">
|
||||
<?php
|
||||
if ( ! apply_filters( 'wpmudev_branding_hide_doc_link', false ) ) {
|
||||
printf(
|
||||
/* translators: %1$s: opening a tag, %2$s: closing a tag */
|
||||
esc_html__( 'Not using your language, or have improvements? Help us improve translations by providing your own improvements %1$shere%2$s.', 'wp-smushit' ),
|
||||
'<a href="' . esc_html( $translation_link ) . '" target="_blank">',
|
||||
'</a>'
|
||||
);
|
||||
}
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render tracking settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function render_tracking_settings() {
|
||||
do_action( 'wp_smush_render_setting_row', 'usage', $this->settings->get( 'usage' ) );
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Smush upgrade page class: Upgrade extends Abstract_Page.
|
||||
*
|
||||
* @since 3.2.3
|
||||
* @package Smush\App\Pages
|
||||
*/
|
||||
|
||||
namespace Smush\App\Pages;
|
||||
|
||||
use Smush\App\Abstract_Page;
|
||||
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Upgrade
|
||||
*/
|
||||
class Upgrade extends Abstract_Page {
|
||||
/**
|
||||
* Parent slug.
|
||||
*/
|
||||
private $parent_slug;
|
||||
|
||||
public function __construct( $slug, $title, $parent_slug = false, $is_upsell_link = false ) {
|
||||
parent::__construct( $slug, $title, $parent_slug, false, $is_upsell_link );
|
||||
|
||||
if ( $is_upsell_link ) {
|
||||
$this->parent_slug = $parent_slug;
|
||||
add_action( 'admin_head', array( $this, 'adjust_upsell_submenu' ) );
|
||||
}
|
||||
}
|
||||
|
||||
public function adjust_upsell_submenu() {
|
||||
$submenu_selector = "#toplevel_page_{$this->parent_slug} li:last-child a";
|
||||
?>
|
||||
<style>
|
||||
<?php echo esc_html( $submenu_selector ); ?> {
|
||||
background-color: #8d00b1 !important;
|
||||
color: #fff !important;
|
||||
font-weight: 500 !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
window.addEventListener( 'load', function() {
|
||||
const submenu = document.querySelector( '<?php echo esc_html( $submenu_selector ); ?>' );
|
||||
if ( submenu ) {
|
||||
submenu.target = "_blank";
|
||||
}
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render the page.
|
||||
*/
|
||||
public function render() {
|
||||
?>
|
||||
<div class="<?php echo $this->settings->get( 'accessible_colors' ) ? 'sui-wrap sui-color-accessible' : 'sui-wrap'; ?>">
|
||||
<?php $this->render_inner_content(); ?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Render inner content.
|
||||
*/
|
||||
public function render_inner_content() {
|
||||
$this->view( 'smush-upgrade-page' );
|
||||
}
|
||||
|
||||
/**
|
||||
* On load actions.
|
||||
*/
|
||||
public function on_load() {
|
||||
add_action(
|
||||
'admin_enqueue_scripts',
|
||||
function() {
|
||||
wp_enqueue_script( 'smush-sui', WP_SMUSH_URL . 'app/assets/js/smush-sui.min.js', array( 'jquery', 'clipboard' ), WP_SHARED_UI_VERSION, true );
|
||||
wp_enqueue_script( 'smush-wistia', '//fast.wistia.com/assets/external/E-v1.js', array(), WP_SMUSH_VERSION, true );
|
||||
wp_enqueue_style( 'smush-admin', WP_SMUSH_URL . 'app/assets/css/smush-admin.min.css', array(), WP_SMUSH_VERSION );
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Common hooks for all screens.
|
||||
*/
|
||||
public function add_action_hooks() {
|
||||
add_filter( 'admin_body_class', array( $this, 'smush_body_classes' ) );
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user