The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
23 views

OOP - from plugin add new object and call static method in another file

I am trying to create an object from the plugins main file by first requiring a class file in a sub-directory, then creating a new->object, and then calling a method from within the required class ...
2
votes
1answer
34 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
41 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
40 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
42 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
103 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
48 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
91 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
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
173 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
155 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
89 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
219 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
50 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 ...
0
votes
0answers
71 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
1answer
188 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
136 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
98 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
171 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
426 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
592 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
634 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 ...
1
vote
1answer
547 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 ...
0
votes
1answer
426 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
94 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 ...
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
43 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 ...
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 ...
0
votes
3answers
92 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
1answer
119 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
119 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
56 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
341 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('', ...
0
votes
1answer
160 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
166 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
347 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
90 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
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 ...
-3
votes
1answer
69 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
364 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 ...
6
votes
2answers
677 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
59 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
131 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
309 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
133 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. ...
1
vote
2answers
894 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
37 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 { ...