-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sync: check schema is available or not #8143
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,15 +21,17 @@ public static function get_taxonomies() { | |
$sanitized_taxonomy = self::sanitize_taxonomy( $taxonomy ); | ||
if ( ! empty( $sanitized_taxonomy ) ) { | ||
$wp_taxonomies_without_callbacks[ $taxonomy_name ] = $sanitized_taxonomy; | ||
} else { | ||
} else { | ||
error_log( 'Jetpack: Encountered a recusive taxonomy:' . $taxonomy_name ); | ||
} | ||
} | ||
|
||
return $wp_taxonomies_without_callbacks; | ||
} | ||
|
||
public static function get_shortcodes() { | ||
global $shortcode_tags; | ||
|
||
return array_keys( $shortcode_tags ); | ||
} | ||
|
||
|
@@ -47,19 +49,23 @@ public static function sanitize_taxonomy( $taxonomy ) { | |
} | ||
// Remove any meta_box_cb if they are not the default wp ones. | ||
if ( isset( $cloned_taxonomy->meta_box_cb ) && | ||
! in_array( $cloned_taxonomy->meta_box_cb, array( 'post_tags_meta_box', 'post_categories_meta_box' ) ) ) { | ||
! in_array( $cloned_taxonomy->meta_box_cb, array( 'post_tags_meta_box', 'post_categories_meta_box' ) ) | ||
) { | ||
$cloned_taxonomy->meta_box_cb = null; | ||
} | ||
// Remove update call back | ||
if ( isset( $cloned_taxonomy->update_count_callback ) && | ||
! is_null( $cloned_taxonomy->update_count_callback ) ) { | ||
! is_null( $cloned_taxonomy->update_count_callback ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
) { | ||
$cloned_taxonomy->update_count_callback = null; | ||
} | ||
// Remove rest_controller_class if it something other then the default. | ||
if ( isset( $cloned_taxonomy->rest_controller_class ) && | ||
'WP_REST_Terms_Controller' !== $cloned_taxonomy->rest_controller_class ) { | ||
if ( isset( $cloned_taxonomy->rest_controller_class ) && | ||
'WP_REST_Terms_Controller' !== $cloned_taxonomy->rest_controller_class | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
) { | ||
$cloned_taxonomy->rest_controller_class = null; | ||
} | ||
|
||
return $cloned_taxonomy; | ||
} | ||
|
||
|
@@ -91,6 +97,7 @@ public static function get_hosting_provider() { | |
if ( defined( 'VIP_GO_ENV' ) && false !== VIP_GO_ENV ) { | ||
return 'vip-go'; | ||
} | ||
|
||
return 'unknown'; | ||
} | ||
|
||
|
@@ -130,7 +137,7 @@ public static function file_system_write_access() { | |
require_once( ABSPATH . 'wp-admin/includes/template.php' ); | ||
|
||
$filesystem_method = get_filesystem_method(); | ||
if ( 'direct' === $filesystem_method ) { | ||
if ( 'direct' === $filesystem_method ) { | ||
return true; | ||
} | ||
|
||
|
@@ -160,8 +167,8 @@ public static function get_raw_or_filtered_url( $url_type ) { | |
Jetpack_Constants::get_constant( 'JETPACK_SYNC_USE_RAW_URL' ) | ||
) { | ||
$scheme = is_ssl() ? 'https' : 'http'; | ||
$url = self::get_raw_url( $url_type ); | ||
$url = set_url_scheme( $url, $scheme ); | ||
$url = self::get_raw_url( $url_type ); | ||
$url = set_url_scheme( $url, $scheme ); | ||
} else { | ||
$url = self::normalize_www_in_url( $url_type, $url_function ); | ||
} | ||
|
@@ -203,26 +210,26 @@ public static function get_protocol_normalized_url( $callable, $new_value ) { | |
$option_key = self::HTTPS_CHECK_OPTION_PREFIX . $callable; | ||
|
||
$parsed_url = wp_parse_url( $new_value ); | ||
if ( ! $parsed_url ) { | ||
if ( empty ( $parsed_url['scheme'] ) ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't just |
||
return $new_value; | ||
} | ||
|
||
$scheme = $parsed_url['scheme']; | ||
$scheme_history = get_option( $option_key, array() ); | ||
$scheme = $parsed_url['scheme']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is where we need to see if the key exists, and I'd prefer to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zinigor |
||
$scheme_history = get_option( $option_key, array() ); | ||
$scheme_history[] = $scheme; | ||
|
||
// Limit length to self::HTTPS_CHECK_HISTORY | ||
$scheme_history = array_slice( $scheme_history, ( self::HTTPS_CHECK_HISTORY * -1 ) ); | ||
$scheme_history = array_slice( $scheme_history, ( self::HTTPS_CHECK_HISTORY * - 1 ) ); | ||
|
||
update_option( $option_key, $scheme_history ); | ||
|
||
$forced_scheme = in_array( 'https', $scheme_history ) ? 'https' : 'http'; | ||
$forced_scheme = in_array( 'https', $scheme_history ) ? 'https' : 'http'; | ||
|
||
return set_url_scheme( $new_value, $forced_scheme ); | ||
} | ||
|
||
public static function get_raw_url( $option_name ) { | ||
$value = null; | ||
$value = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid unnecessary changes like this. It's OK to remove spaces that shouldn't be there in related code, but these edits make the PR harder to review. Thanks! |
||
$constant = ( 'home' == $option_name ) | ||
? 'WP_HOME' | ||
: 'WP_SITEURL'; | ||
|
@@ -248,13 +255,13 @@ public static function normalize_www_in_url( $option, $url_function ) { | |
return $url; | ||
} | ||
|
||
if ( $url[ 'host' ] === "www.{$option_url[ 'host' ]}" ) { | ||
if ( $url['host'] === "www.{$option_url[ 'host' ]}" ) { | ||
// remove www if not present in option URL | ||
$url[ 'host' ] = $option_url[ 'host' ]; | ||
$url['host'] = $option_url['host']; | ||
} | ||
if ( $option_url[ 'host' ] === "www.{$url[ 'host' ]}" ) { | ||
if ( $option_url['host'] === "www.{$url[ 'host' ]}" ) { | ||
// add www if present in option URL | ||
$url[ 'host' ] = $option_url[ 'host' ]; | ||
$url['host'] = $option_url['host']; | ||
} | ||
|
||
$normalized_url = "{$url['scheme']}://{$url['host']}"; | ||
|
@@ -293,13 +300,16 @@ public static function get_plugins_action_links( $plugin_file_singular = null ) | |
if ( is_null( $plugin_file_singular ) ) { | ||
return $plugins_action_links; | ||
} | ||
|
||
return ( isset( $plugins_action_links[ $plugin_file_singular ] ) ? $plugins_action_links[ $plugin_file_singular ] : null ); | ||
} | ||
|
||
return array(); | ||
} | ||
|
||
public static function wp_version() { | ||
global $wp_version; | ||
|
||
return $wp_version; | ||
} | ||
|
||
|
@@ -313,6 +323,7 @@ public static function site_icon_url() { | |
|
||
public static function roles() { | ||
$wp_roles = wp_roles(); | ||
|
||
return $wp_roles->roles; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you meant to clarify the
if
statement here, it might be best to move the first check on its own line as well: