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

Fix static-analysis and PHPUnit tests errors #7814

Merged
merged 4 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-comments-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ class AMP_Comments_Sanitizer extends AMP_Base_Sanitizer {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

if (
array_key_exists( AMP_Style_Sanitizer::class, $sanitizers )
&&
Expand Down
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-script-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ class AMP_Script_Sanitizer extends AMP_Base_Sanitizer {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

$this->sanitizers = $sanitizers;
}

Expand Down
2 changes: 0 additions & 2 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,6 @@ private function is_class_allowed_in_amp_date_picker( $class ) {
* @param AMP_Base_Sanitizer[] $sanitizers Sanitizers.
*/
public function init( $sanitizers ) {
parent::init( $sanitizers );

$this->sanitizers = $sanitizers;
}

Expand Down
28 changes: 24 additions & 4 deletions src/ReaderThemeSupportFeatures.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@ final class ReaderThemeSupportFeatures implements Service, Registerable {
*/
const KEY_CUSTOM_SPACING_SIZE = 'customSpacingSize';

/**
* Key for `defaultSpacingSizes` boolean in theme.json (v3).
*
* @var string
*/
const KEY_DEFAULT_SPACING_SIZES = 'defaultSpacingSizes';

/**
* Action fired when the cached primary_theme_support should be updated.
*
Expand Down Expand Up @@ -496,10 +503,23 @@ private function print_editor_gradient_presets_styles( array $gradient_presets )
* Print spacing sizes custom properties.
*/
private function print_spacing_sizes_custom_properties() {
$custom_properties = [];
$spacing_sizes = wp_get_global_settings( [ self::KEY_SPACING, self::KEY_SPACING_SIZES ], self::KEY_THEME );
$is_wp_generating_spacing_sizes = 0 !== wp_get_global_settings( [ self::KEY_SPACING, self::KEY_SPACING_SCALE ], self::KEY_THEME )[ self::KEY_STEPS ];
$custom_spacing_size = wp_get_global_settings( [ self::KEY_SPACING, self::KEY_CUSTOM_SPACING_SIZE ], self::KEY_THEME );
$custom_properties = [];
$spacing = wp_get_global_settings( [ self::KEY_SPACING ], self::KEY_THEME );
$spacing_sizes = $spacing[ self::KEY_SPACING_SIZES ] ?? [];
$custom_spacing_size = $spacing[ self::KEY_CUSTOM_SPACING_SIZE ] ?? false;
$spacing_scale = $spacing[ self::KEY_SPACING_SCALE ] ?? [];

/**
* By default check for `defaultSpacingSizes` boolean introduced in theme.json (v3)
* and if it's false, then check for `steps` in `spacingScale` which is v2 default.
*
* @see <https://github.com/WordPress/gutenberg/pull/58409#issuecomment-2078077477>.
*/
$is_wp_generating_spacing_sizes = $spacing[ self::KEY_DEFAULT_SPACING_SIZES ] ?? false;

if ( array_key_exists( self::KEY_STEPS, $spacing_scale ) ) {
$is_wp_generating_spacing_sizes = 0 !== $spacing_scale[ self::KEY_STEPS ];
}

if ( ! $is_wp_generating_spacing_sizes && $custom_spacing_size ) {
if ( isset( $spacing_sizes[ self::KEY_THEME ] ) ) {
Expand Down
Loading