Tabbed View in Plugin Pages – Output not as expected
-
Working on a plugin which uses the tabbed interface for settings pages.
All of my code functions as desired (i think) outside of the “tabbed” view but, I moved something which had been displaying as a “standalone page” when an item is clicked for edit from an extended WP_List_Table (which was formerly not part of a tabbed view).
I wanted the user to stay in that tabbed interface, so I moved my logic / html forms for the table element’s edit page (the standalone) into a PHP Class, to more easily work with it in the context of the tabbed view. It’s not working as expected. I have xdebug enabled and WP_DEBUG of course but i’m not getting any insight. I’m using error_log() in my code as well. From the HTML output, it seems the code is crashing after the nonce is created.
Is this an error in use of the WP_Screen object?
The PHP Code:
namespace Trn\Inc\Core; use Trn\Inc\Core\Trn_Helpers; use Trn\Inc\Core\Trn_List_Table; class UserEdit { // string for building HTML table public $html_concat; public function __construct() { // concatenate HTML table for single user edit $this->html_concat = ''; } // var $this->html_concat - a string for rendering the HTML single user update forms public function useredit_html($user) { $trn_list_table = new Trn_List_Table(); if (current_user_can('edit_users')) { $this->html_concat .= '<div class="card"> <h3 class="align-right accent-h3">Individual User Settings</h3>'; } else { $this->html_concat .= '<p>' . __('You are not authorized to perform this operation.', $trn_list_table->plugin_text_domain) . '</p>'; } // trn_relayGROUP_NAMES - get_option names from db to populate form fields $trn_relaygroup = get_option('trn_relaygroup_names'); $trn_helpers_general = new Trn_Helpers(); if ($trn_relaygroup) { $trn_relaygroup = wp_parse_args($trn_relaygroup, $trn_helpers_general->trn_permission_defaults()); } else { $trn_relaygroup = $trn_helpers_general->trn_permission_defaults(); } $form_labels = $trn_relaygroup; // Create the nonce value $nonce = wp_create_nonce('my-ajax-nonce'); // Render an HTML element with the nonce value as a data attribute $this->html_concat = '<h1><span class="ucwords text-shadow">'.$user->display_name.'</span> - Text Relay Notifier Settings</h1><div id="my-ajax-nonce" data-nonce="' . esc_attr($nonce) . '"></div>';
The HTML Out (the bottom of my “view source”). Seems like some of my plugin code is running, and i’m not getting any fatal errors. Note that rogue text which is output RE: the html form checkboxes. That particular error existed in my standalone page as well, so maybe that’s the ultimate cause. Sadly, I can’t find where it’s coming from. Where is the
<div class="contextual-help-tabs-wrap">
created? I tried searching those classes in my custom plugin code. I assume it’s dynamically rendered somewhere in the Core, but learning that might give me the insight i need?<div class="contextual-help-tabs"> <ul> </ul> </div> <div class="contextual-help-tabs-wrap"> </div> </div> </div> </div> checked='checked' checked='checked'
What do you recommend? Thank you!
- The topic ‘Tabbed View in Plugin Pages – Output not as expected’ is closed to new replies.