Пример #1
0
 /**
  * Format 'targeting' value
  */
 public function column_targeting($data)
 {
     $target_tags = $data["target_tags"];
     $target_categories = $data["target_categories"];
     $target_posts = $data["target_posts"];
     // create a virtual Thank Me Later message
     $message = new Bbpp_ThankMeLater_Message();
     $message->addMessage(array("target_tags" => $target_tags, "target_categories" => $target_categories, "target_posts" => $target_posts));
     $posts = $message->getTargets();
     $count = count($posts);
     $sep = _x(", ", "separator in list of post names", "bbpp-thankmelater");
     $max_show = 2;
     if ($count == 0) {
         $summary = __("Targets 0 posts", "bbpp-thankmelater");
     } elseif ($count <= $max_show) {
         $names = "";
         $post = get_post($posts[$count - 1]);
         $last_name = $post->post_title;
         for ($i = 0; $i < $count - 1; $i++) {
             if ($i > 0) {
                 $names .= $sep;
             }
             $post = get_post($posts[$i]);
             $names .= $post->post_title;
         }
         $summary = sprintf(_n("Targets %2\$s", "Targets %s and %s", $count, "bbpp-thankmelater"), esc_html($names), esc_html($last_name));
     } else {
         $names = "";
         for ($i = 0; $i < $max_show; $i++) {
             if ($i > 0) {
                 $names .= $sep;
             }
             $post = get_post($posts[$i]);
             $names .= $post->post_title;
         }
         $view_all_url = "?page=" . urlencode(stripslashes($_REQUEST["page"])) . "&action=targets" . "&id=" . $data["id"];
         $summary = sprintf(_n("Targets %s and %s%d other post%s", "Targets %s and %s%d other posts%s.", $count - $max_show, "bbpp-thankmelater"), esc_html($names), "<a href=\"{$view_all_url}\">", $count - $max_show, "</a>");
     }
     if (!$target_categories && !$target_tags && !$target_posts) {
         $summary = __("Targets all posts", "bbpp-thankmelater");
     }
     return $summary;
 }
Пример #2
0
 /**
  * Get a full list of all posts targeted by a message
  * 
  * @param type $id
  */
 public function targets($id)
 {
     // create a virtual Thank Me Later message
     $message = new Bbpp_ThankMeLater_Message($id);
     $posts = $message->getTargets();
     $count = count($posts);
     require_once BBPP_THANKMELATER_PLUGIN_PATH . "admin/messages/targets.php";
 }