Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
找不到Wordpress错误选项页_Wordpress_Options - Fatal编程技术网

找不到Wordpress错误选项页

找不到Wordpress错误选项页,wordpress,options,Wordpress,Options,我知道对于同一个错误有很多帖子,但是所有的解决方案在我的情况下都不起作用 我认为option\u页面和option\u组都可以。所以我不知道问题出在哪里…也许是我的插件的结构 这是我的主类jmvwmanager <?php class JMVWManage { public function __construct(){ register_activation_hook(__FILE__, array('JMVWManage', 'install'));

我知道对于同一个错误有很多帖子,但是所有的解决方案在我的情况下都不起作用

我认为
option\u页面
option\u组
都可以。所以我不知道问题出在哪里…也许是我的插件的结构

这是我的主类
jmvwmanager

 <?php

 class JMVWManage
 {
     public function __construct(){
         register_activation_hook(__FILE__, array('JMVWManage', 'install'));
         register_uninstall_hook(__FILE__, array('JMVWManage', 'uninstall'));
         add_action('admin_menu', array($this, 'add_admin_menu'), 20);

         include_once plugin_dir_path( __FILE__ ).'/admin/jmvwform.php';

         // Tracks new sections for whitelist_custom_options_page()
         $this->page_sections = array();
         // Must run after wp's `option_update_filter()`, so priority > 10
         add_action( 'whitelist_options', array( $this, 'whitelist_custom_options_page' ),11 );

        }

     // White-lists options on custom pages.
     // Workaround for second issue: 
     public function whitelist_custom_options_page( $whitelist_options ){
     // Custom options are mapped by section id; Re-map by page slug.
        foreach($this->page_sections as $page => $sections ){
            $whitelist_options[$page] = array();
            foreach( $sections as $section )
                if( !empty( $whitelist_options[$section] ) )
                    foreach( $whitelist_options[$section] as $option )
                        $whitelist_options[$page][] = $option;
        }
        return $whitelist_options;
    }

    // Wrapper for wp's `add_settings_section()` that tracks custom sections
    private function add_settings_section( $id, $title, $cb, $page ){
        add_settings_section( $id, $title, $cb, $page );
        if( $id != $page ){
            if( !isset($this->page_sections[$page]))
                $this->page_sections[$page] = array();
                $this->page_sections[$page][$id] = $id;
          }
    }




    public static function install(){

       global $wpdb;
       $wpdb->query("CREATE TABLE IF NOT EXISTS {$wpdb->prefix}jmvw_cat_user (id INT AUTO_INCREMENT PRIMARY KEY, cat VARCHAR(255) NOT NULL);");

    }

    public static function uninstall(){

       global $wpdb;
       $wpdb->query("DROP TABLE IF EXISTS {$wpdb->prefix}jmvw_cat_user;");
    }



    public function add_admin_menu(){
        add_users_page('Manage Users Categories', 'Manage Categories', 'manage_options', 'plugin-settings', array($this, 'plugin_settings'));
    }


    public function plugin_settings(){
        echo '<h1>'.get_admin_page_title().'</h1>';
        echo '<p>Bienvenue sur la page d\'accueil du plugin</p>';

        $form = new JMVWForm();

        echo $form->jmvw_form();

   }
}

new JMVWManage();
?>
wordpress说,所以当我提交表格时,选项页找不到,不知道为什么。 我想我所有的参数都是正确的

提前谢谢
Jordan

查看此链接@vel谢谢!但它不起作用!或者我把代码放在JMVWManage类或者JMVWForm类中……您在JMVWManage类或者JMVWForm类中都试过了吗?是的!我先在JMVWManage中尝试,然后在JMVWMeal中尝试……至少在同一时间在2中尝试xD@vel要我用ne代码编辑我的第一封邮件吗?
 <?php 

 class JMVWForm
 {


    private $categorie;

    public function __construct(){
       add_action('admin_init', array($this, 'jmvw_register_settings'));

       // Tracks new sections for whitelist_custom_options_page()
       $this->page_sections = array();
       // Must run after wp's `option_update_filter()`, so priority > 10
       add_action( 'whitelist_options', array( $this, 'whitelist_custom_options_page' ),11 );


   }


   // White-lists options on custom pages.
   // Workaround for second issue: 
   public function whitelist_custom_options_page( $whitelist_options ){
       // Custom options are mapped by section id; Re-map by page slug.
       foreach($this->page_sections as $page => $sections ){
           $whitelist_options[$page] = array();
           foreach( $sections as $section )
               if( !empty( $whitelist_options[$section] ) )
                   foreach( $whitelist_options[$section] as $option )
                       $whitelist_options[$page][] = $option;
       }
     return $whitelist_options;
   }

   // Wrapper for wp's `add_settings_section()` that tracks custom sections
   private function add_settings_section( $id, $title, $cb, $page ){
       add_settings_section( $id, $title, $cb, $page );
       if( $id != $page ){
           if( !isset($this->page_sections[$page]))
               $this->page_sections[$page] = array();
               $this->page_sections[$page][$id] = $id;
       }
   }


   public function jmvw_form(){

       global $wpdb;
       $row = $wpdb->get_var("SELECT * FROM $wpdb->cat");
       if(is_null($row)){
               ?>
                   <form method="post" action="options.php">
                           <?php settings_fields('jmvw_settings');?>
                           <label>Ajout de categories</label>
                           <input type="text" name="jmvw_options_sender" value="<?php echo get_option('jmvw_options_sender')?>"/>
                           <?php submit_button(); ?>
                   </form>

           <?php

       }
       else{

           foreach($categorie as $cat){

               ?>
                   <div class="jmvw-div-cat">
                           <h3><?php echo $cat ?></h3>

                           <div class="jmvw-cat-rights">
                               <?php echo "Dans lidee ici il y aura les droit des categorie" ?>
                           </div>

                   </div>

           <?php
           }

       }

   }



   public function jmvw_register_settings(){

       register_setting('jmvw_settings', 'jmvw_options_sender');

   }

}



?>