daily pastebin goal
47%
SHARE
TWEET

Untitled

a guest May 16th, 2018 103 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function getILikeThis($arg) {
  2.     global $wpdb;
  3.     $post_ID = get_the_ID();
  4.     $ip = $_SERVER['REMOTE_ADDR'];
  5.    
  6.     $liked = get_post_meta($post_ID, '_liked', true) != '' ? get_post_meta($post_ID, '_liked', true) : '0';
  7.     $voteStatusByIp = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."ilikethis_votes WHERE post_id = '$post_ID' AND ip = '$ip'");
  8.        
  9.     if (!isset($_COOKIE['liked-'.$post_ID]) && $voteStatusByIp == 0) {
  10.         if (get_option('ilt_textOrImage') == 'image') {
  11.             $counter = '<a onclick="likeThis('.$post_ID.');" class="image">'.$liked.'</a>';
  12.         }
  13.         else {
  14.             $counter = $liked.' <a onclick="likeThis('.$post_ID.');">'.get_option('ilt_text').'</a>';
  15.         }
  16.     }
  17.     else {
  18.         $counter = $liked;
  19.     }
  20.    
  21.     $iLikeThis = '<div id="iLikeThis-'.$post_ID.'" class="iLikeThis">';
  22.         $iLikeThis .= '<span class="counter">'.$counter.'</span>';
  23.     $iLikeThis .= '</div>';
  24.    
  25.     if ($arg == 'put') {
  26.         return $iLikeThis;
  27.     }
  28.     else {
  29.         echo $iLikeThis;
  30.     }
  31. }
  32.  
  33. if (get_option('ilt_onPage') == '1') {
  34.     function putILikeThis($content) {
  35.         if(!is_feed() && !is_page()) {
  36.             $content.= getILikeThis('put');
  37.         }
  38.         return $content;
  39.     }
  40.  
  41.     add_filter('the_content', putILikeThis);
  42. }
  43.  
  44. function enqueueScripts() {
  45.     if (get_option('ilt_jquery') == '1') {
  46.         wp_enqueue_script('iLikeThis', WP_PLUGIN_URL.'/i-like-this/js/i-like-this.js', array('jquery'));   
  47.     }
  48.     else {
  49.         wp_enqueue_script('iLikeThis', WP_PLUGIN_URL.'/i-like-this/js/i-like-this.js');
  50.     }
  51. }
  52.  
  53. function addHeaderLinks() {
  54.     echo '<link rel="stylesheet" type="text/css" href="'.WP_PLUGIN_URL.'/i-like-this/css/i-like-this.css" media="screen" />'."\n";
  55.     echo '<script type="text/javascript">var blogUrl = \''.get_bloginfo('wpurl').'\'</script>'."\n";
  56. }
  57.  
  58. add_action('init', enqueueScripts);
  59. add_action('wp_head', addHeaderLinks);
  60. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top