Advertisement
Viruthagiri

cp_hooks.php

Jan 30th, 2012
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** Post hook */
  2. add_action('publish_post', 'cp_newPost');
  3. function cp_newPost($pid) {
  4.     global $blog_id;
  5.     $post = get_post($pid);
  6.     $uid = $post->post_author;
  7.     global $wpdb;
  8.     $count = (int) $wpdb->get_var("select count(id) from `".CP_DB."` where `type`='post' and `data`=". $pid);
  9.     if($count==0){
  10.        $pid = array( "post_id" => $pid, "blog_id" => $blog_id );
  11.         cp_points('post', $uid, apply_filters('cp_post_points',get_option('cp_post_points')), $pid);
  12.     }
  13. }
  14.  
  15.  
  16.  
  17. /** Post logs hook */
  18. add_action('cp_logs_description','cp_admin_logs_desc_post', 10, 4);
  19. function cp_admin_logs_desc_post($type,$uid,$points,$data){
  20.     if($type!='post') { return; }
  21.     global $wpdb;
  22.     $wpdb->get_var( "SELECT count(id) FROM ".CP_DB." WHERE type='post' AND data = '" . $data ."'" );
  23.     $blog_id = $wpdb->get_var( "SELECT blog_id FROM ".CP_DB." WHERE type = 'post' AND uid = " . $uid . " AND data = '" . $data . "'" );
  24.     if( $blog_id == 0 ) {
  25.         $post = get_post($data);
  26.         echo __('Created a Post', 'cp'). ' "<a href="'.get_permalink( $post ).'">' . $post->post_title . '</a>"';
  27.         } else {
  28.             $post = get_blog_post( $blog_id, $data );
  29.             echo __('Post on', 'cp') . ' "<a href="'.$post->guid.'">' . $post->post_title . '</a>"';
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement