[theme-reviewers] Child theme question

Thomas Usborne hello at edge22.com
Fri May 23 02:14:05 UTC 2014


They're using the 'default' argument in the add_setting function:

 

// Add Header Layout setting

$wp_customize->add_setting(

                // ID

                'generate_settings[header_layout_setting]',

                // Arguments array

                array(

                                'default' => 'fluid-header',

                                'type' => 'option'

                )

);

 

Using add_filter, the new options took place while viewing the live site, but when I went into the Customizer, the default argument above was overriding the filtered defaults.

 

Tom

 

From: theme-reviewers [mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Chip Bennett
Sent: Thursday, May 22, 2014 7:07 PM
To: [theme-reviewers]
Subject: Re: [theme-reviewers] Child theme question

 

Why isn't the customizer using the defined/filterable defaults in the parent theme?

On May 22, 2014 10:04 PM, "Thomas Usborne" <hello at edge22.com> wrote:

So I went ahead and tried using filters, and while it worked on the live site, it didn't work while in the Customize screen, as those options are using the defaults set in the customizer.php file.

 

However, would this be acceptable?

 

https://gist.github.com/proframework/2100e308050c3aa00a94 

 

Of course I could do it without the admin notice, but I think giving the user an option to import the child theme settings is a good idea in case they make changes to the child theme and don't want to lose those changes if another theme is activated and they switch back.

 

Thanks!

Tom

 

From: theme-reviewers [mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Simon Prosser
Sent: Thursday, May 22, 2014 6:06 PM
To: Discussion list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Child theme question

 

file_get_contents == badness. And anyway file_get_contents with a remote url would be banned on just about every shared host out there.

 

On 23 May 2014 01:58, Chip Bennett <chip at chipbennett.net> wrote:

Given that you should have only one single option (wp_options db entry), I don't think that gist would be the way to go.

On May 22, 2014 8:46 PM, "Thomas Usborne" <hello at edge22.com> wrote:

Thanks for the info – that definitely looks like the best way to go about it.

 

Alternatively, would something like this be acceptable?

 

https://gist.github.com/proframework/a37e928462f72d674fd2 

 

Thanks again for all the help – I really appreciate it.

Tom

 

From: theme-reviewers [mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Chip Bennett
Sent: Thursday, May 22, 2014 5:10 PM
To: [theme-reviewers]
Subject: Re: [theme-reviewers] Child theme question

 

The parent theme will define defaults for each option. Put the defaults in an array, wrap it in a function (eg themeslug_get_defaults ()), and then pass the returned output through a custom filter. For example:

function themeslug_get_defaults () {
    $defaults = array( // values here );
    return apply_filters ( 'themeslug_option_defaults', $defaults );
}

Then, you can just add a filter in the child theme.

On May 22, 2014 7:02 PM, "Thomas Usborne" <hello at edge22.com> wrote:

Thanks for getting back to me.

 

Sorry for not being more specific.

 

The options are already present in the parent theme – so the child theme won't necessarily be adding more options to the customize panel.

 

The child theme will simply be changing some of the pre-existing parent theme options (sidebar layout for example).

 

On theme activation I know I can import settings from a .json file, but wanted to know if this was frowned upon for some reason?

 

I wouldn't want to automatically import the .json file in case they made changes, changed themes and changed back – wouldn't want to overwrite their options. However, I could add a notice of some sort with a link to initiate the import of settings from the .json file.

 

Thanks again!

Tom

 

From: theme-reviewers [mailto:theme-reviewers-bounces at lists.wordpress.org] On Behalf Of Otto
Sent: Thursday, May 22, 2014 3:55 PM
To: Discussion list for WordPress theme reviewers.
Subject: Re: [theme-reviewers] Child theme question

 

Hard to say without more specific details. But the easy way is for the parent theme to be expandable through the use of actions and filters.

 

So for example, in the parent, in the function where it's adding the customize stuff, you could do_action('themename_customize_whatever'); and then the child could add it's own function to do more stuff, and hook it into that action.

 

Same for any settings or options or arrays of "stuff". Run them through an apply_filters call in the parent, and then the child can use that to modify them before they make it wherever they're going.

 




-Otto

 

On Thu, May 22, 2014 at 5:34 PM, Thomas Usborne <hello at edge22.com> wrote:

Hi everyone, hope I'm doing this right!

 

I recently had my first theme added to WordPress.org.

 

I now want to begin releasing some child themes for it, but have a question about how to go about doing that.

 

The child themes will obviously have some CSS etc.. but it will also have some options changed in the "Customize" section of the parent theme.

 

Would it be acceptible to display a message to the user upon activation which would allow them to click a link to import some of the options into the parent theme?

 

If not, what's the best way for me to go about this?

 

Thanks!

Tom

 


_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers

 


_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers


_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers


_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers





 

-- 
My Blog: http://pross.org.uk/
Plugins : http://pross.org.uk/plugins/
Themes: http://wordpress.org/extend/themes/profile/pross 


_______________________________________________
theme-reviewers mailing list
theme-reviewers at lists.wordpress.org
http://lists.wordpress.org/mailman/listinfo/theme-reviewers

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wordpress.org/pipermail/theme-reviewers/attachments/20140522/36357bd1/attachment-0001.html>


More information about the theme-reviewers mailing list