Skip to content

Commit 550f748

Browse files
authored
Merge pull request #669 from alleyinteractive/phpcs-updates
Updates per latest phpcs standards
2 parents 7df0c8f + 3f065ff commit 550f748

File tree

4 files changed

+15
-37
lines changed

4 files changed

+15
-37
lines changed

php/class-fieldmanager-colorpicker.php

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct( $label = '', $options = array() ) {
3939
fm_add_script( 'fm_colorpicker', 'js/fieldmanager-colorpicker.js', array( 'jquery', 'wp-color-picker' ), '1.0', true );
4040
fm_add_style( 'wp-color-picker' );
4141

42-
$this->sanitize = array( $this, 'sanitize_hex_color' );
42+
$this->sanitize = 'sanitize_hex_color';
4343

4444
parent::__construct( $label, $options );
4545

@@ -66,25 +66,4 @@ public function form_element( $value = '' ) {
6666
$this->get_element_attributes()
6767
);
6868
}
69-
70-
/**
71-
* Sanitizes a hex color.
72-
*
73-
* Returns either '', a 3 or 6 digit hex color (with #), or nothing.
74-
*
75-
* This was copied from core; sanitize_hex_color() is not available outside
76-
* of the customizer. {@see https://core.trac.wordpress.org/ticket/27583}.
77-
*
78-
* @param string $color The current color.
79-
* @return string
80-
*/
81-
function sanitize_hex_color( $color ) {
82-
$color = trim( $color );
83-
84-
if ( '' !== $color && preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
85-
return $color;
86-
}
87-
88-
return '';
89-
}
9069
}

php/context/class-fieldmanager-context-quickedit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function __construct( $title, $post_types, $column_display_callback, $col
104104
* @param array $columns The custom columns.
105105
* @return array $columns The custom columns.
106106
*/
107-
function add_custom_columns( $columns ) {
107+
public function add_custom_columns( $columns ) {
108108
$columns[ $this->fm->name ] = $this->column_title;
109109
return $columns;
110110
}

php/datasource/class-fieldmanager-datasource-post.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ function fm_url_to_post_id( $url ) {
404404
} else {
405405
// Chop off /path/to/blog.
406406
$home_path = wp_parse_url( home_url() );
407-
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
407+
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
408408
$url = str_replace( $home_path, '', $url );
409409
}
410410

@@ -421,7 +421,7 @@ function fm_url_to_post_id( $url ) {
421421
$request_match = $url . '/' . $request;
422422
}
423423

424-
if ( preg_match( "!^$match!" , $request_match, $matches ) ) {
424+
if ( preg_match( "!^$match!", $request_match, $matches ) ) {
425425
// Got a match.
426426
// Trim the query of everything up to the '?'.
427427
$query = preg_replace( '!^.+\?!', '', $query );

php/datasource/class-fieldmanager-datasource-term.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ private function get_term( $term_id ) {
427427
$term = $wpdb->get_row( $wpdb->prepare(
428428
"SELECT t.*, tt.*
429429
FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
430-
WHERE tt.term_taxonomy_id = %d LIMIT 1"
431-
, $term_id
430+
WHERE tt.term_taxonomy_id = %d LIMIT 1",
431+
$term_id
432432
) ); // WPCS: db call ok.
433433

434434
wp_cache_set( $cache_key, $term );
@@ -451,17 +451,16 @@ private function get_term( $term_id ) {
451451
* @return string HTML string.
452452
*/
453453
public function get_view_link( $value ) {
454-
if ( function_exists( 'wpcom_vip_get_term_link' ) ) {
455-
$term_link = wpcom_vip_get_term_link( $this->get_term( $value ) );
456-
} else {
457-
$term_link = get_term_link( $this->get_term( $value ) );
454+
$term_link = get_term_link( $this->get_term( $value ) );
455+
if ( is_string( $term_link ) ) {
456+
return sprintf(
457+
' <a target="_new" class="fm-autocomplete-view-link %s" href="%s">%s</a>',
458+
empty( $value ) ? 'fm-hidden' : '',
459+
empty( $value ) ? '#' : esc_url( $term_link ),
460+
esc_html__( 'View', 'fieldmanager' )
461+
);
458462
}
459-
return sprintf(
460-
' <a target="_new" class="fm-autocomplete-view-link %s" href="%s">%s</a>',
461-
empty( $value ) ? 'fm-hidden' : '',
462-
empty( $value ) ? '#' : esc_url( $term_link ),
463-
esc_html__( 'View', 'fieldmanager' )
464-
);
463+
return '';
465464
}
466465

467466
/**

0 commit comments

Comments
 (0)