change “missing attachment” text functions.php

You should never change a core file. This message is called by the function wp_get_attachment_link(). For this singular message this function does not apply a filter, but it return the string as value, which can help. You can simple identify where in your theme this function is called and change it return, like: $result = … Read more

WP 4.5 hide core customizer sections

If you check out the source of WP_Customizer, you’ll see there is no title_tagline or header_image at the time the filter runs: final class WP_Customize_Manager { protected $components = array( ‘widgets’, ‘nav_menus’ ); public function __construct() { // a bunch of requires $components = apply_filters( ‘customize_loaded_components’, $this->components, $this ); } } Use the customize_register hook … Read more

I need to hook and change language of facebook sdk

Check the documentation of add_filter() first argument is name of filter and second one is callback function name. (both are required) See the example for your case:- add_filter(‘bimber_facebook_sdk_src’, ‘change_fb_sdk_url’); function change_fb_sdk_url($current_url) { // Variable $current_url hold the current value of URL // You can manipulate what you want // Or simply return your URL return … Read more

Get_template_part inside filter?

You can use output buffering to get the template output and return it in place of the emptied shortcode content: if ($pos !== false) ob_start; get_template_part(‘content-gallery.php’); $contentgallery = ob_get_contents(); ob_end_clean(); return substr_replace( $content, $contentgallery, $pos, strlen($shortcode[0]) );` } EDIT It might make it easier to just replace the gallery shortcode? remove_shortcode(‘gallery’); add_shortcode(‘gallery’,’my_content_gallery’); function my_content_gallery() { … Read more

Admin: how to make a custom list filter button send GET queryvars

Thanks to @cybmeta I was able to solve my issue. Below I post all the relevant code. Keep in mind it refers to a ‘distributor’ custom post type that uses 4 custom taxonomies (‘italy’,’france’,’spain’,’world’). // add columns function add_distributor_columns($table_columns){ $area_column = array(‘area’ => ‘Area’); $macroarea_column = array(‘macroarea’ => ‘Macroarea’); // put them on the right … Read more

Want to use wp_get_current_user() in query filter

since the query filter is “applied to all queries (at least all queries run after plugins are loaded)” as stated here in the wordpress codex you should do a further test to make sure that you are in the query you want to be. Perhaps a certain query or queries is/are run before the one(s) … Read more

Register new user, assign custom role then send email

TO really fit your needs, I think it’s better to rewrite some part of wp_insert_user() function, some part can interrest you $user_email = apply_filters( ‘pre_user_email’, $raw_user_email ); And : $illegal_logins = (array) apply_filters( ‘illegal_user_logins’, array() ); if ( in_array( strtolower( $user_login ), array_map( ‘strtolower’, $illegal_logins ) ) ) { return new WP_Error( ‘invalid_username’, __( ‘Sorry, … Read more