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