• 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!

    • This topic was modified 1 year, 5 months ago by ajaxStardust.
    • This topic was modified 1 year, 5 months ago by ajaxStardust.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ajaxStardust

    (@ajaxstardust)

    i found my issue with the HTML cutting off after <div class="contextual-help-tabs-wrap"> : see line 903 of WP_Screen (2023.06.05)

    My content is now displaying as it did when the page was standalone. But that’s just it. It’s still not rendering as part of the tabbed view.

    I suspect it’s a WP_Screen issue, but i’m not sure where to begin debugging for that.

    Moderator bcworkz

    (@bcworkz)

    I’m unclear how you’ve tried to incorporate a list table into your tabbed content. I sounds like you may be trying to add an entire WP_Screen object to your tabbed content, thus nesting one WP_Screen within another. AFAIK you cannot nest screen objects.

    You should only want to include the list table itself in tabbed content, not the entire screen object. The only screen object involved should be the one for all of your tabbed content.

    Thread Starter ajaxStardust

    (@ajaxstardust)

    haha. i dunno @bcworkz .
    it’s been submitted for review as a plugin. so, we’ll see what happens.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Tabbed View in Plugin Pages – Output not as expected’ is closed to new replies.