PluginProbe
Polylang / 2.5
Polylang v2.5
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/static-pages.php +6 -27 2.72.5 View file →
@@ -4,9 +4,9 @@
4 4 * Base class to manage the static front page and the page for posts
5 5 *
6 6 * @since 1.8
7 7 */
8 -class PLL_Static_Pages {
8 +abstract class PLL_Static_Pages {
9 9 public $model, $options;
10 10 public $page_on_front, $page_for_posts;
11 11
12 12 /**
@@ -16,9 +16,9 @@
16 16 *
17 17 * @param object $polylang
18 18 */
19 19 public function __construct( &$polylang ) {
20 - $this->model = &$polylang->model;
20 + $this->model = &$polylang->model;
21 21 $this->options = &$polylang->options;
22 22 $this->curlang = &$polylang->curlang;
23 23
24 24 $this->init();
@@ -32,11 +32,8 @@
32 32 add_action( 'update_option_page_for_posts', array( $this->model, 'clean_languages_cache' ) );
33 33
34 34 // Refresh rewrite rules when the page on front is modified
35 35 add_action( 'update_option_page_on_front', 'flush_rewrite_rules' );
36 -
37 - // OEmbed
38 - add_filter( 'oembed_request_post_id', array( $this, 'oembed_request_post_id' ), 10, 2 );
39 36 }
40 37
41 38 /**
42 39 * Stores the page on front and page for posts ids
@@ -46,9 +43,11 @@
46 43 public function init() {
47 44 if ( 'page' == get_option( 'show_on_front' ) ) {
48 45 $this->page_on_front = get_option( 'page_on_front' );
49 46 $this->page_for_posts = get_option( 'page_for_posts' );
50 - } else {
47 + }
48 +
49 + else {
51 50 $this->page_on_front = 0;
52 51 $this->page_for_posts = 0;
53 52 }
54 53 }
@@ -62,11 +61,9 @@
62 61 * @param int $id post id of the page
63 62 * @return string modified link
64 63 */
65 64 public function page_link( $link, $id ) {
66 - $lang = $this->model->post->get_language( $id );
67 -
68 - if ( $lang && $id == $lang->page_on_front ) {
65 + if ( ( $lang = $this->model->post->get_language( $id ) ) && $id == $lang->page_on_front ) {
69 66 return $lang->home_url;
70 67 }
71 68 return $link;
72 69 }
@@ -100,24 +97,6 @@
100 97 */
101 98 public function translate_page_for_posts( $v ) {
102 99 // Don't attempt to translate in a 'switch_blog' action as there is a risk to call this function while initializing the languages cache
103 100 return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
104 - }
105 -
106 - /**
107 - * Fixes the oembed for the translated static front page
108 - * when the language page is redirected to the front page
109 - *
110 - * @since 2.6
111 - *
112 - * @param int $post_id The post ID.
113 - * @param string $url The requested URL.
114 - */
115 - public function oembed_request_post_id( $post_id, $url ) {
116 - foreach ( $this->model->get_languages_list() as $lang ) {
117 - if ( trailingslashit( $url ) === trailingslashit( $lang->home_url ) ) {
118 - $post_id = $lang->page_on_front;
119 - }
120 - }
121 - return $post_id;
122 101 }
123 102 }