2017-12-21 10 views
0

私はクライアント用のWordPress用のプラグインをビルドしていますが、私は奇妙な問題を抱えているようです。オプションページを追加しましたが、正しく動作しません。WordPressプラグインの設定ページ(options_page)がDBアップグレードページにリダイレクトされます

私がWordpressメニューに行くと、私のオプションページが見えます。それは正しいオプションのページoptions-general.php?page=Beacon_Registation_WPを持っていますが、メニュー項目をクリックするとそのページが私にリダイレクトされますupgrade.php?_wp_http_referer=%2Fwp-admin%2Foptions-general.php%3Fpage%3DBeacon_Registation_WP

なぜこのようなことが起こっているのか分かりません。プラグインのエントリポイントとして使用して

コードイム:唯一の問題は、だから、Wordpressのいくつかのハッキング後OPTIONS_PAGE

答えて

0

あるので、わずか2つのショートコードを確認するために

<?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(); 

が正しく動作しています私たちはこれを掘り下げてinclude("admin.php")にしました。私は確信していますが、WordPressがこのプロセスを妨害し、このプロセスが動作しないように思われます。

のでinclude相対パスは、それがinclude("business.html");include("agency.html");と同じように動作するようですが、「admin.php」1は、ちょうど別のadmin.phpのは、どのようにか、なぜこの問題が発生した不明な点が含まれますように、それはだ起こらないように思われます。私はあなたがおそらく標準admin.phpを含む絶対パスを解決し、そのinclude(realpath(dirname(__FILE__))."/admin.php");

+1

経由含ま修正する

。それは[行50](https://github.com/WordPress/WordPress/blob/master/wp-admin/admin.php#L50)のあなたのようなリダイレクトを持っています。 [include](http://php.net/manual/en/function.include.php)のマニュアルでは、include_pathを最初に確認し、次に呼び出し元のファイルとcwdのdirを確認します。それは、ビジネスと代理店が期待どおりに機能していることを説明します – jh1711

関連する問題