Changeset 2542100
- Timestamp:
- 06/03/2021 03:10:44 PM (5 years ago)
- Location:
- recommend/trunk
- Files:
-
- 6 added
- 4 edited
-
README.md (added)
-
README.txt (modified) (1 diff)
-
assets/css/wp-recommend.css (modified) (1 diff)
-
assets/js/like-action.js (modified) (7 diffs)
-
changelog.txt (added)
-
inc (added)
-
inc/admin.php (added)
-
inc/rest-api.php (added)
-
recommend.php (added)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
recommend/trunk/README.txt
r2527503 r2542100 6 6 Tested up to: 5.7 7 7 Requires PHP: 7.0 8 Stable tag: 0. 58 Stable tag: 0.6 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 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.12 Recommend 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. 13 13 14 14 == Description == 15 15 16 16 = 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 22 19 * Custom label text for like count 23 20 * 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 25 23 * Disable plugin CSS or add custom styling rules 26 24 27 To display the like count/link in your template, add the below code:25 == Installation == 28 26 29 <?php if( function_exists('wp_recommend_show_likes') ) wp_recommend_show_likes(); ?> 27 Once 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. 30 28 31 Or use the shortcode: `[wp-recommend-likes]` 32 29 If 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 40 The following shortcode will display the like count on any post. 41 `[recommend-likes]` 42 43 The 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; 1 button.recommend-likes { 2 display: block; 3 margin: 0; 4 padding: 0; 5 background: none; 6 border: none; 7 text-decoration: none; 8 color: #484848; 8 9 cursor: pointer; 9 10 } 10 11 11 a.wp-recommend-likes:hover,12 a.wp-recommend-likes:focus {13 color: # 5f5f5f !important;12 button.recommend-likes:hover, 13 button.recommend-likes:focus { 14 color: #333333; 14 15 } 15 16 16 a.wp-recommend-likes svg.wp-recommend-likes-icon {17 button.recommend-likes svg.recommend-likes-icon { 17 18 position: relative; 18 19 top: 2px; 19 display: inline-block !important;20 display: inline-block; 20 21 width: 16px; 21 22 height: 16px; 22 fill: # b4b4b4;23 fill: #AD000E; 23 24 } 24 25 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;26 button.recommend-likes:hover svg.recommend-likes-icon, 27 button.recommend-likes:focus svg.recommend-likes-icon { 28 fill: #AD000E; 28 29 } 29 30 30 a.wp-recommend-likes span.wp-recommend-likes-count {31 display: inline-block !important;31 button.recommend-likes span.recommend-likes-count { 32 display: inline-block; 32 33 margin-left: 6px; 33 34 } -
recommend/trunk/assets/js/like-action.js
r2527495 r2542100 6 6 7 7 // 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') ); 10 10 } 11 11 12 12 // Create an click event 13 $('. wp-recommend-likes').click(function(){13 $('.recommend-likes').click(function(){ 14 14 el = $(this); 15 15 post_id = el.data('post-id'); … … 21 21 // Add post ID to the 'liked_posts' array 22 22 liked_posts.push(post_id); 23 // Update the ' wp_recommend_likes' cookie24 setCookie(' wp_recommend_likes', JSON.stringify(liked_posts), 30);23 // Update the 'recommend_likes' cookie 24 setCookie('recommend_likes', JSON.stringify(liked_posts), 30); 25 25 // Make AJAX call to update the like count in the database 26 26 wp_recommend_increase_like_count( post_id ); 27 27 } else { 28 console.log('howdy');29 28 // Find the index of the post_id in the lided_posts array and remove it from the array 30 29 liked_posts.splice(liked_posts.indexOf( post_id ), 1); 31 // Update the ' wp_recommend_likes' cookie32 setCookie(' wp_recommend_likes', JSON.stringify(liked_posts), 30);30 // Update the 'recommend_likes' cookie 31 setCookie('recommend_likes', JSON.stringify(liked_posts), 30); 33 32 // Make AJAX call to update the like count in the database 34 33 wp_recommend_decrease_like_count( post_id ); … … 38 37 // Add post ID to the 'liked_posts' array 39 38 liked_posts.push(post_id); 40 // Create new ' wp_recommend_likes' cookie41 setCookie(' wp_recommend_likes', JSON.stringify(liked_posts), 30);39 // Create new 'recommend_likes' cookie 40 setCookie('recommend_likes', JSON.stringify(liked_posts), 30); 42 41 // Make AJAX call to update the like count in the database 43 42 wp_recommend_increase_like_count( post_id ); … … 55 54 }, 56 55 beforeSend: function() { 57 el.children('. wp-recommend-likes-count').html('-');56 el.children('.recommend-likes-count').html('-'); 58 57 }, 59 58 success: function(data){ … … 61 60 el.addClass('liked'); 62 61 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']); 65 64 } 66 65 }); … … 77 76 }, 78 77 beforeSend: function() { 79 el.children('. wp-recommend-likes-count').html('-');78 el.children('.recommend-likes-count').html('-'); 80 79 }, 81 80 success: function(data){ … … 83 82 el.removeClass('liked'); 84 83 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']); 87 86 } 88 87 }); -
recommend/trunk/uninstall.php
r2527495 r2542100 6 6 } 7 7 8 // Function to uninstall the ' WPRecommend' plugin8 // Function to uninstall the 'Recommend' plugin 9 9 function wp_recommend_delete_plugin() { 10 10
Note: See TracChangeset
for help on using the changeset viewer.