diff options
Diffstat (limited to 'plugins/jetpack/sync/class.jetpack-sync-functions.php')
-rw-r--r-- | plugins/jetpack/sync/class.jetpack-sync-functions.php | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/plugins/jetpack/sync/class.jetpack-sync-functions.php b/plugins/jetpack/sync/class.jetpack-sync-functions.php index 1f3bddd7..905d187e 100644 --- a/plugins/jetpack/sync/class.jetpack-sync-functions.php +++ b/plugins/jetpack/sync/class.jetpack-sync-functions.php @@ -16,8 +16,51 @@ class Jetpack_Sync_Functions { public static function get_taxonomies() { global $wp_taxonomies; + $wp_taxonomies_without_callbacks = array(); + foreach ( $wp_taxonomies as $taxonomy_name => $taxonomy ) { + $sanitized_taxonomy = self::sanitize_taxonomy( $taxonomy ); + if ( ! empty( $sanitized_taxonomy ) ) { + $wp_taxonomies_without_callbacks[ $taxonomy_name ] = $sanitized_taxonomy; + } 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 ); + } + + /** + * Removes any callback data since we will not be able to process it on our side anyways. + */ + public static function sanitize_taxonomy( $taxonomy ) { - return $wp_taxonomies; + // Lets clone the taxonomy object instead of modifing the global one. + $cloned_taxonomy = json_decode( wp_json_encode( $taxonomy ) ); + + // recursive taxonomies are no fun. + if ( is_null( $cloned_taxonomy ) ) { + return null; + } + // 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' ) ) ) { + $cloned_taxonomy->meta_box_cb = null; + } + // Remove update call back + if ( isset( $cloned_taxonomy->update_count_callback ) && + ! is_null( $cloned_taxonomy->update_count_callback ) ) { + $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 ) { + $cloned_taxonomy->rest_controller_class = null; + } + return $cloned_taxonomy; } public static function get_post_types() { |