Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.2 gives white screen of death #37

Closed
senlin opened this issue Dec 21, 2011 · 12 comments
Closed

4.0.2 gives white screen of death #37

senlin opened this issue Dec 21, 2011 · 12 comments

Comments

@senlin
Copy link
Contributor

senlin commented Dec 21, 2011

Just updated to version 4.0.2 and unfortunately that gave me the white screen of death. Reverting back to 4.0.1 didn't solve it however and deleting the plugin also didn't help.

The only thing that worked, was to delete the demo.php from my theme. I have given this demo.php file a different name (sl_metaboxes.php) and added it to the includes folder of my theme. In my functions.php file I have called it as:
// Include Metaboxes script
include 'includes/sl_metaboxes.php';

My error log says the following:
[21-Dec-2011 07:48:48] PHP Fatal error: Class 'RW_Meta_Box' not found in /.../.../public_html/domain/wp-content/themes/salt2011/includes/sl_metaboxes.php on line 145

Line 145 calls this:
143: // Register meta boxes
144: foreach ( $meta_boxes as $meta_box ) {
145: new RW_Meta_Box( $meta_box );
146: }

Now what I don't understand is that version 4.0.1 worked with my setup, but after updating to 4.0.2 and then downgrading back to 4.0.1 it doesn't work anymore.

I have temporarily deleted the sl_metaboxes.php file, but if we cannot find a solution soon, I will have to revert back to the old hard-coded script instead of the plugin.

Looking forward to hear other experiences and hopefully a solution.

Thanks,
Piet

@rilwis
Copy link
Member

rilwis commented Dec 21, 2011

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.

@senlin
Copy link
Contributor Author

senlin commented Dec 21, 2011

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...

@senlin
Copy link
Contributor Author

senlin commented Dec 21, 2011

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.

@rilwis
Copy link
Member

rilwis commented Dec 21, 2011

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?

@senlin
Copy link
Contributor Author

senlin commented Dec 21, 2011

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'

@rilwis
Copy link
Member

rilwis commented Dec 22, 2011

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?

@senlin
Copy link
Contributor Author

senlin commented Dec 22, 2011

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

@rilwis
Copy link
Member

rilwis commented Dec 22, 2011

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

@senlin
Copy link
Contributor Author

senlin commented Dec 22, 2011

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

@senlin
Copy link
Contributor Author

senlin commented Dec 22, 2011

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...

@rilwis
Copy link
Member

rilwis commented Dec 22, 2011

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.

@senlin
Copy link
Contributor Author

senlin commented Dec 22, 2011

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

@senlin senlin closed this as completed Dec 22, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants