From 4d4f1ef51ef92a771e9d6bbf1e194180d19cb993 Mon Sep 17 00:00:00 2001 From: Andrew Duthie Date: Wed, 27 Feb 2019 10:21:09 -0500 Subject: [PATCH] Plugin: Remove PHP functions slated for removal in 5.2 (#14090) * Plugin: Remove PHP functions slated for removal in 5.2 * Documentation: Update FAQ to avoid reference to deprecated function --- docs/designers-developers/faq.md | 3 +- gutenberg.php | 100 --------------------- lib/blocks.php | 142 ------------------------------ lib/client-assets.php | 115 ------------------------ lib/compat.php | 93 ------------------- lib/load.php | 4 - lib/meta-box-partial-page.php | 118 ------------------------- lib/plugin-compat.php | 33 ------- lib/register.php | 124 -------------------------- lib/rest-api.php | 121 ------------------------- phpunit/class-admin-test.php | 69 --------------- phpunit/class-blocks-api-test.php | 95 -------------------- 12 files changed, 1 insertion(+), 1016 deletions(-) delete mode 100644 lib/blocks.php delete mode 100644 lib/compat.php delete mode 100644 lib/meta-box-partial-page.php delete mode 100644 lib/plugin-compat.php delete mode 100644 phpunit/class-admin-test.php delete mode 100644 phpunit/class-blocks-api-test.php diff --git a/docs/designers-developers/faq.md b/docs/designers-developers/faq.md index 4fcccc36723bf..eb4b21b2a1a6c 100644 --- a/docs/designers-developers/faq.md +++ b/docs/designers-developers/faq.md @@ -365,8 +365,7 @@ var blocks = wp.blocks.parse( postContent ); In PHP: ```php -$blocks = gutenberg_parse_blocks( $post_content ); // plugin -$blocks = parse_blocks( $post_content ); // WordPress 5.0 +$blocks = parse_blocks( $post_content ); ``` ## Why should I start using this once released? diff --git a/gutenberg.php b/gutenberg.php index 40da12a8c4b8c..db7f70d1cab95 100644 --- a/gutenberg.php +++ b/gutenberg.php @@ -234,103 +234,3 @@ function gutenberg_init( $return, $post ) { return true; } - -/** - * Adds the filters to register additional links for the Gutenberg editor in - * the post/page screens. - * - * @since 1.5.0 - * @deprecated 5.0.0 - */ -function gutenberg_add_edit_link_filters() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - -/** - * Registers an additional link in the post/page screens to edit any post/page in - * the Classic editor. - * - * @since 1.5.0 - * @deprecated 5.0.0 - * - * @param array $actions Post actions. - * - * @return array Updated post actions. - */ -function gutenberg_add_edit_link( $actions ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $actions; -} - -/** - * Removes the Edit action from the reusable block list's Bulk Actions dropdown. - * - * @since 3.8.0 - * @deprecated 5.0.0 - * - * @param array $actions Bulk actions. - * - * @return array Updated bulk actions. - */ -function gutenberg_block_bulk_actions( $actions ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $actions; -} - -/** - * Prints the JavaScript to replace the default "Add New" button.$_COOKIE - * - * @since 1.5.0 - * @deprecated 5.0.0 - */ -function gutenberg_replace_default_add_new_button() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - -/** - * Adds the block-editor-page class to the body tag on the Gutenberg page. - * - * @since 1.5.0 - * @deprecated 5.0.0 - * - * @param string $classes Space separated string of classes being added to the body tag. - * @return string The $classes string, with block-editor-page appended. - */ -function gutenberg_add_admin_body_class( $classes ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $classes; -} - -/** - * Adds attributes to kses allowed tags that aren't in the default list - * and that Gutenberg needs to save blocks such as the Gallery block. - * - * @deprecated 5.0.0 - * - * @param array $tags Allowed HTML. - * @return array (Maybe) modified allowed HTML. - */ -function gutenberg_kses_allowedtags( $tags ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $tags; -} - -/** - * Adds the wp-embed-responsive class to the body tag if the theme has opted in to - * Gutenberg responsive embeds. - * - * @since 4.1.0 - * @deprecated 5.0.0 - * - * @param Array $classes Array of classes being added to the body tag. - * @return Array The $classes array, with wp-embed-responsive appended. - */ -function gutenberg_add_responsive_body_class( $classes ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $classes; -} diff --git a/lib/blocks.php b/lib/blocks.php deleted file mode 100644 index 3419e81c8bb38..0000000000000 --- a/lib/blocks.php +++ /dev/null @@ -1,142 +0,0 @@ -/' - ); - - return $dynamic_block_pattern; - } -} - -/** - * Renders a single block into a HTML string. - * - * @since 1.9.0 - * @since 4.4.0 renders full nested tree of blocks before reassembling into HTML string - * @global WP_Post $post The post to edit. - * @deprecated 5.0.0 render_block() - * - * @param array $block A single parsed block object. - * @return string String of rendered HTML. - */ -function gutenberg_render_block( $block ) { - _deprecated_function( __FUNCTION__, '5.0.0', 'render_block()' ); - - return render_block( $block ); -} - -if ( ! function_exists( 'strip_dynamic_blocks' ) ) { - /** - * Remove all dynamic blocks from the given content. - * - * @since 3.6.0 - * @deprecated 5.0.0 - * - * @param string $content Content of the current post. - * @return string - */ - function strip_dynamic_blocks( $content ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return preg_replace( get_dynamic_blocks_regex(), '', $content ); - } -} - -if ( ! function_exists( 'strip_dynamic_blocks_add_filter' ) ) { - /** - * Adds the content filter to strip dynamic blocks from excerpts. - * - * It's a bit hacky for now, but once this gets merged into core the function - * can just be called in `wp_trim_excerpt()`. - * - * @since 3.6.0 - * @deprecated 5.0.0 - * - * @param string $text Excerpt. - * @return string - */ - function strip_dynamic_blocks_add_filter( $text ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - add_filter( 'the_content', 'strip_dynamic_blocks', 6 ); - - return $text; - } -} - -if ( ! function_exists( 'strip_dynamic_blocks_remove_filter' ) ) { - /** - * Removes the content filter to strip dynamic blocks from excerpts. - * - * It's a bit hacky for now, but once this gets merged into core the function - * can just be called in `wp_trim_excerpt()`. - * - * @since 3.6.0 - * @deprecated 5.0.0 - * - * @param string $text Excerpt. - * @return string - */ - function strip_dynamic_blocks_remove_filter( $text ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - remove_filter( 'the_content', 'strip_dynamic_blocks', 6 ); - - return $text; - } -} diff --git a/lib/client-assets.php b/lib/client-assets.php index ac84f94a19025..834a08a2d83a9 100644 --- a/lib/client-assets.php +++ b/lib/client-assets.php @@ -34,35 +34,6 @@ function gutenberg_url( $path ) { return plugins_url( $path, dirname( __FILE__ ) ); } -/** - * Returns contents of an inline script used in appending polyfill scripts for - * browsers which fail the provided tests. The provided array is a mapping from - * a condition to verify feature support to its polyfill script handle. - * - * @param array $tests Features to detect. - * @return string Conditional polyfill inline script. - */ -function gutenberg_get_script_polyfill( $tests ) { - _deprecated_function( __FUNCTION__, '5.0.0', 'wp_get_script_polyfill' ); - - global $wp_scripts; - return wp_get_script_polyfill( $wp_scripts, $tests ); -} - -if ( ! function_exists( 'register_tinymce_scripts' ) ) { - /** - * Registers the main TinyMCE scripts. - * - * @deprecated 5.0.0 wp_register_tinymce_scripts - */ - function register_tinymce_scripts() { - _deprecated_function( __FUNCTION__, '5.0.0', 'wp_register_tinymce_scripts' ); - - global $wp_scripts; - return wp_register_tinymce_scripts( $wp_scripts ); - } -} - /** * Registers a script according to `wp_register_script`. Honors this request by * deregistering any script by the same handler before registration. @@ -465,23 +436,6 @@ function gutenberg_register_scripts_and_styles() { add_action( 'wp_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 ); add_action( 'admin_enqueue_scripts', 'gutenberg_register_scripts_and_styles', 5 ); -/** - * Append result of internal request to REST API for purpose of preloading - * data to be attached to the page. Expected to be called in the context of - * `array_reduce`. - * - * @deprecated 5.0.0 rest_preload_api_request - * - * @param array $memo Reduce accumulator. - * @param string $path REST API path to preload. - * @return array Modified reduce accumulator. - */ -function gutenberg_preload_api_request( $memo, $path ) { - _deprecated_function( __FUNCTION__, '5.0.0', 'rest_preload_api_request' ); - - return rest_preload_api_request( $memo, $path ); -} - /** * Registers vendor JavaScript files to be used as dependencies of the editor * and plugins. @@ -597,51 +551,6 @@ function gutenberg_register_vendor_script( $handle, $src, $deps = array() ) { ); } -/** - * Prepares server-registered blocks for JavaScript, returning an associative - * array of registered block data keyed by block name. Data includes properties - * of a block relevant for client registration. - * - * @deprecated 5.0.0 get_block_editor_server_block_settings - * - * @return array An associative array of registered block data. - */ -function gutenberg_prepare_blocks_for_js() { - _deprecated_function( __FUNCTION__, '5.0.0', 'get_block_editor_server_block_settings' ); - - return get_block_editor_server_block_settings(); -} - -/** - * Handles the enqueueing of block scripts and styles that are common to both - * the editor and the front-end. - * - * Note: This function must remain *before* - * `gutenberg_editor_scripts_and_styles` so that editor-specific stylesheets - * are loaded last. - * - * @since 0.4.0 - * @deprecated 5.0.0 wp_common_block_scripts_and_styles - */ -function gutenberg_common_scripts_and_styles() { - _deprecated_function( __FUNCTION__, '5.0.0', 'wp_common_block_scripts_and_styles' ); - - wp_common_block_scripts_and_styles(); -} - -/** - * Enqueues registered block scripts and styles, depending on current rendered - * context (only enqueuing editor scripts while in context of the editor). - * - * @since 2.0.0 - * @deprecated 5.0.0 wp_enqueue_registered_block_scripts_and_styles - */ -function gutenberg_enqueue_registered_block_scripts_and_styles() { - _deprecated_function( __FUNCTION__, '5.0.0', 'wp_enqueue_registered_block_scripts_and_styles' ); - - wp_enqueue_registered_block_scripts_and_styles(); -} - /** * Assigns a default editor template with a default block by post format, if * not otherwise assigned for a new post of type "post". @@ -711,21 +620,6 @@ function gutenberg_get_autosave_newer_than_post_save( $post ) { return false; } -/** - * Returns all the block categories. - * - * @since 2.2.0 - * @deprecated 5.0.0 get_block_categories - * - * @param WP_Post $post Post object. - * @return Object[] Block categories. - */ -function gutenberg_get_block_categories( $post ) { - _deprecated_function( __FUNCTION__, '5.0.0', 'get_block_categories' ); - - return get_block_categories( $post ); -} - /** * Loads Gutenberg Locale Data. */ @@ -1198,12 +1092,3 @@ function gutenberg_editor_scripts_and_styles( $hook ) { */ do_action( 'enqueue_block_editor_assets' ); } - -/** - * Enqueue the reusable blocks listing page's script - * - * @deprecated 5.0.0 - */ -function gutenberg_load_list_reusable_blocks() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} diff --git a/lib/compat.php b/lib/compat.php deleted file mode 100644 index dc090cfe047de..0000000000000 --- a/lib/compat.php +++ /dev/null @@ -1,93 +0,0 @@ - tags. This adds a filter prior to saving the post via - * REST API to disable markdown support. Disables markdown support provided by - * plugins Jetpack, JP-Markdown, and WP Editor.MD - * - * @since 1.3.0 - * @deprecated 5.0.0 - * - * @param array $post Post object which contains content to check for block. - * @return array $post Post object. - */ -function gutenberg_remove_wpcom_markdown_support( $post ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $post; -} diff --git a/lib/register.php b/lib/register.php index 9f86fdb58200b..91ef3ee26e9aa 100644 --- a/lib/register.php +++ b/lib/register.php @@ -9,18 +9,6 @@ die( 'Silence is golden.' ); } -/** - * Collect information about meta_boxes registered for the current post. - * - * Redirects to classic editor if a meta box is incompatible. - * - * @since 1.5.0 - * @deprecated 5.0.0 register_and_do_post_meta_boxes - */ -function gutenberg_collect_meta_box_data() { - _deprecated_function( __FUNCTION__, '5.0.0', 'register_and_do_post_meta_boxes' ); -} - /** * Return whether the post can be edited in Gutenberg and by the current user. * @@ -56,102 +44,6 @@ function gutenberg_can_edit_post_type( $post_type ) { return use_block_editor_for_post_type( $post_type ); } -/** - * Determine whether a post has blocks. This test optimizes for performance - * rather than strict accuracy, detecting the pattern of a block but not - * validating its structure. For strict accuracy, you should use the block - * parser on post content. - * - * @see gutenberg_parse_blocks() - * - * @since 0.5.0 - * @deprecated 3.6.0 Use has_blocks() - * - * @param object $post Post. - * @return bool Whether the post has blocks. - */ -function gutenberg_post_has_blocks( $post ) { - _deprecated_function( __FUNCTION__, '3.6.0', 'has_blocks()' ); - return has_blocks( $post ); -} - -/** - * Determine whether a content string contains blocks. This test optimizes for - * performance rather than strict accuracy, detecting the pattern of a block - * but not validating its structure. For strict accuracy, you should use the - * block parser on post content. - * - * @see gutenberg_parse_blocks() - * - * @since 1.6.0 - * @deprecated 3.6.0 Use has_blocks() - * - * @param string $content Content to test. - * @return bool Whether the content contains blocks. - */ -function gutenberg_content_has_blocks( $content ) { - _deprecated_function( __FUNCTION__, '3.6.0', 'has_blocks()' ); - return has_blocks( $content ); -} - -/** - * Returns the current version of the block format that the content string is using. - * - * If the string doesn't contain blocks, it returns 0. - * - * @since 2.8.0 - * @see gutenberg_content_has_blocks() - * @deprecated 5.0.0 block_version - * - * @param string $content Content to test. - * @return int The block format version. - */ -function gutenberg_content_block_version( $content ) { - _deprecated_function( __FUNCTION__, '5.0.0', 'block_version' ); - - return block_version( $content ); -} - -/** - * Adds a "Gutenberg" post state for post tables, if the post contains blocks. - * - * @deprecated 5.0.0 - * - * @param array $post_states An array of post display states. - * @return array A filtered array of post display states. - */ -function gutenberg_add_gutenberg_post_state( $post_states ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $post_states; -} - -/** - * Registers custom post types required by the Gutenberg editor. - * - * @since 0.10.0 - * @deprecated 5.0.0 - */ -function gutenberg_register_post_types() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - -/** - * Apply the correct labels for Reusable Blocks in the bulk action updated messages. - * - * @since 4.3.0 - * @deprecated 5.0.0 - * - * @param array $messages Arrays of messages, each keyed by the corresponding post type. - * - * @return array - */ -function gutenberg_bulk_post_updated_messages( $messages ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $messages; -} - /** * Injects a hidden input in the edit form to propagate the information that classic editor is selected. * @@ -192,19 +84,3 @@ function gutenberg_revisions_link_to_editor( $url ) { return $url; } - -/** - * Modifies revisions data to preserve Gutenberg argument used in determining - * where to redirect user returning to editor. - * - * @since 1.9.0 - * @deprecated 5.0.0 - * - * @param array $revisions_data The bootstrapped data for the revisions screen. - * @return array Modified bootstrapped data for the revisions screen. - */ -function gutenberg_revisions_restore( $revisions_data ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $revisions_data; -} diff --git a/lib/rest-api.php b/lib/rest-api.php index d12d7df12dfcc..1b36ba7df9b38 100644 --- a/lib/rest-api.php +++ b/lib/rest-api.php @@ -10,16 +10,6 @@ die( 'Silence is golden.' ); } -/** - * Registers the REST API routes needed by the Gutenberg editor. - * - * @since 2.8.0 - * @deprecated 5.0.0 - */ -function gutenberg_register_rest_routes() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - /** * Handle a failing oEmbed proxy request to try embedding as a shortcode. * @@ -61,114 +51,3 @@ function gutenberg_filter_oembed_result( $response, $handler, $request ) { ); } add_filter( 'rest_request_after_callbacks', 'gutenberg_filter_oembed_result', 10, 3 ); - -/** - * Add additional 'visibility' rest api field to taxonomies. - * - * Used so private taxonomies are not displayed in the UI. - * - * @see https://core.trac.wordpress.org/ticket/42707 - * @deprecated 5.0.0 - */ -function gutenberg_add_taxonomy_visibility_field() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - -/** - * Gets taxonomy visibility property data. - * - * @see https://core.trac.wordpress.org/ticket/42707 - * @deprecated 5.0.0 - * - * @param array $object Taxonomy data from REST API. - * @return array Array of taxonomy visibility data. - */ -function gutenberg_get_taxonomy_visibility_data( $object ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return isset( $object['visibility'] ) ? $object['visibility'] : array(); -} - -/** - * Add a permalink template to posts in the post REST API response. - * - * @see https://core.trac.wordpress.org/ticket/45017 - * @deprecated 5.0.0 - * - * @param WP_REST_Response $response WP REST API response of a post. - * @return WP_REST_Response Response containing the permalink_template. - */ -function gutenberg_add_permalink_template_to_posts( $response ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $response; -} - -/** - * Add the block format version to post content in the post REST API response. - * - * @see https://core.trac.wordpress.org/ticket/43887 - * @deprecated 5.0.0 - * - * @param WP_REST_Response $response WP REST API response of a post. - * @return WP_REST_Response Response containing the block_format. - */ -function gutenberg_add_block_format_to_post_content( $response ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $response; -} - -/** - * Include target schema attributes to links, based on whether the user can. - * - * @see https://core.trac.wordpress.org/ticket/45014 - * @deprecated 5.0.0 - * - * @param WP_REST_Response $response WP REST API response of a post. - * @return WP_REST_Response Response containing the new links. - */ -function gutenberg_add_target_schema_to_links( $response ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $response; -} - -/** - * Whenever a post type is registered, ensure we're hooked into it's WP REST API response. - * - * @deprecated 5.0.0 - * - * @param string $post_type The newly registered post type. - * @return string That same post type. - */ -function gutenberg_register_post_prepare_functions( $post_type ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $post_type; -} - -/** - * Silence PHP Warnings and Errors in JSON requests - * - * @see https://core.trac.wordpress.org/ticket/44534 - * @deprecated 5.0.0 - */ -function gutenberg_silence_rest_errors() { - _deprecated_function( __FUNCTION__, '5.0.0' ); -} - -/** - * Include additional labels for registered post types - * - * @see https://core.trac.wordpress.org/ticket/45101 - * @deprecated 5.0.0 - * - * @param array $args Arguments supplied to register_post_type(). - * @return array Arguments supplied to register_post_type() - */ -function gutenberg_filter_post_type_labels( $args ) { - _deprecated_function( __FUNCTION__, '5.0.0' ); - - return $args; -} diff --git a/phpunit/class-admin-test.php b/phpunit/class-admin-test.php deleted file mode 100644 index e96f4958366ca..0000000000000 --- a/phpunit/class-admin-test.php +++ /dev/null @@ -1,69 +0,0 @@ -post->create( - array( - 'post_title' => 'Example', - 'post_content' => "\n

Tester

\n", - ) - ); - self::$post_without_blocks = self::factory()->post->create( - array( - 'post_title' => 'Example', - 'post_content' => 'Tester', - ) - ); - } - - /** - * Tests gutenberg_post_has_blocks(). - * - * @covers ::gutenberg_post_has_blocks - * @expectedDeprecated gutenberg_post_has_blocks - */ - function test_gutenberg_post_has_blocks() { - $this->assertTrue( gutenberg_post_has_blocks( self::$post_with_blocks ) ); - $this->assertFalse( gutenberg_post_has_blocks( self::$post_without_blocks ) ); - } - - /** - * Tests gutenberg_content_has_blocks(). - * - * @covers ::gutenberg_content_has_blocks - * @expectedDeprecated gutenberg_content_has_blocks - */ - function test_gutenberg_content_has_blocks() { - $content_with_blocks = get_post_field( 'post_content', self::$post_with_blocks ); - $content_without_blocks = get_post_field( 'post_content', self::$post_without_blocks ); - - $this->assertTrue( gutenberg_content_has_blocks( $content_with_blocks ) ); - $this->assertFalse( gutenberg_content_has_blocks( $content_without_blocks ) ); - } -} diff --git a/phpunit/class-blocks-api-test.php b/phpunit/class-blocks-api-test.php deleted file mode 100644 index 1573f980f6368..0000000000000 --- a/phpunit/class-blocks-api-test.php +++ /dev/null @@ -1,95 +0,0 @@ - -

paragraph

- - - - - - -'; - - public $filtered_content = ' - -

paragraph

- - - - - - -'; - - /** - * Dummy block rendering function. - * - * @return string Block output. - */ - function render_dummy_block() { - return get_the_excerpt( self::$post_id ); - } - - /** - * Set up. - */ - function setUp() { - parent::setUp(); - - self::$post_id = $this->factory()->post->create( - array( - 'post_excerpt' => '', // Empty excerpt, so it has to be generated. - 'post_content' => '', - ) - ); - - register_block_type( - 'core/dummy', - array( - 'render_callback' => array( $this, 'render_dummy_block' ), - ) - ); - } - - /** - * Tear down. - */ - function tearDown() { - parent::tearDown(); - - $registry = WP_Block_Type_Registry::get_instance(); - $registry->unregister( 'core/dummy' ); - - wp_delete_post( self::$post_id, true ); - } - - /** - * Tests strip_dynamic_blocks(). - * - * @covers ::strip_dynamic_blocks - */ - function test_strip_dynamic_blocks() { - $this->setExpectedDeprecated( 'strip_dynamic_blocks' ); - $this->setExpectedDeprecated( 'get_dynamic_blocks_regex' ); - - // Simple dynamic block.. - $content = ''; - $this->assertEmpty( strip_dynamic_blocks( $content ) ); - - // Dynamic block with options, embedded in other content. - $this->assertEquals( $this->filtered_content, strip_dynamic_blocks( $this->content ) ); - } -}