Changeset 1108796
- Timestamp:
- 03/09/2015 02:27:45 PM (11 years ago)
- Location:
- simple-custom-post-likes/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
simple-custom-post-likes/trunk/admin.php
r1103117 r1108796 17 17 <tr> 18 18 <th scope="row"><label for="content_element">Select Element to append to</label></th> 19 <td><input id="content_element" type="text" name="content_element" value="<?php if(get_option( 'favourates_element' )) {19 <td><input type="text" name="content_element" placeholder="<?php if(get_option( 'favourates_element', 'post' )) { 20 20 echo get_option( 'favourates_element' ); 21 21 } ?>"></td> … … 49 49 $type = $_POST['content_element']; 50 50 update_option( 'favourates_element', $type , '', 'yes' ); 51 ?>52 <script>53 jQuery(document).ready(function($) {54 jQuery('#content_element').val("<?php echo $type; ?>");55 });</script>56 <?php57 51 } 58 52 ?> -
simple-custom-post-likes/trunk/index.php
r1103165 r1108796 1 1 <?php 2 /** 3 * Plugin Name: Simple Featured post likes 4 * Description: Adds Likes/Favorites to Wordpress post or custom post type. 5 * Author: Richard Miles 6 * Version: 1.0.1 7 * Author URI: http://richymiles.wordpress.com 8 */ 9 2 /* 3 Plugin Name: Simple Featured post likes 4 Description: Adds Likes/Favorites to Wordpress post or custom post type. 5 Author: Richard Miles 6 Version: 1.0 7 Author URI: http://richymiles.wordpress.com 8 */ 10 9 11 10 function get_users_array($post_id) { 12 11 $new_array = array(); 13 12 $array = get_post_meta($post_id,'favourite_users'); 14 if ( !$array) {13 if (empty($array) || is_null($array)) { 15 14 return false; 16 15 } 17 foreach($array[0] as $key => $value) 16 foreach($array[0] as $key => $value) { 18 17 $new_array[$key] = $value; 18 } 19 19 return $new_array; 20 20 } … … 23 23 $new_array = array(); 24 24 $array = get_post_meta($post_id,'favourite_users'); 25 if ( ! $array) {26 return false;25 if (empty($array) || is_null($array)) { 26 return 0; 27 27 } 28 28 $count = 0; … … 39 39 if (isset($_REQUEST['post_id'])) { 40 40 $users = get_users_array($_REQUEST['post_id']); 41 $liked ;41 $liked = false; 42 42 if ($users) { 43 43 if(!in_array(get_user_id(), $users)) { 44 ?> 45 <?php 46 $liked = false; 47 array_push($users, get_user_id()); 48 update_post_meta($_REQUEST['post_id'], 'favourite_users', $users); 44 array_push($users, get_user_id()); 45 update_post_meta($_REQUEST['post_id'], 'favourite_users', $users); 49 46 } else { 50 47 $liked = true; … … 79 76 // } 80 77 81 add_action('admin_menu', ' add_likes_menu');78 add_action('admin_menu', 'my_plugin_menu'); 82 79 83 function add_likes_menu() {80 function my_plugin_menu() { 84 81 add_options_page('My Options', 'Favourite Posts', 'manage_options', plugin_dir_path( __FILE__ ) . 'admin.php'); 85 82 } 86 83 87 84 88 add_action('wp_head',' simple_likes_ajaxurl');85 add_action('wp_head','pluginname_ajaxurl'); 89 86 90 function simple_likes_ajaxurl() {87 function pluginname_ajaxurl() { 91 88 ?> 92 89 <script type="text/javascript"> … … 138 135 //status is the http request status - 200 for all good, 404 not found e.t.c 139 136 jQuery('#user_favourite').val(value); 140 console.log( "success");137 console.log(value); 141 138 if (obj.liked) { 142 139 jQuery('#user_favourite').css('background' , 'tomato'); … … 153 150 <?php 154 151 // echo get_user_id(); 155 $content .= ob_get_contents(); 152 if (is_single()) { 153 $content .= ob_get_contents(); 154 } 155 156 156 ob_end_clean(); 157 157 } -
simple-custom-post-likes/trunk/readme.txt
r1103168 r1108796 1 1 === Simple custom post likes === 2 Contributors: richymilo , leogopal3 Donate link: http:// richymiles.wordpress.com4 Tags: custom post types, likes, featured , voting, rating, polling5 Requires at least: 3. 92 Contributors: richymilo 3 Donate link: http://wobble.co.za/ 4 Tags: custom post types, likes, featured 5 Requires at least: 3.0.1 6 6 Tested up to: 4.1.1 7 Stable tag: 1.0.17 Stable tag: 4.3 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 36 36 37 37 == Changelog == 38 = 1.0.1 =39 * Minor Changes40 * Added Uninstall.php to clean up database when uninstalled.41 42 38 = 1.0 = 43 39 * First Version, Basic Working copy 44 * Fixed a few backend bugs, uses value now instead of placeholder 40 41 = 1.0.1 = 42 * Support added for single post
Note: See TracChangeset
for help on using the changeset viewer.