function jl_brd_dashboard_recent_drafts($drafts = false)
{
    if (!$drafts) {
        $drafts_query = new WP_Query(array('post_type' => 'any', 'post_status' => array('draft', 'pending'), 'posts_per_page' => 150, 'orderby' => 'modified', 'order' => 'DESC'));
        $drafts =& $drafts_query->posts;
    }
    if ($drafts && is_array($drafts)) {
        $list = array();
        foreach ($drafts as $draft) {
            $url = get_edit_post_link($draft->ID);
            $title = _draft_or_post_title($draft->ID);
            $last_id = get_post_meta($draft->ID, '_edit_last', true);
            $last_user = get_userdata($last_id);
            $last_modified = '<i>' . esc_html($last_user->display_name) . '</i>';
            $item = '<h4><a href="' . $url . '" title="' . sprintf(__('Edit ?%s?'), esc_attr($title)) . '">' . esc_html($title) . '</a>' . '<abbr> ' . $draft->post_status . ' ' . $draft->post_type . '</abbr>' . '<abbr style="display:block;margin-left:0;">' . sprintf(__('Last edited by %1$s on %2$s at %3$s'), $last_modified, mysql2date(get_option('date_format'), $draft->post_modified), mysql2date(get_option('time_format'), $draft->post_modified)) . '</abbr></h4>';
            if ($the_content = preg_split('#\\s#', strip_shortcodes(strip_tags($draft->post_content), 11, PREG_SPLIT_NO_EMPTY))) {
                $item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
            }
            $list[] = $item;
        }
        ?>
	<ul>
		<li><?php 
        echo join("</li>\n<li>", $list);
        ?>
</li>
	</ul>
<?php 
    } else {
        _e('There are no drafts at the moment');
    }
}
Example #2
0
 /**
  * @see CPAC_Column_Actions::get_actions()
  * @since 2.3.4
  */
 public function get_actions($id)
 {
     global $wp_list_table;
     if (!$wp_list_table) {
         return;
     }
     $post = get_post($id);
     $att_title = _draft_or_post_title($id);
     $actions = array();
     if ($wp_list_table->detached) {
         if (current_user_can('edit_post', $post->ID)) {
             $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
         }
         if (current_user_can('delete_post', $post->ID)) {
             if (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
                 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post={$post->ID}", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
             } else {
                 $delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
                 $actions['delete'] = "<a class='submitdelete'{$delete_ays} href='" . wp_nonce_url("post.php?action=delete&amp;post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
             }
         }
         $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $att_title)) . '" rel="permalink">' . __('View') . '</a>';
         if (current_user_can('edit_post', $post->ID)) {
             $actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\'' . $post->ID . '\' );return false;" class="hide-if-no-js">' . __('Attach') . '</a>';
         }
     } else {
         if (current_user_can('edit_post', $post->ID) && !$wp_list_table->is_trash) {
             $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '">' . __('Edit') . '</a>';
         }
         if (current_user_can('delete_post', $post->ID)) {
             if ($wp_list_table->is_trash) {
                 $actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=untrash&amp;post={$post->ID}", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
             } elseif (EMPTY_TRASH_DAYS && MEDIA_TRASH) {
                 $actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url("post.php?action=trash&amp;post={$post->ID}", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
             }
             if ($wp_list_table->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH) {
                 $delete_ays = !$wp_list_table->is_trash && !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
                 $actions['delete'] = "<a class='submitdelete'{$delete_ays} href='" . wp_nonce_url("post.php?action=delete&amp;post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
             }
         }
         if (!$wp_list_table->is_trash) {
             $title = _draft_or_post_title($post->post_parent);
             $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
         }
     }
     /**
      * Filter the action links for each attachment in the Media list table.
      *
      * @since 2.8.0
      *
      * @param array   $actions  An array of action links for each attachment.
      *                          Default 'Edit', 'Delete Permanently', 'View'.
      * @param WP_Post $post     WP_Post object for the current attachment.
      * @param bool    $detached Whether the list table contains media not attached
      *                          to any posts. Default true.
      */
     $actions = apply_filters('media_row_actions', $actions, $post, $wp_list_table->detached);
     return $actions;
 }
Example #3
0
 /**
  * Get column value of media actions
  *
  * This part is copied from the Media List Table class
  *
  * @since 1.4.2
  *
  * @param int $id
  * @return string Actions
  */
 private function get_column_value_actions($id)
 {
     if (file_exists(ABSPATH . 'wp-admin/includes/class-wp-list-table.php')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
     }
     if (file_exists(ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php')) {
         require_once ABSPATH . 'wp-admin/includes/class-wp-media-list-table.php';
     }
     // we need class to get the object actions
     $m = new WP_Media_List_Table();
     // prevent php notice
     $m->is_trash = isset($_REQUEST['status']) && 'trash' == $_REQUEST['status'];
     // get media actions
     $media = get_post($id);
     $actions = $m->_get_row_actions($media, _draft_or_post_title($id));
     return implode(' | ', $actions);
 }
function media_custom_columns($column_name, $id)
{
    $post = get_post($id);
    if ($column_name != 'better_parent') {
        return;
    }
    if ($post->post_parent > 0) {
        if (get_post($post->post_parent)) {
            $title = _draft_or_post_title($post->post_parent);
        }
        ?>
	            <strong><a href="<?php 
        echo get_edit_post_link($post->post_parent);
        ?>
"><?php 
        echo $title;
        ?>
</a></strong>, <?php 
        echo get_the_time(__('Y/m/d'));
        ?>
	            <br />
	            <a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php 
        echo $post->ID;
        ?>
');return false;" href="#the-list"><?php 
        _e('Re-Attach');
        ?>
</a>
	            <?php 
    } else {
        ?>
	            <?php 
        _e('(Unattached)');
        ?>
<br />
	            <a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php 
        echo $post->ID;
        ?>
');return false;" href="#the-list"><?php 
        _e('Attach');
        ?>
</a>
	            <?php 
    }
}
Example #5
0
 /**
  * @see CPAC_Column_Actions::get_actions()
  * @since 2.2.6
  */
 public function get_actions($item_id)
 {
     $actions = array();
     $post = get_post($item_id);
     $title = _draft_or_post_title();
     $post_type_object = get_post_type_object($post->post_type);
     $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
     $quickedit_enabled = false;
     $stored_columns = $this->get_storage_model()->get_stored_columns();
     foreach ($stored_columns as $column) {
         if ($column['type'] == 'title') {
             $quickedit_enabled = true;
         }
     }
     // taken from Wordpress core
     if ($can_edit_post && 'trash' != $post->post_status) {
         $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
         if ($quickedit_enabled) {
             $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
         }
     }
     if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
         if ('trash' == $post->post_status) {
             $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
         }
         if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
         }
     }
     if ($post_type_object->public) {
         if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
             if ($can_edit_post) {
                 $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
             }
         } elseif ('trash' != $post->post_status) {
             $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
         }
     }
     return $actions;
 }
function anno_wp_dashboard_recent_post_types($args)
{
    /* Chenged from here */
    if (!$args['post_type']) {
        $args['post_type'] = 'any';
    }
    $query_args = array('post_type' => $args['post_type'], 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $i = 0;
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today', 'annot');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow', 'anno');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS', 'anno'), $time);
            }
            $text = sprintf(_x('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>', '1: relative date, 2: time, 4: post title', 'anno'), $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title());
            $hidden = $i >= $args['display'] ? ' class="hidden"' : '';
            echo "<li{$hidden}>{$text}</li>";
            $i++;
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}
 /**
  * Return title column
  * @param  object $webhook
  * @return string
  */
 public function column_title($webhook)
 {
     $the_webhook = $this->get_webbook_object($webhook);
     $edit_link = admin_url('admin.php?page=wc-settings&amp;tab=api&amp;section=webhooks&amp;edit-webhook=' . $the_webhook->id);
     $title = _draft_or_post_title($the_webhook->get_post_data());
     $post_type_object = get_post_type_object($the_webhook->get_post_data()->post_type);
     $post_status = $the_webhook->get_post_data()->post_status;
     // Title
     $output = '<strong>';
     if ('trash' == $post_status) {
         $output .= esc_html($title);
     } else {
         $output .= '<a href="' . esc_url($edit_link) . '" class="row-title">' . esc_html($title) . '</a>';
     }
     $output .= '</strong>';
     // Get actions
     $actions = array('id' => sprintf(__('ID: %d', 'woocommerce'), $the_webhook->id));
     if (current_user_can($post_type_object->cap->edit_post, $the_webhook->id) && 'trash' !== $post_status) {
         $actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'woocommerce') . '</a>';
     }
     if (current_user_can($post_type_object->cap->delete_post, $the_webhook->id)) {
         if ('trash' == $post_status) {
             $actions['untrash'] = '<a title="' . esc_attr__('Restore this item from the Trash', 'woocommerce') . '" href="' . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $the_webhook->id)), 'untrash-post_' . $the_webhook->id) . '">' . __('Restore', 'woocommerce') . '</a>';
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = '<a class="submitdelete" title="' . esc_attr(__('Move this item to the Trash', 'woocommerce')) . '" href="' . get_delete_post_link($the_webhook->id) . '">' . __('Trash', 'woocommerce') . '</a>';
         }
         if ('trash' == $post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = '<a class="submitdelete" title="' . esc_attr(__('Delete this item permanently', 'woocommerce')) . '" href="' . get_delete_post_link($the_webhook->id, '', true) . '">' . __('Delete Permanently', 'woocommerce') . '</a>';
         }
     }
     $actions = apply_filters('post_row_actions', $actions, $the_webhook->get_post_data());
     $row_actions = array();
     foreach ($actions as $action => $link) {
         $row_actions[] = '<span class="' . esc_attr($action) . '">' . $link . '</span>';
     }
     $output .= '<div class="row-actions">' . implode(' | ', $row_actions) . '</div>';
     return $output;
 }
Example #8
0
function xt_manage_post_custom_column($column, $post_id)
{
    switch ($column) {
        case 'icon':
            $att_title = _draft_or_post_title();
            ?>
				<a href="<?php 
            echo esc_url(get_edit_post_link($post_id, true));
            ?>
" title="<?php 
            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;', XT_TEXT_DOMAIN), $att_title));
            ?>
"><?php 
            if ($thumb = get_the_post_thumbnail($post_id, array(80, 60))) {
                echo $thumb;
            } else {
                echo '<img width="46" height="60" src="' . wp_mime_type_icon('image/jpeg') . '" alt="">';
            }
            ?>
</a>
<?php 
            break;
    }
}
 /**
  * Generates and displays row action links.
  *
  * @since 4.3.0
  * @access protected
  *
  * @param object $post        Post being acted upon.
  * @param string $column_name Current column name.
  * @param string $primary     Primary column name.
  * @return string Row actions output for posts.
  */
 protected function handle_row_actions($post, $column_name, $primary)
 {
     if ($primary !== $column_name) {
         return '';
     }
     $post_type_object = get_post_type_object($post->post_type);
     $can_edit_post = current_user_can('edit_post', $post->ID);
     $actions = array();
     if ($can_edit_post && 'trash' != $post->post_status) {
         $actions['edit'] = '<a href="' . get_edit_post_link($post->ID) . '" title="' . esc_attr__('Edit this item') . '">' . __('Edit') . '</a>';
         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__('Edit this item inline') . '">' . __('Quick&nbsp;Edit') . '</a>';
     }
     if (current_user_can('delete_post', $post->ID)) {
         if ('trash' == $post->post_status) {
             $actions['untrash'] = "<a title='" . esc_attr__('Restore this item from the Trash') . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__('Move this item to the Trash') . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
         }
         if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__('Delete this item permanently') . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
         }
     }
     if (is_post_type_viewable($post_type_object)) {
         $title = _draft_or_post_title();
         if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
             if ($can_edit_post) {
                 $preview_link = set_url_scheme(get_permalink($post->ID));
                 /** This filter is documented in wp-admin/includes/meta-boxes.php */
                 $preview_link = apply_filters('preview_post_link', add_query_arg('preview', 'true', $preview_link), $post);
                 $actions['view'] = '<a href="' . esc_url($preview_link) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
             }
         } elseif ('trash' != $post->post_status) {
             $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
         }
     }
     if (is_post_type_hierarchical($post->post_type)) {
         /**
          * Filter the array of row action links on the Pages list table.
          *
          * The filter is evaluated only for hierarchical post types.
          *
          * @since 2.8.0
          *
          * @param array $actions An array of row action links. Defaults are
          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
          *                         'Delete Permanently', 'Preview', and 'View'.
          * @param WP_Post $post The post object.
          */
         $actions = apply_filters('page_row_actions', $actions, $post);
     } else {
         /**
          * Filter the array of row action links on the Posts list table.
          *
          * The filter is evaluated only for non-hierarchical post types.
          *
          * @since 2.8.0
          *
          * @param array $actions An array of row action links. Defaults are
          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
          *                         'Delete Permanently', 'Preview', and 'View'.
          * @param WP_Post $post The post object.
          */
         $actions = apply_filters('post_row_actions', $actions, $post);
     }
     return $this->row_actions($actions);
 }
 function custom_hubpage_columns($column)
 {
     global $post;
     switch ($column) {
         case "hub_title":
             $edit_link = get_edit_post_link($post->ID);
             $title = _draft_or_post_title();
             $post_type_object = get_post_type_object($post->post_type);
             $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
             echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>';
             _post_states($post);
             echo '</strong>';
             if ($post->post_parent > 0) {
                 echo '&nbsp;&nbsp;&larr; <a href="' . get_edit_post_link($post->post_parent) . '">' . get_the_title($post->post_parent) . '</a>';
             }
             // Excerpt view
             if (isset($_GET['mode']) && $_GET['mode'] == 'excerpt') {
                 echo apply_filters('the_excerpt', $post->post_excerpt);
             }
             // Get actions
             $actions = array();
             $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
             if ($can_edit_post && 'trash' != $post->post_status) {
                 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline', WPC_CLIENT_TEXT_DOMAIN)) . '">' . __('Quick&nbsp;Edit', WPC_CLIENT_TEXT_DOMAIN) . '</a>';
             }
             if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                 if ('trash' == $post->post_status) {
                     $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash', WPC_CLIENT_TEXT_DOMAIN)) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore', WPC_CLIENT_TEXT_DOMAIN) . "</a>";
                 } elseif (EMPTY_TRASH_DAYS) {
                     $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash', WPC_CLIENT_TEXT_DOMAIN)) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash', WPC_CLIENT_TEXT_DOMAIN) . "</a>";
                 }
                 if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                     $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently', WPC_CLIENT_TEXT_DOMAIN)) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently', WPC_CLIENT_TEXT_DOMAIN) . "</a>";
                 }
             }
             if ($post_type_object->public) {
                 if ('trash' != $post->post_status) {
                     $actions['view'] = '<a href="' . wpc_client_get_slug('hub_page_id') . $post->ID . '" target="_blank" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;', WPC_CLIENT_TEXT_DOMAIN), $title)) . '" rel="permalink">' . __('Preview', WPC_CLIENT_TEXT_DOMAIN) . '</a>';
                 }
             }
             $actions = apply_filters('post_row_actions', $actions, $post);
             echo '<div class="row-actions">';
             $i = 0;
             $action_count = sizeof($actions);
             foreach ($actions as $action => $link) {
                 ++$i;
                 $i == $action_count ? $sep = '' : ($sep = ' | ');
                 echo "<span class='{$action}'>{$link}{$sep}</span>";
             }
             echo '</div>';
             get_inline_data($post);
             break;
         case "client":
             $client = get_users(array('role' => 'wpc_client', 'meta_key' => 'wpc_cl_hubpage_id', 'meta_value' => $post->ID));
             if ($client) {
                 echo $client[0]->user_login;
             }
             break;
     }
 }
Example #11
0
/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => 'future' === $args['status'] ? 'editable' : 'readable');
    /**
     * Filter the query arguments used for the Recent Posts widget.
     *
     * @since 4.2.0
     *
     * @param array $query_args The arguments passed to WP_Query to produce the list of posts.
     */
    $query_args = apply_filters('dashboard_recent_posts_query_args', $query_args);
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            // Use the post edit link for those who can edit, the permalink otherwise.
            $recent_post_link = current_user_can('edit_post', get_the_ID()) ? get_edit_post_link() : get_permalink();
            /* translators: 1: relative date, 2: time, 3: post edit link or permalink, 4: post title */
            $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
            printf("<li>{$format}</li>", $relative, get_the_time(), $recent_post_link, _draft_or_post_title());
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}
Example #12
0
function wp_dashboard_recent_drafts($drafts = false)
{
    if (!$drafts) {
        $drafts_query = new WP_Query(array('post_type' => 'post', 'post_status' => 'draft', 'author' => $GLOBALS['current_user']->ID, 'posts_per_page' => 5, 'orderby' => 'modified', 'order' => 'DESC'));
        $drafts =& $drafts_query->posts;
    }
    if ($drafts && is_array($drafts)) {
        $list = array();
        foreach ($drafts as $draft) {
            $url = get_edit_post_link($draft->ID);
            $title = _draft_or_post_title($draft->ID);
            $item = "<h4><a href='{$url}' title='" . sprintf(__('Edit &#8220;%s&#8221;'), esc_attr($title)) . "'>" . esc_html($title) . "</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time(get_option('date_format'), $draft) . '</abbr></h4>';
            if ($the_content = preg_split('#\\s#', strip_tags($draft->post_content), 11, PREG_SPLIT_NO_EMPTY)) {
                $item .= '<p>' . join(' ', array_slice($the_content, 0, 10)) . (10 < count($the_content) ? '&hellip;' : '') . '</p>';
            }
            $list[] = $item;
        }
        ?>
	<ul>
		<li><?php 
        echo join("</li>\n<li>", $list);
        ?>
</li>
	</ul>
	<p class="textright"><a href="edit.php?post_status=draft" ><?php 
        _e('View all');
        ?>
</a></p>
<?php 
    } else {
        _e('There are no drafts at the moment');
    }
}
    default:
        if (!($revision = wp_get_post_revision($revision_id))) {
            break;
        }
        if (!($post = get_post($revision->post_parent))) {
            break;
        }
        if (!current_user_can('read_post', $revision->ID) || !current_user_can('read_post', $post->ID)) {
            break;
        }
        // Revisions disabled and we're not looking at an autosave
        if (!wp_revisions_enabled($post) && !wp_is_post_autosave($revision)) {
            $redirect = 'edit.php?post_type=' . $post->post_type;
            break;
        }
        $post_title = '<a href="' . get_edit_post_link() . '">' . _draft_or_post_title() . '</a>';
        $h2 = sprintf(__('Compare Revisions of &#8220;%1$s&#8221;'), $post_title);
        $title = __('Revisions');
        $redirect = false;
        break;
}
// Empty post_type means either malformed object found, or no valid parent was found.
if (!$redirect && empty($post->post_type)) {
    $redirect = 'edit.php';
}
if (!empty($redirect)) {
    wp_redirect($redirect);
    exit;
}
// This is so that the correct "Edit" menu item is selected.
if (!empty($post->post_type) && 'post' != $post->post_type) {
Example #14
0
    ?>
</th>
	<th scope="col"><?php 
    /* translators: column name in media */
    echo _x('Date Added', 'media column name');
    ?>
</th>
</tr>
</tfoot>

<tbody id="the-list" class="list:post">
<?php 
    if ($orphans) {
        foreach ($orphans as $post) {
            $class = 'alternate' == $class ? '' : 'alternate';
            $att_title = esc_html(_draft_or_post_title($post->ID));
            ?>
	<tr id='post-<?php 
            echo $post->ID;
            ?>
' class='<?php 
            echo $class;
            ?>
' valign="top">
		<th scope="row" class="check-column"><input type="checkbox" name="media[]" value="<?php 
            echo esc_attr($post->ID);
            ?>
" /></th>

		<td class="media-icon"><?php 
            if ($thumb = wp_get_attachment_image($post->ID, array(80, 60), true)) {
 /**
  * Output custom columns for icons.
  * @param string $column
  */
 public function render_social_icon_columns($column)
 {
     global $post;
     switch ($column) {
         case 'name':
             $edit_link = get_edit_post_link($post->ID);
             $title = _draft_or_post_title();
             echo '<strong><a class="row-title" href="' . esc_url($edit_link) . '">' . esc_html($title) . '</a>';
             _post_states($post);
             echo '</strong>';
             $this->_render_social_icon_row_actions($post, $title);
             break;
         case 'shortcode':
             $shortcode = '[social_icons_group id="' . $post->ID . '"]';
             echo '<span class="shortcode"><input type="text" class="regular-text code" onfocus="this.select();" readonly="readonly" value="' . esc_attr($shortcode) . '" /></span>';
             break;
         default:
             break;
     }
 }
 /**
  * Generates and displays row action links.
  *
  * @since 4.3.0
  * @access protected
  *
  * @param object $post        Attachment being acted upon.
  * @param string $column_name Current column name.
  * @param string $primary     Primary column name.
  * @return string Row actions output for media attachments.
  */
 protected function handle_row_actions($post, $column_name, $primary)
 {
     if ($primary !== $column_name) {
         return '';
     }
     $att_title = _draft_or_post_title();
     return $this->row_actions($this->_get_row_actions($post, $att_title));
 }
Example #17
0
/**
 * Custom Columns for Products page
 *
 * @access public
 * @param mixed $column
 * @return void
 */
function woocommerce_custom_product_columns($column)
{
    global $post, $woocommerce, $the_product;
    if (empty($the_product) || $the_product->id != $post->ID) {
        $the_product = get_product($post);
    }
    switch ($column) {
        case "thumb":
            echo '<a href="' . get_edit_post_link($post->ID) . '">' . $the_product->get_image() . '</a>';
            break;
        case "name":
            $edit_link = get_edit_post_link($post->ID);
            $title = _draft_or_post_title();
            $post_type_object = get_post_type_object($post->post_type);
            $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
            echo '<strong><a class="row-title" href="' . $edit_link . '">' . $title . '</a>';
            _post_states($post);
            echo '</strong>';
            if ($post->post_parent > 0) {
                echo '&nbsp;&nbsp;&larr; <a href="' . get_edit_post_link($post->post_parent) . '">' . get_the_title($post->post_parent) . '</a>';
            }
            // Excerpt view
            if (isset($_GET['mode']) && $_GET['mode'] == 'excerpt') {
                echo apply_filters('the_excerpt', $post->post_excerpt);
            }
            // Get actions
            $actions = array();
            $actions['id'] = 'ID: ' . $post->ID;
            if ($can_edit_post && 'trash' != $post->post_status) {
                $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
            }
            if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                if ('trash' == $post->post_status) {
                    $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
                } elseif (EMPTY_TRASH_DAYS) {
                    $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
                }
                if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
                }
            }
            if ($post_type_object->public) {
                if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
                    if ($can_edit_post) {
                        $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
                    }
                } elseif ('trash' != $post->post_status) {
                    $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
                }
            }
            $actions = apply_filters('post_row_actions', $actions, $post);
            echo '<div class="row-actions">';
            $i = 0;
            $action_count = sizeof($actions);
            foreach ($actions as $action => $link) {
                ++$i;
                $i == $action_count ? $sep = '' : ($sep = ' | ');
                echo "<span class='{$action}'>{$link}{$sep}</span>";
            }
            echo '</div>';
            get_inline_data($post);
            /* Custom inline data for woocommerce */
            echo '
				<div class="hidden" id="woocommerce_inline_' . $post->ID . '">
					<div class="menu_order">' . $post->menu_order . '</div>
					<div class="sku">' . $the_product->sku . '</div>
					<div class="regular_price">' . $the_product->regular_price . '</div>
					<div class="sale_price">' . $the_product->sale_price . '</div>
					<div class="weight">' . $the_product->weight . '</div>
					<div class="length">' . $the_product->length . '</div>
					<div class="width">' . $the_product->width . '</div>
					<div class="height">' . $the_product->height . '</div>
					<div class="visibility">' . $the_product->visibility . '</div>
					<div class="stock_status">' . $the_product->stock_status . '</div>
					<div class="stock">' . $the_product->stock . '</div>
					<div class="manage_stock">' . $the_product->manage_stock . '</div>
					<div class="featured">' . $the_product->featured . '</div>
					<div class="product_type">' . $the_product->product_type . '</div>
					<div class="product_is_virtual">' . $the_product->virtual . '</div>
				</div>
			';
            break;
        case "sku":
            if ($the_product->get_sku()) {
                echo $the_product->get_sku();
            } else {
                echo '<span class="na">&ndash;</span>';
            }
            break;
        case "product_type":
            if ($the_product->product_type == 'grouped') {
                echo '<span class="product-type tips ' . $the_product->product_type . '" data-tip="' . __('Grouped', 'woocommerce') . '"></span>';
            } elseif ($the_product->product_type == 'external') {
                echo '<span class="product-type tips ' . $the_product->product_type . '" data-tip="' . __('External/Affiliate', 'woocommerce') . '"></span>';
            } elseif ($the_product->product_type == 'simple') {
                if ($the_product->is_virtual()) {
                    echo '<span class="product-type tips virtual" data-tip="' . __('Virtual', 'woocommerce') . '"></span>';
                } elseif ($the_product->is_downloadable()) {
                    echo '<span class="product-type tips downloadable" data-tip="' . __('Downloadable', 'woocommerce') . '"></span>';
                } else {
                    echo '<span class="product-type tips ' . $the_product->product_type . '" data-tip="' . __('Simple', 'woocommerce') . '"></span>';
                }
            } elseif ($the_product->product_type == 'variable') {
                echo '<span class="product-type tips ' . $the_product->product_type . '" data-tip="' . __('Variable', 'woocommerce') . '"></span>';
            } else {
                // Assuming that we have other types in future
                echo '<span class="product-type tips ' . $the_product->product_type . '" data-tip="' . ucwords($the_product->product_type) . '"></span>';
            }
            break;
        case "price":
            if ($the_product->get_price_html()) {
                echo $the_product->get_price_html();
            } else {
                echo '<span class="na">&ndash;</span>';
            }
            break;
        case "product_cat":
        case "product_tag":
            if (!($terms = get_the_terms($post->ID, $column))) {
                echo '<span class="na">&ndash;</span>';
            } else {
                foreach ($terms as $term) {
                    $termlist[] = '<a href="' . admin_url('edit.php?' . $column . '=' . $term->slug . '&post_type=product') . ' ">' . $term->name . '</a>';
                }
                echo implode(', ', $termlist);
            }
            break;
        case 'featured':
            $url = wp_nonce_url(admin_url('admin-ajax.php?action=woocommerce-feature-product&product_id=' . $post->ID), 'woocommerce-feature-product');
            echo '<a href="' . $url . '" title="' . __('Toggle featured', 'woocommerce') . '">';
            if ($the_product->is_featured()) {
                echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/featured.png" alt="' . __('yes', 'woocommerce') . '" height="14" width="14" />';
            } else {
                echo '<img src="' . $woocommerce->plugin_url() . '/assets/images/featured-off.png" alt="' . __('no', 'woocommerce') . '" height="14" width="14" />';
            }
            echo '</a>';
            break;
        case "is_in_stock":
            if ($the_product->is_in_stock()) {
                echo '<mark class="instock">' . __('In stock', 'woocommerce') . '</mark>';
            } else {
                echo '<mark class="outofstock">' . __('Out of stock', 'woocommerce') . '</mark>';
            }
            if ($the_product->managing_stock()) {
                echo ' &times; ' . $the_product->get_total_stock();
            }
            break;
    }
}
Example #18
0
/**
 * Values for Columns on the Coupons admin page.
 *
 * @access public
 * @param mixed $column
 * @return void
 */
function woocommerce_custom_coupon_columns($column)
{
    global $post, $woocommerce;
    switch ($column) {
        case "coupon_code":
            $edit_link = get_edit_post_link($post->ID);
            $title = _draft_or_post_title();
            $post_type_object = get_post_type_object($post->post_type);
            $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
            echo '<div class="code tips" data-tip="' . __('Edit coupon', 'woocommerce') . '"><a href="' . esc_attr($edit_link) . '"><span>' . esc_html($title) . '</span></a></div>';
            _post_states($post);
            // Get actions
            $actions = array();
            if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                if ('trash' == $post->post_status) {
                    $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
                } elseif (EMPTY_TRASH_DAYS) {
                    $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
                }
                if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                    $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
                }
            }
            $actions = apply_filters('post_row_actions', $actions, $post);
            echo '<div class="row-actions">';
            $i = 0;
            $action_count = sizeof($actions);
            foreach ($actions as $action => $link) {
                ++$i;
                $i == $action_count ? $sep = '' : ($sep = ' | ');
                echo "<span class='{$action}'>{$link}{$sep}</span>";
            }
            echo '</div>';
            break;
        case "type":
            echo esc_html($woocommerce->get_coupon_discount_type(get_post_meta($post->ID, 'discount_type', true)));
            break;
        case "amount":
            echo esc_html(get_post_meta($post->ID, 'coupon_amount', true));
            break;
        case "products":
            $product_ids = get_post_meta($post->ID, 'product_ids', true);
            $product_ids = $product_ids ? array_map('absint', explode(',', $product_ids)) : array();
            if (sizeof($product_ids) > 0) {
                echo esc_html(implode(', ', $product_ids));
            } else {
                echo '&ndash;';
            }
            break;
        case "usage_limit":
            $usage_limit = get_post_meta($post->ID, 'usage_limit', true);
            if ($usage_limit) {
                echo esc_html($usage_limit);
            } else {
                echo '&ndash;';
            }
            break;
        case "usage":
            $usage_count = absint(get_post_meta($post->ID, 'usage_count', true));
            $usage_limit = esc_html(get_post_meta($post->ID, 'usage_limit', true));
            if ($usage_limit) {
                printf(__('%s / %s', 'woocommerce'), $usage_count, $usage_limit);
            } else {
                printf(__('%s / &infin;', 'woocommerce'), $usage_count);
            }
            break;
        case "expiry_date":
            $expiry_date = get_post_meta($post->ID, 'expiry_date', true);
            if ($expiry_date) {
                echo esc_html(date_i18n('F j, Y', strtotime($expiry_date)));
            } else {
                echo '&ndash;';
            }
            break;
        case "description":
            echo wp_kses_post($post->post_excerpt);
            break;
    }
}
 /**
  * Generates and displays row action links.
  *
  * @since 4.3.0
  * @access protected
  *
  * @param object $post        Post being acted upon.
  * @param string $column_name Current column name.
  * @param string $primary     Primary column name.
  * @return string Row actions output for posts.
  */
 protected function handle_row_actions($post, $column_name, $primary)
 {
     if ($primary !== $column_name) {
         return '';
     }
     $post_type_object = get_post_type_object($post->post_type);
     $can_edit_post = current_user_can('edit_post', $post->ID);
     $actions = array();
     $title = _draft_or_post_title();
     if ($can_edit_post && 'trash' != $post->post_status) {
         $actions['edit'] = sprintf('<a href="%s" aria-label="%s">%s</a>', get_edit_post_link($post->ID), esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)), __('Edit'));
         $actions['inline hide-if-no-js'] = sprintf('<a href="#" class="editinline" aria-label="%s">%s</a>', esc_attr(sprintf(__('Quick edit &#8220;%s&#8221; inline'), $title)), __('Quick&nbsp;Edit'));
     }
     if (current_user_can('delete_post', $post->ID)) {
         if ('trash' === $post->post_status) {
             $actions['untrash'] = sprintf('<a href="%s" aria-label="%s">%s</a>', wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID), esc_attr(sprintf(__('Restore &#8220;%s&#8221; from the Trash'), $title)), __('Restore'));
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = sprintf('<a href="%s" class="submitdelete" aria-label="%s">%s</a>', get_delete_post_link($post->ID), esc_attr(sprintf(__('Move &#8220;%s&#8221; to the Trash'), $title)), _x('Trash', 'verb'));
         }
         if ('trash' === $post->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = sprintf('<a href="%s" class="submitdelete" aria-label="%s">%s</a>', get_delete_post_link($post->ID, '', true), esc_attr(sprintf(__('Delete &#8220;%s&#8221; permanently'), $title)), __('Delete Permanently'));
         }
     }
     if (is_post_type_viewable($post_type_object)) {
         if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
             if ($can_edit_post) {
                 $unpublished_link = set_url_scheme(get_permalink($post));
                 $preview_link = get_preview_post_link($post, array(), $unpublished_link);
                 $actions['view'] = sprintf('<a href="%s" rel="permalink" aria-label="%s">%s</a>', esc_url($preview_link), esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)), __('Preview'));
             }
         } elseif ('trash' != $post->post_status) {
             $actions['view'] = sprintf('<a href="%s" rel="permalink" aria-label="%s">%s</a>', get_permalink($post->ID), esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)), __('View'));
         }
     }
     if (is_post_type_hierarchical($post->post_type)) {
         /**
          * Filter the array of row action links on the Pages list table.
          *
          * The filter is evaluated only for hierarchical post types.
          *
          * @since 2.8.0
          *
          * @param array $actions An array of row action links. Defaults are
          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
          *                         'Delete Permanently', 'Preview', and 'View'.
          * @param WP_Post $post The post object.
          */
         $actions = apply_filters('page_row_actions', $actions, $post);
     } else {
         /**
          * Filter the array of row action links on the Posts list table.
          *
          * The filter is evaluated only for non-hierarchical post types.
          *
          * @since 2.8.0
          *
          * @param array $actions An array of row action links. Defaults are
          *                         'Edit', 'Quick Edit', 'Restore, 'Trash',
          *                         'Delete Permanently', 'Preview', and 'View'.
          * @param WP_Post $post The post object.
          */
         $actions = apply_filters('post_row_actions', $actions, $post);
     }
     return $this->row_actions($actions);
 }
Example #20
0
        $title = __('Comments');
    }
}
add_screen_option('per_page');
get_current_screen()->add_help_tab(array('id' => 'overview', 'title' => __('Overview'), 'content' => '<p>' . __('You can manage comments made on your site similar to the way you manage posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.') . '</p>'));
get_current_screen()->add_help_tab(array('id' => 'moderating-comments', 'title' => __('Moderating Comments'), 'content' => '<p>' . __('A red bar on the left means the comment is waiting for you to moderate it.') . '</p>' . '<p>' . __('In the <strong>Author</strong> column, in addition to the author&#8217;s name, email address, and blog URL, the commenter&#8217;s IP address is shown. Clicking on this link will show you all the comments made from this IP address.') . '</p>' . '<p>' . __('In the <strong>Comment</strong> column, hovering over any comment gives you options to approve, reply (and approve), quick edit, edit, spam mark, or trash that comment.') . '</p>' . '<p>' . __('In the <strong>In Response To</strong> column, there are three elements. The text is the name of the post that inspired the comment, and links to the post editor for that entry. The View Post link leads to that post on your live site. The small bubble with the number in it shows the number of approved comments that post has received. If there are pending comments, a red notification circle with the number of pending comments is displayed. Clicking the notification circle will filter the comments screen to show only pending comments on that post.') . '</p>' . '<p>' . __('In the <strong>Submitted On</strong> column, the date and time the comment was left on your site appears. Clicking on the date/time link will take you to that comment on your live site.') . '</p>' . '<p>' . __('Many people take advantage of keyboard shortcuts to moderate their comments more quickly. Use the link to the side to learn more.') . '</p>'));
get_current_screen()->set_help_sidebar('<p><strong>' . __('For more information:') . '</strong></p>' . '<p>' . __('<a href="https://codex.wordpress.org/Administration_Screens#Comments" target="_blank">Documentation on Comments</a>') . '</p>' . '<p>' . __('<a href="https://codex.wordpress.org/Comment_Spam" target="_blank">Documentation on Comment Spam</a>') . '</p>' . '<p>' . __('<a href="https://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">Documentation on Keyboard Shortcuts</a>') . '</p>' . '<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>');
get_current_screen()->set_screen_reader_content(array('heading_views' => __('Filter comments list'), 'heading_pagination' => __('Comments list navigation'), 'heading_list' => __('Comments list')));
require_once ABSPATH . 'wp-admin/admin-header.php';
?>

<div class="wrap">
<h1><?php 
if ($post_id) {
    /* translators: %s: link to post */
    printf(__('Comments on &#8220;%s&#8221;'), sprintf('<a href="%1$s">%2$s</a>', get_edit_post_link($post_id), wp_html_excerpt(_draft_or_post_title($post_id), 50, '&hellip;')));
} else {
    _e('Comments');
}
if (isset($_REQUEST['s']) && $_REQUEST['s']) {
    echo '<span class="subtitle">';
    /* translators: %s: search keywords */
    printf(__('Search results for &#8220;%s&#8221;'), wp_html_excerpt(esc_html(wp_unslash($_REQUEST['s'])), 50, '&hellip;'));
    echo '</span>';
}
?>
</h1>

<?php 
if (isset($_REQUEST['error'])) {
    $error = (int) $_REQUEST['error'];
    /**
     * prints the individual row
     *
     * @param object $post
     * @param int $comment_pending_count
     * @param string $mode
     */
    protected function _manage_row($post, $comment_pending_count, $mode)
    {
        static $rowclass;
        $global_post = $post;
        setup_postdata($post);
        $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
        $current_user = wp_get_current_user();
        $post_owner = $current_user->ID == $post->post_author ? 'self' : 'other';
        $edit_link = get_edit_post_link($post->ID);
        $title = _draft_or_post_title($post->ID);
        ?>
		<tr id='post-<?php 
        echo $post->ID;
        ?>
'	class='<?php 
        echo trim($rowclass . ' author-' . $post_owner . ' status-' . $post->post_status);
        ?>
 iedit'	valign="top">
			<?php 
        $posts_columns = get_column_headers($this->get_content_type());
        $hidden = get_hidden_columns($this->get_content_type());
        foreach ($posts_columns as $column_name => $column_display_name) {
            $class = "class=\"{$column_name} column-{$column_name}\"";
            $style = '';
            if (in_array($column_name, $hidden)) {
                $style = ' style="display:none;"';
            }
            $attributes = "{$class}{$style}";
            switch ($column_name) {
                case 'cb':
                    ?>
						<th scope="row" class="check-column"><?php 
                    if (current_user_can('edit_post', $post->ID)) {
                        ?>
<input	type="checkbox" name="post[]" value="<?php 
                        the_ID();
                        ?>
" /><?php 
                    }
                    ?>
</th>
						<?php 
                    break;
                    //end case 'cb'
                //end case 'cb'
                case 'date':
                    if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) {
                        $t_time = $h_time = __('Unpublished');
                        $time_diff = 0;
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $post->post_date;
                        $time = get_post_time('G', true, $post);
                        $time_diff = time() - $time;
                        if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                    }
                    echo '<td ' . $attributes . '>';
                    if ('excerpt' == $mode) {
                        echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
                    } else {
                        echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                    }
                    echo '<br />';
                    if ('publish' == $post->post_status) {
                        _e('Published');
                    } elseif ('future' == $post->post_status) {
                        if ($time_diff > 0) {
                            echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
                        } else {
                            _e('Scheduled');
                        }
                    } else {
                        _e('Last Modified');
                    }
                    echo '</td>';
                    break;
                    //end case 'date'
                //end case 'date'
                case 'title':
                    $attributes = 'class="post-title column-title"' . $style;
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
><strong><?php 
                    if (current_user_can('edit_post', $post->ID) && $post->post_status != 'trash') {
                        ?>
<a	class="row-title" href="<?php 
                        echo $edit_link;
                        ?>
" title="<?php 
                        echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title));
                        ?>
"><?php 
                        echo $title;
                        ?>
</a><?php 
                    } else {
                        echo $title;
                    }
                    _post_states($post);
                    ?>
</strong>
						<?php 
                    if ('excerpt' == $mode) {
                        the_excerpt();
                    }
                    $actions = array();
                    if ('trash' == $post->post_status && current_user_can('delete_post', $post->ID)) {
                        $actions['untrash'] = "<a title='" . esc_attr(__('Remove this post from the Trash')) . "' href='" . wp_nonce_url("post.php?action=untrash&amp;post={$post->ID}", 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
                        $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
                    } else {
                        if (current_user_can('edit_post', $post->ID)) {
                            $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this post')) . '">' . __('Edit') . '</a>';
                            //removing quickedit for now
                            //$actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this post inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
                        }
                        if (current_user_can('delete_post', $post->ID) && function_exists('wp_trash_post')) {
                            $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this post to the Trash')) . "' href='" . wp_nonce_url("post.php?action=trash&amp;post={$post->ID}", 'trash-post_' . $post->ID) . "'>" . __('Trash') . "</a>";
                        } else {
                            $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this post permanently')) . "' href='" . wp_nonce_url("post.php?action=delete&amp;post={$post->ID}", 'delete-post_' . $post->ID) . "'>" . __('Delete Permanently') . "</a>";
                        }
                        if (in_array($post->post_status, array('pending', 'draft'))) {
                            if (current_user_can('edit_post', $post->ID)) {
                                $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
                            }
                        } else {
                            $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
                        }
                    }
                    $actions = apply_filters('post_row_actions', $actions, $post);
                    $action_count = count($actions);
                    $i = 0;
                    echo '<div class="row-actions">';
                    foreach ($actions as $action => $link) {
                        ++$i;
                        $i == $action_count ? $sep = '' : ($sep = ' | ');
                        echo "<span class='{$action}'>{$link}{$sep}</span>";
                    }
                    echo '</div>';
                    get_inline_data($post);
                    ?>
						</td>
						<?php 
                    break;
                    //end case 'title'
                //end case 'title'
                case 'categories':
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    $categories = get_the_category();
                    if (!empty($categories)) {
                        $out = array();
                        foreach ($categories as $c) {
                            $out[] = "<a href='edit.php?category_name={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
                        }
                        echo join(', ', $out);
                    } else {
                        _e('Uncategorized');
                    }
                    ?>
</td>
						<?php 
                    break;
                    //end case 'categories'
                //end case 'categories'
                case 'tags':
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    $tags = get_the_tags($post->ID);
                    if (!empty($tags)) {
                        $out = array();
                        foreach ($tags as $c) {
                            $out[] = "<a href='edit.php?tag={$c->slug}'> " . esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
                        }
                        echo join(', ', $out);
                    } else {
                        _e('No Tags');
                    }
                    ?>
						</td>
						<?php 
                    break;
                    //end case 'tags'
                //end case 'tags'
                case 'comments':
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
>
						<div class="post-com-count-wrapper">
						<?php 
                    if (!isset($pending_comments)) {
                        $pending_comments = 0;
                    }
                    $pending_phrase = sprintf(__('%s pending'), number_format($pending_comments));
                    if ($pending_comments) {
                        echo '<strong>';
                    }
                    comments_number("<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('0', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('1', 'comment count') . '</span></a>', "<a href='edit-comments.php?p={$post->ID}' title='{$pending_phrase}' class='post-com-count'><span class='comment-count'>" . _x('%', 'comment count') . '</span></a>');
                    if ($pending_comments) {
                        echo '</strong>';
                    }
                    ?>
						</div>
						</td>
						<?php 
                    break;
                    //end case 'comments'
                //end case 'comments'
                case 'author':
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
><a href="edit.php?author=<?php 
                    the_author_meta('ID');
                    ?>
"><?php 
                    the_author();
                    ?>
</a></td>
						<?php 
                    break;
                    //end case 'author'
                //end case 'author'
                case 'control_view':
                    ?>
						<td><a href="<?php 
                    the_permalink();
                    ?>
" rel="permalink"	class="view"><?php 
                    _e('View');
                    ?>
</a></td>
						<?php 
                    break;
                    //end case 'control_view'
                //end case 'control_view'
                case 'control_edit':
                    ?>
						<td><?php 
                    if (current_user_can('edit_post', $post->ID)) {
                        echo "<a href='{$edit_link}' class='edit'>" . __('Edit') . "</a>";
                    }
                    ?>
</td>
						<?php 
                    break;
                    //end case 'control_edit'
                //end case 'control_edit'
                case 'control_delete':
                    ?>
						<td><?php 
                    if (current_user_can('delete_post', $post->ID)) {
                        echo "<a href='" . wp_nonce_url("post.php?action=delete&amp;post={$post->ID}", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>";
                    }
                    ?>
</td>
						<?php 
                    break;
                    //end case 'control_delete
                //end case 'control_delete
                default:
                    ?>
						<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    do_action('manage_posts_custom_column', $column_name, $post->ID);
                    ?>
</td>
						<?php 
                    break;
            }
        }
        ?>
		</tr>
		<?php 
        $post = $global_post;
    }
						<td class='sort'>
							<input type='hidden' name='sort[]' value='<?php 
    echo absint($rule->ID);
    ?>
' />
						</td>
						<td>
							<strong>
								<a href='<?php 
    echo get_edit_post_link($rule->ID);
    ?>
' class='row-title' title='<?php 
    _e('Edit Method', 'woocommerce-advanced-shipping-validation');
    ?>
'><?php 
    echo _draft_or_post_title($rule->ID);
    ?>
</a><?php 
    _post_states($rule);
    ?>
</strong>
							<div class='row-actions'>
								<span class='edit'>
									<a href='<?php 
    echo get_edit_post_link($rule->ID);
    ?>
' title='<?php 
    _e('Edit Method', 'woocommerce-advanced-shipping-validation');
    ?>
'>
										<?php 
        /**
         * Find out if a shortcode is used anywhere
         *
         * Liberally nicked from TR All Shortcodes plugin & adjusted based on WP posts-list-table code
         * Source: http://wordpress.org/plugins/tr-all-shortcodes/
         * Source: http://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-wp-posts-list-table.php#L473
         *
         * @param   string  $shortcode  Validated shortcode
         * @return  void
         */
        function ajax_find_shortcode_uses($shortcode)
        {
            // '_' is a wildcard in mysql, so escape it
            $query = $GLOBALS['wpdb']->prepare('select * from `' . $GLOBALS['wpdb']->posts . '`
					where `post_status` <> "inherit"
						and `post_type` <> "attachment"
						and `post_content` like %s
					order by `post_type` ASC, `post_date` DESC;', '%[' . str_replace('_', '\\_', $shortcode) . '%');
            $posts = $GLOBALS['wpdb']->get_results($query);
            /* Do we have posts ? */
            if ($GLOBALS['wpdb']->num_rows === 0) {
                $response = array('id' => 0, 'data' => '');
                $this->send_ajax_response($response);
                exit;
            }
            /* Ok, we've found some posts using the shortcode */
            $output = '
						<h4>' . __('Shortcode found in the following posts/pages/etc:', self::$name) . '</h4>
						<table>
							<thead>
								<tr>
									<th>#</th>' . '
									<th>' . esc_html__('Title') . '</th>
									<th>' . esc_html__('Post Type', self::$name) . '</th>
									<th>' . esc_html__('Status') . '</th>' . '
									<th>' . esc_html__('Author') . '</th>
									<th>' . esc_html__('Shortcode usage(s)', self::$name) . '</th>
								</tr>
							</thead>
							<tbody>';
            foreach ($posts as $i => $post) {
                $edit_link = get_edit_post_link($post->ID);
                $title = _draft_or_post_title($post->ID);
                $post_type_object = get_post_type_object($post->post_type);
                $can_edit_post = current_user_can('edit_post', $post->ID);
                switch ($post->post_status) {
                    case 'publish':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Published');
                        break;
                    case 'future':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Scheduled');
                        break;
                    case 'private':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Private');
                        break;
                    case 'pending':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Pending Review');
                        break;
                    case 'draft':
                    case 'auto-draft':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Draft');
                        break;
                    case 'trash':
                        /* TRANSLATORS: no need to translate, WP standard translation will be used */
                        $post_status = __('Trash');
                        break;
                    default:
                        $post_status = __('Unknown', self::$name);
                        break;
                }
                $actions = array();
                if ($can_edit_post && 'trash' != $post->post_status) {
                    /* TRANSLATORS: no need to translate, WP standard translation will be used */
                    $actions['edit'] = '<a href="' . $edit_link . '" title="' . esc_attr(__('Edit this item')) . '">';
                    /* TRANSLATORS: no need to translate, WP standard translation will be used */
                    $actions['edit'] .= __('Edit') . '</a>';
                }
                if ($post_type_object->public) {
                    if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
                        if ($can_edit_post) {
                            /* TRANSLATORS: no need to translate, WP standard translation will be used */
                            $actions['view'] = '<a href="' . esc_url(apply_filters('preview_post_link', set_url_scheme(add_query_arg('preview', 'true', get_permalink($post->ID))))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">';
                            /* TRANSLATORS: no need to translate, WP standard translation will be used */
                            $actions['view'] .= __('Preview') . '</a>';
                        }
                    } else {
                        if ('trash' != $post->post_status) {
                            /* TRANSLATORS: no need to translate, WP standard translation will be used */
                            $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">';
                            /* TRANSLATORS: no need to translate, WP standard translation will be used */
                            $actions['view'] .= __('View') . '</a>';
                        }
                    }
                }
                $output .= '
								<tr>
									<td>' . ($i + 1) . '</td>
									<td class="column-title"><strong>' . $title . '</strong>';
                if ($actions !== array()) {
                    $output .= '<div class="row-actions">' . implode(' | ', $actions) . '</div>';
                }
                $output .= '
									</td>
									<td>' . esc_html($post_type_object->labels->singular_name) . '</td>
									<td>' . esc_html($post_status) . '</td>
									<td>' . esc_html(get_the_author_meta('display_name', $post->post_author)) . '</td>
									<td>' . $this->find_shortcode_usage($shortcode, $post->post_content) . '</td>
								</tr>';
            }
            unset($i, $post);
            $output .= '
							</tbody>
						</table>';
            $response = array('id' => 1, 'data' => $output, 'tr_class' => self::$name . '-uses');
            $this->send_ajax_response($response);
            exit;
        }
Example #24
0
/**
 * Generates Publishing Soon and Recently Published sections.
 *
 * @since 3.8.0
 *
 * @param array $args {
 *     An array of query and display arguments.
 *
 *     @type int    $max     Number of posts to display.
 *     @type string $status  Post status.
 *     @type string $order   Designates ascending ('ASC') or descending ('DESC') order.
 *     @type string $title   Section title.
 *     @type string $id      The container id.
 * }
 * @return bool False if no posts were found. True otherwise.
 */
function wp_dashboard_recent_posts($args)
{
    $query_args = array('post_type' => 'post', 'post_status' => $args['status'], 'orderby' => 'date', 'order' => $args['order'], 'posts_per_page' => intval($args['max']), 'no_found_rows' => true, 'cache_results' => false, 'perm' => 'future' === $args['status'] ? 'editable' : 'readable');
    $posts = new WP_Query($query_args);
    if ($posts->have_posts()) {
        echo '<div id="' . $args['id'] . '" class="activity-block">';
        echo '<h4>' . $args['title'] . '</h4>';
        echo '<ul>';
        $today = date('Y-m-d', current_time('timestamp'));
        $tomorrow = date('Y-m-d', strtotime('+1 day', current_time('timestamp')));
        while ($posts->have_posts()) {
            $posts->the_post();
            $time = get_the_time('U');
            if (date('Y-m-d', $time) == $today) {
                $relative = __('Today');
            } elseif (date('Y-m-d', $time) == $tomorrow) {
                $relative = __('Tomorrow');
            } else {
                /* translators: date and time format for recent posts on the dashboard, see http://php.net/date */
                $relative = date_i18n(__('M jS'), $time);
            }
            if (current_user_can('edit_post', get_the_ID())) {
                /* translators: 1: relative date, 2: time, 3: post edit link, 4: post title */
                $format = __('<span>%1$s, %2$s</span> <a href="%3$s">%4$s</a>');
                printf("<li>{$format}</li>", $relative, get_the_time(), get_edit_post_link(), _draft_or_post_title());
            } else {
                /* translators: 1: relative date, 2: time, 3: post title */
                $format = __('<span>%1$s, %2$s</span> %3$s');
                printf("<li>{$format}</li>", $relative, get_the_time(), _draft_or_post_title());
            }
        }
        echo '</ul>';
        echo '</div>';
    } else {
        return false;
    }
    wp_reset_postdata();
    return true;
}
    function single_row($a_post, $level = 0)
    {
        global $post, $mode;
        static $alternate;
        $global_post = $post;
        $post = $a_post;
        setup_postdata($post);
        $edit_link = get_edit_post_link($post->ID);
        $title = _draft_or_post_title();
        $post_type_object = get_post_type_object($post->post_type);
        $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
        $alternate = 'alternate' == $alternate ? '' : 'alternate';
        $classes = $alternate . ' iedit author-' . (get_current_user_id() == $post->post_author ? 'self' : 'other');
        ?>
		<tr id="post-<?php 
        echo $post->ID;
        ?>
" class="<?php 
        echo implode(' ', get_post_class($classes, $post->ID));
        ?>
" valign="top">
	<?php 
        list($columns, $hidden) = $this->get_column_info();
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"{$column_name} column-{$column_name}\"";
            $style = '';
            if (in_array($column_name, $hidden)) {
                $style = ' style="display:none;"';
            }
            $attributes = "{$class}{$style}";
            switch ($column_name) {
                case 'cb':
                    ?>
			<th scope="row" class="check-column"><?php 
                    if ($can_edit_post) {
                        ?>
<input type="checkbox" name="post[]" value="<?php 
                        the_ID();
                        ?>
" /><?php 
                    }
                    ?>
</th>
			<?php 
                    break;
                case 'title':
                    if ($this->hierarchical_display) {
                        $attributes = 'class="post-title page-title column-title"' . $style;
                        if (0 == $level && (int) $post->post_parent > 0) {
                            //sent level 0 by accident, by default, or because we don't know the actual level
                            $find_main_page = (int) $post->post_parent;
                            while ($find_main_page > 0) {
                                $parent = get_page($find_main_page);
                                if (is_null($parent)) {
                                    break;
                                }
                                $level++;
                                $find_main_page = (int) $parent->post_parent;
                                if (!isset($parent_name)) {
                                    $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
                                }
                            }
                        }
                        $pad = str_repeat('&#8212; ', $level);
                        ?>
			<td <?php 
                        echo $attributes;
                        ?>
><strong><?php 
                        if ($can_edit_post && $post->post_status != 'trash') {
                            ?>
<a class="row-title" href="<?php 
                            echo $edit_link;
                            ?>
" title="<?php 
                            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title));
                            ?>
"><?php 
                            echo $pad;
                            echo $title;
                            ?>
</a><?php 
                        } else {
                            echo $pad;
                            echo $title;
                        }
                        _post_states($post);
                        echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name) : '';
                        ?>
</strong>
<?php 
                    } else {
                        $attributes = 'class="post-title page-title column-title"' . $style;
                        ?>
			<td <?php 
                        echo $attributes;
                        ?>
><strong><?php 
                        if ($can_edit_post && $post->post_status != 'trash') {
                            ?>
<a class="row-title" href="<?php 
                            echo $edit_link;
                            ?>
" title="<?php 
                            echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title));
                            ?>
"><?php 
                            echo $title;
                            ?>
</a><?php 
                        } else {
                            echo $title;
                        }
                        _post_states($post);
                        ?>
</strong>
<?php 
                        if ('excerpt' == $mode) {
                            the_excerpt();
                        }
                    }
                    $actions = array();
                    if ($can_edit_post && 'trash' != $post->post_status) {
                        $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
                    }
                    if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
                        if ('trash' == $post->post_status) {
                            $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore') . "</a>";
                        } elseif (EMPTY_TRASH_DAYS) {
                            $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
                        }
                        if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                            $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
                        }
                    }
                    if ($post_type_object->public) {
                        if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
                            if ($can_edit_post) {
                                $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
                            }
                        } elseif ('trash' != $post->post_status) {
                            $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
                        }
                    }
                    $actions = apply_filters(is_post_type_hierarchical($post->post_type) ? 'page_row_actions' : 'post_row_actions', $actions, $post);
                    echo $this->row_actions($actions);
                    get_inline_data($post);
                    echo '</td>';
                    break;
                case 'date':
                    if ('0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name) {
                        $t_time = $h_time = __('Unpublished');
                        $time_diff = 0;
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $post->post_date;
                        $time = get_post_time('G', true, $post);
                        $time_diff = time() - $time;
                        if ($time_diff > 0 && $time_diff < 24 * 60 * 60) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                    }
                    echo '<td ' . $attributes . '>';
                    if ('excerpt' == $mode) {
                        echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
                    } else {
                        echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                    }
                    echo '<br />';
                    if ('publish' == $post->post_status) {
                        _e('Published');
                    } elseif ('future' == $post->post_status) {
                        if ($time_diff > 0) {
                            echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
                        } else {
                            _e('Scheduled');
                        }
                    } else {
                        _e('Last Modified');
                    }
                    echo '</td>';
                    break;
                case 'categories':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    $categories = get_the_category();
                    if (!empty($categories)) {
                        $out = array();
                        foreach ($categories as $c) {
                            $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'category_name' => $c->slug), 'edit.php')), esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')));
                        }
                        echo join(', ', $out);
                    } else {
                        _e('Uncategorized');
                    }
                    ?>
</td>
			<?php 
                    break;
                case 'tags':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    $tags = get_the_tags($post->ID);
                    if (!empty($tags)) {
                        $out = array();
                        foreach ($tags as $c) {
                            $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'tag' => $c->slug), 'edit.php')), esc_html(sanitize_term_field('name', $c->name, $c->term_id, 'tag', 'display')));
                        }
                        echo join(', ', $out);
                    } else {
                        _e('No Tags');
                    }
                    ?>
</td>
			<?php 
                    break;
                case 'comments':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><div class="post-com-count-wrapper">
			<?php 
                    $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0;
                    $this->comments_bubble($post->ID, $pending_comments);
                    ?>
			</div></td>
			<?php 
                    break;
                case 'author':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'author' => get_the_author_meta('ID')), 'edit.php')), get_the_author());
                    ?>
</td>
			<?php 
                    break;
                default:
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    if (is_post_type_hierarchical($post->post_type)) {
                        do_action('manage_pages_custom_column', $column_name, $post->ID);
                    } else {
                        do_action('manage_posts_custom_column', $column_name, $post->ID);
                    }
                    do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID);
                    ?>
</td>
			<?php 
                    break;
            }
        }
        ?>
		</tr>
	<?php 
        $post = $global_post;
    }
Example #26
0
 function modify_medialibrary_permalink($action, $post, $detached)
 {
     $rtm_id = rtmedia_id($post->ID);
     if ($rtm_id) {
         $link = get_rtmedia_permalink($rtm_id);
         $title = _draft_or_post_title($post->post_parent);
         $action['view'] = '<a href="' . $link . '" title="' . esc_attr(sprintf(esc_html__('View &#8220;%s&#8221;', 'buddypress-media'), $title)) . '" rel="permalink">' . esc_html__('View', 'buddypress-media') . '</a>';
     }
     return $action;
 }
    function single_row($post, $level = 0)
    {
        global $mode;
        static $alternate;
        $global_post = get_post();
        $GLOBALS['post'] = $post;
        setup_postdata($post);
        $edit_link = get_edit_post_link($post->ID);
        $title = _draft_or_post_title();
        $post_type_object = get_post_type_object($post->post_type);
        $can_edit_post = current_user_can('edit_post', $post->ID);
        $alternate = 'alternate' == $alternate ? '' : 'alternate';
        $classes = $alternate . ' iedit author-' . (get_current_user_id() == $post->post_author ? 'self' : 'other');
        $lock_holder = wp_check_post_lock($post->ID);
        if ($lock_holder) {
            $classes .= ' wp-locked';
            $lock_holder = get_userdata($lock_holder);
        }
        ?>
		<tr id="post-<?php 
        echo $post->ID;
        ?>
" class="<?php 
        echo implode(' ', get_post_class($classes, $post->ID));
        ?>
" valign="top">
	<?php 
        list($columns, $hidden) = $this->get_column_info();
        foreach ($columns as $column_name => $column_display_name) {
            $class = "class=\"{$column_name} column-{$column_name}\"";
            $style = '';
            if (in_array($column_name, $hidden)) {
                $style = ' style="display:none;"';
            }
            $attributes = "{$class}{$style}";
            switch ($column_name) {
                case 'cb':
                    ?>
			<th scope="row" class="check-column">
				<?php 
                    if ($can_edit_post) {
                        ?>
				<label class="screen-reader-text" for="cb-select-<?php 
                        the_ID();
                        ?>
"><?php 
                        printf(__('Select %s'), $title);
                        ?>
</label>
				<input id="cb-select-<?php 
                        the_ID();
                        ?>
" type="checkbox" name="post[]" value="<?php 
                        the_ID();
                        ?>
" />
				<div class="locked-indicator"></div>
				<?php 
                    }
                    ?>
			</th>
			<?php 
                    break;
                case 'title':
                    $attributes = 'class="post-title page-title column-title"' . $style;
                    if ($this->hierarchical_display) {
                        if (0 == $level && (int) $post->post_parent > 0) {
                            //sent level 0 by accident, by default, or because we don't know the actual level
                            $find_main_page = (int) $post->post_parent;
                            while ($find_main_page > 0) {
                                $parent = get_post($find_main_page);
                                if (is_null($parent)) {
                                    break;
                                }
                                $level++;
                                $find_main_page = (int) $parent->post_parent;
                                if (!isset($parent_name)) {
                                    /** This filter is documented in wp-includes/post-template.php */
                                    $parent_name = apply_filters('the_title', $parent->post_title, $parent->ID);
                                }
                            }
                        }
                    }
                    $pad = str_repeat('&#8212; ', $level);
                    echo "<td {$attributes}><strong>";
                    if ($format = get_post_format($post->ID)) {
                        $label = get_post_format_string($format);
                        echo '<a href="' . esc_url(add_query_arg(array('post_format' => $format, 'post_type' => $post->post_type), 'edit.php')) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> ";
                    }
                    if ($can_edit_post && $post->post_status != 'trash') {
                        echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)) . '">' . $pad . $title . '</a>';
                    } else {
                        echo $pad . $title;
                    }
                    _post_states($post);
                    if (isset($parent_name)) {
                        echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name);
                    }
                    echo "</strong>\n";
                    if ($can_edit_post && $post->post_status != 'trash') {
                        if ($lock_holder) {
                            $locked_avatar = get_avatar($lock_holder->ID, 18);
                            $locked_text = esc_html(sprintf(__('%s is currently editing'), $lock_holder->display_name));
                        } else {
                            $locked_avatar = $locked_text = '';
                        }
                        echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
                    }
                    if (!$this->hierarchical_display && 'excerpt' == $mode && current_user_can('read_post', $post->ID)) {
                        the_excerpt();
                    }
                    $actions = array();
                    if ($can_edit_post && 'trash' != $post->post_status) {
                        $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
                    }
                    if (current_user_can('delete_post', $post->ID)) {
                        if ('trash' == $post->post_status) {
                            $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-post_' . $post->ID) . "'>" . __('Restore') . "</a>";
                        } elseif (EMPTY_TRASH_DAYS) {
                            $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
                        }
                        if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
                            $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
                        }
                    }
                    if ($post_type_object->public) {
                        if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
                            if ($can_edit_post) {
                                $actions['view'] = '<a href="' . esc_url(apply_filters('preview_post_link', set_url_scheme(add_query_arg('preview', 'true', get_permalink($post->ID))))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
                            }
                        } elseif ('trash' != $post->post_status) {
                            $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
                        }
                    }
                    $actions = apply_filters(is_post_type_hierarchical($post->post_type) ? 'page_row_actions' : 'post_row_actions', $actions, $post);
                    echo $this->row_actions($actions);
                    get_inline_data($post);
                    echo '</td>';
                    break;
                case 'date':
                    if ('0000-00-00 00:00:00' == $post->post_date) {
                        $t_time = $h_time = __('Unpublished');
                        $time_diff = 0;
                    } else {
                        $t_time = get_the_time(__('Y/m/d g:i:s A'));
                        $m_time = $post->post_date;
                        $time = get_post_time('G', true, $post);
                        $time_diff = time() - $time;
                        if ($time_diff > 0 && $time_diff < DAY_IN_SECONDS) {
                            $h_time = sprintf(__('%s ago'), human_time_diff($time));
                        } else {
                            $h_time = mysql2date(__('Y/m/d'), $m_time);
                        }
                    }
                    echo '<td ' . $attributes . '>';
                    if ('excerpt' == $mode) {
                        echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
                    } else {
                        echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
                    }
                    echo '<br />';
                    if ('publish' == $post->post_status) {
                        _e('Published');
                    } elseif ('future' == $post->post_status) {
                        if ($time_diff > 0) {
                            echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
                        } else {
                            _e('Scheduled');
                        }
                    } else {
                        _e('Last Modified');
                    }
                    echo '</td>';
                    break;
                case 'comments':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><div class="post-com-count-wrapper">
			<?php 
                    $pending_comments = isset($this->comment_pending_count[$post->ID]) ? $this->comment_pending_count[$post->ID] : 0;
                    $this->comments_bubble($post->ID, $pending_comments);
                    ?>
			</div></td>
			<?php 
                    break;
                case 'author':
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    printf('<a href="%s">%s</a>', esc_url(add_query_arg(array('post_type' => $post->post_type, 'author' => get_the_author_meta('ID')), 'edit.php')), get_the_author());
                    ?>
</td>
			<?php 
                    break;
                default:
                    if ('categories' == $column_name) {
                        $taxonomy = 'category';
                    } elseif ('tags' == $column_name) {
                        $taxonomy = 'post_tag';
                    } elseif (0 === strpos($column_name, 'taxonomy-')) {
                        $taxonomy = substr($column_name, 9);
                    } else {
                        $taxonomy = false;
                    }
                    if ($taxonomy) {
                        $taxonomy_object = get_taxonomy($taxonomy);
                        echo '<td ' . $attributes . '>';
                        if ($terms = get_the_terms($post->ID, $taxonomy)) {
                            $out = array();
                            foreach ($terms as $t) {
                                $posts_in_term_qv = array();
                                if ('post' != $post->post_type) {
                                    $posts_in_term_qv['post_type'] = $post->post_type;
                                }
                                if ($taxonomy_object->query_var) {
                                    $posts_in_term_qv[$taxonomy_object->query_var] = $t->slug;
                                } else {
                                    $posts_in_term_qv['taxonomy'] = $taxonomy;
                                    $posts_in_term_qv['term'] = $t->slug;
                                }
                                $out[] = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg($posts_in_term_qv, 'edit.php')), esc_html(sanitize_term_field('name', $t->name, $t->term_id, $taxonomy, 'display')));
                            }
                            /* translators: used between list items, there is a space after the comma */
                            echo join(__(', '), $out);
                        } else {
                            echo '&#8212;';
                        }
                        echo '</td>';
                        break;
                    }
                    ?>
			<td <?php 
                    echo $attributes;
                    ?>
><?php 
                    if (is_post_type_hierarchical($post->post_type)) {
                        do_action('manage_pages_custom_column', $column_name, $post->ID);
                    } else {
                        do_action('manage_posts_custom_column', $column_name, $post->ID);
                    }
                    do_action("manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID);
                    ?>
</td>
			<?php 
                    break;
            }
        }
        ?>
		</tr>
	<?php 
        $GLOBALS['post'] = $global_post;
    }
					$h_time = sprintf( __('%s from now'), human_time_diff( $time ) );
				else
					$h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
			} else {
				$h_time = mysql2date(__('Y/m/d'), $m_time);
			}
		}
		?>
		<td <?php echo $attributes ?>><?php echo $h_time ?></td>
		<?php
		break;

	case 'parent':
		if ( $post->post_parent > 0 ) {
			if ( get_post($post->post_parent) ) {
				$title =_draft_or_post_title($post->post_parent);
			}
			?>
			<td <?php echo $attributes ?>><strong><a href="<?php echo get_edit_post_link( $post->post_parent ); ?>"><?php echo $title ?></a></strong>, <?php echo get_the_time(__('Y/m/d')); ?></td>
			<?php
		} else {
			?>
			<td <?php echo $attributes ?>><?php _e('(Unattached)'); ?><br />
			<a class="hide-if-no-js" onclick="findPosts.open('media[]','<?php echo $post->ID ?>');return false;" href="#the-list"><?php _e('Attach'); ?></a></td>
			<?php
		}

		break;

	case 'comments':
		$attributes = 'class="comments column-comments num"' . $style;
Example #29
0
 /**
  *	Get column value of post actions
  *
  *	This part is copied from the Posts List Table class
  *
  * 	@since     1.4.2
  */
 protected function get_column_value_actions($post_id)
 {
     $actions = array();
     $post = get_post($post_id);
     $title = _draft_or_post_title();
     $post_type_object = get_post_type_object($post->post_type);
     $can_edit_post = current_user_can($post_type_object->cap->edit_post, $post->ID);
     if ($can_edit_post && 'trash' != $post->post_status) {
         $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
         $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
     }
     if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
         if ('trash' == $post->post_status) {
             $actions['untrash'] = "<a title='" . esc_attr(__('Restore this item from the Trash')) . "' href='" . wp_nonce_url(admin_url(sprintf($post_type_object->_edit_link . '&amp;action=untrash', $post->ID)), 'untrash-' . $post->post_type . '_' . $post->ID) . "'>" . __('Restore') . "</a>";
         } elseif (EMPTY_TRASH_DAYS) {
             $actions['trash'] = "<a class='submitdelete' title='" . esc_attr(__('Move this item to the Trash')) . "' href='" . get_delete_post_link($post->ID) . "'>" . __('Trash') . "</a>";
         }
         if ('trash' == $post->post_status || !EMPTY_TRASH_DAYS) {
             $actions['delete'] = "<a class='submitdelete' title='" . esc_attr(__('Delete this item permanently')) . "' href='" . get_delete_post_link($post->ID, '', true) . "'>" . __('Delete Permanently') . "</a>";
         }
     }
     if ($post_type_object->public) {
         if (in_array($post->post_status, array('pending', 'draft', 'future'))) {
             if ($can_edit_post) {
                 $actions['view'] = '<a href="' . esc_url(add_query_arg('preview', 'true', get_permalink($post->ID))) . '" title="' . esc_attr(sprintf(__('Preview &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
             }
         } elseif ('trash' != $post->post_status) {
             $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . esc_attr(sprintf(__('View &#8220;%s&#8221;'), $title)) . '" rel="permalink">' . __('View') . '</a>';
         }
     }
     return implode(' | ', $actions);
 }
Example #30
0
function all_rights_reserved()
{
    _e('All Rights Reserved', 'blanket');
}
# Manage Every Column's values
add_filter('manage_edit-page_columns', function ($columns) {
    $columns = array('cb' => '<input type="checkbox" />', 'blanket_title' => __('Title'), 'date' => 'Date');
    return $columns;
});
add_action('manage_pages_custom_column', function ($column, $post_id) {
    global $post;
    switch ($column) {
        case 'blanket_title':
            // variables
            $post = get_post($post_id);
            $title = _draft_or_post_title();
            $post_type_object = get_post_type_object($post->post_type);
            $can_edit_post = current_user_can('edit_post', $post->ID);
            // set up row actions
            $actions = array();
            if ($can_edit_post && $post->post_status != 'trash') {
                $edit_link = get_edit_post_link($post->ID);
                echo '<a class="row-title" href="' . $edit_link . '" title="' . sprintf(__('Edit &#8220;%s&#8221;'), $title) . '">' . html_entity_decode($title) . '</a>';
            } else {
                echo html_entity_decode($title);
            }
            if ($can_edit_post && 'trash' != $post->post_status) {
                $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . esc_attr(__('Edit this item')) . '">' . __('Edit') . '</a>';
                $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr(__('Edit this item inline')) . '">' . __('Quick&nbsp;Edit') . '</a>';
            }
            if (current_user_can('delete_post', $post->ID)) {