Skip to content

Commit

Permalink
Squashed merge commit with trunk
Browse files Browse the repository at this point in the history
commit 0374c69
Merge: 83de623 072da09
Author: Sarah Norris <[email protected]>
Date:   Tue Apr 4 16:15:50 2023 +0100

    Merge pull request #297 from WordPress/add/font-family-labels

    Add labels around Google font family checkbox controls

commit 83de623
Merge: 58491a7 b814f29
Author: Sarah Norris <[email protected]>
Date:   Tue Apr 4 16:13:48 2023 +0100

    Merge pull request #296 from WordPress/try/add-current-wp-version

    Add current WordPress version to style.css and readme.txt

commit 58491a7
Author: github-actions <[email protected]>
Date:   Mon Apr 3 20:54:08 2023 +0000

    Version bump & changelog update

commit 3a58a30
Merge: bb36a3a fd779d3
Author: Jeff Ong <[email protected]>
Date:   Mon Apr 3 11:27:38 2023 -0400

    Merge pull request #292 from WordPress/try/site-editor-overwrite

    Add Export (Clone) to site editor

commit fd779d3
Author: Jeff Ong <[email protected]>
Date:   Mon Apr 3 11:26:11 2023 -0400

    Carry forward previous theme tags.

commit 072da09
Author: Sarah Norris <[email protected]>
Date:   Sat Apr 1 21:39:54 2023 +0100

    Add checkbox labels to font family table header

commit 54318c6
Author: Sarah Norris <[email protected]>
Date:   Sat Apr 1 21:39:22 2023 +0100

    Add checkbox labels to font family variants

commit b814f29
Author: Sarah Norris <[email protected]>
Date:   Sat Apr 1 20:54:04 2023 +0100

    Add current WP version to readme.txt

commit f4070b2
Author: Sarah Norris <[email protected]>
Date:   Sat Apr 1 20:53:50 2023 +0100

    Add current WP version to style.css

commit bb36a3a
Merge: b5a0a0a 8c4098a
Author: Matias Benedetto <[email protected]>
Date:   Fri Mar 31 17:35:57 2023 -0300

    Merge pull request #293 from WordPress/update/google-fonts-json-_4537839996

    Update Google Fonts JSON data from API

commit cd5f862
Author: Matias Benedetto <[email protected]>
Date:   Fri Mar 31 17:22:36 2023 -0300

    setting the filename of the exported zip file

commit b5a0a0a
Merge: e3f9193 260d115
Author: Matias Benedetto <[email protected]>
Date:   Fri Mar 31 13:05:52 2023 -0300

    Merge pull request #291 from WordPress/fix/280

    Fixing image downloading not working in some cases

commit 1b19d29
Author: Jeff Ong <[email protected]>
Date:   Thu Mar 30 12:24:35 2023 -0400

    Make linter happy.

commit b86a1f1
Author: Jeff Ong <[email protected]>
Date:   Thu Mar 30 12:23:42 2023 -0400

    Rename file.

commit 6efb440
Author: Jeff Ong <[email protected]>
Date:   Wed Mar 29 17:27:42 2023 -0400

    Add validation to form button, improve spacing.

commit b5c6a17
Author: Jeff Ong <[email protected]>
Date:   Wed Mar 29 17:11:01 2023 -0400

    Async/await, update icon, button.

commit 8bc38ef
Author: Jeff Ong <[email protected]>
Date:   Wed Mar 29 16:40:00 2023 -0400

    Use tt3 as placeholder

    Co-authored-by: Ben Dwyer <[email protected]>

commit 16f3c5c
Author: Matias Benedetto <[email protected]>
Date:   Wed Mar 29 15:50:17 2023 -0300

    Implementing WordPress apiFetch replacing the browser's fetch function

commit 4870efb
Author: Jeff Ong <[email protected]>
Date:   Mon Mar 27 17:47:44 2023 -0400

    Lint php.

commit ebdf773
Author: Jeff Ong <[email protected]>
Date:   Mon Mar 27 17:47:22 2023 -0400

    Site editor rest API export.

commit a7b2de4
Author: Jeff Ong <[email protected]>
Date:   Mon Mar 27 13:49:35 2023 -0400

    Add panel to sidebar in site editor.

commit 8c4098a
Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Date:   Tue Mar 28 00:15:24 2023 +0000

    Updating file

commit 260d115
Author: Matias Benedetto <[email protected]>
Date:   Mon Mar 27 15:48:44 2023 -0300

    fixing image downloading not working in some cases
  • Loading branch information
mikachan committed Apr 5, 2023
1 parent 121fc68 commit a4397de
Show file tree
Hide file tree
Showing 14 changed files with 26,736 additions and 34,479 deletions.
46 changes: 44 additions & 2 deletions admin/class-create-block-theme-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@ class Create_Block_Theme_Admin {
public function __construct() {
add_action( 'admin_menu', array( $this, 'create_admin_menu' ) );
add_action( 'admin_init', array( $this, 'blockbase_save_theme' ) );
add_action( 'enqueue_block_editor_assets', array( $this, 'create_block_theme_enqueue' ) );
add_action( 'rest_api_init', array( $this, 'register_theme_export' ) );
}

function create_block_theme_enqueue() {
$asset_file = include( plugin_dir_path( dirname( __FILE__ ) ) . 'build/plugin-sidebar.asset.php' );

wp_register_script(
'create-block-theme-slot-fill',
plugins_url( 'build/plugin-sidebar.js', dirname( __FILE__ ) ),
$asset_file['dependencies'],
$asset_file['version']
);
wp_enqueue_script(
'create-block-theme-slot-fill',
);
}

function create_admin_menu() {
Expand Down Expand Up @@ -147,6 +163,11 @@ function clone_theme( $theme, $screenshot ) {
$theme['template'] = wp_get_theme()->get( 'Template' );
$theme['original_theme'] = wp_get_theme()->get( 'Name' );

// 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 = Theme_Zip::create_zip( $filename );
Expand Down Expand Up @@ -187,9 +208,30 @@ function clone_theme( $theme, $screenshot ) {
header( 'Content-Disposition: attachment; filename=' . $theme['slug'] . '.zip' );
header( 'Content-Length: ' . filesize( $filename ) );
flush();
echo readfile( $filename );
die();
readfile( $filename );
unlink( $filename );
exit;
}

function rest_export_theme( $request ) {
$theme = $request->get_params();
$this->clone_theme( $theme, null );
}

public function register_theme_export() {
register_rest_route(
'create-block-theme/v1',
'/export',
array(
'methods' => 'POST',
'callback' => array( $this, 'rest_export_theme' ),
'permission_callback' => function () {
return current_user_can( 'edit_theme_options' );
},
)
);
}

/**
* Create a child theme of the activated theme
*/
Expand Down
7 changes: 2 additions & 5 deletions admin/create-theme/theme-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,12 @@ public static function make_relative_media_url( $absolute_url ) {

public static function add_media_to_local( $media ) {
foreach ( $media as $url ) {
$download_file = file_get_contents( $url );
$download_file = download_url( $url );
$media_path = get_stylesheet_directory() . DIRECTORY_SEPARATOR . self::get_media_folder_path_from_url( $url );
if ( ! is_dir( $media_path ) ) {
wp_mkdir_p( $media_path );
}
file_put_contents(
$media_path . basename( $url ),
$download_file
);
rename( $download_file, $media_path . basename( $url ) );
}
}
}
3 changes: 2 additions & 1 deletion admin/create-theme/theme-readme.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static function build_readme_txt( $theme ) {
$author = $theme['author'];
$author_uri = $theme['author_uri'];
$copy_year = gmdate( 'Y' );
$wp_version = get_bloginfo( 'version' );
$original_theme = $theme['original_theme'] ?? '';
$original_theme_credits = $original_theme ? self::original_theme_credits( $name ) : '';

Expand All @@ -24,7 +25,7 @@ public static function build_readme_txt( $theme ) {
return "=== {$name} ===
Contributors: {$author}
Requires at least: 5.8
Tested up to: 5.9
Tested up to: {$wp_version}
Requires PHP: 5.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
3 changes: 2 additions & 1 deletion admin/create-theme/theme-styles.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public static function build_child_style_css( $theme ) {
$uri = $theme['uri'];
$author = $theme['author'];
$author_uri = $theme['author_uri'];
$wp_version = get_bloginfo( 'version' );
$template = $theme['template'];
$tags = Theme_Tags::theme_tags_list( $theme );
return "/*
Expand All @@ -22,7 +23,7 @@ public static function build_child_style_css( $theme ) {
Author URI: {$author_uri}
Description: {$description}
Requires at least: 5.8
Tested up to: 5.9
Tested up to: {$wp_version}
Requires PHP: 5.7
Version: 0.0.1
License: GNU General Public License v2 or later
Expand Down
9 changes: 6 additions & 3 deletions admin/create-theme/theme-zip.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ public static function add_templates_to_zip( $zip, $export_type, $new_slug ) {
static function add_media_to_zip( $zip, $media ) {
$media = array_unique( $media );
foreach ( $media as $url ) {
$folder_path = Theme_Media::get_media_folder_path_from_url( $url );
$download_file = file_get_contents( $url );
$zip->addFromString( $folder_path . basename( $url ), $download_file );
$folder_path = Theme_Media::get_media_folder_path_from_url( $url );
$download_file = download_url( $url );
$content_array = file( $download_file );
$file_as_string = implode( '', $content_array );

$zip->addFromString( $folder_path . basename( $url ), $file_as_string );
}
}

Expand Down
Loading

0 comments on commit a4397de

Please sign in to comment.