@@ -12,19 +12,19 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CMB2_Type_Text_Date extends CMB2_Type_Picker_Base { |
| 14 | 14 | |
| 15 | - public function render( $args = array() ) { |
|
| 16 | - $args = $this->parse_args( 'text_date', array( |
|
| 15 | + public function render($args = array()) { |
|
| 16 | + $args = $this->parse_args('text_date', array( |
|
| 17 | 17 | 'class' => 'cmb2-text-small cmb2-datepicker', |
| 18 | 18 | 'value' => $this->field->get_timestamp_format(), |
| 19 | 19 | 'desc' => $this->_desc(), |
| 20 | - 'js_dependencies' => array( 'jquery-ui-core', 'jquery-ui-datepicker' ), |
|
| 21 | - ) ); |
|
| 20 | + 'js_dependencies' => array('jquery-ui-core', 'jquery-ui-datepicker'), |
|
| 21 | + )); |
|
| 22 | 22 | |
| 23 | - if ( false === strpos( $args['class'], 'timepicker' ) ) { |
|
| 24 | - $this->parse_picker_options( 'date' ); |
|
| 23 | + if (false === strpos($args['class'], 'timepicker')) { |
|
| 24 | + $this->parse_picker_options('date'); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - return parent::render( $args ); |
|
| 27 | + return parent::render($args); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | } |
@@ -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 | } |
@@ -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,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 | } |
@@ -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 | } |
@@ -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 | |
@@ -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 | } |
@@ -19,21 +19,21 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public $type = 'checkbox'; |
| 21 | 21 | |
| 22 | - public function render( $args = array() ) { |
|
| 23 | - $classes = false === $this->field->args( 'select_all_button' ) |
|
| 22 | + public function render($args = array()) { |
|
| 23 | + $classes = false === $this->field->args('select_all_button') |
|
| 24 | 24 | ? 'cmb2-checkbox-list no-select-all cmb2-list' |
| 25 | 25 | : 'cmb2-checkbox-list cmb2-list'; |
| 26 | 26 | |
| 27 | - $args = $this->parse_args( $this->type, array( |
|
| 27 | + $args = $this->parse_args($this->type, array( |
|
| 28 | 28 | 'class' => $classes, |
| 29 | - 'options' => $this->concat_items( array( |
|
| 29 | + 'options' => $this->concat_items(array( |
|
| 30 | 30 | 'name' => $this->_name() . '[]', |
| 31 | 31 | 'method' => 'list_input_checkbox', |
| 32 | - ) ), |
|
| 33 | - 'desc' => $this->_desc( true ), |
|
| 34 | - ) ); |
|
| 32 | + )), |
|
| 33 | + 'desc' => $this->_desc(true), |
|
| 34 | + )); |
|
| 35 | 35 | |
| 36 | - return $this->rendered( $this->ul( $args ) ); |
|
| 36 | + return $this->rendered($this->ul($args)); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | } |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * @param string $file File url |
| 20 | 20 | * @return bool Whether file has a valid image extension |
| 21 | 21 | */ |
| 22 | - public function is_valid_img_ext( $file, $blah = false ) { |
|
| 23 | - $file_ext = CMB2_Utils::get_file_ext( $file ); |
|
| 22 | + public function is_valid_img_ext($file, $blah = false) { |
|
| 23 | + $file_ext = CMB2_Utils::get_file_ext($file); |
|
| 24 | 24 | |
| 25 | - $valid_types = array( 'jpg', 'jpeg', 'png', 'gif', 'ico', 'icon' ); |
|
| 25 | + $valid_types = array('jpg', 'jpeg', 'png', 'gif', 'ico', 'icon'); |
|
| 26 | 26 | |
| 27 | 27 | /** |
| 28 | 28 | * Which image types are considered valid image file extensions. |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | * |
| 32 | 32 | * @param array $valid_types The valid image file extensions. |
| 33 | 33 | */ |
| 34 | - $is_valid_types = apply_filters( 'cmb2_valid_img_types', $valid_types ); |
|
| 35 | - $is_valid = $file_ext && in_array( $file_ext, (array) $is_valid_types ); |
|
| 34 | + $is_valid_types = apply_filters('cmb2_valid_img_types', $valid_types); |
|
| 35 | + $is_valid = $file_ext && in_array($file_ext, (array) $is_valid_types); |
|
| 36 | 36 | $field_id = $this->field->id(); |
| 37 | 37 | |
| 38 | 38 | /** |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | * @param string $file File url. |
| 47 | 47 | * @param string $file_ext File extension. |
| 48 | 48 | */ |
| 49 | - return (bool) apply_filters( "cmb2_{$field_id}_is_valid_img_ext", $is_valid, $file, $file_ext ); |
|
| 49 | + return (bool) apply_filters("cmb2_{$field_id}_is_valid_img_ext", $is_valid, $file, $file_ext); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -56,13 +56,13 @@ discard block |
||
| 56 | 56 | * @param array $args Array of arguments for output |
| 57 | 57 | * @return string Image wrap output |
| 58 | 58 | */ |
| 59 | - public function img_status_output( $args ) { |
|
| 60 | - return sprintf( '<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>', |
|
| 59 | + public function img_status_output($args) { |
|
| 60 | + return sprintf('<%1$s class="img-status cmb2-media-item">%2$s<p class="cmb2-remove-wrapper"><a href="#" class="cmb2-remove-file-button"%3$s>%4$s</a></p>%5$s</%1$s>', |
|
| 61 | 61 | $args['tag'], |
| 62 | 62 | $args['image'], |
| 63 | - isset( $args['cached_id'] ) ? ' rel="' . esc_attr( $args['cached_id'] ) . '"' : '', |
|
| 64 | - esc_html( $this->_text( 'remove_image_text', esc_html__( 'Remove Image', 'cmb2' ) ) ), |
|
| 65 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
| 63 | + isset($args['cached_id']) ? ' rel="' . esc_attr($args['cached_id']) . '"' : '', |
|
| 64 | + esc_html($this->_text('remove_image_text', esc_html__('Remove Image', 'cmb2'))), |
|
| 65 | + isset($args['id_input']) ? $args['id_input'] : '' |
|
| 66 | 66 | ); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -73,16 +73,16 @@ discard block |
||
| 73 | 73 | * @param array $args Array of arguments for output |
| 74 | 74 | * @return string File wrap output |
| 75 | 75 | */ |
| 76 | - public function file_status_output( $args ) { |
|
| 77 | - return sprintf( '<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span> (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>', |
|
| 76 | + public function file_status_output($args) { |
|
| 77 | + return sprintf('<%1$s class="file-status cmb2-media-item"><span>%2$s <strong>%3$s</strong></span> (<a href="%4$s" target="_blank" rel="external">%5$s</a> / <a href="#" class="cmb2-remove-file-button"%6$s>%7$s</a>)%8$s</%1$s>', |
|
| 78 | 78 | $args['tag'], |
| 79 | - esc_html( $this->_text( 'file_text', esc_html__( 'File:', 'cmb2' ) ) ), |
|
| 80 | - esc_html( CMB2_Utils::get_file_name_from_path( $args['value'] ) ), |
|
| 81 | - esc_url( $args['value'] ), |
|
| 82 | - esc_html( $this->_text( 'file_download_text', esc_html__( 'Download', 'cmb2' ) ) ), |
|
| 83 | - isset( $args['cached_id'] ) ? ' rel="' . esc_attr( $args['cached_id'] ) . '"' : '', |
|
| 84 | - esc_html( $this->_text( 'remove_text', esc_html__( 'Remove', 'cmb2' ) ) ), |
|
| 85 | - isset( $args['id_input'] ) ? $args['id_input'] : '' |
|
| 79 | + esc_html($this->_text('file_text', esc_html__('File:', 'cmb2'))), |
|
| 80 | + esc_html(CMB2_Utils::get_file_name_from_path($args['value'])), |
|
| 81 | + esc_url($args['value']), |
|
| 82 | + esc_html($this->_text('file_download_text', esc_html__('Download', 'cmb2'))), |
|
| 83 | + isset($args['cached_id']) ? ' rel="' . esc_attr($args['cached_id']) . '"' : '', |
|
| 84 | + esc_html($this->_text('remove_text', esc_html__('Remove', 'cmb2'))), |
|
| 85 | + isset($args['id_input']) ? $args['id_input'] : '' |
|
| 86 | 86 | ); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -138,16 +138,16 @@ discard block |
||
| 138 | 138 | * 'name' => (string) e.g. 'thumbnail' |
| 139 | 139 | * ) |
| 140 | 140 | */ |
| 141 | - static function get_image_size_data( $img_size = '', $fallback = 'thumbnail' ) { |
|
| 141 | + static function get_image_size_data($img_size = '', $fallback = 'thumbnail') { |
|
| 142 | 142 | $data = array(); |
| 143 | 143 | |
| 144 | - if ( is_array( $img_size ) ) { |
|
| 145 | - $data['width'] = intval( $img_size[0] ); |
|
| 146 | - $data['height'] = intval( $img_size[1] ); |
|
| 144 | + if (is_array($img_size)) { |
|
| 145 | + $data['width'] = intval($img_size[0]); |
|
| 146 | + $data['height'] = intval($img_size[1]); |
|
| 147 | 147 | $data['name'] = ''; |
| 148 | 148 | |
| 149 | 149 | // Try and get the closest named size from our array of dimensions |
| 150 | - if ( $named_size = CMB2_Utils::get_named_size( $img_size ) ) { |
|
| 150 | + if ($named_size = CMB2_Utils::get_named_size($img_size)) { |
|
| 151 | 151 | $data['name'] = $named_size; |
| 152 | 152 | } |
| 153 | 153 | } else { |
@@ -155,18 +155,18 @@ discard block |
||
| 155 | 155 | $image_sizes = CMB2_Utils::get_available_image_sizes(); |
| 156 | 156 | |
| 157 | 157 | // The 'thumb' alias, which works elsewhere, doesn't work in the wp.media uploader |
| 158 | - if ( 'thumb' == $img_size ) { |
|
| 158 | + if ('thumb' == $img_size) { |
|
| 159 | 159 | $img_size = 'thumbnail'; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | // Named size doesn't exist, use $fallback |
| 163 | - if ( ! array_key_exists( $img_size, $image_sizes ) ) { |
|
| 163 | + if ( ! array_key_exists($img_size, $image_sizes)) { |
|
| 164 | 164 | $img_size = $fallback; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | // Get image dimensions from named sizes |
| 168 | - $data['width'] = intval( $image_sizes[ $img_size ]['width'] ); |
|
| 169 | - $data['height'] = intval( $image_sizes[ $img_size ]['height'] ); |
|
| 168 | + $data['width'] = intval($image_sizes[$img_size]['width']); |
|
| 169 | + $data['height'] = intval($image_sizes[$img_size]['height']); |
|
| 170 | 170 | $data['name'] = $img_size; |
| 171 | 171 | } |
| 172 | 172 | |
@@ -185,17 +185,17 @@ discard block |
||
| 185 | 185 | * @param array $meta Array of attachment meta data ( from wp_get_attachment_metadata() ) |
| 186 | 186 | * @return array filtered $response array |
| 187 | 187 | */ |
| 188 | - public static function prepare_image_sizes_for_js( $response, $attachment, $meta ) { |
|
| 189 | - foreach ( CMB2_Utils::get_available_image_sizes() as $size => $info ) { |
|
| 188 | + public static function prepare_image_sizes_for_js($response, $attachment, $meta) { |
|
| 189 | + foreach (CMB2_Utils::get_available_image_sizes() as $size => $info) { |
|
| 190 | 190 | |
| 191 | 191 | // registered image size exists for this attachment |
| 192 | - if ( isset( $meta['sizes'][ $size ] ) ) { |
|
| 192 | + if (isset($meta['sizes'][$size])) { |
|
| 193 | 193 | |
| 194 | - $attachment_url = wp_get_attachment_url( $attachment->ID ); |
|
| 195 | - $base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url ); |
|
| 196 | - $size_meta = $meta['sizes'][ $size ]; |
|
| 194 | + $attachment_url = wp_get_attachment_url($attachment->ID); |
|
| 195 | + $base_url = str_replace(wp_basename($attachment_url), '', $attachment_url); |
|
| 196 | + $size_meta = $meta['sizes'][$size]; |
|
| 197 | 197 | |
| 198 | - $response['sizes'][ $size ] = array( |
|
| 198 | + $response['sizes'][$size] = array( |
|
| 199 | 199 | 'url' => $base_url . $size_meta['file'], |
| 200 | 200 | 'height' => $size_meta['height'], |
| 201 | 201 | 'width' => $size_meta['width'], |