我有一个使用OOP的插件,它可以在我的本地主机上完美运行,但不能在我的Bluehost服务器上运行。除Composer自动加载外,它不需要任何依赖关系(我已将composer生成的供应商文件夹和json上传到远程插件文件夹)。我知道该插件正在激活,因为它正在为我的wp_options生成空的数据库条目。但是,我的add_menu_page函数没有在管理控制台中生成选项页面。
我确保本地主机和远程主机运行的是相同版本的PHP(7.2+)和Wordpress(5.0.3)
我已经禁用了所有其他插件,并尝试在21主题中使用uding,所以我非常有信心这不是由于冲突引起的。
我已在wp_config中启用调试,并且未收到任何错误。
我的Bluehost错误日志中没有错误
下面是我的Dashboard.php示例。...我之所以发布它,是因为缺少菜单选项是我未知错误的征兆,但我不认为是原因
<?php
/**
* @package ICUPlugin
*/
namespace Inc\Pages;
use Inc\Api\SettingsApi;
use Inc\Base\BaseController;
use Inc\Api\Callbacks\AdminCallbacks;
use Inc\Api\Callbacks\ManagerCallbacks;
/**
*
*/
class Dashboard extends BaseController
{
public $settings;
public $callbacks;
public $callbacks_mgr;
public $pages = array();
//public $subpages = array();
public function register()
{
$this->settings = new SettingsApi();
$this->callbacks = new AdminCallbacks();
$this->callbacks_mgr = new ManagerCallbacks();
$this->setPages();
//$this->setSubpages();
$this->setSettings();
$this->setSections();
$this->setFields();
$this->settings->addPages( $this->pages )->withSubPage( 'Dashboard'
)->register();
}
public function setPages() {
$this->pages = array(
array(
'page_title' => 'ICU Plugin',
'menu_title' => 'ICU',
'capability' => 'manage_options',
'menu_slug' => 'icu_plugin',
'callback' => array( $this->callbacks, 'adminDashboard' ),
'icon_url' => 'dashicons-store',
'position' => 110
)
);
}
public function setSettings() {
$args = array(
array(
'option_group' => 'icu_plugin_settings',
'option_name' => 'icu_plugin',
'callback' => array( $this->callbacks_mgr, 'checkboxSanitize'
)
)
);
$this->settings->setSettings( $args );
}
public function setSections() {
$args = array(
array(
'id' => 'icu_admin_index',
'title' => 'Settings Manager',
'callback' => array( $this->callbacks_mgr,
'adminSectionManager' ),
'page' => 'icu_plugin'
)
);
$this->settings->setSections( $args );
}
public function setFields() {
$args = array();
foreach( $this->settingsManagers as $key => $value ) {
$args[] = array(
'id' => $key,
'title' => $value,
'callback' => array( $this->callbacks_mgr, 'checkboxField' ),
'page' => 'icu_plugin',
'section' => 'icu_admin_index',
'args' => array(
'option_name' => 'icu_plugin',
'label_for' => $key,
'class' => 'ui-toggle'
)
);
}
$this->settings->setFields( $args );
}
}