WordPress插件设置页面(options_page)重定向到数据库升级页面

时间:2017-12-21 11:42:35

标签: php wordpress

我一直在为客户端构建一个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

1 个答案:

答案 0 :(得分:1)

因此,在对Wordpress管理面板进行一些黑客攻击后,我们设法将其深入到 @Test public void testMergesortUnsortedList() { List<Integer> sequence = new ArrayList<>(Arrays.asList(3, 2, 1, 5, 4)); MergeSort.mergeSort(sequence); System.out.println("final: " + sequence); assertEquals(Arrays.asList(1, 2, 3, 4, 5), sequence); sequence = new ArrayList<>(Arrays.asList(3, 2, 1, 6, 5, 4)); MergeSort.mergeSort(sequence); assertEquals(sequence, Arrays.asList(1, 2, 3, 4, 5, 6)); } import java.util.ArrayList; import java.util.List; public class MergeSort { public static <E extends Comparable<E>> void mergeSort(List<E> list) { if (list.size() > 1) { // the first half of the list (always smaller than or equal to tail) ArrayList<E> head = new ArrayList<>(list.subList(0, list.size() / 2)); // the second half of the list ArrayList<E> tail = new ArrayList<>(list.subList(list.size() / 2, list.size())); //temporary list ArrayList<E> temp = new ArrayList<>(); if (head.size() > 1) { mergeSort(head); } if (tail.size() > 1) { mergeSort(tail); } // while either head or tail still has a member while (head.size() > 0 || tail.size() > 0) { // if both head and tail still have members if (head.size() > 0 && tail.size() > 0) { // if head is smaller than tail if (head.get(0).compareTo(tail.get(0)) < 1) { temp.add(head.get(0)); head.remove(0); } else { temp.add(tail.get(0)); tail.remove(0); } // if only head has members } else if (head.size() > 0) { temp.add(head.get(0)); head.remove(0); // if only tail has members } else { temp.add(tail.get(0)); tail.remove(0); } } // overwrite the old list with the sorted list list = temp; System.out.println(list); } } } 我不确定WordPress如何干预并阻止此过程工作。

所以include("admin.php")相对路径似乎与includeinclude("business.html");一样有效,但是&#34; admin.php&#34;一个似乎没有发生它就像另一个admin.php得到的不确定如何或为什么会发生这种情况。

所以要修复我解决了绝对路径,并通过include("agency.html");

包含
相关问题