retesere20

Untitled

Jan 14th, 2018
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // wp-includes\class-wp-post-type.php : 540
  2.  
  3. public function add_rewrite_rules() {
  4. global $wp_rewrite, $wp;
  5.  
  6. if ( false !== $this->query_var && $wp && is_post_type_viewable( $this ) ) {
  7. $wp->add_query_var( $this->query_var );
  8. }
  9.  
  10. if ( false !== $this->rewrite && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
  11. if ( $this->hierarchical ) {
  12. add_rewrite_tag( "%$this->name%", '(.+?)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&pagename=" );
  13. } else {
  14. add_rewrite_tag( "%$this->name%", '([^/]+)', $this->query_var ? "{$this->query_var}=" : "post_type=$this->name&name=" );
  15. }
  16.  
  17. if ( $this->has_archive ) {
  18. $archive_slug = true === $this->has_archive ? $this->rewrite['slug'] : $this->has_archive;
  19. if ( $this->rewrite['with_front'] ) {
  20. $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug;
  21. } else {
  22. $archive_slug = $wp_rewrite->root . $archive_slug;
  23. }
  24.  
  25. add_rewrite_rule( "{$archive_slug}/?$", "index.php?post_type=$this->name", 'top' );
  26. if ( $this->rewrite['feeds'] && $wp_rewrite->feeds ) {
  27. $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')';
  28. add_rewrite_rule( "{$archive_slug}/feed/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' );
  29. add_rewrite_rule( "{$archive_slug}/$feeds/?$", "index.php?post_type=$this->name" . '&feed=$matches[1]', 'top' );
  30. }
  31. if ( $this->rewrite['pages'] ) {
  32. add_rewrite_rule( "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$", "index.php?post_type=$this->name" . '&paged=$matches[1]', 'top' );
  33. }
  34. }
  35.  
  36. $permastruct_args = $this->rewrite;
  37. $permastruct_args['feed'] = $permastruct_args['feeds'];
  38. add_permastruct( $this->name, "{$this->rewrite['slug']}/%$this->name%", $permastruct_args );
  39. }
  40. }
RAW Paste Data