cmb_id ] = $cmb_instance; } /** * Remove a CMB2 instance object from the registry. * * @since 1.X.X * * @param string $cmb_id A CMB2 instance id. */ public static function remove( $cmb_id ) { if ( array_key_exists( $cmb_id, self::$cmb2_instances ) ) { unset( self::$cmb2_instances[ $cmb_id ] ); } } /** * Retrieve a CMB2 instance by cmb id. * * @since 1.X.X * * @param string $cmb_id A CMB2 instance id. * * @return CMB2|bool False or CMB2 object instance. */ public static function get( $cmb_id ) { if ( empty( self::$cmb2_instances ) || empty( self::$cmb2_instances[ $cmb_id ] ) ) { return false; } return self::$cmb2_instances[ $cmb_id ]; } /** * Retrieve all CMB2 instances registered. * * @since 1.X.X * @return CMB2[] Array of all registered cmb2 instances. */ public static function get_all() { return self::$cmb2_instances; } /** * Retrieve all CMB2 instances that have the specified property set. * @since 2.2.3 * @param string $property Property name. * @param mixed $ignore The value to ignore. * @return CMB2[] Array of matching cmb2 instances. */ public static function get_by_property( $property, $ignore = null ) { $by_property[ $property ] = array(); foreach ( self::$cmb2_instances as $cmb_id => $cmb ) { if ( $ignore === $cmb->prop( $property ) ) { continue; } $by_property[ $property ][ $cmb_id ] = $cmb; } return $by_property[ $property ]; } }