A type of hook that provides a way for content to be overridden programatically

learn more… | top users | synonyms (5)

26
votes
3answers
1k views

How to remove a filter that is an anonymous object?

In my functions.php file I would like to remove the below filter, but I'm not sure how to do it since it's in a class. What should remove_filter() look like? add_filter('comments_array',array( ...
24
votes
4answers
14k views

Filter to remove image dimension attributes?

I'm working on a site based on a fluid width css template which sets a max-width on images to the width of the column containing them, and I need to remove the inline width and height dimension ...
18
votes
1answer
4k views

Passing a parameter to filter and action functions

Is a way to pass my own parameters to the function in add_filter or add_action. For example take a look in the following code: function my_content($content, $my_param) { do something... using ...
12
votes
2answers
330 views

How do filters and hooks really work in PHP

How does filters and hooks actually work in WordPress? I'm asking about something advanced. How is it implemented in PHP? E.g how does it collect all the hooks from the different plugins and "attach" ...
12
votes
5answers
5k views

single-{$post_type}-{slug}.php for custom post types

My favorite part of the Wordpress template hierarchy is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template. We can ...
12
votes
2answers
7k views

Explanation for apply_filters function and its variables

I'm learning how to build html forms using PHP by taking an example from "simplr form registration" plugin. I'm looking at this code: $form .= apply_filters('simplr-reg-instructions', __('Please ...
11
votes
6answers
14k views

remove empty paragraphs from the_content?

Hey guys, I simply want to prevent the creation of empty paragraphs in my wordpress post. That happens quite often when trying to manually space content. I don't know why this doesn't take effect? ...
11
votes
2answers
5k views

Difference Between Filter and Action Hooks?

I have been looking at the plugin API a bit more in depth recently and I was wondering what real differences there were between action and filter hooks. They both are events that receive data as a ...
11
votes
1answer
5k views

Saving Taxonomy Terms

I have an interesting problem which I hope someone can quickly answer. I have created my own metabox which, based on "MY METABOX CODE" (list below) is correctly displaying a dropdown list of all my ...
11
votes
2answers
774 views

How to make a image-size selected by default in Media upload - WP v3.5

Bare with me. I want to have a custom image size selected by default in the Media upload popup page. In Wordpress v3.4.2 and prior, this elegant code worked fine: function ...
10
votes
1answer
492 views

How to create an API for my plugin?

I have been developing plugins for WordPress, most plugins I have developed use two or three classes, hence not as huge as Buddypress or WooCommerce. I am planning to develop two open source plugins ...
8
votes
3answers
3k views

remove_action or remove_filter with external classes?

In a situation where a plugin has encapsulated its methods within a class and then registered a filter or action against one of those methods, how do you remove the action or the filter if you no ...
8
votes
1answer
5k views

How to add defer=“defer” tag in plugin javascripts?

I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in contact form 7 javascripts. This is how contact form 7 includes javascript in header. ...
8
votes
2answers
268 views

How do I exclude plugins from getting automatically updated?

There is an opt-in filter that allows all plugins on my site to receive automatic updates: add_filter( 'auto_update_plugin', '__return_true' ); I like this feature, but I don't want all my plugins ...
7
votes
3answers
6k views

apply_filters() and the_excerpt are giving unexpected results

I feel like I must be missing something pretty obvious, here, but I can't seem to get WordPress to cooperate. I'm generating Facebook OG tags with a function. Everything works fine, except for the ...
7
votes
2answers
1k views

Remove “Insert from URL” link in Media upload - WP 3.5

How do I remove the Insert from URL link in the new Wordpress 3.5 Add Media popup page? In earlier versions of Wordpress, this worked fine: // removes URL tab in image upload for post function ...
7
votes
4answers
2k views

LESS CSS enqueue_style with add_filter to change rel attribute

What I'm trying to do is use less css with Wordpress. You're supposed to link to your .less files with the rel attribute set to 'stylesheet/less'. But I can't figure out how to alter the code that ...
7
votes
1answer
3k views

Row actions for custom post types?

I'm working on a plugin, which converts a site into a feedback sort of portal. I made a new object page, 'Feedbacks', which displays all the feedbacks is a tabular format, and I'm using ...
7
votes
1answer
553 views

Assign a Class to the Current “Tag” for Formatting

Essentially what I am hoping to replicate is something like the "current-menu-item" class that is applied to WP Menus. My client is wanting to use Tags as a sub-nav, and I've managed to get the tags ...
6
votes
2answers
271 views

WordPress Internal @ Mentions

I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter. Example: If the username ...
6
votes
3answers
4k views

How to know what functions are hooked to an action/filter?

Is there a way to know what functions are hooked to a particular hook? For example if I'd like to know what functions are hooked to the wp_head hook.
6
votes
1answer
634 views

Changing JPEG compression depending on image size

Short. I want ''large' images compressed by 90%, and 'medium' to be by 60%. Has many af you know, sometimes larger images suffer from high compression, but other small images don't. This function ...
6
votes
1answer
5k views

Removing Image and Caption Dimension Attributes

This question is an offshoot from the this discussion on removing dimension attributes from images. The solution code provided on that thread works very well except that it has the unfortunate side ...
6
votes
2answers
1k views

WordPress 3.9 - Trouble Editing new TinyMCE

With WordPress 3.9 coming soon it's bringing along TinyMCE 4.0. I'm running my plugins and functions through some testing and found that one of my functions seems broken / not working with the new ...
6
votes
1answer
8k views

Wordpress hooks/filters insert before content or after title

trying to insert content before the post content in my functions.php - I know how to use the regular wp hooks, but unsure how to insert into other areas. Tried this, but it kills content on any other ...
6
votes
3answers
670 views

How to filter by post-format in admin?

I need to filter my posts by Post-Formats in admin ? How can I do that ? For now, Wordpress allows to filter by Categories and Dates.
6
votes
1answer
424 views

Extend WordPress 3.8 Site Activity Dashboard Widget to include more comments

The new Site Activity dashboard widget defaults to showing 5 comments. I'd like to show 10. I can see the code in core /wp-admin/includes/dashboard.php where it calls the function ...
6
votes
1answer
1k views

Set media upload attachment link to none and hide it in WP v3.5

In the Media upload popup page, how do I set the attachment link to none and hide it in Wordpress version 3.5? The following filter worked fine in earlier versions of WP: function ...
6
votes
3answers
3k views

How to Pass External Variables to Filters/Actions

I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around. Take this example: ...
6
votes
2answers
128 views

Remove Actions/Filters added via Anonymous Functions

That's a freaking bad practice I must say. Spent last two hours finding a solution to remove actions and filters added via Anonymous functions. This is the code used on a Parent Theme, and I need ...
6
votes
2answers
283 views

current_shortcode() - detect currently used shortcode

In a plugin class I want to provide simple fields for public data: email, phone number, Twitter etc. The list can be extended. See the plugin Public Contact Data on GitHub for details. To keep the ...
6
votes
1answer
2k views

How to add sub-menu to a menu generated by wp_nav_menu by using plugin

I have a menu generated by wp_nav_menu which look like <ul class="nav-menu" id="menu-top-nav"> <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-43" ...
5
votes
5answers
4k views

Remove classes from body_class

I don't need this whole mess of classes like this... <body class="page page-id-829 page-template page-template-page-template-portfolio-php portfolio"> I'd like something like this... <body ...
5
votes
3answers
1k views

Filter any HTTP request URI?

I want to filter any HTTP request URI done through the HTTP API. Use cases: The WordPress update check goes to http://api.wordpress.org/core/version-check/1.6/, but ...
5
votes
1answer
7k views

Add filter menu to admin list of posts (of custom type) to filter posts by custom field values

This answer is very close to what I am looking to do, but instead I would like to specify a specific custom field and display a select menu of its available values. Thanks!
5
votes
2answers
109 views

Valid characters for actions, hooks and filters

I haven't ever seen a tag such as do_action('something_10'). Is it invalid if I use numbers? If the method is valid, how can I write different numbers in the tag string conditionally? For example, is ...
5
votes
3answers
2k views

Change admin bar to default:off

While I quite like the admin bar I actually want it to be OFF by default instead of ON ( I don't want to disable it altogether because I want users to be able to turn it on if they want - but but I ...
5
votes
1answer
113 views

Add filter to blogroll widget

I'm trying to add <i class="icon-ok"></i> before the content inside the <li> of the blogroll widget. I'm assuming that's done through the link_title filter, but I can't find a ...
5
votes
2answers
2k views

Earliest hook to reliably get $post/$posts

What's the earliest possible action I can hook into where I'll be able to access the global $post/$posts variables on both the front and back ends? I've tried looking through the Codex reference, Adam ...
5
votes
1answer
170 views

Filter username field on registration for profanity and unwanted words

How do I add a filter to the username field to stop new users from registering using unwanted words such as administrator or general profanity? Ideally, if I could add a large list of words that are ...
5
votes
1answer
107 views

Add whitespace between Chinese and other letters

I want to add a space between a Chinese character and a letter or a number to make the article more readable. For example: Google与Apple展开的专利大战在2天之前结束。 Google 与 Apple 展开的专利大战在 2 天之前结束。 But ...
5
votes
1answer
3k views

Changing WooCommerce Display Price Based on User Role & Category

I'm looking to display a different price based on a user role (wholesaler, dealer, etc) AND based on the category. There's a dynamic pricing plugin that displays these discounts once an item is added ...
5
votes
3answers
1k views

Is there a way to add another row to the tinyMCE kitchen sink toggle?

The tinyMCE "kitchen sink" toggle button shows/hides a row of buttons. I have successfully added my row of shortcode buttons to the tinyMCE editor, but I was wondering if there was a way to make my ...
5
votes
4answers
2k views

No filter of code on switch from html to visual editor, how?

Yes, i have found other questions to this topic, but no have the same topic exactly and no solution for my problem. If you include code inside the html-tab and you switch to the visual mode, then ...
5
votes
1answer
316 views

Limit Media Library to Given Folder

I have made a plugin that uses the Media Library to allow users to upload files to a specific directory - using the upload_dir filter. I would like to know if there is a way (i.e. a filter) I can use ...
5
votes
1answer
110 views

How to auto-translate custom user roles?

I developed a small plugin that adds (or to be more precise: first deletes then adds again) some custom user roles. Each of these roles is set up in a way like this: function ...
5
votes
1answer
132 views

Add quick edit fields without custom colum

This question is a follow up on that answer I wrote. Let's say I want to add something to the quick edit box for the Posts post type list table. To do so, I have to add a custom column because of the ...
4
votes
5answers
638 views

Implementing advanced add_* function wrappers

add_action() and add_filter() are major functions. However in some scenarios add one more function and hook it somewhere approach gets bulky and inconvenient. I had determined for myself several use ...
4
votes
3answers
139 views

How to restrict actions and filters “properly” by conditions

Which one is correct when adding actions/filters/etc.... Both methods work fine and I've seen people do things both ways, but I'm assuming one is correct. My gut tells me that wrapping the if ...
4
votes
2answers
5k views

Default Image Link Removal

Just wondering if there is a way to remove WordPress's default function of adding a tag around an inserted image. I assume its a "remove_filter" function like you can do for WPAutoP, but all my ...