rogerlos / cmb2-metatabs-options Goto Github PK
View Code? Open in Web Editor NEWExtends CMB2 to allow WordPress options pages with multiple metaboxes and optional tabs.
Extends CMB2 to allow WordPress options pages with multiple metaboxes and optional tabs.
Defining arrays using []
is supporting from PHP 5.4
But I found some servers with php 5.6 that do not recognizes this expresion
Anyway for maximum compatibility I suggest to replace it with array()
It would be useful to add a composer.json
file to you project.
{
"name": "rogerlos/cmb2-metatabs-options",
"description": "Extends CMB2 to allow WordPress options pages with multiple metaboxes and optional tabs.",
"type": "wordpress-plugin",
"require": {
"webdevstudios/cmb2": "^2.2"
},
"license": "GPLv2",
"authors": [
{
"name": "Roger Los",
"email": "[email protected]"
}
],
"minimum-stability": "stable"
}
Help me....
how to echo field
i use cmb2_metatabs_options_go() but not working!!!!
example : echo cmb2_metatabs_options_go( 'ex_cats_say' );
PLEASE help me and answer to my question....
Hi !
I'm glad you updated after my comments :)
I have a last difficulty though, probably a simple problem not linked to the code you wrote: i'm trying to make the option page (created following your example) accessible to a user which for i created a specific role. This user role does not have access to the optons-general.php page.
What should i provide as 'topmenu' arg then? How can i create an admin menu item dedicated to this option page ?
Thanks a lot in advance for the help ;)
Will be awesome get this functionallity implemented with the ability to enable/disable and also to set a custom text for the reset button
without adding it to packagist.org, one cannot composer require rogerlos/cmb2-metatabs-options
to bring the package into their project
I am thinking about make a private page by user, is it possible?
The idea is by specified role, the users can save their own files in their private page.
Maybe with a hidden field we can save the user_id that is saving files in a group of cmb2 into the private page.
thanks Rogerlos! ;-)
No the same issue from #10
I'm trying to add the metatabs-options to the Post and Page post types and I'm unable to do so. I tried with the $show_on
variable and I'm afraid this is not the way to do it.
'topmenu' => 'edit.php',
'postslug' => 'page',
With CMB2 I can accomplish this by setting object_type
to object_type => array('post', 'page')
but I couldn't set it up in your plugin. I would appreciate your help.
Thanks for releasing this, amazing stuff.
CMB2 2.2.5 adds an automatic handler for options pages (class CMB_Options_Hookup) that automatically add a new admin page with the box registered
We need to disable It for CMO pages because It causes some critical errors (like break the save button)
There is a new box parameter (display_cb) that accepts the value false to disable it
hi guys
taxonomy_select type not saving in options page ....
where is the problem ?
Currently if two projects have your plugin php throws a fatal error because plugin fuctions are redeclared
Updating autoloader.php with this changes the issue get fixes:
<?php
/**
* RNL AUTOLOADER
* Looks in /code to see if a file matching the classname exists
*
* @param $class
*
* @since 1.0.0
*/
if( ! function_exists( 'rnl_autoloader' ) ) {
function rnl_autoloader( $class ) {
$base_dir = __DIR__;
$class = strtolower( $class );
$file = $base_dir . '/code/' . $class . '.php';
if ( file_exists( $file ) ) require $file;
}
}
If your are ok with this changes I can PR them or you can commit them directly
CMO cleanup css has a rule #side-sortables{padding-top:22px;}
that adds an extra padding on the entire wp admin
Adding a prefix to all this rules with .cmo-options-page
or #cmo-options-form
fixes the issue
Also, if multiple plugins register CMO , this css is registered multiple times
<style type="text/css" id="CMO-cleanup-css">#poststuff h2.nav-tab-wrapper{padding-bottom:0;margin-bottom: 20px;}.opt-hidden{display:none;}#side-sortables{padding-top:22px;}</style>
<style type="text/css" id="CMO-cleanup-css">#poststuff h2.nav-tab-wrapper{padding-bottom:0;margin-bottom: 20px;}.opt-hidden{display:none;}#side-sortables{padding-top:22px;}</style>
<style type="text/css" id="CMO-cleanup-css">#poststuff h2.nav-tab-wrapper{padding-bottom:0;margin-bottom: 20px;}.opt-hidden{display:none;}#side-sortables{padding-top:22px;}</style>
Checking if this has been rendered with a global var could solve the problem
Hi I'm getting the following error?
Fatal error: Using $this when not in object context in ....../wp-content/plugins/hpw-functionality/cmb2-metatabs-options/code/cmb2_metatabs_options.php on line 282
Have tried using the example code instead of my own and I still get the error.
Everything works fine in my single install development environment. When I move the working code to a multisite environment I get this error?
Hello everyone,
I've found this function in an other settings-page snippet and I like it very much. Maybe the author want to integrate it into the code.
Now you could get any key with the following line:
echo settingspage_get_option('ID-OF-YOUR-FIELD'):
easy, isn't it?
Source:
https://github.com/WebDevStudios/CMB2-Snippet-Library/tree/master/options-and-settings-pages
Greetings
/* Get value for option-page key */
function settingspage_get_option( $key = '', $default = null ) {
$options_key = 'settingspage_options';
if ( function_exists( 'cmb2_get_option' ) ) {
// Use cmb2_get_option as it passes through some key filters.
return cmb2_get_option( $options_key, $key, $default );
}
// Fallback to get_option if CMB2 is not loaded yet.
$opts = get_option( $options_key, $key, $default );
$val = $default;
if ( 'all' == $key ) {
$val = $opts;
} elseif ( array_key_exists( $key, $opts ) && false !== $opts[ $key ] ) {
$val = $opts[ $key ];
}
return $val;
}
Hi,
I had problems using menuargs in the plugin to edit icon, position and capabilty. So I added the following to the code.
In the props array:
'capability' => 'manage_options', 'icon_url' => 'dashicons-layout', 'position' => 1,
And the build_menu_args-function:
`
private function build_menu_args () {
// if a menu arguments array was injected, return it
if ( ! empty( self::$props['menuargs'] ) ) {
// if menu arguments are less than 7, add empty argument to end, assumes subpage wanted
if ( count( self::$props['menuargs'] ) < 7 && self::$props['topmenu'] )
self::$props['menuargs'][] = null;
return self::$props['menuargs'];
}
// otherwise build the menu page from the page title and options-slug
$args = array();
if ( self::$props['topmenu'] ) {
// add a post_type get var, to allow post options pages
$add = self::$props['postslug'] ? '?post_type=' . self::$props['postslug'] : '';
$args[] = self::$props['topmenu'] . $add;
}
$args[] = $args[] = self::$props['title'];
$args[] = self::$props['capability'];
$args[] = self::$props['key'];
$args[] = array( $this, 'admin_page_display' );
if ( ! self::$props['topmenu'] )
$args[] = self::$props['icon_url'];
$args[] = self::$props['position'];
return $args;
}`
Would be a great and easier way to add those parameters
how to echo options
get_options();?
Cmb2_Metatabs_Options();?
Could you tell me how you would add a capability to view the link in the admin menu AND edit the settings page created with this class ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.