Beispiel #1
0
 /**
  * Retrieve the posts counts
  */
 public function get_posts_counts()
 {
     global $wp_query;
     $counts = ap_flagged_posts_count();
     $this->published_count = $counts->publish;
     $this->pending_count = $counts->pending;
     $this->trash_count = $counts->trash;
     $this->draft_count = $counts->draft;
     $this->moderate_count = $counts->moderate;
     $this->closed_count = $counts->closed;
     $this->total_count = $counts->total;
 }
Beispiel #2
0
 /**
  * Register the administration menu for this plugin into the WordPress Dashboard menu.
  */
 public function add_plugin_admin_menu()
 {
     if (!current_user_can('delete_pages')) {
         return;
     }
     global $submenu;
     $flagged_count = ap_flagged_posts_count();
     $flagged_count = $flagged_count->total > 0 ? $flagged_count->total : 0;
     $num_posts = wp_count_posts('question', 'readable');
     $status = 'moderate';
     $mod_count = 0;
     if (!empty($num_posts->{$status})) {
         $mod_count = $num_posts->{$status};
     }
     $total = $flagged_count + $mod_count;
     $Totalcount = '';
     if ($total > 0) {
         $Totalcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($total) . '</span></span>';
     }
     $Flagcount = '';
     if ($flagged_count > 0) {
         $Flagcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($flagged_count) . '</span></span>';
     }
     $Modcount = '';
     if ($mod_count > 0) {
         $Modcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($mod_count) . '</span></span>';
     }
     $pos = $this->get_free_menu_position(42.9);
     add_menu_page('AnsPress', 'AnsPress' . $Totalcount, 'delete_pages', 'anspress', array($this, 'dashboard_page'), ANSPRESS_URL . '/assets/answer.png', $pos);
     add_submenu_page('anspress', __('All Questions', 'anspress-question-answer'), __('All Questions', 'anspress-question-answer'), 'delete_pages', 'edit.php?post_type=question', '');
     add_submenu_page('anspress', __('New Question', 'anspress-question-answer'), __('New Question', 'anspress-question-answer'), 'delete_pages', 'post-new.php?post_type=question', '');
     add_submenu_page('anspress', __('All Answers', 'anspress-question-answer'), __('All Answers', 'anspress-question-answer'), 'delete_pages', 'edit.php?post_type=answer', '');
     add_submenu_page('anspress', __('Moderate question & answer', 'anspress-question-answer'), __('Moderate', 'anspress-question-answer') . $Modcount, 'manage_options', 'anspress_moderate', array($this, 'display_moderate_page'));
     add_submenu_page('anspress', __('Flagged question & answer', 'anspress-question-answer'), __('Flagged', 'anspress-question-answer') . $Flagcount, 'delete_pages', 'anspress_flagged', array($this, 'display_flagged_page'));
     add_submenu_page('anspress', __('Reputation', 'anspress-question-answer'), __('Reputation', 'anspress-question-answer'), 'manage_options', 'anspress_reputation', array($this, 'display_reputation_page'));
     add_submenu_page('ap_post_flag', __('Post flag', 'anspress-question-answer'), __('Post flag', 'anspress-question-answer'), 'delete_pages', 'ap_post_flag', array($this, 'display_post_flag'));
     add_submenu_page('ap_select_question', __('Select question', 'anspress-question-answer'), __('Select question', 'anspress-question-answer'), 'delete_pages', 'ap_select_question', array($this, 'display_select_question'));
     /**
      * ACTION: ap_admin_menu
      * @since unknown
      */
     do_action('ap_admin_menu');
     add_submenu_page('anspress', __('AnsPress Options', 'anspress-question-answer'), __('Options', 'anspress-question-answer'), 'manage_options', 'anspress_options', array($this, 'display_plugin_admin_page'));
     $submenu['anspress'][500] = array('Theme & Extensions', 'manage_options', 'http://anspress.io/themes/');
     add_submenu_page('anspress', __('About AnsPress', 'anspress-question-answer'), __('About AnsPress', 'anspress-question-answer'), 'manage_options', 'anspress_about', array($this, 'display_plugin_about_page'));
 }
Beispiel #3
0
 /**
  * Retrieve the posts counts
  */
 public function get_posts_counts()
 {
     global $wp_query;
     $counts = ap_flagged_posts_count();
     $this->published_count = $counts->publish;
     $this->pending_count = $counts->pending;
     $this->trash_count = $counts->trash;
     $this->draft_count = $counts->draft;
     $this->moderate_count = $counts->moderate;
     foreach ($counts as $count) {
         $this->total_count += $count;
     }
 }
Beispiel #4
0
 /**
  * Register the administration menu for this plugin into the WordPress Dashboard menu.
  */
 public function add_plugin_admin_menu()
 {
     $flagged_count = ap_flagged_posts_count();
     $flagged_count = $flagged_count->total > 0 ? $flagged_count->total : 0;
     $num_posts = wp_count_posts('question', 'readable');
     $status = "moderate";
     $mod_count = 0;
     $count = '';
     if (!empty($num_posts->{$status})) {
         $mod_count = $num_posts->{$status};
     }
     $total = $flagged_count + $mod_count;
     $Totalcount = '';
     if ($total > 0) {
         $Totalcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($total) . '</span></span>';
     }
     $Flagcount = '';
     if ($flagged_count > 0) {
         $Flagcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($flagged_count) . '</span></span>';
     }
     $Modcount = '';
     if ($mod_count > 0) {
         $Modcount = ' <span class="update-plugins count"><span class="plugin-count">' . number_format_i18n($mod_count) . '</span></span>';
     }
     add_menu_page('AnsPress', 'AnsPress' . $Totalcount, 'manage_options', 'anspress', array($this, 'dashboard_page'), ANSPRESS_URL . '/assets/answer.png', 6);
     add_submenu_page('anspress', __('All Questions', 'ap'), __('All Questions', 'ap'), 'manage_options', 'edit.php?post_type=question', '');
     add_submenu_page('anspress', __('New Question', 'ap'), __('New Question', 'ap'), 'manage_options', 'post-new.php?post_type=question', '');
     add_submenu_page('anspress', __('All Answers', 'ap'), __('All Answers', 'ap'), 'manage_options', 'edit.php?post_type=answer', '');
     add_submenu_page('anspress', __('Moderate question & answer', 'ap'), __('Moderate', 'ap') . $Modcount, 'manage_options', 'anspress_moderate', array($this, 'display_moderate_page'));
     add_submenu_page('anspress', __('Flagged question & answer', 'ap'), __('Flagged', 'ap') . $Flagcount, 'manage_options', 'anspress_flagged', array($this, 'display_flagged_page'));
     add_submenu_page('anspress', 'Questions Category', 'Category', 'manage_options', 'edit-tags.php?taxonomy=question_category');
     add_submenu_page('anspress', 'Questions Tags', 'Tags', 'manage_options', 'edit-tags.php?taxonomy=question_tags');
     add_submenu_page('anspress', 'Questions Label', 'Label', 'manage_options', 'edit-tags.php?taxonomy=question_label');
     do_action('ap_admin_menu');
     add_submenu_page('anspress', __('Points', 'ap'), __('User Points', 'ap'), 'manage_options', 'ap_points', array($this, 'display_points_page'));
     add_submenu_page('anspress', __('Badges', 'ap'), __('User Badges', 'ap'), 'manage_options', 'ap_badges', array($this, 'display_badges_page'));
     add_submenu_page('anspress', __('AnsPress Options', 'ap'), __('Options', 'ap'), 'manage_options', 'anspress_options', array($this, 'display_plugin_admin_page'));
     add_submenu_page('anspress', __('Addons', 'ap'), __('Addons', 'ap'), 'manage_options', 'anspress_addons', array($this, 'display_plugin_addons_page'));
     add_submenu_page('ap_install', __('Install', 'ap'), __('Install', 'ap'), 'manage_options', 'anspress_install', array($this, 'display_install_page'));
 }