Git Product home page Git Product logo

favorites's Introduction

Favorites for Wordpress

Overview

Favorites is a WordPress plugin designed for end users and theme developers. It provides an easy-to-use API for adding favorite button functionality to any post type.

The plugin name is “Favorites,” but the button text is customizable. It can provide a way to save favorites, likes, bookmarks, or any other similar types of data.

Demo

View the Demo

Installation - WP Directory Download

  1. Upload the favorites plugin directory to the wp-content/plugins/ directory
  2. Activate the plugin through the Plugins menu in WordPress
  3. Visit the plugin settings to configure display options
  4. Use the template functions, display settings, or shortcodes to display the favorite button, favorite counts, and/or user favorites.

Installation - Git Clone

  1. Clone the repository to your site plugins directory
  2. Run composer install
  3. Activate the plugin through the Plugins menu in WordPress
  4. Visit the plugin settings to configure display options
  5. Use the template functions, display settings, or shortcodes to display the favorite button, favorite counts, and/or user favorites.

Usage

Favorite Button

The favorite button can be added automatically to the content by enabling specific post types in the plugin settings. It may also be added to template files or through the content editor using the included functions or shortcodes. The post id may be left blank in all cases if inside the loop. The site id parameter is optional, for use in multisite installations.

  • Get function: get_favorites_button($post_id, $site_id)
  • Print function: the_favorites_button($post_id, $site_id)
  • Shortcode: [favorite_button post_id="" site_id=""]

Favorite Count (by Post)

Total favorites for each post are saved as a simple integer. If a user unfavorites a post, this count is updated. Anonymous users' favorites count towards the total by default, but may be disabled via the plugin settings. The post id may be left blank in all cases if inside the loop.

  • Get function: get_favorites_count($post_id)
  • Print function: the_favorites_count($post_id)
  • Shortcode: [favorite_count post_id=""]

Favorite Count (by User)

Displays the total number of favorites a user has favorited. Template functions accept the same filters parameter as the user favorites functions.

  • Get function: get_user_favorites_count($user_id, $site_id, $filters)
  • Print function: the_user_favorites_count($user_id, $site_id, $filters)
  • Shortcode: [user_favorites user_id="" site_id="" post_types=""]

Favorite Count (All Users, All Posts)

Displays the total number of favorites across an entire site.

  • Get function: get_total_favorites_count($site_id)
  • Print function: the_total_favorites_count($site_id)

User Favorites

User favorites are stored as an array of post ids. Logged-in users' favorites are stored as a custom user meta field, while anonymous users' favorites are stored in either the session or browser cookie (configurable in the plugin settings). If the user id parameter is omitted, the favorites default to the current user. The site id parameter is optional, for use in multisite installations.

  • Get function (returns array of IDs): get_user_favorites($user_id, $site_id, $filters)
  • Get function (returns html list): get_user_favorites_list($user_id, $site_id, $include_links, $filters, include_thumbnails="false" thumbnail_size="thumbnail" include_excerpt="false")
  • Print function (prints an html list): the_user_favorites_list($user_id, $site_id, $include_links, $filters, include_thumbnails="false" thumbnail_size="thumbnail" include_excerpt="false")
  • Shortcode (prints an html list, with the option of omitting links): [user_favorites user_id="" include_links="true" site_id="" post_types="", include_thumbnails="false" thumbnail_size="thumbnail" include_excerpt="false"]

Clear Favorites Button

The clear favorites button clears out all of the current user's favorites.

  • Get function: get_clear_favorites_button($site_id, $button_text)
  • Print function: the_clear_favorites_button($site_id, $button_text)
  • Shortcode: [clear_favorites_button siteid="" text=""]

favorites's People

Contributors

kylephillips avatar renatonascalves avatar cadoo avatar gfargo avatar slimndap avatar stephenwidom avatar radwanhallak avatar

Stargazers

WTellos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.