我一直在为客户端构建一个WordPress插件,但我似乎遇到了一个奇怪的问题。我添加了一个选项页面,但它无法正常工作。
当我转到Wordpress菜单时,我可以看到我的选项页面。它有正确的选项页面options-general.php?page=Beacon_Registation_WP
,但是当我点击菜单项时,该页面将我重定向到upgrade.php?_wp_http_referer=%2Fwp-admin%2Foptions-general.php%3Fpage%3DBeacon_Registation_WP
我不确定为什么会这样。
我使用的代码作为插件的入口点:
<?php
/**
* Plugin Name: ** OMITED **
* Plugin URI: ** OMITED **
* Description: This plugin enabled the wordpress site to register new users to the beaconapp
* Version: 1.0
* Author: Martin Barker - ** OMITED **
* Author URI: ** OMITED **
* License: Propriatry Software (do not distribute)
*/
class BeaconRegistation
{
// handler for registing the wp-admin menu
public function addMenuItem()
{
add_options_page( 'Configure Server', 'BeaconApp Registation', 'manage_options', 'Beacon_Registation_WP', array($this, "wp_admin") );
}
// display the wp_admin page for this plugin
public function wp_admin()
{
ob_start();
if ( !current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
$this->sdr = get_option("sdr", "martindev.** OMITED **");
if($_POST['sdr'] !== $this->sdr){
update_option("sdr", $_POST['sdr']);
$this->sdr = get_option("sdr", "martindev.** OMITED **");
}
// include the view for switch environment
include("admin.php");
return ob_get_clean();
}
// displays the shortcode 'ba_business_form'
public function showBusinessForm($atts, $content = "")
{
ob_start();
if($_POST['form_mode'] == "business"){
// form has been posted
}else{
include("business.html");
}
return ob_get_clean();
}
// displays the short code 'ba_agency_form'
public function showAgencyForm($atts, $content = "")
{
ob_start();
if($_POST['form_mode'] == "agency"){
// form has been posted
}else{
include("agency.html");
}
return ob_get_clean();
}
public function init()
{
// add the admin menu call
add_action( 'admin_menu', array($this, "addMenuItem"));
// add the short code for the business form
add_shortcode("ba_business_form", array($this, "showBusinessForm"));
// add the short code for the agency form
add_shortcode("ba_agency_form", array($this, "showAgencyForm"));
}
}
(new BeaconRegistation())->init();
只是为了确认2个短代码是否正常工作,唯一的问题是options_page
因此,在对Wordpress管理面板进行一些黑客攻击后,我们设法将其挖掘到include("admin.php")
我不确定如何但WordPress似乎干扰并阻止此过程工作。
所以include
相对路径似乎与include("business.html");
和include("agency.html");
一样工作但是“admin.php”似乎没有发生它就像另一个admin.php get包括不确定如何或为什么会发生这种情况。
所以要修复我解决了绝对路径,并通过该include(realpath(dirname(__FILE__))."/admin.php");
包括