0
votes
0answers
29 views

remove_filter right way

What is the right way to remove filter in condition? method 1 public function update_loop($query) { global $wp; if(!$query->is_main_query() || $query->is_admin) return; ...
0
votes
1answer
27 views

conditionally load javascript & CSS for do_action() calls from plugin

I am developing a plugin and using do_action() instead of shortcodes to display plugin content on the site. The plugin will only be used by me, but I am making the plugin to separate components of ...
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 ...
2
votes
2answers
37 views

What's the earliest point I can get the queried object ID?

I'm writing a supplement plugin to Wordpress Mobile Pack because I would like to use the default theme on pages that are assigned a certain page template. My plugin will only deal with the mobile ...
0
votes
1answer
64 views

Show error message after exception handled

I have a plugin that updates a user profile, and I want to handle a date exception and show a error message when it fails, but I can't make it work. Here is part of the class: private function ...
1
vote
3answers
122 views

What are the benefit in adding hook in the init() hook?

I see a lot of plugins using this approach to add a new hook, e.g. add_action('init', function() { add_action('SOME_LATER_HOOK', xxx); add_filter('SOME_LATER_FILTER', yyy); }); Why they don't ...
0
votes
1answer
170 views

How to add custom content under plugin row in WordPress admin plugin list?

I'm looking to add a custom message under my plugin in the "Plugins" page, much like the following screenshot: What action or filter should I use? Thank you!
0
votes
1answer
49 views

Odd behaviour with submenu link creation

I'm trying to develop a plugin that needs to add two pages to the dashboard side-bar menu. One of these being a main category. Everything is fine, except for the second submenu item for the settings ...
0
votes
0answers
35 views

remove_action(“wp_ajax_function”, “function”); not working

I have the following code in a file called contact-form.php. The file lives here: wp-content/themes/NAMEOFTHEME/ (premium theme) function theme_contact_form() { // some code here (send mail when ...
0
votes
1answer
77 views

How to use add_action for multiple instances of the same class

I'm writing a plugin which defines a class that is meant to be called multiple times. The class uses add_action to register it's own methods as callbacks. class MyClass { __construct($foo) { ...
1
vote
0answers
53 views

I have 2 plugins using the same wp_login action hook and one is not working

so this is after a few hours investigating, I have s2member plugin and a custom plugin what happens is they are both using wp_login hook in this manner, s2member: add_action("wp_login", ...
0
votes
1answer
154 views

Is it possible to create an action hook using do_action() within add_action()?

Is it possible to create a new action hook like do_action('my-hook-name'); inside a call to add_action();? I'm aware this code doesn't work, but I was thinking something along the lines of... ...
1
vote
1answer
54 views

wordpress plugin is not activating from widget

I am just creating a plugin in wordpress. In this plugin I am trying to create a widget, In that widget it will show a title, input text and text area in the widget section and when the values will be ...
0
votes
3answers
745 views

add action wp_head not working

I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making. The plugin has an interface where the user enters some details which are then added to the ...
0
votes
2answers
128 views

How do I print a notice only on certain admin pages?

I'm writing a plugin which would print a notice, but only on the media page. I found the admin_notices and all_admin_notices actions, but these are fired on all admin pages. Is there any way to find ...
0
votes
1answer
64 views

Is it possible to cancel a post status transition?

Question I want to cancel pending_to_published actions: Posts that match certain criteria should that go from pending to published should stay pending. (Alternatively, I need a to make add an ...
1
vote
1answer
209 views

When is it too late to call the action wp_enqueue_scripts?

I'm creating a plugin that always enqueues a script in the footer. I also have a function that if called would enqueue an additional script that depends on the other one. Here is the basic format of ...
1
vote
2answers
27 views

Is it possible to add an action to the currently running action?

My question is very simple but I haven't found this answer yet. Here's an example: class MyClass { public function __construct(){ add_action('init', array($this, 'init')); ...
3
votes
1answer
157 views

Which action for triggering cron “wp”or “init”?

Which one do you recommend using within a plugin and why? add_action( 'wp', 'trigger_me' ); function trigger_me() { if ( !wp_next_scheduled( 'my_plugin_cron' ) ) { ...
0
votes
1answer
624 views

How to access function from outside of a class within this class in WP plugin?

I am developing a WP plugin called e.g. DD_Awesome_Plugin and this is my code so far (simplified version without additional code logic within class functions): class DD_Awesome_PLugin { public ...
0
votes
0answers
242 views

Front end form submission/processing, without using a template file

I'm writing a plugin which has a front end form that is generated by a shortcode. I'm struggling with processing the form submission in any way. Many tutorials describe placing form processing code at ...
10
votes
1answer
493 views

How to create an API for my plugin?

I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins ...
-1
votes
1answer
79 views

How to remove a class [closed]

Is it possible to remove classes from a plugin and add theme into to theme? I need to modify Woocommerce WP_Checkout class but I want to move it to my theme folder so if woocommerce will be updated ...
1
vote
1answer
75 views

Issue plugin commands in admin settings page

What is the right way to issue commands in wp-admin? My plugin imports data from a set of RSS feeds via a cron job. Thats all working good. I've set up a custom settings page to change parameters, and ...
0
votes
1answer
1k views

Where is the best place to use add_filter

Should I use the function add_filter In my plugin's init action hook or just the in the main plugin script? Since sometimes I found people is using filter all over the place and if I put in the init ...
0
votes
1answer
2k views

Using the 'draft_to_publish' hook (post status transition)

I am trying to use the draft_to_publish hook (http://codex.wordpress.org/Post_Status_Transitions) to run a function when a post that is a draft becomes published. This hook does not appear to be ...
0
votes
1answer
97 views

template_redirect not being called when using ajax

Usually I hook all my custom plugins code with the template_redirect hook but one of the issue I encountered is it does not work for the ajax call. So if I want to target both standard calls and ajax ...
2
votes
1answer
495 views

How to redirect to action on custom page within admin section

Currently I'm developing(well at least trying to;) plugin which will handle custom gallery of images. I stumbled upon one problem though. I'll try to picture it. I've created custom menu page on ...
3
votes
5answers
397 views

How do I make a theme “plugin-ready”?

How do I revise a theme so that I can publish my event hooks and anyone can build a plugin to add new functionality easily to my theme?
1
vote
2answers
367 views

My plugin class doesn't work! [closed]

Long story short; I'm writing a plugin in OOP. The constructor is run, but the callback of my add_action does not run. I just can't find out why. I have added echo's on different spots to see what ...
1
vote
1answer
128 views

How to call bind function in wordpress actions or hooks

I have made a class file in my plugin folder. Then I wrote, class Sample{ function footer_content(){ echo "show any data"; } } Then I added the function footer_content to wordpress ...
3
votes
1answer
264 views

Do I need to call do_action in my plugin?

Do I need to call do_action function every time I add_action something?
0
votes
1answer
48 views

How Can I Add Code To A Preexisting Function Without Editing it

This is what I am trying to do: Lets say I have a parent plugin, Plugin X, and a child plugin (an extension, whose purpose is to enhance X) Y. There is a function in plugin X that I wish to add ...
1
vote
1answer
913 views

How to use filter hook 'post_updated_messages' in coherence with action hook 'save_post'

I am trying to send out e-mail, SMS and IM notifications to group members of this WordPress website, whenever a WordPress page in their user group has been published/updated. I figured using the ...
1
vote
1answer
108 views

Valid filenames for add_action's first parameter

Some examples in WordPress' docs pass a filename to add_action rather than an action name. For example, add_action( 'load-post.php', 'callback' ); add_action( 'load-post-new.php', 'callback' ); ...
2
votes
3answers
2k views

A Post is saved twice or more during add_action(save_post)

I have added a custom meta box for advanced information for a specific post category, to my create new post page. Now I recognize, that if I save the post, it writes 2 entries in the db with 2 ...
4
votes
1answer
105 views

How Do I Load My Action Earlier Enough?

With add_action, I want to intercept as early as I can in my plugin and send a 304 Not Modified header per some rules. Does anyone know what the order is of events? When I view this page, it seems to ...
1
vote
1answer
783 views

Add something to beginning of content with add_action('the_content')?

I'm using add_action('the_content', 'myFunction', 10) to append data to the end of the content. How can I place content at the beginning of the content?
0
votes
2answers
1k views

How to append new form elements in “Add New” form of Users in Wordpress admin panel?

I'm developing a WordPress plugin and I want to append some extra form fields in add new form of Users section inside admin panel without editing core files. Can somebody help me in achieving this.
0
votes
1answer
110 views

Bug: Post needs to be updated twice when adding action for save_post hook

My function does exactly what I want it to do: I'm trying to add/update meta fields in another post type when an "events" post is saved. Except the post needs to be updated twice for the information ...
0
votes
1answer
344 views

Adding tables to dashboard pages programmatically?

I think that is not possible with some actions or filters, I know that I can do it just with html and using right css styles, and of course php to achieve what I need, or to write some minde actions. ...
6
votes
1answer
2k views

How to override existing plugin action with new action

I'm using a plugin. It has an action like this. add_action('publish_post', 'old_action'); function old_action($pid) { "code goes here" } } I'm writing a module for this plugin. So i need to ...
0
votes
1answer
1k views

Getting admin notices working for plugin errors

I'm beginning with creating plugins and I don't quite understand the process of displaying error messages. e.g. I use the php readfile function to download a file from a hidden location. If something ...
1
vote
2answers
2k views

Hook to get image filename when it is uploaded

I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to ...
3
votes
2answers
101 views

Which to use to execute code during the saving of a plugin settings page?

I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to ...
0
votes
1answer
197 views

Setting post_id for single.php based on URL without a redirect

I'm migrating a Joomla! database to Wordpress and the website has to remain exact regarding URLs. The Joomla site has its posts with .html extensions, and the importer I created maps the Joomla file ...
1
vote
1answer
755 views

When to load auto-login code?

I'm using this (simplified) code to automatically login users via a plugin for a single sign-on system: $user_info = get_userdatabylogin( $username ); $user_id = $user_info->ID; ...
3
votes
2answers
56 views

How can I limit functionality in one version of a plugin?

I am busy writing a plugin with a free version and a paid, Pro version. For our initial release of both versions, I want to keep things as simple as possible, so I would rather defer using a strategy ...
0
votes
1answer
581 views

admin_notices not displaying in plugin

I know I'm probably doing something dumb here but I just can't get this to run. I'm trying to set up a little API for my plugin and to create a class to display admin notices a little easier. Here's ...
0
votes
1answer
678 views

Hook for page Request?

I want to run a function that looks at the current url params of the page that is requested and sets a cookie based on those params. So, I guess I'm looking for: The Wordpress Hook that allows me ...