Tag Info

New answers tagged

5

Both approaches are not mutually exclusive. As @gmazzap said, don’t create a callback hell. But you can provide an initial hook, so other developers don’t have to rely on the rather slow function_exists() checks. Example In your plugin, provide a hook that other developers can use to call your classes and functions safely. add_action( 'wp_loaded', [new ...


4

Surely this approach has some benefits, but has also some issues. It's not really easy to use If the target of your plugin are WordPress developers, they will be very familiar with plugin API, but end users are not. For a non-developer, something like: $data = give_me_the_data(); It's easier to understand, remember and type than: $data = ...


0

It's simply the wrong endpoint. The admin_post_* hook and its admin_post_nopriv_* counterpart is not fired for any admin page with the appropriate action request variable set, it only triggers for requests hitting wp-admin/admin-post.php. Try https://test.local/wp-admin/admin-post.php?action=test instead. I should add that using admin-post.php for ...


6

I guess you have: the_content(); wp_link_pages(); in your theme file. So you can instead try the following (PHP 5.4+): /** * Append the wp_link_pages to the content. */ ! is_admin() && add_filter( 'the_content', function( $content ) { if( in_the_loop() ) { $args = [ 'echo' => false ]; // <-- Adjust the arguments ...


1

I believe you are looking for activated_plugin and deactivated_plugin, see the wordpress documentation:


1

The publish_{post-type} action is triggered only when the post change from any post status (not published) to published; for example, if the post is already published and you edit it, the publish_{post-type} action is not triggered. I think you need to hook your function to save_post_{post_type} action, which is triggered every time a post is saved, not ...


-3

You could just do a display:none on the css selector for the slug so they never see it.


0

It's actually used by WP to allow plugin developers change WP behavior. You can make your code flexible using do_action so other plugin/theme developers or simply yourself can change behavior of your code. For example imagine you have a WP loop in a theme framework. You would like to add breadcrumb at the top of it, here is the simplest method: ... ...


0

Untested but ... You need to pass your "action" identifier with the data, like so: var data = { 'action': 'my_action', 'whatever': 1234 }; In your case, that action would be get_number_of_promos. The example is from the Codex page about AJAX, which you should read carefully: https://codex.wordpress.org/AJAX_in_Plugins


0

Add Custom Class In Custom Column custom posttype / post/page/ and user list Table . This is a Simple Please Try This Add column name like "purchased-leads num " space between for separate class. Add Add "num" Class in Column And Auto Text align Center like Post count , no need Any Other css . add_filter( 'manage_users_columns', ...


2

The thing with class methods is that unless they're static, they belong to an object. And in your case your object is: new WC_Admin_Taxonomies_new(); Which means PHP will create the object and keep it in memory. But unfortunately, since you're not assigning this object to a variable, you have no way of referencing it later in your code. Off the top of my ...


1

You need to insert your term after the init hook (i.e. when the taxonomy is registered): function create_tax() { $args = array(...); register_taxonomy('custom_tax', array('post'), $args); // Now we're safe $result = wp_insert_term('Test Term', 'custom_tax', array('parent'=>0) ); }


1

This is not possible, since the output of your gtp_users_table_content function for the manage_users_custom_column action hook is printed within predefined <td></td> elements. However, you can put a simple div with a class around your output: // Add users table lead purchase column content add_action( 'manage_users_custom_column', ...


0

The problem is the initialization in WordPress via register_activation_hook( __FILE__, 'activate_IWCollege_Courses' ); The function was fired on the Activation of a plugin, not more. You must switch to the hook init. For Custom Post types is the init hook the recommendation of the codex. But the important part flush_rewrite_rules();in your activation ...


1

Use in_the_loop() to know if you are currently in the loop of the main query. function after_title($title) { if ( in_the_loop() && ( is_single() || is_page() || is_home() || is_category() ) ) { $write = 'AFTER TITLE'; $title = $title.$write; } return $title; } add_filter( 'the_title', 'after_title' );



Top 50 recent answers are included