[wp-trac] [WordPress Trac] #59507: global-styles-and-settings.php in wp_theme_has_theme_json

WordPress Trac noreply at wordpress.org
Fri Sep 29 18:45:19 UTC 2023


#59507: global-styles-and-settings.php in wp_theme_has_theme_json
-------------------------------+-----------------------------
 Reporter:  cocasio45          |      Owner:  (none)
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Themes             |    Version:  6.3.1
 Severity:  normal             |   Keywords:  needs-patch
  Focuses:  php-compatibility  |
-------------------------------+-----------------------------
 Wordpress 6.3.1 , php 8.1.23

 {{{#!php
 <?php
 function wp_theme_has_theme_json() {
         static $theme_has_support = array();

         $stylesheet = get_stylesheet();

         if (
                 isset( $theme_has_support[ $stylesheet ] ) &&
                 /*
                  * Ignore static cache when the development mode is set to
 'theme', to avoid interfering with
                  * the theme developer's workflow.
                  */
                 ! wp_is_development_mode( 'theme' )
         ) {
                 return $theme_has_support[ $stylesheet ];
         }

         $stylesheet_directory = get_stylesheet_directory();
         $template_directory   = get_template_directory();

         // This is the same as get_theme_file_path(), which isn't
 available in load-styles.php context
         if ( $stylesheet_directory !== $template_directory && file_exists(
 $stylesheet_directory . '/theme.json' ) ) {
                 $path = $stylesheet_directory . '/theme.json';
         } else {
                 $path = $template_directory . '/theme.json';
         }

         /** This filter is documented in wp-includes/link-template.php */
         $path = apply_filters( 'theme_file_path', $path, 'theme.json' );

         /* ADD THIS SECTION */
         if( ! $path ) {
                 $theme_has_support[ $stylesheet ] = false;
                 return false;
         }
          /* END OF SECTION */

         $theme_has_support[ $stylesheet ] = file_exists( $path );
         /* file_exists THROW DEPRECATION ERROR WHEN RECIEVE NULL */

         return $theme_has_support[ $stylesheet ];
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59507>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list