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