PluginProbe
Plugin Load Filter / 2.3.1
Plugin Load Filter v2.3.1
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 +34 -85 2.4.12.3.1 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.4.1
5 + Version: 2.3.1
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
@@ -9,88 +9,9 @@
9 9 License: GPLv2
10 10 Text Domain: plf
11 11 Domain Path: /languages
12 12 */
13 -defined( 'ABSPATH' ) || exit;
14 13
15 -/***************************************************************************
16 - * plugin activation / deactivation / uninstall
17 - **************************************************************************/
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 -
37 - //deactivation
38 - function plugin_load_filter_deactivation( $network_deactivating ) {
39 - $act = false;
40 - if (is_multisite()) {
41 - if(! $network_deactivating){
42 - global $wpdb;
43 - $current_blog_id = get_current_blog_id();
44 - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
45 - foreach ( $blog_ids as $blog_id ) {
46 - if($blog_id == $current_blog_id){
47 - //current site
48 - }
49 - else {
50 - //other site active check
51 - switch_to_blog( $blog_id );
52 - if ( is_plugin_active( plugin_basename( __FILE__ )))
53 - $act = true;
54 - }
55 - }
56 - switch_to_blog( $current_blog_id );
57 - }
58 - }
59 - if($act === false){
60 - flush_rewrite_rules(); //options data 'rewrite_rules' clear for remake.
61 - if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
62 - @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' );
63 - }
64 - }
65 - }
66 - register_deactivation_hook( __FILE__, 'plugin_load_filter_deactivation' );
67 -
68 - //uninstall
69 - function plugin_load_filter_uninstall() {
70 -
71 - if ( !is_multisite()) {
72 - delete_option('plf_queryvars');
73 - delete_option('plf_option' );
74 - } else {
75 - global $wpdb;
76 - $current_blog_id = get_current_blog_id();
77 - $blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
78 - foreach ( $blog_ids as $blog_id ) {
79 - switch_to_blog( $blog_id );
80 - delete_option('plf_queryvars');
81 - delete_option('plf_option' );
82 - }
83 - switch_to_blog( $current_blog_id );
84 - }
85 - if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
86 - @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' );
87 - }
88 - }
89 - register_uninstall_hook(__FILE__, 'plugin_load_filter_uninstall');
90 -
91 -}
92 -
93 14 $Plf_setting = new Plf_setting();
94 15
95 16 class Plf_setting {
96 17
@@ -195,14 +116,41 @@
195 116 }
196 117
197 118 if(is_admin()) {
198 119 add_action( 'plugins_loaded', array(&$this, 'plf_admin_start'), 9999 );
199 - add_action( 'admin_init', array(&$this, 'action_posts'));
200 120 add_action( 'add_meta_boxes', array(&$this, 'load_meta_boxes'), 10, 2 );
121 + //plf-filter must-use plagin activete check
122 + if(wp_mkdir_p( WPMU_PLUGIN_DIR )){
123 + if ( !file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
124 + @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php');
125 + }
126 + else {
127 + require_once(ABSPATH . 'wp-admin/includes/plugin.php');
128 + $dp = get_plugin_data( WPMU_PLUGIN_DIR . "/plf-filter.php", false, false );
129 + $sp = get_plugin_data( __DIR__ . '/mu-plugins/plf-filter.php', false, false );
130 + if(version_compare( $dp['Version'], $sp['Version'], '!=')){
131 + @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php');
132 + }
133 + }
134 + }
135 + register_deactivation_hook( __FILE__, 'Plf_setting::deactivation' );
136 + register_uninstall_hook(__FILE__, 'Plf_setting::uninstall');
201 137 }
202 138 add_action( 'wp_ajax_plugin_load_filter', array(&$this, 'plf_ajax_postidfilter'));
203 139 }
204 140
141 + //Plugin Deactivate
142 + public static function deactivation() {
143 + if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) {
144 + @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' );
145 + }
146 + }
147 + //Plugin Uninstall
148 + public static function uninstall() {
149 + delete_option('plf_queryvars');
150 + delete_option('plf_option' );
151 + }
152 +
205 153 //Plugin Load Filter admin setting start
206 154 public function plf_admin_start() {
207 155 require_once(ABSPATH . 'wp-admin/includes/plugin.php');
208 156
@@ -236,8 +184,9 @@
236 184 }
237 185 if ( empty( $this->plugins_inf ) )
238 186 return;
239 187
188 + $this->action_posts(); //POST, GET Request Action
240 189 add_action('admin_menu', array(&$this, 'plf_option_menu'));
241 190 }
242 191
243 192 //Plugins sub menu add
@@ -258,9 +207,9 @@
258 207 }
259 208
260 209 //plugin filter option action request (add, update, delete)
261 210 function action_posts() {
262 - if (current_user_can( 'activate_plugins' )) {
211 + if (current_user_can( 'edit_plugins' )) {
263 212 if( isset($_POST['edit_regist_filter']) ) {
264 213 if(isset($_POST['plfregist'])){
265 214 check_admin_referer('plugin_load_filter');
266 215 foreach( array('_admin', '_pagefilter') as $item){
@@ -622,9 +571,9 @@
622 571 <ul>
623 572 <li><a href="#plf-registration-tab" ><?php _e('Filter Registration', 'plf'); ?></a></li>
624 573 <li><a href="#plf-activation-tab" ><?php _e('Page Filter Activation', 'plf'); ?></a></li>
625 574 </ul>
626 - <form method="post" autocomplete="off">
575 + <form method="post" >
627 576 <?php wp_nonce_field( 'plugin_load_filter'); ?>
628 577 <div id="plf-registration-tab" style="display : none;">
629 578 <?php $this->plfregist_table($this->plugins_inf, $this->filter); ?>
630 579 <p class="submit">
@@ -665,9 +614,9 @@
665 614 * Meta box
666 615 * Individual of the plug-in filter meta box for Post/Page/CustomPost
667 616 **************************************************************************/
668 617 function load_meta_boxes( $post_type, $post ) {
669 - if ( current_user_can('activate_plugins', $post->ID) ) {
618 + if ( current_user_can('edit_plugins', $post->ID) ) {
670 619 add_meta_box( 'pluginfilterdiv', __( 'Page Filter Plugin', 'plf' ), array(&$this, 'plf_meta_box'), null, 'side' );
671 620 add_action( 'admin_head', array(&$this, 'plf_css' ));
672 621 add_action( 'admin_footer', array(&$this, 'plf_meta_script' ));
673 622 }
@@ -776,9 +725,9 @@
776 725 //wp_ajax_plugin_load_filter called function
777 726 function plf_ajax_postidfilter() {
778 727 if ( isset($_POST['post_id']) ) {
779 728 $pid = (int) $_POST['post_id'];
780 - if ( !current_user_can( 'activate_plugins', $pid ) )
729 + if ( !current_user_can( 'edit_plugins', $pid ) )
781 730 wp_die( -1 );
782 731 check_ajax_referer( "plugin_load_filter-$pid" );
783 732
784 733 $pgfilter = (!empty($this->filter['_pagefilter']['plugins']))? $this->filter['_pagefilter']['plugins'] : array();