| @@ -1,115 +1,39 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: plugin load filter |
| 4 | 4 | Description: Dynamically activate the selected plugins for each page. Response will be faster by filtering plugins. |
| 5 | - Version: 4.3.0 | |
| 6 | - Plugin URI: https://celtislab.net/en/wp-plugin-load-filter | |
| 5 | + Version: 2.3.1 | |
| 6 | + Plugin URI: http://celtislab.net/wp_plugin_load_filter | |
| 7 | 7 | Author: enomoto@celtislab |
| 8 | - Author URI: https://celtislab.net/ | |
| 9 | - Requires at least: 6.0 | |
| 10 | - Tested up to: 6.8 | |
| 11 | - Requires PHP: 8.1 | |
| 8 | + Author URI: http://celtislab.net/ | |
| 12 | 9 | License: GPLv2 |
| 13 | 10 | Text Domain: plf |
| 14 | 11 | Domain Path: /languages |
| 15 | 12 | */ |
| 16 | 13 | |
| 17 | -defined( 'ABSPATH' ) || exit; | |
| 18 | - | |
| 19 | -/*************************************************************************** | |
| 20 | - * plugin activation / deactivation / uninstall | |
| 21 | - **************************************************************************/ | |
| 22 | -if(is_admin()){ | |
| 23 | - //deactivation | |
| 24 | - function plugin_load_filter_deactivation( $network_deactivating ) { | |
| 25 | - $act = false; | |
| 26 | - if (is_multisite()) { | |
| 27 | - if(! $network_deactivating){ | |
| 28 | - global $wpdb; | |
| 29 | - $current_blog_id = get_current_blog_id(); | |
| 30 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); | |
| 31 | - foreach ( $blog_ids as $blog_id ) { | |
| 32 | - if($blog_id == $current_blog_id){ | |
| 33 | - //current site | |
| 34 | - } | |
| 35 | - else { | |
| 36 | - //other site active check | |
| 37 | - switch_to_blog( $blog_id ); | |
| 38 | - if ( is_plugin_active( plugin_basename( __FILE__ ))) | |
| 39 | - $act = true; | |
| 40 | - } | |
| 41 | - } | |
| 42 | - switch_to_blog( $current_blog_id ); | |
| 43 | - } | |
| 44 | - } | |
| 45 | - if($act === false){ | |
| 46 | - flush_rewrite_rules(); //options data 'rewrite_rules' clear for remake. | |
| 47 | - if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { | |
| 48 | - @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' ); | |
| 49 | - } | |
| 50 | - } | |
| 51 | - } | |
| 52 | - register_deactivation_hook( __FILE__, 'plugin_load_filter_deactivation' ); | |
| 53 | - | |
| 54 | - //uninstall | |
| 55 | - function plugin_load_filter_uninstall() { | |
| 56 | - | |
| 57 | - if ( !is_multisite()) { | |
| 58 | - delete_option('plf_queryvars'); | |
| 59 | - delete_option('plf_option' ); | |
| 60 | - delete_option('plf_addon_options'); | |
| 61 | - } else { | |
| 62 | - global $wpdb; | |
| 63 | - $current_blog_id = get_current_blog_id(); | |
| 64 | - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" ); | |
| 65 | - foreach ( $blog_ids as $blog_id ) { | |
| 66 | - switch_to_blog( $blog_id ); | |
| 67 | - delete_option('plf_queryvars'); | |
| 68 | - delete_option('plf_option' ); | |
| 69 | - delete_option('plf_addon_options'); | |
| 70 | - } | |
| 71 | - switch_to_blog( $current_blog_id ); | |
| 72 | - } | |
| 73 | - if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { | |
| 74 | - @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' ); | |
| 75 | - } | |
| 76 | - } | |
| 77 | - register_uninstall_hook(__FILE__, 'plugin_load_filter_uninstall'); | |
| 78 | - | |
| 79 | -} | |
| 80 | - | |
| 81 | 14 | $Plf_setting = new Plf_setting(); |
| 82 | 15 | |
| 83 | 16 | class Plf_setting { |
| 84 | 17 | |
| 85 | - static $plugins_inf = ''; //active plugin/module infomation | |
| 86 | - static $filter = array(); //filter option data | |
| 18 | + private $plugins_inf = ''; //active plugin/module infomation | |
| 19 | + private $filter = array(); //filter option data | |
| 87 | 20 | private $tab_num = 0; |
| 88 | - | |
| 21 | + | |
| 89 | 22 | /*************************************************************************** |
| 90 | 23 | * Style Sheet |
| 91 | 24 | **************************************************************************/ |
| 92 | 25 | function plf_css() { ?> |
| 93 | 26 | <style type="text/css"> |
| 94 | - #plugin-filter-select {margin-top: 12px;} | |
| 95 | - #plugin-filter-select p {margin: 1em 0;} | |
| 96 | - #page-filter-stat { margin-top: 12px;} | |
| 97 | - #activation-table { padding-bottom: 8px; border: 1px solid #eee;} | |
| 98 | - #activation-table th { text-align: center;} | |
| 99 | - #activation-table td { font-size: 97%;} | |
| 27 | + #activation-table { margin-top: 10px; border: 1px solid #eee;} | |
| 100 | 28 | #activation-table input[type=checkbox] { height: 25px; width: 25px; opacity: 0;} |
| 101 | - #plf-post-locale-select { margin-top: 16px;} | |
| 102 | 29 | thead .plugins-name { background-color: aliceblue;} |
| 103 | 30 | thead .device-type { background-color: oldlace;} |
| 104 | - thead .plugins-name, tbody .plugins-name { min-width: 144px; max-width: 200px; padding: 3px 3px 3px 5px;} | |
| 105 | - thead .device-type, tbody .device-type { min-width: 40px; max-width: 40px; text-align: center; padding: 5px 1px 2px;} | |
| 31 | + thead .plugins-name, tbody .plugins-name { min-width: 172px; max-width: 172px;} | |
| 32 | + thead .device-type, tbody .device-type { min-width: 36px; max-width: 36px; padding: 0;} | |
| 106 | 33 | .dashicons-yes:before { font-size: 20px; border: 1px solid #eee; background-color: whitesmoke;} |
| 107 | - .device-type label { color: whitesmoke; } | |
| 108 | - input.altcheckbox[type="checkbox"] { -webkit-appearance: none; appearance: none; position: absolute;} | |
| 109 | - .device-type input.altcheckbox[type="checkbox"]:checked + span.dashicons-yes:before { background-color: yellowgreen; } | |
| 110 | - .plf-option-info { font-size:12px; margin:10px 0; padding:3px; background-color:#fff8e5;} | |
| 111 | - .edit-post-locale-link span.dashicons { width: 0.8em; height: 0.8em; margin: -0.4em 0.1em 0; vertical-align: middle; text-decoration: initial;} | |
| 34 | + .device-type label { color: whitesmoke; margin-left: -28px; } | |
| 35 | + .device-type input[type="checkbox"]:checked + label .dashicons-yes:before { background-color: yellowgreen; } | |
| 112 | 36 | </style> |
| 113 | 37 | <?php } |
| 114 | 38 | |
| 115 | 39 | function jquery_tab_css() { ?> |
| @@ -131,49 +55,36 @@ | ||
| 131 | 55 | .ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #dddddd; background-color: #0073ea; font-weight: bold; color: #ffffff; } |
| 132 | 56 | .ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, .ui-state-hover a:visited { color: #ffffff; text-decoration: none; } |
| 133 | 57 | .ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #ffffff; text-decoration: none; } |
| 134 | 58 | |
| 135 | - #wrap_registration-table, #wrap_activation-table { overflow:auto; height:600px; position: relative;} | |
| 136 | - #registration-table input[type=radio], #registration-table input[type=checkbox], #activation-table input[type=checkbox] { height: 25px; width: 25px; opacity: 0;} | |
| 137 | - #registration-table th {text-align: center;} | |
| 59 | + #wrap_registration-table, #wrap_activation-table { overflow-x:auto;} | |
| 60 | + #registration-table input[type=radio], #activation-table input[type=checkbox] { height: 25px; width: 25px; opacity: 0;} | |
| 138 | 61 | thead, tbody { display: block;} |
| 139 | - .widefat * { word-wrap: break-word !important;} | |
| 140 | - .widefat thead { position:sticky; top:0px; z-index:1;} | |
| 141 | - .widefat tr:first-of-type th:first-of-type {position: sticky; left: 0px; text-align: left; background-color: aliceblue; z-index:3;} | |
| 142 | - .widefat th { padding: 8px;} | |
| 143 | - .widefat td { padding: 8px;} | |
| 144 | - .widefat td:first-of-type { position: sticky; left: 0px; text-align: left; background-color: white;} | |
| 62 | + .plugins-table-body { overflow-y:scroll; height:500px; } | |
| 63 | + .widefat td, .widefat th { padding: 8px 4px;} | |
| 145 | 64 | thead .filter-plugins-name, thead .plugins-name { background-color: aliceblue;} |
| 146 | - thead .urlfilter { background-color: lavenderblush;} | |
| 147 | - .filter-none, .filter-admin, .filter-tmpl { background-color: honeydew;} | |
| 65 | + .filter-none, .filter-admin, .filter-tmpl { background-color: oldlace;} | |
| 148 | 66 | thead .device-type { background-color: oldlace;} |
| 149 | - thead .ckbox-type { background-color: lavender;} | |
| 67 | + thead .tmpl-type { background-color: lavender;} | |
| 150 | 68 | thead .pformat { background-color: honeydew;} |
| 151 | 69 | thead .tmpl-embed { background-color: lightyellow;} |
| 152 | 70 | thead .tmpl-custom { background-color: lavenderblush;} |
| 153 | - thead .filter-plugins-name, tbody .filter-plugins-name { min-width: 240px; max-width: 240px;} | |
| 71 | + thead .filter-plugins-name, tbody .filter-plugins-name { min-width: 260px; max-width: 260px;} | |
| 154 | 72 | thead .plugins-name, tbody .plugins-name { min-width: 180px; max-width: 180px;} |
| 155 | - thead .device-type, tbody .device-type, thead .ckbox-type, tbody .ckbox-type, thead .deny-type, tbody .deny-type { min-width: 40px; max-width: 40px; text-align: center;} | |
| 156 | - thead .filter-type, tbody .filter-type { min-width: 56px; max-width: 56px; text-align:center;} | |
| 157 | - .urlfilter-description { padding: 0 10px 15px;} | |
| 158 | - .grid-row { display: flex; flex-flow: row wrap;} | |
| 159 | - .filter-description { padding: 0 10px; width:62%;} | |
| 160 | - .side-info { width: 30%; padding-left: 24px;} | |
| 161 | - .exclude-pformat { padding: 5px 0 20px} | |
| 73 | + thead .filter-type, tbody .filter-type { min-width: 100px; max-width: 100px;} | |
| 74 | + thead .device-type, tbody .device-type, thead .tmpl-type, tbody .tmpl-type { min-width: 40px; max-width: 40px; } | |
| 75 | + .filter-description { padding: 0 10px 20px 10px;} | |
| 76 | + .exclude-pformat { padding: 16px 0 20px} | |
| 162 | 77 | .exclude-pformat label { white-space:nowrap;} |
| 163 | 78 | .exclude-pformat span { margin-right: 12px; } |
| 164 | 79 | .dashicons:before { font-size: 24px; } |
| 165 | - .radio-green label, .radio-red label { color: #ddd; margin-left: -32px; } | |
| 166 | - .ckbox-type label { color: #ddd;} | |
| 167 | - .radio-green input[type="radio"]:checked + span { color: #8bc34a; } | |
| 168 | - .radio-red input[type="radio"]:checked + span { color: tomato; } | |
| 169 | - .ckbox-type input[type="checkbox"]:checked + span { color: #4caf50; } | |
| 170 | - /* .dashicons-dismiss:before { background-color: yellowgreen; font-size: 20px; border-radius: 12px; } */ | |
| 171 | - .deny-type label { color: #4caf50;} | |
| 172 | - .deny-type input.altcheckbox[type="checkbox"]:checked + span { color: #ddd; } | |
| 173 | - .dashicons-yes:before { font-size: 20px; border: 1px solid #eee; } | |
| 174 | - .device-type input.altcheckbox[type="checkbox"]:checked + span.dashicons-yes:before { background-color: yellowgreen; } | |
| 175 | - .option-item { margin-bottom: 28px; } | |
| 80 | + .radio-green label, .radio-red label, .tmpl-type label { color: #ddd; margin-left: -28px; } | |
| 81 | + .radio-green input[type="radio"]:checked + label { color: #339966; } | |
| 82 | + .radio-red input[type="radio"]:checked + label { color: #ff0000; } | |
| 83 | + .tmpl-type input[type="checkbox"]:checked + label { color: #339966; } | |
| 84 | + .dashicons-yes:before { font-size: 20px; border: 1px solid #eee; background-color: whitesmoke;} | |
| 85 | + .device-type label { color: whitesmoke; margin-left: -28px; } | |
| 86 | + .device-type input[type="checkbox"]:checked + label .dashicons-yes:before { background-color: yellowgreen; } | |
| 176 | 87 | </style> |
| 177 | 88 | <?php } |
| 178 | 89 | |
| 179 | 90 | /*************************************************************************** |
| @@ -180,104 +91,109 @@ | ||
| 180 | 91 | * Plugin Load Filter Option Setting |
| 181 | 92 | **************************************************************************/ |
| 182 | 93 | |
| 183 | 94 | public function __construct() { |
| 184 | - | |
| 185 | - add_action('init', function(){ load_plugin_textdomain('plf', false, basename( dirname( __FILE__ ) ).'/languages' ); }, 1); | |
| 186 | 95 | |
| 187 | - self::$filter = get_option('plf_option', array()); | |
| 188 | - if(empty(self::$filter['optver']) || self::$filter['optver'] < '2'){ | |
| 189 | - self::$filter['optver'] = '2'; | |
| 190 | - //ここにデータフォーマットが変わった場合の変換処理を記述 | |
| 96 | + load_plugin_textdomain('plf', false, basename( dirname( __FILE__ ) ).'/languages' ); | |
| 97 | + | |
| 98 | + $this->filter = get_option('plf_option'); | |
| 99 | + //v2.3.0 option change | |
| 100 | + if(empty($this->filter['optver']) || $this->filter['optver'] < '2'){ | |
| 101 | + $this->filter['optver'] = '2'; | |
| 102 | + | |
| 103 | + if(empty($this->filter['group']['desktop']) && empty($this->filter['group']['mobile'])){ | |
| 104 | + //For ver2.2.0 compatibility, set '_pagefilter' data to 'desktop' and 'mobile' | |
| 105 | + if(!empty($this->filter['_pagefilter'])){ | |
| 106 | + $this->filter['group']['desktop'] = $this->filter['_pagefilter']; | |
| 107 | + $this->filter['group']['mobile'] = $this->filter['_pagefilter']; | |
| 108 | + } | |
| 109 | + if(!empty($this->filter['_desktop'])){ | |
| 110 | + $this->filter['_desktop'] = null; | |
| 111 | + } | |
| 112 | + if(!empty($this->filter['_mobile'])){ | |
| 113 | + $this->filter['_mobile'] = null; | |
| 114 | + } | |
| 115 | + } | |
| 191 | 116 | } |
| 192 | - if(!empty(self::$filter['language'])){ | |
| 193 | - add_action( 'wp_head', array('Plf_setting', 'altenate_hreflang') ); | |
| 194 | - } | |
| 195 | - | |
| 117 | + | |
| 196 | 118 | if(is_admin()) { |
| 197 | 119 | add_action( 'plugins_loaded', array(&$this, 'plf_admin_start'), 9999 ); |
| 198 | - add_action( 'admin_init', array(&$this, 'action_posts')); | |
| 199 | 120 | add_action( 'add_meta_boxes', array(&$this, 'load_meta_boxes'), 10, 2 ); |
| 121 | + //plf-filter must-use plagin activete check | |
| 122 | + if(wp_mkdir_p( WPMU_PLUGIN_DIR )){ | |
| 123 | + if ( !file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { | |
| 124 | + @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php'); | |
| 125 | + } | |
| 126 | + else { | |
| 127 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); | |
| 128 | + $dp = get_plugin_data( WPMU_PLUGIN_DIR . "/plf-filter.php", false, false ); | |
| 129 | + $sp = get_plugin_data( __DIR__ . '/mu-plugins/plf-filter.php', false, false ); | |
| 130 | + if(version_compare( $dp['Version'], $sp['Version'], '!=')){ | |
| 131 | + @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php'); | |
| 132 | + } | |
| 133 | + } | |
| 134 | + } | |
| 135 | + register_deactivation_hook( __FILE__, 'Plf_setting::deactivation' ); | |
| 136 | + register_uninstall_hook(__FILE__, 'Plf_setting::uninstall'); | |
| 200 | 137 | } |
| 201 | 138 | add_action( 'wp_ajax_plugin_load_filter', array(&$this, 'plf_ajax_postidfilter')); |
| 202 | 139 | } |
| 203 | 140 | |
| 141 | + //Plugin Deactivate | |
| 142 | + public static function deactivation() { | |
| 143 | + if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { | |
| 144 | + @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' ); | |
| 145 | + } | |
| 146 | + } | |
| 147 | + //Plugin Uninstall | |
| 148 | + public static function uninstall() { | |
| 149 | + delete_option('plf_queryvars'); | |
| 150 | + delete_option('plf_option' ); | |
| 151 | + } | |
| 152 | + | |
| 204 | 153 | //Plugin Load Filter admin setting start |
| 205 | 154 | public function plf_admin_start() { |
| 206 | 155 | require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
| 207 | 156 | |
| 208 | - self::$plugins_inf = get_plugins(); | |
| 209 | - //Ver4.0.0 でしか呼び出せないメソッドを呼び出さないよう新設した switch_theme があるかどうかで判定 | |
| 210 | - if(method_exists('Plf_filter', 'switch_theme')){ | |
| 211 | - if(class_exists('Plf_filter')){ | |
| 212 | - if ( is_multisite() ) | |
| 213 | - remove_filter('pre_site_option_active_sitewide_plugins', array('Plf_filter', 'active_sitewide_plugins')); | |
| 214 | - remove_filter('pre_option_active_plugins', array('Plf_filter', 'active_plugins')); | |
| 157 | + $this->plugins_inf = get_plugins(); | |
| 158 | + $packplug = array(); | |
| 159 | + foreach ( $this->plugins_inf as $plugin_key => $a_plugin ) { | |
| 160 | + if(is_plugin_inactive( $plugin_key )){ | |
| 161 | + unset($this->plugins_inf[$plugin_key]); | |
| 215 | 162 | } |
| 216 | - foreach ( self::$plugins_inf as $plugin_key => $a_plugin ) { | |
| 217 | - if(is_plugin_inactive( $plugin_key )){ | |
| 218 | - unset(self::$plugins_inf[$plugin_key]); | |
| 163 | + } | |
| 164 | + //jetpack active module | |
| 165 | + if(method_exists('Jetpack', 'get_module')){ | |
| 166 | + $modules = Jetpack::get_active_modules(); | |
| 167 | + $modules = array_diff( $modules, array( 'vaultpress' ) ); | |
| 168 | + foreach ( $modules as $key => $module_name ) { | |
| 169 | + if(!empty($module_name)){ | |
| 170 | + $module = Jetpack::get_module( $module_name ); | |
| 171 | + if(!empty($module)) | |
| 172 | + $this->plugins_inf['jetpack_module/' . $module_name] = $module; | |
| 219 | 173 | } |
| 220 | 174 | } |
| 221 | - if(class_exists('Plf_filter')){ | |
| 222 | - if ( is_multisite() ) | |
| 223 | - add_filter('pre_site_option_active_sitewide_plugins', array('Plf_filter', 'active_sitewide_plugins')); | |
| 224 | - add_filter('pre_option_active_plugins', array('Plf_filter', 'active_plugins')); | |
| 225 | - } | |
| 226 | - | |
| 227 | - //jetpack active module | |
| 228 | - if(method_exists('Jetpack', 'get_module')){ | |
| 229 | - if(class_exists('Plf_filter')){ | |
| 230 | - remove_filter('pre_option_jetpack_active_modules', array('Plf_filter', 'active_jetmodules')); | |
| 175 | + } | |
| 176 | + //celtispack active module | |
| 177 | + if(method_exists('Celtispack', 'get_module')){ | |
| 178 | + $modules = Celtispack::get_active_modules(); | |
| 179 | + foreach ( $modules as $key => $module_name ) { | |
| 180 | + if(!empty($module_name)){ | |
| 181 | + $this->plugins_inf['celtispack_module/' . $module_name] = Celtispack::get_module( $module_name ); | |
| 231 | 182 | } |
| 232 | - $modules = Jetpack::get_active_modules(); | |
| 233 | - $modules = array_diff( $modules, array( 'vaultpress' ) ); | |
| 234 | - foreach ( $modules as $key => $module_name ) { | |
| 235 | - if(!empty($module_name)){ | |
| 236 | - $module = Jetpack::get_module( $module_name ); | |
| 237 | - if(!empty($module)) | |
| 238 | - self::$plugins_inf['jetpack_module/' . $module_name] = $module; | |
| 239 | - } | |
| 240 | - } | |
| 241 | - if(class_exists('Plf_filter')){ | |
| 242 | - add_filter('pre_option_jetpack_active_modules', array('Plf_filter', 'active_jetmodules')); | |
| 243 | - } | |
| 244 | 183 | } |
| 245 | - //celtispack active module | |
| 246 | - if(method_exists('Celtispack', 'get_module')){ | |
| 247 | - if(class_exists('Plf_filter')){ | |
| 248 | - remove_filter('pre_option_celtispack_active_modules', array('Plf_filter', 'active_celtismodules')); | |
| 249 | - } | |
| 250 | - $modules = Celtispack::get_active_modules(); | |
| 251 | - foreach ( $modules as $key => $module_name ) { | |
| 252 | - if(!empty($module_name)){ | |
| 253 | - self::$plugins_inf['celtispack_module/' . $module_name] = Celtispack::get_module( $module_name ); | |
| 254 | - } | |
| 255 | - } | |
| 256 | - if(class_exists('Plf_filter')){ | |
| 257 | - add_filter('pre_option_celtispack_active_modules', array('Plf_filter', 'active_celtismodules')); | |
| 258 | - } | |
| 259 | - } | |
| 260 | - if ( empty( self::$plugins_inf ) ) | |
| 261 | - return; | |
| 262 | 184 | } |
| 185 | + if ( empty( $this->plugins_inf ) ) | |
| 186 | + return; | |
| 263 | 187 | |
| 188 | + $this->action_posts(); //POST, GET Request Action | |
| 264 | 189 | add_action('admin_menu', array(&$this, 'plf_option_menu')); |
| 265 | 190 | } |
| 266 | 191 | |
| 267 | - static function get_plugins_inf() { | |
| 268 | - $inf = (!empty(self::$plugins_inf))? self::$plugins_inf : false; | |
| 269 | - return $inf; | |
| 270 | - } | |
| 271 | - | |
| 272 | 192 | //Plugins sub menu add |
| 273 | 193 | public function plf_option_menu() { |
| 274 | - if(current_user_can( 'activate_plugins' )){ | |
| 275 | - $page = add_menu_page( 'Plugin Load FIlter Settings', esc_html__('Plugin Load Filter', 'plf'), 'manage_options', 'plugin_load_filter_admin_manage_page', array(&$this, 'plf_option_page'), 'dashicons-filter', '65.1'); | |
| 276 | - add_submenu_page( 'plugin_load_filter_admin_manage_page', 'Plugin Load FIlter Settings', esc_html__('General Settings', 'plf'), 'manage_options', 'plugin_load_filter_admin_manage_page', array(&$this, 'plf_option_page') ); | |
| 277 | - add_action( 'admin_print_scripts-'.$page, array(&$this, 'plf_scripts') ); | |
| 278 | - add_action( 'admin_print_scripts-'.$page, array(&$this, 'deploy_mu_plugins')); | |
| 279 | - } | |
| 194 | + $page = add_plugins_page( 'Plugin Load Filter', __('Plugin Load Filter', 'plf'), 'manage_options', 'plugin_load_filter_admin_manage_page', array(&$this,'plf_option_page')); | |
| 195 | + add_action('admin_print_scripts-'.$page, array(&$this, 'plf_scripts')); | |
| 280 | 196 | } |
| 281 | 197 | |
| 282 | 198 | //Plugin Load Filter setting page script |
| 283 | 199 | function plf_scripts() { |
| @@ -287,62 +203,16 @@ | ||
| 287 | 203 | wp_enqueue_script( 'jquery-ui-tabs' ); |
| 288 | 204 | add_action( 'admin_head', array(&$this, 'plf_css' )); |
| 289 | 205 | add_action( 'admin_head', array(&$this, 'jquery_tab_css' )); |
| 290 | 206 | add_action( 'admin_footer', array(&$this, 'activetab_script' )); |
| 291 | - add_action( 'admin_notices', array('Plf_setting', 'plf_notice')); | |
| 292 | 207 | } |
| 293 | - | |
| 294 | - //plf-filter.php mu-plugins module set | |
| 295 | - public function deploy_mu_plugins() { | |
| 296 | - if(wp_mkdir_p( WPMU_PLUGIN_DIR )){ | |
| 297 | - if ( !file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { | |
| 298 | - @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php'); | |
| 299 | - } | |
| 300 | - else { | |
| 301 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); | |
| 302 | - $dp = get_plugin_data( WPMU_PLUGIN_DIR . "/plf-filter.php", false, false ); | |
| 303 | - $sp = get_plugin_data( __DIR__ . '/mu-plugins/plf-filter.php', false, false ); | |
| 304 | - if(version_compare( $dp['Version'], $sp['Version'], '!=')){ | |
| 305 | - @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php'); | |
| 306 | - } | |
| 307 | - } | |
| 308 | - } | |
| 309 | - } | |
| 310 | - | |
| 311 | - //Notice Message display | |
| 312 | - static function plf_notice() { | |
| 313 | - $notice = get_transient('plf_notice'); | |
| 314 | - if(!empty($notice)){ | |
| 315 | - echo '<div class="notice notice-warning"><p>Plugin Load Filter : ' . $notice . '</p></div>'; | |
| 316 | - delete_transient('plf_notice'); | |
| 317 | - } | |
| 318 | - } | |
| 319 | 208 | |
| 320 | 209 | //plugin filter option action request (add, update, delete) |
| 321 | 210 | function action_posts() { |
| 322 | - if (current_user_can( 'activate_plugins' )) { | |
| 211 | + if (current_user_can( 'edit_plugins' )) { | |
| 323 | 212 | if( isset($_POST['edit_regist_filter']) ) { |
| 324 | 213 | if(isset($_POST['plfregist'])){ |
| 325 | 214 | check_admin_referer('plugin_load_filter'); |
| 326 | - //url filter | |
| 327 | - $groupkeys = (method_exists('Plf_filter', 'get_active_group'))? Plf_filter::get_active_group() : array(); | |
| 328 | - if(!empty($groupkeys) && isset($_POST['plfurlkey'])){ | |
| 329 | - $urlkeys = array_keys($_POST['plfurlkey']); | |
| 330 | - foreach( $groupkeys as $item){ | |
| 331 | - if(empty( $_POST['plfurlkey'][$item])){ | |
| 332 | - self::$filter['plfurlkey'][$item]['plugins'] = ''; | |
| 333 | - } else { | |
| 334 | - $plugins = array(); | |
| 335 | - foreach ( $_POST['plfurlkey'][$item] as $p_key => $val ) { | |
| 336 | - if($val == '1') | |
| 337 | - $plugins[] = $p_key; | |
| 338 | - } | |
| 339 | - $option["plugins"] = implode(",", $plugins); | |
| 340 | - self::$filter['plfurlkey'][$item] = $option; | |
| 341 | - } | |
| 342 | - } | |
| 343 | - } | |
| 344 | - //page type filter | |
| 345 | 215 | foreach( array('_admin', '_pagefilter') as $item){ |
| 346 | 216 | $plugins = array(); |
| 347 | 217 | foreach ( $_POST['plfregist'] as $p_key => $val ) { |
| 348 | 218 | if($val == $item) |
| @@ -372,11 +242,10 @@ | ||
| 372 | 242 | if(!empty($cbase) && $call === false) |
| 373 | 243 | unset($plugins[$cbase]); |
| 374 | 244 | } |
| 375 | 245 | $option["plugins"] = implode(",", array_keys($plugins)); |
| 376 | - self::$filter[$item] = $option; | |
| 246 | + $this->filter[$item] = $option; | |
| 377 | 247 | } |
| 378 | - //exclude option | |
| 379 | 248 | if(isset($_POST['plf_option']['exclude'])){ |
| 380 | 249 | $exclude = array(); |
| 381 | 250 | foreach ( $_POST['plf_option']['exclude'] as $ft => $v ) { |
| 382 | 251 | if(!empty($v)) |
| @@ -381,58 +250,31 @@ | ||
| 381 | 250 | foreach ( $_POST['plf_option']['exclude'] as $ft => $v ) { |
| 382 | 251 | if(!empty($v)) |
| 383 | 252 | $exclude[$ft] = true; |
| 384 | 253 | } |
| 385 | - self::$filter['exclude'] = $exclude; | |
| 386 | - } else { | |
| 387 | - self::$filter['exclude'] = array(); | |
| 254 | + $this->filter['exclude'] = $exclude; | |
| 388 | 255 | } |
| 389 | - | |
| 390 | - //admin bar (filtered stat) | |
| 391 | - self::$filter['admin_bar'] = (isset($_POST['plf_option']['admin_bar']))? 1 : 0; | |
| 392 | - | |
| 393 | - //Language option | |
| 394 | - self::$filter['language'] = (isset($_POST['plf_option']['language']))? 1 : 0; | |
| 395 | - | |
| 396 | - //Ajax acceleration plugin filter (for plugin developers) | |
| 397 | - self::$filter['ajax_accelfilter'] = (isset($_POST['plf_option']['ajax_accelfilter']))? 1 : 0; | |
| 398 | - | |
| 399 | - update_option('plf_option', self::$filter, 'no' ); | |
| 256 | + else { | |
| 257 | + $this->filter['exclude'] = ''; | |
| 258 | + } | |
| 259 | + update_option('plf_option', $this->filter ); | |
| 400 | 260 | } |
| 401 | 261 | header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page')); |
| 402 | 262 | exit; |
| 403 | - | |
| 404 | - } elseif( isset($_POST['clear_regist_filter']) ) { | |
| 263 | + } | |
| 264 | + elseif( isset($_POST['clear_regist_filter']) ) { | |
| 405 | 265 | check_admin_referer('plugin_load_filter'); |
| 406 | - if(!empty(self::$filter['plfurlkey'])){ | |
| 407 | - foreach (self::$filter['plfurlkey'] as $key => $val) { | |
| 408 | - unset(self::$filter['plfurlkey'][$key]); | |
| 409 | - } | |
| 410 | - } | |
| 411 | 266 | foreach( array('_admin', '_pagefilter') as $item){ |
| 412 | - self::$filter[$item] = array(); | |
| 267 | + $this->filter[$item] = ''; | |
| 413 | 268 | } |
| 414 | - self::$filter['exclude'] = array(); | |
| 415 | - | |
| 416 | - //old data unset | |
| 417 | - if(isset(self::$filter['urlkey'])){ | |
| 418 | - unset(self::$filter['urlkey']); | |
| 419 | - } | |
| 420 | - if(isset(self::$filter['urlkeylist'])){ | |
| 421 | - unset(self::$filter['urlkeylist']); | |
| 422 | - } | |
| 423 | - | |
| 424 | - self::$filter['admin_bar'] = 0; | |
| 425 | - self::$filter['language'] = 0; | |
| 426 | - self::$filter['ajax_accelfilter'] = 0; | |
| 427 | - update_option('plf_option', self::$filter, 'no' ); | |
| 269 | + $this->filter['exclude'] = ''; | |
| 270 | + update_option('plf_option', $this->filter ); | |
| 428 | 271 | header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page')); |
| 429 | 272 | exit; |
| 430 | - | |
| 431 | - } else if(isset($_POST['edit_activate_page_filter']) ) { | |
| 273 | + } | |
| 274 | + else if(isset($_POST['edit_activate_page_filter']) ) { | |
| 432 | 275 | if(isset($_POST['plfactive'])){ |
| 433 | 276 | check_admin_referer('plugin_load_filter'); |
| 434 | - self::$filter['group'] = array(); | |
| 435 | 277 | $group = array_keys($_POST['plfactive']); |
| 436 | 278 | foreach( $group as $item){ |
| 437 | 279 | $plugins = array(); |
| 438 | 280 | foreach ( $_POST['plfactive'][$item] as $p_key => $val ) { |
| @@ -437,21 +279,24 @@ | ||
| 437 | 279 | $plugins = array(); |
| 438 | 280 | foreach ( $_POST['plfactive'][$item] as $p_key => $val ) { |
| 439 | 281 | if($val == '1') |
| 440 | 282 | $plugins[] = $p_key; |
| 441 | - } | |
| 283 | + } | |
| 442 | 284 | $option["plugins"] = implode(",", $plugins); |
| 443 | - self::$filter['group'][$item] = $option; | |
| 285 | + $this->filter['group'][$item] = $option; | |
| 444 | 286 | } |
| 445 | - update_option('plf_option', self::$filter, 'no' ); | |
| 287 | + update_option('plf_option', $this->filter ); | |
| 446 | 288 | } |
| 447 | 289 | header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page&action=tab_1')); |
| 448 | 290 | exit; |
| 449 | - | |
| 450 | - } elseif( isset($_POST['clear_activate_page_filter']) ) { | |
| 291 | + } | |
| 292 | + elseif( isset($_POST['clear_activate_page_filter']) ) { | |
| 451 | 293 | check_admin_referer('plugin_load_filter'); |
| 452 | - self::$filter['group'] = array(); | |
| 453 | - update_option('plf_option', self::$filter, 'no' ); | |
| 294 | + $group = array_keys($_POST['plfactive']); | |
| 295 | + foreach( $group as $item){ | |
| 296 | + $this->filter['group'][$item] = ''; | |
| 297 | + } | |
| 298 | + update_option('plf_option', $this->filter ); | |
| 454 | 299 | header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page&action=tab_1')); |
| 455 | 300 | exit; |
| 456 | 301 | } |
| 457 | 302 | if(!empty($_GET['action']) && $_GET['action']=='tab_1') { |
| @@ -461,34 +306,37 @@ | ||
| 461 | 306 | } |
| 462 | 307 | |
| 463 | 308 | //Plugin or Module key to name |
| 464 | 309 | // $type : list/smart/tree |
| 465 | - static function pluginkey_to_name( $infkey, $type='list') { | |
| 310 | + public function pluginkey_to_name( $infkey, $type='list') { | |
| 311 | + | |
| 466 | 312 | $name = ''; |
| 467 | 313 | if(strpos($infkey, 'jetpack_module/') !== false){ |
| 468 | - if(!empty(self::$plugins_inf[$infkey]['name'])){ | |
| 314 | + if(!empty($this->plugins_inf[$infkey]['name'])){ | |
| 469 | 315 | $m_mark = ($type !== 'list')? '-' : 'Jetpack-'; |
| 470 | 316 | if($type === 'smart') { |
| 471 | - if(empty(self::$filter['_pagefilter']['plugins']) || strpos(self::$filter['_pagefilter']['plugins'], 'jetpack/') === false) | |
| 472 | - $name = $m_mark . self::$plugins_inf[$infkey]['name']; | |
| 473 | - } else { | |
| 474 | - $name = $m_mark . self::$plugins_inf[$infkey]['name']; | |
| 317 | + if(empty($this->filter['_pagefilter']['plugins']) || strpos($this->filter['_pagefilter']['plugins'], 'jetpack/') === false) | |
| 318 | + $name = $m_mark . $this->plugins_inf[$infkey]['name']; | |
| 475 | 319 | } |
| 320 | + else | |
| 321 | + $name = $m_mark . $this->plugins_inf[$infkey]['name']; | |
| 476 | 322 | } |
| 477 | - } elseif(strpos($infkey, 'celtispack_module/') !== false){ | |
| 478 | - if(!empty(self::$plugins_inf[$infkey]['Name'])){ | |
| 323 | + } | |
| 324 | + elseif(strpos($infkey, 'celtispack_module/') !== false){ | |
| 325 | + if(!empty($this->plugins_inf[$infkey]['Name'])){ | |
| 479 | 326 | $m_mark = ($type !== 'list')? '-' : 'Celtispack-'; |
| 480 | 327 | if($type === 'smart') { |
| 481 | - if(empty(self::$filter['_pagefilter']['plugins']) || strpos(self::$filter['_pagefilter']['plugins'], 'celtispack/') === false) | |
| 482 | - $name = $m_mark . self::$plugins_inf[$infkey]['Name']; | |
| 483 | - } else { | |
| 484 | - $name = $m_mark . self::$plugins_inf[$infkey]['Name']; | |
| 328 | + if(empty($this->filter['_pagefilter']['plugins']) || strpos($this->filter['_pagefilter']['plugins'], 'celtispack/') === false) | |
| 329 | + $name = $m_mark . $this->plugins_inf[$infkey]['Name']; | |
| 485 | 330 | } |
| 331 | + else | |
| 332 | + $name = $m_mark . $this->plugins_inf[$infkey]['Name']; | |
| 486 | 333 | } |
| 487 | - } else { | |
| 488 | - if(!empty(self::$plugins_inf[$infkey]['Name'])) | |
| 489 | - $name = self::$plugins_inf[$infkey]['Name']; | |
| 490 | 334 | } |
| 335 | + else { | |
| 336 | + if(!empty($this->plugins_inf[$infkey]['Name'])) | |
| 337 | + $name = $this->plugins_inf[$infkey]['Name']; | |
| 338 | + } | |
| 491 | 339 | return($name); |
| 492 | 340 | } |
| 493 | 341 | |
| 494 | 342 | //Checkbox |
| @@ -495,97 +343,24 @@ | ||
| 495 | 343 | static function checkbox($name, $value, $label = '') { |
| 496 | 344 | return "<label><input type='checkbox' name='$name' value='1' " . checked( $value, 1, false ). "/> $label</label>"; |
| 497 | 345 | } |
| 498 | 346 | static function altcheckbox($name, $value, $label = '') { |
| 499 | - //return "<input type='hidden' name='$name' value='0'><input type='checkbox' name='$name' value='1' " . checked( $value, 1, false ). "/><label> $label</label>"; | |
| 500 | - return "<label><input type='checkbox' name='$name' class='altcheckbox' value='1' " . checked( $value, 1, false ). "/> $label</label>"; | |
| 347 | + return "<input type='hidden' name='$name' value='0'><input type='checkbox' name='$name' value='1' " . checked( $value, 1, false ). "/><label> $label</label>"; | |
| 501 | 348 | } |
| 502 | - | |
| 503 | - //dropdown list | |
| 504 | - static function dropdown($name, $items, $selected, $args = null) { | |
| 505 | - $defaults = array( | |
| 506 | - 'id' => $name, | |
| 507 | - 'none' => false, | |
| 508 | - 'class' => null, | |
| 509 | - 'multiple' => false, | |
| 510 | - 'select_attr' => "" | |
| 511 | - ); | |
| 512 | - | |
| 513 | - if (!is_array($items)) | |
| 514 | - return; | |
| 515 | - | |
| 516 | - if (empty($items)) | |
| 517 | - $items = array(); | |
| 518 | - | |
| 519 | - // Items is in key => value format. If value is itself an array, use only the 1st column | |
| 520 | - foreach ($items as $key => &$value) { | |
| 521 | - if (is_array($value)) | |
| 522 | - $value = array_shift($value); | |
| 523 | - } | |
| 524 | - | |
| 525 | - extract(wp_parse_args($args, $defaults)); | |
| 526 | - | |
| 527 | - // If 'none' arg provided, prepend a blank entry | |
| 528 | - if ($none) { | |
| 529 | - if ($none === true) | |
| 530 | - $none = ' '; | |
| 531 | - $items = array('' => $none) + $items; // Note that array_merge() won't work because it renumbers indexes! | |
| 532 | - } | |
| 533 | - | |
| 534 | - if (!$id) | |
| 535 | - $id = $name; | |
| 536 | - | |
| 537 | - $name = ($name) ? "name='$name'" : ""; | |
| 538 | - $id = ($id) ? "id='$id'" : ""; | |
| 539 | - $class = ($class) ? "class='$class'" : ""; | |
| 540 | - $multiple = ($multiple) ? "multiple='multiple'" : ""; | |
| 541 | - | |
| 542 | - $html = "<select $name $id $class $multiple $select_attr>"; | |
| 543 | - | |
| 544 | - foreach ((array) $items as $key => $label) { | |
| 545 | - $key = esc_attr($key); | |
| 546 | - $label = esc_attr($label); | |
| 547 | - | |
| 548 | - $html .= "<option value='$key' " . selected($selected, $key, false) . ">$label</option>"; | |
| 549 | - } | |
| 550 | - $html .= "</select>"; | |
| 551 | - return $html; | |
| 552 | - } | |
| 553 | - | |
| 554 | - //安全な文字列から指定タグのみデコード(既存の翻訳ファイルへ影響せずにエスケープするために使用) | |
| 555 | - //<strong>Type</strong> -> <strong>Type</strong> | |
| 556 | - static function decode_safe_tag( $tag, $safe_str ) { | |
| 557 | - $safe_str = preg_replace_callback( "|<($tag.*)>(.*)</($tag)>|im", function($matches){ | |
| 558 | - $tag_attrs = str_replace( '"', '"', $matches[1]); | |
| 559 | - return '<' . $tag_attrs . '>' . $matches[2] . '</' . $matches[3] . '>'; | |
| 560 | - }, $safe_str); | |
| 561 | - return $safe_str; | |
| 562 | - } | |
| 563 | 349 | |
| 564 | - public function plfregist_item($key, $chklist, $filter) { | |
| 565 | - $p_name = self::pluginkey_to_name($key); | |
| 350 | + public function plfregist_item($key, $val) { | |
| 351 | + $p_name = $this->pluginkey_to_name($key); | |
| 566 | 352 | $opt_name = "plfregist[$key]"; |
| 567 | 353 | ?> |
| 568 | 354 | <tr id="plfregist_<?php echo $key; ?>"> |
| 569 | 355 | <td class="filter-plugins-name"><?php echo $p_name; ?></td> |
| 570 | - <?php | |
| 571 | - foreach($chklist as $urlkey){ | |
| 572 | - $checked = (empty($filter['plfurlkey'][$urlkey]['plugins']) || false === strpos($filter['plfurlkey'][$urlkey]['plugins'], $key))? false : true; | |
| 573 | - echo '<td class="deny-type filter-type">' . self::altcheckbox("plfurlkey[$urlkey][$key]", $checked, '<span class="dashicons dashicons-admin-plugins"></span>') . '</td>'; | |
| 574 | - } | |
| 575 | - $radio = ''; | |
| 576 | - if(!empty($filter['_admin']['plugins']) && false !== strpos($filter['_admin']['plugins'], $key)) | |
| 577 | - $radio = '_admin'; | |
| 578 | - else if(!empty($filter['_pagefilter']['plugins']) && false !== strpos($filter['_pagefilter']['plugins'], $key)) | |
| 579 | - $radio = '_pagefilter'; | |
| 580 | - ?> | |
| 581 | - <td class="radio-green filter-type"><label><input type="radio" name="<?php echo $opt_name; ?>" value='' <?php checked('', $radio); ?>/><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 582 | - <td class="radio-red filter-type"><label><input type="radio" name="<?php echo $opt_name; ?>" value="_admin" <?php checked('_admin', $radio); ?>/><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 583 | - <td class="radio-red filter-type"><label><input type="radio" name="<?php echo $opt_name; ?>" value="_pagefilter" <?php checked('_pagefilter', $radio); ?>/><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 356 | + <td class="radio-green filter-type"><input type="radio" name="<?php echo $opt_name; ?>" value='' <?php checked('', $val); ?>/><label><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 357 | + <td class="radio-red filter-type"><input type="radio" name="<?php echo $opt_name; ?>" value="_admin" <?php checked('_admin', $val); ?>/><label><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 358 | + <td class="radio-red filter-type"><input type="radio" name="<?php echo $opt_name; ?>" value="_pagefilter" <?php checked('_pagefilter', $val); ?>/><label><span class="dashicons dashicons-admin-plugins"></span></label></td> | |
| 584 | 359 | </tr> |
| 585 | 360 | <?php |
| 586 | 361 | } |
| 587 | - | |
| 362 | + | |
| 588 | 363 | //Filterring plugins select |
| 589 | 364 | public function plfregist_table($plugins, $filter) { |
| 590 | 365 | ?> |
| 591 | 366 | <div id="wrap_registration-table"> |
| @@ -590,75 +365,13 @@ | ||
| 590 | 365 | ?> |
| 591 | 366 | <div id="wrap_registration-table"> |
| 592 | 367 | <table id="registration-table" class="widefat"> |
| 593 | 368 | <thead> |
| 594 | - <?php | |
| 595 | - $groupkeys = (method_exists('Plf_filter', 'get_active_group'))? Plf_filter::get_active_group() : array(); | |
| 596 | - $urlnum = count($groupkeys); | |
| 597 | - ?> | |
| 598 | - <tr> | |
| 599 | - <th class="filter-plugins-name" rowspan="2"><?php esc_html_e('Plugins'); ?></th> | |
| 600 | - <?php if($urlnum > 0) { ?> | |
| 601 | - <th class="filter-type urlfilter" colspan="<?php echo $urlnum; ?>" style="font-weight:bold; font-size:smaller;"><?php esc_html_e('URL Group Filter', 'plf'); ?></th> | |
| 602 | - <?php } ?> | |
| 603 | - <th class="filter-type filter-tmpl" colspan="3" style="font-weight:bold; font-size:smaller;"><?php esc_html_e('Page Type Filter', 'plf'); ?></th> | |
| 369 | + <tr><th class="filter-plugins-name"><?php _e('Plugins'); ?></th> | |
| 370 | + <th class="filter-type filter-none"><?php _e('Normal Load', 'plf'); ?></th> | |
| 371 | + <th class="filter-type filter-admin"><?php _e('Admin Filter', 'plf'); ?></th> | |
| 372 | + <th class="filter-type filter-tmpl"><?php _e('Page Filter', 'plf'); ?></th> | |
| 604 | 373 | </tr> |
| 605 | - <tr> | |
| 606 | - <?php //Addon URL filter group key | |
| 607 | - if($urlnum > 0) { | |
| 608 | - foreach ( $groupkeys as $v) { | |
| 609 | - $_flt = (method_exists('Plf_filter', 'get_slug_filter'))? Plf_filter::get_slug_filter( $v ) : array(); | |
| 610 | - $hint = ''; | |
| 611 | - foreach ($_flt as $_v) { | |
| 612 | - $hint .= '[' . $_v['slug'] . '] ' . $_v['summary'] . PHP_EOL; | |
| 613 | - | |
| 614 | - if((int)$_v['targetpage'] === 1) { | |
| 615 | - $post_type = (!empty($_v['post_type']))? $_v['post_type'] : ''; | |
| 616 | - $taxonomy = ''; | |
| 617 | - if(!empty($_v['taxonomies']) && !empty($_v['term'])){ | |
| 618 | - $taxonomy = " : {$_v['taxonomies']}({$_v['term']})"; | |
| 619 | - } | |
| 620 | - if(!empty($post_type)){ | |
| 621 | - $hint .= 'Singular (' . $post_type . ')' . $taxonomy . PHP_EOL; | |
| 622 | - } else { | |
| 623 | - $hint .= 'Singular ' . $taxonomy . PHP_EOL; | |
| 624 | - } | |
| 625 | - } elseif((int)$_v['targetpage'] === 2) { | |
| 626 | - if(!empty($_v['ajax_action'])){ | |
| 627 | - $hint .= 'Ajax request (' . $_v['ajax_action'] . ')' . PHP_EOL; | |
| 628 | - } else { | |
| 629 | - $hint .= 'Ajax request' . PHP_EOL; | |
| 630 | - } | |
| 631 | - } | |
| 632 | - | |
| 633 | - $hint .= 'url filter : '; | |
| 634 | - $urlkey = (!empty($_v['url_path']))? array_filter( array_map("trim", explode(PHP_EOL, $_v['url_path']))) : array(); | |
| 635 | - if(!empty($urlkey)){ | |
| 636 | - foreach ($urlkey as $key) { | |
| 637 | - $hint .= $key . ' '; | |
| 638 | - } | |
| 639 | - } | |
| 640 | - $urlkey = (!empty($_v['url_q_and']))? array_filter( array_map("trim", explode(PHP_EOL, $_v['url_q_and']))) : array(); | |
| 641 | - if(!empty($urlkey)){ | |
| 642 | - foreach ($urlkey as $key) { | |
| 643 | - $hint .= ' AND ' . $key; | |
| 644 | - } | |
| 645 | - } | |
| 646 | - $urlkey = (!empty($filter['url_q_not']))? array_filter( array_map("trim", explode(PHP_EOL, $filter['url_q_not']))) : array(); | |
| 647 | - if(!empty($urlkey)){ | |
| 648 | - foreach ($urlkey as $key) { | |
| 649 | - $hint .= ' NOT ' . $key; | |
| 650 | - } | |
| 651 | - } | |
| 652 | - $hint .= PHP_EOL . PHP_EOL; | |
| 653 | - } | |
| 654 | - echo "<th class='filter-type urlfilter'><span title='$hint' style='font-size:smaller'>{$v}</span></th>"; | |
| 655 | - } | |
| 656 | - } ?> | |
| 657 | - <th class="filter-type filter-none"><span style="font-size:smaller"><?php esc_html_e('Normal', 'plf'); ?></span></th> | |
| 658 | - <th class="filter-type filter-admin"><span style="font-size:smaller"><?php esc_html_e('Admin Type', 'plf'); ?></span></th> | |
| 659 | - <th class="filter-type filter-tmpl"><span style="font-size:smaller"><?php esc_html_e('Page Type', 'plf'); ?></span></th> | |
| 660 | - </tr> | |
| 661 | 374 | </thead> |
| 662 | 375 | <tbody class="plugins-table-body"> |
| 663 | 376 | <?php |
| 664 | 377 | //plugins filter registoration table |
| @@ -663,12 +376,19 @@ | ||
| 663 | 376 | <?php |
| 664 | 377 | //plugins filter registoration table |
| 665 | 378 | $plist = array(); |
| 666 | 379 | foreach ( $plugins as $p_key => $val ) { |
| 667 | - $name = self::pluginkey_to_name($p_key); | |
| 380 | + $name = $this->pluginkey_to_name($p_key); | |
| 668 | 381 | if(!empty($name)) |
| 669 | 382 | $plist[$p_key] = ''; |
| 670 | 383 | } |
| 384 | + foreach( array('_admin', '_pagefilter') as $item){ | |
| 385 | + $parr = (!empty($filter[$item]['plugins'])) ? array_map("trim", explode(',', $filter[$item]['plugins'])) : array(); | |
| 386 | + foreach ( $plist as $p_key => $val ) { | |
| 387 | + if(empty($val) && in_array($p_key, $parr)) | |
| 388 | + $plist[$p_key] = $item; | |
| 389 | + } | |
| 390 | + } | |
| 671 | 391 | $jlist = $clist = array(); |
| 672 | 392 | foreach ( $plist as $p_key => $val ) { |
| 673 | 393 | if(strpos($p_key, 'jetpack_module/') !== false){ |
| 674 | 394 | $jlist[$p_key] = $plist[$p_key]; |
| @@ -678,16 +398,8 @@ | ||
| 678 | 398 | $clist[$p_key] = $plist[$p_key]; |
| 679 | 399 | unset($plist[$p_key]); |
| 680 | 400 | } |
| 681 | 401 | } |
| 682 | - //Addon URL filter group key | |
| 683 | - $chklist = array(); | |
| 684 | - if($urlnum > 0) { | |
| 685 | - foreach ( $groupkeys as $key) { | |
| 686 | - $chklist[] = $key; | |
| 687 | - } | |
| 688 | - } | |
| 689 | - | |
| 690 | 402 | foreach ( $plist as $p_key => $val ) { |
| 691 | 403 | $modules = array(); |
| 692 | 404 | if(strpos($p_key, 'jetpack/') !== false) |
| 693 | 405 | $modules = $jlist; |
| @@ -693,13 +405,13 @@ | ||
| 693 | 405 | $modules = $jlist; |
| 694 | 406 | else if(strpos($p_key, 'celtispack/') !== false) |
| 695 | 407 | $modules = $clist; |
| 696 | 408 | else |
| 697 | - $this->plfregist_item($p_key, $chklist, $filter); | |
| 409 | + $this->plfregist_item($p_key, $val); | |
| 698 | 410 | if(!empty($modules)){ |
| 699 | 411 | echo "<input type='hidden' name='plfregist[$p_key]' value='_pagefilter'>"; |
| 700 | 412 | foreach ( $modules as $m_key => $val) { |
| 701 | - $this->plfregist_item($m_key, $chklist, $filter); | |
| 413 | + $this->plfregist_item($m_key, $val); | |
| 702 | 414 | } |
| 703 | 415 | } |
| 704 | 416 | } |
| 705 | 417 | ?> |
| @@ -704,71 +416,36 @@ | ||
| 704 | 416 | } |
| 705 | 417 | ?> |
| 706 | 418 | </tbody> |
| 707 | 419 | </table> |
| 708 | - </div> | |
| 709 | - <p></p> | |
| 710 | - <div class="grid-row"> | |
| 711 | - <div class="filter-description"> | |
| 712 | - <p><strong>[ <?php esc_html_e('Page Type Filter', 'plf'); ?> ]</strong></p> | |
| 713 | - <?php echo self::decode_safe_tag( 'strong', esc_html__('<strong>Normal</strong> - Exclude plugin from Page Type filter', 'plf')); ?><br /> | |
| 714 | - <?php echo self::decode_safe_tag( 'strong', esc_html__('<strong>Admin Type</strong> - If you only use plugins for Admin pages.', 'plf')); ?><br /> | |
| 715 | - <?php echo self::decode_safe_tag( 'strong', esc_html__('<strong>Page Type</strong> - If you want to activate or deactivate plugins for each Page Type and Single page.', 'plf')); ?> | |
| 716 | - <p> | |
| 717 | - <?php | |
| 718 | - $checked = (!empty(self::$filter['admin_bar']))? self::$filter['admin_bar'] : false; | |
| 719 | - echo '<span class="admin-bar-option">' . self::checkbox("plf_option[admin_bar]", $checked, esc_html__('Add a link to admin bar for displaying the plugins filtered status', 'plf') ) . '</span>'; | |
| 720 | - ?> | |
| 721 | - </p> | |
| 722 | - <p><?php esc_html_e('* Plugins with `Page Type Filter` selected are blocked, but you can Activate it for various Page type in the `Page Type Activation` and Single Page setting.', 'plf'); ?></p> | |
| 723 | - | |
| 420 | + <br /> | |
| 421 | + <p><strong>[ Admin Filter ]</strong></p> | |
| 422 | + <div class="filter-description"><?php _e('Plugins to be used only in admin mode.', 'plf'); ?></div> | |
| 423 | + <p><strong>[ Page Filter ]</strong></p> | |
| 424 | + <div class="filter-description"> | |
| 425 | + <?php _e('Plugins for selecting whether to activate each Page type or Post.', 'plf'); ?><br /> | |
| 426 | + <?php _e('Selected page filter plugins are once blocked, but is activated by "Page filter Activation" setting.', 'plf'); ?> | |
| 724 | 427 | <div class="exclude-pformat"> |
| 725 | - <p><?php echo self::decode_safe_tag( 'strong', esc_html__('<strong>Exclude Post Format Type</strong> - Choose Post Format Type you are not using. To exclude from Page Type item subject.', 'plf')); ?></p> | |
| 726 | - <?php | |
| 428 | + <p><strong><?php _e( 'Exclude Post Format Type', 'plf' ); ?></strong><br /> | |
| 429 | + <?php _e('Choose Post Format Type you are not using. To exclude from Page Filter item subject.', 'plf'); ?> | |
| 430 | + </p> | |
| 431 | + <?php | |
| 727 | 432 | $html = '<div>'; |
| 728 | 433 | $pformat = array('image', 'gallery', 'video', 'audio', 'aside', 'status', 'quote', 'link', 'chat' ); |
| 729 | 434 | foreach ( $pformat as $type ) { |
| 730 | - $checked = (!empty(self::$filter['exclude'][$type]))? self::$filter['exclude'][$type] : false; | |
| 435 | + $checked = (!empty($this->filter['exclude'][$type]))? $this->filter['exclude'][$type] : false; | |
| 731 | 436 | $label = "<span>$type</span>"; |
| 732 | 437 | $html .= self::checkbox("plf_option[exclude][$type]", $checked, $label); |
| 733 | 438 | } |
| 734 | 439 | $html .= '</div>'; |
| 735 | 440 | echo $html; |
| 736 | - ?> | |
| 441 | + ?> | |
| 737 | 442 | </div> |
| 738 | - <p><strong>[ <?php esc_html_e('Ajax acceleration filter (Features for plugin developers)', 'plf'); ?> ]</strong></p> | |
| 739 | - <p><?php esc_html_e('If you are implementing Ajax requests in your plugin development, you can deactivate unnecessary plugins and speed up Ajax by setting the plugin slugs to be activated to `_ajax_plf` in the request data.','plf'); ?></p> | |
| 740 | - <?php | |
| 741 | - $checked = (!empty(self::$filter['ajax_accelfilter']))? self::$filter['ajax_accelfilter'] : false; | |
| 742 | - echo '<div class="option-item">' . self::checkbox("plf_option[ajax_accelfilter]", $checked, esc_html__('Ajax acceleration filter', 'plf') ) . '</div>'; | |
| 743 | - ?> | |
| 744 | - <p><strong>[ <?php esc_html_e('Post Language Locale', 'plf'); ?> ]</strong></p> | |
| 745 | - <p><?php esc_html_e('A very simple multilingual feature that uses MO translation files for the selected locale per Post/Page editing screen.','plf'); ?></p> | |
| 746 | - <?php | |
| 747 | - $checked = (!empty(self::$filter['language']))? self::$filter['language'] : false; | |
| 748 | - echo '<div class="option-item">' . self::checkbox("plf_option[language]", $checked, esc_html__('Language switching per post', 'plf') ) . '</div>'; | |
| 749 | - ?> | |
| 750 | - </div> | |
| 751 | - <div class="side-info"> | |
| 752 | - <?php if(! is_plugin_active('plugin-load-filter-addon/plugin-load-filter-addon.php')){ ?> | |
| 753 | - <div style="background-color: #f0fff0; border:1px solid #70c370; padding:4px 20px; margin: 10px 0;" > | |
| 754 | - <p><strong><?php esc_html_e('Introduction of Addon', 'plf'); ?></strong></p> | |
| 755 | - <p><?php esc_html_e('Thank you for using Plugin Load Filter. We offer URL filtering as Addon. Please consider using Addon!', 'plf'); ?></p> | |
| 756 | - <p><?php esc_html_e('See more information ', 'plf'); ?><a target="_blank" rel="noopener" href="https://celtislab.net/en/wp-plugin-load-filter-addon/"> Plugin Load Filter Addon</a></p> | |
| 757 | - </div> | |
| 758 | - <?php } ?> | |
| 759 | - <?php if(! is_plugin_active('realtime-img-optimizer/realtime-img-optimizer.php')){ ?> | |
| 760 | - <div style="background-color: #f0fff0; border:1px solid #70c370; padding:4px 20px; margin: 10px 0;" > | |
| 761 | - <p><strong><?php esc_html_e('Introduction of Realtime Image Optimizer', 'plf'); ?></strong></p> | |
| 762 | - <p><?php esc_html_e('We sell Image Optimization plugin. Reduce and speed up data size by converting to WebP / AVIF.', 'plf'); ?></p> | |
| 763 | - <p><?php esc_html_e('See more information ', 'plf'); ?><a target="_blank" rel="noopener" href="https://celtislab.net/en/wp-realtime-image-optimizer/"> Realtime Image Optimizer</a></p> | |
| 764 | - </div> | |
| 765 | - <?php } ?> | |
| 766 | - </div> | |
| 767 | 443 | </div> |
| 444 | + </div> | |
| 768 | 445 | <?php |
| 769 | 446 | } |
| 770 | - | |
| 447 | + | |
| 771 | 448 | //Activate plugins select from Page Filter |
| 772 | 449 | public function _plfactive_checkbox_row($p_key, $select_cvplugins, $chklist, $filter) { |
| 773 | 450 | |
| 774 | 451 | $selplugins = array_map("trim", explode(',', $select_cvplugins)); |
| @@ -773,9 +450,9 @@ | ||
| 773 | 450 | |
| 774 | 451 | $selplugins = array_map("trim", explode(',', $select_cvplugins)); |
| 775 | 452 | $devlist = array('desktop','mobile'); |
| 776 | 453 | if(in_array( $p_key, $selplugins )){ |
| 777 | - $p_name = self::pluginkey_to_name($p_key); | |
| 454 | + $p_name = $this->pluginkey_to_name($p_key); | |
| 778 | 455 | echo "<tr><td class='plugins-name'>$p_name</td>"; |
| 779 | 456 | foreach($devlist as $devtype){ |
| 780 | 457 | $checked = (empty($filter['group'][$devtype]['plugins']) || false === strpos($filter['group'][$devtype]['plugins'], $p_key))? false : true; |
| 781 | 458 | echo '<td class="device-type">' . self::altcheckbox("plfactive[$devtype][$p_key]", $checked, '<span class="dashicons dashicons-yes"></span>') . '</td>'; |
| @@ -781,9 +458,9 @@ | ||
| 781 | 458 | echo '<td class="device-type">' . self::altcheckbox("plfactive[$devtype][$p_key]", $checked, '<span class="dashicons dashicons-yes"></span>') . '</td>'; |
| 782 | 459 | } |
| 783 | 460 | foreach($chklist as $pgtype){ |
| 784 | 461 | $checked = (empty($filter['group'][$pgtype]['plugins']) || false === strpos($filter['group'][$pgtype]['plugins'], $p_key))? false : true; |
| 785 | - echo '<td class="ckbox-type">' . self::altcheckbox("plfactive[$pgtype][$p_key]", $checked, '<span class="dashicons dashicons-admin-plugins"></span>') . '</td>'; | |
| 462 | + echo '<td class="tmpl-type">' . self::altcheckbox("plfactive[$pgtype][$p_key]", $checked, '<span class="dashicons dashicons-admin-plugins"></span>') . '</td>'; | |
| 786 | 463 | } |
| 787 | 464 | echo "</tr>"; |
| 788 | 465 | } |
| 789 | 466 | } |
| @@ -795,17 +472,17 @@ | ||
| 795 | 472 | ?> |
| 796 | 473 | <div id="wrap_activation-table"> |
| 797 | 474 | <table id="activation-table" class="widefat"> |
| 798 | 475 | <thead> |
| 799 | - <tr><th class="plugins-name"><?php esc_html_e('Plugins'); ?></th> | |
| 800 | - <th class="device-type"><span title="<?php esc_html_e('Desktop Device', 'plf'); ?>" class="dashicons dashicons-desktop"></span><br /><span style="font-size:xx-small">Desktop</span></th> | |
| 801 | - <th class="device-type"><span title="<?php esc_html_e('Mobile Device', 'plf'); ?>" class="dashicons dashicons-smartphone"></span><br /><span style="font-size:xx-small">Mobile</span></th> | |
| 802 | - <th class="ckbox-type"><span title="<?php esc_html_e('Home/Front-page', 'plf'); ?>" class="dashicons dashicons-admin-home"></span><br /><span style="font-size:xx-small">Home</span></th> | |
| 803 | - <th class="ckbox-type"><span title="<?php esc_html_e('Archive page', 'plf'); ?>" class="dashicons dashicons-list-view"></span><br /><span style="font-size:xx-small">Archive</span></th> | |
| 804 | - <th class="ckbox-type"><span title="<?php esc_html_e('Search page', 'plf'); ?>" class="dashicons dashicons-search"></span><br /><span style="font-size:xx-small">Search</span></th> | |
| 805 | - <th class="ckbox-type"><span title="<?php esc_html_e('Attachment page', 'plf'); ?>" class="dashicons dashicons-media-default"></span><br /><span style="font-size:xx-small">Attach</span></th> | |
| 806 | - <th class="ckbox-type"><span title="<?php esc_html_e('Page', 'plf'); ?>" class="dashicons dashicons-admin-page"></span><br /><span style="font-size:xx-small">Page</span></th> | |
| 807 | - <th class="ckbox-type pformat"><span title="<?php esc_html_e('Post : ', 'plf'); esc_html_e('Standard', 'plf'); ?>" class="dashicons dashicons-admin-post"></span><br /><span style="font-size:xx-small">Post</span></th> | |
| 476 | + <tr><th class="plugins-name"><?php _e('Plugins'); ?></th> | |
| 477 | + <th class="device-type"><span title="<?php _e('Desktop Device', 'plf'); ?>" class="dashicons dashicons-desktop"></span><br /><span style="font-size:xx-small">Desktop</span></th> | |
| 478 | + <th class="device-type"><span title="<?php _e('Mobile Device', 'plf'); ?>" class="dashicons dashicons-smartphone"></span><br /><span style="font-size:xx-small">Mobile</span></th> | |
| 479 | + <th class="tmpl-type"><span title="<?php _e('Home/Front-page', 'plf'); ?>" class="dashicons dashicons-admin-home"></span><br /><span style="font-size:xx-small">Home</span></th> | |
| 480 | + <th class="tmpl-type"><span title="<?php _e('Archive page', 'plf'); ?>" class="dashicons dashicons-list-view"></span><br /><span style="font-size:xx-small">Archive</span></th> | |
| 481 | + <th class="tmpl-type"><span title="<?php _e('Search page', 'plf'); ?>" class="dashicons dashicons-search"></span><br /><span style="font-size:xx-small">Search</span></th> | |
| 482 | + <th class="tmpl-type"><span title="<?php _e('Attachment page', 'plf'); ?>" class="dashicons dashicons-media-default"></span><br /><span style="font-size:xx-small">Attach</span></th> | |
| 483 | + <th class="tmpl-type"><span title="<?php _e('Page', 'plf'); ?>" class="dashicons dashicons-admin-page"></span><br /><span style="font-size:xx-small">Page</span></th> | |
| 484 | + <th class="tmpl-type pformat"><span title="<?php _e('Post : ', 'plf'); _e('Standard', 'plf'); ?>" class="dashicons dashicons-admin-post"></span><br /><span style="font-size:xx-small">Post</span></th> | |
| 808 | 485 | <?php |
| 809 | 486 | $pformat = array('image', 'gallery', 'video', 'audio', 'aside', 'status', 'quote', 'link', 'chat' ); |
| 810 | 487 | $exclude = array(); |
| 811 | 488 | if(!empty($filter['exclude'])){ |
| @@ -816,22 +493,22 @@ | ||
| 816 | 493 | } |
| 817 | 494 | } |
| 818 | 495 | foreach ( $pformat as $type) { |
| 819 | 496 | if(!in_array($type, $exclude)){ |
| 820 | - $title = esc_html__('Post : ', 'plf') . $type; | |
| 497 | + $title = __('Post : ', 'plf') . $type; | |
| 821 | 498 | $icon = ($type === "link")? "dashicons-admin-links" : "dashicons-format-$type"; |
| 822 | - echo '<th class="ckbox-type pformat"><span title="' . $title . '" class="dashicons ' . $icon .'"></span><br /><span style="font-size:xx-small">' . $type .'</span></th>'; | |
| 499 | + echo '<th class="tmpl-type pformat"><span title="' . $title . '" class="dashicons ' . $icon .'"></span><br /><span style="font-size:xx-small">' . $type .'</span></th>'; | |
| 823 | 500 | } |
| 824 | 501 | } |
| 825 | 502 | if(function_exists('is_embed')){ |
| 826 | - $title = esc_html__('WordPress Embed Content Card (API)', 'plf'); | |
| 827 | - echo "<th class='ckbox-type tmpl-embed'><span title='$title' style='font-size:xx-small'>Embed Content</span></th>"; | |
| 503 | + $title = __('WordPress Embed Content Card (API)', 'plf'); | |
| 504 | + echo "<th class='tmpl-type tmpl-embed'><span title='$title' style='font-size:xx-small'>Embed Content</span></th>"; | |
| 828 | 505 | } |
| 829 | 506 | $post_types = get_post_types( array('public' => true, '_builtin' => false) ); |
| 830 | 507 | foreach ( $post_types as $post_type ) { |
| 831 | 508 | if(!empty($post_type)){ |
| 832 | - $title = esc_html__('Custom Post : ', 'plf') . $post_type; | |
| 833 | - echo "<th class='ckbox-type tmpl-custom'><span title='$title' style='font-size:xx-small'>$post_type</span></th>"; | |
| 509 | + $title = __('Custom Post : ', 'plf') . $post_type; | |
| 510 | + echo "<th class='tmpl-type tmpl-custom'><span title='$title' style='font-size:xx-small'>$post_type</span></th>"; | |
| 834 | 511 | } |
| 835 | 512 | } |
| 836 | 513 | ?> |
| 837 | 514 | </tr> |
| @@ -839,9 +516,9 @@ | ||
| 839 | 516 | <tbody class="plugins-table-body"> |
| 840 | 517 | <?php |
| 841 | 518 | $nplugins = $jmodules = $cmodules = $allmodule = array(); |
| 842 | 519 | foreach ( $plugins as $p_key => $p_data ) { |
| 843 | - $p_name = self::pluginkey_to_name($p_key); | |
| 520 | + $p_name = $this->pluginkey_to_name($p_key); | |
| 844 | 521 | if(empty($p_name)) |
| 845 | 522 | continue; |
| 846 | 523 | if(strpos($p_key, 'jetpack_module/') !== false) |
| 847 | 524 | $jmodules[] = $p_key; |
| @@ -886,55 +563,50 @@ | ||
| 886 | 563 | } |
| 887 | 564 | |
| 888 | 565 | //Option Setting Form Display |
| 889 | 566 | public function plf_option_page() { |
| 890 | - $clear_dialog = esc_html__('Plugin Load Filter Settings\nClick OK to clear it.', 'plf'); | |
| 891 | 567 | ?> |
| 892 | - <h2><?php esc_html_e('Plugin Load Filter Settings', 'plf'); ?></h2> | |
| 568 | + <h2><?php _e('Plugin Load Filter Settings', 'plf'); ?></h2> | |
| 893 | 569 | <p></p> |
| 894 | 570 | <div id="plf-setting-tabs"> |
| 895 | 571 | <ul> |
| 896 | - <li><a href="#plf-registration-tab" ><?php esc_html_e('Filter Registration', 'plf'); ?></a></li> | |
| 897 | - <li><a href="#plf-activation-tab" ><?php esc_html_e('Page Type Activation', 'plf'); ?></a></li> | |
| 572 | + <li><a href="#plf-registration-tab" ><?php _e('Filter Registration', 'plf'); ?></a></li> | |
| 573 | + <li><a href="#plf-activation-tab" ><?php _e('Page Filter Activation', 'plf'); ?></a></li> | |
| 898 | 574 | </ul> |
| 899 | - <div id="plf-registration-tab" style="display : none;"> | |
| 900 | - <form method="post" autocomplete="off"> | |
| 901 | - <?php wp_nonce_field( 'plugin_load_filter'); ?> | |
| 902 | - <?php $this->plfregist_table(self::$plugins_inf, self::$filter); ?> | |
| 575 | + <form method="post" > | |
| 576 | + <?php wp_nonce_field( 'plugin_load_filter'); ?> | |
| 577 | + <div id="plf-registration-tab" style="display : none;"> | |
| 578 | + <?php $this->plfregist_table($this->plugins_inf, $this->filter); ?> | |
| 579 | + <p class="submit"> | |
| 580 | + <input type="submit" class="button-primary" name="clear_regist_filter" value="<?php _e('Clear', 'plf'); ?>" /> | |
| 581 | + <input type="submit" class="button-primary" name="edit_regist_filter" value="<?php _e('Filter Entry »', 'plf'); ?>" /> | |
| 582 | + </p> | |
| 583 | + </div> | |
| 584 | + <div id="plf-activation-tab" style="display : none;"> | |
| 585 | + <?php | |
| 586 | + $pgfilter = (!empty($this->filter['_pagefilter']['plugins']))? $this->filter['_pagefilter']['plugins'] : array(); | |
| 587 | + if(!empty($pgfilter)){ | |
| 588 | + $this->plfactive_table($this->plugins_inf, $pgfilter, $this->filter); | |
| 589 | + ?> | |
| 590 | + <br /> | |
| 591 | + <p><?php _e('Select plugins to be activated for each page type by clicking on <span class="dashicons dashicons-admin-plugins"></span> mark from "page filter" registered plugins.', 'plf') ?><br /> | |
| 592 | + <?php _e('You can also select plugins to activate from Post/Page content editing screen.', 'plf') ?> | |
| 593 | + </p> | |
| 903 | 594 | <p class="submit"> |
| 904 | - <input type="submit" class="button-primary" name="clear_regist_filter" value="<?php esc_html_e('Clear', 'plf'); ?>" onclick="return confirm('<?php echo $clear_dialog; ?>')" /> | |
| 905 | - <input type="submit" class="button-primary" name="edit_regist_filter" value="<?php esc_html_e('Filter Entry »', 'plf'); ?>" /> | |
| 595 | + <input type="submit" class="button-primary" name="clear_activate_page_filter" value="<?php _e('Clear', 'plf'); ?>" /> | |
| 596 | + <input type="submit" class="button-primary" name="edit_activate_page_filter" value="<?php _e('Activate Plugin Entry »', 'plf'); ?>" /> | |
| 906 | 597 | </p> |
| 907 | - </form> | |
| 908 | - </div> | |
| 909 | - <div id="plf-activation-tab" style="display : none;"> | |
| 910 | - <form method="post" autocomplete="off"> | |
| 911 | - <?php wp_nonce_field( 'plugin_load_filter'); ?> | |
| 912 | 598 | <?php |
| 913 | - $pgfilter = (!empty(self::$filter['_pagefilter']['plugins']))? self::$filter['_pagefilter']['plugins'] : array(); | |
| 914 | - if(!empty($pgfilter)){ | |
| 915 | - $this->plfactive_table(self::$plugins_inf, $pgfilter, self::$filter); | |
| 916 | - ?> | |
| 917 | - <br /> | |
| 918 | - <p><?php | |
| 919 | - echo self::decode_safe_tag( 'span', esc_html__('Select plugins to be activated for each page type by clicking on <span class="dashicons dashicons-admin-plugins"></span> mark from "page type filter" registered plugins.', 'plf')); | |
| 920 | - ?><br /> | |
| 921 | - <?php esc_html_e('You can also select plugins to activate from Post/Page content editing screen.', 'plf') ?> | |
| 922 | - </p> | |
| 923 | - <p class="submit"> | |
| 924 | - <input type="submit" class="button-primary" name="clear_activate_page_filter" value="<?php esc_html_e('Clear', 'plf'); ?>" onclick="return confirm('<?php echo $clear_dialog; ?>')" /> | |
| 925 | - <input type="submit" class="button-primary" name="edit_activate_page_filter" value="<?php esc_html_e('Activate Plugin Entry »', 'plf'); ?>" /> | |
| 926 | - </p> | |
| 927 | - <?php | |
| 928 | - } else { | |
| 929 | - ?> | |
| 930 | - <br /> | |
| 931 | - <p><span style="color: #ff0000;"><?php esc_html_e('Page Filter is not registered', 'plf') ?></span></p> | |
| 932 | - <?php | |
| 933 | - } | |
| 599 | + } | |
| 600 | + else { | |
| 934 | 601 | ?> |
| 935 | - </form> | |
| 602 | + <br /> | |
| 603 | + <p><span style="color: #ff0000;"><?php _e('Page Filter is not registered', 'plf') ?></span></p> | |
| 604 | + <?php | |
| 605 | + } | |
| 606 | + ?> | |
| 936 | 607 | </div> |
| 608 | + </form> | |
| 937 | 609 | </div> |
| 938 | 610 | <?php |
| 939 | 611 | } |
| 940 | 612 | |
| @@ -942,11 +614,11 @@ | ||
| 942 | 614 | * Meta box |
| 943 | 615 | * Individual of the plug-in filter meta box for Post/Page/CustomPost |
| 944 | 616 | **************************************************************************/ |
| 945 | 617 | function load_meta_boxes( $post_type, $post ) { |
| 946 | - if ( current_user_can('activate_plugins', $post->ID) ) { | |
| 947 | - add_meta_box( 'pluginfilterdiv', esc_html__( 'Plugin Load Filter', 'plf' ), array(&$this, 'plf_meta_box'), null, 'side' ); | |
| 948 | - //add_action( 'admin_head', array(&$this, 'plf_css' )); | |
| 618 | + if ( current_user_can('edit_plugins', $post->ID) ) { | |
| 619 | + add_meta_box( 'pluginfilterdiv', __( 'Page Filter Plugin', 'plf' ), array(&$this, 'plf_meta_box'), null, 'side' ); | |
| 620 | + add_action( 'admin_head', array(&$this, 'plf_css' )); | |
| 949 | 621 | add_action( 'admin_footer', array(&$this, 'plf_meta_script' )); |
| 950 | 622 | } |
| 951 | 623 | } |
| 952 | 624 | |
| @@ -961,9 +633,9 @@ | ||
| 961 | 633 | $device['desktop'] = $checked_arcvplugins['desktop']; |
| 962 | 634 | $device['mobile'] = $checked_arcvplugins['mobile']; |
| 963 | 635 | $devlist = array('desktop','mobile'); |
| 964 | 636 | if(in_array( $p_key, $selplugins )){ |
| 965 | - $p_name = self::pluginkey_to_name($p_key); | |
| 637 | + $p_name = $this->pluginkey_to_name($p_key); | |
| 966 | 638 | $html .= "<tr><td class='plugins-name'>$p_name</td>"; |
| 967 | 639 | foreach($devlist as $devtype){ |
| 968 | 640 | $checked = (empty($device[$devtype]) || false === strpos($device[$devtype], $p_key))? false : true; |
| 969 | 641 | $html .= "<td class='device-type $devtype'>" . self::altcheckbox("plf_option[$devtype][$p_key]", $checked, '<span class="dashicons dashicons-yes"></span>') . '</td>'; |
| @@ -979,21 +651,21 @@ | ||
| 979 | 651 | // $checked_arcvplugins : array csv string : ['desktop']=desktop enable plugins, ['mobile']=mobile enable plugins |
| 980 | 652 | function pagefilter_plugins_checklist( $plugins, $select_cvplugins, $checked_arcvplugins ) { |
| 981 | 653 | |
| 982 | 654 | if(empty($select_cvplugins)) |
| 983 | - return esc_html__('Page Filter is not registered', 'plf'); | |
| 655 | + return __('Page Filter is not registered', 'plf'); | |
| 984 | 656 | |
| 985 | 657 | $html = '<table id="activation-table">'; |
| 986 | 658 | $html .= '<thead>'; |
| 987 | - $html .= '<tr><th class="plugins-name">'. esc_html__('Plugins') . '</th>'; | |
| 988 | - $html .= '<th class="device-type"><span title="'. esc_html__('Desktop Device', 'plf'). '" class="dashicons dashicons-desktop"></span><br /><span style="font-size:xx-small">Desktop</span></th>'; | |
| 989 | - $html .= '<th class="device-type"><span title="'. esc_html__('Mobile Device', 'plf'). '" class="dashicons dashicons-smartphone"></span><br /><span style="font-size:xx-small">Mobile</span></th>'; | |
| 659 | + $html .= '<tr><th class="plugins-name">'. __('Plugins') . '</th>'; | |
| 660 | + $html .= '<th class="device-type"><span title="'. __('Desktop Device', 'plf'). '" class="dashicons dashicons-desktop"></span><br /><span style="font-size:xx-small">Desktop</span></th>'; | |
| 661 | + $html .= '<th class="device-type"><span title="'. __('Mobile Device', 'plf'). '" class="dashicons dashicons-smartphone"></span><br /><span style="font-size:xx-small">Mobile</span></th>'; | |
| 990 | 662 | $html .= '</tr>'; |
| 991 | 663 | $html .= '</thead>'; |
| 992 | 664 | $html .= '<tbody class="plugins-table-body meta-boxes-plugins-table">'; |
| 993 | 665 | $nplugins = $jmodules = $cmodules = array(); |
| 994 | 666 | foreach ( $plugins as $p_key => $p_data ) { |
| 995 | - $p_name = self::pluginkey_to_name($p_key); | |
| 667 | + $p_name = $this->pluginkey_to_name($p_key); | |
| 996 | 668 | if(empty($p_name)) |
| 997 | 669 | continue; |
| 998 | 670 | if(strpos($p_key, 'jetpack_module/') !== false) |
| 999 | 671 | $jmodules[] = $p_key; |
| @@ -1022,114 +694,31 @@ | ||
| 1022 | 694 | $html .= '</table>'; |
| 1023 | 695 | return $html; |
| 1024 | 696 | } |
| 1025 | 697 | |
| 1026 | - //get_locale に加えたフィルターフックを外してサイトのロケールを取得 | |
| 1027 | - static function get_site_locale(){ | |
| 1028 | - global $locale; | |
| 1029 | - if(class_exists('Plf_filter')){ | |
| 1030 | - remove_filter( 'locale', array('Plf_filter', 'post_locale') ); | |
| 1031 | - $locale = null; | |
| 1032 | - $site_locale = get_locale(); | |
| 1033 | - add_filter( 'locale', array('Plf_filter', 'post_locale') ); | |
| 1034 | - } else { | |
| 1035 | - $locale = null; | |
| 1036 | - $site_locale = get_locale(); | |
| 1037 | - } | |
| 1038 | - return $site_locale; | |
| 1039 | - } | |
| 1040 | - | |
| 1041 | 698 | function plf_meta_box( $post, $box ) { |
| 1042 | 699 | if(is_object($post)){ |
| 1043 | 700 | $myfilter = get_post_meta( $post->ID, '_plugin_load_filter', true ); |
| 1044 | 701 | //ver2.2.0 for compatibility, set 'plugins' data to 'desktop' and 'mobile' |
| 1045 | - if(is_array($myfilter) && !empty($myfilter['plugins'])){ | |
| 702 | + if(!empty($myfilter['plugins'])){ | |
| 1046 | 703 | $myfilter['desktop'] = $myfilter['plugins']; |
| 1047 | 704 | $myfilter['mobile'] = $myfilter['plugins']; |
| 1048 | 705 | unset($myfilter['plugins']); |
| 1049 | 706 | } |
| 1050 | 707 | $default = array( 'filter' => 'default', 'desktop' => '', 'mobile' => ''); |
| 1051 | - $option = (!empty($myfilter) && is_array($myfilter))? $myfilter : $default; | |
| 708 | + $option = (!empty($myfilter))? $myfilter : $default; | |
| 1052 | 709 | $option = wp_parse_args( $option, $default); |
| 1053 | - $pgfilter = (!empty(self::$filter['_pagefilter']['plugins']))? self::$filter['_pagefilter']['plugins'] : array(); | |
| 710 | + $pgfilter = (!empty($this->filter['_pagefilter']['plugins']))? $this->filter['_pagefilter']['plugins'] : array(); | |
| 1054 | 711 | $ajax_nonce = wp_create_nonce( 'plugin_load_filter-' . $post->ID ); |
| 1055 | - $this->plf_css(); | |
| 1056 | 712 | ?> |
| 1057 | - <div id="plugin-filter-select"> | |
| 1058 | - <p><?php esc_html_e( 'Plugin filter for Single post', 'plf' ); ?></p> | |
| 1059 | - <label><input type="radio" name="pagefilter" value="default" <?php checked('default', $option['filter']); ?>/><?php esc_html_e('Not Use', 'plf' ); ?></label> | |
| 1060 | - <label><input type="radio" name="pagefilter" value="include" <?php checked('include', $option['filter']); ?>/><?php esc_html_e('Use', 'plf'); ?></label> | |
| 1061 | - <div id="page-filter-stat"> | |
| 1062 | - <?php echo $this->pagefilter_plugins_checklist( self::$plugins_inf, $pgfilter, $option ); ?> | |
| 1063 | - </div> | |
| 1064 | - <div class="plf-option-info"><?php esc_html_e('Plugin Activate/Deactivate filter for this Post only', 'plf'); ?></div> | |
| 1065 | - <?php | |
| 1066 | - $c_locale = $o_post_id = ''; | |
| 1067 | - $languages = array(); | |
| 1068 | - $locale_mode = 'style="display:none;"'; | |
| 1069 | - if(!empty(self::$filter['language'])){ | |
| 1070 | - $languages = get_available_languages(); | |
| 1071 | - $site_locale = self::get_site_locale(); | |
| 1072 | - //bogo と同じ _locale ポストメタデータ採用 | |
| 1073 | - $c_locale = get_post_meta( $post->ID, '_locale', true ); | |
| 1074 | - if(empty($c_locale)){ | |
| 1075 | - $c_locale = $site_locale; | |
| 1076 | - } | |
| 1077 | - if ( ! in_array( $c_locale, $languages ) ) { | |
| 1078 | - $c_locale = ''; | |
| 1079 | - } | |
| 1080 | - $o_post_id = get_post_meta( $post->ID, '_original_post_id', true ); | |
| 1081 | - $o_post_id = (is_numeric($o_post_id))? $o_post_id : ''; | |
| 1082 | - $locale_mode = ''; | |
| 1083 | - } | |
| 1084 | - echo '<p class="hide-if-no-js"><a id="plugin-filter-submit" class="button" href="#pluginfilterdiv" onclick="WPAddPagePluginLoadFilter(\'' . $ajax_nonce . '\');return false;" >'. esc_html__('Save') .'</a></p>'; | |
| 1085 | - ?> | |
| 1086 | - <hr> | |
| 1087 | - <div id="plf-post-locale-select" <?php echo $locale_mode; ?>> | |
| 1088 | - <p><?php esc_html_e( 'Language of this post', 'plf' ); ?> <span class="dashicons dashicons-translation" aria-hidden="true"></span></p> | |
| 1089 | - <?php | |
| 1090 | - wp_dropdown_languages( | |
| 1091 | - array( | |
| 1092 | - 'name' => 'plf_locale', | |
| 1093 | - 'id' => 'plf_locale', | |
| 1094 | - 'selected' => $c_locale, | |
| 1095 | - 'languages' => $languages, | |
| 1096 | - 'show_available_translations' => false, | |
| 1097 | - ) | |
| 1098 | - ); | |
| 1099 | - ?> | |
| 1100 | - <p><?php esc_html_e( 'Original post ID for hreflang', 'plf' ); ?></p> | |
| 1101 | - <input type="text" id="plf_original_post_id" name="plf_original_post_id" size="8" value="<?php echo $o_post_id; ?>" /> | |
| 1102 | - <div class="hflang-group-edit-lonk"> | |
| 1103 | - <?php | |
| 1104 | - $id = (is_numeric($o_post_id))? $o_post_id : $post->ID; | |
| 1105 | - global $wpdb; | |
| 1106 | - $ids = $wpdb->get_row($wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_original_post_id' AND meta_value = %d", $id ), ARRAY_N); | |
| 1107 | - if(is_array($ids)){ | |
| 1108 | - if(!in_array((string)$id, $ids)){ | |
| 1109 | - $ids[] = (string)$id; | |
| 1110 | - } | |
| 1111 | - if(count($ids) > 1){ | |
| 1112 | - foreach ($ids as $v) { | |
| 1113 | - if( $post->ID != $v){ | |
| 1114 | - $l = get_post_meta( $v, '_locale', true ); | |
| 1115 | - if(empty($l)){ | |
| 1116 | - $l = $site_locale; | |
| 1117 | - } | |
| 1118 | - $url = get_edit_post_link( $v ); | |
| 1119 | - if(!empty($url)){ | |
| 1120 | - echo '<p><a class="edit-post-locale-link" target="_blank" href="' . $url .'" rel="external noreferrer noopener">' . esc_html__('Edit Post') . " ($l) " . '<span class="dashicons dashicons-external" aria-hidden="true"></span></a></p>'; | |
| 1121 | - } | |
| 1122 | - } | |
| 1123 | - } | |
| 1124 | - } | |
| 1125 | - } | |
| 1126 | - ?> | |
| 1127 | - </div> | |
| 1128 | - <div class="plf-option-info"><?php esc_html_e('Use MO translation file for the selected locale. When Original Post ID is registered, posts with the same Original Post ID are treated as `hreflang` metadata group.', 'plf'); ?></div> | |
| 1129 | - <?php echo '<p class="hide-if-no-js"><a id="plugin-filter-submit" class="button" href="#pluginfilterdiv" onclick="WPAddPagePluginLoadFilter(\'' . $ajax_nonce . '\');return false;" >'. esc_html__('Save') .'</a></p>'; ?> | |
| 1130 | - </div> | |
| 713 | + <div id="plugin-filter-select"> | |
| 714 | + <label><input type="radio" name="pagefilter" value="default" <?php checked('default', $option['filter']); ?>/><?php _e('Not Use', 'plf' ); ?></label> | |
| 715 | + <label><input type="radio" name="pagefilter" value="include" <?php checked('include', $option['filter']); ?>/><?php _e('Activate Plugins', 'plf'); ?></label> | |
| 716 | + <div id="page-filter-stat"> | |
| 717 | + <?php echo $this->pagefilter_plugins_checklist( $this->plugins_inf, $pgfilter, $option ); ?> | |
| 1131 | 718 | </div> |
| 719 | + <?php echo '<p class="hide-if-no-js"><a id="plugin-filter-submit" class="button" href="#pluginfilterdiv" onclick="WPAddPagePluginLoadFilter(\'' . $ajax_nonce . '\');return false;" >'. __('Save') .'</a></p>'; ?> | |
| 720 | + </div> | |
| 1132 | 721 | <?php |
| 1133 | 722 | } |
| 1134 | 723 | } |
| 1135 | 724 | |
| @@ -1136,58 +725,18 @@ | ||
| 1136 | 725 | //wp_ajax_plugin_load_filter called function |
| 1137 | 726 | function plf_ajax_postidfilter() { |
| 1138 | 727 | if ( isset($_POST['post_id']) ) { |
| 1139 | 728 | $pid = (int) $_POST['post_id']; |
| 1140 | - if ( !current_user_can( 'activate_plugins', $pid ) ) | |
| 729 | + if ( !current_user_can( 'edit_plugins', $pid ) ) | |
| 1141 | 730 | wp_die( -1 ); |
| 1142 | 731 | check_ajax_referer( "plugin_load_filter-$pid" ); |
| 1143 | 732 | |
| 1144 | - if(!empty(self::$filter['language'])){ | |
| 1145 | - if(isset($_POST['locale'])){ | |
| 1146 | - $s_locale = (!empty($_POST['locale']))? $_POST['locale'] : 'en_US'; | |
| 1147 | - $languages = get_available_languages(); | |
| 1148 | - $languages[] = 'en_US'; //add WP default locale | |
| 1149 | - if ( in_array( $s_locale, $languages ) ) { | |
| 1150 | - $g_locale = get_post_meta( $pid, '_locale', true ); | |
| 1151 | - global $locale; | |
| 1152 | - if(class_exists('Plf_filter')){ | |
| 1153 | - remove_filter( 'locale', array('Plf_filter', 'post_locale') ); | |
| 1154 | - $locale = null; | |
| 1155 | - $o_locale = get_locale(); | |
| 1156 | - add_filter( 'locale', array('Plf_filter', 'post_locale') ); | |
| 1157 | - } else { | |
| 1158 | - $locale = null; | |
| 1159 | - $o_locale = get_locale(); | |
| 1160 | - } | |
| 1161 | - if($s_locale !== $g_locale){ | |
| 1162 | - if($s_locale === $o_locale){ | |
| 1163 | - delete_post_meta( $pid, '_locale'); | |
| 1164 | - } else { | |
| 1165 | - update_post_meta( $pid, '_locale', $s_locale ); | |
| 1166 | - } | |
| 1167 | - } | |
| 1168 | - } | |
| 1169 | - } | |
| 1170 | - if(isset($_POST['original_post_id'])){ | |
| 1171 | - if(empty($_POST['original_post_id'])){ | |
| 1172 | - delete_post_meta( $pid, '_original_post_id'); | |
| 1173 | - } elseif(preg_match( '/([0-9]+)?/', $_POST['original_post_id'], $match )){ | |
| 1174 | - $o_id = (int)$match[1]; | |
| 1175 | - $post = get_post($o_id); | |
| 1176 | - if(is_object($post)){ | |
| 1177 | - $g_id = get_post_meta( $pid, '_original_post_id', true ); | |
| 1178 | - if($o_id !== $g_id){ | |
| 1179 | - update_post_meta( $pid, '_original_post_id', $o_id ); | |
| 1180 | - } | |
| 1181 | - } | |
| 1182 | - } | |
| 1183 | - } | |
| 1184 | - } | |
| 1185 | - $pgfilter = (!empty(self::$filter['_pagefilter']['plugins']))? self::$filter['_pagefilter']['plugins'] : array(); | |
| 733 | + $pgfilter = (!empty($this->filter['_pagefilter']['plugins']))? $this->filter['_pagefilter']['plugins'] : array(); | |
| 1186 | 734 | $option["filter"] = (empty($_POST['filter']))? 'default' : $_POST['filter']; |
| 1187 | 735 | if('default' == $option["filter"]){ |
| 1188 | 736 | delete_post_meta( $pid, '_plugin_load_filter'); |
| 1189 | - } else { | |
| 737 | + } | |
| 738 | + else { | |
| 1190 | 739 | $plugins = array(); |
| 1191 | 740 | if( preg_match_all('/plf_option\[desktop\]\[(.+?)\]/u', $_POST['desktop'], $matches)){ |
| 1192 | 741 | if(!empty($matches[1])){ |
| 1193 | 742 | foreach ($matches[1] as $plugin){ |
| @@ -1207,41 +756,14 @@ | ||
| 1207 | 756 | } |
| 1208 | 757 | update_post_meta( $pid, '_plugin_load_filter', $option ); |
| 1209 | 758 | } |
| 1210 | 759 | |
| 1211 | - $html = $this->pagefilter_plugins_checklist( self::$plugins_inf, $pgfilter, $option ); | |
| 760 | + $html = $this->pagefilter_plugins_checklist( $this->plugins_inf, $pgfilter, $option ); | |
| 1212 | 761 | wp_send_json_success($html); |
| 1213 | 762 | } |
| 1214 | 763 | wp_die( 0 ); |
| 1215 | 764 | } |
| 1216 | 765 | |
| 1217 | - //alternate hreflang meta tag | |
| 1218 | - static function altenate_hreflang() { | |
| 1219 | - if ( is_singular() ) { | |
| 1220 | - global $post, $wpdb; | |
| 1221 | - $pid = $post->ID; | |
| 1222 | - $oid = get_post_meta( $pid, '_original_post_id', true ); | |
| 1223 | - $oid = (is_numeric($oid))? $oid : $pid; | |
| 1224 | - $ids = $wpdb->get_row($wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_original_post_id' AND meta_value = %d", $oid ), ARRAY_N); | |
| 1225 | - if(is_array($ids)){ | |
| 1226 | - if(!in_array((string)$oid, $ids)){ | |
| 1227 | - $ids[] = (string)$oid; | |
| 1228 | - } | |
| 1229 | - if(count($ids) > 1){ | |
| 1230 | - $site_locale = self::get_site_locale(); | |
| 1231 | - foreach ($ids as $id) { | |
| 1232 | - $l = get_post_meta( $id, '_locale', true ); | |
| 1233 | - if(empty($l)){ | |
| 1234 | - $l = $site_locale; | |
| 1235 | - } | |
| 1236 | - $url = get_permalink( $id ); | |
| 1237 | - echo '<link rel="alternate" hreflang="' . esc_attr($l) . '" href="' . esc_url($url) .'" />' . PHP_EOL; | |
| 1238 | - } | |
| 1239 | - } | |
| 1240 | - } | |
| 1241 | - } | |
| 1242 | - } | |
| 1243 | - | |
| 1244 | 766 | /*************************************************************************** |
| 1245 | 767 | * Javascript |
| 1246 | 768 | **************************************************************************/ |
| 1247 | 769 | function activetab_script() { ?> |
| @@ -1248,43 +770,14 @@ | ||
| 1248 | 770 | <script type='text/javascript' > |
| 1249 | 771 | /* <![CDATA[ */ |
| 1250 | 772 | var plf_activetab = <?php echo $this->tab_num; ?> |
| 1251 | 773 | /* ]]> */ |
| 1252 | - jQuery(document).ready(function ($) { | |
| 1253 | - plf_setting_tabs(); | |
| 1254 | - function plf_setting_tabs(){ $('#plf-setting-tabs').tabs({ active:plf_activetab, }); } | |
| 1255 | - }); | |
| 774 | + jQuery(document).ready(function ($) { plf_setting_tabs(); function plf_setting_tabs(){ $('#plf-setting-tabs').tabs({ active:plf_activetab, }); }}); | |
| 1256 | 775 | </script> |
| 1257 | 776 | <?php } |
| 1258 | 777 | |
| 1259 | - function plf_meta_script() { | |
| 1260 | - $reload_dialog = esc_html__('Plugin Load Filter setting has been updated.\nClick OK to reload the page.', 'plf'); | |
| 1261 | - ?> | |
| 778 | + function plf_meta_script() { ?> | |
| 1262 | 779 | <script type='text/javascript' > |
| 1263 | - WPAddPagePluginLoadFilter = function(nonce){ | |
| 1264 | - jQuery.ajax({ | |
| 1265 | - type: 'POST', | |
| 1266 | - url: ajaxurl, | |
| 1267 | - data: { | |
| 1268 | - action: "plugin_load_filter", | |
| 1269 | - post_id : jQuery( '#post_ID' ).val(), | |
| 1270 | - _ajax_nonce: nonce, | |
| 1271 | - locale: jQuery("select[name='plf_locale']").val(), | |
| 1272 | - original_post_id: jQuery("input[name='plf_original_post_id']").val(), | |
| 1273 | - filter: jQuery("input[name='pagefilter']:checked").val(), | |
| 1274 | - desktop: jQuery('.meta-boxes-plugins-table td.desktop input:checked').map(function(){ return jQuery(this).attr("name"); }).get().join(','), | |
| 1275 | - mobile: jQuery('.meta-boxes-plugins-table td.mobile input:checked').map(function(){ return jQuery(this).attr("name"); }).get().join(','), | |
| 1276 | - }, | |
| 1277 | - dataType: 'json', | |
| 1278 | - }).then( | |
| 1279 | - function (response, dataType) { | |
| 1280 | - jQuery('#page-filter-stat').html(response.data); | |
| 1281 | - if(window.confirm('<?php echo $reload_dialog; ?>')){ | |
| 1282 | - location.reload(); | |
| 1283 | - } | |
| 1284 | - }, | |
| 1285 | - function () { /* alert("ajax error"); */ } | |
| 1286 | - ); | |
| 1287 | - }; | |
| 780 | + WPAddPagePluginLoadFilter = function(nonce){ jQuery.ajax({ type: 'POST', url: ajaxurl, data: { action: "plugin_load_filter", post_id : jQuery( '#post_ID' ).val(), _ajax_nonce: nonce, filter: jQuery("input[name='pagefilter']:checked").val(), desktop: jQuery('.meta-boxes-plugins-table td.desktop input:checked').map(function(){ return jQuery(this).attr("name"); }).get().join(','), mobile: jQuery('.meta-boxes-plugins-table td.mobile input:checked').map(function(){ return jQuery(this).attr("name"); }).get().join(','),}, dataType: 'json', success: function(response, dataType) { jQuery('#page-filter-stat').html(response.data); }}); return false; }; | |
| 1288 | 781 | </script> |
| 1289 | 782 | <?php } |
| 1290 | -} | |
| 783 | +} | |