Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 1 addition & 22 deletions php/class-fieldmanager-colorpicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function __construct( $label = '', $options = array() ) {
fm_add_script( 'fm_colorpicker', 'js/fieldmanager-colorpicker.js', array( 'jquery', 'wp-color-picker' ), '1.0', true );
fm_add_style( 'wp-color-picker' );

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

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

Expand All @@ -66,25 +66,4 @@ public function form_element( $value = '' ) {
$this->get_element_attributes()
);
}

/**
* Sanitizes a hex color.
*
* Returns either '', a 3 or 6 digit hex color (with #), or nothing.
*
* This was copied from core; sanitize_hex_color() is not available outside
* of the customizer. {@see https://core.trac.wordpress.org/ticket/27583}.
*
* @param string $color The current color.
* @return string
*/
function sanitize_hex_color( $color ) {
$color = trim( $color );

if ( '' !== $color && preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) {
return $color;
}

return '';
}
}
2 changes: 1 addition & 1 deletion php/context/class-fieldmanager-context-quickedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function __construct( $title, $post_types, $column_display_callback, $col
* @param array $columns The custom columns.
* @return array $columns The custom columns.
*/
function add_custom_columns( $columns ) {
public function add_custom_columns( $columns ) {
$columns[ $this->fm->name ] = $this->column_title;
return $columns;
}
Expand Down
4 changes: 2 additions & 2 deletions php/datasource/class-fieldmanager-datasource-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ function fm_url_to_post_id( $url ) {
} else {
// Chop off /path/to/blog.
$home_path = wp_parse_url( home_url() );
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
$url = str_replace( $home_path, '', $url );
}

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

if ( preg_match( "!^$match!" , $request_match, $matches ) ) {
if ( preg_match( "!^$match!", $request_match, $matches ) ) {
// Got a match.
// Trim the query of everything up to the '?'.
$query = preg_replace( '!^.+\?!', '', $query );
Expand Down
23 changes: 11 additions & 12 deletions php/datasource/class-fieldmanager-datasource-term.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ private function get_term( $term_id ) {
$term = $wpdb->get_row( $wpdb->prepare(
"SELECT t.*, tt.*
FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
WHERE tt.term_taxonomy_id = %d LIMIT 1"
, $term_id
WHERE tt.term_taxonomy_id = %d LIMIT 1",
$term_id
) ); // WPCS: db call ok.

wp_cache_set( $cache_key, $term );
Expand All @@ -451,17 +451,16 @@ private function get_term( $term_id ) {
* @return string HTML string.
*/
public function get_view_link( $value ) {
if ( function_exists( 'wpcom_vip_get_term_link' ) ) {
$term_link = wpcom_vip_get_term_link( $this->get_term( $value ) );
} else {
$term_link = get_term_link( $this->get_term( $value ) );
$term_link = get_term_link( $this->get_term( $value ) );
if ( is_string( $term_link ) ) {
return sprintf(
' <a target="_new" class="fm-autocomplete-view-link %s" href="%s">%s</a>',
empty( $value ) ? 'fm-hidden' : '',
empty( $value ) ? '#' : esc_url( $term_link ),
esc_html__( 'View', 'fieldmanager' )
);
}
return sprintf(
' <a target="_new" class="fm-autocomplete-view-link %s" href="%s">%s</a>',
empty( $value ) ? 'fm-hidden' : '',
empty( $value ) ? '#' : esc_url( $term_link ),
esc_html__( 'View', 'fieldmanager' )
);
return '';
}

/**
Expand Down