Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-smush...
File: wp-smush.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WP Smush plugin
[2] Fix | Delete
*
[3] Fix | Delete
* Reduce image file sizes, improve performance and boost your SEO using the free
[4] Fix | Delete
* <a href="https://wpmudev.com/">WPMU DEV</a> WordPress Smush API.
[5] Fix | Delete
*
[6] Fix | Delete
* @link http://wpmudev.com/project/wp-smush-pro/
[7] Fix | Delete
* @since 1.0.0
[8] Fix | Delete
* @package WP_Smush
[9] Fix | Delete
*
[10] Fix | Delete
* @wordpress-plugin
[11] Fix | Delete
* Plugin Name: Smush
[12] Fix | Delete
* Plugin URI: http://wordpress.org/plugins/wp-smushit/
[13] Fix | Delete
* Description: Reduce image file sizes, improve performance and boost your SEO using the free <a href="https://wpmudev.com/">WPMU DEV</a> WordPress Smush API.
[14] Fix | Delete
* Version: 3.16.6
[15] Fix | Delete
* Requires at least: 6.4
[16] Fix | Delete
* Requires PHP: 7.4
[17] Fix | Delete
* Author: WPMU DEV
[18] Fix | Delete
* Author URI: https://profiles.wordpress.org/wpmudev/
[19] Fix | Delete
* License: GPLv2
[20] Fix | Delete
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
[21] Fix | Delete
* Text Domain: wp-smushit
[22] Fix | Delete
* Domain Path: /languages/
[23] Fix | Delete
* Network: true
[24] Fix | Delete
*/
[25] Fix | Delete
[26] Fix | Delete
/*
[27] Fix | Delete
This plugin was originally developed by Alex Dunae (http://dialect.ca/).
[28] Fix | Delete
[29] Fix | Delete
Copyright 2007-2022 Incsub (http://incsub.com)
[30] Fix | Delete
[31] Fix | Delete
This program is free software; you can redistribute it and/or modify
[32] Fix | Delete
it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
[33] Fix | Delete
the Free Software Foundation.
[34] Fix | Delete
[35] Fix | Delete
This program is distributed in the hope that it will be useful,
[36] Fix | Delete
but WITHOUT ANY WARRANTY; without even the implied warranty of
[37] Fix | Delete
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[38] Fix | Delete
GNU General Public License for more details.
[39] Fix | Delete
[40] Fix | Delete
You should have received a copy of the GNU General Public License
[41] Fix | Delete
along with this program; if not, write to the Free Software
[42] Fix | Delete
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
[43] Fix | Delete
*/
[44] Fix | Delete
[45] Fix | Delete
// If this file is called directly, abort.
[46] Fix | Delete
if ( ! defined( 'WPINC' ) ) {
[47] Fix | Delete
die;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
if ( ! defined( 'WP_SMUSH_VERSION' ) ) {
[51] Fix | Delete
define( 'WP_SMUSH_VERSION', '3.16.6' );
[52] Fix | Delete
}
[53] Fix | Delete
// Used to define body class.
[54] Fix | Delete
if ( ! defined( 'WP_SHARED_UI_VERSION' ) ) {
[55] Fix | Delete
define( 'WP_SHARED_UI_VERSION', 'sui-2-12-23' );
[56] Fix | Delete
}
[57] Fix | Delete
if ( ! defined( 'WP_SMUSH_BASENAME' ) ) {
[58] Fix | Delete
define( 'WP_SMUSH_BASENAME', plugin_basename( __FILE__ ) );
[59] Fix | Delete
}
[60] Fix | Delete
if ( ! defined( 'WP_SMUSH_API' ) ) {
[61] Fix | Delete
define( 'WP_SMUSH_API', 'https://smushpro.wpmudev.com/1.0/' );
[62] Fix | Delete
}
[63] Fix | Delete
if ( ! defined( 'WP_SMUSH_UA' ) ) {
[64] Fix | Delete
define( 'WP_SMUSH_UA', 'WP Smush/' . WP_SMUSH_VERSION . '; ' . network_home_url() );
[65] Fix | Delete
}
[66] Fix | Delete
if ( ! defined( 'WP_SMUSH_DIR' ) ) {
[67] Fix | Delete
define( 'WP_SMUSH_DIR', plugin_dir_path( __FILE__ ) );
[68] Fix | Delete
}
[69] Fix | Delete
if ( ! defined( 'WP_SMUSH_URL' ) ) {
[70] Fix | Delete
define( 'WP_SMUSH_URL', plugin_dir_url( __FILE__ ) );
[71] Fix | Delete
}
[72] Fix | Delete
if ( ! defined( 'WP_SMUSH_MAX_BYTES' ) ) {
[73] Fix | Delete
define( 'WP_SMUSH_MAX_BYTES', 5242880 ); // 5MB
[74] Fix | Delete
}
[75] Fix | Delete
if ( ! defined( 'WP_SMUSH_PREMIUM_MAX_BYTES' ) ) {
[76] Fix | Delete
define( 'WP_SMUSH_PREMIUM_MAX_BYTES', 268435456 );
[77] Fix | Delete
}
[78] Fix | Delete
if ( ! defined( 'WP_SMUSH_TIMEOUT' ) ) {
[79] Fix | Delete
define( 'WP_SMUSH_TIMEOUT', 420 ); // 7 minutes
[80] Fix | Delete
}
[81] Fix | Delete
if ( ! defined( 'WP_SMUSH_RETRY_ATTEMPTS' ) ) {
[82] Fix | Delete
define( 'WP_SMUSH_RETRY_ATTEMPTS', 3 );
[83] Fix | Delete
}
[84] Fix | Delete
if ( ! defined( 'WP_SMUSH_RETRY_WAIT' ) ) {
[85] Fix | Delete
define( 'WP_SMUSH_RETRY_WAIT', 1 );
[86] Fix | Delete
}
[87] Fix | Delete
if ( ! defined( 'WP_SMUSH_PARALLEL' ) ) {
[88] Fix | Delete
define( 'WP_SMUSH_PARALLEL', true );
[89] Fix | Delete
}
[90] Fix | Delete
if ( ! defined( 'WP_SMUSH_BACKGROUND' ) ) {
[91] Fix | Delete
define( 'WP_SMUSH_BACKGROUND', true );
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
if ( ! defined( 'WP_SMUSH_MIN_PHP_VERSION' ) ) {
[95] Fix | Delete
define( 'WP_SMUSH_MIN_PHP_VERSION', '7.4' );
[96] Fix | Delete
}
[97] Fix | Delete
[98] Fix | Delete
if ( version_compare( PHP_VERSION, WP_SMUSH_MIN_PHP_VERSION, '<' ) ) {
[99] Fix | Delete
if ( ! function_exists( 'wp_smush_php_deprecated_notice' ) ) {
[100] Fix | Delete
function wp_smush_php_deprecated_notice() {
[101] Fix | Delete
// Only show the deprecated notice for admin and only network side for MU site.
[102] Fix | Delete
if ( ! current_user_can( 'manage_options' ) || ( is_multisite() && ! is_network_admin() ) ) {
[103] Fix | Delete
return;
[104] Fix | Delete
}
[105] Fix | Delete
?>
[106] Fix | Delete
<div class="notice notice-error is-dismissible">
[107] Fix | Delete
<p>
[108] Fix | Delete
<?php
[109] Fix | Delete
printf(
[110] Fix | Delete
wp_kses( /* translators: %1$s - Requires PHP version - %2$s URL to an article about our hosting benefits. */
[111] Fix | Delete
__( 'Your site is running an outdated version of PHP that is no longer supported or receiving security updates. Please update PHP to at least version %1$s at your hosting provider in order to activate Smush, or consider switching to <a href="%2$s" target="_blank" rel="noopener noreferrer">WPMU DEV Hosting</a>.', 'wp-smushit' ),
[112] Fix | Delete
array(
[113] Fix | Delete
'a' => array(
[114] Fix | Delete
'href' => array(),
[115] Fix | Delete
'target' => array(),
[116] Fix | Delete
'rel' => array(),
[117] Fix | Delete
),
[118] Fix | Delete
'strong' => array(),
[119] Fix | Delete
)
[120] Fix | Delete
),
[121] Fix | Delete
esc_html( WP_SMUSH_MIN_PHP_VERSION ),
[122] Fix | Delete
'https://wpmudev.com/hosting/'
[123] Fix | Delete
);
[124] Fix | Delete
?>
[125] Fix | Delete
</p>
[126] Fix | Delete
</div>
[127] Fix | Delete
<?php
[128] Fix | Delete
[129] Fix | Delete
// Deactivate plugin.
[130] Fix | Delete
deactivate_plugins( WP_SMUSH_BASENAME, false, is_network_admin() );
[131] Fix | Delete
}
[132] Fix | Delete
}
[133] Fix | Delete
add_action( 'admin_notices', 'wp_smush_php_deprecated_notice' );
[134] Fix | Delete
add_action( 'network_admin_notices', 'wp_smush_php_deprecated_notice' );
[135] Fix | Delete
return;
[136] Fix | Delete
}
[137] Fix | Delete
/**
[138] Fix | Delete
* To support Smushing on staging sites like SiteGround staging where staging site urls are different
[139] Fix | Delete
* but redirects to main site url. Remove the protocols and www, and get the domain name.*
[140] Fix | Delete
* If Set to false, WP Smush switch backs to the Old Sync Optimisation.
[141] Fix | Delete
*/
[142] Fix | Delete
$site_url = str_replace( array( 'http://', 'https://', 'www.' ), '', site_url() );
[143] Fix | Delete
// Compat with WPMU DEV staging.
[144] Fix | Delete
$wpmu_host = isset( $_SERVER['WPMUDEV_HOSTING_ENV'] ) && 'staging' === sanitize_text_field( wp_unslash( $_SERVER['WPMUDEV_HOSTING_ENV'] ) );
[145] Fix | Delete
if ( ! defined( 'WP_SMUSH_ASYNC' ) ) {
[146] Fix | Delete
if ( ( ! empty( $_SERVER['SERVER_NAME'] ) && 0 !== strpos( $site_url, sanitize_text_field( wp_unslash( $_SERVER['SERVER_NAME'] ) ) ) ) || $wpmu_host ) {
[147] Fix | Delete
define( 'WP_SMUSH_ASYNC', false );
[148] Fix | Delete
} else {
[149] Fix | Delete
define( 'WP_SMUSH_ASYNC', true );
[150] Fix | Delete
}
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
/**
[154] Fix | Delete
* If we are activating a version, while having another present and activated.
[155] Fix | Delete
* Leave in the Pro version, if it is available.
[156] Fix | Delete
*
[157] Fix | Delete
* @since 2.9.1
[158] Fix | Delete
*/
[159] Fix | Delete
if ( WP_SMUSH_BASENAME !== plugin_basename( __FILE__ ) ) {
[160] Fix | Delete
$pro_installed = false;
[161] Fix | Delete
if ( file_exists( WP_PLUGIN_DIR . '/wp-smush-pro/wp-smush.php' ) ) {
[162] Fix | Delete
$pro_installed = true;
[163] Fix | Delete
}
[164] Fix | Delete
[165] Fix | Delete
if ( ! function_exists( 'is_plugin_active' ) ) {
[166] Fix | Delete
include_once ABSPATH . 'wp-admin/includes/plugin.php';
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if ( is_plugin_active( 'wp-smush-pro/wp-smush.php' ) ) {
[170] Fix | Delete
deactivate_plugins( plugin_basename( __FILE__ ) );
[171] Fix | Delete
update_site_option( 'smush_deactivated', 1 );
[172] Fix | Delete
return; // Return to avoid errors with free-dashboard module.
[173] Fix | Delete
} elseif ( $pro_installed && is_plugin_active( WP_SMUSH_BASENAME ) ) {
[174] Fix | Delete
deactivate_plugins( WP_SMUSH_BASENAME );
[175] Fix | Delete
// If WordPress is already in the process of activating - return.
[176] Fix | Delete
if ( defined( 'WP_SANDBOX_SCRAPING' ) && WP_SANDBOX_SCRAPING ) {
[177] Fix | Delete
return;
[178] Fix | Delete
}
[179] Fix | Delete
activate_plugin( plugin_basename( __FILE__ ) );
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
[183] Fix | Delete
/* @noinspection PhpIncludeInspection */
[184] Fix | Delete
require_once WP_SMUSH_DIR . 'core/class-installer.php';
[185] Fix | Delete
register_activation_hook( __FILE__, array( 'Smush\\Core\\Installer', 'smush_activated' ) );
[186] Fix | Delete
register_deactivation_hook( __FILE__, array( 'Smush\\Core\\Installer', 'smush_deactivated' ) );
[187] Fix | Delete
[188] Fix | Delete
register_activation_hook( __FILE__, function () {
[189] Fix | Delete
update_option( 'wp-smush-plugin-activated', true );
[190] Fix | Delete
} );
[191] Fix | Delete
[192] Fix | Delete
// Init the plugin and load the plugin instance for the first time.
[193] Fix | Delete
add_action( 'plugins_loaded', array( 'WP_Smush', 'get_instance' ) );
[194] Fix | Delete
[195] Fix | Delete
if ( ! class_exists( 'WP_Smush' ) ) {
[196] Fix | Delete
/**
[197] Fix | Delete
* Class WP_Smush
[198] Fix | Delete
*/
[199] Fix | Delete
final class WP_Smush {
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Plugin instance.
[203] Fix | Delete
*
[204] Fix | Delete
* @since 2.9.0
[205] Fix | Delete
* @var null|WP_Smush
[206] Fix | Delete
*/
[207] Fix | Delete
private static $instance = null;
[208] Fix | Delete
[209] Fix | Delete
/**
[210] Fix | Delete
* Plugin core.
[211] Fix | Delete
*
[212] Fix | Delete
* @since 2.9.0
[213] Fix | Delete
* @var Smush\Core\Core
[214] Fix | Delete
*/
[215] Fix | Delete
private $core;
[216] Fix | Delete
[217] Fix | Delete
/**
[218] Fix | Delete
* Plugin admin.
[219] Fix | Delete
*
[220] Fix | Delete
* @since 2.9.0
[221] Fix | Delete
* @var Smush\App\Admin
[222] Fix | Delete
*/
[223] Fix | Delete
private $admin;
[224] Fix | Delete
[225] Fix | Delete
/**
[226] Fix | Delete
* Plugin API.
[227] Fix | Delete
*
[228] Fix | Delete
* @since 3.0
[229] Fix | Delete
* @var Smush\Core\Api\Smush_API
[230] Fix | Delete
*/
[231] Fix | Delete
private $api = '';
[232] Fix | Delete
[233] Fix | Delete
/**
[234] Fix | Delete
* Media library UI.
[235] Fix | Delete
*
[236] Fix | Delete
* @since 3.4.0
[237] Fix | Delete
* @var Smush\App\Media_Library
[238] Fix | Delete
*/
[239] Fix | Delete
private $library;
[240] Fix | Delete
[241] Fix | Delete
/**
[242] Fix | Delete
* Stores the value of validate_install function.
[243] Fix | Delete
*
[244] Fix | Delete
* @var bool $is_pro
[245] Fix | Delete
*/
[246] Fix | Delete
private static $is_pro;
[247] Fix | Delete
[248] Fix | Delete
/**
[249] Fix | Delete
* Return the plugin instance.
[250] Fix | Delete
*
[251] Fix | Delete
* @return WP_Smush
[252] Fix | Delete
*/
[253] Fix | Delete
public static function get_instance() {
[254] Fix | Delete
if ( ! self::$instance ) {
[255] Fix | Delete
self::$instance = new self();
[256] Fix | Delete
}
[257] Fix | Delete
[258] Fix | Delete
return self::$instance;
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* WP_Smush constructor.
[263] Fix | Delete
*/
[264] Fix | Delete
private function __construct() {
[265] Fix | Delete
spl_autoload_register( array( $this, 'autoload' ) );
[266] Fix | Delete
[267] Fix | Delete
add_action( 'admin_init', array( '\\Smush\\Core\\Installer', 'upgrade_settings' ) );
[268] Fix | Delete
add_action( 'current_screen', array( '\\Smush\\Core\\Installer', 'maybe_create_table' ) );
[269] Fix | Delete
// We use priority 9 to avoid conflict with old free-dashboard module <= 2.0.4.
[270] Fix | Delete
add_action( 'admin_init', array( $this, 'register_free_modules' ), 9 );
[271] Fix | Delete
[272] Fix | Delete
// The dash-notification actions are hooked into "init" with a priority of 10.
[273] Fix | Delete
add_action( 'init', array( $this, 'register_pro_modules' ), 5 );
[274] Fix | Delete
[275] Fix | Delete
add_action( 'init', array( $this, 'do_plugin_activated_action' ) );
[276] Fix | Delete
[277] Fix | Delete
$this->init();
[278] Fix | Delete
}
[279] Fix | Delete
[280] Fix | Delete
public function do_plugin_activated_action() {
[281] Fix | Delete
$transient_key = 'wp-smush-plugin-activated';
[282] Fix | Delete
if ( ! get_option( $transient_key ) ) {
[283] Fix | Delete
return;
[284] Fix | Delete
}
[285] Fix | Delete
[286] Fix | Delete
( new \Smush\Core\Modules\Background\Mutex( $transient_key ) )
[287] Fix | Delete
->set_break_on_timeout( true )
[288] Fix | Delete
->execute( function () use ( $transient_key ) {
[289] Fix | Delete
// The get_option call we made above has added the "true" value to the cache,
[290] Fix | Delete
// get_option is always going to return true even if the option was deleted in another thread,
[291] Fix | Delete
// now we need use a thread safe method instead
[292] Fix | Delete
$background_utils = new \Smush\Core\Modules\Background\Background_Utils();
[293] Fix | Delete
if ( $background_utils->get_option( $transient_key, false ) ) {
[294] Fix | Delete
do_action( 'wp_smush_plugin_activated' );
[295] Fix | Delete
delete_option( $transient_key );
[296] Fix | Delete
}
[297] Fix | Delete
} );
[298] Fix | Delete
}
[299] Fix | Delete
[300] Fix | Delete
/**
[301] Fix | Delete
* Autoload method.
[302] Fix | Delete
*
[303] Fix | Delete
* @since 3.1.0
[304] Fix | Delete
* @param string $class Class name to autoload.
[305] Fix | Delete
*/
[306] Fix | Delete
public function autoload( $class ) {
[307] Fix | Delete
// Project-specific namespace prefix.
[308] Fix | Delete
$prefix = 'Smush\\';
[309] Fix | Delete
[310] Fix | Delete
// Does the class use the namespace prefix?
[311] Fix | Delete
$len = strlen( $prefix );
[312] Fix | Delete
if ( 0 !== strncmp( $prefix, $class, $len ) ) {
[313] Fix | Delete
// Maybe require some external classes.
[314] Fix | Delete
$external_libs = array( 'WDEV_Logger' );
[315] Fix | Delete
if ( in_array( $class, $external_libs, true ) ) {
[316] Fix | Delete
$lib = str_replace( '_', '-', strtolower( $class ) );
[317] Fix | Delete
$file = WP_SMUSH_DIR . "core/external/{$lib}/{$lib}.php";
[318] Fix | Delete
if ( file_exists( $file ) ) {
[319] Fix | Delete
require_once $file;
[320] Fix | Delete
}
[321] Fix | Delete
}
[322] Fix | Delete
// No, move to the next registered autoloader.
[323] Fix | Delete
return;
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
// Get the relative class name.
[327] Fix | Delete
$relative_class = substr( $class, $len );
[328] Fix | Delete
[329] Fix | Delete
$path = explode( '\\', strtolower( str_replace( '_', '-', $relative_class ) ) );
[330] Fix | Delete
$file = array_pop( $path );
[331] Fix | Delete
$file = WP_SMUSH_DIR . implode( '/', $path ) . '/class-' . $file . '.php';
[332] Fix | Delete
[333] Fix | Delete
// If the file exists, require it.
[334] Fix | Delete
if ( file_exists( $file ) ) {
[335] Fix | Delete
/* @noinspection PhpIncludeInspection */
[336] Fix | Delete
require $file;
[337] Fix | Delete
}
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
/**
[341] Fix | Delete
* Init core module.
[342] Fix | Delete
*
[343] Fix | Delete
* @since 2.9.0
[344] Fix | Delete
*/
[345] Fix | Delete
private function init() {
[346] Fix | Delete
try {
[347] Fix | Delete
$this->api = new Smush\Core\Api\Smush_API( Smush\Core\Helper::get_wpmudev_apikey() );
[348] Fix | Delete
} catch ( Exception $e ) {
[349] Fix | Delete
$this->api = '';
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
// Handle failed items, load it before validate the install.
[353] Fix | Delete
new Smush\Core\Error_Handler();
[354] Fix | Delete
[355] Fix | Delete
$this->validate_install();
[356] Fix | Delete
[357] Fix | Delete
$this->core = new Smush\Core\Core();
[358] Fix | Delete
$this->library = new Smush\App\Media_Library( $this->core() );
[359] Fix | Delete
if ( is_admin() ) {
[360] Fix | Delete
$this->admin = new Smush\App\Admin( $this->library() );
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
if ( defined( 'WP_CLI' ) && WP_CLI ) {
[364] Fix | Delete
WP_CLI::add_command( 'smush', '\\Smush\\Core\\CLI' );
[365] Fix | Delete
}
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
/**
[369] Fix | Delete
* Getter method for core.
[370] Fix | Delete
*
[371] Fix | Delete
* @since 2.9.0
[372] Fix | Delete
*
[373] Fix | Delete
* @return Smush\Core\Core
[374] Fix | Delete
*/
[375] Fix | Delete
public function core() {
[376] Fix | Delete
return $this->core;
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
/**
[380] Fix | Delete
* Getter method for core.
[381] Fix | Delete
*
[382] Fix | Delete
* @since 2.9.0
[383] Fix | Delete
*
[384] Fix | Delete
* @return Smush\App\Admin
[385] Fix | Delete
*/
[386] Fix | Delete
public function admin() {
[387] Fix | Delete
return $this->admin;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
/**
[391] Fix | Delete
* Getter method for core.
[392] Fix | Delete
*
[393] Fix | Delete
* @since 3.0
[394] Fix | Delete
*
[395] Fix | Delete
* @return Smush\Core\Api\Smush_API
[396] Fix | Delete
*/
[397] Fix | Delete
public function api() {
[398] Fix | Delete
return $this->api;
[399] Fix | Delete
}
[400] Fix | Delete
[401] Fix | Delete
/**
[402] Fix | Delete
* Getter method for library.
[403] Fix | Delete
*
[404] Fix | Delete
* @since 3.4.0
[405] Fix | Delete
*
[406] Fix | Delete
* @return Smush\App\Media_Library
[407] Fix | Delete
*/
[408] Fix | Delete
public function library() {
[409] Fix | Delete
return $this->library;
[410] Fix | Delete
}
[411] Fix | Delete
[412] Fix | Delete
/**
[413] Fix | Delete
* Return PRO status.
[414] Fix | Delete
*
[415] Fix | Delete
* @since 2.9.0
[416] Fix | Delete
*
[417] Fix | Delete
* @return bool
[418] Fix | Delete
*/
[419] Fix | Delete
public static function is_pro() {
[420] Fix | Delete
return self::$is_pro;
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
public static function is_expired() {
[424] Fix | Delete
return ! self::is_pro() && Smush\Core\Helper::get_wpmudev_apikey();
[425] Fix | Delete
}
[426] Fix | Delete
[427] Fix | Delete
public static function is_new_user() {
[428] Fix | Delete
return ! self::is_pro() && ! self::is_expired();
[429] Fix | Delete
}
[430] Fix | Delete
[431] Fix | Delete
/**
[432] Fix | Delete
* Verify the site is connected to TFH.
[433] Fix | Delete
*
[434] Fix | Delete
* @since 3.12.0
[435] Fix | Delete
*
[436] Fix | Delete
* @return boolean
[437] Fix | Delete
*/
[438] Fix | Delete
public static function is_site_connected_to_tfh() {
[439] Fix | Delete
return isset( $_SERVER['WPMUDEV_HOSTED'] )
[440] Fix | Delete
&& class_exists( '\WPMUDEV_Dashboard' ) && is_object( \WPMUDEV_Dashboard::$api )
[441] Fix | Delete
&& method_exists( \WPMUDEV_Dashboard::$api, 'get_membership_status' )
[442] Fix | Delete
&& 'free' === \WPMUDEV_Dashboard::$api->get_membership_status();
[443] Fix | Delete
}
[444] Fix | Delete
[445] Fix | Delete
public static function is_member() {
[446] Fix | Delete
return self::is_pro() || self::is_site_connected_to_tfh();
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Register submodules.
[451] Fix | Delete
* Only for wordpress.org members.
[452] Fix | Delete
*/
[453] Fix | Delete
public function register_free_modules() {
[454] Fix | Delete
if ( false === strpos( WP_SMUSH_DIR, 'wp-smushit' ) || class_exists( 'WPMUDEV_Dashboard' ) || file_exists( WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php' ) ) {
[455] Fix | Delete
return;
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
/* @noinspection PhpIncludeInspection */
[459] Fix | Delete
require_once WP_SMUSH_DIR . 'core/external/free-dashboard/module.php';
[460] Fix | Delete
/* @noinspection PhpIncludeInspection */
[461] Fix | Delete
require_once WP_SMUSH_DIR . 'core/external/plugin-notice/notice.php';
[462] Fix | Delete
[463] Fix | Delete
// Add the Mailchimp group value.
[464] Fix | Delete
add_action(
[465] Fix | Delete
'frash_subscribe_form_fields',
[466] Fix | Delete
function ( $mc_list_id ) {
[467] Fix | Delete
if ( '4b14b58816' === $mc_list_id ) {
[468] Fix | Delete
echo '<input type="hidden" id="mce-group[53]-53-1" name="group[53][2]" value="2" />';
[469] Fix | Delete
}
[470] Fix | Delete
}
[471] Fix | Delete
);
[472] Fix | Delete
[473] Fix | Delete
// Register the current plugin.
[474] Fix | Delete
do_action(
[475] Fix | Delete
'wpmudev_register_notices',
[476] Fix | Delete
'smush',
[477] Fix | Delete
array(
[478] Fix | Delete
'basename' => WP_SMUSH_BASENAME, // Required: Plugin basename (for backward compat).
[479] Fix | Delete
'title' => 'Smush', // Required: Plugin title.
[480] Fix | Delete
'wp_slug' => 'wp-smushit', // Required: wp.org slug of the plugin.
[481] Fix | Delete
'cta_email' => __( 'Get Fast!', 'wp-smushit' ), // Email button CTA.
[482] Fix | Delete
'installed_on' => time(), // Optional: Plugin activated time.
[483] Fix | Delete
'screens' => array( // Required: Plugin screen ids.
[484] Fix | Delete
'toplevel_page_smush',
[485] Fix | Delete
),
[486] Fix | Delete
)
[487] Fix | Delete
);
[488] Fix | Delete
add_filter( 'wpmudev_notices_is_disabled', array( $this, 'enable_free_tips_opt_in' ), 10, 3 );
[489] Fix | Delete
[490] Fix | Delete
// The email message contains 1 variable: plugin-name.
[491] Fix | Delete
add_filter(
[492] Fix | Delete
'wdev_email_message_' . WP_SMUSH_BASENAME,
[493] Fix | Delete
function () {
[494] Fix | Delete
return "You're awesome for installing %s! Make sure you get the most out of it, boost your Google PageSpeed score with these tips and tricks - just for users of Smush!";
[495] Fix | Delete
}
[496] Fix | Delete
);
[497] Fix | Delete
[498] Fix | Delete
// Recommended plugin notice.
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function