• Resolved zuroma

    (@zuroma)


    This is an amazing framework. I’m working through all the tutorials and everything works, fields, tabs, etc., but I cannot get Page Meta Boxes to show up no matter what I try.

    No errors are being generated. Any tips on what to try or where to look to figure out why it’s not showing up?

    If you’re curious, here is my code.

    // 
    // Meta Box 1
    //
    class GFUserQueries_MetaBox1 extends AdminPageFramework_PageMetaBox {
     	
     	public function setUp() {
        
            /**
             * Adds setting fields in the meta box.
             */
            $this->addSettingFields(
                array(
                    'field_id'          => 'tutorial_normal_page_metabox_select',
                    'type'              => 'select',
                    'title'             => __( 'Select', 'admin-page-framework-tutorial' ),
                    'label'             => array(
                        'a' => __( 'Apple', 'admin-page-framework-tutorial' ),
                        'b' => __( 'Banana', 'admin-page-framework-tutorial' ),
                        'c' => __( 'Cherry', 'admin-page-framework-tutorial' ),
                    ),
                    'is_multiple'       => true,
                    'attributes'        => array(
                        'size'  => 5,
                    ),
                ),        
                array(
                    'field_id'          => 'tutorial_normal_page_metabox_textarea',
                    'type'              => 'textarea',
                    'title'             => __( 'Text Area', 'admin-page-framework-tutorial' ),
                    'repeatable'        => true,
                )
            );     
            
            add_filter( 'content_zpage1_my_tab_a', array( $this, 'replyToInsertContents' ) );
        }
        
         public function replyToInsertContents( $sContent ) {
            
            $_aOptions  = get_option( 'APF_Tabs', array() );
            return $sContent 
                . "<h3>" . __( 'Saved Options', 'admin-page-framework-tutorial' ) . "</h3>"
                . AdminPageFramework_Debug::getArray( $_aOptions );
            
        }
            
            
    }
    
    //
    // GFUserQueries Class
    // 
    class GFUserQueries extends GFUserQueries_AdminPageFramework {
    
    	public function setUp() {
    	
        	$this->setRootMenuPage( 'GF User Queries' ); 
    	    $this->addSubMenuItems(
        	    array(
            	    'title'     => 'User Queries',
                	'page_slug' => 'zpage1',
    	        ),
        	    array(
            	    'title'     => 'Single User Page',
                	'page_slug' => 'gf_userq_single_page',
    	        ),
    	        array(
            	    'title'     => 'User Tags',
                	'page_slug' => 'gf_userq_user_tags',
    	        ),      
    	        array(
            	    'title'     => 'User Report Setup',
                	'page_slug' => 'gf_userq_report_setup',
    	        )	        
        	); 
    
    		$this->addInPageTabs(
                'zpage1',    // set the target page slug so that the 'page_slug' key can be omitted from the next continuing in-page tab arrays.
                array(
                    'tab_slug'  =>    'my_tab_a',    // avoid hyphen(dash), dots, and white spaces
                    'title'     =>    __( 'Tab A', 'admin-page-framework-tutorial' ),
                ),        
                array(
                    'tab_slug'  =>    'my_tab_b',
                    'title'     =>    __( 'Tab B', 'admin-page-framework-tutorial' ),
                ),                    
                array(
                    'tab_slug'  =>    'my_tab_c',
                    'title'     =>    __( 'Tab C', 'admin-page-framework-tutorial' ),
                )
            );    
                	
        	
        	
            // disable heading tabs
    		$this->setPageHeadingTabsVisibility( false );     
    		
    		// add action for page loading
    		add_action( 
                'load_' . 'zpage1',
                array( $this, 'replyToLoadPage' )
            );     
    		
    	}
       
       
           /**
         * Called when the page starts loading.
         * 
         * @callback        action      load_{page slug}
         * @return          void
         */
        public function replyToLoadPage( $oFactory ) { 
        
        	error_log("inside loading");
        	
            $this->addSettingFields(
                array(    // Single text field
                    'field_id'      => 'my_text_field',
                    'type'          => 'text',
                    'title'         => 'Text',
                    'description'   => 'Type something here.',   
                ),
                array(    // Text Area
                    'field_id'      => 'my_textarea_field',
                    'type'          => 'textarea',
                    'title'         => 'Single Text Area',
                    'description'   => 'Type a text string here.',
                    'default'       => 'Hello World! This is set as the default string.',
                ),   
                array( // Submit button
                    'field_id'      => 'submit_button',
                    'type'          => 'submit',
                )   
            );      	
        
    		// instantiate meta boxes
            new GFUserQueries_MetaBox1(
                null,                                           // meta box id - passing null will make it auto generate
                __( 'Normal', 'admin-page-framework-loader' ), // title
                'zpage1',
                'side',                                       // context
                'default'                                       // priority
            );
    
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author miunosoft

    (@miunosoft)

    Two things I noticed.

    1. You haven’t instantiated the extended admin page class GFUserQueries in your code.

    2. Your page meta box extends the raw AdminPageFramework_PageMetabox class, not GFUserQueries_AdminPageFramework_PageMetabox.

    Also, you should enable the debug mode with the WP_DEBUG constant in wp-config.php while you code.

    Thread Starter zuroma

    (@zuroma)

    Thanks so much!

    I had instantiated the GFUserQueries, but I did extend the raw class instead of the generated one. I stared at it for so long as didn’t notice. I appreciate your help!

    Plugin Author miunosoft

    (@miunosoft)

    Glad it helped!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t Get Page Meta Box to Work’ is closed to new replies.