@@ -32,20 +32,20 @@ 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 | - ), 'taxonomy_select_hierarchical' ) |
|
| 37 | + ), 'taxonomy_select_hierarchical') |
|
| 38 | 38 | ); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function select_option( $args = array() ) { |
|
| 42 | - if ( $this->level > 0 ) { |
|
| 43 | - $args['label'] = str_repeat( ' ', $this->level ) . $args['label']; |
|
| 41 | + public function select_option($args = array()) { |
|
| 42 | + if ($this->level > 0) { |
|
| 43 | + $args['label'] = str_repeat(' ', $this->level) . $args['label']; |
|
| 44 | 44 | } |
| 45 | - $option = parent::select_option( $args ); |
|
| 46 | - $children = $this->build_children( $this->current_term, $this->saved_term ); |
|
| 45 | + $option = parent::select_option($args); |
|
| 46 | + $children = $this->build_children($this->current_term, $this->saved_term); |
|
| 47 | 47 | |
| 48 | - if ( ! empty( $children ) ) { |
|
| 48 | + if ( ! empty($children)) { |
|
| 49 | 49 | $option .= $children; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return string Child option output. |
| 64 | 64 | */ |
| 65 | - public function child_option_output( $terms, $saved ) { |
|
| 65 | + public function child_option_output($terms, $saved) { |
|
| 66 | 66 | $this->level++; |
| 67 | - $output = $this->loop_terms( $terms, $saved ); |
|
| 67 | + $output = $this->loop_terms($terms, $saved); |
|
| 68 | 68 | $this->level--; |
| 69 | 69 | |
| 70 | 70 | return $output; |
@@ -15,33 +15,33 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function render() { |
| 17 | 17 | return $this->rendered( |
| 18 | - $this->types->radio( array( |
|
| 18 | + $this->types->radio(array( |
|
| 19 | 19 | 'class' => $this->get_wrapper_classes(), |
| 20 | 20 | 'options' => $this->get_term_options(), |
| 21 | - ), 'taxonomy_multicheck' ) |
|
| 21 | + ), 'taxonomy_multicheck') |
|
| 22 | 22 | ); |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | protected function get_term_options() { |
| 26 | 26 | $all_terms = $this->get_terms(); |
| 27 | 27 | |
| 28 | - if ( ! $all_terms || is_wp_error( $all_terms ) ) { |
|
| 29 | - return $this->no_terms_result( $all_terms ); |
|
| 28 | + if ( ! $all_terms || is_wp_error($all_terms)) { |
|
| 29 | + return $this->no_terms_result($all_terms); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - return $this->loop_terms( $all_terms, $this->get_object_term_or_default() ); |
|
| 32 | + return $this->loop_terms($all_terms, $this->get_object_term_or_default()); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - protected function loop_terms( $all_terms, $saved_terms ) { |
|
| 35 | + protected function loop_terms($all_terms, $saved_terms) { |
|
| 36 | 36 | $options = ''; |
| 37 | - foreach ( $all_terms as $term ) { |
|
| 38 | - $options .= $this->list_term_input( $term, $saved_terms ); |
|
| 37 | + foreach ($all_terms as $term) { |
|
| 38 | + $options .= $this->list_term_input($term, $saved_terms); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | return $options; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - protected function list_term_input( $term, $saved_terms ) { |
|
| 44 | + protected function list_term_input($term, $saved_terms) { |
|
| 45 | 45 | $args = array( |
| 46 | 46 | 'value' => $term->slug, |
| 47 | 47 | 'label' => $term->name, |
@@ -49,24 +49,24 @@ discard block |
||
| 49 | 49 | 'name' => $this->_name() . '[]', |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - if ( is_array( $saved_terms ) && in_array( $term->slug, $saved_terms ) ) { |
|
| 52 | + if (is_array($saved_terms) && in_array($term->slug, $saved_terms)) { |
|
| 53 | 53 | $args['checked'] = 'checked'; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - return $this->list_input( $args, ++$this->counter ); |
|
| 56 | + return $this->list_input($args, ++$this->counter); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | public function get_object_term_or_default() { |
| 60 | 60 | $saved_terms = $this->get_object_terms(); |
| 61 | 61 | |
| 62 | - return is_wp_error( $saved_terms ) || empty( $saved_terms ) |
|
| 62 | + return is_wp_error($saved_terms) || empty($saved_terms) |
|
| 63 | 63 | ? $this->field->get_default() |
| 64 | - : wp_list_pluck( $saved_terms, 'slug' ); |
|
| 64 | + : wp_list_pluck($saved_terms, 'slug'); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function get_wrapper_classes() { |
| 68 | 68 | $classes = 'cmb2-checkbox-list cmb2-list'; |
| 69 | - if ( false === $this->field->args( 'select_all_button' ) ) { |
|
| 69 | + if (false === $this->field->args('select_all_button')) { |
|
| 70 | 70 | $classes .= ' no-select-all'; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -27,8 +27,8 @@ discard block |
||
| 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 | |
@@ -39,23 +39,23 @@ discard block |
||
| 39 | 39 | * @param array $args Override arguments |
| 40 | 40 | * @return string Form input element |
| 41 | 41 | */ |
| 42 | - public function render( $args = array() ) { |
|
| 43 | - $args = empty( $args ) ? $this->args : $args; |
|
| 44 | - $a = $this->parse_args( $this->type, array( |
|
| 42 | + public function render($args = array()) { |
|
| 43 | + $args = empty($args) ? $this->args : $args; |
|
| 44 | + $a = $this->parse_args($this->type, array( |
|
| 45 | 45 | 'type' => 'text', |
| 46 | 46 | 'class' => 'regular-text', |
| 47 | 47 | 'name' => $this->_name(), |
| 48 | 48 | 'id' => $this->_id(), |
| 49 | 49 | 'value' => $this->field->escaped_value(), |
| 50 | - 'desc' => $this->_desc( true ), |
|
| 50 | + 'desc' => $this->_desc(true), |
|
| 51 | 51 | 'js_dependencies' => array(), |
| 52 | - ), $args ); |
|
| 52 | + ), $args); |
|
| 53 | 53 | |
| 54 | 54 | // Add character counter? |
| 55 | - $a = $this->maybe_update_attributes_for_char_counter( $a ); |
|
| 55 | + $a = $this->maybe_update_attributes_for_char_counter($a); |
|
| 56 | 56 | |
| 57 | 57 | return $this->rendered( |
| 58 | - sprintf( '<input%s/>%s', $this->concat_attrs( $a, array( 'desc' ) ), $a['desc'] ) |
|
| 58 | + sprintf('<input%s/>%s', $this->concat_attrs($a, array('desc')), $a['desc']) |
|
| 59 | 59 | ); |
| 60 | 60 | } |
| 61 | 61 | } |
@@ -12,43 +12,43 @@ discard block |
||
| 12 | 12 | */ |
| 13 | 13 | class CMB2_Type_File_List extends CMB2_Type_File_Base { |
| 14 | 14 | |
| 15 | - public function render( $args = array() ) { |
|
| 15 | + public function render($args = array()) { |
|
| 16 | 16 | $field = $this->field; |
| 17 | 17 | $meta_value = $field->escaped_value(); |
| 18 | 18 | $name = $this->_name(); |
| 19 | - $img_size = $field->args( 'preview_size' ); |
|
| 20 | - $query_args = $field->args( 'query_args' ); |
|
| 19 | + $img_size = $field->args('preview_size'); |
|
| 20 | + $query_args = $field->args('query_args'); |
|
| 21 | 21 | $output = ''; |
| 22 | 22 | |
| 23 | 23 | // get an array of image size meta data, fallback to 'thumbnail' |
| 24 | - $img_size_data = parent::get_image_size_data( $img_size, 'thumbnail' ); |
|
| 24 | + $img_size_data = parent::get_image_size_data($img_size, 'thumbnail'); |
|
| 25 | 25 | |
| 26 | - $output .= parent::render( array( |
|
| 26 | + $output .= parent::render(array( |
|
| 27 | 27 | 'type' => 'hidden', |
| 28 | 28 | 'class' => 'cmb2-upload-file cmb2-upload-list', |
| 29 | 29 | 'size' => 45, |
| 30 | 30 | 'desc' => '', |
| 31 | 31 | 'value' => '', |
| 32 | - 'data-previewsize' => sprintf( '[%d,%d]', $img_size_data['width'], $img_size_data['height'] ), |
|
| 32 | + 'data-previewsize' => sprintf('[%d,%d]', $img_size_data['width'], $img_size_data['height']), |
|
| 33 | 33 | 'data-sizename' => $img_size_data['name'], |
| 34 | - 'data-queryargs' => ! empty( $query_args ) ? json_encode( $query_args ) : '', |
|
| 34 | + 'data-queryargs' => ! empty($query_args) ? json_encode($query_args) : '', |
|
| 35 | 35 | 'js_dependencies' => 'media-editor', |
| 36 | - ) ); |
|
| 36 | + )); |
|
| 37 | 37 | |
| 38 | - $output .= parent::render( array( |
|
| 38 | + $output .= parent::render(array( |
|
| 39 | 39 | 'type' => 'button', |
| 40 | 40 | 'class' => 'cmb2-upload-button button-secondary cmb2-upload-list', |
| 41 | - 'value' => esc_attr( $this->_text( 'add_upload_files_text', esc_html__( 'Add or Upload Files', 'cmb2' ) ) ), |
|
| 41 | + 'value' => esc_attr($this->_text('add_upload_files_text', esc_html__('Add or Upload Files', 'cmb2'))), |
|
| 42 | 42 | 'name' => '', |
| 43 | 43 | 'id' => '', |
| 44 | - ) ); |
|
| 44 | + )); |
|
| 45 | 45 | |
| 46 | - $output .= '<ul id="' . $this->_id( '-status', false ) . '" class="cmb2-media-status cmb-attach-list">'; |
|
| 46 | + $output .= '<ul id="' . $this->_id('-status', false) . '" class="cmb2-media-status cmb-attach-list">'; |
|
| 47 | 47 | |
| 48 | - if ( $meta_value && is_array( $meta_value ) ) { |
|
| 48 | + if ($meta_value && is_array($meta_value)) { |
|
| 49 | 49 | |
| 50 | - foreach ( $meta_value as $id => $fullurl ) { |
|
| 51 | - $id_input = parent::render( array( |
|
| 50 | + foreach ($meta_value as $id => $fullurl) { |
|
| 51 | + $id_input = parent::render(array( |
|
| 52 | 52 | 'type' => 'hidden', |
| 53 | 53 | 'value' => $fullurl, |
| 54 | 54 | 'name' => $name . '[' . $id . ']', |
@@ -56,23 +56,23 @@ discard block |
||
| 56 | 56 | 'data-id' => $id, |
| 57 | 57 | 'desc' => '', |
| 58 | 58 | 'class' => false, |
| 59 | - ) ); |
|
| 59 | + )); |
|
| 60 | 60 | |
| 61 | - if ( $this->is_valid_img_ext( $fullurl ) ) { |
|
| 61 | + if ($this->is_valid_img_ext($fullurl)) { |
|
| 62 | 62 | |
| 63 | - $output .= $this->img_status_output( array( |
|
| 64 | - 'image' => wp_get_attachment_image( $id, $img_size ), |
|
| 63 | + $output .= $this->img_status_output(array( |
|
| 64 | + 'image' => wp_get_attachment_image($id, $img_size), |
|
| 65 | 65 | 'tag' => 'li', |
| 66 | 66 | 'id_input' => $id_input, |
| 67 | - ) ); |
|
| 67 | + )); |
|
| 68 | 68 | |
| 69 | 69 | } else { |
| 70 | 70 | |
| 71 | - $output .= $this->file_status_output( array( |
|
| 71 | + $output .= $this->file_status_output(array( |
|
| 72 | 72 | 'value' => $fullurl, |
| 73 | 73 | 'tag' => 'li', |
| 74 | 74 | 'id_input' => $id_input, |
| 75 | - ) ); |
|
| 75 | + )); |
|
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | $output .= '</ul>'; |
| 82 | 82 | |
| 83 | - return $this->rendered( $output ); |
|
| 83 | + return $this->rendered($output); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
@@ -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 | } |