Advertisement
bigorangemachine

Untitled

Sep 20th, 2011
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.58 KB | None | 0 0
  1. <?php
  2. function my_init(){
  3.     if(function_exists('wpfp_list_favorite_posts')){
  4.         add_shortcode('my-wp-favorite-posts', 'my_wpfp_list_favorite_posts');
  5.     }
  6. }
  7. function my_wpfp_list_favorite_posts( $args = array() ) {
  8.     $user = $_REQUEST['user'];
  9.     if(array_check($args)){extract($args);}
  10.     $wpfp_options = wpfp_get_options();
  11.     if (!empty($user)):
  12.         if (!wpfp_is_user_favlist_public($user)):
  13.             $favorite_post_ids = wpfp_get_users_favorites($user);
  14.         endif;
  15.     else:
  16.         $favorite_post_ids = wpfp_get_users_favorites();
  17.     endif;
  18.  
  19.         $output =NULL;
  20.     $output.="<div class='wpfp-span'>";
  21.     if (!empty($user)):
  22.         if (!wpfp_is_user_favlist_public($user)):
  23.             $output.="$user's Favorite Posts.";
  24.         else:
  25.             $output.="$user's list is not public.";
  26.         endif;
  27.     endif;
  28.  
  29.     if ($wpfp_before):
  30.         $output.="<p>".$wpfp_before."</p>";
  31.     endif;
  32.  
  33.     $output.="<ul>";
  34.     if ($favorite_post_ids):
  35.         foreach ($favorite_post_ids as $post_id) {
  36.             $p = get_post($post_id);
  37.             $output.="<li>";
  38.             $output.="<a href='".get_permalink($post_id)."' title='". $p->post_title ."'>" . $p->post_title . "</a> ";
  39.             $output.=my_wpfp_remove_favorite_link($post_id);
  40.             $output.="</li>";
  41.         }
  42.     else:
  43.         $output.="<li>";
  44.         $output.=$wpfp_options['favorites_empty'];
  45.         $output.="</li>";
  46.     endif;
  47.     $output.="</ul>";
  48.     $output.=my_wpfp_clear_list_link();
  49.     $output.="</div>";
  50.     $output.=wpfp_cookie_warning();
  51.         return $output;
  52. }
  53.  
  54. function my_wpfp_remove_favorite_link($post_id) {
  55.     if (wpfp_is_user_can_edit()) {
  56.         $wpfp_options = wpfp_get_options();
  57.         $class = 'wpfp-link remove-parent';
  58.         $link = "<a id='rem_$post_id' class='$class' href='?wpfpaction=remove&amp;page=1&amp;postid=". $post_id ."' title='".wpfp_get_option('rem')."' rel='nofollow'>".wpfp_get_option('rem')."</a>";
  59.         $link = apply_filters( 'wpfp_remove_favorite_link', $link );
  60.         return $link;
  61.     }
  62. }
  63. function my_wpfp_clear_list_link() {
  64.     if (wpfp_is_user_can_edit()) {
  65.         $wpfp_options = wpfp_get_options();
  66.         $out =NULL;
  67.                 $out.=wpfp_before_link_img();
  68.         $out.=wpfp_loading_img();
  69.         return $out."<a class='wpfp-link' href='?wpfpaction=clear' rel='nofollow'>". wpfp_get_option('clear') . "</a>";
  70.     }
  71. }
  72. function my_wpfp_cookie_warning() {
  73.     if (!is_user_logged_in() && !isset($_GET['user']) ):
  74.         return "<p>".wpfp_get_option('cookie_warning')."</p>";
  75.     endif;
  76. }
  77. add_action('init','my_init');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement