origgami / CMB2-grid

A grid system for Wordpress CMB2 library that allows columns creation
88 stars 21 forks source link

Undefined function cmb2_get_metabox #10

Closed gorirrajoe closed 8 years ago

gorirrajoe commented 8 years ago

Getting this error:

Fatal error: Call to undefined function cmb2_get_metabox() in C:\xampp\htdocs[REDACTED]\wp-content\plugins\CMB2-grid-master\Grid\Cmb2Grid.php on line 22

I have CMB2 and this plugin installed and enabled.

<?php
function vn_bike_review_metaboxes() {

        // Start with an underscore to hide fields from custom fields list
        $prefix = '_vn_bike_review_';

        /**
         * Initiate the metabox
         */
        $cmb_bikes = new_cmb2_box( array(
            'id' => 'bike_review',
            'title' => __( 'Bike Reviews', 'vn' ),
            'object_types' => array( 'bike-reviews', ), // Post type
            'context' => 'normal',
            'priority' => 'high',
            'show_names' => true, // Show field names on the left
            'closed' => false,
        ) );

        // Scoring fields
        // text
        $scoring1 = $cmb_bikes->add_field( array(
            'name'    => 'LAB Score',
            'id'      => $prefix . 'bike_lab_score',
            'type'    => 'text',
            'desc'    => 'Out of 20',
        ) );

        // text
        $scoring2 = $cmb_bikes->add_field( array(
            'name'    => 'BUILD Score',
            'id'      => $prefix . 'bike_build_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring3 = $cmb_bikes->add_field( array(
            'name'    => 'COMFORT Score',
            'id'      => $prefix . 'bike_comfort_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring4 = $cmb_bikes->add_field( array(
            'name'    => 'VALUE Score',
            'id'      => $prefix . 'bike_value_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring5 = $cmb_bikes->add_field( array(
            'name'    => 'HANDLING Score',
            'id'      => $prefix . 'bike_handling_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring6 = $cmb_bikes->add_field( array(
            'name'    => 'PEDALING RESPONSE Score',
            'id'      => $prefix . 'bike_pedaling_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring7 = $cmb_bikes->add_field( array(
            'name'    => 'AESTHETICS Score',
            'id'      => $prefix . 'bike_aesthetics_score',
            'type'    => 'text',
            'desc'    => 'Out of 5',
        ) );

        // text
        $scoring8 = $cmb_bikes->add_field( array(
            'name'    => 'ASCENDING Score',
            'id'      => $prefix . 'bike_ascending_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring9 = $cmb_bikes->add_field( array(
            'name'    => 'DESCENDING Score',
            'id'      => $prefix . 'bike_descending_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $scoring10 = $cmb_bikes->add_field( array(
            'name'    => 'VERSATILITY Score',
            'id'      => $prefix . 'bike_versatility_score',
            'type'    => 'text',
            'desc'    => 'Out of 15',
        ) );

        // text
        $cmb_bikes->add_field( array(
            'name'    => 'OVERALL Score',
            'id'      => $prefix . 'bike_overall',
            'type'    => 'text',
            'desc'    => 'Out of 100',
        ) );
}
add_action( 'cmb2_init', 'vn_bike_review_metaboxes' );

if(!is_admin()){
    return;
}
$cmb2Grid = new \Cmb2Grid\Grid\Cmb2Grid($cmb_bikes);
$row = $cmb2Grid->addRow();
$row->addColumns( array(
    $scoring1,
    $scoring2,
    $scoring3,
));
gorirrajoe commented 8 years ago

never mind -- i have to put that code within the vn_bike_review_metaboxes() function