PATH:
home
/
letacommog
/
metras
/
wp-content
/
plugins
/
wp-lastweets
/
vendor
/
htmlburger
/
carbon-fields
/
core
/
Field
<?php namespace Carbon_Fields\Field; use Carbon_Fields\Helper\Helper; class Sidebar_Field extends Select_Field { /** * Allow the user to add new sidebars * * @var boolean */ private $enable_add_new = true; /** * Array of sidebars to exclude from the select menu * * @var array */ private $excluded_sidebars = array(); /** * {@inheritDoc} */ protected function load_options() { $sidebars = Helper::get_active_sidebars(); $options = array(); foreach ( $sidebars as $sidebar ) { if ( in_array( $sidebar[ 'id' ], $this->excluded_sidebars ) ) { continue; } $options[ $sidebar['id'] ] = $sidebar['name']; } return $options; } /** * Disable adding new sidebars. * * @return self $this */ public function disable_add_new() { $this->enable_add_new = false; return $this; } /** * Specify sidebars to be excluded. * * @param array $sidebars * @return self $this */ public function set_excluded_sidebars( $sidebars ) { $this->excluded_sidebars = is_array( $sidebars ) ? $sidebars : array( $sidebars ); return $this; } /** * Returns an array that holds the field data, suitable for JSON representation. * * @param bool $load Should the value be loaded from the database or use the value from the current instance. * @return array */ public function to_json( $load ) { $options = array(); if ( $this->enable_add_new ) { $options[] = array( 'value' => '__add_new', 'label' => _x( 'Add New', 'sidebar', 'carbon-fields' ), ); } $field_data = parent::to_json( $load ); // override default value and options behavior since sidebars are // loaded separately and not as a part of the field options $field_data = array_merge( $field_data, array( 'value' => $this->get_formatted_value(), ) ); $field_data['options'] = array_merge( $field_data['options'], $options ); if ( ! empty( $this->excluded_sidebars ) ) { $field_data = array_merge( $field_data, array( 'excluded_sidebars' => $this->excluded_sidebars, ) ); } return $field_data; } }
[+]
..
[-] Date_Field.php
[edit]
[-] Checkbox_Field.php
[edit]
[-] Broken_Field.php
[edit]
[-] Sidebar_Field.php
[edit]
[-] Textarea_Field.php
[edit]
[-] Radio_Image_Field.php
[edit]
[-] Text_Field.php
[edit]
[-] Multiselect_Field.php
[edit]
[-] Set_Field.php
[edit]
[-] Radio_Field.php
[edit]
[-] Group_Field.php
[edit]
[-] Header_Scripts_Field.php
[edit]
[-] Oembed_Field.php
[edit]
[-] Scripts_Field.php
[edit]
[-] Hidden_Field.php
[edit]
[-] Field.php
[edit]
[-] Date_Time_Field.php
[edit]
[-] Footer_Scripts_Field.php
[edit]
[-] Time_Field.php
[edit]
[-] Image_Field.php
[edit]
[-] Gravity_Form_Field.php
[edit]
[-] Color_Field.php
[edit]
[-] Complex_Field.php
[edit]
[-] Select_Field.php
[edit]
[-] Predefined_Options_Field.php
[edit]
[-] Rich_Text_Field.php
[edit]
[-] Separator_Field.php
[edit]
[-] File_Field.php
[edit]
[-] Association_Field.php
[edit]
[-] Media_Gallery_Field.php
[edit]
[-] Map_Field.php
[edit]
[-] Html_Field.php
[edit]