| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * CMB2 Meta Box | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @since  0.1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @category  WordPress_Plugin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @package   CMB2 Admin Extension | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @author    twoelevenjay | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * @license   GPL-2.0+ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | if ( ! class_exists( 'CMB2_Meta_Box' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	 * Class CMB2_Meta_Box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | 	class CMB2_Meta_Box { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | 		 * Field prefix. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | 		 * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | 		private $prefix = '_cmb2_'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | 		 * Instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | 		 * @var object | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | 		protected static $instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 		 * Initiate CMB2 Admin Extension object. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		 * @todo For now plugin will use one main object, will consider 3 seperate objects in the future. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		 * @todo Comment. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 		 * @since 0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 		public function __construct() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 			add_action( 'pre_current_active_plugins', array( $this, 'hide_cmb2_plugins' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 			add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 			add_action( 'cmb2_init', array( $this, 'init_user_defined_meta_boxes_and_fields' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 		 * Return an instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 		 * @return object A single instance of this class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 		public static function get_instance() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 			// If the single instance hasn't been set, set it now. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 			if ( self::$instance === null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 				self::$instance = new self; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			return self::$instance; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 		 * Determine if current user has permission to CMB2 view plugins. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 		 * @since  0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 69 |  | View Code Duplication | 		public function is_cmb2_allowed() { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 			$cmb2_settings = get_option( '_cmb2_settings' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 			if ( empty( $cmb2_settings ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 				// No settings saved. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 			$current_user  = wp_get_current_user(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 			$allowed_users = isset( $cmb2_settings['_cmb2_user_multicheckbox'] ) ? $cmb2_settings['_cmb2_user_multicheckbox'] : array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 			if ( empty( $allowed_users ) || in_array( $current_user->ID, $allowed_users, true ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 		 * Only show CMB2 plugins to users defined in settings. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 		 * @since  0.0.1 | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 92 |  |  | 		 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  | 		public function hide_cmb2_plugins() { | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  | 			global $wp_list_table; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  | 			if ( ! $this->is_cmb2_allowed() ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  | 				$to_hide = array( CMB2AE_CMB2_PLUGIN_FILE, 'cmb2-admin-extension/cmb2-admin-extension.php' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  | 				$plugins = $wp_list_table->items; | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  | 				foreach ( array_keys( $plugins ) as $key ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  | 					if ( in_array( $key, $to_hide, true ) ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  | 						unset( $wp_list_table->items[ $key ] ); | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  | 					} | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  | 				} | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 		 * Enqueue CMB2 Admin Extension scripts and styles. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 		 * @since  0.0.8 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 		public function enqueue_scripts() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			$screen = get_current_screen(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			if ( $screen->post_type === 'meta_box' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 				wp_register_style( 'cmb2_admin_styles', CMB2AE_URI . '/css/meta-box-fields.css', false, '0.0.8' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 				wp_enqueue_style( 'cmb2_admin_styles' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 				wp_enqueue_script( 'cmb2_admin_scripts', CMB2AE_URI . '/js/meta-box-fields.js', true, array( 'jquery' ), '0.0.8' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 		 * Function is_repeatable(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 		 * @todo Document properly. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 		 * @since  0.0.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 		 * @param string $field_type A CMB2 field type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 		static function is_repeatable( $field_type ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 			$repeatable_fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 				'text', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 				'text_small', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 				'text_medium', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 				'text_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 				'text_url', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 				'text_money', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 				'textarea', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 				'textarea_small', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 				'textarea_code', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 				'text_date', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 				'text_time', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 				'select_timezone', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 				'text_date_timestamp', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 				'text_datetime_timestamp', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 				'text_datetime_timestamp_timezone', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 				'colorpicker', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 				'select', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 				'multicheck', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 				'multicheck_inline', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 				'file', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 				'file_list', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			return in_array( $field_type, $repeatable_fields, true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 		 * Function has_options(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 		 * @todo Document properly. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 		 * @since  0.0.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		 * @param string $field_type A CMB2 field type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 		static function has_options( $field_type ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 			$options_fields = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 				'radio', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 				'radio_inline', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  | 				'taxonomy_radio', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 				'taxonomy_radio_inline', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 				'select', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  | 				'taxonomy_select', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 				'multicheck', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 				'multicheck_inline', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 				'taxonomy_multicheck', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 				'taxonomy_multicheck_inline', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 			return in_array( $field_type, $options_fields, true ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 		 * Function afo(). | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		 * @todo Document properly. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 		 * @since  0.0.6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 		 * @param array  $field      Field definition. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 		 * @param string $field_type A CMB2 field type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 		static function afo( $field, $field_type ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 			return ( in_array( $field['_cmb2_field_type_select'], $field_type, true ) && ( ! empty( $field['_cmb2_add_upload_file_text'] ) && is_string( $field['_cmb2_add_upload_file_text'] ) ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  | 		 * Loop through user defined meta_box and creates the custom meta boxes and fields. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 		 * @since  0.0.1 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  | 		public function init_user_defined_meta_boxes_and_fields() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 			$args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  | 				'post_type'        => 'meta_box', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 				'post_status'      => 'publish', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 				'posts_per_page'   => -1, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 				'suppress_filters' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  | 			$prefix = $this->prefix; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  | 			$user_meta_boxes = get_posts( $args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 			foreach ( $user_meta_boxes as $user_meta_box ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 				$metabox_id = $user_meta_box->ID; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 				$title          = get_the_title( $metabox_id ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 				$id             = str_replace( '-', '_', $user_meta_box->post_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 				$post_type      = cmbf( $metabox_id, $prefix . 'post_type_multicheckbox' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 				$context        = cmbf( $metabox_id, $prefix . 'context_radio' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 				$priority       = cmbf( $metabox_id, $prefix . 'priority_radio' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 				$show_names     = cmbf( $metabox_id, $prefix . 'show_names' ) === 'on' ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 				$disable_styles = cmbf( $metabox_id, $prefix . 'disable_styles' ) === 'on' ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 				$closed         = cmbf( $metabox_id, $prefix . 'closed' ) === 'on' ? true : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 				$fields         = cmbf( $metabox_id, $prefix . 'custom_field' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 				/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 				 * Initiate the metabox. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 				 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 				${ 'cmb_' . $id } = new_cmb2_box( array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  | 					'id'           => $id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 					'title'        => $title, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 					'object_types' => $post_type, // Post type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 					'context'      => $context, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 					'priority'     => $priority, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 					'show_names'   => $show_names, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 					'cmb_styles'   => $disable_styles, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 					'closed'       => $closed, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 				) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 				foreach ( $fields as $field ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  | 					$field_id = '_' . strtolower( str_replace( ' ', '_', $field['_cmb2_name_text'] ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 					$field_args = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 						'name' => $field['_cmb2_name_text'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 						'desc' => $field['_cmb2_decription_textarea'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 						'id'   => $field_id, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 						'type' => $field['_cmb2_field_type_select'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 					$options = isset( $field['_cmb2_options_textarea'] ) ? $field['_cmb2_options_textarea'] : false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  | 					if ( $options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 						$options = explode( PHP_EOL, $options ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 						foreach ( $options as $option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 							$opt_arr = explode( ',', $option ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 							if ( ! isset( $opt_arr[1] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 								continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 							} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 							$field_options[ $opt_arr[0] ] = $opt_arr[1]; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 						} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 						$field_args['options'] = $field_options; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 					if ( strpos( $field['_cmb2_field_type_select'], 'tax' ) !== false  && $field['_cmb2_tax_options_radio_inline'] !== '' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 						$field_args['taxonomy'] = $field['_cmb2_tax_options_radio_inline']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 					if ( strpos( $field['_cmb2_field_type_select'], 'tax' ) !== false && isset( $field['_cmb2_no_terms_text'] ) && $field['_cmb2_no_terms_text'] !== '' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 						$field_args['options']['no_terms_text'] = $field['_cmb2_no_terms_text']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 					if ( isset( $field['_cmb2_repeatable_checkbox'] ) && $field['_cmb2_repeatable_checkbox'] === 'on' && $this->is_repeatable( $field['_cmb2_field_type_select'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 						$field_args['repeatable'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 					if ( $field['_cmb2_field_type_select'] === 'url' && isset( $field['_cmb2_protocols_checkbox'] ) && ! empty( $field['_cmb2_protocols_checkbox'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 						$field_args['protocols'] = $field['_cmb2_protocols_checkbox']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 					if ( $this->afo( $field, array( 'text_money' ), '_cmb2_currency_text' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 						$field_args['before_field'] = $field['_cmb2_currency_text']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 					if ( $this->afo( $field, array( 'text_time' ), '_cmb2_time_format' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 						$field_args['time_format'] = $field['_cmb2_time_format']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 					if ( $this->afo( $field, array( 'text_date', 'text_date_timestamp' ), '_cmb2_date_format' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 						$field_args['date_format'] = $field['_cmb2_date_format']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 					if ( $this->afo( $field, array( 'text_date_timestamp' ), '_cmb2_time_zone_key_select' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 						$field_args['timezone_meta_key'] = $field['_cmb2_time_zone_key_select']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 					if ( isset( $field['_cmb2_none_checkbox'] ) && $field['_cmb2_none_checkbox'] === 'on' && $this->has_options( $field['_cmb2_field_type_select'] ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 						$field_args['show_option_none'] = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 					if ( strpos( $field['_cmb2_field_type_select'], 'multicheck' ) !== false  && isset( $field['_cmb2_select_all_checkbox'] ) && $field['_cmb2_select_all_checkbox'] === 'on' ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 						$field_args['select_all_button'] = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 					if ( $this->afo( $field, array( 'file' ), '_cmb2_add_upload_file_text' ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 						$field_args['options']['add_upload_file_text'] = $field['_cmb2_add_upload_file_text']; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 					} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 					${ 'cmb_' . $id }->add_field( $field_args ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | if ( ! function_exists( 'cmb2ae_metabox' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 	 * Main instance of CMB2_Meta_Box. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 	 * @since  0.1.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 	function cmb2ae_metabox() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 		return CMB2_Meta_Box::get_instance(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 317 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 318 |  |  |  | 
            
                        
This check looks
TODOcomments that have been left in the code.``TODO``s show that something is left unfinished and should be attended to.