Plugin Directory

Changeset 2542100


Ignore:
Timestamp:
06/03/2021 03:10:44 PM (5 years ago)
Author:
mattlitzinger
Message:

Version 0.6

Location:
recommend/trunk
Files:
6 added
4 edited

Legend:

Unmodified
Added
Removed
  • recommend/trunk/README.txt

    r2527503 r2542100  
    66Tested up to: 5.7
    77Requires PHP: 7.0
    8 Stable tag: 0.5
     8Stable tag: 0.6
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    12 Add like/recommend functionality to posts and pages. This metric can then be used to return more relevant search results or a collection of most liked posts/pages.
     12Recommend allows you to add a like user action to your content. Unlike social sharing or commenting, the like action is simple and intuitive. The like count can then be used to return more relevant search results or a collection of most liked posts.
    1313
    1414== Description ==
    1515
    1616= Features = 
    17 * Give users to ability to like a post
    18 * Display the number of likes on a post
    19 * Add the like count to any post/page
    20 
    21 = Advanced Options = 
     17* Give users a "like" action on posts 
     18* Display the like count on a post 
    2219* Custom label text for like count
    2320* Disable label text for count site-wide
    24 * Choose between a "Thumbs Up" or a "Heart" icon
     21* Choose between a \"Thumbs Up\" or a \"Heart\" icon
     22* Limit like action to specific post types
    2523* Disable plugin CSS or add custom styling rules
    2624
    27 To display the like count/link in your template, add the below code:
     25== Installation ==
    2826
    29     <?php if( function_exists('wp_recommend_show_likes') ) wp_recommend_show_likes(); ?>
     27Once the plugin is activated, the like count will be displayed below the content for individual posts across all post types. You can disable this in the plugin settings or define which post types to include.
    3028
    31 Or use the shortcode: `[wp-recommend-likes]` 
    32  
     29If you'd rather display the like count in your template files, use the below code:
     30```
     31<?php
     32    if( function_exists('wp_recommend_show_likes') ) {
     33        wp_recommend_show_likes();
     34    }
     35?>
     36```
     37
     38== Shortcodes ==
     39
     40The following shortcode will display the like count on any post. 
     41`[recommend-likes]` 
     42
     43The following shortcode will display a list of most liked posts. There are two optional parameters to fine tune the displayed results: `post_type` and `posts_per_page`. The default values for these parameters are shown in the example below.     
     44`[recommend-liked-posts post_type="post" posts_per_page="5"]`
     45
  • recommend/trunk/assets/css/wp-recommend.css

    r2527495 r2542100  
    1 a.wp-recommend-likes {
    2     display: block !important;
    3     margin: 0 !important;
    4     padding: 0 !important;
    5     border-bottom: 0 !important;
    6     text-decoration: none !important;
    7     color: #b4b4b4 !important;
     1button.recommend-likes {
     2    display: block;
     3    margin: 0;
     4    padding: 0;
     5    background: none;
     6    border: none;
     7    text-decoration: none;
     8    color: #484848;
    89    cursor: pointer;
    910}
    1011
    11 a.wp-recommend-likes:hover,
    12 a.wp-recommend-likes:focus {
    13     color: #5f5f5f !important;
     12button.recommend-likes:hover,
     13button.recommend-likes:focus {
     14    color: #333333;
    1415}
    1516
    16 a.wp-recommend-likes svg.wp-recommend-likes-icon {
     17button.recommend-likes svg.recommend-likes-icon {
    1718    position: relative;
    1819    top: 2px;
    19     display: inline-block !important;
     20    display: inline-block;
    2021    width: 16px;
    2122    height: 16px;
    22     fill: #b4b4b4;
     23    fill: #AD000E;
    2324}
    2425
    25 a.wp-recommend-likes:hover svg.wp-recommend-likes-icon,
    26 a.wp-recommend-likes:focus svg.wp-recommend-likes-icon {
    27     fill: #5f5f5f !important;
     26button.recommend-likes:hover svg.recommend-likes-icon,
     27button.recommend-likes:focus svg.recommend-likes-icon {
     28    fill: #AD000E;
    2829}
    2930
    30 a.wp-recommend-likes span.wp-recommend-likes-count {
    31     display: inline-block !important;
     31button.recommend-likes span.recommend-likes-count {
     32    display: inline-block;
    3233    margin-left: 6px;
    3334}
  • recommend/trunk/assets/js/like-action.js

    r2527495 r2542100  
    66
    77        // Check if cookie has been set
    8         if( getCookie('wp_recommend_likes') != null ) {
    9             liked_posts = JSON.parse( getCookie('wp_recommend_likes') );
     8        if( getCookie('recommend_likes') != null ) {
     9            liked_posts = JSON.parse( getCookie('recommend_likes') );
    1010        }
    1111
    1212        // Create an click event
    13         $('.wp-recommend-likes').click(function(){
     13        $('.recommend-likes').click(function(){
    1414            el = $(this);
    1515            post_id = el.data('post-id');
     
    2121                // Add post ID to the 'liked_posts' array
    2222                liked_posts.push(post_id);
    23                 // Update the 'wp_recommend_likes' cookie
    24                 setCookie('wp_recommend_likes', JSON.stringify(liked_posts), 30);
     23                // Update the 'recommend_likes' cookie
     24                setCookie('recommend_likes', JSON.stringify(liked_posts), 30);
    2525                // Make AJAX call to update the like count in the database
    2626                wp_recommend_increase_like_count( post_id );
    2727            } else {
    28                 console.log('howdy');
    2928                // Find the index of the post_id in the lided_posts array and remove it from the array
    3029                liked_posts.splice(liked_posts.indexOf( post_id ), 1);
    31                 // Update the 'wp_recommend_likes' cookie
    32                 setCookie('wp_recommend_likes', JSON.stringify(liked_posts), 30);
     30                // Update the 'recommend_likes' cookie
     31                setCookie('recommend_likes', JSON.stringify(liked_posts), 30);
    3332                // Make AJAX call to update the like count in the database
    3433                wp_recommend_decrease_like_count( post_id ); 
     
    3837            // Add post ID to the 'liked_posts' array
    3938            liked_posts.push(post_id);
    40             // Create new 'wp_recommend_likes' cookie
    41             setCookie('wp_recommend_likes', JSON.stringify(liked_posts), 30);
     39            // Create new 'recommend_likes' cookie
     40            setCookie('recommend_likes', JSON.stringify(liked_posts), 30);
    4241            // Make AJAX call to update the like count in the database
    4342            wp_recommend_increase_like_count( post_id );
     
    5554                },
    5655                beforeSend: function() {
    57                     el.children('.wp-recommend-likes-count').html('-');
     56                    el.children('.recommend-likes-count').html('-');
    5857                },
    5958                success: function(data){
     
    6160                    el.addClass('liked');
    6261                    el.attr('title', 'Unlike this');
    63                     el.children('.wp-recommend-likes-count').html(data['new_likes']);
    64                     el.children('.wp-recommend-likes-label').html(data['likes_label']);
     62                    el.children('.recommend-likes-count').html(data['new_likes']);
     63                    el.children('.recommend-likes-label').html(data['likes_label']);
    6564                }
    6665            });
     
    7776                },
    7877                beforeSend: function() {
    79                     el.children('.wp-recommend-likes-count').html('-');
     78                    el.children('.recommend-likes-count').html('-');
    8079                },
    8180                success: function(data){
     
    8382                    el.removeClass('liked');
    8483                    el.attr('title', 'Like this');
    85                     el.children('.wp-recommend-likes-count').html(data['new_likes']);
    86                     el.children('.wp-recommend-likes-label').html(data['likes_label']);
     84                    el.children('.recommend-likes-count').html(data['new_likes']);
     85                    el.children('.recommend-likes-label').html(data['likes_label']);
    8786                }
    8887            });
  • recommend/trunk/uninstall.php

    r2527495 r2542100  
    66}
    77
    8 // Function to uninstall the 'WP Recommend' plugin
     8// Function to uninstall the 'Recommend' plugin
    99function wp_recommend_delete_plugin() {
    1010
Note: See TracChangeset for help on using the changeset viewer.