Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#24953 closed enhancement (wontfix)

Child theme functions.php only

Reported by: wikicms's profile wikicms Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Themes Keywords: close
Focuses: Cc:

Description

Sometimes needed to completely disable or full rewriting the file functions.php parent theme. But this is impossible. Renaming or deleting pointless after updating themes all come back.

I believe that we can introduce a constant defined in the file functions.php child theme, which will properly disable functions.php parent theme.

Example:
wp-content/themes/theme-child/functions.php

<?php
define( 'CHILD_THEME_ONLY', true );

And little changes in wp-setting.php:

if ( ! defined( 'WP_INSTALLING' ) || 'wp-activate.php' === $pagenow ) {
	if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
		include( STYLESHEETPATH . '/functions.php' );
	if ( ! defined('CHILD_THEME_ONLY') ) {
		if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
			include( TEMPLATEPATH . '/functions.php' );
	}
}

Sorry for my English and posting code here. I don't know how to create patches.

Change History (6)

#1 @knutsp
12 years ago

  • Cc knut@… added

#2 follow-up: @channeleaton
12 years ago

  • Cc channeleaton added

Could you provide a more detailed use case? At this point I don't see why you couldn't just unhook or overload functions.

#3 in reply to: ↑ 2 @nacin
12 years ago

Replying to channeleaton:

Could you provide a more detailed use case? At this point I don't see why you couldn't just unhook or overload functions.

Not every theme is written to become a parent theme. That might mean that some functions are not unhookable or overloadable.

I think the issue here is that this would make the child theme very fragile, and too frail for updates to the parent theme. If the parent theme isn't coded in such a way to be friendly to child themes, then maybe it shouldn't be child-themed. For this, suggest wontfix.

#4 follow-up: @wikicms
12 years ago

Thanks for replies.

I downloaded some new themes http://wordpress.org/themes/browse/new/ to check and in many themes used not overloaded or not unhookable functions. Often used require or include statements.

Another way yet - if the community is not ready to support this idea, please pay attention to the developers of themes on this issue, and urge them to apply only easily modifiable code.

This would simplify the life of a "child themes" developers.

PS Child themes avoid banality, both in design and in the logic of behavior. I would very much like to be able to completely change both. Thank you.

Last edited 12 years ago by wikicms (previous) (diff)

#5 in reply to: ↑ 4 @obenland
12 years ago

  • Keywords close added; dev-feedback removed

Replying to wikicms:

I downloaded some new themes http://wordpress.org/themes/browse/new/ to check and in many themes used not overloaded or not unhookable functions. Often used require or include statements.

Require and include statements don't necessarily mean that the functions in those files are not overridable. See the default themes for an example.


Another way yet - if the community is not ready to support this idea, please pay attention to the developers of themes on this issue, and urge them to apply only easily modifiable code.

While it is not a requirement to wrap all code in callbacks, the Theme Review Team usually does a good job in reminding developers to do so.


PS Child themes avoid banality, both in design and in the logic of behavior. I would very much like to be able to completely change both.

In a case where you want to completely change the parent theme, maybe creating a child theme is not the best idea?

#6 @nacin
12 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.