filter = get_option('plf_option'); if(is_admin()) { add_action( 'plugins_loaded', array(&$this, 'plf_admin_start'), 9999 ); add_action( 'update_option_plf_option', array(&$this, 'plf_transient_clear') ); add_action( 'update_option_active_plugins', array(&$this, 'plf_transient_clear') ); add_action( 'update_option_jetpack_active_modules', array(&$this, 'plf_transient_clear') ); add_action( 'update_option_celtispack_active_modules', array(&$this, 'plf_transient_clear') ); add_action( 'add_meta_boxes', array(&$this, 'load_meta_boxes'), 10, 2 ); //plf-filter must-use plagin activete check if(wp_mkdir_p( WPMU_PLUGIN_DIR )){ if ( !file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { @copy(__DIR__ . '/mu-plugins/plf-filter.php', WPMU_PLUGIN_DIR . '/plf-filter.php'); } } register_deactivation_hook( __FILE__, 'Plf_setting::deactivation' ); register_uninstall_hook(__FILE__, 'Plf_setting::uninstall'); } add_action( 'save_post', array(&$this, 'plf_transient_clear') ); add_action( 'deleted_post', array(&$this, 'plf_transient_clear') ); add_action( 'wp_ajax_plugin_load_filter', array(&$this, 'plf_ajax_postidfilter')); } //Plugin Deactivate public static function deactivation() { if ( file_exists( WPMU_PLUGIN_DIR . "/plf-filter.php" )) { @unlink( WPMU_PLUGIN_DIR . '/plf-filter.php' ); } } //Plugin Uninstall public static function uninstall() { delete_option('plf_queryvars'); delete_option('plf_option' ); } //Disable the transient cache by changing the update time public function plf_transient_clear() { $this->filter['updated'] = strtotime("now"); update_option('plf_option', $this->filter ); } //Plugin Load Filter admin setting start public function plf_admin_start() { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); $this->plugins_inf = get_plugins(); $packplug = array(); foreach ( $this->plugins_inf as $plugin_key => $a_plugin ) { if(is_plugin_inactive( $plugin_key )){ unset($this->plugins_inf[$plugin_key]); } } //jetpack active module if(method_exists('Jetpack', 'get_module')){ $modules = Jetpack::get_active_modules(); $modules = array_diff( $modules, array( 'vaultpress' ) ); foreach ( $modules as $key => $module_name ) { if(!empty($module_name)){ $module = Jetpack::get_module( $module_name ); if(!empty($module)) $this->plugins_inf['jetpack_module/' . $module_name] = $module; } } } //celtispack active module if(method_exists('Celtispack', 'get_module')){ $modules = Celtispack::get_active_modules(); foreach ( $modules as $key => $module_name ) { if(!empty($module_name)){ $this->plugins_inf['celtispack_module/' . $module_name] = Celtispack::get_module( $module_name ); } } } if ( empty( $this->plugins_inf ) ) return; $this->action_posts(); //POST, GET Request Action add_action('admin_menu', array(&$this, 'plf_option_menu')); } //Plugins sub menu add public function plf_option_menu() { $page = add_plugins_page( 'Plugin Load Filter', __('Plugin Load Filter', 'plf'), 'manage_options', 'plugin_load_filter_admin_manage_page', array(&$this,'plf_option_page')); add_action('admin_print_scripts-'.$page, array(&$this, 'plf_scripts')); } //Plugin Load Filter setting page script function plf_scripts() { wp_enqueue_script( 'jquery' ); wp_enqueue_script( 'jquery-ui-core' ); wp_enqueue_script( 'jquery-ui-widget' ); wp_enqueue_script( 'jquery-ui-tabs' ); add_action( 'admin_head', array(&$this, 'plf_css' )); add_action( 'admin_head', array(&$this, 'jquery_tab_css' )); add_action( 'admin_footer', array(&$this, 'activetab_script' )); } //plugin filter option action request (add, update, delete) function action_posts() { if (current_user_can( 'edit_plugins' )) { if( isset($_POST['edit_regist_filter']) ) { if(isset($_POST['plfregist'])){ check_admin_referer('plugin_load_filter'); foreach( array('_admin', '_desktop', '_mobile', '_pagefilter') as $item){ $plugins = array(); foreach ( $_POST['plfregist'] as $p_key => $val ) { if($val == $item) $plugins[$p_key] = $val; } if($item == '_pagefilter'){ //If all modules is specified filter, in some cases you want to deactivate plugin itself. $jbase = $cbase = ''; $jall = $call = true; foreach ( $_POST['plfregist'] as $p_key => $val ) { if(strpos($p_key, 'jetpack/') !== false) $jbase = $p_key; else if(strpos($p_key, 'celtispack/') !== false) $cbase = $p_key; else if(strpos($p_key, 'jetpack_module/') !== false){ if($val != '_pagefilter' && $val != '_admin'){ $jall = false; } } else if(strpos($p_key, 'celtispack_module/') !== false){ if($val != '_pagefilter' && $val != '_admin') $call = false; } } if(!empty($jbase) && $jall === false) unset($plugins[$jbase]); if(!empty($cbase) && $call === false) unset($plugins[$cbase]); } $option["plugins"] = implode(",", array_keys($plugins)); $this->filter[$item] = $option; } $this->filter['updated'] = strtotime("now"); update_option('plf_option', $this->filter ); } header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page')); exit; } elseif( isset($_POST['clear_regist_filter']) ) { check_admin_referer('plugin_load_filter'); foreach( array('_admin', '_desktop', '_mobile', '_pagefilter') as $item){ $this->filter[$item] = ''; } $this->filter['updated'] = strtotime("now"); update_option('plf_option', $this->filter ); header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page')); exit; } else if(isset($_POST['edit_activate_page_filter']) ) { if(isset($_POST['plfactive'])){ check_admin_referer('plugin_load_filter'); $group = array_keys($_POST['plfactive']); foreach( $group as $item){ $plugins = array(); foreach ( $_POST['plfactive'][$item] as $p_key => $val ) { if($val == '1') $plugins[] = $p_key; } $option["plugins"] = implode(",", $plugins); $this->filter['group'][$item] = $option; } $this->filter['updated'] = strtotime("now"); update_option('plf_option', $this->filter ); } header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page&action=tab_1')); exit; } elseif( isset($_POST['clear_activate_page_filter']) ) { check_admin_referer('plugin_load_filter'); $group = array_keys($_POST['plfactive']); foreach( $group as $item){ $this->filter['group'][$item] = ''; } $this->filter['updated'] = strtotime("now"); update_option('plf_option', $this->filter ); header('Location: ' . admin_url('plugins.php?page=plugin_load_filter_admin_manage_page&action=tab_1')); exit; } if(!empty($_GET['action']) && $_GET['action']=='tab_1') { $this->tab_num = 1; } } } //Plugin or Module key to name // $type : list/smart/tree public function pluginkey_to_name( $infkey, $type='list') { $name = ''; if(strpos($infkey, 'jetpack_module/') !== false){ if(!empty($this->plugins_inf[$infkey]['name'])){ $m_mark = ($type !== 'list')? '-' : 'Jetpack-'; if($type === 'smart') { if(empty($this->filter['_pagefilter']['plugins']) || strpos($this->filter['_pagefilter']['plugins'], 'jetpack/') === false) $name = $m_mark . $this->plugins_inf[$infkey]['name']; } else $name = $m_mark . $this->plugins_inf[$infkey]['name']; } } elseif(strpos($infkey, 'celtispack_module/') !== false){ if(!empty($this->plugins_inf[$infkey]['Name'])){ $m_mark = ($type !== 'list')? '-' : 'Celtispack-'; if($type === 'smart') { if(empty($this->filter['_pagefilter']['plugins']) || strpos($this->filter['_pagefilter']['plugins'], 'celtispack/') === false) $name = $m_mark . $this->plugins_inf[$infkey]['Name']; } else $name = $m_mark . $this->plugins_inf[$infkey]['Name']; } } else { if(!empty($this->plugins_inf[$infkey]['Name'])) $name = $this->plugins_inf[$infkey]['Name']; } return($name); } //Checkbox static function checkbox($name, $value, $label = '') { return ""; } static function altcheckbox($name, $value, $label = '') { return ""; } //Plugin pagefilter Selected Checkbox (plugin and modules list) // $plugins : array : all active plugins // $select_cvplugins : csv string : pagefilter selected plugins // $checked_cvplugins : csv string : checked plugins function pagefilter_plugins_checklist( $plugins, $select_cvplugins, $checked_cvplugins ) { if(empty($select_cvplugins)) return __('Page Filter is not registered', 'plf'); $nplugins = $jmodules = $cmodules = array(); foreach ( $plugins as $p_key => $p_data ) { $p_name = $this->pluginkey_to_name($p_key); if(empty($p_name)) continue; if(strpos($p_key, 'jetpack_module/') !== false) $jmodules[] = $p_key; else if(strpos($p_key, 'celtispack_module/') !== false) $cmodules[] = $p_key; else $nplugins[] = $p_key; } $selplugins = array_map("trim", explode(',', $select_cvplugins)); $chkplugins = array_map("trim", explode(',', $checked_cvplugins)); $html = '
Home |
Archive |
Search |
Attach |
Page |
Post |
Image |
Gallery |
Video |
Audio |
Aside |
Quote |
Link |
Status |
Chat |
true, '_builtin' => false) );
foreach ( $post_types as $post_type ) {
if(!empty($post_type)){
$title = __('Custom Post : ', 'plf') . $post_type;
echo "$post_type | "; } } ?>|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| $p_name | "; foreach($chklist as $pgtype){ $checked = (empty($filter['group'][$pgtype]['plugins']) || false === strpos($filter['group'][$pgtype]['plugins'], $p_key))? false : true; echo '' . self::altcheckbox("plfactive[$pgtype][$p_key]", $checked, '') . ' | '; } echo "|||||||||||||||
| $p_name | "; foreach($chklist as $pgtype){ $checked = (empty($filter['group'][$pgtype]['plugins']) || false === strpos($filter['group'][$pgtype]['plugins'], $p_key))? false : true; echo '' . self::altcheckbox("plfactive[$pgtype][$p_key]", $checked, '') . ' | '; } echo "|||||||||||||||
| $p_name | "; foreach($chklist as $pgtype){ $checked = (empty($filter['group'][$pgtype]['plugins']) || false === strpos($filter['group'][$pgtype]['plugins'], $p_key))? false : true; echo '' . self::altcheckbox("plfactive[$pgtype][$p_key]", $checked, '') . ' | '; } echo "