| 1 |
<?php |
| 2 |
|
| 3 |
/* |
| 4 |
* links model base class when using pretty permalinks |
| 5 |
* |
| 6 |
* @since 1.6 |
| 7 |
*/ |
| 8 |
abstract class PLL_Links_Permalinks extends PLL_Links_Model { |
| 9 |
public $using_permalinks = true; |
| 10 |
protected $always_rewrite = array('date', 'root', 'comments', 'search', 'author', 'post_format'); |
| 11 |
|
| 12 |
/* |
| 13 |
* returns the link to the first page when using pretty permalinks |
| 14 |
* |
| 15 |
* @since 1.2 |
| 16 |
* |
| 17 |
* @param string $url url to modify |
| 18 |
* @return string modified url |
| 19 |
*/ |
| 20 |
public function remove_paged_from_link($url) { |
| 21 |
return preg_replace('#\/page\/[0-9]+\/#', '/', $url); // FIXME trailing slash ? |
| 22 |
} |
| 23 |
|
| 24 |
/* |
| 25 |
* returns the link to the paged page when using pretty permalinks |
| 26 |
* |
| 27 |
* @since 1.5 |
| 28 |
* |
| 29 |
* @param string $url url to modify |
| 30 |
* @param int $page |
| 31 |
* @return string modified url |
| 32 |
*/ |
| 33 |
public function add_paged_to_link($url, $page) { |
| 34 |
return trailingslashit($url) . 'page/' . $page; // FIXME trailing slash ? |
| 35 |
} |
| 36 |
|
| 37 |
/* |
| 38 |
* prepares rewrite rules filters |
| 39 |
* |
| 40 |
* @since 1.6 |
| 41 |
*/ |
| 42 |
public function get_rewrite_rules_filters() { |
| 43 |
// make sure we have the right post types and taxonomies |
| 44 |
$types = array_values(array_merge($this->model->get_translated_post_types(), $this->model->get_translated_taxonomies())); |
| 45 |
$types = array_merge($this->always_rewrite, $types); |
| 46 |
return apply_filters('pll_rewrite_rules', $types); // allow plugins to add rewrite rules to the language filter |
| 47 |
} |
| 48 |
} |
| 49 |
|