| Server IP : 213.186.33.4 / Your IP : 216.73.216.146 Web Server : Apache System : Linux webm005.cluster103.gra.hosting.ovh.net 6.18.39-ovh-vps-grsec-zfs+ #1 SMP PREEMPT_DYNAMIC Tue Jul 21 12:03:15 CEST 2026 x86_64 User : karinebmkh ( 644538) PHP Version : 8.4.22 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/karinebmkh/www2/wp-content/plugins/glaza-core/lib/meta-box/inc/fields/ |
Upload File : |
<?php
/**
* The sidebar select field.
*
* @package Meta Box
*/
/**
* Sidebar field class.
*/
class RWMB_Sidebar_Field extends RWMB_Object_Choice_Field {
/**
* Normalize parameters for field.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function normalize( $field ) {
// Set default field args.
$field = parent::normalize( $field );
// Prevent select tree for user since it's not hierarchical.
$field['field_type'] = 'select_tree' === $field['field_type'] ? 'select' : $field['field_type'];
// Set to always flat.
$field['flatten'] = true;
// Set default placeholder.
$field['placeholder'] = empty( $field['placeholder'] ) ? __( 'Select a sidebar', 'meta-box' ) : $field['placeholder'];
return $field;
}
/**
* Get users.
*
* @param array $field Field parameters.
*
* @return array
*/
public static function get_options( $field ) {
global $wp_registered_sidebars;
$options = array();
foreach ( $wp_registered_sidebars as $sidebar ) {
$options[] = (object) $sidebar;
}
return $options;
}
/**
* Get field names of object to be used by walker.
*
* @return array
*/
public static function get_db_fields() {
return array(
'parent' => 'parent',
'id' => 'id',
'label' => 'name',
);
}
/**
* Get option label.
*
* @param array $field Field parameters.
* @param string $value Option value.
*
* @return string
*/
public static function get_option_label( $field, $value ) {
if ( ! is_active_sidebar( $value ) ) {
return '';
}
ob_start();
dynamic_sidebar( $value );
return ob_get_clean();
}
}