Changeset 3263029
- Timestamp:
- 03/27/2025 04:47:55 PM (12 months ago)
- Location:
- polylang/trunk
- Files:
-
- 9 edited
-
admin/admin-strings.php (modified) (3 diffs)
-
frontend/frontend-auto-translate.php (modified) (3 diffs)
-
include/Options/Options.php (modified) (7 diffs)
-
include/widget-calendar.php (modified) (7 diffs)
-
integrations/integrations.php (modified) (3 diffs)
-
modules/site-health/admin-site-health.php (modified) (7 diffs)
-
polylang.php (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
polylang/trunk/admin/admin-strings.php
r3243124 r3263029 80 80 foreach ( $widgets as $widget ) { 81 81 // Nothing can be done if the widget is created using pre WP2.8 API. There is no object, so we can't access it to get the widget options. 82 if ( ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' )) {82 if ( ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! $wp_registered_widgets[ $widget ]['callback'][0] instanceof WP_Widget ) { 83 83 continue; 84 84 } 85 85 86 $widget_settings = $wp_registered_widgets[ $widget ]['callback'][0]->get_settings(); 87 $number = $wp_registered_widgets[ $widget ]['params'][0]['number']; 86 $widget_instance = $wp_registered_widgets[ $widget ]['callback'][0]; 87 $widget_settings = $widget_instance->get_settings(); 88 $number = $wp_registered_widgets[ $widget ]['params'][0]['number']; 88 89 89 90 // Don't enable widget translation if the widget is visible in only one language or if there is no title. … … 93 94 94 95 // Widget title. 95 if ( ! empty( $widget_settings[ $number ]['title'] ) ) { 96 if ( ! empty( $widget_settings[ $number ]['title'] ) ) { 96 97 self::register_string( self::$default_strings['widget_title'], $widget_settings[ $number ]['title'], 'Widget' ); 97 98 } … … 103 104 104 105 // Content of the widget custom html. 105 if ( ! empty( $widget_settings[ $number ]['content'] ) ) {106 if ( $widget_instance instanceof WP_Widget_Custom_HTML && ! empty( $widget_settings[ $number ]['content'] ) ) { 106 107 self::register_string( self::$default_strings['widget_text'], $widget_settings[ $number ]['content'], 'Widget', true ); 107 108 } -
polylang/trunk/frontend/frontend-auto-translate.php
r3243124 r3263029 142 142 foreach ( array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) ) as $taxonomy ) { 143 143 $tax = get_taxonomy( $taxonomy ); 144 if ( ! empty( $tax ) && ! empty( $ qv[ $tax->query_var ] ) ) {144 if ( ! empty( $tax ) && ! empty( $tax->query_var ) && ! empty( $qv[ $tax->query_var ] ) ) { 145 145 $qv[ $tax->query_var ] = $this->translate_terms_list( $qv[ $tax->query_var ], $taxonomy ); 146 146 } … … 313 313 314 314 if ( is_array( $query_var ) ) { 315 $slugs = &$query_var;315 $slugs = $query_var; 316 316 } elseif ( is_string( $query_var ) ) { 317 317 $sep = strpos( $query_var, ',' ) !== false ? ',' : '+'; // Two possible separators. … … 320 320 321 321 foreach ( $slugs as &$slug ) { 322 if ( ! is_string( $slug ) ) { 323 // We got an unexpected query var, let return it unchanged. 324 return $query_var; 325 } 322 326 $slug = $this->get_translated_term_by( 'slug', $slug, $taxonomy ); 323 327 } 324 328 325 329 if ( ! empty( $sep ) ) { 326 $query_var =implode( $sep, $slugs );327 } 328 329 return $ query_var;330 return implode( $sep, $slugs ); 331 } 332 333 return $slugs; 330 334 } 331 335 } -
polylang/trunk/include/Options/Options.php
r3250588 r3263029 6 6 namespace WP_Syntex\Polylang\Options; 7 7 8 use WP_Error; 8 9 use ArrayAccess; 9 10 use ArrayIterator; 10 11 use IteratorAggregate; 11 use WP_Error;12 use WP_Site;13 12 use WP_Syntex\Polylang\Options\Abstract_Option; 14 13 … … 76 75 public function __construct() { 77 76 // Keep track of the blog ID. 78 $this->blog_id = (int) get_current_blog_id(); 77 $this->blog_id = (int) get_current_blog_id(); 78 $this->current_blog_id = $this->blog_id; 79 79 80 80 // Handle options. 81 $this->init_options_for_ blog( $this->blog_id);81 $this->init_options_for_current_blog(); 82 82 83 83 add_filter( 'pre_update_option_polylang', array( $this, 'protect_wp_option_storage' ), 1 ); 84 add_action( 'switch_blog', array( $this, ' init_options_for_blog' ), -1000 ); // Options must be ready early.84 add_action( 'switch_blog', array( $this, 'on_blog_switch' ), -1000 ); // Options must be ready early. 85 85 add_action( 'shutdown', array( $this, 'save_all' ), 1000 ); // Make sure to save options after everything. 86 86 } … … 136 136 137 137 /** 138 * Initializes options for the given blog: 139 * - stores the blog ID, 140 * - stores the options. 141 * Hooked to `switch_blog`. 138 * Initializes options for the newly switched blog if applicable. 142 139 * 143 140 * @since 3.7 … … 146 143 * @return void 147 144 */ 148 public function init_options_for_blog( $blog_id ): void {145 public function on_blog_switch( $blog_id ): void { 149 146 $this->current_blog_id = (int) $blog_id; 150 147 … … 157 154 } 158 155 159 $options = get_option( self::OPTION_NAME ); 160 161 if ( empty( $options ) || ! is_array( $options ) ) { 162 $this->options[ $blog_id ] = array(); 163 $this->modified[ $blog_id ] = true; 164 } else { 165 $this->options[ $blog_id ] = $options; 166 } 167 168 /** 169 * Fires after the options have been init for the current blog. 170 * This is the best place to register options. 171 * 172 * @since 3.7 173 * 174 * @param Options $options Instance of the options. 175 * @param int $current_blog_id Current blog ID. 176 */ 177 do_action( 'pll_init_options_for_blog', $this, $this->current_blog_id ); 156 $this->init_options_for_current_blog(); 178 157 } 179 158 … … 195 174 } 196 175 197 remove_action( 'switch_blog', array( $this, ' init_options_for_blog' ), PHP_INT_MIN);176 remove_action( 'switch_blog', array( $this, 'on_blog_switch' ), -1000 ); 198 177 199 178 // Handle the original blog first, maybe this will prevent the use of `switch_to_blog()`. … … 559 538 return $this->modified; 560 539 } 540 541 /** 542 * Initializes options for the current blog. 543 * 544 * @since 3.7 545 * 546 * @return void 547 */ 548 private function init_options_for_current_blog(): void { 549 $options = get_option( self::OPTION_NAME ); 550 551 if ( empty( $options ) || ! is_array( $options ) ) { 552 $this->options[ $this->current_blog_id ] = array(); 553 $this->modified[ $this->current_blog_id ] = true; 554 } else { 555 $this->options[ $this->current_blog_id ] = $options; 556 } 557 558 /** 559 * Fires after the options have been init for the current blog. 560 * This is the best place to register options. 561 * 562 * @since 3.7 563 * 564 * @param Options $options Instance of the options. 565 * @param int $current_blog_id Current blog ID. 566 */ 567 do_action( 'pll_init_options_for_blog', $this, $this->current_blog_id ); 568 } 561 569 } -
polylang/trunk/include/widget-calendar.php
r3243124 r3263029 54 54 55 55 /** 56 * Modified version of the WP get_calendar()function to filter the queries.56 * Modified version of the WP `get_calendar()` function to filter the queries. 57 57 * 58 58 * @since 0.5 59 * 60 * @param bool $initial Optional, default is true. Use initial calendar names. 61 * @param bool $display Optional, default is true. Set to false for return. 59 * @since 3.8 New argument $args added, with backward compatibility (WP 6.8). 60 * 61 * @param array $args { 62 * Optional. Arguments for the `get_calendar` function. 63 * 64 * @type bool $initial Whether to use initial calendar names. Default true. 65 * @type bool $display Whether to display the calendar output. Default true. 66 * @type string $post_type Optional. Post type. Default 'post'. 67 * } 62 68 * @return void|string Void if `$display` argument is true, calendar HTML if `$display` is false. 63 */64 static public function get_calendar( $initial = true, $display = true) {69 */ 70 static function get_calendar( $args = array() ) { 65 71 global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; 66 72 67 $join_clause = PLL()->model->post->join_clause(); #added# 68 $where_clause = PLL()->model->post->where_clause( PLL()->curlang ); #added# 69 70 $key = md5( PLL()->curlang->slug . $m . $monthnum . $year ); #modified# 73 $defaults = array( 74 'initial' => true, 75 'display' => true, 76 'post_type' => 'post', 77 ); 78 79 $original_args = func_get_args(); 80 $args = array(); 81 82 if ( ! empty( $original_args ) ) { 83 if ( ! is_array( $original_args[0] ) ) { 84 if ( isset( $original_args[0] ) && is_bool( $original_args[0] ) ) { 85 $defaults['initial'] = $original_args[0]; 86 } 87 if ( isset( $original_args[1] ) && is_bool( $original_args[1] ) ) { 88 $defaults['display'] = $original_args[1]; 89 } 90 } else { 91 $args = $original_args[0]; 92 } 93 } 94 95 /** This filter is documented in wp-includes/general-template.php */ 96 $args = apply_filters( 'get_calendar_args', wp_parse_args( $args, $defaults ) ); 97 98 $args['lang'] = PLL()->curlang->slug; #added# 99 100 if ( ! post_type_exists( $args['post_type'] ) ) { 101 $args['post_type'] = 'post'; 102 } 103 104 $w = 0; 105 if ( isset( $_GET['w'] ) ) { 106 $w = (int) $_GET['w']; 107 } 108 109 /* 110 * Normalize the cache key. 111 * 112 * The following ensures the same cache key is used for the same parameter 113 * and parameter equivalents. This prevents `post_type > post, initial > true` 114 * from generating a different key from the same values in the reverse order. 115 * 116 * `display` is excluded from the cache key as the cache contains the same 117 * HTML regardless of this function's need to echo or return the output. 118 * 119 * The global values contain data generated by the URL query string variables. 120 */ 121 $cache_args = $args; 122 unset( $cache_args['display'] ); 123 124 $cache_args['globals'] = array( 125 'm' => $m, 126 'monthnum' => $monthnum, 127 'year' => $year, 128 'week' => $w, 129 ); 130 131 wp_recursive_ksort( $cache_args ); 132 $key = md5( serialize( $cache_args ) ); 71 133 $cache = wp_cache_get( 'get_calendar', 'calendar' ); 72 134 73 135 if ( $cache && is_array( $cache ) && isset( $cache[ $key ] ) ) { 74 136 /** This filter is documented in wp-includes/general-template.php */ 75 $output = apply_filters( 'get_calendar', $cache[ $key ] );76 77 if ( $ display) {137 $output = apply_filters( 'get_calendar', $cache[ $key ], $args ); 138 139 if ( $args['display'] ) { 78 140 echo $output; 79 141 return; … … 87 149 } 88 150 151 $post_type = $args['post_type']; 152 89 153 // Quick check. If we have no posts at all, abort! 90 154 if ( ! $posts ) { 91 $gotsome = $wpdb->get_var( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1" ); 155 $prepared_query = $wpdb->prepare( "SELECT 1 as test FROM $wpdb->posts WHERE post_type = %s AND post_status = 'publish' LIMIT 1", $post_type ); 156 $gotsome = $wpdb->get_var( $prepared_query ); 92 157 if ( ! $gotsome ) { 93 158 $cache[ $key ] = ''; … … 97 162 } 98 163 99 if ( isset( $_GET['w'] ) ) {100 $w = (int) $_GET['w'];101 }102 164 // week_begins = 0 stands for Sunday. 103 165 $week_begins = (int) get_option( 'start_of_week' ); … … 128 190 $last_day = gmdate( 't', $unixmonth ); 129 191 192 $join_clause = PLL()->model->post->join_clause(); #added# 193 $where_clause = PLL()->model->post->where_clause( PLL()->curlang ); #added# 194 130 195 // Get the next and previous month and year with at least one post. 131 $previous = $wpdb->get_row(196 $previous_prepared_query = $wpdb->prepare( 132 197 "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 133 198 FROM $wpdb->posts $join_clause 134 199 WHERE post_date < '$thisyear-$thismonth-01' 135 AND post_type = 'post'AND post_status = 'publish' $where_clause200 AND post_type = %s AND post_status = 'publish' $where_clause 136 201 ORDER BY post_date DESC 137 LIMIT 1" 202 LIMIT 1", 203 $post_type 138 204 ); #modified# 139 $next = $wpdb->get_row( 205 $previous = $wpdb->get_row( $previous_prepared_query ); 206 207 $next_prepared_query = $wpdb->prepare( 140 208 "SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 141 209 FROM $wpdb->posts $join_clause 142 210 WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 143 AND post_type = 'post'AND post_status = 'publish' $where_clause211 AND post_type = %s AND post_status = 'publish' $where_clause 144 212 ORDER BY post_date ASC 145 LIMIT 1" 213 LIMIT 1", 214 $post_type 146 215 ); #modified# 216 $next = $wpdb->get_row( $next_prepared_query ); 147 217 148 218 /* translators: Calendar caption: 1: Month name, 2: 4-digit year. */ … … 164 234 165 235 foreach ( $myweek as $wd ) { 166 $day_name = $ initial? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd );236 $day_name = $args['initial'] ? $wp_locale->get_weekday_initial( $wd ) : $wp_locale->get_weekday_abbrev( $wd ); 167 237 $wd = esc_attr( $wd ); 168 238 $calendar_output .= "\n\t\t<th scope=\"col\" aria-label=\"$wd\">$day_name</th>"; … … 178 248 179 249 // Get days with posts. 180 $dayswithposts = $wpdb->get_results(250 $dayswithposts_prepared_query = $wpdb->prepare( 181 251 "SELECT DISTINCT DAYOFMONTH(post_date) 182 252 FROM $wpdb->posts $join_clause WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 183 AND post_type = 'post'AND post_status = 'publish'253 AND post_type = %s AND post_status = 'publish' 184 254 AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' $where_clause", 185 ARRAY_N255 $post_type 186 256 ); #modified# 257 $dayswithposts = $wpdb->get_results( $dayswithposts_prepared_query, ARRAY_N ); 187 258 188 259 if ( $dayswithposts ) { … … 272 343 wp_cache_set( 'get_calendar', $cache, 'calendar' ); 273 344 274 if ( $display ) { 275 /** This filter is documented in wp-includes/general-template.php */ 276 echo apply_filters( 'get_calendar', $calendar_output ); 345 /** This filter is documented in wp-includes/general-template.php */ 346 $calendar_output = apply_filters( 'get_calendar', $calendar_output, $args ); 347 348 if ( $args['display'] ) { 349 echo $calendar_output; 277 350 return; 278 351 } 279 /** This filter is documented in wp-includes/general-template.php */ 280 return apply_filters( 'get_calendar', $calendar_output );352 353 return $calendar_output; 281 354 } 282 355 } -
polylang/trunk/integrations/integrations.php
r2818429 r3263029 18 18 * @var PLL_Integrations|null 19 19 */ 20 protected static $instance ;20 protected static $instance = null; 21 21 22 22 /** … … 25 25 * @since 1.0 26 26 */ 27 protected function __construct() { 27 protected function __construct() {} 28 29 /** 30 * Returns the single instance of the class. 31 * 32 * @since 1.7 33 * 34 * @return self 35 */ 36 public static function instance(): self { 37 if ( null === self::$instance ) { 38 self::$instance = new self(); 39 self::$instance->init(); 40 } 41 42 return self::$instance; 43 } 44 45 /** 46 * Requires integrations. 47 * 48 * @since 3.7 49 * 50 * @return void 51 */ 52 protected function init(): void { 28 53 // Loads external integrations. 29 54 foreach ( glob( __DIR__ . '/*/load.php', GLOB_NOSORT ) as $load_script ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable … … 31 56 } 32 57 } 33 34 /**35 * Access to the single instance of the class.36 *37 * @since 1.738 *39 * @return PLL_Integrations40 */41 public static function instance() {42 if ( empty( self::$instance ) ) {43 self::$instance = new self();44 }45 46 return self::$instance;47 }48 58 } 49 59 -
polylang/trunk/modules/site-health/admin-site-health.php
r3250588 r3263029 120 120 case 'browser': 121 121 if ( ! $value ) { 122 $value = '0: ' . esc_html__( 'Detect browser language deactivated', 'polylang' );123 break; 124 } 125 $value = '1: ' . esc_html__( 'Detect browser language activated', 'polylang' );122 $value = '0: ' . __( 'Detect browser language deactivated', 'polylang' ); 123 break; 124 } 125 $value = '1: ' . __( 'Detect browser language activated', 'polylang' ); 126 126 break; 127 127 case 'rewrite': … … 129 129 $value = '1: ' . sprintf( 130 130 /* translators: %s is a URL slug: `/language/`. */ 131 esc_html__( 'Remove %s in pretty permalinks', 'polylang' ),131 __( 'Remove %s in pretty permalinks', 'polylang' ), 132 132 '`/language/`' 133 133 ); … … 136 136 $value = '0: ' . sprintf( 137 137 /* translators: %s is a URL slug: `/language/`. */ 138 esc_html__( 'Keep %s in pretty permalinks', 'polylang' ),138 __( 'Keep %s in pretty permalinks', 'polylang' ), 139 139 '`/language/`' 140 140 ); … … 142 142 case 'hide_default': 143 143 if ( $value ) { 144 $value = '1: ' . esc_html__( 'Hide URL language information for default language', 'polylang' );145 break; 146 } 147 $value = '0: ' . esc_html__( 'Display URL language information for default language', 'polylang' );144 $value = '1: ' . __( 'Hide URL language information for default language', 'polylang' ); 145 break; 146 } 147 $value = '0: ' . __( 'Display URL language information for default language', 'polylang' ); 148 148 break; 149 149 case 'force_lang': 150 150 switch ( $value ) { 151 151 case '0': 152 $value = '0: ' . esc_html__( 'The language is set from content', 'polylang' );152 $value = '0: ' . __( 'The language is set from content', 'polylang' ); 153 153 break; 154 154 case '1': 155 $value = '1: ' . esc_html__( 'The language is set from the directory name in pretty permalinks', 'polylang' );155 $value = '1: ' . __( 'The language is set from the directory name in pretty permalinks', 'polylang' ); 156 156 break; 157 157 case '2': 158 $value = '2: ' . esc_html__( 'The language is set from the subdomain name in pretty permalinks', 'polylang' );158 $value = '2: ' . __( 'The language is set from the subdomain name in pretty permalinks', 'polylang' ); 159 159 break; 160 160 case '3': 161 $value = '3: ' . esc_html__( 'The language is set from different domains', 'polylang' );161 $value = '3: ' . __( 'The language is set from different domains', 'polylang' ); 162 162 break; 163 163 } … … 165 165 case 'redirect_lang': 166 166 if ( $value ) { 167 $value = '1: ' . esc_html__( 'The front page URL contains the language code instead of the page name or page id', 'polylang' );168 break; 169 } 170 $value = '0: ' . esc_html__( 'The front page URL contains the page name or page id instead of the language code', 'polylang' );167 $value = '1: ' . __( 'The front page URL contains the language code instead of the page name or page id', 'polylang' ); 168 break; 169 } 170 $value = '0: ' . __( 'The front page URL contains the page name or page id instead of the language code', 'polylang' ); 171 171 172 172 break; 173 173 case 'media_support': 174 174 if ( ! $value ) { 175 $value = '0: ' . esc_html__( 'The media are not translated', 'polylang' );176 break; 177 } 178 $value = '1: ' . esc_html__( 'The media are translated', 'polylang' );175 $value = '0: ' . __( 'The media are not translated', 'polylang' ); 176 break; 177 } 178 $value = '1: ' . __( 'The media are translated', 'polylang' ); 179 179 break; 180 180 181 181 case 'sync': 182 182 if ( empty( $value ) ) { 183 $value = '0: ' . esc_html__( 'Synchronization disabled', 'polylang' );183 $value = '0: ' . __( 'Synchronization disabled', 'polylang' ); 184 184 } 185 185 break; … … 381 381 public function homepage_test() { 382 382 $result = array( 383 'label' => esc_html__( 'All languages have a translated homepage', 'polylang' ),383 'label' => __( 'All languages have a translated homepage', 'polylang' ), 384 384 'status' => 'good', 385 385 'badge' => array( … … 399 399 if ( ! empty( $message ) ) { 400 400 $result['status'] = 'critical'; 401 $result['label'] = esc_html__( 'The homepage is not translated in all languages', 'polylang' );401 $result['label'] = __( 'The homepage is not translated in all languages', 'polylang' ); 402 402 $result['description'] = sprintf( '<p>%s</p>', $message ); 403 403 } -
polylang/trunk/polylang.php
r3250588 r3263029 11 11 * Plugin URI: https://polylang.pro 12 12 * Description: Adds multilingual capability to WordPress 13 * Version: 3.7-beta 213 * Version: 3.7-beta3 14 14 * Requires at least: 6.2 15 15 * Requires PHP: 7.2 … … 53 53 } else { 54 54 // Go on loading the plugin 55 define( 'POLYLANG_VERSION', '3.7-beta 2' );55 define( 'POLYLANG_VERSION', '3.7-beta3' ); 56 56 define( 'PLL_MIN_WP_VERSION', '6.2' ); 57 57 define( 'PLL_MIN_PHP_VERSION', '7.2' ); -
polylang/trunk/readme.txt
r3254013 r3263029 120 120 * Pro: Add languages in ACF locations 121 121 * Pro: Add translation of ACF labels in the strings translations page 122 * Pro: Fix incorrect count of translated strings when importing strings translations 122 123 * Pro: Fix incorrect translation when an XLIFF import updates a term sharing its slug 123 124 * Pro: Fix term hierarchy with machine translation 125 * Pro: Fix indented items of a list block not translated with machine translation 124 126 * Pro: Fix navigation block inserted in the wrong language 125 127 * Update plugin updater to 1.9.4 … … 137 139 * Fix possible term duplication #1490 138 140 * Fix sanitization of translated options that may impact other strings #1571 141 * Fix a conflict with WooCommerce Price Based on Country #1638 139 142 140 143 = 3.6.7 (2025-03-11) = -
polylang/trunk/vendor/composer/installed.php
r3250588 r3263029 4 4 'pretty_version' => 'dev-master', 5 5 'version' => 'dev-master', 6 'reference' => ' 4aa0932e5521dc14491fcd371f7b7eb8914e17a6',6 'reference' => 'bebeddac74b7410fc7b81893bdc73afdae97c56c', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-master', 15 15 'version' => 'dev-master', 16 'reference' => ' 4aa0932e5521dc14491fcd371f7b7eb8914e17a6',16 'reference' => 'bebeddac74b7410fc7b81893bdc73afdae97c56c', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.