Changeset 3899
- Timestamp:
- 05/14/2012 08:41:02 PM (12 years ago)
- Location:
- branches/plugin
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/plugin/bbp-includes/bbp-common-functions.php
r3858 r3899 10 10 // Exit if accessed directly 11 11 if ( !defined( 'ABSPATH' ) ) exit; 12 13 /** Versions ******************************************************************/14 15 /**16 * Output the bbPress version17 *18 * @since bbPress (r3468)19 * @uses bbp_get_version() To get the bbPress version20 */21 function bbp_version() {22 echo bbp_get_version();23 }24 /**25 * Return the bbPress version26 *27 * @since bbPress (r3468)28 * @retrun string The bbPress version29 */30 function bbp_get_version() {31 return bbpress()->version;32 }33 34 /**35 * Output the bbPress database version36 *37 * @since bbPress (r3468)38 * @uses bbp_get_version() To get the bbPress version39 */40 function bbp_db_version() {41 echo bbp_get_db_version();42 }43 /**44 * Return the bbPress database version45 *46 * @since bbPress (r3468)47 * @retrun string The bbPress version48 */49 function bbp_get_db_version() {50 return bbpress()->db_version;51 }52 53 /**54 * Output the bbPress database version directly from the database55 *56 * @since bbPress (r3468)57 * @uses bbp_get_version() To get the current bbPress version58 */59 function bbp_db_version_raw() {60 echo bbp_get_db_version_raw();61 }62 /**63 * Return the bbPress database version directly from the database64 *65 * @since bbPress (r3468)66 * @retrun string The current bbPress version67 */68 function bbp_get_db_version_raw() {69 return get_option( '_bbp_db_version', '' );70 }71 72 /** Post Meta *****************************************************************/73 74 /**75 * Update a posts forum meta ID76 *77 * @since bbPress (r3181)78 *79 * @param int $post_id The post to update80 * @param int $forum_id The forum81 */82 function bbp_update_forum_id( $post_id, $forum_id ) {83 84 // Allow the forum ID to be updated 'just in time' before save85 $forum_id = apply_filters( 'bbp_update_forum_id', $forum_id, $post_id );86 87 // Update the post meta forum ID88 update_post_meta( $post_id, '_bbp_forum_id', (int) $forum_id );89 }90 91 /**92 * Update a posts topic meta ID93 *94 * @since bbPress (r3181)95 *96 * @param int $post_id The post to update97 * @param int $forum_id The forum98 */99 function bbp_update_topic_id( $post_id, $topic_id ) {100 101 // Allow the topic ID to be updated 'just in time' before save102 $topic_id = apply_filters( 'bbp_update_topic_id', $topic_id, $post_id );103 104 // Update the post meta topic ID105 update_post_meta( $post_id, '_bbp_topic_id', (int) $topic_id );106 }107 108 /**109 * Update a posts reply meta ID110 *111 * @since bbPress (r3181)112 *113 * @param int $post_id The post to update114 * @param int $forum_id The forum115 */116 function bbp_update_reply_id( $post_id, $reply_id ) {117 118 // Allow the reply ID to be updated 'just in time' before save119 $reply_id = apply_filters( 'bbp_update_reply_id', $reply_id, $post_id );120 121 // Update the post meta reply ID122 update_post_meta( $post_id, '_bbp_reply_id',(int) $reply_id );123 }124 12 125 13 /** Formatting ****************************************************************/ … … 339 227 340 228 /** 341 * The plugin version of bbPress comes with two topic display options:342 * - Traditional: Topics are included in the reply loop (default)343 * - New Style: Topics appear as "lead" posts, ahead of replies344 *345 * @since bbPress (r2954)346 *347 * @param $show_lead Optional. Default false348 * @return bool Yes if the topic appears as a lead, otherwise false349 */350 function bbp_show_lead_topic( $show_lead = false ) {351 return apply_filters( 'bbp_show_lead_topic', (bool) $show_lead );352 }353 354 /**355 229 * Append 'view=all' to query string if it's already there from referer 356 230 * … … 387 261 */ 388 262 function bbp_remove_view_all( $original_link = '' ) { 389 390 // Are we appending the view=all vars? 391 $link = remove_query_arg( 'view', $original_link ); 392 393 return apply_filters( 'bbp_add_view_all', $link, $original_link ); 263 return apply_filters( 'bbp_add_view_all', remove_query_arg( 'view', $original_link ), $original_link ); 394 264 } 395 265 … … 404 274 */ 405 275 function bbp_get_view_all( $cap = 'moderate' ) { 406 407 276 $retval = ( ( !empty( $_GET['view'] ) && ( 'all' == $_GET['view'] ) && current_user_can( $cap ) ) ); 408 409 277 return apply_filters( 'bbp_get_view_all', (bool) $retval ); 410 278 } … … 689 557 } 690 558 691 /** Views *********************************************************************/692 693 /**694 * Get the registered views695 *696 * Does nothing much other than return the {@link $bbp->views} variable697 *698 * @since bbPress (r2789)699 *700 * @return array Views701 */702 function bbp_get_views() {703 return bbpress()->views;704 }705 706 /**707 * Register a bbPress view708 *709 * @todo Implement feeds - See {@link http://trac.bbpress.org/ticket/1422}710 *711 * @since bbPress (r2789)712 *713 * @param string $view View name714 * @param string $title View title715 * @param mixed $query_args {@link bbp_has_topics()} arguments.716 * @param bool $feed Have a feed for the view? Defaults to true. NOT IMPLEMENTED717 * @uses sanitize_title() To sanitize the view name718 * @uses esc_html() To sanitize the view title719 * @return array The just registered (but processed) view720 */721 function bbp_register_view( $view, $title, $query_args = '', $feed = true ) {722 $bbp = bbpress();723 $view = sanitize_title( $view );724 $title = esc_html( $title );725 726 if ( empty( $view ) || empty( $title ) )727 return false;728 729 $query_args = bbp_parse_args( $query_args, '', 'register_view' );730 731 // Set exclude_stickies to true if it wasn't supplied732 if ( !isset( $query_args['show_stickies'] ) )733 $query_args['show_stickies'] = false;734 735 $bbp->views[$view]['title'] = $title;736 $bbp->views[$view]['query'] = $query_args;737 $bbp->views[$view]['feed'] = $feed;738 739 return $bbp->views[$view];740 }741 742 /**743 * Deregister a bbPress view744 *745 * @since bbPress (r2789)746 *747 * @param string $view View name748 * @uses sanitize_title() To sanitize the view name749 * @return bool False if the view doesn't exist, true on success750 */751 function bbp_deregister_view( $view ) {752 $bbp = bbpress();753 $view = sanitize_title( $view );754 755 if ( !isset( $bbp->views[$view] ) )756 return false;757 758 unset( $bbp->views[$view] );759 760 return true;761 }762 763 /**764 * Run the view's query765 *766 * @since bbPress (r2789)767 *768 * @param string $view Optional. View id769 * @param mixed $new_args New arguments. See {@link bbp_has_topics()}770 * @uses bbp_get_view_id() To get the view id771 * @uses bbp_get_view_query_args() To get the view query args772 * @uses sanitize_title() To sanitize the view name773 * @uses bbp_has_topics() To make the topics query774 * @return bool False if the view doesn't exist, otherwise if topics are there775 */776 function bbp_view_query( $view = '', $new_args = '' ) {777 778 $view = bbp_get_view_id( $view );779 if ( empty( $view ) )780 return false;781 782 $query_args = bbp_get_view_query_args( $view );783 784 if ( !empty( $new_args ) ) {785 $new_args = bbp_parse_args( $new_args, '', 'view_query' );786 $query_args = array_merge( $query_args, $new_args );787 }788 789 return bbp_has_topics( $query_args );790 }791 792 /**793 * Return the view's query arguments794 *795 * @since bbPress (r2789)796 *797 * @param string $view View name798 * @uses bbp_get_view_id() To get the view id799 * @return array Query arguments800 */801 function bbp_get_view_query_args( $view ) {802 $view = bbp_get_view_id( $view );803 $retval = !empty( $view ) ? bbpress()->views[$view]['query'] : false;804 805 return apply_filters( 'bbp_get_view_query_args', $retval, $view );806 }807 808 559 /** New/edit topic/reply helpers **********************************************/ 809 560 … … 1823 1574 } 1824 1575 1825 /** Errors ********************************************************************/1826 1827 /**1828 * Adds an error message to later be output in the theme1829 *1830 * @since bbPress (r3381)1831 *1832 * @see WP_Error()1833 * @uses WP_Error::add();1834 *1835 * @param string $code Unique code for the error message1836 * @param string $message Translated error message1837 * @param string $data Any additional data passed with the error message1838 */1839 function bbp_add_error( $code = '', $message = '', $data = '' ) {1840 bbpress()->errors->add( $code, $message, $data );1841 }1842 1843 /**1844 * Check if error messages exist in queue1845 *1846 * @since bbPress (r3381)1847 *1848 * @see WP_Error()1849 *1850 * @uses is_wp_error()1851 * @usese WP_Error::get_error_codes()1852 */1853 function bbp_has_errors() {1854 1855 // Assume no errors1856 $has_errors = false;1857 1858 // Check for errors1859 if ( bbpress()->errors->get_error_codes() )1860 $has_errors = true;1861 1862 // Filter return value1863 $has_errors = apply_filters( 'bbp_has_errors', $has_errors, bbpress()->errors );1864 1865 return $has_errors;1866 }1867 1868 1576 /** Templates ******************************************************************/ 1869 1577 … … 1917 1625 } 1918 1626 1919 /** Post Statuses *************************************************************/1920 1921 /**1922 * Return the public post status ID1923 *1924 * @since bbPress (r3504)1925 *1926 * @return string1927 */1928 function bbp_get_public_status_id() {1929 return bbpress()->public_status_id;1930 }1931 1932 /**1933 * Return the pending post status ID1934 *1935 * @since bbPress (r3581)1936 *1937 * @return string1938 */1939 function bbp_get_pending_status_id() {1940 return bbpress()->pending_status_id;1941 }1942 1943 /**1944 * Return the private post status ID1945 *1946 * @since bbPress (r3504)1947 *1948 * @return string1949 */1950 function bbp_get_private_status_id() {1951 return bbpress()->private_status_id;1952 }1953 1954 /**1955 * Return the hidden post status ID1956 *1957 * @since bbPress (r3504)1958 *1959 * @return string1960 */1961 function bbp_get_hidden_status_id() {1962 return bbpress()->hidden_status_id;1963 }1964 1965 /**1966 * Return the closed post status ID1967 *1968 * @since bbPress (r3504)1969 *1970 * @return string1971 */1972 function bbp_get_closed_status_id() {1973 return bbpress()->closed_status_id;1974 }1975 1976 /**1977 * Return the spam post status ID1978 *1979 * @since bbPress (r3504)1980 *1981 * @return string1982 */1983 function bbp_get_spam_status_id() {1984 return bbpress()->spam_status_id;1985 }1986 1987 /**1988 * Return the trash post status ID1989 *1990 * @since bbPress (r3504)1991 *1992 * @return string1993 */1994 function bbp_get_trash_status_id() {1995 return bbpress()->trash_status_id;1996 }1997 1998 /**1999 * Return the orphan post status ID2000 *2001 * @since bbPress (r3504)2002 *2003 * @return string2004 */2005 function bbp_get_orphan_status_id() {2006 return bbpress()->orphan_status_id;2007 }2008 2009 /** Rewrite IDs ***************************************************************/2010 2011 /**2012 * Return the unique ID for user profile rewrite rules2013 *2014 * @since bbPress (r3762)2015 * @return string2016 */2017 function bbp_get_user_rewrite_id() {2018 return bbpress()->user_id;2019 }2020 2021 /**2022 * Return the enique ID for all edit rewrite rules (forum|topic|reply|tag|user)2023 *2024 * @since bbPress (r3762)2025 * @return string2026 */2027 function bbp_get_edit_rewrite_id() {2028 return bbpress()->edit_id;2029 }2030 2031 /**2032 * Return the unique ID for topic view rewrite rules2033 *2034 * @since bbPress (r3762)2035 * @return string2036 */2037 function bbp_get_view_rewrite_id() {2038 return bbpress()->view_id;2039 }2040 2041 1627 ?> -
branches/plugin/bbp-includes/bbp-topic-template.php
r3861 r3899 35 35 return apply_filters( 'bbp_get_topic_post_type', bbpress()->topic_post_type ); 36 36 } 37 38 /** 39 * The plugin version of bbPress comes with two topic display options: 40 * - Traditional: Topics are included in the reply loop (default) 41 * - New Style: Topics appear as "lead" posts, ahead of replies 42 * 43 * @since bbPress (r2954) 44 * @param $show_lead Optional. Default false 45 * @return bool Yes if the topic appears as a lead, otherwise false 46 */ 47 function bbp_show_lead_topic( $show_lead = false ) { 48 return (bool) apply_filters( 'bbp_show_lead_topic', (bool) $show_lead ); 49 } 37 50 38 51 /** Topic Loop ****************************************************************/ -
branches/plugin/bbpress.php
r3833 r3899 266 266 public $options = array(); 267 267 268 /** Function Overload *****************************************************/ 269 270 /** 271 * @var array Optional Overloads WordPress functions with new functions. 272 */ 273 public $functions = array(); 274 268 275 /** Singleton *************************************************************/ 269 276 … … 420 427 require( $this->plugin_dir . 'bbp-includes/bbp-core-actions.php' ); // All actions 421 428 require( $this->plugin_dir . 'bbp-includes/bbp-core-filters.php' ); // All filters 422 require( $this->plugin_dir . 'bbp-includes/bbp-core-options.php' ); // Configuration Options 429 require( $this->plugin_dir . 'bbp-includes/bbp-core-functions.php' ); // Core functions 430 require( $this->plugin_dir . 'bbp-includes/bbp-core-options.php' ); // Configuration options 423 431 require( $this->plugin_dir . 'bbp-includes/bbp-core-caps.php' ); // Roles and capabilities 424 432 require( $this->plugin_dir . 'bbp-includes/bbp-core-classes.php' ); // Common classes
Note: See TracChangeset
for help on using the changeset viewer.