Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter wyoung221

    (@wyoung221)

    Well I think I finally figured out why these boxes were ever made in the first place: the only thing that has the ids that are in the metaboxes file is an old theme that isn’t in use anymore, so I believe it is fully deprecated and I’m ready to wash my hands of it. Again, thank you very much, you pointed me in directions I never would’ve looked and this would’ve taken me days of frustration otherwise. I already typed out everything below before I figured that out though so if you’re curious:

    PHP Fatal error: Uncaught Error: Call to a member function add_field() on array in /nas/content/staging/[site]/wp-content/mu-plugins/core-functionality/functions/metaboxes.php:40
    Stack trace:
    #0 /nas/content/staging/[site]/wp-includes/class-wp-hook.php(287): be_metaboxes(Array)
    #1 /nas/content/staging/[site]/wp-includes/plugin.php(206): WP_Hook->apply_filters(Array, Array)
    #2 /nas/content/staging/[site]/wp-content/plugins/cmb2/bootstrap.php(42): apply_filters('cmb2_meta_boxes', Array)
    #3 /nas/content/staging/[site]/wp-content/plugins/cmb2/init.php(165): cmb2_bootstrap()
    #4 /nas/content/staging/[site]/wp-includes/class-wp-hook.php(287): CMB2_Bootstrap_270->include_cmb('')
    #5 /nas/content/staging/[site]/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters(NULL, Array)
    #6 /nas/content/staging/[site]/wp-includes/plugin.php(478): WP_Hook->do_action(Array)
    #7 /nas/content/staging/[site]/wp-settings.php(546): do_action('init')
    #8 /nas/content/staging/[site]/nas/content/staging/[site]/wp-content/mu-plugins/core-functionality/functions/metaboxes.php on line 40, referer: https://[mysite].staging.wpengine.com/wp-admin/

    Line 40 is $meta_boxes->add_field( array( and for context, below is how the first few sections of metaboxes.php are set up. I suspect that, probably among other things, the ‘fields’ => array is wrong because I don’t see that anywhere in the guides; I’m guessing it was done this way to group them together but I can’t make heads or tails of how to change it.

    add_filter( 'cmb2_meta_boxes' , 'be_metaboxes' );
    /**
     * Create Metaboxes
     * @since 1.0.0
     * @link http://www.billerickson.net/wordpress-metaboxes/
     */
    
    function be_metaboxes( $meta_boxes ) {
    
    	$meta_boxes->add_field( array(
    		'id' => 'product-information',
    		'title' => 'Product Information',
    		'object_types' => array( 'product' ),
    		'context' => 'normal',
    		'priority' => 'high',
    		'show_names' => true,
    		'fields' => array(
    			array(
    				'name' => 'The Details',
    				'desc' => '',
    				'id' => 'be_product_details',
    				'type' => 'wysiwyg',
    				'options' => array(
    					'textarea_rows' => 5,
    				)
    			),
    			array(
    				'name' => 'The Fit',
    				'desc' => '',
    				'id' => 'be_product_fit',
    				'type' => 'wysiwyg',
    				'options' => array(
    					'textarea_rows' => 5,
    				)
    			),
    			array(
    				'name' => 'Set Page Background to Non-White',
    				'desc' => '',
    				'id' => 'be_product_white_bg',
    				'type' => 'checkbox',
    			)
    			
    		)
    	));
    	$meta_boxes->add_field( array(
    		'id' => 'archive-information',
    		'title' => 'Archive Information',
    		'object_types' => array( 'product' ),
    		'context' => 'normal',
    		'priority' => 'high',
    		'show_names' => true,
    		'fields' => array(
    			array(
    				'name' => 'Title',
    				'desc' => 'Used on category and related post listings. If not provided, defaults to page title',
    				'id' => 'be_archive_title',
    				'type' => 'text',
    			),
    			array(
    				'name' => 'Description',
    				'desc' => 'Used on category and related post listings. If not provided, defaults to Summary from Product Information.',
    				'id' => 'be_archive_desc',
    				'type' => 'wysiwyg',
    				'options' => array(
    					'textarea_rows' => 2,
    				),
    			),
    
    		)
    	));
    Thread Starter wyoung221

    (@wyoung221)

    I have the file saved and I’ve only deleted it from Staging at the moment. I tried to update all the CMBs to CMB2s, change Pages to Object_Types, cut the “Notable Change 3” part about including core files, add the bootstrap section, and replaced the whole cmb folder with cmb2, but I’m missing something because as long as the metaboxes.php file exists, it gives the site a critical error. I’ve spent a week on this and the site not being broken is a victory, even if those fields are now gone. It is probably a very simple thing to fix, but I’m so bad with coding that this is the equivalent of a expecting a caveman to put together an internal combustion engine when he’s barely figured out the concept of fire. I really appreciate the help you’ve given me

    Thread Starter wyoung221

    (@wyoung221)

    Yep you were right, there was a metaboxes.php file that said add_filter( 'cmb_meta_boxes' , 'be_metaboxes' ); and then a bunch of arrays. I deleted the file and it removed some fields, but I don’t think they’re even used for anything. If I’m wrong, I guess I’ll be back another day because I tried everything I could think to make the metaboxes.php work with CMB2 but it only made things worse. Thank you for your help!

Viewing 3 replies - 1 through 3 (of 3 total)