| | 241 | |
| | 242 | // Set the parent, if we're a child theme. |
| | 243 | if ( $this->template != $this->stylesheet ) { |
| | 244 | // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out. |
| | 245 | if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) { |
| | 246 | $_child->parent = null; |
| | 247 | $_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) ); |
| | 248 | $_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) ); |
| | 249 | // The two themes actually reference each other with the Template header. |
| | 250 | if ( $_child->stylesheet == $this->template ) { |
| | 251 | $this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) ); |
| | 252 | $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); |
| | 253 | } |
| | 254 | |
| | 255 | return; |
| | 256 | } |
| | 257 | // Set the parent. Pass the current instance so we can do the crazy checks above and assess errors. |
| | 258 | $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this ); |
| | 259 | } |
| 261 | | // Set the parent, if we're a child theme. |
| 262 | | if ( $this->template != $this->stylesheet ) { |
| 263 | | // If we are a parent, then there is a problem. Only two generations allowed! Cancel things out. |
| 264 | | if ( is_a( $_child, 'WP_Theme' ) && $_child->template == $this->stylesheet ) { |
| 265 | | $_child->parent = null; |
| 266 | | $_child->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $_child->template ) ); |
| 267 | | $_child->cache_add( 'theme', array( 'headers' => $_child->headers, 'errors' => $_child->errors, 'stylesheet' => $_child->stylesheet, 'template' => $_child->template ) ); |
| 268 | | // The two themes actually reference each other with the Template header. |
| 269 | | if ( $_child->stylesheet == $this->template ) { |
| 270 | | $this->errors = new WP_Error( 'theme_parent_invalid', sprintf( __( 'The "%s" theme is not a valid parent theme.' ), $this->template ) ); |
| 271 | | $this->cache_add( 'theme', array( 'headers' => $this->headers, 'errors' => $this->errors, 'stylesheet' => $this->stylesheet, 'template' => $this->template ) ); |
| 272 | | } |
| 273 | | return; |
| 274 | | } |
| 275 | | // Set the parent. Pass the current instance so we can do the crazy checks above and assess errors. |
| 276 | | $this->parent = new WP_Theme( $this->template, isset( $theme_root_template ) ? $theme_root_template : $this->theme_root, $this ); |
| 277 | | } |
| 278 | | |