| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Links model base class when using pretty permalinks |
| 8 | 5 | * |
| @@ -8,51 +5,19 @@ | ||
| 8 | 5 | * |
| 9 | 6 | * @since 1.6 |
| 10 | 7 | */ |
| 11 | 8 | abstract class PLL_Links_Permalinks extends PLL_Links_Model { |
| 12 | - /** | |
| 13 | - * Tells this child class of PLL_Links_Model is for pretty permalinks. | |
| 14 | - * | |
| 15 | - * @var bool | |
| 16 | - */ | |
| 17 | 9 | public $using_permalinks = true; |
| 18 | - | |
| 19 | - /** | |
| 20 | - * The name of the index file which is the entry point to all requests. | |
| 21 | - * We need this before the global $wp_rewrite is created. | |
| 22 | - * Also hardcoded in WP_Rewrite. | |
| 23 | - * | |
| 24 | - * @var string | |
| 25 | - */ | |
| 26 | - protected $index = 'index.php'; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * The prefix for all permalink structures. | |
| 30 | - * | |
| 31 | - * @var string | |
| 32 | - */ | |
| 33 | - protected $root; | |
| 34 | - | |
| 35 | - /** | |
| 36 | - * Whether to add trailing slashes. | |
| 37 | - * | |
| 38 | - * @var bool | |
| 39 | - */ | |
| 40 | - protected $use_trailing_slashes; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * The name of the rewrite rules to always modify. | |
| 44 | - * | |
| 45 | - * @var string[] | |
| 46 | - */ | |
| 10 | + protected $index = 'index.php'; // Need this before $wp_rewrite is created, also hardcoded in wp-includes/rewrite.php | |
| 11 | + protected $root, $use_trailing_slashes; | |
| 47 | 12 | protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' ); |
| 48 | 13 | |
| 49 | 14 | /** |
| 50 | - * Constructor. | |
| 15 | + * Constructor | |
| 51 | 16 | * |
| 52 | 17 | * @since 1.8 |
| 53 | 18 | * |
| 54 | - * @param PLL_Model $model PLL_Model instance. | |
| 19 | + * @param object $model PLL_Model instance | |
| 55 | 20 | */ |
| 56 | 21 | public function __construct( &$model ) { |
| 57 | 22 | parent::__construct( $model ); |
| 58 | 23 | |
| @@ -78,9 +43,9 @@ | ||
| 78 | 43 | * |
| 79 | 44 | * @param string $modified_url The link to the first page |
| 80 | 45 | * @param string $original_url The link to the original paged page |
| 81 | 46 | */ |
| 82 | - return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#/page/[0-9]+/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url ); | |
| 47 | + return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url ); | |
| 83 | 48 | } |
| 84 | 49 | |
| 85 | 50 | /** |
| 86 | 51 | * Returns the link to the paged page when using pretty permalinks |
| @@ -104,13 +69,13 @@ | ||
| 104 | 69 | return apply_filters( 'pll_add_paged_to_link', user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' ), $url, $page ); |
| 105 | 70 | } |
| 106 | 71 | |
| 107 | 72 | /** |
| 108 | - * Returns the home url. | |
| 73 | + * Returns the home url | |
| 109 | 74 | * |
| 110 | 75 | * @since 1.3.1 |
| 111 | 76 | * |
| 112 | - * @param PLL_Language $lang PLL_Language object. | |
| 77 | + * @param object $lang PLL_Language object | |
| 113 | 78 | * @return string |
| 114 | 79 | */ |
| 115 | 80 | public function home_url( $lang ) { |
| 116 | 81 | return trailingslashit( parent::home_url( $lang ) ); |
| @@ -116,14 +81,14 @@ | ||
| 116 | 81 | return trailingslashit( parent::home_url( $lang ) ); |
| 117 | 82 | } |
| 118 | 83 | |
| 119 | 84 | /** |
| 120 | - * Returns the static front page url. | |
| 85 | + * Returns the static front page url | |
| 121 | 86 | * |
| 122 | 87 | * @since 1.8 |
| 123 | 88 | * |
| 124 | - * @param PLL_Language $lang The language object. | |
| 125 | - * @return string The static front page url. | |
| 89 | + * @param object $lang | |
| 90 | + * @return string | |
| 126 | 91 | */ |
| 127 | 92 | public function front_page_url( $lang ) { |
| 128 | 93 | if ( $this->options['hide_default'] && $lang->slug == $this->options['default_lang'] ) { |
| 129 | 94 | return trailingslashit( $this->home ); |
| @@ -136,10 +101,8 @@ | ||
| 136 | 101 | /** |
| 137 | 102 | * Prepares rewrite rules filters |
| 138 | 103 | * |
| 139 | 104 | * @since 1.6 |
| 140 | - * | |
| 141 | - * @return string[] | |
| 142 | 105 | */ |
| 143 | 106 | public function get_rewrite_rules_filters() { |
| 144 | 107 | // Make sure we have the right post types and taxonomies |
| 145 | 108 | $types = array_values( array_merge( $this->model->get_translated_post_types(), $this->model->get_translated_taxonomies(), $this->model->get_filtered_taxonomies() ) ); |