[wp-hackers] Class conflicts with plugin frameworks

Philip Walton philip at philipwalton.com
Thu Apr 28 02:59:05 UTC 2011


Thanks Dion, that definitely points me in the right direction.

On 4/27/11 7:00 PM, Dion Hulse (dd32) wrote:
> The best way is to just do a
> if ( ! class_exists('myclass') ) include framework.php.
>
> of course, if you only want to include the latest version, i'd do something
> such as :(ie. this copy of hte plugin includes version 31 of the framework)
> in global scope upon plugin inclusion:
> $GLOALS[mvcversion] = max (   $GLOALS[mvcversion], 31 )
> add_action plugins_loaded:
>      if ( 31 ==   $GLOALS[mvcversion]&&   ! class_exists('myclass')  ) //This
> plugin has the latest version, and it's not already included
>           include framework.php.
>
> That does require you instantiate the rest of the code later, but thats a
> good thing to do regardless. based on the above code, that could be hooked
> to plugins_loaded early, and a hook on plugins_loaded late could include the
> main class files (ie. the files which rely on the framework). This turns the
> main plugin file into a meer bootstrap file for setting up the environment.
> I'd probably put a activation callback in there too to check server
> requirements/etc too
>
> On 28 April 2011 10:24, Philip Walton<philip at philipwalton.com>  wrote:
>
>> Jonathan, that IS what I'm wanting to do. Perhaps you can point to me to
>> another one of your plugins so I can compare and see exactly what you're
>> suggesting.
>>
>>
>>
>> On 4/27/11 5:19 PM, Jonathon Byrd wrote:
>>
>>> I didn't prefix anything that dealt with the mvc framework as I use these
>>> functions throughout all my plugins. It's just the custom plugin functions
>>> that I prefix.
>>>
>>> In every plugin exists my bootstrap file which preloads the mvc framework.
>>> That's what you were wanting to do, no?
>>>
>>> Sincerely,
>>>
>>> Jonathon Byrd | Partner | Senior Software Engineer
>>> 5 Twenty Studios, LLC
>>>
>>> C: (360) 747-7401 | O: (503) 268-1177 | F: (954) 867-1177
>>> jon at 5twentystudios.com | www.5TwentyStudios.com<
>>> http://www.5twentystudios.com/>
>>>
>>>
>>>
>>> On Wed, Apr 27, 2011 at 5:06 PM, Philip Walton<philip at philipwalton.com
>>>> wrote:
>>>   Yeah, see, prefixing everything manually is exactly what I don't want to
>>>> do, perhaps it's the only way, but I'm hoping to find a better solution.
>>>>
>>>> I was thinking it could be possible to dynamically prefix the classes in
>>>> some sort of init() function that each plugin calls, but I haven't
>>>> experimented with this at all.
>>>>
>>>>
>>>>
>>>> On 4/27/11 3:45 PM, Jonathon Byrd wrote:
>>>>
>>>>   prefixing every function, constant and global with the same three chars
>>>>> throughout each plugin has eliminated 99% of conflicts.
>>>>>
>>>>>   _______________________________________________
>>>> wp-hackers mailing list
>>>> wp-hackers at lists.automattic.com
>>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>>
>>>>   _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
> _______________________________________________
> 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