8889841cplugin.php 0000644 00000000627 15051420274 0006560 0 ustar 00 setting = $field_object->args( 'tabs' );
$this->object_id = $object_id;
// Set layout
$layout = empty( $this->setting['layout'] ) ? 'ui-tabs-horizontal' : "ui-tabs-{$this->setting['layout']}";
$default_data = version_compare( CMB2_VERSION, '2.2.2', '>=' ) ? array(
'class' => "dtheme-cmb2-tabs $layout",
) : $field_type_object->parse_args( $field_object->data_args(), 'tabs', array(
'class' => "dtheme-cmb2-tabs $layout",
) );
// Render field
echo sprintf( '
%s
', $field_type_object->concat_attrs( $default_data, array(
'value',
'name',
'type'
) ), $this->get_tabs() );
}
/**
* Render tabs
*
* @return string
*/
public function get_tabs() {
ob_start();
?>
setting['tabs'] as $key => $tab ): ?>
-
setting['tabs'] as $key => $tab ): ?>
render_fields( $this->setting['config'], $tab['fields'], $this->object_id );
?>
$fields ) );
$CMB2 = new \CMB2( $setting_fields, $object_id );
foreach ( $fields as $key_field => $field ) {
if ( $CMB2->is_options_page_mb() ) {
$CMB2->object_type( $args['object_type'] );
}
// Cmb2 render field
$CMB2->render_field( $field );
}
}
/**
* Hook: Save field values
*
* @param $override_value
* @param $value
* @param $post_id
* @param $data
*/
public static function save( $override_value, $value, $post_id, $data ) {
foreach ( $data['tabs']['tabs'] as $tab ) {
$setting_fields = array_merge( $data['tabs']['config'], array( 'fields' => $tab['fields'] ) );
$CMB2 = new \CMB2( $setting_fields, $post_id );
if ( $CMB2->is_options_page_mb() ) {
$cmb2_options = cmb2_options( $post_id );
$id_fields = array_map( function( $field ) {
return $field['id'];
}, $tab['fields'] );
foreach ( $_POST as $key => $value ) {
if ( array_search( $key, $id_fields ) !== false ) {
$cmb2_options->update( $key, $value );
}
}
} else {
$CMB2->save_fields();
}
}
}
} example.php 0000644 00000011463 15051420274 0006715 0 ustar 00 'example_tabs_metaboxes',
'title' => __( 'Example tabs', 'wp-job-board-pro' ),
'object_types' => array( 'page' ),
'show_names' => true,
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// Setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-job-board-pro' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-job-board-pro' ),
'add_button' => __( 'Add review', 'wp-job-board-pro' ),
'remove_button' => __( 'Remove review', 'wp-job-board-pro' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-job-board-pro' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-job-board-pro' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-job-board-pro' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
// Set tabs
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
}
/*
* Example options page
*/
add_action( 'cmb2_admin_init', 'cmbt_example_options_page_metabox' );
function cmbt_example_options_page_metabox() {
$box_options = array(
'id' => 'myprefix_option_metabox',
'title' => __( 'Example tabs', 'wp-job-board-pro' ),
'show_names' => true,
'object_type' => 'options-page',
'show_on' => array(
// These are important, don't remove
'key' => 'options-page',
'value' => array( 'myprefix_options' )
),
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-job-board-pro' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-job-board-pro' ),
'add_button' => __( 'Add review', 'wp-job-board-pro' ),
'remove_button' => __( 'Remove review', 'wp-job-board-pro' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-job-board-pro' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-job-board-pro' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-job-board-pro' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
} README.md 0000644 00000013417 15051420274 0006031 0 ustar 00 # cmb2-tabs
Extensions the tabs to the library CMB2
### Preview

### Changelog
* 1.2.3 Added license to the project
* 1.2.2 Support vertical layout
* 1.2.1 Support for custom attributes for the tabs container
* 1.0.1 Added support the "options page"
* 1.0.0 Init
### Example metabox
```php
add_filter( 'cmb2_init', 'example_tabs_metaboxes' );
function example_tabs_metaboxes() {
$box_options = array(
'id' => 'example_tabs_metaboxes',
'title' => __( 'Example tabs', 'wp-job-board-pro' ),
'object_types' => array( 'page' ),
'show_names' => true,
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-job-board-pro' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-job-board-pro' ),
'add_button' => __( 'Add review', 'wp-job-board-pro' ),
'remove_button' => __( 'Remove review', 'wp-job-board-pro' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-job-board-pro' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-job-board-pro' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-job-board-pro' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
// set tabs
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
}
```
##### Preview


### Example options page
```php
add_action( 'cmb2_admin_init', 'example_options_page_metabox' );
function example_options_page_metabox() {
$box_options = array(
'id' => 'myprefix_option_metabox',
'title' => __( 'Example tabs', 'wp-job-board-pro' ),
'show_names' => true,
'object_type' => 'options-page',
'show_on' => array(
// These are important, don't remove
'key' => 'options-page',
'value' => array( 'myprefix_options' )
),
);
// Setup meta box
$cmb = new_cmb2_box( $box_options );
// setting tabs
$tabs_setting = array(
'config' => $box_options,
// 'layout' => 'vertical', // Default : horizontal
'tabs' => array()
);
$tabs_setting['tabs'][] = array(
'id' => 'tab1',
'title' => __( 'Tab 1', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'header_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'header_subtitle',
'type' => 'text'
),
array(
'name' => __( 'Background image', 'wp-job-board-pro' ),
'id' => 'header_background',
'type' => 'file',
'options' => array(
'url' => false
)
)
)
);
$tabs_setting['tabs'][] = array(
'id' => 'tab2',
'title' => __( 'Tab 2', 'wp-job-board-pro' ),
'fields' => array(
array(
'name' => __( 'Title', 'wp-job-board-pro' ),
'id' => 'review_title',
'type' => 'text'
),
array(
'name' => __( 'Subtitle', 'wp-job-board-pro' ),
'id' => 'review_subtitle',
'type' => 'text'
),
array(
'id' => 'reviews',
'type' => 'group',
'options' => array(
'group_title' => __( 'Review {#}', 'wp-job-board-pro' ),
'add_button' => __( 'Add review', 'wp-job-board-pro' ),
'remove_button' => __( 'Remove review', 'wp-job-board-pro' ),
'sortable' => false
),
'fields' => array(
array(
'name' => __( 'Author name', 'wp-job-board-pro' ),
'id' => 'name',
'type' => 'text'
),
array(
'name' => __( 'Author avatar', 'wp-job-board-pro' ),
'id' => 'avatar',
'type' => 'file',
'options' => array(
'url' => false
)
),
array(
'name' => __( 'Comment', 'wp-job-board-pro' ),
'id' => 'comment',
'type' => 'textarea'
)
)
)
)
);
$cmb->add_field( array(
'id' => '__tabs',
'type' => 'tabs',
'tabs' => $tabs_setting
) );
}
```
##### Preview


### License
**cmb2-tabs** is an open source project that is licensed under the [MIT license](http://opensource.org/licenses/MIT). LICENSE.md 0000644 00000002067 15051420274 0006155 0 ustar 00 The MIT License (MIT)
Copyright (c) 2016 Güray Yarar
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. autoloader.php 0000644 00000000415 15051420274 0007414 0 ustar 00 x@!X`
UIiBZOe3ݑIb3- 38?3[?_K:9Rxl :0 Pkx]| G,ʙ0d:P@ SD-pnb"@,X82y`#(`
*A58 Qp3<.x$`c# Q i@1d C.7AP 1m_Sy*=QFdzBvx)g¹p
.k#p+|߅%+xP$2E٣Ix
%eN-$J%8 \jvABa0I#TFb9xD"iH$>itt4HL'=d1yBQ(ql6J)ML%ÕY/S%*sK,AVW]vll ՓʦVQOQr49`rʍ/P4m'CD;HDct=^L?J)+X+D)RR8 az#qqeI,hZpkbbb]/JL%o4JmJOFʡ++_R~BWqRWy
Q=ګ:&TPZ^ީ>ApkjxT`3ә̋1MUM?Mff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