first commit

This commit is contained in:
DESKTOP-GBA0BK8\Admin
2023-04-08 12:19:53 -04:00
commit 7c8c8b1c76
4586 changed files with 2050693 additions and 0 deletions
@@ -0,0 +1,44 @@
<?php
/**
* Buttonset control class.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Buttonset control class.
*
* @since 1.0.0
* @access public
*/
class OceanWP_ButterBean_Control_Buttonset extends OceanWP_ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'buttonset';
/**
* Get the value for the setting.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
$value = parent::get_value( $setting );
$object = $this->get_setting( $setting );
return ! $value && $object ? $object->default : $value;
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Multiple checkbox control class. This is for array-type settings, so you'll need
* to utilize a setting type that handles arrays. Both the `array` and `multiple`
* setting types will do this.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Multiple checkboxes control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_CheckBoxes extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'checkboxes';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['value'] = (array) $this->get_value();
}
}
@@ -0,0 +1,104 @@
<?php
/**
* Color control class. This class uses the core WordPress color picker. Expected
* values are hex colors. This class also attempts to strip `#` from the hex color.
* By design, it's recommended to add the `#` on output.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Color control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Color extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'color';
/**
* Custom options to pass to the color picker. Mostly, this is a wrapper for
* `iris()`, which is bundled with core WP. However, if they change pickers
* in the future, it may correspond to a different script.
*
* @link http://automattic.github.io/Iris/#options
* @link https://make.wordpress.org/core/2012/11/30/new-color-picker-in-wp-3-5/
* @since 1.0.0
* @access public
* @var array
*/
public $options = array();
/**
* Enqueue scripts/styles for the control.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue() {
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
}
/**
* Gets the attributes for the control.
*
* @since 1.0.0
* @access public
* @return array
*/
public function get_attr() {
$attr = parent::get_attr();
$setting = $this->get_setting();
$attr['class'] = 'butterbean-color-picker';
$attr['type'] = 'text';
$attr['maxlength'] = 7;
$attr['data-default-color'] = $setting ? $setting->default : '';
return $attr;
}
/**
* Get the value for the setting.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
$value = parent::get_value( $setting );
return ltrim( $value, '#' );
}
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['options'] = $this->options;
}
}
@@ -0,0 +1,140 @@
<?php
/**
* Datetime control class. This class is meant for storing a datetime in the format
* of `YYYY-MM-DD HH:MM:SS` or `0000-00-00 00:00:00`. You can set the `$show_time`
* property to `false`.
*
* Note that this control should be used in conjunction with the `datetime` setting
* type or another custom class that can handle the datetime.
*
* @package ButterBean
* @subpackage Admin
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Datetime control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Datetime extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'datetime';
/**
* Whether to show the time. Note that settings, particularly the
* `ButterBean_Setting_Date` class will store the time as `00:00:00` if
* no time is provided.
*
* @since 1.0.0
* @access public
* @var bool
*/
public $show_time = true;
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @globl object $wp_locale
* @return void
*/
public function to_json() {
global $wp_locale;
parent::to_json();
$this->json['show_time'] = $this->show_time;
$field_name = $this->get_field_name();
// Get project start/end dates.
$date = $this->get_value();
// Get the year, month, and day.
$year = $date ? mysql2date( 'Y', $date, false ) : '';
$month = $date ? mysql2date( 'm', $date, false ) : '';
$day = $date ? mysql2date( 'd', $date, false ) : '';
// Get the hour, minute, and second.
$hour = $date ? mysql2date( 'H', $date, false ) : '';
$minute = $date ? mysql2date( 'i', $date, false ) : '';
$second = $date ? mysql2date( 's', $date, false ) : '';
// Year
$this->json['year'] = array(
'value' => esc_attr( $year ),
'label' => esc_html__( 'Year', 'butterbean' ),
'name' => esc_attr( "{$field_name}_year" ),
'attr' => sprintf( 'placeholder="%s" size="4" maxlength="4" autocomplete="off"', esc_attr( date_i18n( 'Y' ) ) )
);
// Month
$this->json['month'] = array(
'value' => esc_attr( $month ),
'name' => esc_attr( "{$field_name}_month" ),
'label' => esc_html__( 'Month', 'butterbean' ),
'choices' => array(
array(
'num' => '',
'label' => ''
)
)
);
for ( $i = 1; $i < 13; $i = $i +1 ) {
$monthnum = zeroise( $i, 2 );
$monthtext = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) );
$this->json['month']['choices'][] = array(
'num' => $monthnum,
'label' => $monthtext
);
}
// Day
$this->json['day'] = array(
'value' => esc_attr( $day ),
'name' => esc_attr( "{$field_name}_day" ),
'label' => esc_html__( 'Day', 'butterbean' ),
'attr' => sprintf( 'placeholder="%s" size="2" maxlength="2" autocomplete="off"', esc_attr( date_i18n( 'd' ) ) )
);
// Hour
$this->json['hour'] = array(
'value' => esc_attr( $hour ),
'name' => esc_attr( "{$field_name}_hour" ),
'label' => esc_html__( 'Hour', 'butterbean' ),
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
);
// Minute
$this->json['minute'] = array(
'value' => esc_attr( $minute ),
'name' => esc_attr( "{$field_name}_minute" ),
'label' => esc_html__( 'Minute', 'butterbean' ),
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
);
// Second
$this->json['second'] = array(
'value' => esc_attr( $second ),
'name' => esc_attr( "{$field_name}_second" ),
'label' => esc_html__( 'Second', 'butterbean' ),
'attr' => 'placeholder="00" size="2" maxlength="2" autocomplete="off"'
);
}
}
@@ -0,0 +1,54 @@
<?php
/**
* Editor control class.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Editor control class.
*
* @since 1.0.0
* @access public
*/
class OceanWP_ButterBean_Control_Editor extends OceanWP_ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'editor';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['value'] = $this->get_value();
}
/**
* Gets the attributes for the control.
* Sets the new id attribute, as it's required for TinyMCE to function properly.
* Sets new class .tinymce for easier js initialization.
*
* @return array
*/
public function get_attr() {
$this->attr = parent::get_attr();
$this->attr['id'] = $this->get_field_name();
return $this->attr;
}
}
@@ -0,0 +1,82 @@
<?php
/**
* Excerpt control class. Note that this control isn't meant to be tied to a setting. Core
* WP will save the excerpt. Also, make sure to disable the core excerpt metabox if using
* this control.
*
* @package ButterBean
* @subpackage Admin
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Excerpt control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Excerpt extends ButterBean_Control_Textarea {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'excerpt';
/**
* Gets the attributes for the control.
*
* @since 1.0.0
* @access public
* @return array
*/
public function get_attr() {
$attr = parent::get_attr();
$attr['id'] = 'post_excerpt';
return $attr;
}
/**
* Returns the HTML field name for the control.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return string
*/
public function get_field_name( $setting = 'default' ) {
return 'post_excerpt';
}
/**
* Get the value for the setting.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
return get_post( $this->manager->post_id )->post_excerpt;
}
/**
* Gets the Underscore.js template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function get_template() {
butterbean_get_control_template( 'textarea' );
}
}
@@ -0,0 +1,112 @@
<?php
/**
* Image control class. This control allows users to set an image. It passes the attachment
* ID the setting, so you'll need a custom control class if you want to store anything else,
* such as the URL or other data.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Image control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Image extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'image';
/**
* Array of text labels to use for the media upload frame.
*
* @since 1.0.0
* @access public
* @var string
*/
public $l10n = array();
/**
* Image size to display. If the size isn't found for the image,
* the full size of the image will be output.
*
* @since 1.0.0
* @access public
* @var string
*/
public $size = 'large';
/**
* Creates a new control object.
*
* @since 1.0.0
* @access public
* @param object $manager
* @param string $name
* @param array $args
* @return void
*/
public function __construct( $manager, $name, $args = array() ) {
parent::__construct( $manager, $name, $args );
$this->l10n = wp_parse_args(
$this->l10n,
array(
'upload' => esc_html__( 'Add image', 'butterbean' ),
'set' => esc_html__( 'Set as image', 'butterbean' ),
'choose' => esc_html__( 'Choose image', 'butterbean' ),
'change' => esc_html__( 'Change image', 'butterbean' ),
'remove' => esc_html__( 'Remove image', 'butterbean' ),
'placeholder' => esc_html__( 'No image selected', 'butterbean' )
)
);
}
/**
* Enqueue scripts/styles for the control.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue() {
wp_enqueue_script( 'media-views' );
}
/**
* Adds custom data to the json array.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['l10n'] = $this->l10n;
$this->json['size'] = $this->size;
$value = $this->get_value();
$image = $alt = '';
if ( $value ) {
$image = wp_get_attachment_image_src( absint( $value ), $this->size );
$alt = get_post_meta( absint( $value ), '_wp_attachment_image_alt', true );
}
$this->json['src'] = $image ? esc_url( $image[0] ) : '';
$this->json['alt'] = $alt ? esc_attr( $alt ) : '';
}
}
@@ -0,0 +1,83 @@
<?php
/**
* Media control class.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Media control class.
*
* @since 1.0.0
* @access public
*/
class OceanWP_ButterBean_Control_Media extends OceanWP_ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'media';
/**
* Array of text labels to use for the media upload frame.
*
* @since 1.0.0
* @access public
* @var string
*/
public $l10n = array();
/**
* Creates a new control object.
*
* @since 1.0.0
* @access public
* @param object $manager
* @param string $name
* @param array $args
* @return void
*/
public function __construct( $manager, $name, $args = array() ) {
parent::__construct( $manager, $name, $args );
$this->l10n = wp_parse_args(
$this->l10n,
array(
'upload' => esc_html__( 'Browse', 'ocean-extra' ),
)
);
}
/**
* Enqueue scripts/styles for the control.
*
* @since 1.0.0
* @access public
* @return void
*/
public function enqueue() {
wp_enqueue_media();
}
/**
* Adds custom data to the json array.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['l10n'] = $this->l10n;
}
}
@@ -0,0 +1,90 @@
<?php
/**
* Multi-avatars control. This control is for outputting multiple users who can create,
* edit, or publish posts of the given post type. Multiple users can be selected. The
* data is expected to be an array. This control should be used with a setting type that
* handles arrays, such as the built-in `array` or `multiple` types.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Multi-avatars control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Multi_Avatars extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'multi-avatars';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['value'] = is_array( $this->get_value() ) ? array_map( 'absint', $this->get_value() ) : array();
$this->json['choices'] = array();
$users = get_users( array( 'role__in' => $this->get_roles() ) );
foreach ( $users as $user ) {
$this->json['choices'][] = array(
'id' => $user->ID,
'name' => $user->display_name,
'avatar' => get_avatar( $user->ID, 70 )
);
}
}
/**
* Returns an array of user roles that are allowed to edit, publish, or create
* posts of the given post type.
*
* @since 1.0.0
* @access public
* @global object $wp_roles
* @return array
*/
public function get_roles() {
global $wp_roles;
$roles = array();
$type = get_post_type_object( get_post_type( $this->manager->post_id ) );
// Get the post type object caps.
$caps = array( $type->cap->edit_posts, $type->cap->publish_posts, $type->cap->create_posts );
$caps = array_unique( $caps );
// Loop through the available roles.
foreach ( $wp_roles->roles as $name => $role ) {
foreach ( $caps as $cap ) {
// If the role is granted the cap, add it.
if ( isset( $role['capabilities'][ $cap ] ) && true === $role['capabilities'][ $cap ] ) {
$roles[] = $name;
break;
}
}
}
return $roles;
}
}
@@ -0,0 +1,51 @@
<?php
/**
* Color palette control class. The purpose of this class is to give users a choice
* of color palettes. The actual data that is stored is a key of your choosing.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Color palette control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Palette extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'palette';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$value = $this->get_value();
// Make sure the colors have a hash.
foreach ( $this->choices as $choice => $palette ) {
$this->choices[ $choice ]['colors'] = array_map( 'butterbean_maybe_hash_hex_color', $palette['colors'] );
$this->choices[ $choice ]['selected'] = $value && $choice === $value;
}
$this->json['choices'] = $this->choices;
}
}
@@ -0,0 +1,97 @@
<?php
/**
* Post parent control class. This class is a specialty class meant for use in unique
* scenarios where you're not using the core post parent drop-down. This is often the
* case with flat post types that have a parent post. This control is not meant to be
* used with a setting. Core WP will store the data in the `post.post_parent` field.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Post parent control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Parent extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'parent';
/**
* The post type to select posts from.
*
* @since 1.0.0
* @access public
* @var string
*/
public $post_type = '';
/**
* Returns the HTML field name for the control.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return array
*/
public function get_field_name( $setting = 'default' ) {
return 'post_parent';
}
/**
* Get the value for the setting.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
return get_post( $this->manager->post_id )->post_parent;
}
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$_post = get_post( $this->manager->post_id );
$posts = get_posts(
array(
'post_type' => $this->post_type ? $this->post_type : get_post_type( $this->manager->post_id ),
'post_status' => 'any',
'post__not_in' => array( $this->manager->post_id ),
'posts_per_page' => -1,
'post_parent' => 0,
'orderby' => 'title',
'order' => 'ASC',
'fields' => array( 'ID', 'post_title' )
)
);
$this->json['choices'] = array( array( 'value' => 0, 'label' => '' ) );
foreach ( $posts as $post )
$this->json['choices'][] = array( 'value' => $post->ID, 'label' => $post->post_title );
}
}
@@ -0,0 +1,46 @@
<?php
/**
* Radio image control class extends the built-in radio control. This control is
* meant for displaying an image instead of the radio fields.
*
* @package ButterBean
* @subpackage Admin
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Radio image control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Radio_Image extends ButterBean_Control_Radio {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'radio-image';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
foreach ( $this->choices as $value => $args )
$this->choices[ $value ]['url'] = esc_url( sprintf( $args['url'], get_template_directory_uri(), get_stylesheet_directory_uri() ) );
$this->json['choices'] = $this->choices;
}
}
@@ -0,0 +1,46 @@
<?php
/**
* Radio control class that creates a list of radio inputs to choose from.
*
* @package ButterBean
* @subpackage Admin
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Radio control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Radio extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'radio';
/**
* Radio controls imply that a value should be set. Therefore, we will return
* the default if there is no value.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
$value = parent::get_value( $setting );
$object = $this->get_setting( $setting );
return ! $value && $object ? $object->default : $value;
}
}
@@ -0,0 +1,61 @@
<?php
/**
* Range control class.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Range control class.
*
* @since 1.0.0
* @access public
*/
class OceanWP_ButterBean_Control_Range extends OceanWP_ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'range';
/**
* Gets the attributes for the control.
*
* @since 1.0.0
* @access public
* @return array
*/
public function get_attr() {
$attr = parent::get_attr();
$setting = $this->get_setting();
$attr['data-reset_value'] = $setting ? $setting->default : '';
return $attr;
}
/**
* Get the value for the setting.
*
* @since 1.0.0
* @access public
* @param string $setting
* @return mixed
*/
public function get_value( $setting = 'default' ) {
$value = parent::get_value( $setting );
$object = $this->get_setting( $setting );
return ! $value && $object ? $object->default : $value;
}
}
@@ -0,0 +1,53 @@
<?php
/**
* Select group control class. This works just like a normal select. However, it
* allows for `<optgroup>` to be added.
*
* @package ButterBean
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Select group control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Select_Group extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'select-group';
/**
* Adds custom data to the json array.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$choices = $group = array();
foreach ( $this->choices as $choice => $maybe_group ) {
if ( is_array( $maybe_group ) )
$group[ $choice ] = $maybe_group;
else
$choices[ $choice ] = $maybe_group;
}
$this->json['choices'] = $choices;
$this->json['group'] = $group;
}
}
@@ -0,0 +1,42 @@
<?php
/**
* Textarea control class.
*
* @package ButterBean
* @subpackage Admin
* @author Justin Tadlock <justin@justintadlock.com>
* @copyright Copyright (c) 2015-2016, Justin Tadlock
* @link https://github.com/justintadlock/butterbean
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
/**
* Textarea control class.
*
* @since 1.0.0
* @access public
*/
class ButterBean_Control_Textarea extends ButterBean_Control {
/**
* The type of control.
*
* @since 1.0.0
* @access public
* @var string
*/
public $type = 'textarea';
/**
* Adds custom data to the json array. This data is passed to the Underscore template.
*
* @since 1.0.0
* @access public
* @return void
*/
public function to_json() {
parent::to_json();
$this->json['value'] = esc_textarea( $this->get_value() );
}
}