A WordPress plugin for basic management of favourite posts and pages.
Note that the plugin folder should be named favourites
. This is because if the GitHub Updater plugin is used to update this plugin, if the folder is named something other than this, it will get deleted, and the updated plugin folder with a different name will cause the plugin to be silently deactivated.
In the setup for your theme:
global $PF;
$PF = null;
if ( class_exists( 'Pilau_Favourites' ) ) {
$PF = Pilau_Favourites::get_instance();
}
In the template where you want a favourite link:
global $PF;
echo $PF->favourite_link();
Is the current post favourited by the current user?
if ( $PF->favourited() ) {
// Do stuff
}
Get the current user's favourites (an array of post IDs):
$current_user_favourites = $PF->get_user_favourites();
pf_add_favourite_text
- Link text for adding a favouritepf_remove_favourite_text
- Link text for adding a favourite