PluginProbe
Plugin Load Filter / 2.4.0
Plugin Load Filter v2.4.0
trunk 2.0.0 2.0.1 2.1.0 2.2.0 2.2.1 2.3.0 2.3.1 2.4.0 2.4.1 2.5.1 3.3.0 4.0.6 4.1.1 4.2.0 4.3.0 4.3.1 4.4.0
← All changes | plugin-load-filter.php +25 -84 2.5.12.4.0 View file →
@@ -1,9 +1,9 @@
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: 2.5.1
5 + Version: 2.4.0
6 6 Plugin URI: http://celtislab.net/wp_plugin_load_filter
7 7 Author: enomoto@celtislab
8 8 Author URI: http://celtislab.net/
9 9 License: GPLv2
@@ -15,8 +15,26 @@
15 15 /***************************************************************************
16 16 * plugin activation / deactivation / uninstall
17 17 **************************************************************************/
18 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 +
19 37 //deactivation
20 38 function plugin_load_filter_deactivation( $network_deactivating ) {
21 39 $act = false;
22 40 if (is_multisite()) {
@@ -38,9 +56,8 @@
38 56 switch_to_blog( $current_blog_id );
39 57 }
40 58 }
41 59 if($act === false){
42 - flush_rewrite_rules(); //options data 'rewrite_rules' clear for remake.
43 60 if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
44 61 @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' );
45 62 }
46 63 }
@@ -78,9 +95,9 @@
78 95
79 96 private $plugins_inf = ''; //active plugin/module infomation
80 97 private $filter = array(); //filter option data
81 98 private $tab_num = 0;
82 -
99 +
83 100 /***************************************************************************
84 101 * Style Sheet
85 102 **************************************************************************/
86 103 function plf_css() { ?>
@@ -127,9 +144,8 @@
127 144 thead .device-type { background-color: oldlace;}
128 145 thead .tmpl-type { background-color: lavender;}
129 146 thead .pformat { background-color: honeydew;}
130 147 thead .tmpl-embed { background-color: lightyellow;}
131 - thead .tmpl-amp { background-color: #fff3b8;}
132 148 thead .tmpl-custom { background-color: lavenderblush;}
133 149 thead .filter-plugins-name, tbody .filter-plugins-name { min-width: 260px; max-width: 260px;}
134 150 thead .plugins-name, tbody .plugins-name { min-width: 180px; max-width: 180px;}
135 151 thead .filter-type, tbody .filter-type { min-width: 100px; max-width: 100px;}
@@ -155,9 +171,9 @@
155 171
156 172 public function __construct() {
157 173
158 174 load_plugin_textdomain('plf', false, basename( dirname( __FILE__ ) ).'/languages' );
159 -
175 +
160 176 $this->filter = get_option('plf_option');
161 177 //v2.3.0 option change
162 178 if(empty($this->filter['optver']) || $this->filter['optver'] < '2'){
163 179 $this->filter['optver'] = '2';
@@ -178,9 +194,9 @@
178 194 }
179 195
180 196 if(is_admin()) {
181 197 add_action( 'plugins_loaded', array(&$this, 'plf_admin_start'), 9999 );
182 - add_action( 'admin_init', array(&$this, 'action_posts'));
198 + add_action( 'admin_init', array(&$this, 'action_posts'));
183 199 add_action( 'add_meta_boxes', array(&$this, 'load_meta_boxes'), 10, 2 );
184 200 }
185 201 add_action( 'wp_ajax_plugin_load_filter', array(&$this, 'plf_ajax_postidfilter'));
186 202 }
@@ -226,9 +242,8 @@
226 242 //Plugins sub menu add
227 243 public function plf_option_menu() {
228 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'));
229 245 add_action('admin_print_scripts-'.$page, array(&$this, 'plf_scripts'));
230 - add_action('admin_print_scripts-'.$page, array(&$this, 'deploy_mu_plugins'));
231 246 }
232 247
233 248 //Plugin Load Filter setting page script
234 249 function plf_scripts() {
@@ -238,36 +253,9 @@
238 253 wp_enqueue_script( 'jquery-ui-tabs' );
239 254 add_action( 'admin_head', array(&$this, 'plf_css' ));
240 255 add_action( 'admin_head', array(&$this, 'jquery_tab_css' ));
241 256 add_action( 'admin_footer', array(&$this, 'activetab_script' ));
242 - add_action( 'admin_notices', array(&$this, 'plf_notice'));
243 257 }
244 -
245 - //plf-filter.php mu-plugins module set
246 - public function deploy_mu_plugins() {
247 - if(wp_mkdir_p( WPMU_PLUGIN_DIR )){
248 - if ( !file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
249 - @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php');
250 - }
251 - else {
252 - require_once(ABSPATH . 'wp-admin/includes/plugin.php');
253 - $dp = get_plugin_data( WPMU_PLUGIN_DIR . "/plf-filter.php", false, false );
254 - $sp = get_plugin_data( __DIR__ . '/mu-plugins/plf-filter.php', false, false );
255 - if(version_compare( $dp['Version'], $sp['Version'], '!=')){
256 - @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php');
257 - }
258 - }
259 - }
260 - }
261 -
262 - //Notice Message display
263 - public function plf_notice() {
264 - $notice = get_transient('plf_notice');
265 - if(!empty($notice)){
266 - echo "<div class='message error'><p>Plugin Load Filter : $notice</p></div>";
267 - delete_transient('plf_notice');
268 - }
269 - }
270 258
271 259 //plugin filter option action request (add, update, delete)
272 260 function action_posts() {
273 261 if (current_user_can( 'activate_plugins' )) {
@@ -317,18 +305,8 @@
317 305 }
318 306 else {
319 307 $this->filter['exclude'] = '';
320 308 }
321 - $items = array( 'amp', 'url_1', 'url_2' );
322 - foreach ($items as $key) {
323 - $url_key = (isset($_POST['plf_option'][$key]))? $_POST['plf_option'][$key] : '';
324 - if(empty($url_key) || preg_match('/\A([a-zA-Z0-9_\-]+)/u', $url_key)){
325 - $this->filter[$key] = $url_key;
326 - } else {
327 - $notice = __('There are invalid characters in AMP/URL Keyword. Use characters include Alphanumeric, Hyphens, Underscores.','plf');
328 - set_transient('plf_notice', $notice, 30);
329 - }
330 - }
331 309 update_option('plf_option', $this->filter );
332 310 }
333 311 header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page'));
334 312 exit;
@@ -338,11 +316,8 @@
338 316 foreach( array('_admin', '_pagefilter') as $item){
339 317 $this->filter[$item] = '';
340 318 }
341 319 $this->filter['exclude'] = '';
342 - $this->filter['amp'] = '';
343 - $this->filter['url_1'] = '';
344 - $this->filter['url_2'] = '';
345 320 update_option('plf_option', $this->filter );
346 321 header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page'));
347 322 exit;
348 323 }
@@ -420,9 +395,9 @@
420 395 }
421 396 static function altcheckbox($name, $value, $label = '') {
422 397 return "<input type='hidden' name='$name' value='0'><input type='checkbox' name='$name' value='1' " . checked( $value, 1, false ). "/><label> $label</label>";
423 398 }
424 -
399 +
425 400 public function plfregist_item($key, $val) {
426 401 $p_name = $this->pluginkey_to_name($key);
427 402 $opt_name = "plfregist[$key]";
428 403 ?>
@@ -514,29 +489,8 @@
514 489 $html .= '</div>';
515 490 echo $html;
516 491 ?>
517 492 </div>
518 - <div class="amp-url-pattern">
519 - <p><strong><?php _e( 'AMP / URL Page filter (Beta Test)', 'plf' ); ?></strong><br />
520 - <?php _e('Setting the keyword enables the filter. [Valid characters: alphanumeric characters, hyphens (-), underscores (_)]', 'plf'); ?><br />
521 - <?php _e('AMP / URL page judgment is done from REQUEST URI with regular expressions including setting keyword. <code>(/|&|\.|\?)keyword(/|&|=|\.|$)</code>', 'plf'); ?><br />
522 - <span style='background-color: #fbf7dc; padding: 2px;'>
523 - <?php _e('*AMP page display requires AMP plugin or theme.', 'plf'); ?>
524 - </span>
525 - </p>
526 - <?php
527 - $items = array( 'amp' => __('AMP keyword (In many cases, it is identified with "amp")', 'plf'), 'url_1' => __('URL filter keyword-1', 'plf'), 'url_2' => __('URL filter keyword-2', 'plf') );
528 - $html = "";
529 - foreach ($items as $key => $label) {
530 - $html .= "<div>";
531 - $val = (!empty($this->filter[$key]))? $this->filter[$key] : '';
532 - $html .= "<input id='plf_option[$key]' class='medium-text' type='text' name='plf_option[$key]' value='$val' />";
533 - $html .= "<label style='margin-left:10px;'>$label</label>";
534 - $html .= "</div>";
535 - }
536 - echo $html;
537 - ?>
538 - </div>
539 493 </div>
540 494 </div>
541 495 <?php
542 496 }
@@ -598,15 +552,8 @@
598 552 if(function_exists('is_embed')){
599 553 $title = __('WordPress Embed Content Card (API)', 'plf');
600 554 echo "<th class='tmpl-type tmpl-embed'><span title='$title' style='font-size:xx-small'>Embed Content</span></th>";
601 555 }
602 - $items = array( 'amp' => 'AMP filter', 'url_1' => 'URL filter1', 'url_2' => 'URL filter2' );
603 - foreach ($items as $key => $label) {
604 - if(!empty($filter[$key])){
605 - $title = "$label Keyword : " . $filter[$key];
606 - echo "<th class='tmpl-type tmpl-amp'><span title='$title' style='font-size:xx-small'>{$filter[$key]}</span></th>";
607 - }
608 - }
609 556 $post_types = get_post_types( array('public' => true, '_builtin' => false) );
610 557 foreach ( $post_types as $post_type ) {
611 558 if(!empty($post_type)){
612 559 $title = __('Custom Post : ', 'plf') . $post_type;
@@ -638,13 +585,8 @@
638 585 }
639 586 if(function_exists('is_embed')){
640 587 $chklist[] = 'content-card';
641 588 }
642 - foreach ($items as $key => $label) {
643 - if(!empty($filter[$key])){
644 - $chklist[] = $key;
645 - }
646 - }
647 589 $post_types = get_post_types( array('public' => true, '_builtin' => false) );
648 590 foreach ( $post_types as $post_type ) {
649 591 $chklist[] = $post_type;
650 592 }
@@ -671,9 +613,8 @@
671 613 }
672 614
673 615 //Option Setting Form Display
674 616 public function plf_option_page() {
675 - $clear_dialog = __('Plugin Load Filter Settings\nClick OK to clear it.', 'plf');
676 617 ?>
677 618 <h2><?php _e('Plugin Load Filter Settings', 'plf'); ?></h2>
678 619 <p></p>
679 620 <div id="plf-setting-tabs">
@@ -685,9 +626,9 @@
685 626 <?php wp_nonce_field( 'plugin_load_filter'); ?>
686 627 <div id="plf-registration-tab" style="display : none;">
687 628 <?php $this->plfregist_table($this->plugins_inf, $this->filter); ?>
688 629 <p class="submit">
689 - <input type="submit" class="button-primary" name="clear_regist_filter" value="<?php _e('Clear', 'plf'); ?>" onclick="return confirm('<?php echo $clear_dialog; ?>')" />&nbsp;&nbsp;&nbsp;
630 + <input type="submit" class="button-primary" name="clear_regist_filter" value="<?php _e('Clear', 'plf'); ?>" />&nbsp;&nbsp;&nbsp;
690 631 <input type="submit" class="button-primary" name="edit_regist_filter" value="<?php _e('Filter Entry &raquo;', 'plf'); ?>" />
691 632 </p>
692 633 </div>
693 634 <div id="plf-activation-tab" style="display : none;">
@@ -700,9 +641,9 @@
700 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 />
701 642 <?php _e('You can also select plugins to activate from Post/Page content editing screen.', 'plf') ?>
702 643 </p>
703 644 <p class="submit">
704 - <input type="submit" class="button-primary" name="clear_activate_page_filter" value="<?php _e('Clear', 'plf'); ?>" onclick="return confirm('<?php echo $clear_dialog; ?>')" />&nbsp;&nbsp;&nbsp;
645 + <input type="submit" class="button-primary" name="clear_activate_page_filter" value="<?php _e('Clear', 'plf'); ?>" />&nbsp;&nbsp;&nbsp;
705 646 <input type="submit" class="button-primary" name="edit_activate_page_filter" value="<?php _e('Activate Plugin Entry &raquo;', 'plf'); ?>" />
706 647 </p>
707 648 <?php
708 649 }