| @@ -4,11 +4,10 @@ | ||
| 4 | 4 | |
| 5 | 5 | function bogo_add_rewrite_tags() { |
| 6 | 6 | $regex = bogo_get_lang_regex(); |
| 7 | 7 | |
| 8 | - if ( empty( $regex ) ) { | |
| 8 | + if ( empty( $regex ) ) | |
| 9 | 9 | return; |
| 10 | - } | |
| 11 | 10 | |
| 12 | 11 | add_rewrite_tag( '%lang%', $regex, 'lang=' ); |
| 13 | 12 | |
| 14 | 13 | $old_regex = bogo_get_prop( 'lang_rewrite_regex' ); |
| @@ -181,31 +180,17 @@ | ||
| 181 | 180 | |
| 182 | 181 | function bogo_rewrite_rules_array( $rules ) { |
| 183 | 182 | global $wp_rewrite; |
| 184 | 183 | |
| 185 | - $lang_regex = bogo_get_lang_regex(); | |
| 186 | - | |
| 187 | - // REST rewrite rules | |
| 188 | - if ( function_exists( 'rest_get_url_prefix' ) ) { | |
| 189 | - $rest_url_prefix = rest_get_url_prefix(); | |
| 190 | - | |
| 191 | - $extra_rules = array( | |
| 192 | - "^{$lang_regex}/{$rest_url_prefix}/?$" | |
| 193 | - => 'index.php?lang=$matches[1]&rest_route=/', | |
| 194 | - "^{$lang_regex}/{$rest_url_prefix}/(.*)?" | |
| 195 | - => 'index.php?lang=$matches[1]&rest_route=/$matches[2]' ); | |
| 196 | - | |
| 197 | - $rules = $extra_rules + $rules; | |
| 198 | - } | |
| 199 | - | |
| 200 | 184 | $post_types = array_diff( |
| 201 | 185 | (array) bogo_localizable_post_types(), |
| 202 | 186 | get_post_types( array( '_builtin' => true ) ) ); |
| 203 | 187 | |
| 204 | - if ( empty( $post_types ) ) { | |
| 188 | + if ( empty( $post_types ) ) | |
| 205 | 189 | return $rules; |
| 206 | - } | |
| 207 | 190 | |
| 191 | + $lang_regex = bogo_get_lang_regex(); | |
| 192 | + | |
| 208 | 193 | foreach ( $post_types as $post_type ) { |
| 209 | 194 | if ( ! $post_type_obj = get_post_type_object( $post_type ) ) |
| 210 | 195 | continue; |
| 211 | 196 | |
| @@ -316,9 +301,8 @@ | ||
| 316 | 301 | $feedregex = $wp_rewrite->feed_base . '/' . $feedregex2; |
| 317 | 302 | $trackbackregex = 'trackback/?$'; |
| 318 | 303 | $pageregex = $wp_rewrite->pagination_base . '/?([0-9]{1,})/?$'; |
| 319 | 304 | $commentregex = 'comment-page-([0-9]{1,})/?$'; |
| 320 | - $embedregex = 'embed/?$'; | |
| 321 | 305 | |
| 322 | 306 | if ( $endpoints ) { |
| 323 | 307 | $ep_query_append = array(); |
| 324 | 308 | |
| @@ -334,16 +318,14 @@ | ||
| 334 | 318 | $num_tokens = count( $tokens[0] ); |
| 335 | 319 | $index = $wp_rewrite->index; |
| 336 | 320 | $feedindex = $index; |
| 337 | 321 | $trackbackindex = $index; |
| 338 | - $embedindex = $index; | |
| 339 | 322 | |
| 340 | 323 | for ( $i = 0; $i < $num_tokens; ++$i ) { |
| 341 | - if ( 0 < $i ) { | |
| 324 | + if ( 0 < $i ) | |
| 342 | 325 | $queries[$i] = $queries[$i - 1] . '&'; |
| 343 | - } else { | |
| 326 | + else | |
| 344 | 327 | $queries[$i] = ''; |
| 345 | - } | |
| 346 | 328 | |
| 347 | 329 | $query_token = |
| 348 | 330 | str_replace( $wp_rewrite->rewritecode, $wp_rewrite->queryreplace, $tokens[0][$i] ) |
| 349 | 331 | . $wp_rewrite->preg_index( $i + 1 ); |
| @@ -352,11 +334,10 @@ | ||
| 352 | 334 | } |
| 353 | 335 | |
| 354 | 336 | $structure = $permalink_structure; |
| 355 | 337 | |
| 356 | - if ( $front != '/' ) { | |
| 338 | + if ( $front != '/' ) | |
| 357 | 339 | $structure = str_replace( $front, '', $structure ); |
| 358 | - } | |
| 359 | 340 | |
| 360 | 341 | $structure = trim( $structure, '/' ); |
| 361 | 342 | |
| 362 | 343 | $dirs = $walk_dirs ? explode( '/', $structure ) : array( $structure ); |
| @@ -419,28 +400,24 @@ | ||
| 419 | 400 | } |
| 420 | 401 | |
| 421 | 402 | $rewrite = array(); |
| 422 | 403 | |
| 423 | - if ( $feed ) { | |
| 404 | + if ( $feed ) | |
| 424 | 405 | $rewrite = array( $feedmatch => $feedquery, $feedmatch2 => $feedquery2 ); |
| 425 | - } | |
| 426 | 406 | |
| 427 | - if ( $paged ) { | |
| 407 | + if ( $paged ) | |
| 428 | 408 | $rewrite = array_merge( $rewrite, array( $pagematch => $pagequery ) ); |
| 429 | - } | |
| 430 | 409 | |
| 431 | - if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) { | |
| 410 | + if ( EP_PAGES & $ep_mask || EP_PERMALINK & $ep_mask ) | |
| 432 | 411 | $rewrite = array_merge( $rewrite, array( $commentmatch => $commentquery ) ); |
| 433 | - } elseif ( EP_ROOT & $ep_mask && get_option( 'page_on_front' ) ) { | |
| 412 | + else if ( EP_ROOT & $ep_mask && get_option( 'page_on_front' ) ) | |
| 434 | 413 | $rewrite = array_merge( $rewrite, array( $rootcommentmatch => $rootcommentquery ) ); |
| 435 | - } | |
| 436 | 414 | |
| 437 | 415 | if ( $endpoints ) { |
| 438 | 416 | foreach ( (array) $ep_query_append as $regex => $ep ) { |
| 439 | - if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) { | |
| 417 | + if ( $ep[0] & $ep_mask || $ep[0] & $ep_mask_specific ) | |
| 440 | 418 | $rewrite[$match . $regex] = $index . '?' . $query |
| 441 | 419 | . $ep[1] . $wp_rewrite->preg_index( $num_toks + 2 ); |
| 442 | - } | |
| 443 | 420 | } |
| 444 | 421 | } |
| 445 | 422 | |
| 446 | 423 | if ( $num_toks ) { |
| @@ -457,11 +434,10 @@ | ||
| 457 | 434 | && strpos( $struct, '%minute%' ) !== false |
| 458 | 435 | && strpos( $struct, '%second%' ) !== false ) ) { |
| 459 | 436 | $post = true; |
| 460 | 437 | |
| 461 | - if ( strpos( $struct, '%pagename%' ) !== false ) { | |
| 438 | + if ( strpos( $struct, '%pagename%' ) !== false ) | |
| 462 | 439 | $page = true; |
| 463 | - } | |
| 464 | 440 | } |
| 465 | 441 | |
| 466 | 442 | if ( ! $post ) { |
| 467 | 443 | foreach ( get_post_types( array( '_builtin' => false ) ) as $ptype ) { |
| @@ -475,12 +451,8 @@ | ||
| 475 | 451 | |
| 476 | 452 | if ( $post ) { |
| 477 | 453 | $trackbackmatch = $match . $trackbackregex; |
| 478 | 454 | $trackbackquery = $trackbackindex . '?' . $query . '&tb=1'; |
| 479 | - | |
| 480 | - $embedmatch = $match . $embedregex; | |
| 481 | - $embedquery = $embedindex . '?' . $query . '&embed=true'; | |
| 482 | - | |
| 483 | 455 | $match = rtrim( $match, '/' ); |
| 484 | 456 | $submatchbase = preg_replace( '/\(([^?].+?)\)/', '(?:$1)', $match ); |
| 485 | 457 | |
| 486 | 458 | $sub1 = $submatchbase . '/([^/]+)/'; |
| @@ -487,9 +459,8 @@ | ||
| 487 | 459 | $sub1tb = $sub1 . $trackbackregex; |
| 488 | 460 | $sub1feed = $sub1 . $feedregex; |
| 489 | 461 | $sub1feed2 = $sub1 . $feedregex2; |
| 490 | 462 | $sub1comment = $sub1 . $commentregex; |
| 491 | - $sub1embed = $sub1 . $embedregex; | |
| 492 | 463 | |
| 493 | 464 | $sub2 = $submatchbase . '/attachment/([^/]+)/'; |
| 494 | 465 | $sub2tb = $sub2 . $trackbackregex; |
| 495 | 466 | $sub2feed = $sub2 . $feedregex; |
| @@ -494,15 +465,13 @@ | ||
| 494 | 465 | $sub2tb = $sub2 . $trackbackregex; |
| 495 | 466 | $sub2feed = $sub2 . $feedregex; |
| 496 | 467 | $sub2feed2 = $sub2 . $feedregex2; |
| 497 | 468 | $sub2comment = $sub2 . $commentregex; |
| 498 | - $sub2embed = $sub2 . $embedregex; | |
| 499 | 469 | |
| 500 | 470 | $subquery = $index . '?attachment=' . $wp_rewrite->preg_index( 1 ); |
| 501 | 471 | $subtbquery = $subquery . '&tb=1'; |
| 502 | 472 | $subfeedquery = $subquery . '&feed=' . $wp_rewrite->preg_index( 2 ); |
| 503 | 473 | $subcommentquery = $subquery . '&cpage=' . $wp_rewrite->preg_index( 2 ); |
| 504 | - $subembedquery = $subquery . '&embed=true'; | |
| 505 | 474 | |
| 506 | 475 | if ( ! empty( $endpoints ) ) { |
| 507 | 476 | foreach ( (array) $ep_query_append as $regex => $ep ) { |
| 508 | 477 | if ( $ep[0] & EP_ATTACHMENT ) { |
| @@ -529,10 +498,8 @@ | ||
| 529 | 498 | |
| 530 | 499 | if ( $post ) { |
| 531 | 500 | $rewrite = array_merge( array( $trackbackmatch => $trackbackquery ), $rewrite ); |
| 532 | 501 | |
| 533 | - $rewrite = array_merge( array( $embedmatch => $embedquery ), $rewrite ); | |
| 534 | - | |
| 535 | 502 | if ( ! $page ) { |
| 536 | 503 | $rewrite = array_merge( $rewrite, array( |
| 537 | 504 | $sub1 => $subquery, |
| 538 | 505 | $sub1tb => $subtbquery, |
| @@ -537,10 +504,9 @@ | ||
| 537 | 504 | $sub1 => $subquery, |
| 538 | 505 | $sub1tb => $subtbquery, |
| 539 | 506 | $sub1feed => $subfeedquery, |
| 540 | 507 | $sub1feed2 => $subfeedquery, |
| 541 | - $sub1comment => $subcommentquery, | |
| 542 | - $sub1embed => $subembedquery ) ); | |
| 508 | + $sub1comment => $subcommentquery ) ); | |
| 543 | 509 | } |
| 544 | 510 | |
| 545 | 511 | $rewrite = array_merge( array( |
| 546 | 512 | $sub2 => $subquery, |
| @@ -546,10 +512,9 @@ | ||
| 546 | 512 | $sub2 => $subquery, |
| 547 | 513 | $sub2tb => $subtbquery, |
| 548 | 514 | $sub2feed => $subfeedquery, |
| 549 | 515 | $sub2feed2 => $subfeedquery, |
| 550 | - $sub2comment => $subcommentquery, | |
| 551 | - $sub2embed => $subembedquery ), $rewrite ); | |
| 516 | + $sub2comment => $subcommentquery ), $rewrite ); | |
| 552 | 517 | } |
| 553 | 518 | } |
| 554 | 519 | |
| 555 | 520 | $post_rewrite = array_merge( $rewrite, $post_rewrite ); |
| @@ -556,4 +521,6 @@ | ||
| 556 | 521 | } |
| 557 | 522 | |
| 558 | 523 | return $post_rewrite; |
| 559 | 524 | } |
| 525 | + | |
| 526 | +?> | |