The oop tag has no wiki summary.
0
votes
1answer
43 views
Why can wordpress not find the actions I add in my constructor?
I have a theme which has a page to display a keyword taxonomy called taxonomy-keyword.php. From this page I instantiate a sort of ViewModel called KeywordPage. It looks like this:
namespace ...
0
votes
3answers
72 views
Need oop for wordpress theme? [duplicate]
I know how to program in PHP, but I don't know OOPS(Object Oriented Programming). Is it better to make themes in OOPS(Object Oriented Programming) or with normal coding? Is it better for performances, ...
0
votes
1answer
73 views
Plugin won't activate, fatal error (widget class not found)
I've been putting together a simple WordPress plugin that employs a sidebar widget and shortcode. One user has reported the following error when trying to activate the plugin on their local WP ...
-1
votes
2answers
53 views
Hooks are not executing
Based on my understanding of hooks, you create a hook, by doing do_action('hook_name'); then add something to said hook and call the method where you want it to do the hook, so:
public function ...
1
vote
1answer
38 views
Create hooks based on an array of hook names?
I have this idea where I would create a class that would take in a set of hook names then create them, for me to use when ever, and where ever.
Currently the way to create a hook is we do something ...
1
vote
1answer
42 views
Advice on plugin structure
I'm looking for a bit of advice on structuring the classes within a plugin I'm writing for my charity website.
At the moment the plugin is OOP based with a single class. However, its becoming quite ...
-3
votes
1answer
47 views
$_html is empty when var dumped
So I have run across a bizzar issue, in which I know is working as i expect it to in terms of the array values, yet the _html variable returns something like string(29) " " which to my knowledge ...
3
votes
2answers
77 views
How do I use add_action from a class method?
For some context, we're building an activation system for new users of an app using WordPress as a framework. We've got a plugin driving most of our interactions, where all of this code resides.
When ...
5
votes
2answers
208 views
What is the correct way to build a widget using OOP
I am working on a simple search form widget, with a built in autocomplete capability (You can download the current version here). The plugin is working, but I am currently rewriting all the code using ...
0
votes
1answer
41 views
Keeping Objects in Memory
I have built a WordPress plugin using classes. Each project class is created for a specific user. I want to do three things:
Keep the project object in memory for that user between his or her ...
0
votes
1answer
71 views
How do I create Widget within plugin that uses its own class?
I wrote WordPress plugin and want to include 2 extra Widgets with it...
if( !class_exists('plugin_name') ) {
class plugin_name {
// plugin code
}
}
// include widgets code
...
0
votes
1answer
151 views
Check if a class exists within a method
I'm new to OOP and I'm writing my first plugin. I want to check if the Facebook plugin has already been activated. If so, I want to skip some code:
class MyClass {
...
function fb_js_sdk_setup() ...
0
votes
2answers
88 views
Get options from database using php class
I want to make a php class that gets an option from the wp database (which is an array of options) and be able to call this class with the name of the option and the class to return the options value.
...
0
votes
2answers
216 views
PHP error with shortcode handler from a class
Currently i am using the following generic flow for adding the shortcode for a plugin.
class MyPlugin {
private $myvar;
function baztag_func() {
print $this->myvar;
...
1
vote
0answers
29 views
remove class from code [closed]
How can I remove the class from the following code and use it without the functions. I tried removing the functions and class and add it in functions.php but it did not work.
class someclass {
...
3
votes
2answers
618 views
Using attachment_fields_to_edit filter inside plugin class
I'm writing a plugin using OOP. I realise that filters and action hooks need to be placed inside the constructor method in WordPress like so:
add_action('wp_enqueue_scripts', array($this, ...
12
votes
2answers
446 views
How to remove a filter that is an anonymous object?
In my functions.php file I would like to remove the below filter, but I'm not sure how to do it since it's in a class. What should remove_filter() look like?
add_filter('comments_array',array( ...
0
votes
1answer
168 views
OOP Plugin: Where should I place the action hooks in the class?
Where in my admin class should I place the action hooks for adding css, scripts and the add menu page?
In the __construct? Or should they be placed in a method?
1
vote
2answers
282 views
uml diagrams of wordpess
Where can I find UML diagrams of WordPress (Data flow diagrams,State diagram, component diagram, use case diagram, deployment diagram)?
7
votes
2answers
940 views
Why do some hooks not work inside class context?
I'm pretty stumped on this one. I'm using add_action inside my plugin class to do certain things- add scripts & styles to the head, wp_ajax, etc. Here's the actions, in the __construct:
function ...
2
votes
1answer
422 views
Using a plugin class inside a template
I am writing a plugin to send an invitation to a friend which opens up a form when a link is clicked. I encapsulated all the functions in class by following the code given in the Report Broken Video ...
3
votes
3answers
161 views
scheduled event not getting executed
class checkPost{
function __construct()
{
if ( !wp_next_scheduled('my_task_hook') ) {
wp_schedule_event( time(), 'hourly', 'my_task_hook' ); // hourly, daily and twicedaily
}
...
1
vote
2answers
159 views
Applying OO patterns and principles to plugin development
I'm busy writing my first plugin, using PHP 5.3.5. I come from a C# environment, and I must say I'm more than happy with the level of support for good, solid OOP techniques in PHP. However, I'm a ...
1
vote
2answers
323 views
Check to see if page exists problems
I've created a class to dynamically create pages. I'm checking to see if the page exists by comparing the new page's title to post_name. The comparison seems to work ok, but even if there is a match ...
7
votes
1answer
898 views
Using classes instead of global functions in functions.php
In many themes I've seen (including TwentyEleven) and in the examples I've found online, when building the functions.php file for a theme all functionality is declared in a global scope. To clarify, ...
15
votes
5answers
862 views
Should all plugins be encapsulated in a Class?
When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts?
Does using classes create performance overheads for PHP?
If there is a performance hit, ...
5
votes
1answer
2k views
Plugin Form Submission Best Practice
I have done a lot of researching and haven't found quite what I am looking for, so I am hoping that I can be pointed in the right direction.
I am developing an Events plugin that will book a ticket ...
4
votes
1answer
394 views
Registering Class methods as hook callbacks
I'm not sure if I have done this correctly.
As I understand it:
if I have a class foo and a static method bar I can register that as the callback by passing the array array("foo","bar") as the ...
4
votes
2answers
990 views
Does an activated plugin automatically mean its methods are available to other WP functions?
I made a WordPress plugin like this:
Class MY_CLASS {
//codes
}
Global $myclass;
$myclass = New MY_CLASS ();
After installed and activated the plugin, can I use this class in other plugins without ...
3
votes
3answers
930 views
Plugin Architecture/Design Pattern - is better to use a private Observer/Mediator Pattern for plugin subclasses or WP add_action?
I'm coding a very complex plugin which it's organized as a parent "container" class and several subclasses, where each subclass is an optional/mandatory element which usually (but not always) maps to ...
6
votes
2answers
2k views
Will WordPress become completely OOP?
Is there any information about WordPress becoming completely OOP in future versions?
1
vote
2answers
480 views
problem with implementing widget via the_content()
hey guys,
I really need you help with this one.
I'm using the subscribe2 Plugin (for email subscriptions).
I want to show the signup form as a widget. The plugin author recommends doing it the ...
1
vote
1answer
310 views
PHP5, Inheritance, Singleton - action & filter hook limitations
I'm currently working on a plugin, which uses the builtin cron functionality of wordpress.
Instead of using PHP4, I want to use PHP5 with inheritance and the singleton design pattern. I run in some ...
1
vote
3answers
363 views
Ajax with OOP doesn't work
I have a small script within theme's functions.php file that uses ajax, principle like this:
add_action('admin_head', 'rw_script');
function rw_script() {
echo '
<script ...
21
votes
6answers
2k views
Using OOP in themes
I see a lot of plugins making use of object-oriented coding when there isn't really necessary.
But what's even worse is that theme developers are starting to do the same thing. Commercial themes and ...

