The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
513 views

Wrapper class: How to get rid of call_user_func_array() warning?

I have several installations of wordpress and now im trying to create my own small framework so I can create and maintain my themes more efficiently. What I would like to do is to have a wrapper for ...
2
votes
1answer
29 views

Creating a menu page in a Object Oriented developed plugin

I am trying for the first time to build a plugin for Wordpress following OOP way. I am having some problems while trying to create a submenu page using add_users_page() function. Here is a simple ...
0
votes
0answers
37 views

How make modular WP plugin based on OOP?

For example I have "my-plugin" plugin created using class: class My_Plugin { public function __construct() { } /** * Other code where I creating plugins admin pagec etc. */ } ...
0
votes
1answer
39 views

OOP and WordPress shortcode

I tried to add a shortcode this way class MyPlugin { function __construct() { $this->make_shortcode(); } function ShowMsg($cls, $lst4) { $data = ...
1
vote
1answer
37 views

Plugin activation hook in an abstract class

I would like to create a common abstract class to use for every WordPress plugin that I develop. As a part of the class' initiation process, I would like to fire the activation hook which calls an ...
0
votes
1answer
29 views

A question about add_action()

I was following this ( http://codex.wordpress.org/Plugin_API ) tut on codex. The part where a class is created and is called in add_action. No argument was passed to emailer::send ? Why? It was ...
1
vote
1answer
92 views

How to structure a plugin into multiple files using classes?

I am writing my first simple plugin from scratch so I'm looking for a bit of advice on structuring the classes within the plugin. I encapsulated some basic functions in a class in the main plugin file ...
1
vote
1answer
42 views

How do I extend one plugin I'm writing with another I'm writing using classes?

I have a set of plugins that do different things. I'm wanting to write a plugin with a class I can extend in each of my custom plugins to meet a common goal. In my "socket" plugin I have something ...
1
vote
2answers
87 views

Conditional tags inside a class

I have a couple of functions that I now combined in a class. The reason for that was that all these functions go towards one goal, and it is more appropriate way to use the globals between these ...
0
votes
3answers
89 views

plugin class inheritance. cannot change variable

I guess I have a problem understanding inheritance. I have 4 classes like so; class FOO extends WP_Widget { protected $pluginOptions; function __construct() { $this->pluginOptions ...
0
votes
0answers
9 views

Custom class file

I have created a class for custom post-type, taxonomy and meta boxes. I made a method called form-elements and within that I have included HTML form elements. I need to share this method with other ...
0
votes
1answer
157 views

How To Remove The Filter That Adds JetPack Related Content To Dom

I am trying to remove the filter in JetPack's Related Posts module that adds the element to the DOM that the module's JavaScript populates with the related posts. Once I remove it, I can achieve my ...
0
votes
1answer
142 views

Wp_update_post: Infinite loop even with remove_action solution, OOP

I have a quite complex PHP class, reponsible for creating and printing meta_boxes, generating and saving meta fields, ... Each meta_box (object of class) has its own save function, that updates meta ...
1
vote
1answer
84 views

Single Responsibility Principle and WP Classes

Still working my way through OOP and Solid principles. I’m having a hard time getting around having to have many new SomeClass(); calls, or adding them to an action hook ( add_action( 'init', array( ...
1
vote
3answers
202 views

Trying to get logged-in user data inside php class

I am trying to get the current logged-in user data and use this in the parent class(I need it in several functions). In the example below I can get the userID in the first function but it will give ...
0
votes
0answers
48 views

OOP - add_action

I'm making a simple theme framework for personal use and I'm try to set up various options in a class. Basically, I want to use add_action within my class but the function doesn't seem to be firing ...
3
votes
1answer
1k 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 ...
0
votes
0answers
68 views

Ajax Request not coming back to class

I'm struggling with an ajax request. It's executed but not returning back to my class. My PHP: ... public function __construct() { add_action( 'admin_print_styles', ...
0
votes
1answer
40 views

How do add_action and WP_Query

I am new to WP, semi-new to PHP and new to OOP. 1) How can the WP function add_action receive another function as its argument? I know this by itself is not possible. I deliberately broke some code ...
2
votes
3answers
2k views

Using Ajax with a Class file

At the moment I have an ajax that works (I get a success [200] response), but having an issue with the action hooks on the response. The JSON object is not coming back, instead I'm getting a 0. I ...
2
votes
1answer
179 views

Using a front controller in a Wordpress plugin, any suggestions?

My idea was to use a front controller in our plugin. has anyone done that already? The responsibilities of the controller should be initiate router class; provide access to objects registry, which ...
0
votes
3answers
130 views

How to make method from plugin available in theme?

Let's say this was in my plugin: class pluginslug_foo { public function bar() { //stuff } } and I wanted to make the method bar available for use outside of the plugin, for ...
0
votes
3answers
96 views

Registering and using actions which return results in a Plugin class

I have a plugin class which contains a function spektrix_list_events() class SpektrixPlugin { public function __construct(){ add_action( 'init', array ( $this, 'init' )); } ...
0
votes
1answer
165 views

Wp ajax not working from “current_screen” admin hook

I have a class that is doing some backend work ( enqueening css and js files creating metaboxes, registering ajax hooks etc...) Everything works fine when I just include the files. The problem is ...
6
votes
1answer
420 views

How to create a flexible abstraction for WP_Query?

My question is about php but it involves wordpress as i am creating a plugin. The case is that i have 5 questions, each question have 6 choices and one choice to choose from each. Now the person would ...
1
vote
1answer
536 views

How to include one class/instance without using global variables

I would like to add http://mobiledetect.net/ class to my template. Which is the best approach to dynamically use this class in every part(s) of my template? For the moment I just loaded the class in ...
1
vote
2answers
587 views

How to use classes declared in another plugin?

I'm developing a Wordpress Woocommerce plugin. On my local environment it works fine but I have problems when adding the plugin to a replica of the prod environment. I am new to wordpress and not very ...
8
votes
2answers
3k views

Will WordPress become completely OOP?

Is there any information about WordPress becoming completely OOP in future versions?
0
votes
1answer
399 views

Wordpress class, using add_action to call member function does not work

I'm learning to create a WP plugin as a class. However, it seems the add_action doesn't work when calling my function; it works when using $this->init(). Example: class test { public $age = ...
0
votes
1answer
86 views

Using Geo Data Store Plugin Code

I'm trying to simply use the Geo Data Store Plugin Code functions from within my theme files and have never done this. I've tested the $sc_gds to see if isset, yet not getting anything when looping ...
26
votes
3answers
1k 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
105 views

learning OOP with wordpress plugin

I used to develop in functional design so far and I am now learning OOP. I stumbled upon following problem. Sometimes in OOP a function needs to send and argument as an array. Example. I want to ...
0
votes
2answers
40 views

private functions in plugins

I've developed two plugins in which one function is the same (same name, same functionality). When trying to activate both plugins Wordpress throws an error because it doesn't let me defining the ...
0
votes
1answer
116 views

Dynamically creating multiple widgets from Mustache templates

I built a bunch of basic Mustache templates for a project, and now I'm wanting to effectively make them available to WordPress as widgets. //This uses Composer to manage dependencies (Mustache). ...
0
votes
1answer
118 views

add_action does not work when instance multiple tab-containers via template-file

I wrote my first class in functions.php which I want to use to create multiple tabs with a simple call all over my template files. When I create a new instance directly in functions.php everything is ...
1
vote
1answer
55 views

accessing parent variables in child construct without executing action in parent

I am quite probably going about this the wrong way, but I cant figure out how to rectify this.... would be great if someone could point me in the right direction. happy to provide more details if ...
0
votes
2answers
329 views

register child class in another plugin

I think this should be relatively easy, but somehow I cannot figure out how to do this. essentially there's a preexisting plugin that does this: add_action('widgets_init', create_function('', ...
-1
votes
2answers
87 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 ...
0
votes
1answer
155 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 ...
2
votes
2answers
574 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 ...
0
votes
3answers
165 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
332 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
vote
1answer
82 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
68 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 ...
18
votes
5answers
1k 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, ...
-3
votes
1answer
67 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
345 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 ...
3
votes
2answers
930 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, ...
6
votes
2answers
650 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 ...
1
vote
2answers
214 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 ...