Remove an action hook within a Class

Since you are not specifying a priority to your actions, they will be executed in the order they are encountered. So your remove_action may very well be executed after the actions tied to the same hook have already been executed. You could solve this by attaching a higher priority to the action that does the … Read more

Add a class to the anchor tag on HTML5 gallery

f you mean to add a class on the anchor image wrapper that you have added using wp-editor then you could add folllowing code : this will filter the content and add class to your image <?php function add_class_to_gallery($content) { $classes=”gallery-link”; // check if there are already a class property assigned to the anchor if … Read more

Button not refreshing page

Because onsubmit event not working with “input” tag. You can see more details in https://www.w3schools.com/jsref/event_onsubmit.asp Supported HTML tags: form, keygen Replace code to <form method=”post” onSubmit=”window.location.reload()”> <input type=”submit” name=”switchlon” id=”switchlon” value=”Switch to London” /><br/> </form> or <form method=”post” > <input type=”submit” name=”switchlon” id=”switchlon” onClick=”window.location.reload()” value=”Switch to London” /><br/> </form>

Delete a WordPress transient from a shortcode on Page/Post update

If you will save all data of shortcodes in one variable, you can reset it easy. Example somewhere in shortcode(pseudocode): $page_cache = get_transient(“page_{$page_id}”); if ( empty($page_cache ) ){ global $shortcode_index; $page_cache[$shortcode_index] = **some data that cached**; set_transient( “page_{$page_id}”, $page_cache, **some time** ); $shortcode_index++; **** } And then you can delete it just by page_id on … Read more

get current custom post ID by WP_Query method

Since the AJAX can be called from anywhere, even by a search engine, you should pass the ID manually. To do this, you need to include the ID of your current page somewhere in your template. There is a common practice to include extra information in hidden input elements. You can add this hidden element … Read more

Change the CSS of the Customizer API

Definitely, you can use the customize_controls_enqueue_scripts hook to load custom CSS and JS. This is an example of making the panel 400px: File: sample-theme/css/customizer-controls.css .wp-full-overlay.expanded { margin-left: 400px; } .wp-full-overlay-sidebar { min-width: 400px; } .wp-full-overlay.collapsed .wp-full-overlay-sidebar { margin-left: -400px; } File: sample-theme/functions.php /** * Enqueue style for customized customizer. */ function sample_theme_customize_enqueue() { wp_enqueue_style( ‘custom-customize’, … Read more

How to disable the password strength meter script on reset password page?

If you only want to hide the password strength meter, you could do so via CSS. In your plugin function login_stylesheet() { wp_enqueue_style( ‘custom-login’, plugins_url( ‘login.css’, __FILE__ ) ); } add_action( ‘login_enqueue_scripts’, ‘login_stylesheet’ ); In login.css (hide box and change border-color of inputs) body.login-action-rp #pass-strength-result { display: none; } body.login-action-rp #pass1, body.login-action-rp #pass1-text { border-color: … Read more