Changeset 6551 for trunk/src/includes/core/theme-compat.php
- Timestamp:
- 06/15/2017 04:31:59 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/core/theme-compat.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/core/theme-compat.php
r6501 r6551 29 29 * 30 30 * This is only intended to be extended, and is included here as a basic guide 31 * for future Theme Packs to use. @link BBP_Twenty_Ten is a good example of 32 * extending this class, as is @link bbp_setup_theme_compat() 31 * for future Template Packs to use. @link bbp_setup_theme_compat() 33 32 * 34 33 * @since 2.0.0 bbPress (r3506) … … 88 87 : ''; 89 88 } 89 90 /** 91 * Return the template directory. 92 * 93 * @since 2.6.0 bbPress (r6548) 94 * 95 * @return string 96 */ 97 public function get_dir() { 98 return $this->dir; 99 } 90 100 } 91 101 … … 93 103 94 104 /** 95 * Setup the default theme compat theme105 * Setup the active template pack and register it's directory in the stack. 96 106 * 97 107 * @since 2.0.0 bbPress (r3311) … … 99 109 * @param BBP_Theme_Compat $theme 100 110 */ 101 function bbp_setup_theme_compat( $theme = ' ' ) {111 function bbp_setup_theme_compat( $theme = 'default' ) { 102 112 $bbp = bbpress(); 103 113 104 // Make sure theme package is available, set to default if not 105 if ( ! isset( $bbp->theme_compat->packages[ $theme ] ) || ! is_a( $bbp->theme_compat->packages[ $theme ], 'BBP_Theme_Compat' ) ) { 114 // Bail if something already has this under control 115 if ( ! empty( $bbp->theme_compat->theme ) ) { 116 return; 117 } 118 119 // Fallback for empty theme 120 if ( empty( $theme ) ) { 106 121 $theme = 'default'; 107 122 } 108 123 109 // Try to set the active theme compat theme. If it's not in the registered 110 // packages array, it doesn't exist, so do nothing with it. 124 // If the theme is registered, use it and add it to the stack 111 125 if ( isset( $bbp->theme_compat->packages[ $theme ] ) ) { 112 126 $bbp->theme_compat->theme = $bbp->theme_compat->packages[ $theme ]; 113 } 127 128 // Setup the template stack for the active template pack 129 bbp_register_template_stack( array( $bbp->theme_compat->theme, 'get_dir' ) ); 130 } 131 } 132 133 /** 134 * Get the current template pack package. 135 * 136 * @since 2.6.0 bbPress (r6548) 137 * 138 * @return BBP_Theme_Compat 139 */ 140 function bbp_get_current_template_pack() { 141 $bbp = bbpress(); 142 143 // Theme was not setup, so fallback to an empty object 144 if ( empty( $bbp->theme_compat->theme ) ) { 145 $bbp->theme_compat->theme = new BBP_Theme_Compat(); 146 } 147 148 // Filter & return 149 return apply_filters( 'bbp_get_current_template_pack', $bbp->theme_compat->theme ); 150 } 151 152 /** 153 * Gets the id of the bbPress compatible theme used, in the event the 154 * currently active WordPress theme does not explicitly support bbPress. 155 * This can be filtered or set manually. Tricky theme authors can override the 156 * default and include their own bbPress compatibility layers for their themes. 157 * 158 * @since 2.0.0 bbPress (r3506) 159 * 160 * @uses apply_filters() 161 * @return string 162 */ 163 function bbp_get_theme_compat_id() { 164 165 // Filter & return 166 return apply_filters( 'bbp_get_theme_compat_id', bbp_get_current_template_pack()->id ); 114 167 } 115 168 … … 125 178 * @return string 126 179 */ 127 function bbp_get_theme_compat_ id() {180 function bbp_get_theme_compat_name() { 128 181 129 182 // Filter & return 130 return apply_filters( 'bbp_get_theme_compat_id', bbpress()->theme_compat->theme->id ); 131 } 132 133 /** 134 * Gets the name of the bbPress compatible theme used, in the event the 135 * currently active WordPress theme does not explicitly support bbPress. 136 * This can be filtered or set manually. Tricky theme authors can override the 137 * default and include their own bbPress compatibility layers for their themes. 138 * 139 * @since 2.0.0 bbPress (r3506) 140 * 141 * @uses apply_filters() 142 * @return string 143 */ 144 function bbp_get_theme_compat_name() { 145 146 // Filter & return 147 return apply_filters( 'bbp_get_theme_compat_name', bbpress()->theme_compat->theme->name ); 183 return apply_filters( 'bbp_get_theme_compat_name', bbp_get_current_template_pack()->name ); 148 184 } 149 185 … … 162 198 163 199 // Filter & return 164 return apply_filters( 'bbp_get_theme_compat_version', bbp ress()->theme_compat->theme->version );200 return apply_filters( 'bbp_get_theme_compat_version', bbp_get_current_template_pack()->version ); 165 201 } 166 202 … … 179 215 180 216 // Filter & return 181 return apply_filters( 'bbp_get_theme_compat_dir', bbp ress()->theme_compat->theme->dir );217 return apply_filters( 'bbp_get_theme_compat_dir', bbp_get_current_template_pack()->dir ); 182 218 } 183 219 … … 196 232 197 233 // Filter & return 198 return apply_filters( 'bbp_get_theme_compat_url', bbp ress()->theme_compat->theme->url );234 return apply_filters( 'bbp_get_theme_compat_url', bbp_get_current_template_pack()->url ); 199 235 } 200 236 … … 273 309 274 310 /** 275 * Set the theme compatoriginal_template global311 * Is a template the original_template global 276 312 * 277 313 * Stash the original template file for the current query. Useful for checking … … 283 319 $bbp = bbpress(); 284 320 321 // Bail if no original template 285 322 if ( empty( $bbp->theme_compat->original_template ) ) { 286 323 return false; … … 317 354 } 318 355 } 356 319 357 /** 320 358 * This fun little function fills up some WordPress globals with dummy data to
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)