$post_id) { if(!get_post_status($post_id)) { unset($options[$category][$type][$script]['current'][$key]); } } //clean up the options array before saving perfmatters_script_manager_filter_options($options); update_option('perfmatters_script_manager', $options); } } //load script manager settings global $perfmatters_script_manager_settings; $perfmatters_script_manager_settings = get_option('perfmatters_script_manager_settings'); //build array of existing plugin disables global $perfmatters_disables; $perfmatters_disables = array(); if(!empty($perfmatters_options['disable_google_maps'])) { $perfmatters_disables[] = 'maps.google.com'; $perfmatters_disables[] = 'maps.googleapis.com'; $perfmatters_disables[] = 'maps.gstatic.com'; } if(!empty($perfmatters_options['disable_google_fonts'])) { $perfmatters_disables[] = 'fonts.googleapis.com'; } //setup filters array global $perfmatters_filters; $perfmatters_filters = array( "js" => array ( "title" => "JS", "scripts" => $wp_scripts ), "css" => array( "title" => "CSS", "scripts" => $wp_styles ) ); //load script manager options global $perfmatters_script_manager_options; $perfmatters_script_manager_options = get_option('perfmatters_script_manager'); //load styles include('script_manager_css.php'); //disable shortcodes remove_all_shortcodes(); //wrapper echo "
"; //header echo "
"; echo "
"; //menu toggle echo ""; //logo echo ""; echo "
"; //main navigation echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo "
"; //main container echo "
"; //visible container echo "
"; echo '
'; //disclaimer if(empty($perfmatters_script_manager_settings['hide_disclaimer'])) { echo '
'; echo '
'; echo $pmsm_tab != 'main' ? '' : ''; wp_nonce_field('pmsm_disclaimer_close', 'pmsm_disclaimer_close_nonce'); echo ''; echo '
'; _e('We recommend testing Script Manager changes on a staging/dev site first, as you could break your site\'s appearance.', 'perfmatters'); echo ' ' . __('View Documentation', 'perfmatters') . ''; echo '
'; } //testing mode if(!empty($perfmatters_script_manager_settings['testing_mode'])) { echo '
' . __('You are in Testing Mode. Changes will only be visible to logged-in admins.') . '
'; } echo '
'; //universal form echo "
"; //content container echo "
"; //main tab if($pmsm_tab == 'main') { //title bar echo "
"; echo "

" . __('Script Manager', 'perfmatters') . "

"; echo "

" . __('Manage scripts loading on the current page.', 'perfmatters') . "

"; echo "
"; //load master array global $master_array; $master_array = perfmatters_script_manager_load_master_array(); //print scripts foreach($master_array['resources'] as $category => $groups) { echo '
'; if(!empty($groups)) { echo "

" . $category . "

"; if($category != "misc") { echo "
"; foreach($groups as $group => $details) { echo "
"; echo "
"; echo "

" . (!empty($details['name']) ? $details['name'] : "") . "

"; //Status echo "
"; if(!empty($details['size'])) { echo "" . __('Total size', 'perfmatters') . ": " . round($details['size'] / 1024, 1) . " KB"; } perfmatters_script_manager_print_status($category, $group); echo "
"; echo "
"; $assets = !empty($details['assets']) ? $details['assets'] : false; perfmatters_script_manager_print_section($category, $group, $assets); echo "
"; } echo "
"; } else { if(!empty($groups['assets'])) { perfmatters_script_manager_print_section($category, $category, $groups['assets']); } } } echo '
'; } //loading wrapper echo "
"; if(function_exists('is_amp_endpoint') && is_amp_endpoint()) { echo "" . __('The Script Manager does not support AMP pages.', 'perfmatters') . ""; } else { echo "" . __('Loading Scripts', 'perfmatters') . ""; } echo "
"; } //global view tab elseif($pmsm_tab == 'global') { include('script_manager_global.php'); } //settings tab elseif($pmsm_tab == 'settings') { //title bar echo "
"; echo "

" . __('Settings', 'perfmatters') . "

"; echo "

" . __('View and manage all of your Script Manager settings.', 'perfmatters') . "

"; echo "
"; //settings container echo "
"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
" . perfmatters_title(__('Display Archives', 'perfmatters'), 'separate_archives') . ""; $args = array( 'id' => 'separate_archives', 'option' => 'perfmatters_script_manager_settings' ); perfmatters_print_input($args); echo "
" . __('Add WordPress archives to your Script Manager selection options. Archive posts will no longer be grouped with their post type.', 'perfmatters') . "
"; echo "
" . perfmatters_title(__('Display Dependencies', 'perfmatters'), 'separate_archives') . ""; $args = array( 'id' => 'dependencies', 'option' => 'perfmatters_script_manager_settings' ); perfmatters_print_input($args); echo "
" . __('Show dependencies for each script.', 'perfmatters') . "
"; echo "
" . perfmatters_title(__('Testing Mode', 'perfmatters'), 'testing_mode') . ""; $args = array( 'id' => 'testing_mode', 'option' => 'perfmatters_script_manager_settings' ); perfmatters_print_input($args); echo "
" . __('Restrict your Script Manager configuration to logged-in admins only.', 'perfmatters') . ' ' . __('View Documentation', 'perfmatters') . '' . "
"; echo "
" . perfmatters_title(__('MU Mode', 'perfmatters'), 'mu_mode') . ""; $args = array( 'id' => 'mu_mode', 'option' => 'perfmatters_script_manager_settings' ); perfmatters_print_input($args); echo "
" . __('Must-use (MU) mode requires elevated permissions and a file to be copied into the mu-plugins directory. This gives you more control and the ability to disable plugin queries, inline CSS, etc.', 'perfmatters') . ' ' . __('View Documentation', 'perfmatters') . '' . "
"; echo "
" . __('Warning', 'perfmatters') . ": " . __('Any previous plugin-level disables will now disable the entire plugin. Please review your existing Script Manager configuration before enabling this option.', 'perfmatters') . "
"; //mu plugin file check if(!empty($perfmatters_script_manager_settings['mu_mode'])) { if(file_exists(WPMU_PLUGIN_DIR . "/perfmatters_mu.php")) { //$mu_plugins = get_mu_plugins(); if(!function_exists('get_plugin_data')) { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); } //get plugin data $mu_plugin_data = get_plugin_data(WPMU_PLUGIN_DIR . "/perfmatters_mu.php"); if(empty($mu_plugin_data['Version']) || !defined('PERFMATTERS_VERSION') || ($mu_plugin_data['Version'] != PERFMATTERS_VERSION)) { $mu_message = __("MU plugin version mismatch.", 'perfmatters'); $mu_class = "pmsm-mu-mismatch"; } else { $mu_message = __("MU plugin installed.", 'perfmatters'); $mu_class = "pmsm-mu-found"; } } else { $mu_message = __("MU plugin file not found.", 'perfmatters'); $mu_class = "pmsm-mu-missing"; } echo "
" . $mu_message . "
"; } echo "
" . perfmatters_title(__('Hide Disclaimer', 'perfmatters'), 'hide_disclaimer') . ""; $args = array( 'id' => 'hide_disclaimer', 'option' => 'perfmatters_script_manager_settings' ); perfmatters_print_input($args); echo "
" . __('Hide the disclaimer message box across all Script Manager views.', 'perfmatters') . "
"; echo "
" . perfmatters_title(__('Reset Script Manager', 'perfmatters'), 'reset_script_manager') . ""; //Reset Form echo "
"; echo ""; echo "
"; echo "
"; echo "" . __('Remove and reset all of your existing Script Manager settings.', 'perfmatters') . ""; echo "
"; echo "
"; //Nonce wp_nonce_field('perfmatter_script_manager_save_settings', 'perfmatters_script_manager_settings_nonce'); echo "
"; } echo "
"; //toolbar echo "
"; echo "
"; echo "
"; //save button echo "
"; if($pmsm_tab != 'global') { echo ""; echo ""; } echo "
"; //copyright echo ""; echo "
"; //message echo "
"; echo "
"; echo "
"; echo "
"; echo "
"; //hidden reset form if($pmsm_tab == 'settings') { echo "
"; echo ""; echo ""; echo "
"; } echo "
"; echo "
";