can't display php document in wordpress settings api tab

27 views Asked by At

I am coding a plugin on wordpress and am trying to add a php files data to my tab in wordpress settings.

I tried adding it like this, but its displaying the title, but not my document which is after the action tag. Im calling it through action and the action tag that I set in the construct. This action tag is connected to my method. But this method is never called, which I found out through debugging. Why isnt it calling the method and is there a better way to add my php document, so it displays the content on my plugin page?

    private function settings_fields() {

        $settings['Servers'] = array(
            'title'       => __( 'Servers', 'panelhelper' ),
            'description' => __( 'Please enter API Server info below.', 'panelhelper' ),
            
            'home' => array(
                'action' => 'panelhelper_servers_tab', // this is what doesnt work
                'hide_sidebar' => true
            ),

        );

        $settings = apply_filters( $this->parent->_token . '_settings_fields', $settings );

        return $settings;
    }


    public function __construct( $parent ) {
        $this->parent = $parent;

        $this->base = 'wpt_';
        

        // Initialise settings.
        add_action( 'init', array( $this, 'init_settings' ), 11 );

        add_action( 'panelhelper_servers_tab', array( $this, 'servers_tab' ) );

        
        // Register plugin settings.
        add_action( 'admin_init', array( $this, 'register_settings' ) );

        // Add settings page to menu.
        add_action( 'admin_menu', array( $this, 'add_menu_item' ) );

        // Add settings link to plugins page.
        add_filter(
            'plugin_action_links_' . plugin_basename( $this->parent->file ),
            array(
                $this,
                'add_settings_link',
            )
        );

        // Configure placement of plugin settings page. See readme for implementation.
        add_filter( $this->base . 'menu_settings', array( $this, 'configure_settings' ) );

    }


    public function servers_tab() {

     $this->cpt_obj_servers = new panelhelper_server_list();

     $servers_tab = PANELHELPER_TEMPLATE_PATH . '/admin/servers.php';


        if ( file_exists( $servers_tab ) ) {
           include_once( $servers_tab );
        }
        
    }

0

There are 0 answers