Check if action hook exists before adding actions to it

You cannot check if an action will be called before that happens. Even if there were already callbacks attached to the action there would be no guarantee the matching do_action() will be used. In your case, test with is_plugin_active(): if ( is_plugin_active( ‘wordpress-seo/wp-seo.php’ ) ) { // do something } As @Barry Carlyon mentions in … Read more

How to modify post content before writing to database?

You generally use add_filter before displaying information. For your case you can use add_action(‘publish_post’, ‘your_function’) and then you intercept $_POST values. The content of the WYSIWYG editor is available through $_POST[‘content’]. The hook is of type publish_{post_type} btw. You should change accordingly. Example: function wpse_89292_save_my_post() { print_r( $_POST[‘content’] ); # will display contents of the … Read more

How to add a link to WordPress Plugin install Listing

This is the filter: “plugin_install_action_links”. You can find this in /wp-admin/includes/class-wp-plugin-install-list-table.php (currently) at line 434: $action_links = apply_filters( ‘plugin_install_action_links’, $action_links, $plugin ); Use it like: add_filter( ‘plugin_install_action_links’, ‘my_custom_links’, 10, 2 ); function my_custom_links( $action_links, $plugin ){ $action_links[] = ‘<a href=””>……</a>’; return $action_links; }

Anyway to edit the titlebar of WordPress Widgets in the Admin area?

I believe you are looking for $params = apply_filters( ‘dynamic_sidebar_params’, $params ); (look here: https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets.php#L706). Now this filter will evaluate both in front end and back end. so to answer your question, you could wrap your filter in a if( is_admin() ){ // Do icons } check. Better yet, you could define this at registration … Read more

admin_post hook not called

Modify your form to include: <form action=”<?php echo admin_url(‘admin-post.php’); ?>” method=”post”> <input type=”hidden” name=”action” value=”volunteer”> … </form> and add an action to run your function: add_action( ‘admin_post_volunteer’, ‘send_contact_to_civicrm’ ); add_action( ‘admin_post_nopriv_volunteer’, ‘send_contact_to_civicrm’ ); function send_contact_to_civicrm() { // stuff here }

Modify featured image URL at runtime

HTML generated by the_post_thumbnail() & get_the_post_thumbnail() can be altered using the post_thumbnail_html filter. This works even when there is no post thumbnail. Example: /** * Filters the post thumbnail HTML. * * @since 2.9.0 * * @param string $html The post thumbnail HTML. * @param int $post_id The post ID. * @param string $post_thumbnail_id The … Read more

Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)

Why it is added in the footer: This is the expected behaviour. Since you have enqueued the style within your Shortcode hook function, by the time it executes, WordPress is already done generating the <head> section of your page, since WordPress will only execute your shortcode function once it has found the shortcode in your … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)