@@ -12,67 +12,67 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CMB2_Type_Text_Datetime_Timestamp extends CMB2_Type_Picker_Base { |
| 14 | 14 | |
| 15 | - public function render( $args = array() ) { |
|
| 15 | + public function render($args = array()) { |
|
| 16 | 16 | $field = $this->field; |
| 17 | 17 | |
| 18 | 18 | $value = $field->escaped_value(); |
| 19 | - if ( empty( $value ) ) { |
|
| 19 | + if (empty($value)) { |
|
| 20 | 20 | $value = $field->get_default(); |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - $args = wp_parse_args( $this->args, array( |
|
| 23 | + $args = wp_parse_args($this->args, array( |
|
| 24 | 24 | 'value' => $value, |
| 25 | 25 | 'desc' => $this->_desc(), |
| 26 | 26 | 'datepicker' => array(), |
| 27 | 27 | 'timepicker' => array(), |
| 28 | - ) ); |
|
| 28 | + )); |
|
| 29 | 29 | |
| 30 | - if ( empty( $args['value'] ) ) { |
|
| 30 | + if (empty($args['value'])) { |
|
| 31 | 31 | $args['value'] = $value; |
| 32 | 32 | // This will be used if there is a select_timezone set for this field |
| 33 | 33 | $tz_offset = $field->field_timezone_offset(); |
| 34 | - if ( ! empty( $tz_offset ) ) { |
|
| 34 | + if ( ! empty($tz_offset)) { |
|
| 35 | 35 | $args['value'] -= $tz_offset; |
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $has_good_value = ! empty( $args['value'] ) && ! is_array( $args['value'] ); |
|
| 39 | + $has_good_value = ! empty($args['value']) && ! is_array($args['value']); |
|
| 40 | 40 | |
| 41 | - $date_input = parent::render( $this->date_args( $args, $has_good_value ) ); |
|
| 42 | - $time_input = parent::render( $this->time_args( $args, $has_good_value ) ); |
|
| 41 | + $date_input = parent::render($this->date_args($args, $has_good_value)); |
|
| 42 | + $time_input = parent::render($this->time_args($args, $has_good_value)); |
|
| 43 | 43 | |
| 44 | - return $this->rendered( $date_input . "\n" . $time_input ); |
|
| 44 | + return $this->rendered($date_input . "\n" . $time_input); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function date_args( $args, $has_good_value ) { |
|
| 48 | - $date_args = wp_parse_args( $args['datepicker'], array( |
|
| 47 | + public function date_args($args, $has_good_value) { |
|
| 48 | + $date_args = wp_parse_args($args['datepicker'], array( |
|
| 49 | 49 | 'class' => 'cmb2-text-small cmb2-datepicker', |
| 50 | - 'name' => $this->_name( '[date]' ), |
|
| 51 | - 'id' => $this->_id( '_date' ), |
|
| 52 | - 'value' => $has_good_value ? $this->field->get_timestamp_format( 'date_format', $args['value'] ) : '', |
|
| 50 | + 'name' => $this->_name('[date]'), |
|
| 51 | + 'id' => $this->_id('_date'), |
|
| 52 | + 'value' => $has_good_value ? $this->field->get_timestamp_format('date_format', $args['value']) : '', |
|
| 53 | 53 | 'desc' => '', |
| 54 | - ) ); |
|
| 54 | + )); |
|
| 55 | 55 | |
| 56 | 56 | $date_args['rendered'] = true; |
| 57 | 57 | |
| 58 | 58 | // Let's get the date-format, and set it up as a data attr for the field. |
| 59 | - return $this->parse_picker_options( 'date', $date_args ); |
|
| 59 | + return $this->parse_picker_options('date', $date_args); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - public function time_args( $args, $has_good_value ) { |
|
| 63 | - $time_args = wp_parse_args( $args['timepicker'], array( |
|
| 62 | + public function time_args($args, $has_good_value) { |
|
| 63 | + $time_args = wp_parse_args($args['timepicker'], array( |
|
| 64 | 64 | 'class' => 'cmb2-timepicker text-time', |
| 65 | - 'name' => $this->_name( '[time]' ), |
|
| 66 | - 'id' => $this->_id( '_time' ), |
|
| 67 | - 'value' => $has_good_value ? $this->field->get_timestamp_format( 'time_format', $args['value'] ) : '', |
|
| 65 | + 'name' => $this->_name('[time]'), |
|
| 66 | + 'id' => $this->_id('_time'), |
|
| 67 | + 'value' => $has_good_value ? $this->field->get_timestamp_format('time_format', $args['value']) : '', |
|
| 68 | 68 | 'desc' => $args['desc'], |
| 69 | - 'js_dependencies' => array( 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-datetimepicker' ), |
|
| 70 | - ) ); |
|
| 69 | + 'js_dependencies' => array('jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-datetimepicker'), |
|
| 70 | + )); |
|
| 71 | 71 | |
| 72 | 72 | $time_args['rendered'] = true; |
| 73 | 73 | |
| 74 | 74 | // Let's get the time-format, and set it up as a data attr for the field. |
| 75 | - return $this->parse_picker_options( 'time', $time_args ); |
|
| 75 | + return $this->parse_picker_options('time', $time_args); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | } |
@@ -12,30 +12,30 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CMB2_Type_Oembed extends CMB2_Type_Text { |
| 14 | 14 | |
| 15 | - public function render( $args = array() ) { |
|
| 15 | + public function render($args = array()) { |
|
| 16 | 16 | $field = $this->field; |
| 17 | 17 | |
| 18 | - $meta_value = trim( $field->escaped_value() ); |
|
| 18 | + $meta_value = trim($field->escaped_value()); |
|
| 19 | 19 | |
| 20 | - $oembed = ! empty( $meta_value ) |
|
| 21 | - ? cmb2_ajax()->get_oembed( array( |
|
| 20 | + $oembed = ! empty($meta_value) |
|
| 21 | + ? cmb2_ajax()->get_oembed(array( |
|
| 22 | 22 | 'url' => $field->escaped_value(), |
| 23 | 23 | 'object_id' => $field->object_id, |
| 24 | 24 | 'object_type' => $field->object_type, |
| 25 | 25 | 'oembed_args' => array( |
| 26 | 26 | 'width' => '640', |
| 27 | 27 | ), |
| 28 | - 'field_id' => $this->_id( '', false ), |
|
| 29 | - ) ) |
|
| 28 | + 'field_id' => $this->_id('', false), |
|
| 29 | + )) |
|
| 30 | 30 | : ''; |
| 31 | 31 | |
| 32 | - return parent::render( array( |
|
| 32 | + return parent::render(array( |
|
| 33 | 33 | 'class' => 'cmb2-oembed regular-text', |
| 34 | 34 | 'data-objectid' => $field->object_id, |
| 35 | 35 | 'data-objecttype' => $field->object_type, |
| 36 | - ) ) |
|
| 36 | + )) |
|
| 37 | 37 | . '<p class="cmb-spinner spinner"></p>' |
| 38 | - . '<div id="' . $this->_id( '-status' ) . '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>'; |
|
| 38 | + . '<div id="' . $this->_id('-status') . '" class="cmb2-media-status ui-helper-clearfix embed_wrap">' . $oembed . '</div>'; |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | } |
@@ -27,26 +27,26 @@ |
||
| 27 | 27 | * @param CMB2_Types $types |
| 28 | 28 | * @param array $args |
| 29 | 29 | */ |
| 30 | - public function __construct( CMB2_Types $types, $args = array(), $type = '' ) { |
|
| 31 | - parent::__construct( $types, $args ); |
|
| 30 | + public function __construct(CMB2_Types $types, $args = array(), $type = '') { |
|
| 31 | + parent::__construct($types, $args); |
|
| 32 | 32 | $this->type = $type ? $type : $this->type; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function render() { |
| 36 | - $args = $this->parse_args( $this->type, array( |
|
| 36 | + $args = $this->parse_args($this->type, array( |
|
| 37 | 37 | 'class' => 'cmb2-radio-list cmb2-list', |
| 38 | - 'options' => $this->concat_items( array( |
|
| 38 | + 'options' => $this->concat_items(array( |
|
| 39 | 39 | 'label' => 'test', |
| 40 | 40 | 'method' => 'list_input', |
| 41 | - ) ), |
|
| 42 | - 'desc' => $this->_desc( true ), |
|
| 43 | - ) ); |
|
| 41 | + )), |
|
| 42 | + 'desc' => $this->_desc(true), |
|
| 43 | + )); |
|
| 44 | 44 | |
| 45 | - return $this->rendered( $this->ul( $args ) ); |
|
| 45 | + return $this->rendered($this->ul($args)); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function ul( $a ) { |
|
| 49 | - return sprintf( '<ul class="%s">%s</ul>%s', $a['class'], $a['options'], $a['desc'] ); |
|
| 48 | + protected function ul($a) { |
|
| 49 | + return sprintf('<ul class="%s">%s</ul>%s', $a['class'], $a['options'], $a['desc']); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | } |
@@ -32,26 +32,26 @@ discard block |
||
| 32 | 32 | |
| 33 | 33 | public function render() { |
| 34 | 34 | return $this->rendered( |
| 35 | - $this->types->select( array( |
|
| 35 | + $this->types->select(array( |
|
| 36 | 36 | 'options' => $this->get_term_options(), |
| 37 | - ) ) |
|
| 37 | + )) |
|
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | protected function get_term_options() { |
| 42 | 42 | $all_terms = $this->get_terms(); |
| 43 | 43 | |
| 44 | - if ( ! $all_terms || is_wp_error( $all_terms ) ) { |
|
| 45 | - return $this->no_terms_result( $all_terms, 'strong' ); |
|
| 44 | + if ( ! $all_terms || is_wp_error($all_terms)) { |
|
| 45 | + return $this->no_terms_result($all_terms, 'strong'); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - $this->saved_term = $this->get_object_term_or_default(); |
|
| 49 | - $option_none = $this->field->args( 'show_option_none' ); |
|
| 48 | + $this->saved_term = $this->get_object_term_or_default(); |
|
| 49 | + $option_none = $this->field->args('show_option_none'); |
|
| 50 | 50 | $options = ''; |
| 51 | 51 | |
| 52 | - if ( ! empty( $option_none ) ) { |
|
| 52 | + if ( ! empty($option_none)) { |
|
| 53 | 53 | |
| 54 | - $field_id = $this->_id( '', false ); |
|
| 54 | + $field_id = $this->_id('', false); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * Default (option-none) taxonomy-select value. |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @param string $option_none_value Default (option-none) taxonomy-select value. |
| 62 | 62 | */ |
| 63 | - $option_none_value = apply_filters( 'cmb2_taxonomy_select_default_value', '' ); |
|
| 63 | + $option_none_value = apply_filters('cmb2_taxonomy_select_default_value', ''); |
|
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * Default (option-none) taxonomy-select value. |
@@ -71,30 +71,30 @@ discard block |
||
| 71 | 71 | * |
| 72 | 72 | * @param string $option_none_value Default (option-none) taxonomy-select value. |
| 73 | 73 | */ |
| 74 | - $option_none_value = apply_filters( "cmb2_taxonomy_select_{$field_id}_default_value", $option_none_value ); |
|
| 74 | + $option_none_value = apply_filters("cmb2_taxonomy_select_{$field_id}_default_value", $option_none_value); |
|
| 75 | 75 | |
| 76 | - $options .= $this->select_option( array( |
|
| 76 | + $options .= $this->select_option(array( |
|
| 77 | 77 | 'label' => $option_none, |
| 78 | 78 | 'value' => $option_none_value, |
| 79 | 79 | 'checked' => $this->saved_term == $option_none_value, |
| 80 | - ) ); |
|
| 80 | + )); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $options .= $this->loop_terms( $all_terms, $this->saved_term ); |
|
| 83 | + $options .= $this->loop_terms($all_terms, $this->saved_term); |
|
| 84 | 84 | |
| 85 | 85 | return $options; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - protected function loop_terms( $all_terms, $saved_term ) { |
|
| 88 | + protected function loop_terms($all_terms, $saved_term) { |
|
| 89 | 89 | $options = ''; |
| 90 | 90 | |
| 91 | - foreach ( $all_terms as $term ) { |
|
| 91 | + foreach ($all_terms as $term) { |
|
| 92 | 92 | $this->current_term = $term; |
| 93 | - $options .= $this->select_option( array( |
|
| 93 | + $options .= $this->select_option(array( |
|
| 94 | 94 | 'label' => $term->name, |
| 95 | 95 | 'value' => $term->slug, |
| 96 | 96 | 'checked' => $this->saved_term === $term->slug, |
| 97 | - ) ); |
|
| 97 | + )); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | return $options; |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | * @param array $args Override arguments |
| 20 | 20 | * @return string Form textarea element |
| 21 | 21 | */ |
| 22 | - public function render( $args = array() ) { |
|
| 23 | - $args = wp_parse_args( $args, array( |
|
| 22 | + public function render($args = array()) { |
|
| 23 | + $args = wp_parse_args($args, array( |
|
| 24 | 24 | 'class' => 'cmb2-textarea-code', |
| 25 | - 'desc' => '</pre>' . $this->_desc( true ), |
|
| 26 | - ) ); |
|
| 25 | + 'desc' => '</pre>' . $this->_desc(true), |
|
| 26 | + )); |
|
| 27 | 27 | |
| 28 | - if ( true !== $this->field->options( 'disable_codemirror' ) |
|
| 29 | - && function_exists( 'wp_enqueue_code_editor' ) ) { |
|
| 30 | - $args['js_dependencies'] = array( 'code-editor' ); |
|
| 28 | + if (true !== $this->field->options('disable_codemirror') |
|
| 29 | + && function_exists('wp_enqueue_code_editor')) { |
|
| 30 | + $args['js_dependencies'] = array('code-editor'); |
|
| 31 | 31 | } else { |
| 32 | - $args['class'] = rtrim( $args['class'] ) . ' disable-codemirror'; |
|
| 32 | + $args['class'] = rtrim($args['class']) . ' disable-codemirror'; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | return $this->rendered( |
| 36 | - sprintf( '<pre>%s', parent::render( $args ) ) |
|
| 36 | + sprintf('<pre>%s', parent::render($args)) |
|
| 37 | 37 | ); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -19,8 +19,8 @@ discard block |
||
| 19 | 19 | * @param array $args Arguments array containing value, label, and checked boolean |
| 20 | 20 | * @return string Generated option element html |
| 21 | 21 | */ |
| 22 | - public function select_option( $args = array() ) { |
|
| 23 | - return sprintf( "\t" . '<option value="%s" %s>%s</option>', $args['value'], selected( isset( $args['checked'] ) && $args['checked'], true, false ), $args['label'] ) . "\n"; |
|
| 22 | + public function select_option($args = array()) { |
|
| 23 | + return sprintf("\t" . '<option value="%s" %s>%s</option>', $args['value'], selected(isset($args['checked']) && $args['checked'], true, false), $args['label']) . "\n"; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | /** |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | * @param int $i Iterator value |
| 32 | 32 | * @return string Gnerated list item html |
| 33 | 33 | */ |
| 34 | - public function list_input( $args = array(), $i ) { |
|
| 35 | - $a = $this->parse_args( 'list_input', array( |
|
| 34 | + public function list_input($args = array(), $i) { |
|
| 35 | + $a = $this->parse_args('list_input', array( |
|
| 36 | 36 | 'type' => 'radio', |
| 37 | 37 | 'class' => 'cmb2-option', |
| 38 | 38 | 'name' => $this->_name(), |
| 39 | - 'id' => $this->_id( $i ), |
|
| 39 | + 'id' => $this->_id($i), |
|
| 40 | 40 | 'value' => $this->field->escaped_value(), |
| 41 | 41 | 'label' => '', |
| 42 | - ), $args ); |
|
| 42 | + ), $args); |
|
| 43 | 43 | |
| 44 | - return sprintf( "\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs( $a, array( 'label' ) ), $a['id'], $a['label'] ); |
|
| 44 | + return sprintf("\t" . '<li><input%s/> <label for="%s">%s</label></li>' . "\n", $this->concat_attrs($a, array('label')), $a['id'], $a['label']); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | * @param int $i Iterator value |
| 53 | 53 | * @return string Gnerated list item html |
| 54 | 54 | */ |
| 55 | - public function list_input_checkbox( $args, $i ) { |
|
| 55 | + public function list_input_checkbox($args, $i) { |
|
| 56 | 56 | $saved_value = $this->field->escaped_value(); |
| 57 | - if ( is_array( $saved_value ) && in_array( $args['value'], $saved_value ) ) { |
|
| 57 | + if (is_array($saved_value) && in_array($args['value'], $saved_value)) { |
|
| 58 | 58 | $args['checked'] = 'checked'; |
| 59 | 59 | } |
| 60 | 60 | $args['type'] = 'checkbox'; |
| 61 | - return $this->list_input( $args, $i ); |
|
| 61 | + return $this->list_input($args, $i); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -68,27 +68,27 @@ discard block |
||
| 68 | 68 | * @param array $args Optional arguments |
| 69 | 69 | * @return string Concatenated html items |
| 70 | 70 | */ |
| 71 | - public function concat_items( $args = array() ) { |
|
| 71 | + public function concat_items($args = array()) { |
|
| 72 | 72 | $field = $this->field; |
| 73 | 73 | |
| 74 | - $method = isset( $args['method'] ) ? $args['method'] : 'select_option'; |
|
| 75 | - unset( $args['method'] ); |
|
| 74 | + $method = isset($args['method']) ? $args['method'] : 'select_option'; |
|
| 75 | + unset($args['method']); |
|
| 76 | 76 | |
| 77 | 77 | $value = null !== $field->escaped_value() |
| 78 | 78 | ? $field->escaped_value() |
| 79 | 79 | : $field->get_default(); |
| 80 | 80 | |
| 81 | - $value = CMB2_Utils::normalize_if_numeric( $value ); |
|
| 81 | + $value = CMB2_Utils::normalize_if_numeric($value); |
|
| 82 | 82 | |
| 83 | 83 | $concatenated_items = ''; |
| 84 | 84 | $i = 1; |
| 85 | 85 | |
| 86 | 86 | $options = array(); |
| 87 | - if ( $option_none = $field->args( 'show_option_none' ) ) { |
|
| 87 | + if ($option_none = $field->args('show_option_none')) { |
|
| 88 | 88 | $options[''] = $option_none; |
| 89 | 89 | } |
| 90 | 90 | $options = $options + (array) $field->options(); |
| 91 | - foreach ( $options as $opt_value => $opt_label ) { |
|
| 91 | + foreach ($options as $opt_value => $opt_label) { |
|
| 92 | 92 | |
| 93 | 93 | // Clone args & modify for just this item |
| 94 | 94 | $a = $args; |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | $a['label'] = $opt_label; |
| 98 | 98 | |
| 99 | 99 | // Check if this option is the value of the input |
| 100 | - if ( $value === CMB2_Utils::normalize_if_numeric( $opt_value ) ) { |
|
| 100 | + if ($value === CMB2_Utils::normalize_if_numeric($opt_value)) { |
|
| 101 | 101 | $a['checked'] = 'checked'; |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | - $concatenated_items .= $this->$method( $a, $i++ ); |
|
| 104 | + $concatenated_items .= $this->$method($a, $i++); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | return $concatenated_items; |
@@ -20,70 +20,70 @@ discard block |
||
| 20 | 20 | * @since 1.1.0 |
| 21 | 21 | * @return string Form wysiwyg element |
| 22 | 22 | */ |
| 23 | - public function render( $args = array() ) { |
|
| 23 | + public function render($args = array()) { |
|
| 24 | 24 | $field = $this->field; |
| 25 | - $a = $this->parse_args( 'wysiwyg', array( |
|
| 26 | - 'id' => $this->_id( '', false ), |
|
| 27 | - 'value' => $field->escaped_value( 'stripslashes' ), |
|
| 28 | - 'desc' => $this->_desc( true ), |
|
| 25 | + $a = $this->parse_args('wysiwyg', array( |
|
| 26 | + 'id' => $this->_id('', false), |
|
| 27 | + 'value' => $field->escaped_value('stripslashes'), |
|
| 28 | + 'desc' => $this->_desc(true), |
|
| 29 | 29 | 'options' => $field->options(), |
| 30 | - ) ); |
|
| 30 | + )); |
|
| 31 | 31 | |
| 32 | - if ( ! $field->group ) { |
|
| 32 | + if ( ! $field->group) { |
|
| 33 | 33 | |
| 34 | - $a = $this->maybe_update_attributes_for_char_counter( $a ); |
|
| 34 | + $a = $this->maybe_update_attributes_for_char_counter($a); |
|
| 35 | 35 | |
| 36 | - if ( $this->has_counter ) { |
|
| 37 | - $a['options']['editor_class'] = ! empty( $a['options']['editor_class'] ) |
|
| 36 | + if ($this->has_counter) { |
|
| 37 | + $a['options']['editor_class'] = ! empty($a['options']['editor_class']) |
|
| 38 | 38 | ? $a['options']['editor_class'] . ' cmb2-count-chars' |
| 39 | 39 | : 'cmb2-count-chars'; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - return $this->rendered( $this->get_wp_editor( $a ) . $a['desc'] ); |
|
| 42 | + return $this->rendered($this->get_wp_editor($a) . $a['desc']); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | // Character counter not currently working for grouped WYSIWYG |
| 46 | 46 | $this->field->args['char_counter'] = false; |
| 47 | 47 | |
| 48 | 48 | // wysiwyg fields in a group need some special handling. |
| 49 | - $field->add_js_dependencies( 'wp-util', 'cmb2-wysiwyg' ); |
|
| 49 | + $field->add_js_dependencies('wp-util', 'cmb2-wysiwyg'); |
|
| 50 | 50 | |
| 51 | 51 | // Hook in our template-output to the footer. |
| 52 | - add_action( is_admin() ? 'admin_footer' : 'wp_footer', array( $this, 'add_wysiwyg_template_for_group' ) ); |
|
| 52 | + add_action(is_admin() ? 'admin_footer' : 'wp_footer', array($this, 'add_wysiwyg_template_for_group')); |
|
| 53 | 53 | |
| 54 | 54 | return $this->rendered( |
| 55 | - sprintf( '<div class="cmb2-wysiwyg-wrap">%s', parent::render( array( |
|
| 55 | + sprintf('<div class="cmb2-wysiwyg-wrap">%s', parent::render(array( |
|
| 56 | 56 | 'class' => 'cmb2_textarea cmb2-wysiwyg-placeholder', |
| 57 | 57 | 'data-groupid' => $field->group->id(), |
| 58 | 58 | 'data-iterator' => $field->group->index, |
| 59 | - 'data-fieldid' => $field->id( true ), |
|
| 60 | - 'desc' => '</div>' . $this->_desc( true ), |
|
| 61 | - ) ) ) |
|
| 59 | + 'data-fieldid' => $field->id(true), |
|
| 60 | + 'desc' => '</div>' . $this->_desc(true), |
|
| 61 | + ))) |
|
| 62 | 62 | ); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - protected function get_wp_editor( $args ) { |
|
| 65 | + protected function get_wp_editor($args) { |
|
| 66 | 66 | ob_start(); |
| 67 | - wp_editor( $args['value'], $args['id'], $args['options'] ); |
|
| 67 | + wp_editor($args['value'], $args['id'], $args['options']); |
|
| 68 | 68 | return ob_get_clean(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function add_wysiwyg_template_for_group() { |
| 72 | 72 | $group_id = $this->field->group->id(); |
| 73 | - $field_id = $this->field->id( true ); |
|
| 73 | + $field_id = $this->field->id(true); |
|
| 74 | 74 | $hash = $this->field->hash_id(); |
| 75 | 75 | $options = $this->field->options(); |
| 76 | 76 | $options['textarea_name'] = 'cmb2_n_' . $group_id . $field_id; |
| 77 | 77 | |
| 78 | 78 | // Initate the editor with special id/value/name so we can retrieve the options in JS. |
| 79 | - $editor = $this->get_wp_editor( array( |
|
| 79 | + $editor = $this->get_wp_editor(array( |
|
| 80 | 80 | 'value' => 'cmb2_v_' . $group_id . $field_id, |
| 81 | 81 | 'id' => 'cmb2_i_' . $group_id . $field_id, |
| 82 | 82 | 'options' => $options, |
| 83 | - ) ); |
|
| 83 | + )); |
|
| 84 | 84 | |
| 85 | 85 | // Then replace the special id/value/name with underscore placeholders. |
| 86 | - $editor = str_replace( array( |
|
| 86 | + $editor = str_replace(array( |
|
| 87 | 87 | 'cmb2_n_' . $group_id . $field_id, |
| 88 | 88 | 'cmb2_v_' . $group_id . $field_id, |
| 89 | 89 | 'cmb2_i_' . $group_id . $field_id, |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | '{{ data.name }}', |
| 92 | 92 | '{{{ data.value }}}', |
| 93 | 93 | '{{ data.id }}', |
| 94 | - ), $editor ); |
|
| 94 | + ), $editor); |
|
| 95 | 95 | |
| 96 | 96 | // And put the editor instance in a JS template wrapper. |
| 97 | 97 | echo '<script type="text/template" id="tmpl-cmb2-wysiwyg-' . $group_id . '-' . $field_id . '">'; |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | ? $this->field->get_default() |
| 19 | 19 | : CMB2_Utils::timezone_string(); |
| 20 | 20 | |
| 21 | - $this->args = wp_parse_args( $this->args, array( |
|
| 21 | + $this->args = wp_parse_args($this->args, array( |
|
| 22 | 22 | 'class' => 'cmb2_select cmb2-select-timezone', |
| 23 | - 'options' => wp_timezone_choice( $this->field->escaped_value() ), |
|
| 23 | + 'options' => wp_timezone_choice($this->field->escaped_value()), |
|
| 24 | 24 | 'desc' => $this->_desc(), |
| 25 | - ) ); |
|
| 25 | + )); |
|
| 26 | 26 | |
| 27 | 27 | return parent::render(); |
| 28 | 28 | } |
@@ -19,23 +19,23 @@ |
||
| 19 | 19 | * @param array $args Override arguments |
| 20 | 20 | * @return string Form textarea element |
| 21 | 21 | */ |
| 22 | - public function render( $args = array() ) { |
|
| 23 | - $args = empty( $args ) ? $this->args : $args; |
|
| 24 | - $a = $this->parse_args( 'textarea', array( |
|
| 22 | + public function render($args = array()) { |
|
| 23 | + $args = empty($args) ? $this->args : $args; |
|
| 24 | + $a = $this->parse_args('textarea', array( |
|
| 25 | 25 | 'class' => 'cmb2_textarea', |
| 26 | 26 | 'name' => $this->_name(), |
| 27 | 27 | 'id' => $this->_id(), |
| 28 | 28 | 'cols' => 60, |
| 29 | 29 | 'rows' => 10, |
| 30 | - 'value' => $this->field->escaped_value( 'esc_textarea' ), |
|
| 31 | - 'desc' => $this->_desc( true ), |
|
| 32 | - ), $args ); |
|
| 30 | + 'value' => $this->field->escaped_value('esc_textarea'), |
|
| 31 | + 'desc' => $this->_desc(true), |
|
| 32 | + ), $args); |
|
| 33 | 33 | |
| 34 | 34 | // Add character counter? |
| 35 | - $a = $this->maybe_update_attributes_for_char_counter( $a ); |
|
| 35 | + $a = $this->maybe_update_attributes_for_char_counter($a); |
|
| 36 | 36 | |
| 37 | 37 | return $this->rendered( |
| 38 | - sprintf( '<textarea%s>%s</textarea>%s', $this->concat_attrs( $a, array( 'desc', 'value' ) ), $a['value'], $a['desc'] ) |
|
| 38 | + sprintf('<textarea%s>%s</textarea>%s', $this->concat_attrs($a, array('desc', 'value')), $a['value'], $a['desc']) |
|
| 39 | 39 | ); |
| 40 | 40 | } |
| 41 | 41 | } |