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
add_filter('uwf-feedback-back', 'customize_uwf_profile_back', 10, 2);

function customize_uwf_profile_back($output , $instance){

}

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
add_filter('uwf-feedback-back', 'customize_uwf_profile_back', 10, 2);
 
function customize_uwf_profile_back($output , $instance){
    return $output . '<br /><br />Enter your username in the profile settings';
}

The following is the form appearance after adding the above code to your themes functions.php

WordPress Freelancer Hooks API Summary

  1. uwf-profile-front
  2. uwf-feedback-front
  3. uwf-affiliate-front

  4. uwf-profile-back

  5. uwf-feedback-back
  6. uwf-affiliate-back

  7. uwf-profile-settings

  8. uwf-feedback-settings
  9. uwf-affiliate-settings

  10. uwf-widget-customizer

  11. uwf-menu-init
  12. 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.