WordPress.org

Make WordPress Core

Ticket #40820: 40820_fix_proposal.diff

File 40820_fix_proposal.diff, 840 bytes (added by davilera, 3 years ago)

Adds an extra check to make sure that the parent theme of a child theme is not the child theme itself.

  • wp-includes/class-wp-theme.php

     
    267267                        }
    268268                }
    269269
     270                if ( ! $this->template && $this->stylesheet === $this->headers['Template']) {
     271                        $this->errors = new WP_Error( 'child_theme_invalid', __( 'The theme defines itself as its parent theme. Please fix the "Template" header.' ) );
     272                        $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet ) );
     273                        return;
     274                }//end if
     275
    270276                // (If template is set from cache [and there are no errors], we know it's good.)
    271277                if ( ! $this->template && ! ( $this->template = $this->headers['Template'] ) ) {
    272278                        $this->template = $this->stylesheet;