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

Varia: check for $post before adding admin body classes #8556

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

ramonjd
Copy link
Member

@ramonjd ramonjd commented Dec 31, 2024

Changes proposed in this Pull Request:

Check for $post before adding admin body classes. This prevents a PHP warning on the widgets screen where there is no post.

<b>Warning</b>: Attempt to read property "ID" on null in <b>[...]wp-content/themes/pub/varia/inc/wpcom.php</b> on line <b>150</b><br>

The error also causes a UI anomaly in the admin sidebar:

Screenshot 2024-12-31 at 1 51 59 pm

Testing:

Note, the PHP warning does not appear in production, probably because these warnings are suppressed.

Activate Varia or a Varia child theme like Rockfield.

Sandbox a test site and navigate to /wp-admin/widgets.php

The above error should not show and the nav should appear normal.

Related issue(s):

… warning on the widgets screen where there is no post.
Copy link
Contributor

Preview changes

I've detected changes to the following themes in this PR: Varia.
You can preview these changes by following the links below:

I will update this comment with the latest preview links as you push more changes to this PR.

Note

The preview sites are created using WordPress Playground. You can add content, edit settings, and test the themes as you would on a real site, but please note that changes are not saved between sessions.

Copy link
Contributor

Theme-Check results

varia: There are required changes on the theme ❌.

❎ REQUIRED

  • Found a Customizer setting called 'color_a11y_warning' ) in inc/wpcom.php that did not have a sanitization callback function. Every call to the add_setting() method needs to have a sanitization callback function passed. Line 66: $wp_customize->add_setting( 'color_a11y_warning' );
  • bump-version-numbers.sh rebuild-child-themes.sh Shell script file found. This file must not be in the production version of the theme.
  • Tested up to: is missing from your style.css header. Also, this should be numbers only, so 5.0 and not WP 5.0
  • Requires PHP: is missing from your style.css header.
💡 RECOMMENDED (6)
  • No reference to register_block_pattern was found in the theme. Theme authors are encouraged to implement custom block patterns as a transition to block themes.
  • No reference to register_block_style was found in the theme. Theme authors are encouraged to implement new block styles as a transition to block themes.
  • .wp-caption css class is recommended in your theme css.
  • .wp-caption-text css class is recommended in your theme css.
  • No reference to add_theme_support( "custom-header", $args ) was found in the theme. It is recommended that the theme implement this functionality if using an image for the header.
  • No reference to add_theme_support( "custom-background", $args ) was found in the theme. If the theme uses background images or solid colors for the background, then it is recommended that the theme implement this functionality.
⚠️ WARNING (13)
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors-css-variables.php. Function __, with the arguments 'Background Color'. Line 22: __( 'Background Color' )
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors-css-variables.php. Function __, with the arguments 'Foreground Color'. Line 38: __( 'Foreground Color' )
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors-css-variables.php. Function __, with the arguments 'Primary Color'. Line 54: __( 'Primary Color' )
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors-css-variables.php. Function __, with the arguments 'Secondary Color'. Line 70: __( 'Secondary Color' )
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors-css-variables.php. Function __, with the arguments 'Tertiary Color'. Line 86: __( 'Tertiary Color' )
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors.php. Function __, with the arguments 'Background Color'. Line 90: ), __( 'Background Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors.php. Function __, with the arguments 'Link Color'. Line 214: ), __( 'Link Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors.php. Function __, with the arguments 'Text Color'. Line 364: ), __( 'Text Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-colors.php. Function __, with the arguments 'Secondary Color'. Line 380: ), __( 'Secondary Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-editor-colors.php. Function __, with the arguments 'Background Color'. Line 72: ), __( 'Background Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-editor-colors.php. Function __, with the arguments 'Link Color'. Line 150: ), __( 'Link Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-editor-colors.php. Function __, with the arguments 'Text Color'. Line 227: ), __( 'Text Color' ) );
  • Found a translation function that is missing a text-domain in the file inc/wpcom-editor-colors.php. Function __, with the arguments 'Secondary Color'. Line 243: ), __( 'Secondary Color' ) );

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant