WordPress Freelancer Hooks API Explained
In the first article on WordPress Freelancer Hooks API, the basics of the api discussed and example code for a working example was explained. At the end of this article contains a list of all the available hooks in WordPress Freelancer Hooks API.
Customizing Widget Back end Appearance using WordPress Freelancer Hooks API
All widgets should extend WordPress Widget Class. UW_Freelancer_Feedback class (which is in class-uwf-feedback.php) extends WP_Widget in order to produce WordPress Freelancer Feedback Widget.
The form method in UW_Freelancer_Feedback called view file called ‘feedback-back.php’. Echo statement at the end of this file outputs the widget back end form. similar to the example that was discussed in the first article, just before echoing the output it apply filters. ‘uwf-feedback-back’ filter is applied to the output at this time. You can hook into this filter to alter/extend widget form.
Extending Feedback Widget Form with WordPress Freelancer Hooks API
All widgets should extend the WordPress widget class. UW_Freelancer_Feedback class (which is in class-uwf-feedback.php) extends WP_Widget class in order to produce WordPress Freelancer Feedback Widget.
The form method in UW_Freelancer_Feedback class calls a view file called ‘feedback-back.php’. Echo statement at the end of this file outputs the widget backend form. Similar to the example that was discussed in the first article, just before echoing the output it apply filters. ‘uwf-feedback-back’ filter is applied to the output at this time. You can hook into this filter to alter/extend widget form.
Extending Feedback Widget Form with WordPress Freelancer Hooks API
The following is how ‘uwf-feedback-back’ filter is applied inside the plugin core.
echo apply_filters(‘uwf-feedback-back’, $output, $instance );
The following code is an skeleton code you can put in your themes functions.php file to extend WordPress Feedback Widget output.
1 2 3 4 5 |
|
By default, all widget options are configured globally in plugin dashboard page. With WordPress Freelancer Hooks API you can localize these settings per widget instance. The following example demonstrates how to add an extra instruction to the WordPress Freelancer Feedback Widget admin form.
Suppose we want to add an extra line of instruction to the above form. We are given the current $output variable. We need to extend it to add an extra line. You can use the following code to achieve this.
1 2 3 4 5 |
|
The following is the form appearance after adding the above code to your themes functions.php
WordPress Freelancer Hooks API Summary
- uwf-profile-front
- uwf-feedback-front
uwf-affiliate-front
uwf-profile-back
- uwf-feedback-back
uwf-affiliate-back
uwf-profile-settings
- uwf-feedback-settings
uwf-affiliate-settings
uwf-widget-customizer
- uwf-menu-init
- uwf-customizer-footer
The above are the currently available hooks in the WordPress Freelancer Hooks API. Future versions of WordPress Freelancer Plugin API will add more hooks and they will be added to the above list later.