mirror of
https://github.com/mainwp/mainwp-child.git
synced 2025-09-06 09:20:28 +08:00
Fixed: CodeFactor issues
This commit is contained in:
parent
2df8ed7210
commit
d7220088da
1 changed files with 198 additions and 221 deletions
|
@ -6,7 +6,7 @@ class MainWP_Child_Branding {
|
|||
public $child_plugin_dir;
|
||||
public $child_branding_options = null;
|
||||
|
||||
static function Instance() {
|
||||
public static function Instance() {
|
||||
if ( null === self::$instance ) {
|
||||
self::$instance = new MainWP_Child_Branding();
|
||||
}
|
||||
|
@ -20,12 +20,11 @@ class MainWP_Child_Branding {
|
|||
$this->child_branding_options = $this->init_options();
|
||||
}
|
||||
|
||||
function init_options() {
|
||||
public function init_options() {
|
||||
|
||||
$opts = get_option( 'mainwp_child_branding_settings' );
|
||||
|
||||
if ( ! is_array( $opts ) ) {
|
||||
// compatible with old code
|
||||
$opts = array();
|
||||
|
||||
$label = get_option( 'mainwp_branding_button_contact_label' );
|
||||
|
@ -38,19 +37,19 @@ class MainWP_Child_Branding {
|
|||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $opts );
|
||||
}
|
||||
|
||||
if ( ! isset($opts['contact_label']) || empty($opts['contact_label']) ) {
|
||||
$opts['contact_label'] = 'Contact Support';
|
||||
if ( ! isset( $opts['contact_label'] ) || empty( $opts['contact_label'] ) ) {
|
||||
$opts['contact_label'] = __( 'Contact Support', 'mainwp-child' );
|
||||
}
|
||||
|
||||
$disconnected = isset( $opts['branding_disconnected'] ) ? $opts['branding_disconnected'] : '';
|
||||
$preserve_branding = isset( $opts['preserve_branding'] ) ? $opts['preserve_branding'] : '';
|
||||
$cancelled_branding = ( $disconnected === 'yes' ) && ! $preserve_branding;
|
||||
$cancelled_branding = ( 'yes' === $disconnected ) && ! $preserve_branding;
|
||||
|
||||
$opts['cancelled_branding'] = $cancelled_branding;
|
||||
$opts['branding_preserve_title'] = '';
|
||||
|
||||
if ( ! $cancelled_branding ) {
|
||||
if ( isset($opts['branding_header']) ) {
|
||||
if ( isset( $opts['branding_header'] ) ) {
|
||||
$branding_header = $opts['branding_header'];
|
||||
if ( is_array( $branding_header ) && isset( $branding_header['name'] ) && ! empty( $branding_header['name'] ) ) {
|
||||
$opts['branding_preserve_title'] = stripslashes( $branding_header['name'] );
|
||||
|
@ -64,7 +63,7 @@ class MainWP_Child_Branding {
|
|||
|
||||
function get_extra_options() {
|
||||
$extra = array();
|
||||
if ( is_array($this->child_branding_options) && isset($this->child_branding_options['extra_settings']) ) {
|
||||
if ( is_array( $this->child_branding_options ) && isset( $this->child_branding_options['extra_settings'] ) ) {
|
||||
$extra = $this->child_branding_options['extra_settings'];
|
||||
if ( ! is_array($extra) ) {
|
||||
$extra = array();
|
||||
|
@ -82,7 +81,7 @@ class MainWP_Child_Branding {
|
|||
if ( ! $this->is_branding() ) {
|
||||
return $plugin_meta;
|
||||
}
|
||||
// hide View details links
|
||||
// hide View details links!
|
||||
$meta_total = count( $plugin_meta );
|
||||
for ( $i = 0; $i < $meta_total; $i++ ) {
|
||||
$str_meta = $plugin_meta[ $i ];
|
||||
|
@ -96,7 +95,6 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
public function child_deactivation() {
|
||||
// will remove later
|
||||
$dell_all = array(
|
||||
'mainwp_branding_disable_change',
|
||||
'mainwp_branding_disable_switching_theme',
|
||||
|
@ -110,7 +108,6 @@ class MainWP_Child_Branding {
|
|||
'mainwp_branding_remove_wp_tools',
|
||||
'mainwp_branding_remove_wp_setting',
|
||||
'mainwp_branding_remove_permalink',
|
||||
// 'mainwp_branding_plugin_header', // don't remove header
|
||||
'mainwp_branding_button_contact_label',
|
||||
'mainwp_branding_send_email_message',
|
||||
'mainwp_branding_message_return_sender',
|
||||
|
@ -136,7 +133,6 @@ class MainWP_Child_Branding {
|
|||
'remove_wp_tools',
|
||||
'remove_wp_setting',
|
||||
'remove_permalink',
|
||||
// 'branding_header', // don't remove header
|
||||
'contact_label',
|
||||
'email_message',
|
||||
'message_return_sender',
|
||||
|
@ -153,7 +149,6 @@ class MainWP_Child_Branding {
|
|||
MainWP_Helper::update_option( 'mainwp_child_branding_settings', $this->child_branding_options );
|
||||
}
|
||||
|
||||
|
||||
public function action() {
|
||||
$information = array();
|
||||
switch ( $_POST['action'] ) {
|
||||
|
@ -166,7 +161,7 @@ class MainWP_Child_Branding {
|
|||
|
||||
public function update_branding() {
|
||||
$information = array();
|
||||
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) );
|
||||
$settings = maybe_unserialize( base64_decode( $_POST['settings'] ) ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions -- base64_encode function is used for benign reasons.
|
||||
if ( ! is_array( $settings ) ) {
|
||||
return $information;
|
||||
}
|
||||
|
@ -174,7 +169,6 @@ class MainWP_Child_Branding {
|
|||
$current_settings = $this->child_branding_options;
|
||||
$current_extra_setting = $this->child_branding_options['extra_settings'];
|
||||
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_ext_enabled', 'Y' );
|
||||
$current_settings['branding_ext_enabled'] = 'Y';
|
||||
|
||||
$header = array(
|
||||
|
@ -182,27 +176,11 @@ class MainWP_Child_Branding {
|
|||
'description' => $settings['child_plugin_desc'],
|
||||
'author' => $settings['child_plugin_author'],
|
||||
'authoruri' => $settings['child_plugin_author_uri'],
|
||||
'pluginuri' => isset($settings['child_plugin_uri']) ? $settings['child_plugin_uri'] : '',
|
||||
'pluginuri' => isset( $settings['child_plugin_uri'] ) ? $settings['child_plugin_uri'] : '',
|
||||
);
|
||||
|
||||
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' ); // to compatible with old version of child report plugin
|
||||
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' ); // to compatible
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_email', $settings['child_support_email'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_support_message', $settings['child_support_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_restore', $settings['child_remove_restore'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_setting', $settings['child_remove_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_server_info', $settings['child_remove_server_info'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_connection_detail', (isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0) );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_tools', $settings['child_remove_wp_tools'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_wp_setting', $settings['child_remove_wp_setting'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_remove_permalink', $settings['child_remove_permalink'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_button_contact_label', $settings['child_button_contact_label'], 'yes' );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_send_email_message', $settings['child_send_email_message'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_message_return_sender', $settings['child_message_return_sender'] );
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_submit_button_title', $settings['child_submit_button_title'] );
|
||||
// if ( isset( $settings['child_disable_wp_branding'] ) && ( 'Y' === $settings['child_disable_wp_branding'] || 'N' === $settings['child_disable_wp_branding'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_wp_branding', $settings['child_disable_wp_branding'] );
|
||||
// }
|
||||
MainWP_Helper::update_option( 'mainwp_branding_preserve_branding', $settings['child_preserve_branding'], 'yes' );
|
||||
MainWP_Helper::update_option( 'mainwp_branding_plugin_header', $header, 'yes' );
|
||||
|
||||
$current_settings['preserve_branding'] = $settings['child_preserve_branding'];
|
||||
$current_settings['branding_header'] = $header;
|
||||
|
@ -211,7 +189,7 @@ class MainWP_Child_Branding {
|
|||
$current_settings['remove_restore'] = $settings['child_remove_restore'];
|
||||
$current_settings['remove_setting'] = $settings['child_remove_setting'];
|
||||
$current_settings['remove_server_info'] = $settings['child_remove_server_info'];
|
||||
$current_settings['remove_connection_detail'] = isset($settings['child_remove_connection_detail']) ? $settings['child_remove_connection_detail'] : 0;
|
||||
$current_settings['remove_connection_detail'] = isset( $settings['child_remove_connection_detail'] ) ? $settings['child_remove_connection_detail'] : 0;
|
||||
$current_settings['remove_wp_tools'] = $settings['child_remove_wp_tools'];
|
||||
$current_settings['remove_wp_setting'] = $settings['child_remove_wp_setting'];
|
||||
$current_settings['remove_permalink'] = $settings['child_remove_permalink'];
|
||||
|
@ -266,7 +244,7 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['login_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_login_image_url'] ); // Upload image to WP
|
||||
$upload = $this->uploadImage( $settings['child_login_image_url'] );
|
||||
if ( null !== $upload ) {
|
||||
$extra_setting['login_image'] = array(
|
||||
'path' => $upload['path'],
|
||||
|
@ -292,7 +270,7 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['favico_image'] = array();
|
||||
} else {
|
||||
try {
|
||||
$upload = $this->uploadImage( $settings['child_favico_image_url'] ); // Upload image to WP
|
||||
$upload = $this->uploadImage( $settings['child_favico_image_url'] );
|
||||
if ( null !== $upload ) {
|
||||
$extra_setting['favico_image'] = array(
|
||||
'path' => $upload['path'],
|
||||
|
@ -313,36 +291,16 @@ class MainWP_Child_Branding {
|
|||
$extra_setting['favico_image'] = $current_extra_setting['favico_image'];
|
||||
}
|
||||
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_extra_settings', $extra_setting, 'yes' );
|
||||
$current_settings['extra_settings'] = $extra_setting;
|
||||
|
||||
// keep it to compatible with old version of child reports plugin
|
||||
if ( $settings['child_plugin_hide'] ) {
|
||||
MainWP_Helper::update_option( 'mainwp_branding_child_hide', 'T', 'yes' );
|
||||
} else {
|
||||
MainWP_Helper::update_option( 'mainwp_branding_child_hide', '' );
|
||||
}
|
||||
//
|
||||
// if ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_show_support', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_change'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_change', '' );
|
||||
// }
|
||||
|
||||
// if ( $settings['child_disable_switching_theme'] ) {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', 'T' );
|
||||
// } else {
|
||||
// MainWP_Helper::update_option( 'mainwp_branding_disable_switching_theme', '' );
|
||||
// }
|
||||
|
||||
$current_settings['hide'] = $settings['child_plugin_hide'] ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty($settings['child_support_email']) ) ? 'T' : '';
|
||||
$current_settings['show_support'] = ( $settings['child_show_support_button'] && ! empty( $settings['child_support_email'] ) ) ? 'T' : '';
|
||||
$current_settings['disable_change'] = $settings['child_disable_change'] ? 'T' : '';
|
||||
$current_settings['disable_switching_theme'] = $settings['child_disable_switching_theme'] ? 'T' : '';
|
||||
|
||||
|
@ -353,19 +311,18 @@ class MainWP_Child_Branding {
|
|||
return $information;
|
||||
}
|
||||
|
||||
static function uploadImage( $img_url ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/file.php'; // Contains download_url
|
||||
global $mainWPChild;
|
||||
public static function uploadImage( $img_url ) {
|
||||
include_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
global $mainWPChild;
|
||||
add_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
// Download $img_url
|
||||
$temporary_file = download_url( $img_url );
|
||||
remove_filter( 'http_request_args', array( $mainWPChild, 'http_request_reject_unsafe_urls' ), 99, 2 );
|
||||
|
||||
if ( is_wp_error( $temporary_file ) ) {
|
||||
throw new Exception( 'Error: ' . $temporary_file->get_error_message() );
|
||||
throw new Exception( $temporary_file->get_error_message() );
|
||||
} else {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url ); // Local name
|
||||
$local_img_path = $upload_dir['path'] . DIRECTORY_SEPARATOR . basename( $img_url );
|
||||
$local_img_path = dirname( $local_img_path ) . '/' . wp_unique_filename( dirname( $local_img_path ), basename( $local_img_path ) );
|
||||
$local_img_url = $upload_dir['url'] . '/' . basename( $local_img_path );
|
||||
$moved = @rename( $temporary_file, $local_img_path );
|
||||
|
@ -385,17 +342,14 @@ class MainWP_Child_Branding {
|
|||
|
||||
|
||||
public function branding_init() {
|
||||
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
// to hide updates notice
|
||||
if ( is_admin() ) {
|
||||
// back end
|
||||
add_action( 'in_admin_footer', array( $this, 'in_admin_footer' ) );
|
||||
} elseif ( is_user_logged_in() ) {
|
||||
// front end
|
||||
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ));
|
||||
add_action( 'wp_after_admin_bar_render', array( $this, 'after_admin_bar_render' ) );
|
||||
}
|
||||
|
||||
$opts = $this->child_branding_options;
|
||||
|
||||
$cancelled_branding = $opts['cancelled_branding'];
|
||||
|
@ -403,7 +357,7 @@ class MainWP_Child_Branding {
|
|||
return;
|
||||
}
|
||||
|
||||
// enable branding in case child plugin deactive and re-activated
|
||||
// enable branding in case child plugin deactive and re-activated.
|
||||
add_filter( 'all_plugins', array( $this, 'modify_plugin_header' ) );
|
||||
|
||||
if ( $this->is_branding() ) {
|
||||
|
@ -411,7 +365,7 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'mainwp_child_hide_update_notice', array( &$this, 'hide_update_notice' ) );
|
||||
}
|
||||
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
if ( ! isset( $opts['branding_ext_enabled'] ) || 'Y' !== $opts['branding_ext_enabled'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -419,35 +373,47 @@ class MainWP_Child_Branding {
|
|||
|
||||
if ( 'T' === $opts['disable_change'] ) {
|
||||
|
||||
// Disable the WordPress plugin update notifications
|
||||
remove_action('load-update-core.php', 'wp_update_plugins');
|
||||
add_filter('pre_site_transient_update_plugins', '__return_null');
|
||||
// Disable the WordPress plugin update notifications.
|
||||
remove_action( 'load-update-core.php', 'wp_update_plugins' );
|
||||
add_filter( 'pre_site_transient_update_plugins', '__return_null' );
|
||||
|
||||
// Disable the WordPress theme update notifications
|
||||
remove_action('load-update-core.php', 'wp_update_themes');
|
||||
add_filter('pre_site_transient_update_themes', ( $func = function( $a ) {
|
||||
return null;
|
||||
} ));
|
||||
// Disable the WordPress theme update notifications.
|
||||
remove_action( 'load-update-core.php', 'wp_update_themes' );
|
||||
add_filter(
|
||||
'pre_site_transient_update_themes',
|
||||
(
|
||||
$func = function( $a ) {
|
||||
return null;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
// Disable the WordPress core update notifications
|
||||
add_action('after_setup_theme', 'remove_core_updates');
|
||||
// Disable the WordPress core update notifications.
|
||||
add_action( 'after_setup_theme', 'remove_core_updates' );
|
||||
function remove_core_updates() {
|
||||
add_action('init', ( $func = function( $a ) {
|
||||
remove_action( 'wp_version_check', 'wp_version_check' );
|
||||
} ), 2);
|
||||
add_filter('pre_option_update_core', '__return_null');
|
||||
add_filter('pre_site_transient_update_core', '__return_null');
|
||||
add_action(
|
||||
'init',
|
||||
(
|
||||
$func = function( $a ) {
|
||||
remove_action( 'wp_version_check', 'wp_version_check' );
|
||||
}
|
||||
),
|
||||
2
|
||||
);
|
||||
add_filter( 'pre_option_update_core', '__return_null' );
|
||||
add_filter( 'pre_site_transient_update_core', '__return_null' );
|
||||
}
|
||||
|
||||
add_action( 'admin_head', array( &$this, 'admin_head_hide_elements' ), 15 );
|
||||
add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9);
|
||||
add_action( 'admin_menu', array( $this, 'branding_redirect' ), 9 );
|
||||
}
|
||||
|
||||
// to fix
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) ); if ( ! isset($opts['disable_wp_branding']) || $opts['disable_wp_branding'] !== 'Y' ) {
|
||||
add_action( 'admin_menu', array( &$this, 'admin_menu' ) );
|
||||
|
||||
if ( ! isset( $opts['disable_wp_branding'] ) || 'Y' !== $opts['disable_wp_branding'] ) {
|
||||
add_filter( 'wp_footer', array( &$this, 'branding_global_footer' ), 15 );
|
||||
add_action( 'wp_dashboard_setup', array( &$this, 'custom_dashboard_widgets' ), 999 );
|
||||
// branding site generator
|
||||
// branding site generator.
|
||||
$types = array( 'html', 'xhtml', 'atom', 'rss2', 'rdf', 'comment', 'export' );
|
||||
foreach ( $types as $type ) {
|
||||
add_filter( 'get_the_generator_' . $type, array( &$this, 'custom_the_generator' ), 999, 2 );
|
||||
|
@ -460,13 +426,12 @@ class MainWP_Child_Branding {
|
|||
add_filter( 'login_headertext', array( &$this, 'custom_login_headertitle' ) );
|
||||
add_action( 'wp_head', array( &$this, 'custom_favicon_frontend' ) );
|
||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||
// remove_filter( 'update_footer', 'core_update_footer' );
|
||||
add_filter( 'update_footer', array( &$this, 'core_update_footer' ), 14 );
|
||||
add_filter( 'admin_footer_text', array( &$this, 'admin_footer_text' ), 14 );
|
||||
}
|
||||
|
||||
if ( isset( $extra_setting['hide_nag'] ) && ! empty( $extra_setting['hide_nag'] ) ) {
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ));
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
||||
}
|
||||
|
||||
add_action( 'admin_menu', array( &$this, 'remove_default_post_metaboxes' ) );
|
||||
|
@ -474,15 +439,15 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
public function admin_init() {
|
||||
remove_action( 'admin_notices', 'update_nag', 3 );
|
||||
}
|
||||
|
||||
// to fix conflict with other plugin
|
||||
// prevent conflicts with other plugins.
|
||||
function admin_menu() {
|
||||
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||
if ( $allow_contact ) {; // ok
|
||||
$allow_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
|
||||
if ( $allow_contact ) {
|
||||
// skip!
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
@ -497,23 +462,38 @@ class MainWP_Child_Branding {
|
|||
$title = $opts['contact_label'];
|
||||
if ( isset( $extra_setting['show_button_in'] ) && ( 2 === (int) $extra_setting['show_button_in'] || 3 === (int) $extra_setting['show_button_in'] ) ) {
|
||||
$title = $opts['contact_label'];
|
||||
add_menu_page( $title, $title, 'read', 'ContactSupport2', array(
|
||||
$this,
|
||||
'contact_support',
|
||||
), '', '2.0001' );
|
||||
add_menu_page(
|
||||
$title,
|
||||
$title,
|
||||
'read',
|
||||
'ContactSupport2',
|
||||
array(
|
||||
$this,
|
||||
'contact_support',
|
||||
),
|
||||
'',
|
||||
'2.0001'
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset( $extra_setting['show_button_in'] ) && ( 1 === $extra_setting['show_button_in'] || 3 === $extra_setting['show_button_in'] ) ) {
|
||||
add_submenu_page( null, $title, $opts['contact_label'], 'read', 'ContactSupport', array(
|
||||
$this,
|
||||
'contact_support',
|
||||
) );
|
||||
add_submenu_page(
|
||||
null,
|
||||
$title,
|
||||
$opts['contact_label'],
|
||||
'read',
|
||||
'ContactSupport',
|
||||
array(
|
||||
$this,
|
||||
'contact_support',
|
||||
)
|
||||
);
|
||||
add_action( 'admin_bar_menu', array( $this, 'add_support_button_in_top_admin_bar' ), 100 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function remove_default_post_metaboxes() {
|
||||
public function remove_default_post_metaboxes() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
add_filter( 'manage_posts_columns', array( &$this, 'custom_post_columns' ) );
|
||||
|
@ -552,8 +532,7 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
function custom_post_columns( $defaults ) {
|
||||
public function custom_post_columns( $defaults ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
if ( isset( $extra_setting['hide_metabox_post_comments'] ) && $extra_setting['hide_metabox_post_comments'] ) {
|
||||
|
@ -569,7 +548,7 @@ class MainWP_Child_Branding {
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
function manage_my_category_columns( $defaults ) {
|
||||
public function manage_my_category_columns( $defaults ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
if ( isset( $extra_setting['hide_metabox_post_slug'] ) && $extra_setting['hide_metabox_post_slug'] ) {
|
||||
|
@ -579,12 +558,12 @@ class MainWP_Child_Branding {
|
|||
return $defaults;
|
||||
}
|
||||
|
||||
function remove_default_page_metaboxes() {
|
||||
public function remove_default_page_metaboxes() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
add_filter( 'manage_pages_columns', array( &$this, 'custom_pages_columns' ) );
|
||||
|
||||
if ( isset( $extra_setting['hide_metabox_page_custom_fields'] ) && $extra_setting['hide_metabox_page_custom_fields'] ) { // if (get_option('wlcms_o_page_meta_box_custom'))
|
||||
if ( isset( $extra_setting['hide_metabox_page_custom_fields'] ) && $extra_setting['hide_metabox_page_custom_fields'] ) {
|
||||
remove_meta_box( 'postcustom', 'page', 'normal' );
|
||||
}
|
||||
if ( isset( $extra_setting['hide_metabox_page_author'] ) && $extra_setting['hide_metabox_page_author'] ) {
|
||||
|
@ -629,33 +608,34 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
|
||||
function admin_head_hide_elements() {
|
||||
?><script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
document.getElementById("wp-admin-bar-updates").outerHTML = '';
|
||||
document.getElementById("menu-plugins").outerHTML = '';
|
||||
var els_core = document.querySelectorAll("a[href='update-core.php']");
|
||||
for (var i = 0, l = els_core.length; i < l; i++) {
|
||||
public function admin_head_hide_elements() {
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
document.getElementById( "wp-admin-bar-updates" ).outerHTML = '';
|
||||
document.getElementById( "menu-plugins" ).outerHTML = '';
|
||||
var els_core = document.querySelectorAll( "a[href='update-core.php']" );
|
||||
for ( var i = 0, l = els_core.length; i < l; i++ ) {
|
||||
var el = els_core[i];
|
||||
el.parentElement.innerHTML = '';
|
||||
}
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
function core_update_footer() {
|
||||
echo ''; // it clear version text
|
||||
public function core_update_footer() {
|
||||
echo '';
|
||||
}
|
||||
|
||||
function admin_footer_text() {
|
||||
public function admin_footer_text() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['dashboard_footer'] ) && ! empty( $extra_setting['dashboard_footer'] ) ) {
|
||||
echo wp_kses_post( nl2br( stripslashes( $extra_setting['dashboard_footer'] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
function custom_favicon_frontend() {
|
||||
public function custom_favicon_frontend() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['favico_image']['url'] ) && ! empty( $extra_setting['favico_image']['url'] ) ) {
|
||||
$favico = $extra_setting['favico_image']['url'];
|
||||
|
@ -663,18 +643,15 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
|
||||
function custom_login_logo() {
|
||||
public function custom_login_logo() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['login_image']['url'] ) && ! empty( $extra_setting['login_image']['url'] ) ) {
|
||||
$login_logo = $extra_setting['login_image']['url'];
|
||||
echo '<style type="text/css">
|
||||
#login h1 a { background-image: url(\'' . esc_url( $login_logo ) . '\') !important; height:70px !important; width:310px !important; background-size: auto auto !important; }
|
||||
</style>';
|
||||
echo '<style type="text/css">#login h1 a { background-image: url(\'' . esc_url( $login_logo ) . '\') !important; height:70px !important; width:310px !important; background-size: auto auto !important; }</style>';
|
||||
}
|
||||
}
|
||||
|
||||
function custom_login_headerurl( $value ) {
|
||||
|
||||
public function custom_login_headerurl( $value ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['login_image_link'] ) && ! empty( $extra_setting['login_image_link'] ) ) {
|
||||
return $extra_setting['login_image_link'];
|
||||
|
@ -683,8 +660,7 @@ class MainWP_Child_Branding {
|
|||
return $value;
|
||||
}
|
||||
|
||||
function custom_login_headertitle( $value ) {
|
||||
|
||||
public function custom_login_headertitle( $value ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['login_image_title'] ) && ! empty( $extra_setting['login_image_title'] ) ) {
|
||||
return $extra_setting['login_image_title'];
|
||||
|
@ -693,7 +669,7 @@ class MainWP_Child_Branding {
|
|||
return $value;
|
||||
}
|
||||
|
||||
function custom_gettext( $translations, $text, $domain = 'default' ) {
|
||||
public function custom_gettext( $translations, $text, $domain = 'default' ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
$texts_replace = $extra_setting['texts_replace'];
|
||||
if ( is_array( $texts_replace ) && count( $texts_replace ) > 0 ) {
|
||||
|
@ -707,7 +683,7 @@ class MainWP_Child_Branding {
|
|||
return $translations;
|
||||
}
|
||||
|
||||
function custom_admin_css() {
|
||||
public function custom_admin_css() {
|
||||
$header_css = '';
|
||||
$extra_setting = $this->get_extra_options();
|
||||
|
||||
|
@ -729,14 +705,14 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
}
|
||||
|
||||
function custom_login_css() {
|
||||
public function custom_login_css() {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['login_css'] ) && ! empty( $extra_setting['login_css'] ) ) {
|
||||
echo '<style>' . MainWP_Helper::parse_css( $extra_setting['login_css'] ) . '</style>';
|
||||
}
|
||||
}
|
||||
|
||||
function custom_the_generator( $generator, $type = '' ) {
|
||||
public function custom_the_generator( $generator, $type = '' ) {
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['site_generator'] ) ) {
|
||||
if ( ! empty( $extra_setting['site_generator'] ) ) {
|
||||
|
@ -777,7 +753,7 @@ class MainWP_Child_Branding {
|
|||
return $generator;
|
||||
}
|
||||
|
||||
function custom_dashboard_widgets() {
|
||||
public function custom_dashboard_widgets() {
|
||||
global $wp_meta_boxes;
|
||||
$extra_setting = $this->get_extra_options();
|
||||
if ( isset( $extra_setting['remove_widget_welcome'] ) && $extra_setting['remove_widget_welcome'] ) {
|
||||
|
@ -807,14 +783,15 @@ class MainWP_Child_Branding {
|
|||
public function send_support_mail() {
|
||||
$email = $this->child_branding_options['support_email'];
|
||||
$sub = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_subject'] ) ) );
|
||||
$from = trim($_POST['mainwp_branding_contact_send_from']);
|
||||
$from = trim( $_POST['mainwp_branding_contact_send_from'] );
|
||||
$subject = ! empty( $sub ) ? $sub : 'MainWP - Support Contact';
|
||||
$content = wp_kses_post( nl2br( stripslashes( $_POST['mainwp_branding_contact_message_content'] ) ) );
|
||||
$mail = $headers = '';
|
||||
$mail = '';
|
||||
$headers = '';
|
||||
if ( ! empty( $_POST['mainwp_branding_contact_message_content'] ) && ! empty( $email ) ) {
|
||||
global $current_user;
|
||||
$headers .= "Content-Type: text/html;charset=utf-8\r\n";
|
||||
if ( ! empty($from) ) {
|
||||
if ( ! empty( $from ) ) {
|
||||
$headers .= 'From: "' . $from . '" <' . $from . ">\r\n";
|
||||
}
|
||||
$mail .= "<p>Support Email from: <a href='" . site_url() . "'>" . site_url() . "</a></p>\r\n\r\n";
|
||||
|
@ -832,7 +809,7 @@ class MainWP_Child_Branding {
|
|||
return false;
|
||||
}
|
||||
|
||||
function contact_support() {
|
||||
public function contact_support() {
|
||||
global $current_user;
|
||||
?>
|
||||
<style>
|
||||
|
@ -870,17 +847,16 @@ class MainWP_Child_Branding {
|
|||
$send_email_message = __( 'Sending email failed!', 'mainwp-child' );
|
||||
}
|
||||
?>
|
||||
<div
|
||||
class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '  ' . $back_link; ?></div>
|
||||
<?php
|
||||
<div class="mainwp_info-box-yellow"><?php echo esc_html( $send_email_message ) . '  ' . $back_link; ?></div>
|
||||
<?php
|
||||
} else {
|
||||
$from_page = '';
|
||||
if ( isset( $_GET['from_page'] ) ) {
|
||||
$from_page = urldecode( $_GET['from_page'] );
|
||||
$from_page = rawurldecode( $_GET['from_page'] );
|
||||
} else {
|
||||
$protocol = isset( $_SERVER['HTTPS'] ) && strcasecmp( $_SERVER['HTTPS'], 'off' ) ? 'https://' : 'http://';
|
||||
$fullurl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$from_page = urldecode( $fullurl );
|
||||
$from_page = rawurldecode( $fullurl );
|
||||
}
|
||||
|
||||
$support_message = $opts['support_message'];
|
||||
|
@ -890,24 +866,33 @@ class MainWP_Child_Branding {
|
|||
<form action="" method="post">
|
||||
<div style="width: 99%;">
|
||||
<h2><?php echo esc_html( $opts['contact_label'] ); ?></h2>
|
||||
|
||||
<div style="height: auto; margin-bottom: 10px; text-align: left">
|
||||
<p><?php echo wp_kses_post( $support_message ); ?></p>
|
||||
<p><label for="mainwp_branding_contact_message_subject"><?php _e('Subject:', 'mainwp-child'); ?></label><br>
|
||||
<input type="text" id="mainwp_branding_contact_message_subject" name="mainwp_branding_contact_message_subject" style="width: 650px;"></p>
|
||||
<p><label for="mainwp_branding_contact_send_from"><?php _e('From:', 'mainwp-child'); ?></label><br>
|
||||
<input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_html( $from_email ); ?>"></p>
|
||||
<p>
|
||||
<label for="mainwp_branding_contact_message_subject"><?php esc_html_e( 'Subject:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<input type="text" id="mainwp_branding_contact_message_subject" name="mainwp_branding_contact_message_subject" style="width: 650px;">
|
||||
</p>
|
||||
<p>
|
||||
<label for="mainwp_branding_contact_send_from"><?php esc_html_e( 'From:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<input type="text" id="mainwp_branding_contact_send_from" name="mainwp_branding_contact_send_from" style="width: 650px;" value="<?php echo esc_attr( $from_email ); ?>">
|
||||
</p>
|
||||
<div style="max-width: 650px;">
|
||||
<label for="mainwp_branding_contact_message_content"><?php _e('Your message:', 'mainwp-child'); ?></label><br>
|
||||
<label for="mainwp_branding_contact_message_content"><?php esc_html_e( 'Your message:', 'mainwp-child' ); ?></label>
|
||||
<br>
|
||||
<?php
|
||||
remove_editor_styles(); // stop custom theme styling interfering with the editor
|
||||
wp_editor( '', 'mainwp_branding_contact_message_content', array(
|
||||
'textarea_name' => 'mainwp_branding_contact_message_content',
|
||||
'textarea_rows' => 10,
|
||||
'teeny' => true,
|
||||
'wpautop' => true,
|
||||
'media_buttons' => false,
|
||||
)
|
||||
remove_editor_styles(); // stop custom theme styling interfering with the editor.
|
||||
wp_editor(
|
||||
'',
|
||||
'mainwp_branding_contact_message_content',
|
||||
array(
|
||||
'textarea_name' => 'mainwp_branding_contact_message_content',
|
||||
'textarea_rows' => 10,
|
||||
'teeny' => true,
|
||||
'wpautop' => true,
|
||||
'media_buttons' => false,
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
@ -915,14 +900,11 @@ class MainWP_Child_Branding {
|
|||
<br/>
|
||||
<?php
|
||||
$button_title = $opts['submit_button_title'];
|
||||
$button_title = ! empty( $button_title ) ? $button_title : __( 'Submit' );
|
||||
$button_title = ! empty( $button_title ) ? $button_title : __( 'Submit', 'mainwp-child' );
|
||||
?>
|
||||
<input id="mainwp-branding-contact-support-submit" type="submit" name="submit"
|
||||
value="<?php echo esc_attr( $button_title ); ?>"
|
||||
class="button-primary button" style="float: left"/>
|
||||
<input id="mainwp-branding-contact-support-submit" type="submit" name="submit" value="<?php echo esc_attr( $button_title ); ?>" class="button-primary button" style="float: left"/>
|
||||
</div>
|
||||
<input type="hidden" name="mainwp_branding_send_from_page"
|
||||
value="<?php echo esc_url( $from_page ); ?>"/>
|
||||
<input type="hidden" name="mainwp_branding_send_from_page" value="<?php echo esc_url( $from_page ); ?>"/>
|
||||
<input type="hidden" name="_wpnonce" value="<?php echo esc_attr( wp_create_nonce( '_contactNonce' ) ); ?>"/>
|
||||
</form>
|
||||
<?php
|
||||
|
@ -933,18 +915,19 @@ class MainWP_Child_Branding {
|
|||
* @param WP_Admin_Bar $wp_admin_bar
|
||||
*/
|
||||
public function add_support_button_in_top_admin_bar( $wp_admin_bar ) {
|
||||
$allow_contact = apply_filters('mainwp_branding_role_cap_enable_contact_form', false);
|
||||
if ( $allow_contact ) {; // ok
|
||||
$allow_contact = apply_filters( 'mainwp_branding_role_cap_enable_contact_form', false );
|
||||
if ( $allow_contact ) {
|
||||
// skip!
|
||||
} elseif ( ! current_user_can( 'administrator' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( isset( $_GET['from_page'] ) ) {
|
||||
$href = admin_url( 'admin.php?page=ContactSupport&from_page=' . urlencode( esc_url( $_GET['from_page'] ) ) );
|
||||
$href = admin_url( 'admin.php?page=ContactSupport&from_page=' . rawurlencode( esc_url( $_GET['from_page'] ) ) );
|
||||
} else {
|
||||
$protocol = isset( $_SERVER['HTTPS'] ) && strcasecmp( $_SERVER['HTTPS'], 'off' ) ? 'https://' : 'http://';
|
||||
$fullurl = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
$href = admin_url( 'admin.php?page=ContactSupport&from_page=' . urlencode( esc_url( $fullurl ) ) );
|
||||
$href = admin_url( 'admin.php?page=ContactSupport&from_page=' . rawurlencode( esc_url( $fullurl ) ) );
|
||||
}
|
||||
$args = array(
|
||||
'id' => 999,
|
||||
|
@ -963,7 +946,7 @@ class MainWP_Child_Branding {
|
|||
public function is_branding() {
|
||||
$opts = $this->child_branding_options;
|
||||
|
||||
if ( ! isset($opts['branding_ext_enabled']) || $opts['branding_ext_enabled'] !== 'Y' ) {
|
||||
if ( ! isset( $opts['branding_ext_enabled'] ) || 'Y' !== $opts['branding_ext_enabled'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -974,13 +957,15 @@ class MainWP_Child_Branding {
|
|||
if ( $cancelled_branding ) {
|
||||
return false;
|
||||
}
|
||||
// hide
|
||||
|
||||
if ( 'T' === $is_hide ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( is_array( $branding_header ) && ! empty( $branding_header['name'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1002,63 +987,60 @@ class MainWP_Child_Branding {
|
|||
}
|
||||
|
||||
public function after_admin_bar_render() {
|
||||
$hide_slugs = apply_filters( 'mainwp_child_hide_update_notice', array() );
|
||||
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
|
||||
|
||||
if ( ! is_array($hide_slugs) ) {
|
||||
if ( ! is_array( $hide_slugs ) ) {
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
if ( count($hide_slugs) == 0 ) {
|
||||
if ( 0 == count( $hide_slugs ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists('get_plugin_updates') ) {
|
||||
if ( ! function_exists( 'get_plugin_updates' ) ) {
|
||||
include_once ABSPATH . '/wp-admin/includes/update.php';
|
||||
}
|
||||
|
||||
$count_hide = 0;
|
||||
|
||||
$updates = get_plugin_updates();
|
||||
if ( is_array($updates) ) {
|
||||
if ( is_array( $updates ) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array($slug, $hide_slugs) ) {
|
||||
if ( in_array( $slug, $hide_slugs ) ) {
|
||||
$count_hide++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count_hide == 0 ) {
|
||||
if ( 0 == $count_hide ) {
|
||||
return;
|
||||
}
|
||||
// js for front end
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
var $adminBarUpdates = document.querySelector( '#wp-admin-bar-updates .ab-label' ),
|
||||
var mainwpCountHide = <?php echo esc_attr( $count_hide ); ?>;
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
var $adminBarUpdates = document.querySelector( '#wp-admin-bar-updates .ab-label' ),
|
||||
itemCount;
|
||||
|
||||
if (typeof($adminBarUpdates) !== 'undefined' && $adminBarUpdates !== null) {
|
||||
if ( typeof( $adminBarUpdates ) !== 'undefined' && $adminBarUpdates !== null ) {
|
||||
itemCount = $adminBarUpdates.textContent;
|
||||
itemCount = parseInt(itemCount);
|
||||
itemCount = parseInt( itemCount );
|
||||
|
||||
itemCount -= mainwpCountHide;
|
||||
if (itemCount < 0)
|
||||
if ( itemCount < 0 )
|
||||
itemCount = 0;
|
||||
|
||||
$adminBarUpdates.textContent = itemCount;
|
||||
}
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function in_admin_footer() {
|
||||
$hide_slugs = apply_filters( 'mainwp_child_hide_update_notice', array() );
|
||||
|
||||
$hide_slugs = apply_filters('mainwp_child_hide_update_notice', array());
|
||||
|
||||
if ( ! is_array($hide_slugs) ) {
|
||||
if ( ! is_array( $hide_slugs ) ) {
|
||||
$hide_slugs = array();
|
||||
}
|
||||
|
||||
|
@ -1067,38 +1049,36 @@ class MainWP_Child_Branding {
|
|||
$updates = get_plugin_updates();
|
||||
if ( is_array($updates) ) {
|
||||
foreach ( $updates as $slug => $data ) {
|
||||
if ( in_array($slug, $hide_slugs) ) {
|
||||
if ( in_array( $slug, $hide_slugs ) ) {
|
||||
$count_hide++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count_hide == 0 ) {
|
||||
if ( 0 == $count_hide ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// to tweaks counting of update notification display
|
||||
// js for admin end
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var mainwpCountHide = <?php echo esc_attr($count_hide); ?>;
|
||||
document.addEventListener("DOMContentLoaded", function(event) {
|
||||
if (typeof(pagenow) !== 'undefined' && pagenow == 'plugins') {
|
||||
var mainwpCountHide = <?php echo esc_attr( $count_hide ); ?>;
|
||||
document.addEventListener( "DOMContentLoaded", function( event ) {
|
||||
if ( typeof( pagenow ) !== 'undefined' && pagenow == 'plugins' ) {
|
||||
<?php
|
||||
// hide update notice row
|
||||
if ( in_array('mainwp-child/mainwp-child.php', $hide_slugs) ) {
|
||||
// hide update notice row.
|
||||
if ( in_array( 'mainwp-child/mainwp-child.php', $hide_slugs ) ) {
|
||||
?>
|
||||
var el = document.querySelector('tr#mainwp-child-update');
|
||||
if (typeof(el) !== 'undefined' && el !== null) {
|
||||
var el = document.querySelector( 'tr#mainwp-child-update' );
|
||||
if ( typeof( el ) !== 'undefined' && el !== null ) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
<?php
|
||||
}
|
||||
// hide update notice row
|
||||
if ( in_array('mainwp-child-reports/mainwp-child-reports.php', $hide_slugs) ) {
|
||||
// hide update notice row.
|
||||
if ( in_array( 'mainwp-child-reports/mainwp-child-reports.php', $hide_slugs ) ) {
|
||||
?>
|
||||
var el = document.querySelector('tr#mainwp-child-reports-update');
|
||||
if (typeof(el) !== 'undefined' && el !== null) {
|
||||
var el = document.querySelector( 'tr#mainwp-child-reports-update' );
|
||||
if ( typeof( el ) !== 'undefined' && el !== null ) {
|
||||
el.style.display = 'none';
|
||||
}
|
||||
<?php
|
||||
|
@ -1106,36 +1086,35 @@ class MainWP_Child_Branding {
|
|||
?>
|
||||
}
|
||||
|
||||
if (mainwpCountHide > 0) {
|
||||
if ( mainwpCountHide > 0 ) {
|
||||
jQuery( document ).ready( function () {
|
||||
|
||||
var $adminBarUpdates = jQuery( '#wp-admin-bar-updates' ),
|
||||
$pluginsNavMenuUpdateCount = jQuery( 'a[href="plugins.php"] .update-plugins' ),
|
||||
itemCount;
|
||||
var $adminBarUpdates = jQuery( '#wp-admin-bar-updates' ),
|
||||
$pluginsNavMenuUpdateCount = jQuery( 'a[href="plugins.php"] .update-plugins' ),
|
||||
itemCount;
|
||||
itemCount = $adminBarUpdates.find( '.ab-label' ).text();
|
||||
itemCount -= mainwpCountHide;
|
||||
if (itemCount < 0)
|
||||
if ( itemCount < 0 )
|
||||
itemCount = 0;
|
||||
|
||||
itemPCount = $pluginsNavMenuUpdateCount.find( '.plugin-count' ).text();
|
||||
itemPCount -= mainwpCountHide;
|
||||
|
||||
if (itemPCount < 0)
|
||||
if ( itemPCount < 0 )
|
||||
itemPCount = 0;
|
||||
|
||||
$adminBarUpdates.find( '.ab-label' ).text(itemCount);
|
||||
$adminBarUpdates.find( '.ab-label' ).text( itemCount );
|
||||
$pluginsNavMenuUpdateCount.find( '.plugin-count' ).text( itemPCount );
|
||||
|
||||
});
|
||||
} );
|
||||
}
|
||||
});
|
||||
} );
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function branding_map_meta_cap( $caps, $cap, $user_id, $args ) {
|
||||
if ( isset($this->child_branding_options['disable_switching_theme']) && 'T' === $this->child_branding_options['disable_switching_theme'] ) {
|
||||
// disable: theme switching
|
||||
if ( isset( $this->child_branding_options['disable_switching_theme'] ) && 'T' === $this->child_branding_options['disable_switching_theme'] ) {
|
||||
if ( 'switch_themes' === $cap ) {
|
||||
$caps[0] = 'do_not_allow';
|
||||
}
|
||||
|
@ -1145,7 +1124,7 @@ class MainWP_Child_Branding {
|
|||
|
||||
public function modify_plugin_header( $plugins ) {
|
||||
$opts = $this->child_branding_options;
|
||||
if ( is_array($opts) ) {
|
||||
if ( is_array( $opts ) ) {
|
||||
$is_hide = isset( $opts['hide'] ) ? $opts['hide'] : '';
|
||||
$cancelled_branding = $opts['cancelled_branding'];
|
||||
$branding_header = isset( $opts['branding_header'] ) ? $opts['branding_header'] : '';
|
||||
|
@ -1154,7 +1133,7 @@ class MainWP_Child_Branding {
|
|||
return $plugins;
|
||||
}
|
||||
|
||||
if ( $is_hide === 'T' ) {
|
||||
if ( 'T' === $is_hide ) {
|
||||
foreach ( $plugins as $key => $value ) {
|
||||
$plugin_slug = basename( $key, '.php' );
|
||||
if ( 'mainwp-child' === $plugin_slug ) {
|
||||
|
@ -1174,13 +1153,12 @@ class MainWP_Child_Branding {
|
|||
return $plugins;
|
||||
}
|
||||
|
||||
function hide_update_notice( $slugs ) {
|
||||
public function hide_update_notice( $slugs ) {
|
||||
$slugs[] = 'mainwp-child/mainwp-child.php';
|
||||
return $slugs;
|
||||
}
|
||||
|
||||
|
||||
function remove_update_nag( $value ) {
|
||||
public function remove_update_nag( $value ) {
|
||||
if ( isset( $_POST['mainwpsignature'] ) ) {
|
||||
return $value;
|
||||
}
|
||||
|
@ -1219,4 +1197,3 @@ class MainWP_Child_Branding {
|
|||
return $plugins;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue