我正在开发一个wordpress插件,我有一个自己无法解决的问题。我只在加载CPT管理列表时才尝试加载一些操作和筛选器,我有以下代码:
主插件文件中的代码:
<?php
..
..
..
require_once WTDOMCHECK_PLUGIN_DIR.\'includes/class-plugin.php\';
$WTDOMCHECK_SERVERS = "";
$LICENSE_STATUS = "";
// All the magic is done here!
if ( class_exists(\'plugin\') ) $wtdomcheck = new plugin();
// Activation method
register_activation_hook( __FILE__, array($wtdomcheck, \'WTActivate\' ) );
// Deactivation method
register_deactivation_hook( __FILE__, array($wtdomcheck, \'WTDeactivate\' ) );
// Shortcode to insert the plugin
add_shortcode( \'wtdomcheck\', \'WTDomcheckShow\' );
//Fires basic tasks
$wtdomcheck->WTRegister();
// Where do you want to go?
if ( is_admin() ) {
require_once( \'admin/wtdomcheck_admin.php\' );
} else {
require_once( \'public/wtdomcheck_front.php\' );
}
?>
wtdomcheck\\u管理的内容。php:
<?php
/**
*
* This file contains the necesary functions to display the admin area of the plugin
*
* @author Ezequiel Cattaneo <[email protected]>
*
* @link https://webstower.com.ar/wtdomcheck
* @since 1.0.0
*
**/
require_once WTDOMCHECK_PLUGIN_DIR.\'admin/class/class-admin.php\';
$wtdomadmin = \'\';
//All the magic is done here!
if ( class_exists(\'admin\') ) {
$wtdomadmin = new admin();
$wtdomadmin->WTRegister();
}
?>
以及下面的类文件class admin中的问题。php:
<?
..
..
//
// PARAM
// Register all the actions and filters for the Admin area
//
public function WTRegister()
{
$this->settings->
WTAddPages( $this->pages ) ->
WTWithSubPage( \'Dashboard\' ) ->
WTAddSubPages( $this->subpages ) ->
WTRegister();
//Load stuffs for the settings page
add_action( \'load-settings_page_wtdomaincheck\',
array($this, \'WTRegisterSettingsStuff\')
);
//Load stuffs for the CPT list
add_action( \'edit-wt_whoisservers\', array($this, \'WTRegisterCPTStuff\') );
//Load the widget for the dashboard
add_action( \'wp_dashboard_setup\',
array($this, \'WTDashboardWidgetSettings\')
);
//PLUGIN LIST: Add custom links to the plugin, below the plugin name
add_filter( \'plugin_action_links_\'.WTDOMCHECK_PLUGIN_NAME,
array($this->settings, \'WTAddCustomLinks\')
);
// Add to the admin_init action hook
add_filter(\'current_screen\', array($this, \'WTScreenId\') );
}
..
..
?>
在这段代码中,只有在屏幕中加载了设置页面,并且功能正常时,才会加载操作和过滤器:
//Load stuffs for the settings page
add_action( \'load-settings_page_wtdomaincheck\',
array($this, \'WTRegisterSettingsStuff\')
);
问题是,这种代码的和平被忽略,而没有执行:
//Load stuffs for the CPT list
add_action( \'edit-wt_whoisservers\', array($this, \'WTRegisterCPTStuff\') );
I want load actions and filters only when the cpt is displayed at screen.. 获取当前屏幕信息时,获得了屏幕id“edit-wt\\u whoisservers”。
任何帮助都将不胜感激!提前感谢