Articles of filters

add_filter return value

function validate_username( $username ) { $sanitized = sanitize_user( $username, true ); $valid = ( $sanitized == $username ); return apply_filters( ‘validate_username’, $valid, $username ); } in wp-includes/registration.php i want to change $sanitized = sanitize_user( $username, true ); to $sanitized = sanitize_user( $username, false ); I couldnt success to write add_filter in there, somehow its not […]

How can I remove css from a child theme?

I am using the theme twentyten as a parent theme for my child theme. I have other stylesheets I want to use and so I’m trying to figure out how to wp_deregister_style for the style.css sheet that is printed out in the head section of the html. I have checked the global $wp_styles variable around […]

Allow unfiltered HTML in titles for low level users?

How can the unfiltered_html capability be given to non network admins in a multisite install to allow HTML in titles? In wp-includes/capabilities.php (below) it appears that this capability can not be given to non super_admins. case ‘unfiltered_html’: // Disallow unfiltered_html for all users, even admins and super admins. if ( defined(‘DISALLOW_UNFILTERED_HTML’) && DISALLOW_UNFILTERED_HTML ) { […]

How to add attribute to output with wp_video_shortcode add_filter

I’m trying to add a ‘muted’ option to the video tag output with the content of a post using the built in wp video shortcode. I found this answer How can I get the shortcode to allow query string parameters? which has led me to the add_filter but I’m really struggling how to use it? […]

where to apply “apply filters” and other Sanitization Functions

I got to learn something new today here on this post. I have code written for a Post widget → <?php class chimp_post_widget extends WP_Widget { function __construct() { //Create Widget parent::__construct( ‘post_display_widget’, esc_html__(‘The Post Widget’,’simplisto’), array( ‘classname’ => ‘post-widget’, ‘description’ => esc_html__(‘A Post Thumbnail Widget’, ‘simplisto’ ) ) ); } public function form( $instance […]

WordPress Genesis Child Theme Filter divs

I’m trying to html5ize a Genesis child theme. So far I’ve figured out how to replace the Doctype via hook but am having trouble figuring out how i can change the divs to sections and articles without touching the core files. Can anyone point me in the right direction?

Manipulate Output of wp_list_something: select menu instead of li's

I’m working on a responsive webdesign where my navigation should swap into a select-menu when resizing the window in smaller sizes. Is it somehow possible to add another param to functions like wp_list_categories() or wp_list_pages() so that it outputs <option>item</option> instead of <li>item</li>? So what I wanna do is use wp_list_pages() and wp_list_categories() to ouput […]

How to filter WordPress search, excluding post in some custom taxonomies?

I want to filter WordPress search (and also WordPress listing of posts) on 2 values of a custom taxonomy. I tried this code, filtering my custom taxonomy named “marque”, excluding 70 or 67 IDs (nb : in my back-office, posts can only be classified into one term of my taxonomy a time) : // Filtering […]

Clean-up script tags

I want to clean up <script> tags generated by WordPress to produce more semantic output for HTML5. You can already do this for <style> tags using this code attached to the style_loader_tag filter: //clean up the default WordPress style tags add_filter(‘style_loader_tag’, ‘clean_style_tag’); function clean_style_tag($input) { preg_match_all(“!<link rel=’stylesheet’\s?(id='[^’]+’)?\s+href='(.*)’ type=’text/css’ media='(.*)’ />!”, $input, $matches); //only display media […]

locate_template with multiple categories?

in this example (from Wrox book), if a single-category-$slug.php file exists, it will be shown, otherwise it’s the single.php file. But if we have more than one category for each post (let’s consider that the array $templates will contain more than one result), what will $templatecontain? where do we choose the right slug with this […]