Announcements
Schedule Social Media Posts
Commercial Themes in Jetpack Professional
AJ Morris Acquires iThemes Exchange
Does My Site Need HTTPS?
Is there a plugin for that?
With more than 48,000 plugins in the WordPress repository, it’s hard to find the perfect one. Each week, I will highlight an interesting plugin form the repository.
For more great plugins, download my 50 Most Useful Plugins eBook.
Admin Menu allows you to show/hide specific items, change icon, title, reorder the menus for users. You can have a clean and mistake-free menu for your clients, to other WordPress users and even entire roles.
Exploring Hooks, Actions and Filters
If you’re into WordPress development, you can’t ignore hooks for long before you have to dive in and figure them out. And since modifying WordPress core files is a big no-no, whenever you want to change existing functionality or create new functionality, you will have to turn to hooks.
Definition of Terms
A Hook is a generic term in WordPress that refers to places where you can add your own code or change what WordPress is doing or outputting by default.
Two types of hooks exist in WordPress: actions and filters.
An Action in WordPress is a hook that is triggered at specific time when WordPress is running and lets you take an action. This can include things like creating a widget when WordPress is initializing or sending a Tweet when someone publishes a post.
A Filter in WordPress allows you get and modify WordPress data before it is sent to the database or the browser. Some examples of filters would include customizing how excerpts are displayed or adding some custom code to the end of a blog post.
// Send Joe to get paint
add_action( 'after_joe_arrives' , 'send_joe_to_get_paint', 10 , 2 );
function send_joe_to_get_paint( $joe_has_keys, $joe_has_car ) {
// If $joe_has_keys and $joe_has_car are both true
if ( $joe_has_keys && $joe_has_car ) {
echo 'Joe, please go to the store and get some paint. Thank you!';
}
}
// Cut Jack's boasting
add_filter( 'jacks_boast' , 'cut_the_boasting');
function cut_the_boasting($boast) {
// Replace "best" with "second-best"
$boast = str_replace ( "best" , "second-best" , $boast );
// Append another phrase at the end of his boast
$boast = $boast . ' However, Joe can outshine me any day.';
return $boast;
}
Thank You!
Thank you to those who use my affiliate links. As you know I make a small commission when someone uses my link and I want to say thank you to the following people. For all my recommended resources, go to my Resources Page
View on YourWebsiteEngineer.com
view more