Ejemplo n.º 1
0
/**
 * Conditional check to see if a forum type allows new subforums to be created.
 *
 * @since  1.0.0
 * @access public
 * @param  string  $type
 * @return bool
 */
function mb_forum_type_allows_subforums($type)
{
    return mb_get_forum_type_object($type)->subforums_allowed;
}
Ejemplo n.º 2
0
 /**
  * Handles the output for custom columns.
  *
  * @since  1.0.0
  * @access public
  * @param  string  $column
  * @param  int     $post_id
  */
 public function manage_columns($column, $post_id)
 {
     switch ($column) {
         /* Post status column. */
         case 'status':
             $post_type = mb_get_forum_post_type();
             $status = get_post_status_object(mb_get_forum_status($post_id));
             /* If the forum has the "publish" post status, change it to "open". */
             if (mb_get_publish_post_status() === $status->name) {
                 wp_update_post(array('ID' => $post_id, 'post_status' => mb_get_open_post_status()));
             }
             $url = add_query_arg(array('post_status' => $status->name, 'post_type' => $post_type), admin_url('edit.php'));
             printf('<a href="%s">%s</a>', $url, $status->label);
             break;
             /* Forum type column. */
         /* Forum type column. */
         case 'type':
             $post_type = mb_get_forum_post_type();
             $forum_type = mb_get_forum_type_object(mb_get_forum_type($post_id));
             $url = add_query_arg(array('post_type' => $post_type, 'forum_type' => $forum_type->name), admin_url('edit.php'));
             printf('<a href="%s">%s</a>', $url, $forum_type->label);
             break;
             /* Topic count column. */
         /* Topic count column. */
         case 'subforums':
             $subforum_count = mb_get_forum_subforum_count($post_id);
             $subforum_count = !empty($subforum_count) ? absint($subforum_count) : number_format_i18n(0);
             if (0 < $subforum_count) {
                 printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_forum_post_type(), 'post_parent' => $post_id), admin_url('edit.php')), $subforum_count);
             } else {
                 echo $subforum_count;
             }
             break;
             /* Topic count column. */
         /* Topic count column. */
         case 'topics':
             $topic_count = mb_get_forum_topic_count($post_id);
             $topic_count = !empty($topic_count) ? absint($topic_count) : number_format_i18n(0);
             if (0 < $topic_count && current_user_can('edit_topics')) {
                 printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_topic_post_type(), 'post_parent' => $post_id), admin_url('edit.php')), $topic_count);
             } else {
                 echo $topic_count;
             }
             break;
             /* Reply count column. */
         /* Reply count column. */
         case 'replies':
             $reply_count = mb_get_forum_reply_count($post_id);
             $reply_count = !empty($reply_count) ? absint($reply_count) : number_format_i18n(0);
             if (0 < $reply_count && current_user_can('edit_replies')) {
                 printf('<a href="%s">%s</a>', add_query_arg(array('post_type' => mb_get_reply_post_type(), 'mb_forum' => $post_id), admin_url('edit.php')), $reply_count);
             } else {
                 echo $reply_count;
             }
             break;
             /* Datetime column. */
         /* Datetime column. */
         case 'datetime':
             the_time(get_option('date_format'));
             echo '<br />';
             the_time(get_option('time_format'));
             break;
             /* Just break out of the switch statement for everything else. */
         /* Just break out of the switch statement for everything else. */
         default:
             break;
     }
 }
Ejemplo n.º 3
0
 /**
  * @see Walker::start_el()
  * @since 1.0.0
  *
  * @param string $output Passed by reference. Used to append additional content.
  * @param object $page Page data object.
  * @param int $depth Depth of page in reference to parent pages. Used for padding.
  * @param array $args Uses 'selected' argument for selected page to set selected HTML attribute for option element.
  * @param int $id
  */
 public function start_el(&$output, $page, $depth = 0, $args = array(), $id = 0)
 {
     $forum_type = mb_get_forum_type_object(mb_get_forum_type($page->ID));
     $pad = str_repeat('&nbsp;', $depth * 3);
     $output .= "\t<option class=\"level-{$depth}\" value=\"{$page->ID}\"";
     if ($page->ID == $args['selected']) {
         $output .= ' selected="selected"';
     }
     $post_status = mb_get_forum_status($page->ID);
     if (mb_get_forum_post_type() === $args['child_type'] && !mb_forum_allows_subforums($page->ID)) {
         $output .= ' disabled="disabled"';
     } elseif (mb_get_topic_post_type() === $args['child_type'] && !mb_forum_allows_topics($page->ID)) {
         $output .= ' disabled="disabled"';
     }
     $output .= '>';
     $title = $page->post_title;
     if ('' === $title) {
         $title = sprintf(__('#%d (no title)'), $page->ID);
     }
     /**
      * Filter the page title when creating an HTML drop-down list of pages.
      *
      * @since 3.1.0
      *
      * @param string $title Page title.
      * @param object $page  Page data object.
      */
     $title = apply_filters('list_pages', $title, $page);
     $output .= $pad . esc_html($title);
     $output .= "</option>\n";
 }