Auto Add Page on Theme Select

View: New views
4 Messages — Rating Filter:   Alert me  

Auto Add Page on Theme Select

by Steve Bruner [SlipFire] :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I'm creating a theme and would like a Page to be auto created when the theme
is selected.  Would obviously check to make sure the page doesn't
pre-exist.  Tried using the switch_theme hook but it seems that it won't
execute in functions.php, only a plugin.

Any suggestions would be appreciated.

Thanks
Steve
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Auto Add Page on Theme Select

by Peter Westwood :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On 9 Jun 2009, at 19:11, Steve Bruner [SlipFire] wrote:

> Hi All,
>
> I'm creating a theme and would like a Page to be auto created when  
> the theme
> is selected.  Would obviously check to make sure the page doesn't
> pre-exist.  Tried using the switch_theme hook but it seems that it  
> won't
> execute in functions.php, only a plugin.
>

The switch_theme action will run when the previous theme is still  
effectively active as during the page load the switch happens the old  
themes functions.php is still included.

You best bet is to do something on the init action for now.

But it would be good to open a ticket in trac requesting a way for  
this to be achieved.

I think we need an activation hook for the theme which runs on the  
first page load that a theme is active for in the admin

westi
--
Peter Westwood
http://blog.ftwr.co.uk | http://westi.wordpress.com
C53C F8FC 8796 8508 88D6 C950 54F4 5DCD A834 01C5

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Auto Add Page on Theme Select

by Joost de Valk-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Peter Westwood wrote:

> On 9 Jun 2009, at 19:11, Steve Bruner [SlipFire] wrote:
>
>> Hi All,
>>
>> I'm creating a theme and would like a Page to be auto created when
>> the theme
>> is selected.  Would obviously check to make sure the page doesn't
>> pre-exist.  Tried using the switch_theme hook but it seems that it won't
>> execute in functions.php, only a plugin.
>
> The switch_theme action will run when the previous theme is still
> effectively active as during the page load the switch happens the old
> themes functions.php is still included.
>
> You best bet is to do something on the init action for now.
>
> But it would be good to open a ticket in trac requesting a way for
> this to be achieved.
>
> I think we need an activation hook for the theme which runs on the
> first page load that a theme is active for in the admin
>
> westi
+1 for that, that would make a lot of stuff easier in theme settings.

--
*Joost de Valk*
SEO & Web Development (Magento & WordPress)
OrangeValley <http://www.orangevalley.nl> & Yoast <http://yoast.com>
E: joost@... <mailto:joost@...> -
joost@... <mailto:joost@...>
T: +31624555808 | @yoast <http://twitter.com/yoast> on Twitter
W: http://yoast.com/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: Auto Add Page on Theme Select

by Glenn Ansley :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In the meantime, it may help to parse the GET arguments for
action=activate and template=[yourtemplate].
Hook a function to the init like Westi suggested and do your checks on
the GET string at that point.

Glenn Ansley
http://fullthrottledevelopment.com
http://twitter.com/full_throttle
http://twitter.com/glennansley

On Tue, Jun 9, 2009 at 2:40 PM, Joost de Valk<joost@...> wrote:

> Peter Westwood wrote:
>>
>> On 9 Jun 2009, at 19:11, Steve Bruner [SlipFire] wrote:
>>
>>> Hi All,
>>>
>>> I'm creating a theme and would like a Page to be auto created when the
>>> theme
>>> is selected.  Would obviously check to make sure the page doesn't
>>> pre-exist.  Tried using the switch_theme hook but it seems that it won't
>>> execute in functions.php, only a plugin.
>>
>> The switch_theme action will run when the previous theme is still
>> effectively active as during the page load the switch happens the old themes
>> functions.php is still included.
>>
>> You best bet is to do something on the init action for now.
>>
>> But it would be good to open a ticket in trac requesting a way for this to
>> be achieved.
>>
>> I think we need an activation hook for the theme which runs on the first
>> page load that a theme is active for in the admin
>>
>> westi
>
> +1 for that, that would make a lot of stuff easier in theme settings.
>
> --
> *Joost de Valk*
> SEO & Web Development (Magento & WordPress)
> OrangeValley <http://www.orangevalley.nl> & Yoast <http://yoast.com>
> E: joost@... <mailto:joost@...> - joost@...
> <mailto:joost@...>
> T: +31624555808 | @yoast <http://twitter.com/yoast> on Twitter
> W: http://yoast.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers@...
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers