Comments (12)
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.
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.
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.
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.
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.
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.
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.
A stupid question: did you assign the correct post type to meta box?
from meta-box.
yes, the post type is "normal" post: 'pages' => array( 'post' ),
from meta-box.
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.
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.
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)
- Master branch here on GitHub is not current with version on Wordpress Repo HOT 2
- Switch labels are off HOT 2
- Usage of Select Advanced for taxonomies in admin HOT 1
- Require image orientation on image_advanced field upload HOT 1
- subtitle custom field HOT 2
- Media Library Never Loads HOT 3
- Fatal Error in Taxonomy Field on Frontend Form Following MB Update to Version 5.7.2
- Meta Box interferes with my website's Logo when activated HOT 1
- Scripts loaded on front end HOT 1
- Payment failed for Lifetime metabox.io plan
- WP's preview functionality broken by this plugin as of WP v6.4 HOT 2
- Impossible to preview posts since WP 6.4.0 HOT 1
- Code scanning security issues HOT 1
- fix: defensively check for null post in add_fields() for php 8.3 HOT 2
- Error message: Uncaught TypeError: Return value of RWMB_Sanitizer::sanitize_color() must be of the type string HOT 4
- Obtain the metadata of a MetaBox setting. HOT 4
- OT Menu Mobile not working HOT 2
- Reusing field groups
- Meta Box Custom Table - Hook for replace List_Table HOT 1
- Error saving custom patterns and template parts in WP 6.6 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meta-box.