Changeset 2293580 for codepress-admin-columns/trunk/classes/Helper/Html.php
- Timestamp:
- 04/28/2020 02:28:16 PM (5 years ago)
- File:
- 1 edited
Legend:
- Unmodified
- Added
- Removed
codepress-admin-columns/trunk/classes/Helper/Html.php
r2246221 r2293580 26 26 */ 27 27 public function get_attributes_as_string( array $attributes ) { 28 $output = array();28 $output = []; 29 29 30 30 foreach ( $attributes as $key => $value ) { … … 42 42 * @return string|false HTML Anchor element 43 43 */ 44 public function link( $url, $label = null, $attributes = array()) {44 public function link( $url, $label = null, $attributes = [] ) { 45 45 if ( false === $label ) { 46 46 return $label; … … 102 102 * @return string 103 103 */ 104 public function tooltip( $label, $tooltip, $attributes = array()) {104 public function tooltip( $label, $tooltip, $attributes = [] ) { 105 105 if ( ac_helper()->string->is_not_empty( $label ) && $tooltip ) { 106 106 $label = '<span ' . $this->get_tooltip_attr( $tooltip ) . $this->get_attributes( $attributes ) . '>' . $label . '</span>'; … … 139 139 * @return string 140 140 */ 141 public function get_ajax_toggle_box_link( $id, $label, $column_name ) {142 return ac_helper()->html->link( '#', $label . '<div class="spinner"></div>', array(141 public function get_ajax_toggle_box_link( $id, $label, $column_name, $label_close = null ) { 142 return ac_helper()->html->link( '#', $label . '<div class="spinner"></div>', [ 143 143 'class' => 'ac-toggle-box-link', 144 144 'data-column' => $column_name, 145 145 'data-item-id' => $id, 146 146 'data-ajax-populate' => 1, 147 ) ); 147 'data-label' => $label, 148 'data-label-close' => $label_close, 149 ] ); 148 150 } 149 151 … … 168 170 */ 169 171 private function get_attributes( $attributes ) { 170 $_attributes = array();172 $_attributes = []; 171 173 172 174 foreach ( $attributes as $attribute => $value ) { 173 if ( in_array( $attribute, array( 'title', 'id', 'class', 'style', 'target', 'rel', 'download' )) || 'data-' === substr( $attribute, 0, 5 ) ) {175 if ( in_array( $attribute, [ 'title', 'id', 'class', 'style', 'target', 'rel', 'download' ] ) || 'data-' === substr( $attribute, 0, 5 ) ) { 174 176 $_attributes[] = $this->get_attribute_as_string( $attribute, $value ); 175 177 } … … 187 189 * @return false|array [ internal | external ] 188 190 */ 189 public function get_internal_external_links( $string, $internal_domains = array()) {191 public function get_internal_external_links( $string, $internal_domains = [] ) { 190 192 if ( ! class_exists( 'DOMDocument' ) ) { 191 193 return false; … … 198 200 199 201 if ( ! $internal_domains ) { 200 $internal_domains = array( home_url() );201 } 202 203 $internal_links = array();204 $external_links = array();202 $internal_domains = [ home_url() ]; 203 } 204 205 $internal_links = []; 206 $external_links = []; 205 207 206 208 $dom = new DOMDocument(); … … 236 238 } 237 239 238 return array(240 return [ 239 241 $internal_links, $external_links, 240 );242 ]; 241 243 } 242 244 … … 286 288 287 289 public function remove_empty( $array ) { 288 return array_filter( $array, array( ac_helper()->string, 'is_not_empty' ));290 return array_filter( $array, [ ac_helper()->string, 'is_not_empty' ] ); 289 291 } 290 292 … … 315 317 */ 316 318 public function small_block( $items ) { 317 $blocks = array();319 $blocks = []; 318 320 319 321 foreach ( (array) $items as $item ) { … … 331 333 * @return string 332 334 */ 333 public function progress_bar( $args = array()) {334 $defaults = array(335 public function progress_bar( $args = [] ) { 336 $defaults = [ 335 337 'current' => 0, 336 338 'total' => 100, // -1 is infinitive … … 338 340 'label_right' => '', 339 341 'label_main' => '', 340 );342 ]; 341 343 342 344 $args = wp_parse_args( $args, $defaults ); … … 404 406 $first = sprintf( '<span class="ac-show-more__part -first">%s</span>', implode( $glue, $first_set ) ); 405 407 $more = $last_set ? sprintf( '<span class="ac-show-more__part -more">%s%s</span>', $glue, implode( $glue, $last_set ) ) : ''; 406 $content = sprintf( '<span class="ac-show-more__content">%s%s</span>', $first, $more );408 $content = sprintf( '<span class="ac-show-more__content">%s%s</span>', $first, $more ); 407 409 $toggler = $last_set ? sprintf( '<span class="ac-show-more__divider">|</span><a class="ac-show-more__toggle" data-show-more-toggle data-more="%1$s" data-less="%2$s">%1$s</a>', sprintf( __( '%s more', 'codepress-admin-columns' ), count( $last_set ) ), strtolower( __( 'Hide', 'codepress-admin-columns' ) ) ) : ''; 408 410 … … 433 435 */ 434 436 public function stars( $count, $max = 0 ) { 435 $stars = array(437 $stars = [ 436 438 'filled' => floor( $count ), 437 439 'half' => floor( round( ( $count * 2 ) ) - ( floor( $count ) * 2 ) ) ? 1 : 0, 438 440 'empty' => 0, 439 );441 ]; 440 442 441 443 $max = absint( $max ); … … 452 454 } 453 455 454 $icons = array();456 $icons = []; 455 457 456 458 foreach ( $stars as $type => $_count ) { 457 459 for ( $i = 1; $i <= $_count; $i++ ) { 458 $icons[] = ac_helper()->icon->dashicon( array( 'icon' => 'star-' . $type, 'class' => 'ac-value-star' ));460 $icons[] = ac_helper()->icon->dashicon( [ 'icon' => 'star-' . $type, 'class' => 'ac-value-star' ] ); 459 461 } 460 462 }
Note: See TracChangeset for help on using the changeset viewer.