/** * Pagination for the user loop. * * @since 1.0.0 * @access public * @param array $args * @return string|void */ function mb_loop_user_pagination($args = array()) { $total_users = message_board()->user_query->total_users; $max_pages = ceil($total_users / mb_get_users_per_page()); $query = array('max_num_pages' => $max_pages); return mb_pagination($args, (object) $query); }
* @access public * @return void */ public function activation() { /* Set the current user's forum role so that they can access forum stuff. */ mb_set_current_user_role(); /** // Temporary code to simplify post type names and to match bbPress. global $wpdb; $wpdb->query( "UPDATE {$wpdb->posts} SET post_type = 'topic' WHERE post_type = 'forum_topic'" ); $wpdb->query( "UPDATE {$wpdb->posts} SET post_type = 'reply' WHERE post_type = 'forum_reply'" ); /**/ } } /** * Gets the instance of the Message_Board class. This function is useful for quickly grabbing data * used throughout the plugin. * * @since 1.0.0 * @access public * @return object */ function message_board() { return Message_Board::get_instance(); } /* Let's do this thang! */ message_board();
/** * Returns the plugin's template folder name. This is the fallback used when a template can't be found * in the theme. * * @since 1.0.0 * @access public * @return string */ function mb_get_plugin_template_folder() { return trailingslashit(message_board()->dir_path) . 'templates'; }
/** * Registers the admin scripts and styles. * * @since 1.0.0 * @access public * @return object */ public function register_scripts() { wp_register_script('message-board-admin', message_board()->dir_uri . 'js/admin.js', array('jquery'), false, true); wp_register_style('message-board-admin', message_board()->dir_uri . 'css/admin.css'); }
/** * Returns an array of the plugin's dynamic roles. These roles are "dynamic" because they are not saved in * the database. Instead, they're added early in the page load. * * Developers can overwrite the default roles with custom ones. If doing so, it is recommended to use the * API (e.g., `mb_register_role()`, `mb_unregister_role()`). * * @since 1.0.0 * @access public * @return array */ function mb_get_dynamic_roles() { return apply_filters('mb_get_dynamic_roles', message_board()->roles); }
/** * Returns a single topic type object. * * @since 1.0.0 * @access public * @param string $name * @return object|bool */ function mb_get_topic_type_object($name) { return mb_topic_type_exists($name) ? message_board()->topic_types[$name] : false; }
/** * Callback function on the `after_delete_post` hook for when a reply is deleted. * * @since 1.0.0 * @access public * @param int $post_id * @return void */ function mb_after_delete_reply($post_id) { $mb = message_board(); if (is_object($mb->deleted_post) && $mb->deleted_post->ID === $post_id) { mb_reset_reply_data($mb->deleted_post); $mb->deleted_post = null; } }
/** * Returns a single forum type object. * * @since 1.0.0 * @access public * @param string $name * @return object|bool */ function mb_get_forum_type_object($name) { return mb_forum_type_exists($name) ? message_board()->forum_types[$name] : false; }
/** * Outputs pagination links for single topic pages (the replies are paginated). * * @since 1.0.0 * @access public * @param array $args * @return string */ function mb_loop_reply_pagination($args = array()) { return mb_pagination($args, message_board()->reply_query); }
/** * Outputs pagination links for single topic pages (the replies are paginated). * * @since 1.0.0 * @access public * @param array $args * @return string */ function mb_loop_forum_pagination($args = array()) { return mb_pagination($args, message_board()->forum_query); }
/** * Outputs pagination links for single topic pages (the replies are paginated). * * @since 1.0.0 * @access public * @param array $args * @return string */ function mb_single_topic_pagination($args = array()) { return mb_pagination($args, message_board()->reply_query); }
/** * Outputs pagination links for search results. * * @since 1.0.0 * @access public * @param array $args * @return string */ function mb_loop_search_pagination($args = array()) { return mb_pagination($args, message_board()->search_query); }