[wp-hackers] Creating objects within a plug-in

Williams Phillip phil.m.williams at gmail.com
Fri Jan 11 17:44:43 GMT 2008


I am still new enough to PHP so I am not familiar with how it  
serializes objects, but that might be it. However, let me see if I  
can walk through the use case a little better in case there is  
another solution.

The user will go to an admin page to setup a specific filter for  
archives. They will specify the options such as the type of archive  
links to display, the categories to include/exclude, etc. She then  
wants to use the filter in a sidebar to display archive links. She  
would then need to edit the sidebar template and include something like:

global $all_filter;
$all_filter->get_filtered_archives();

on the page at the desired location.

Presently she would add the following at the beginning of my  
functions.php, say:

$all_filter = new arch_filter;
$all_filter->opt['type'] ='monthly';
$all_filter->opt['exclude'] = get_cat_ID('News').",".implode(",",  
get_career_categories());
$all_filter->opt['show_post_count'] = true;

I am trying avoid the user having to instantiate the filters in this  
manner and would rather the filters be managed through admin screens.  
So the question is where does the $all_filter object first get  
instantiated once the admin screens have been implemented.

Phil
phil.m.williams at gmail.com




On Jan 11, 2008, at 10:54 AM, Burobjorn wrote:

> Not sure if I understand the question correctly, but perhaps you're  
> looking at serializing objects?
>
> grtz
> BjornW
>
>
> Williams Phillip wrote:
>> I am developing a plug-in that will allow archive links and pages  
>> to be easily filtered to exclude or include specific categories.  
>> It consists of a filter class that encapsulates the functionality  
>> of wp_get_archives() with the additional subqueries to limit the  
>> returned posts to the specified categories.
>> Currently, I instantiate various archive filter objects at the  
>> beginning of the functions.php file. I can then use them on any  
>> page by declaring the objects as global. I would like to be able  
>> to go the next step and build an admin screen that will allow a  
>> user to configure any number of archive filters for use on within  
>> templates. I am planning on either using the options route or  
>> creating my own table structure to manage the filter settings.
>> My question is this. How would a filter object be instantiated  
>> that could then be used within another PHP file?
>> Phil
>> phil.m.williams at gmail.com
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
>
> -- 
>
> met vriendelijke groet,
> Bjorn Wijers
>
> * b u r o b j o r n .nl *
> digitaal vakmanschap | digital craftsmanship
>
> Concordiastraat 68-126
> 3551 EM Utrecht
> The Netherlands
>
> phone: +31 30 2444 101
> http://www.burobjorn.nl
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list