New answers tagged add-action
6
Neither.
register_activation_hook( __FILE__, 'trigger_me' );
function trigger_me() {
if ( !wp_next_scheduled( 'my_plugin_cron' ) ) {
wp_schedule_event(time(), 'hourly', 'my_plugin_cron');
}
}
Why parse code on every request when you don't need to?
1
Create a static getter for your class instance:
class DD_Awesome_Plugin
{
/**
* Plugin main instance.
*
* @type object
*/
protected static $instance = NULL;
/**
* Access plugin instance. You can create further instances by calling
* the constructor directly.
*
* @wp-hook wp_loaded
* @return object ...
0
I was literally banging my head around a related issue and this is the first thing I've read online that gave a solid pointer to what I was doing wrong.
Turns out add_meta_boxes is called later than save_post, so you'd need to set up the save hook BEFORE the metabox is created. Seems counter-intuitive at first, but the markup is typically generated AFTER ...
11
The API you offer in a plugin or a theme depends on the logic of that specific code. There is probably no guide that applies to all situations.
I am a contributor for multiple plugins with APIs, and what I have learned so far is:
Do not offer an API until you really know how people use your code.
Release the first two or three versions without any API. ...
1
str_replace will make a mess of any unlucky markup on the page since it will replace matching text inside of markup or inside of URLs.
What you want is a modified versions of an answer I gave to another question about highlighting search terms. The change would be to the highlight_search_term function. You just need to alter it to use the $_GET data ...
1
Check the Filter Reference -- there are filters like the_content, the_title, wp_title, etc. I'm not sure what you'd filter to get the logo description and footer -- you might need to delve into your theme's code.
Also, make sure you sanitize anything you get from $_GET -- never ever trust user-generated content. See Data Validation for more information.
Top 50 recent answers are included
