| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package RGC\CMB2\Field_Switch |
| 4 |
* @author Ruben Garcia (RubenGC) <[email protected]>, GamiPress <[email protected]> |
| 5 |
* @copyright Copyright (c) GamiPress |
| 6 |
* |
| 7 |
* Plugin Name: CMB2 Field Type: Switch |
| 8 |
* Plugin URI: https://github.com/rubengc/cmb2-field-switch |
| 9 |
* GitHub Plugin URI: https://github.com/rubengc/cmb2-field-switch |
| 10 |
* Description: CMB2 field to make checkboxes and radios look as a WordPress Gutenberg switch. |
| 11 |
* Version: 1.0.1 |
| 12 |
* Author: GamiPress |
| 13 |
* Author URI: https://gamipress.com/ |
| 14 |
* License: GPLv2+ |
| 15 |
*/ |
| 16 |
// Exit if accessed directly |
| 17 |
if( !defined( 'ABSPATH' ) ) exit; |
| 18 |
|
| 19 |
global $cmb2_field_switch; |
| 20 |
|
| 21 |
// Prevent CMB2 autoload adding "RGC_" at start |
| 22 |
if( ! class_exists( 'RGC_CMB2_Field_Switch' ) ) { |
| 23 |
|
| 24 |
/** |
| 25 |
* Class RGC_CMB2_Field_Switch |
| 26 |
*/ |
| 27 |
class RGC_CMB2_Field_Switch { |
| 28 |
|
| 29 |
/** |
| 30 |
* Current version number |
| 31 |
*/ |
| 32 |
const VERSION = '1.0.1'; |
| 33 |
|
| 34 |
/** |
| 35 |
* Initialize the plugin by hooking into CMB2 |
| 36 |
*/ |
| 37 |
public function __construct() { |
| 38 |
|
| 39 |
add_action( 'admin_enqueue_scripts', array( $this, 'setup_admin_scripts' ) ); |
| 40 |
|
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Enqueue scripts and styles |
| 45 |
*/ |
| 46 |
public function setup_admin_scripts() { |
| 47 |
|
| 48 |
// CSS needs to be enqueued |
| 49 |
wp_enqueue_style( 'cmb-switch-css', plugins_url( 'switch.css', __FILE__ ), array(), self::VERSION ); |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
} |
| 54 |
|
| 55 |
$cmb2_field_switch = new RGC_CMB2_Field_Switch(); |
| 56 |
|
| 57 |
} |