From 6cd1d20c5b74c81c7b3ca3730ba5491d85a7d88b Mon Sep 17 00:00:00 2001 From: Aki Hamano Date: Mon, 10 Jun 2024 13:24:00 +0900 Subject: [PATCH] Remove unused REAT API endpoint --- includes/class-create-block-theme-api.php | 134 ---------------------- 1 file changed, 134 deletions(-) diff --git a/includes/class-create-block-theme-api.php b/includes/class-create-block-theme-api.php index 0ac724bf..889be29b 100644 --- a/includes/class-create-block-theme-api.php +++ b/includes/class-create-block-theme-api.php @@ -111,28 +111,6 @@ public function register_rest_routes() { }, ) ); - register_rest_route( - 'create-block-theme/v1', - '/export-clone', - array( - 'methods' => 'POST', - 'callback' => array( $this, 'rest_export_cloned_theme' ), - 'permission_callback' => function () { - return current_user_can( 'edit_theme_options' ); - }, - ) - ); - register_rest_route( - 'create-block-theme/v1', - '/export-child-clone', - array( - 'methods' => 'POST', - 'callback' => array( $this, 'rest_export_child_cloned_theme' ), - 'permission_callback' => function () { - return current_user_can( 'edit_theme_options' ); - }, - ) - ); register_rest_route( 'create-block-theme/v1', '/get-readme-data', @@ -289,118 +267,6 @@ function rest_create_blank_theme( $request ) { ); } - function rest_export_cloned_theme( $request ) { - - //TODO: Handle Screenshots - $screenshot = null; - $theme = $this->sanitize_theme_data( $request->get_params() ); - - // Use previous theme's tags if custom tags are empty. - if ( empty( $theme['tags_custom'] ) ) { - $theme['tags_custom'] = implode( ', ', wp_get_theme()->get( 'Tags' ) ); - } - - // Create ZIP file in the temporary directory. - $filename = tempnam( get_temp_dir(), $theme['slug'] ); - $zip = CBT_Theme_Zip::create_zip( $filename, $theme['slug'] ); - $zip = CBT_Theme_Zip::copy_theme_to_zip( $zip, $theme['slug'], $theme['name'] ); - $zip = CBT_Theme_Zip::add_templates_to_zip( $zip, 'all', $theme['slug'] ); - - //TODO: Should the font persistent be optional? - // If so then the Font Library fonts will need to be removed from the theme.json settings. - $theme_json = CBT_Theme_JSON_Resolver::export_theme_data( 'all' ); - $theme_json = CBT_Theme_Zip::add_activated_fonts_to_zip( $zip, $theme_json ); - $zip = CBT_Theme_Zip::add_theme_json_to_zip( $zip, $theme_json ); - - // Add readme.txt. - $zip->addFromStringToTheme( - 'readme.txt', - CBT_Theme_Readme::create( $theme ) - ); - - // Build style.css with new theme metadata - $css_contents = file_get_contents( get_stylesheet_directory() . '/style.css' ); - $css_contents = trim( substr( $css_contents, strpos( $css_contents, '*/' ) + 2 ) ); - $css_contents = CBT_Theme_Styles::build_style_css( $theme ) . $css_contents; - $zip->addFromStringToTheme( - 'style.css', - $css_contents - ); - - // Add / replace screenshot. - if ( CBT_Theme_Utils::is_valid_screenshot( $screenshot ) ) { - $zip->addFileToTheme( - $screenshot['tmp_name'], - 'screenshot.png' - ); - } - - $zip->close(); - - wp_cache_flush(); - - header( 'Content-Type: application/zip' ); - header( 'Content-Disposition: attachment; filename=' . $theme['slug'] . '.zip' ); - header( 'Content-Length: ' . filesize( $filename ) ); - flush(); - echo readfile( $filename ); - } - - function rest_export_child_cloned_theme( $request ) { - - //TODO: Handle Screenshots - $screenshot = null; - $theme = $this->sanitize_theme_data( $request->get_params() ); - - // Create ZIP file in the temporary directory. - $filename = tempnam( get_temp_dir(), $theme['slug'] ); - $zip = CBT_Theme_Zip::create_zip( $filename, $theme['slug'] ); - - //TODO: Should the font persistent be optional? - // If so then the Font Library fonts will need to be removed from the theme.json settings. - $theme_json = CBT_Theme_JSON_Resolver::export_theme_data( 'variation' ); - $theme_json = CBT_Theme_Zip::add_activated_fonts_to_zip( $zip, $theme_json ); - $zip = CBT_Theme_Zip::add_theme_json_to_zip( $zip, $theme_json ); - - // Add readme.txt. - $zip->addFromStringToTheme( - 'readme.txt', - CBT_Theme_Readme::create( $theme ) - ); - - // Build style.css with new theme metadata - $theme['template'] = wp_get_theme()->get( 'TextDomain' ); - $css_contents = CBT_Theme_Styles::build_style_css( $theme ); - $zip->addFromStringToTheme( - 'style.css', - $css_contents - ); - - // Add / replace screenshot. - if ( CBT_Theme_Utils::is_valid_screenshot( $screenshot ) ) { - $zip->addFileToTheme( - $screenshot['tmp_name'], - 'screenshot.png' - ); - } else { - $source = plugin_dir_path( __DIR__ ) . 'assets/boilerplate/screenshot.png'; - $zip->addFileToTheme( - $source, - 'screenshot.png' - ); - } - - $zip->close(); - - wp_cache_flush(); - - header( 'Content-Type: application/zip' ); - header( 'Content-Disposition: attachment; filename=' . $theme['slug'] . '.zip' ); - header( 'Content-Length: ' . filesize( $filename ) ); - flush(); - echo readfile( $filename ); - } - /** * Export the theme as a ZIP file. */