Giter Club home page Giter Club logo

Comments (12)

rilwis avatar rilwis commented on August 15, 2024

We need to check for class_exists() before define our meta boxes, like this:

if ( class_exists( 'RW_Meta_Box' ) ) {
    foreach ( $meta_boxes as $meta_box ) {
        new RW_Meta_Box( $meta_box );
    }
}

Please see the demo/demo.php file for example.

from meta-box.

senlin avatar senlin commented on August 15, 2024

Hi Rilwis, that is one of the things I saw that changed from version 4.0.1 to version 4.0.2. I have now updated the plugin and I have used the new demo.php file to make my sl_metaboxes.php file. However, although the site now runs normal (white screen is gone), I still cannot see the metaboxes that previously were clearly visible...

from meta-box.

senlin avatar senlin commented on August 15, 2024

So basically what I am trying to say is that in the Edit Posts screen my custom meta boxes now have vanished. They're just not there. If I turn on Custom Fields in the Screen Options I can see them, but the Custom Meta Box no longer is there.

from meta-box.

rilwis avatar rilwis commented on August 15, 2024

Can you post your code of your meta box definition? And can you test other plugins by deactivating all plugins and activate each of them?

from meta-box.

senlin avatar senlin commented on August 15, 2024

Hi rilwis, it's a live site of a client, so no, I cannot test other plugins.
code metabox definitions:

/********************* META BOXES DEFINITION ***********************/

/**
 * Prefix of meta keys (optional)
 * Wse underscore (_) at the beginning to make keys hidden
 * You also can make prefix empty to disable it
 */
$prefix = 'sl_';

$meta_boxes = array( );

// Events (posts) meta box
$meta_boxes[] = array(
    'id' => 'events',                   // Meta box id, unique per meta box
    'title' => 'Event Details',    // Meta box title
    'pages' => array( 'post' ),         // Post types, accept custom post types as well, default is array('post'); optional
    'context' => 'normal',                // Where the meta box appear: normal (default), advanced, side; optional
    'priority' => 'high',                 // Order of meta box: high (default), low; optional
    'fields' => array(                    // List of meta fields
        array(
            'name' => 'Subtitle',          // Field name
            'id' => $prefix . 'subtitle',      // Field id, i.e. the meta key
            'type' => 'long_text',               // Field type: text box
            'desc' => 'Some events need to have a subtitle, you can fill that in here. You can leave it empty if this event does not need or have a subtitle.'
        ),
        array(
            'name' => 'Event Date',
            'id' => $prefix . 'date',
            'type' => 'date',               // File type: date
            'format' => 'DD MM d, yy',          // Date format, default yy-mm-dd. Optional. See: http://goo.gl/po8vf
            'desc' => 'Format is DD, MM d, yy, for example: Sunday December 25, 2011
If more than one day, leave this open and see Event Period.' ), array( 'name' => 'Event Period', // Field name 'id' => $prefix . 'period', // Field id, i.e. the meta key 'type' => 'long_text', // Field type: long text field 'desc' => 'Example 1: Whole month of October 2011
Example 2: Every Tuesday in January 2012
Example 3: Monday, March 5, 2012 - Sunday, March 18, 2012
Only fill in if the event spans a period of more than one day.' ), array( 'name' => 'Event Time', 'id' => $prefix . 'eventtime', 'type' => 'text', // Field type: text field 'desc' => 'Example 1: 6:30-10:30pm
Example 2: 11am-2pm
Example 3 (for Event Period): Every night 6:30pm till late.' ) ) ); /** * Register meta boxes * Make sure there's no errors when the plugin is deactivated or during upgrade */ if ( class_exists( 'RW_Meta_Box' ) ) { foreach ( $meta_boxes as $meta_box ) { new RW_Meta_Box( $meta_box ); } }

And to my functionality.php file I added the code for the long_text field:

// Customization on metaboxes script to make standard textbox a little bit longer
if ( !class_exists( 'RWMB_Long_Text_Field' ) ) {

    class RWMB_Long_Text_Field {

        /**
         * Get field end HTML
         * @param $html
         * @param $meta
         * @param $field
         * @return string
         */
        static function html( $html, $meta, $field ) {
            return "";
        }
    }
}

Dunno why the return input doesn't show up here: input type='long_text' class='rwmb-text' name='{$field['id']}' id='{$field['id']}' value='$meta' size='50'

from meta-box.

rilwis avatar rilwis commented on August 15, 2024

The method html() of the class RWMB_Long_Text_Field is not correct. Please see the text.php file for an example.

By the way, does that happen to long_text field only, or all fields?

from meta-box.

senlin avatar senlin commented on August 15, 2024

Hi rilwis, ok I changed the long_text according to the new version of text.php, but still nothing shows in the back-end :(

from meta-box.

rilwis avatar rilwis commented on August 15, 2024

A stupid question: did you assign the correct post type to meta box?

from meta-box.

senlin avatar senlin commented on August 15, 2024

yes, the post type is "normal" post: 'pages' => array( 'post' ),

from meta-box.

senlin avatar senlin commented on August 15, 2024

rilwis I have a side question for you: is there anything fundamentally wrong with your previous metaboxes script, the one that did not come as a plugin? Because if there isn't, then I will stop wasting everyone's time here and just implement that as that is and has been working on all the sites that I use it. This is actually the first site where I use the plugin version on and immediately with the first plugin update things go wrong...

from meta-box.

rilwis avatar rilwis commented on August 15, 2024

Do you mean the 4.0.1 version? From 4.0.1 to 4.0.2, there're some minor fixes for check box fields. If you're saying about version 3.2.2, then there're big changes in the code (refactor, re-format, etc.) but v3.2.2 still works well.

from meta-box.

senlin avatar senlin commented on August 15, 2024

I indeed meant 3.2.2. OK I think I will switch back to that version then, because as you can see I don't need all the extended functionality of the script anyway. When I need the custom meta boxes for a new project I will try to do it again with the plugin version.
Thanks anyways and Happy Holidays.
Piet

from meta-box.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.