Skip to content
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

Extracted any logic that may need to be tested from the api class #522

Merged
merged 28 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
2c367be
Extracted any logic that may need to be tested from the api class
pbking Mar 19, 2024
bda2dc0
Refactored media and pattern parsing to facilitate testing
pbking Mar 19, 2024
260912d
Refactored media and pattern parsing to facilitate testing
pbking Mar 19, 2024
6359594
Moved valid screenshot check to utils to fix bug with exporting theme
pbking Mar 19, 2024
65db63e
Fixed linting errors
pbking Mar 20, 2024
3229006
add code from #524 and add some unit tests for it
pbking Mar 20, 2024
3b18fa7
Fixed path to boilerplate content to fix create blank theme
pbking Mar 20, 2024
d0cb9ee
Refactored zip construction to use shared code with saving logic
pbking Mar 20, 2024
4b67c40
Further consolidated template and css parsing logic for theme exporting
pbking Mar 20, 2024
8e9e102
removed queryID removal from query blocks
pbking Mar 22, 2024
7235e27
Removed unneeded test
pbking Mar 22, 2024
c18c22c
Fixed a few null ref bugs
pbking Mar 22, 2024
bf2a845
Added 'Test_' to the test classes
pbking Mar 22, 2024
26f7552
Fixed a couple of slug processing bugs
pbking Mar 22, 2024
fb49bd3
Fixed the image processing so that the id is removed from inner conte…
pbking Mar 22, 2024
6694dec
Fixed button localization logic
pbking Mar 22, 2024
275e177
localize heading blocks
pbking Mar 22, 2024
fb63596
Add test for escape function effect on php syntax
Mar 22, 2024
f97a8a8
Revert order in which templates parsed
Mar 22, 2024
df468b0
add comment doc for prepare_template_for_export
Mar 22, 2024
649ba9d
Added tests that evaluate encoded patterns and test patterns created …
pbking Mar 25, 2024
1d48804
Added taxQuery removal tests and fixed taxQuery attribute removal logic
pbking Mar 26, 2024
431aefe
Refactored image/cover processing to more cleanly handle id classes
pbking Mar 26, 2024
e1dc292
Add test and fixed bugs around escaping <'s and >'s
pbking Mar 26, 2024
5a26145
move block text escaping to block-specific functions and stopped proc…
pbking Mar 27, 2024
9a6cbe6
Trying alternative approaching to localizing templates
pbking Mar 27, 2024
796fd11
localized quote blocks
pbking Mar 27, 2024
f634e5d
Added localization processing to list, verse, table and media-text bl…
pbking Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions admin/class-create-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require_once __DIR__ . '/create-theme/theme-tags.php';
require_once __DIR__ . '/create-theme/theme-zip.php';
require_once __DIR__ . '/create-theme/theme-media.php';
require_once __DIR__ . '/create-theme/theme-blocks.php';
require_once __DIR__ . '/create-theme/theme-patterns.php';
require_once __DIR__ . '/create-theme/theme-templates.php';
require_once __DIR__ . '/create-theme/theme-styles.php';
Expand All @@ -14,7 +13,7 @@
require_once __DIR__ . '/create-theme/theme-form.php';
require_once __DIR__ . '/create-theme/form-messages.php';
require_once __DIR__ . '/create-theme/theme-fonts.php';

require_once __DIR__ . '/create-theme/theme-create.php';
/**
* The admin-specific functionality of the plugin.
*
Expand Down Expand Up @@ -158,14 +157,14 @@ function create_sibling_theme( $theme, $screenshot ) {
// Remove metadata from style.css file
$css_contents = trim( substr( $css_contents, strpos( $css_contents, '*/' ) + 2 ) );
// Add new metadata
$css_contents = Theme_Styles::build_child_style_css( $theme ) . $css_contents;
$css_contents = Theme_Styles::build_style_css( $theme ) . $css_contents;
$zip->addFromStringToTheme(
'style.css',
$css_contents
);

// Add / replace screenshot.
if ( $this->is_valid_screenshot( $screenshot ) ) {
if ( Theme_Utils::is_valid_screenshot( $screenshot ) ) {
$zip->addFileToTheme(
$screenshot['tmp_name'],
'screenshot.png'
Expand Down Expand Up @@ -227,14 +226,14 @@ function clone_theme( $theme, $screenshot ) {
// Remove metadata from style.css file
$css_contents = trim( substr( $css_contents, strpos( $css_contents, '*/' ) + 2 ) );
// Add new metadata
$css_contents = Theme_Styles::build_child_style_css( $theme ) . $css_contents;
$css_contents = Theme_Styles::build_style_css( $theme ) . $css_contents;
$zip->addFromStringToTheme(
'style.css',
$css_contents
);

// Add / replace screenshot.
if ( $this->is_valid_screenshot( $screenshot ) ) {
if ( Theme_Utils::is_valid_screenshot( $screenshot ) ) {
$zip->addFileToTheme(
$screenshot['tmp_name'],
'screenshot.png'
Expand Down Expand Up @@ -289,11 +288,11 @@ function create_child_theme( $theme, $screenshot ) {
// Add style.css.
$zip->addFromStringToTheme(
'style.css',
Theme_Styles::build_child_style_css( $theme )
Theme_Styles::build_style_css( $theme )
);

// Add / replace screenshot.
if ( $this->is_valid_screenshot( $screenshot ) ) {
if ( Theme_Utils::is_valid_screenshot( $screenshot ) ) {
$zip->addFileToTheme(
$screenshot['tmp_name'],
'screenshot.png'
Expand Down Expand Up @@ -362,7 +361,7 @@ function create_blank_theme( $theme, $screenshot ) {
);

// Add new metadata.
$css_contents = Theme_Styles::build_child_style_css( $theme );
$css_contents = Theme_Styles::build_style_css( $theme );

// Add style.css.
file_put_contents(
Expand All @@ -386,7 +385,7 @@ function create_blank_theme( $theme, $screenshot ) {
}

// Overwrite default screenshot if one is provided.
if ( $this->is_valid_screenshot( $screenshot ) ) {
if ( Theme_Utils::is_valid_screenshot( $screenshot ) ) {
file_put_contents(
$blank_theme_path . DIRECTORY_SEPARATOR . 'screenshot.png',
file_get_contents( $screenshot['tmp_name'] )
Expand Down Expand Up @@ -491,16 +490,4 @@ function blockbase_save_theme() {
}
}
}

const ALLOWED_SCREENSHOT_TYPES = array(
'png' => 'image/png',
);

function is_valid_screenshot( $file ) {
$filetype = wp_check_filetype( $file['name'], self::ALLOWED_SCREENSHOT_TYPES );
if ( is_uploaded_file( $file['tmp_name'] ) && in_array( $filetype['type'], self::ALLOWED_SCREENSHOT_TYPES, true ) && $file['size'] < 2097152 ) {
return 1;
}
return 0;
}
}
193 changes: 0 additions & 193 deletions admin/create-theme/theme-blocks.php

This file was deleted.

Loading
Loading