Articles of hooks

Use an array of page template slugs and $hook

I’m using the function below to load some javascript that removes the checkbox in the User Profile that is used to toggle the Visual Editor: //Remove Visual Editor option in User Profile function remove_visual_editor_admin_script( $hook ){ if (‘user-edit.php’ != $hook) { return; } wp_enqueue_script( ‘remove_visual_script’, get_stylesheet_directory_uri().’/js/remove-visual-editor.js’, array(‘jquery’) ); } add_action(‘admin_enqueue_scripts’,’remove_visual_editor_admin_script’); It loads a simple jQuery […]

Is it safe to register a taxonomy without using any hooks?

I’m creating a WordPress site in which I wanted to use a custom taxonomy in my theme options, which I had registered using the ‘init’ hook. But the problem was that the ‘init’ hooks gets fired after the theme options (I’m using the Redux Framework plugin for the theme options). So when I used the […]

preg_replace not removed “class”

Use this code to remove the label “class” of the images, but does not work. The label does not disappear in the new post. function the_post_thumbnail_remove_class($output) { $output = preg_replace(‘/class=”.*?”/’, ”, $output); return $output; } add_filter(‘post_thumbnail_html’, ‘the_post_thumbnail_remove_class’); It only works on the main page with highlighted images(thumbnail).

Is there a way to prevent a function/method from being called outside a specific hook?

I would like to make function only callable by a specific action, in this case the register_activation_hook() function. How can I do this?

Can my hooked uninstall class function access a global var declared in main plugin file?

My current setup is as follows… In the main plugin file, these two hooks are set (not inside any class): register_activation_hook(__FILE__, array(‘DG_Setup’, ‘activation’)); register_uninstall_hook(__FILE__, array(‘DG_Setup’, ‘uninstall’)); This same main file includes the file containing DG_Setup: include_once DG_PATH . ‘inc/class-setup.php’; And declares $dg_options: define(‘DG_OPTION_NAME’, ‘document_gallery’); $dg_options = get_option(DG_OPTION_NAME); I assumed that by referencing the main plugin […]

How do I amend form data before it is saved for a custom post type

I have a custom post type for clinics which has 3 fields; a textarea for the address of a the clinic and two textboxes for latitude and longitude. I want the user to enter the address in the textarea and then when they hit publish I need to hook in, geocode the address and populate […]

How to hook into the quick edit action?

I found this solution to automatically assign parent terms when a child term is selected, which is working fine for the save_post hook: add_action(‘save_post’, ‘assign_parent_terms’); function assign_parent_terms($post_id){ global $post; if($post->post_type != ‘product’) return $post_id; // get all assigned terms $terms = wp_get_post_terms($post_id, ‘product_cat’ ); foreach($terms as $term){ while($term->parent != 0 && !has_term( $term->parent, ‘product_cat’, $post […]

remove_action not removing add_action from constructor

I am trying to replace a message from a function that got hooked in a constructor from a class from woocommerce. This is what I tried to remove the message: What I tried. function remove_actions() { remove_action( ‘product_cat_pre_add_form’, array( ‘WC_Admin_Taxonomies’, ‘product_cat_description’ )); } add_action( ‘plugins_loaded’, ‘remove_actions’ ); Also instead of the first element from array […]

Create a post builder skin in a plugin

Currently I’m working on a plugin that will display a grid based on post type with many settings to customize it. One of the settings will be to choose between different skins available to display inside the grid. I would like to offer the possibility to developers to include their own skins with a custom […]

Help to change the text for new website notification (wpmu_welcome_notification)

i am trying to change the text for new website notification (wpmu_welcome_notification): in the core file i see wordpress using this function to send the email when new site created: the quasion is how can i hook this function to change body text that used in “$welcome_email” function wpmu_welcome_notification( $blog_id, $user_id, $password, $title, $meta = […]