, GamiPress , AutomatorWP * @copyright Copyright (c) Ruben Garcia * * Plugin Name: CMB2 Tabs * Plugin URI: https://github.com/rubengc/cmb2-tabs * GitHub Plugin URI: https://github.com/rubengc/cmb2-tabs * Description: Tabs for CMB2 boxes. * Version: 1.0.5 * Author: Ruben Garcia * Author URI: http://rubengc.com/ * License: GPLv2+ */ // Exit if accessed directly if( !defined( 'ABSPATH' ) ) exit; // Prevent CMB2 autoload adding "RGC_" at start if( !class_exists( 'RGC_CMB2_Tabs' ) ) { /** * Class RGC_CMB2_Tabs */ class RGC_CMB2_Tabs { /** * Current version number */ const VERSION = '1.0.5'; /** * Initialize the plugin by hooking into CMB2 */ public function __construct() { add_action( 'admin_enqueue_scripts', array( $this, 'setup_admin_scripts' ) ); add_action( 'doing_dark_mode', array( $this, 'setup_dark_mode' ) ); add_action( 'cmb2_before_form', array( $this, 'before_form' ), 10, 4 ); add_action( 'cmb2_after_form', array( $this, 'after_form' ), 10, 4 ); } /** * Render tabs * * @param array $cmb_id The current box ID * @param int $object_id The ID of the current object * @param string $object_type The type of object you are working with. * @param array $cmb This CMB2 object */ public function before_form( $cmb_id, $object_id, $object_type, $cmb ) { if( $cmb->prop( 'tabs' ) && is_array( $cmb->prop( 'tabs' ) ) ) : ?>
prop( 'tabs' ) as $tab ) : $fields_selector = array(); if( ! isset( $tab['id'] ) ) { continue; } if( ! isset( $tab['fields'] ) ) { $tab['fields'] = array(); } if( ! is_array( $tab['fields'] ) ) { $tab['fields'] = array(); } foreach( $tab['fields'] as $tab_field ) : $fields_selector[] = '.' . 'cmb2-id-' . str_replace( '_', '-', sanitize_html_class( $tab_field ) ) . ':not(.cmb2-tab-ignore)'; endforeach; $fields_selector = apply_filters( 'cmb2_tabs_tab_fields_selector', $fields_selector, $tab, $cmb_id, $object_id, $object_type, $cmb ); $fields_selector = apply_filters( 'cmb2_tabs_tab_' . $tab['id'] . '_fields_selector', $fields_selector, $tab, $cmb_id, $object_id, $object_type, $cmb ); ?>
prop( 'tabs' ) && is_array( $cmb->prop( 'tabs' ) ) ) : ?>