Changeset 555
- Timestamp:
- 04/25/2014 04:05:46 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/functions.php
r554 r555 50 50 add_action( 'wp_enqueue_scripts', __NAMESPACE__ . '\\theme_scripts_styles' ); 51 51 add_filter( 'post_type_link', __NAMESPACE__ . '\\method_permalink', 10, 2 ); 52 add_filter( 'term_link', __NAMESPACE__ . '\\taxonomy_permalink', 10, 3 ); 52 53 add_theme_support( 'automatic-feed-links' ); 53 54 add_theme_support( 'post-thumbnails' ); … … 83 84 $query->set( 'orderby', 'title' ); 84 85 $query->set( 'order', 'ASC' ); 86 } 87 88 if ( $query->is_main_query() && $query->is_tax() && $query->get( 'wp-parser-source-file' ) ) { 89 $query->set( 'wp-parser-source-file', str_replace( array( '.php', '/' ), array( '-php', '_' ), $query->query['wp-parser-source-file'] ) ); 85 90 } 86 91 } … … 121 126 'rewrite' => array( 122 127 'feeds' => false, 123 'slug' => 'reference/function ',128 'slug' => 'reference/functions', 124 129 'with_front' => false, 125 130 ), … … 128 133 129 134 // Methods 130 add_rewrite_rule( ' method/([^/]+)/([^/]+)/?$', 'index.php?post_type=wp-parser-function&name=$matches[1]-$matches[2]', 'top' );135 add_rewrite_rule( 'reference/classes/([^/]+)/([^/]+)/?$', 'index.php?post_type=wp-parser-method&name=$matches[1]-$matches[2]', 'top' ); 131 136 132 137 // Classes … … 152 157 'rewrite' => array( 153 158 'feeds' => false, 154 'slug' => 'reference/class ',159 'slug' => 'reference/classes', 155 160 'with_front' => false, 156 161 ), … … 180 185 'rewrite' => array( 181 186 'feeds' => false, 182 'slug' => 'reference/hook ',187 'slug' => 'reference/hooks', 183 188 'with_front' => false, 184 189 ), … … 208 213 'rewrite' => array( 209 214 'feeds' => false, 210 'slug' => ' method',215 'slug' => 'classes', 211 216 'with_front' => false, 212 217 ), … … 240 245 ), 241 246 'public' => true, 242 'rewrite' => array( 'slug' => 'reference/files' ), 247 'hierarchical' => true, 248 'rewrite' => array( 'slug' => 'reference/files', 'hierarchical' => true ), 243 249 'sort' => false, 244 250 'update_count_callback' => '_update_post_term_count', … … 267 273 268 274 function method_permalink( $link, $post ) { 269 if ( $post->post_type !== 'wp-parser- function' || $post->post_parent == 0)275 if ( $post->post_type !== 'wp-parser-method' ) 270 276 return $link; 271 277 272 278 list( $class, $method ) = explode( '-', $post->post_name ); 273 $link = home_url( user_trailingslashit( "method/$class/$method" ) ); 279 $link = home_url( user_trailingslashit( "reference/classes/$class/$method" ) ); 280 return $link; 281 } 282 283 function taxonomy_permalink( $link, $term, $taxonomy ) { 284 if ( $taxonomy === 'wp-parser-source-file' ) { 285 $slug = $term->slug; 286 if ( substr( $slug, -4 ) === '-php' ) { 287 $slug = substr( $slug, 0, -4 ) . '.php'; 288 $slug = str_replace( '_', '/', $slug ); 289 } 290 $link = home_url( user_trailingslashit( "reference/files/$slug" ) ); 291 } elseif ( $taxonomy === 'wp-parser-since' ) { 292 $link = str_replace( $term->slug, str_replace( '-', '.', $term->slug ), $link ); 293 } 274 294 return $link; 275 295 }
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)