@@ -26,13 +26,13 @@ discard block |
||
| 26 | 26 | * @return mixed Array of terms on success |
| 27 | 27 | */ |
| 28 | 28 | public function get_object_terms() { |
| 29 | - switch ( $this->field->object_type ) { |
|
| 29 | + switch ($this->field->object_type) { |
|
| 30 | 30 | case 'options-page': |
| 31 | 31 | case 'term': |
| 32 | 32 | return $this->options_terms(); |
| 33 | 33 | case 'post': |
| 34 | 34 | // WP caches internally so it's better to use |
| 35 | - return get_the_terms( $this->field->object_id, $this->field->args( 'taxonomy' ) ); |
|
| 35 | + return get_the_terms($this->field->object_id, $this->field->args('taxonomy')); |
|
| 36 | 36 | |
| 37 | 37 | default: |
| 38 | 38 | return $this->non_post_object_terms(); |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | * @return mixed Array of terms on success |
| 47 | 47 | */ |
| 48 | 48 | public function options_terms() { |
| 49 | - if ( empty( $this->field->value ) ) { |
|
| 49 | + if (empty($this->field->value)) { |
|
| 50 | 50 | return array(); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | $terms = (array) $this->field->value; |
| 54 | 54 | |
| 55 | - foreach ( $terms as $index => $term ) { |
|
| 56 | - $terms[ $index ] = get_term_by( 'slug', $term, $this->field->args( 'taxonomy' ) ); |
|
| 55 | + foreach ($terms as $index => $term) { |
|
| 56 | + $terms[$index] = get_term_by('slug', $term, $this->field->args('taxonomy')); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | return $terms; |
@@ -67,17 +67,17 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public function non_post_object_terms() { |
| 69 | 69 | $object_id = $this->field->object_id; |
| 70 | - $taxonomy = $this->field->args( 'taxonomy' ); |
|
| 70 | + $taxonomy = $this->field->args('taxonomy'); |
|
| 71 | 71 | |
| 72 | 72 | $cache_key = "cmb-cache-{$taxonomy}-{$object_id}"; |
| 73 | 73 | |
| 74 | 74 | // Check cache |
| 75 | - $cached = get_transient( $cache_key ); |
|
| 75 | + $cached = get_transient($cache_key); |
|
| 76 | 76 | |
| 77 | - if ( ! $cached ) { |
|
| 78 | - $cached = wp_get_object_terms( $object_id, $taxonomy ); |
|
| 77 | + if ( ! $cached) { |
|
| 78 | + $cached = wp_get_object_terms($object_id, $taxonomy); |
|
| 79 | 79 | // Do our own (minimal) caching. Long enough for a page-load. |
| 80 | - set_transient( $cache_key, $cached, 60 ); |
|
| 80 | + set_transient($cache_key, $cached, 60); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | return $cached; |
@@ -92,41 +92,41 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function get_terms() { |
| 94 | 94 | $args = array( |
| 95 | - 'taxonomy' => $this->field->args( 'taxonomy' ), |
|
| 95 | + 'taxonomy' => $this->field->args('taxonomy'), |
|
| 96 | 96 | 'hide_empty' => false, |
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | - if ( null !== $this->parent ) { |
|
| 99 | + if (null !== $this->parent) { |
|
| 100 | 100 | $args['parent'] = $this->parent; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - $args = wp_parse_args( $this->field->prop( 'query_args', array() ), $args ); |
|
| 103 | + $args = wp_parse_args($this->field->prop('query_args', array()), $args); |
|
| 104 | 104 | |
| 105 | - return CMB2_Utils::wp_at_least( '4.5.0' ) |
|
| 106 | - ? get_terms( $args ) |
|
| 107 | - : get_terms( $this->field->args( 'taxonomy' ), http_build_query( $args ) ); |
|
| 105 | + return CMB2_Utils::wp_at_least('4.5.0') |
|
| 106 | + ? get_terms($args) |
|
| 107 | + : get_terms($this->field->args('taxonomy'), http_build_query($args)); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - protected function no_terms_result( $error, $tag = 'li' ) { |
|
| 111 | - if ( is_wp_error( $error ) ) { |
|
| 110 | + protected function no_terms_result($error, $tag = 'li') { |
|
| 111 | + if (is_wp_error($error)) { |
|
| 112 | 112 | $message = $error->get_error_message(); |
| 113 | - $data = 'data-error="' . esc_attr( $error->get_error_code() ) . '"'; |
|
| 113 | + $data = 'data-error="' . esc_attr($error->get_error_code()) . '"'; |
|
| 114 | 114 | } else { |
| 115 | - $message = $this->_text( 'no_terms_text', esc_html__( 'No terms', 'cmb2' ) ); |
|
| 115 | + $message = $this->_text('no_terms_text', esc_html__('No terms', 'cmb2')); |
|
| 116 | 116 | $data = ''; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $this->field->args['select_all_button'] = false; |
| 120 | 120 | |
| 121 | - return sprintf( '<%3$s><label %1$s>%2$s</label></%3$s>', $data, esc_html( $message ), $tag ); |
|
| 121 | + return sprintf('<%3$s><label %1$s>%2$s</label></%3$s>', $data, esc_html($message), $tag); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function get_object_term_or_default() { |
| 125 | 125 | $saved_terms = $this->get_object_terms(); |
| 126 | 126 | |
| 127 | - return is_wp_error( $saved_terms ) || empty( $saved_terms ) |
|
| 127 | + return is_wp_error($saved_terms) || empty($saved_terms) |
|
| 128 | 128 | ? $this->field->get_default() |
| 129 | - : array_shift( $saved_terms )->slug; |
|
| 129 | + : array_shift($saved_terms)->slug; |
|
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | /** |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return string List of terms. |
| 141 | 141 | */ |
| 142 | - protected function loop_terms( $all_terms, $saved_terms ) { |
|
| 142 | + protected function loop_terms($all_terms, $saved_terms) { |
|
| 143 | 143 | return ''; |
| 144 | 144 | } |
| 145 | 145 | |
@@ -151,8 +151,8 @@ discard block |
||
| 151 | 151 | * |
| 152 | 152 | * @return string List of terms. |
| 153 | 153 | */ |
| 154 | - protected function build_children( $parent_term, $saved ) { |
|
| 155 | - if ( empty( $parent_term->term_id ) ) { |
|
| 154 | + protected function build_children($parent_term, $saved) { |
|
| 155 | + if (empty($parent_term->term_id)) { |
|
| 156 | 156 | return ''; |
| 157 | 157 | } |
| 158 | 158 | |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | $terms = $this->get_terms(); |
| 162 | 162 | $options = ''; |
| 163 | 163 | |
| 164 | - if ( ! empty( $terms ) && is_array( $terms ) ) { |
|
| 165 | - $options .= $this->child_option_output( $terms, $saved ); |
|
| 164 | + if ( ! empty($terms) && is_array($terms)) { |
|
| 165 | + $options .= $this->child_option_output($terms, $saved); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | return $options; |
@@ -178,9 +178,9 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return string Child option output. |
| 180 | 180 | */ |
| 181 | - public function child_option_output( $terms, $saved ) { |
|
| 181 | + public function child_option_output($terms, $saved) { |
|
| 182 | 182 | $output = '<li class="cmb2-indented-hierarchy"><ul>'; |
| 183 | - $output .= $this->loop_terms( $terms, $saved ); |
|
| 183 | + $output .= $this->loop_terms($terms, $saved); |
|
| 184 | 184 | $output .= '</ul></li>'; |
| 185 | 185 | |
| 186 | 186 | return $output; |
@@ -13,18 +13,18 @@ |
||
| 13 | 13 | class CMB2_Type_Select extends CMB2_Type_Multi_Base { |
| 14 | 14 | |
| 15 | 15 | public function render() { |
| 16 | - $a = $this->parse_args( 'select', array( |
|
| 16 | + $a = $this->parse_args('select', array( |
|
| 17 | 17 | 'class' => 'cmb2_select', |
| 18 | 18 | 'name' => $this->_name(), |
| 19 | 19 | 'id' => $this->_id(), |
| 20 | - 'desc' => $this->_desc( true ), |
|
| 20 | + 'desc' => $this->_desc(true), |
|
| 21 | 21 | 'options' => $this->concat_items(), |
| 22 | - ) ); |
|
| 22 | + )); |
|
| 23 | 23 | |
| 24 | - $attrs = $this->concat_attrs( $a, array( 'desc', 'options' ) ); |
|
| 24 | + $attrs = $this->concat_attrs($a, array('desc', 'options')); |
|
| 25 | 25 | |
| 26 | 26 | return $this->rendered( |
| 27 | - sprintf( '<select%s>%s</select>%s', $attrs, $a['options'], $a['desc'] ) |
|
| 27 | + sprintf('<select%s>%s</select>%s', $attrs, $a['options'], $a['desc']) |
|
| 28 | 28 | ); |
| 29 | 29 | } |
| 30 | 30 | } |
@@ -20,37 +20,37 @@ |
||
| 20 | 20 | * @param array $args Optional arguments to modify (else use $this->field->args['attributes']) |
| 21 | 21 | * @return array Array of field attributes |
| 22 | 22 | */ |
| 23 | - public function parse_picker_options( $arg = 'date', $args = array() ) { |
|
| 23 | + public function parse_picker_options($arg = 'date', $args = array()) { |
|
| 24 | 24 | $att = 'data-' . $arg . 'picker'; |
| 25 | - $update = empty( $args ); |
|
| 25 | + $update = empty($args); |
|
| 26 | 26 | $atts = array(); |
| 27 | - $format = $this->field->args( $arg . '_format' ); |
|
| 27 | + $format = $this->field->args($arg . '_format'); |
|
| 28 | 28 | |
| 29 | - if ( $js_format = CMB2_Utils::php_to_js_dateformat( $format ) ) { |
|
| 29 | + if ($js_format = CMB2_Utils::php_to_js_dateformat($format)) { |
|
| 30 | 30 | |
| 31 | - if ( $update ) { |
|
| 32 | - $atts = $this->field->args( 'attributes' ); |
|
| 31 | + if ($update) { |
|
| 32 | + $atts = $this->field->args('attributes'); |
|
| 33 | 33 | } else { |
| 34 | - $atts = isset( $args['attributes'] ) |
|
| 34 | + $atts = isset($args['attributes']) |
|
| 35 | 35 | ? $args['attributes'] |
| 36 | 36 | : $atts; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // Don't override user-provided datepicker values |
| 40 | - $data = isset( $atts[ $att ] ) |
|
| 41 | - ? json_decode( $atts[ $att ], true ) |
|
| 40 | + $data = isset($atts[$att]) |
|
| 41 | + ? json_decode($atts[$att], true) |
|
| 42 | 42 | : array(); |
| 43 | 43 | |
| 44 | - $data[ $arg . 'Format' ] = $js_format; |
|
| 45 | - $atts[ $att ] = function_exists( 'wp_json_encode' ) |
|
| 46 | - ? wp_json_encode( $data ) |
|
| 47 | - : json_encode( $data ); |
|
| 44 | + $data[$arg . 'Format'] = $js_format; |
|
| 45 | + $atts[$att] = function_exists('wp_json_encode') |
|
| 46 | + ? wp_json_encode($data) |
|
| 47 | + : json_encode($data); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - if ( $update ) { |
|
| 50 | + if ($update) { |
|
| 51 | 51 | $this->field->args['attributes'] = $atts; |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - return array_merge( $args, $atts ); |
|
| 54 | + return array_merge($args, $atts); |
|
| 55 | 55 | } |
| 56 | 56 | } |
@@ -28,8 +28,8 @@ discard block |
||
| 28 | 28 | * @param array $args Array of arguments for the type. |
| 29 | 29 | * @param string $value Value that the field type is currently set to, or default value. |
| 30 | 30 | */ |
| 31 | - public function __construct( CMB2_Types $types, $args = array(), $value = '' ) { |
|
| 32 | - parent::__construct( $types, $args ); |
|
| 31 | + public function __construct(CMB2_Types $types, $args = array(), $value = '') { |
|
| 32 | + parent::__construct($types, $args); |
|
| 33 | 33 | $this->value = $value ? $value : $this->value; |
| 34 | 34 | } |
| 35 | 35 | |
@@ -42,41 +42,41 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return CMB2_Type_Base|string |
| 44 | 44 | */ |
| 45 | - public function render( $args = array() ) { |
|
| 45 | + public function render($args = array()) { |
|
| 46 | 46 | $meta_value = $this->value ? $this->value : $this->field->escaped_value(); |
| 47 | 47 | |
| 48 | 48 | $hex_color = '(([a-fA-F0-9]){3}){1,2}$'; |
| 49 | - if ( preg_match( '/^' . $hex_color . '/i', $meta_value ) ) { |
|
| 49 | + if (preg_match('/^' . $hex_color . '/i', $meta_value)) { |
|
| 50 | 50 | // Value is just 123abc, so prepend #. |
| 51 | 51 | $meta_value = '#' . $meta_value; |
| 52 | 52 | } elseif ( |
| 53 | 53 | // If value doesn't match #123abc... |
| 54 | - ! preg_match( '/^#' . $hex_color . '/i', $meta_value ) |
|
| 54 | + ! preg_match('/^#' . $hex_color . '/i', $meta_value) |
|
| 55 | 55 | // And value doesn't match rgba()... |
| 56 | - && 0 !== strpos( trim( $meta_value ), 'rgba' ) |
|
| 56 | + && 0 !== strpos(trim($meta_value), 'rgba') |
|
| 57 | 57 | ) { |
| 58 | 58 | // Then sanitize to just #. |
| 59 | 59 | $meta_value = '#'; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - wp_enqueue_style( 'wp-color-picker' ); |
|
| 62 | + wp_enqueue_style('wp-color-picker'); |
|
| 63 | 63 | |
| 64 | - $args = wp_parse_args( $args, array( |
|
| 64 | + $args = wp_parse_args($args, array( |
|
| 65 | 65 | 'class' => 'cmb2-text-small', |
| 66 | - ) ); |
|
| 66 | + )); |
|
| 67 | 67 | |
| 68 | 68 | $args['class'] .= ' cmb2-colorpicker'; |
| 69 | 69 | $args['value'] = $meta_value; |
| 70 | - $args['js_dependencies'] = array( 'wp-color-picker' ); |
|
| 70 | + $args['js_dependencies'] = array('wp-color-picker'); |
|
| 71 | 71 | |
| 72 | - if ( $this->field->options( 'alpha' ) ) { |
|
| 72 | + if ($this->field->options('alpha')) { |
|
| 73 | 73 | $args['js_dependencies'][] = 'wp-color-picker-alpha'; |
| 74 | 74 | $args['data-alpha'] = 'true'; |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - $args = wp_parse_args( $this->args, $args ); |
|
| 77 | + $args = wp_parse_args($this->args, $args); |
|
| 78 | 78 | |
| 79 | - return parent::render( $args ); |
|
| 79 | + return parent::render($args); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | /** |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | * @since 2.2.6.2 |
| 86 | 86 | */ |
| 87 | 87 | public static function dequeue_rgba_colorpicker_script() { |
| 88 | - if ( wp_script_is( 'jw-cmb2-rgba-picker-js', 'enqueued' ) ) { |
|
| 89 | - wp_dequeue_script( 'jw-cmb2-rgba-picker-js' ); |
|
| 90 | - CMB2_JS::register_colorpicker_alpha( true ); |
|
| 88 | + if (wp_script_is('jw-cmb2-rgba-picker-js', 'enqueued')) { |
|
| 89 | + wp_dequeue_script('jw-cmb2-rgba-picker-js'); |
|
| 90 | + CMB2_JS::register_colorpicker_alpha(true); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -15,26 +15,26 @@ 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 | 'options' => $this->get_term_options(), |
| 20 | - ), 'taxonomy_radio' ) |
|
| 20 | + ), 'taxonomy_radio') |
|
| 21 | 21 | ); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | protected function get_term_options() { |
| 25 | 25 | $all_terms = $this->get_terms(); |
| 26 | 26 | |
| 27 | - if ( ! $all_terms || is_wp_error( $all_terms ) ) { |
|
| 28 | - return $this->no_terms_result( $all_terms ); |
|
| 27 | + if ( ! $all_terms || is_wp_error($all_terms)) { |
|
| 28 | + return $this->no_terms_result($all_terms); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | $saved_term = $this->get_object_term_or_default(); |
| 32 | - $option_none = $this->field->args( 'show_option_none' ); |
|
| 32 | + $option_none = $this->field->args('show_option_none'); |
|
| 33 | 33 | $options = ''; |
| 34 | 34 | |
| 35 | - if ( ! empty( $option_none ) ) { |
|
| 35 | + if ( ! empty($option_none)) { |
|
| 36 | 36 | |
| 37 | - $field_id = $this->_id( '', false ); |
|
| 37 | + $field_id = $this->_id('', false); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Default (option-none) taxonomy-radio value. |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * |
| 44 | 44 | * @param string $option_none_value Default (option-none) taxonomy-radio value. |
| 45 | 45 | */ |
| 46 | - $option_none_value = apply_filters( 'cmb2_taxonomy_radio_default_value', '' ); |
|
| 46 | + $option_none_value = apply_filters('cmb2_taxonomy_radio_default_value', ''); |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Default (option-none) taxonomy-radio value. |
@@ -54,39 +54,39 @@ discard block |
||
| 54 | 54 | * |
| 55 | 55 | * @param string $option_none_value Default (option-none) taxonomy-radio value. |
| 56 | 56 | */ |
| 57 | - $option_none_value = apply_filters( "cmb2_taxonomy_radio_{$field_id}_default_value", $option_none_value ); |
|
| 57 | + $option_none_value = apply_filters("cmb2_taxonomy_radio_{$field_id}_default_value", $option_none_value); |
|
| 58 | 58 | |
| 59 | - $options .= $this->list_term_input( (object) array( |
|
| 59 | + $options .= $this->list_term_input((object) array( |
|
| 60 | 60 | 'slug' => $option_none_value, |
| 61 | 61 | 'name' => $option_none, |
| 62 | - ), $saved_term ); |
|
| 62 | + ), $saved_term); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - $options .= $this->loop_terms( $all_terms, $saved_term ); |
|
| 65 | + $options .= $this->loop_terms($all_terms, $saved_term); |
|
| 66 | 66 | |
| 67 | 67 | return $options; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function loop_terms( $all_terms, $saved_term ) { |
|
| 70 | + protected function loop_terms($all_terms, $saved_term) { |
|
| 71 | 71 | $options = ''; |
| 72 | - foreach ( $all_terms as $term ) { |
|
| 73 | - $options .= $this->list_term_input( $term, $saved_term ); |
|
| 72 | + foreach ($all_terms as $term) { |
|
| 73 | + $options .= $this->list_term_input($term, $saved_term); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | return $options; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - protected function list_term_input( $term, $saved_term ) { |
|
| 79 | + protected function list_term_input($term, $saved_term) { |
|
| 80 | 80 | $args = array( |
| 81 | 81 | 'value' => $term->slug, |
| 82 | 82 | 'label' => $term->name, |
| 83 | 83 | ); |
| 84 | 84 | |
| 85 | - if ( $saved_term == $term->slug ) { |
|
| 85 | + if ($saved_term == $term->slug) { |
|
| 86 | 86 | $args['checked'] = 'checked'; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - return $this->list_input( $args, ++$this->counter ); |
|
| 89 | + return $this->list_input($args, ++$this->counter); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | } |
@@ -12,12 +12,12 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CMB2_Type_Text_Time extends CMB2_Type_Text_Date { |
| 14 | 14 | |
| 15 | - public function render( $args = array() ) { |
|
| 16 | - $this->args = $this->parse_picker_options( 'time', wp_parse_args( $this->args, array( |
|
| 15 | + public function render($args = array()) { |
|
| 16 | + $this->args = $this->parse_picker_options('time', wp_parse_args($this->args, array( |
|
| 17 | 17 | 'class' => 'cmb2-timepicker text-time', |
| 18 | - 'value' => $this->field->get_timestamp_format( 'time_format' ), |
|
| 19 | - 'js_dependencies' => array( 'jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-datetimepicker' ), |
|
| 20 | - ) ) ); |
|
| 18 | + 'value' => $this->field->get_timestamp_format('time_format'), |
|
| 19 | + 'js_dependencies' => array('jquery-ui-core', 'jquery-ui-datepicker', 'jquery-ui-datetimepicker'), |
|
| 20 | + ))); |
|
| 21 | 21 | |
| 22 | 22 | return parent::render(); |
| 23 | 23 | } |
@@ -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 | } |