/**
  *
  *
  * @see WP_List_Table::::single_row_columns()
  * @param array   $item A singular item (one full row's worth of data)
  * @return string Text to be placed inside the column <td> (movie title only)
  */
 function column_title($item)
 {
     $message_id = array_search($item->ID, get_option(SI_Messaging::NOTIFICATIONS_OPTION_NAME, array()));
     $name = $message_id ? SI_Messaging::$messages[$message_id]['name'] : sc__('Unassigned');
     $message = SC_Message::get_instance($item->ID);
     $status = $message->get_disabled() ? '<span style="color:red">' . sc__('disabled') . '</span>' : '<span>' . sc__('active') . '</span>';
     //Build row actions
     $actions = array('edit' => sprintf('<a href="%s">Edit</a>', get_edit_post_link($item->ID)));
     //Return the title contents
     return sprintf('%1$s <span style="color:silver">(status: %2$s)</span>%3$s', $name, $status, $this->row_actions($actions));
 }
Ejemplo n.º 2
0
 /**
  * Get message instance.
  * @param  string $message the slug for the message
  * @return SC_Message/false
  */
 public static function get_message_instance($message)
 {
     if (isset(self::$messages[$message])) {
         $messages = get_option(self::NOTIFICATIONS_OPTION_NAME);
         if (isset($messages[$message])) {
             $message_id = $messages[$message];
             $message = SC_Message::get_instance($message_id);
             if ($message != null) {
                 $post = $message->get_post();
                 // Don't return the message if isn't published (excludes deleted, draft, and future posts)
                 if ('publish' == $post->post_status) {
                     return $message;
                 }
             }
         }
     }
     return null;
     // return null and not a boolean for the sake of validity checks elsewhere
 }
 /**
  * main cllback for saving the message
  * @param  object  $message
  * @param  string $message_id
  * @return
  */
 public static function save_meta_box_message_submit($post_id, $post, $callback_args, $message_type = null)
 {
     if (null === $message_type && isset($_POST['message_type'])) {
         $message_type = $_POST['message_type'];
     }
     if (is_null($post_id)) {
         if (isset($_POST['ID'])) {
             $post_id = $_POST['ID'];
         }
     }
     if (get_post_type($post_id) != SC_Message::POST_TYPE) {
         return;
     }
     // Remove any existing message types that point to the post currently being saved
     $message_set = get_option(self::NOTIFICATIONS_OPTION_NAME, array());
     foreach ($message_set as $op_type => $note_id) {
         if ($note_id == $post_id) {
             unset($message_set[$post_id]);
         }
     }
     if (isset(self::$messages[$message_type])) {
         // Associate this post with the given message type
         $message_set[$message_type] = $post_id;
         update_option(self::NOTIFICATIONS_OPTION_NAME, $message_set);
     }
     $message = SC_Message::get_instance($post_id);
     // Mark as disabled or not.
     if (isset($_POST['message_type_disabled']) && $_POST['message_type_disabled'] == 'TRUE') {
         $message->set_disabled('TRUE');
     } else {
         $message->set_disabled(0);
     }
 }