Extension plugins for the plugin (using hooks)
-
During the last couple of years I have helped several users with all kind of requests to alter the working of the plugin. When I change the plugin’s behavior I try use hooks as much as possible. Because when you use hooks, then an upgrade of the plugin won’t overwrite your code changes.
The help page in the plugin contains some examples and also links to some resources on the internet that can help you make your own additions to the plugin.
But because I also made some myself, I decided to write this post to share them with you.
One important note: some of these extensions are very old, so it is possible that some won’t work anymore in the plugin. Maybe the hook is gone or the functionality made it to the core of the plugin, making the extension useless. But the file may still be valuable as an example for you.
Example
If you want to use the hooks in the plugin you have to place your code somewhere so WordPress can pick it up. One place you can put your code is the functions.php of your theme, but I personally prefer writing a simple plugin that you can simply activate/deactivate. I created a template file that you can use to create your own plugin.
football-pool-extension-template.phpAdd match result to User page
As the name says: it adds the match result to the page where you can see the predictions for a user.
football-pool-add-match-result-to-user-page.phpChange what the ranking looks like
This is a simple example on how you can change what you want to show in the ranking. This extension always shows the league image in the ranking. If you want to change the looks for the view for all users, you will have to check the variable$all_user_view
. The$type
variable that is passed to the function tells you if the ranking is displayed in the page, the shortcode or the widget.
football-pool-change-ranking-template.phpLogin names in ranking
This extension shows the login name of users in the ranking instead of the display name.
football-pool-login-names-in-ranking.phpChange the display of user names everywhere in the plugin
The plugin normally shows the display name for a user in the plugin (e.g. the ranking, the shoutbox, etc.). But it is very easy to change this to another field in the User object or if you would like to add extra HTML code.
football-pool-username-extension.phpChange the score calculation (v2.5 and up)
Since version 2.5 changing the way the plugin calculates the score has become very simple. This example also rewards the goal diff points when the match ended in a draw and the user predicted a draw.
football-pool-extension-change-calc-score.phpChange the prediction form HTML
Just two simple examples on how you can change the prediction form. The first one adds a save button to the top of the form. The second one changes every row in the form and adds a save button in the row.
football-pool-extra-match-save-button-at-top.php
football-pool-extra-match-save-buttons.phpOrder match predictions
Order match predictions by score and don’t show users without predictions.
football-pool-matchpredictions-order.phpOnly show ‘open’ matches on the form
If you want to hide matches that can’t be changed anymore in the form, you can use this extension. It simply filters out the matches in the form that are no longer editable for a user and returns this set to the function that creates the form.
football-pool-only-open-matches.phpPagination
Also in the help page of the plugin. A simple function that adds pagination to the ranking, matches and prediction page of the plugin. Useful if you have a lot of data and don’t want to show everything on one page.
football-pool-pagination.php
- The topic ‘Extension plugins for the plugin (using hooks)’ is closed to new replies.