PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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 +43 -6 2.7.33.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Base class to manage the static front page and the page for posts
5 8 *
@@ -5,12 +8,42 @@
5 8 *
6 9 * @since 1.8
7 10 */
8 11 class PLL_Static_Pages {
9 - public $model, $options;
10 - public $page_on_front, $page_for_posts;
12 + /**
13 + * Id of the page on front.
14 + *
15 + * @var int
16 + */
17 + public $page_on_front;
11 18
12 19 /**
20 + * Id of the page for posts.
21 + *
22 + * @var int
23 + */
24 + public $page_for_posts;
25 +
26 + /**
27 + * Stores the plugin options.
28 + *
29 + * @var array
30 + */
31 + protected $options;
32 +
33 + /**
34 + * @var PLL_Model
35 + */
36 + protected $model;
37 +
38 + /**
39 + * Current language.
40 + *
41 + * @var PLL_Language
42 + */
43 + protected $curlang;
44 +
45 + /**
13 46 * Constructor: setups filters and actions
14 47 *
15 48 * @since 1.8
16 49 *
@@ -41,8 +74,10 @@
41 74 /**
42 75 * Stores the page on front and page for posts ids
43 76 *
44 77 * @since 1.8
78 + *
79 + * @return void
45 80 */
46 81 public function init() {
47 82 if ( 'page' == get_option( 'show_on_front' ) ) {
48 83 $this->page_on_front = get_option( 'page_on_front' );
@@ -71,14 +106,15 @@
71 106 return $link;
72 107 }
73 108
74 109 /**
75 - * Adds page_on_front and page_for_posts properties to the language objects
110 + * Adds page_on_front and page_for_posts properties to the language objects.
76 111 *
77 112 * @since 1.8
78 113 *
79 - * @param array $languages
80 - * @param object $model
114 + * @param PLL_Language[] $languages The list of languages.
115 + * @param PLL_Model $model The instance of PLL_Model.
116 + * @return PLL_Language[]
81 117 */
82 118 public static function pll_languages_list( $languages, $model ) {
83 119 if ( 'page' === get_option( 'show_on_front' ) ) {
84 120 foreach ( $languages as $k => $language ) {
@@ -99,9 +135,9 @@
99 135 * @return int
100 136 */
101 137 public function translate_page_for_posts( $v ) {
102 138 // 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 - return isset( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
139 + return isset( $this->curlang->page_for_posts ) && ( $this->curlang->page_for_posts ) && ! doing_action( 'switch_blog' ) ? $this->curlang->page_for_posts : $v;
104 140 }
105 141
106 142 /**
107 143 * Fixes the oembed for the translated static front page
@@ -110,8 +146,9 @@
110 146 * @since 2.6
111 147 *
112 148 * @param int $post_id The post ID.
113 149 * @param string $url The requested URL.
150 + * @return int
114 151 */
115 152 public function oembed_request_post_id( $post_id, $url ) {
116 153 foreach ( $this->model->get_languages_list() as $lang ) {
117 154 if ( trailingslashit( $url ) === trailingslashit( $lang->home_url ) ) {