PluginProbe
Polylang / 3.1
Polylang v3.1
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 +40 -6 2.83.1 View file →
@@ -8,12 +8,42 @@
8 8 *
9 9 * @since 1.8
10 10 */
11 11 class PLL_Static_Pages {
12 - public $model, $options;
13 - 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;
14 18
15 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 + /**
16 46 * Constructor: setups filters and actions
17 47 *
18 48 * @since 1.8
19 49 *
@@ -44,8 +74,10 @@
44 74 /**
45 75 * Stores the page on front and page for posts ids
46 76 *
47 77 * @since 1.8
78 + *
79 + * @return void
48 80 */
49 81 public function init() {
50 82 if ( 'page' == get_option( 'show_on_front' ) ) {
51 83 $this->page_on_front = get_option( 'page_on_front' );
@@ -74,14 +106,15 @@
74 106 return $link;
75 107 }
76 108
77 109 /**
78 - * 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.
79 111 *
80 112 * @since 1.8
81 113 *
82 - * @param array $languages
83 - * @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[]
84 117 */
85 118 public static function pll_languages_list( $languages, $model ) {
86 119 if ( 'page' === get_option( 'show_on_front' ) ) {
87 120 foreach ( $languages as $k => $language ) {
@@ -102,9 +135,9 @@
102 135 * @return int
103 136 */
104 137 public function translate_page_for_posts( $v ) {
105 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
106 - 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;
107 140 }
108 141
109 142 /**
110 143 * Fixes the oembed for the translated static front page
@@ -113,8 +146,9 @@
113 146 * @since 2.6
114 147 *
115 148 * @param int $post_id The post ID.
116 149 * @param string $url The requested URL.
150 + * @return int
117 151 */
118 152 public function oembed_request_post_id( $post_id, $url ) {
119 153 foreach ( $this->model->get_languages_list() as $lang ) {
120 154 if ( trailingslashit( $url ) === trailingslashit( $lang->home_url ) ) {