The tag has no wiki summary.

learn more… | top users | synonyms (1)

0
votes
0answers
20 views

Cannot access $post object - no matter what I try

Here is the code: <?php // Plugin Name: Lohman Supply Product Hover class LohmanProductHover { public function __construct() { add_action('wp_loaded', array($this, ...
1
vote
0answers
36 views

Extending WP_User class and using this sub-class during the whole lifecycle

I am currently struggling with this software design issue I can't seem to get hold of. What I am trying to achieve is the following: for every user on our website, I want to do an API request to a ...
0
votes
1answer
20 views

Custom meta box using OOP way doesn't save data

This is the first time I'm building meta box using OOP way, the problem is when I save the post (product) or update it the input text is not saved to the database. Here is my code: <?php /** * ...
0
votes
0answers
24 views

Best way to access variables in template markup

I am making my own mini OOP wrapper for working with wordpress themes. I have a main $settings variable that contains all of the information like definitions, scripts, menus etc.. I then pass this ...
1
vote
1answer
33 views

Load classes using spl_autoload_register

I have a problem with loading classes in a "includes" folder. Tried on a few WP installations and always same result. I've made a simple plugin to see if the problem is somewhere else but again, it ...
-1
votes
2answers
36 views

Method not receiving attributes from shortcode call, general OOP problems

The method OpenMods that you see below, is supposed to take an array generated by an fgetcsv function, and put it into an HTML table. __construct is supposed to, as is typically the case, define the ...
1
vote
1answer
40 views

Getting headers property from WP_Theme object

Using wp_get_theme returns an object holding the properties of the current theme. The headers property contains any array of information I wish to access. I can access the other properties using ...
0
votes
2answers
24 views

Accessing a protected property of a post

Fatal error: Cannot access protected property Some_Plugin::$_some_property What is the best/least-destructive way of accessing a protected property attached to a post. The property is being ...
0
votes
1answer
22 views

The writing ( with foreach) of the keys of an array of objects to a new array produces fatal error

I have the following problem, i've queried the attached media to a post with: function abc_attachments( $post_id ) { $query = array( 'post_parent' => $post_id, ...
0
votes
1answer
38 views

Class property seems to lose scope, attached to save_post action?

This may be more suited for StackExchange, so if you think that would be the right place to direct my question - please let me know :). So, I have a class with a property of save_list. This is an 2D ...
0
votes
0answers
46 views

Object oriented programming, add_action in constructor not firing

I am trying to write a class that adds an action to the save_post hook, but the post_updated function never gets called. I tried some variations, but it never gets called. Am I doing something wrong? ...
0
votes
2answers
58 views

Using $post->post_name in body id causing error: Trying to get property of non-object

I'm getting the following error in my debug.log: PHP Notice: Trying to get property of non-object in /my-wesbite/wp-content/themes/express/header.php on line 36 This is line 36 of header.php in my ...
0
votes
0answers
39 views

Creating a register settings class that supports extended classes

I am having some trouble implementing a class structure to use for plugins I am developing. What I am trying to do is create a class I can just re-use for each plugin. I want it to be able to be ...
0
votes
0answers
14 views

How do can I pass data retrieved from a filter to template files?

I wrote this class to display only the current top level menu item's children: class deseng_navSplit { var $sorted_menu_items; var $args; function __construct($x, $y) { ...
0
votes
1answer
96 views

Extending the WP_Widget_Text class

I am trying to alter the output of the default WordPress text widget. Since the widget is written in OOP I hoped it could be a simple deal of extending the class and overwriting one method ā€“ but it ...
0
votes
0answers
67 views

Storing PHP structure data in the wp_options table?

I searched too much about that but can't find resonable answer of that question I am creating a WordPress plugin that has so many options that I need to store so to store data using option API which ...
-1
votes
1answer
342 views

Strict Standards: Non-static method in sidebar generator

I used this sidebar generator in my theme functions.php and this plugin work perfectly! No errors. But when I open define('WP_DEBUG', true) I got some error. I know that I have to set wp_debug to ...
0
votes
0answers
37 views

calling a function from a class in your template

ok, so I have created a plugin in Wordpress. I want to be able to use some values I have created in a function within my template but I just don't seem to be able to get it to work. I have created my ...
0
votes
1answer
235 views

Retrieve featured image as object

I want to retrieve the featured image of a post as an object (array) in order to have all image sizes available. The get_the_post_thumbnail() function doesn't do this, any ideas?
1
vote
1answer
36 views

Getting user roles in plugin files

I have a plugin in which I need to use the get_editable_roles() function but I keep getting a fatal error saying that the function does not exist. In my main plugin file I have this code: function ...
4
votes
1answer
175 views

How Can I Add a Filter to Class Instance Only?

I have a custom class which I use for several cases extending it, for example class A { public function show_things() { print_r( apply_filter( 'yet_another_filter', array( 'coffee', ...
4
votes
2answers
240 views

How to name files of namespaced classes?

WP Core Handbook > PHP Coding Standards > Naming Conventions suggests the following for naming files with classes: Class file names should be based on the class name with class- prepended and ...
0
votes
0answers
69 views

Dynamically creating classes for Widget API

So let's say I want to make new Classes for the Widgets API using some variables that the user can configure. The only way I have figured it out is to use the eval() function. This is due to how ...
1
vote
0answers
34 views

Loading Comments From a Class?

I am not using the function comments_template(). Instead I am trying to load the comments from a Class. There is no comments.php file on the root. Comment Class namespace Core\Views; class ...
1
vote
2answers
82 views

When and Where is `global $post` Set and Available?

Usually when people think of the global $post object it's assumed that it's actually set whenever you enter The Loop. I started to play around with how early I could actually call global $post which ...
0
votes
0answers
122 views

Autoloading a PHP class ā€“ working outside, but not inside WordPress plugin

I am thinking about using autoloading in a plugin. Outside of WordPress (as a test) it works as expected, but inside the plugin there are some problems. The directory structure I used for testing: ...
0
votes
1answer
54 views

How to Set Taxonomy Object Description?

I noticed when dealing with Post Type Objects (Using get_post_type_object();) and Taxonomy Objects (Using get_taxonomy();) there's a property called "description". How do you set this description ...
0
votes
2answers
324 views

Object method calling for global $wpdb in header.php

I am developing a Wordpress plugin in an object oriented way, and I would like to read data from the wordpress database using the global $wpdb variable. The global $wpdb variable is called from ...
0
votes
0answers
56 views

Property value of null when value is assigned inside a method hooked to the wp action hook

In my_method() below, I'm assigning an array of post IDs to the property $this->post_ids which is to be used later on in my query args - see process(). If I hook my_method() to the init action ...
0
votes
2answers
128 views

wp_ajax handler with multiple class instances

Eight months ago I asked nearly the same question over there. But the Problem is still not solved so far. But I have an additional ideaa why it is failing. In the meantime my code advanced. I have ...
-1
votes
1answer
71 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 ...
1
vote
1answer
399 views

How to get media objects

I am busy with a loop to return all media in the medialibrary in objects. I figured out how to get the images ( with wp_get_attachment_image('$mediaID') where the $mediaID is the id of the image ) ...
0
votes
1answer
50 views

Same taxonomy for different object types

Starting with WP 2.3 we can do this: register_taxonomy('custom_taxonomy', array('user', 'post', 'link', 'comment')); Those are different object types that belong to different tables and hence can ...
2
votes
1answer
203 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
194 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
56 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
125 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
360 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 ...
0
votes
1answer
59 views

Get object for a few selected taxonomies

I have some custom taxonomies that I would like to use as an object in a foreach loop. I know these functions which returns the object for either all taxonomies: global $wp_taxonomies; or the ...
1
vote
1answer
356 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
194 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 ...
1
vote
1answer
62 views

array of objects to do_action, callback gets singular object?

So I was passing an array of objects through an action today, no biggy, and things were working fine. Until I was iterating over one of the arguments to a callback and started getting errors. The only ...
-1
votes
1answer
111 views

Populate Array with values from another arrray [closed]

I have retrieved WP_Post object and i stored it in a variable. Array ( [0] => WP_Post Object ( [ID] => 45 [post_author] => 1 [post_date] => 2014-03-10 14:22:01 ...
-1
votes
1answer
314 views

How To Remove The Filter That Adds JetPack Related Content To Dom [closed]

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
49 views

Why function hooked using object are executing at all time?

I tried to use class and object in plugin. I made a simple function with a shortcode but it is executing the function without pasting the shortcode to any page/post. class example{ function ...
0
votes
1answer
423 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 ...
2
votes
1answer
128 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
485 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 ...
1
vote
2answers
571 views

The ideal place for storing persistent PHP objects

I'm writing some plugins that do background batch processing, i.e. operations that take longer than 30 seconds. I'm creating objects with the necessary job parameters set like this (this is a hugely ...