diff --git a/php/class-fieldmanager-colorpicker.php b/php/class-fieldmanager-colorpicker.php
index 04907db2b2..a98758094d 100644
--- a/php/class-fieldmanager-colorpicker.php
+++ b/php/class-fieldmanager-colorpicker.php
@@ -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 );
@@ -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 '';
- }
}
diff --git a/php/context/class-fieldmanager-context-quickedit.php b/php/context/class-fieldmanager-context-quickedit.php
index c5feec75bd..80754d7f18 100644
--- a/php/context/class-fieldmanager-context-quickedit.php
+++ b/php/context/class-fieldmanager-context-quickedit.php
@@ -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;
}
diff --git a/php/datasource/class-fieldmanager-datasource-post.php b/php/datasource/class-fieldmanager-datasource-post.php
index 5a6b863a4e..cfb79e8efd 100644
--- a/php/datasource/class-fieldmanager-datasource-post.php
+++ b/php/datasource/class-fieldmanager-datasource-post.php
@@ -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 );
}
@@ -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 );
diff --git a/php/datasource/class-fieldmanager-datasource-term.php b/php/datasource/class-fieldmanager-datasource-term.php
index 52ae8d58ec..0ef5a4d379 100644
--- a/php/datasource/class-fieldmanager-datasource-term.php
+++ b/php/datasource/class-fieldmanager-datasource-term.php
@@ -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 );
@@ -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(
+ ' %s',
+ empty( $value ) ? 'fm-hidden' : '',
+ empty( $value ) ? '#' : esc_url( $term_link ),
+ esc_html__( 'View', 'fieldmanager' )
+ );
}
- return sprintf(
- ' %s',
- empty( $value ) ? 'fm-hidden' : '',
- empty( $value ) ? '#' : esc_url( $term_link ),
- esc_html__( 'View', 'fieldmanager' )
- );
+ return '';
}
/**