- Timestamp:
- 02/27/2024 03:23:17 PM (2 years ago)
- Location:
- polylang/trunk
- Files:
-
- 3 added
- 99 edited
-
admin/admin-base.php (modified) (1 diff)
-
admin/admin-filters-columns.php (modified) (3 diffs)
-
admin/admin-filters-term.php (modified) (6 diffs)
-
admin/admin-filters-widgets-options.php (modified) (1 diff)
-
admin/admin-model.php (modified) (4 diffs)
-
admin/admin-nav-menu.php (modified) (1 diff)
-
admin/view-translations-media.php (modified) (1 diff)
-
admin/view-translations-post.php (modified) (1 diff)
-
admin/view-translations-term.php (modified) (1 diff)
-
changelog.txt (modified) (14 diffs)
-
frontend/canonical.php (modified) (1 diff)
-
frontend/frontend-filters-links.php (modified) (1 diff)
-
frontend/frontend-filters-widgets.php (modified) (3 diffs)
-
frontend/frontend-links.php (modified) (5 diffs)
-
frontend/frontend-nav-menu.php (modified) (2 diffs)
-
frontend/frontend-static-pages.php (modified) (1 diff)
-
include/base.php (modified) (2 diffs)
-
include/cache.php (modified) (6 diffs)
-
include/class-polylang.php (modified) (4 diffs)
-
include/crud-posts.php (modified) (1 diff)
-
include/filters-links.php (modified) (1 diff)
-
include/filters-widgets-options.php (modified) (2 diffs)
-
include/language.php (modified) (4 diffs)
-
include/license.php (modified) (2 diffs)
-
include/links-domain.php (modified) (1 diff)
-
include/model.php (modified) (5 diffs)
-
include/rest-request.php (modified) (1 diff)
-
include/translatable-object.php (modified) (2 diffs)
-
include/translate-option.php (modified) (2 diffs)
-
include/translated-post.php (modified) (3 diffs)
-
include/translated-term.php (modified) (3 diffs)
-
install/install-base.php (modified) (4 diffs)
-
install/plugin-updater.php (modified) (1 diff)
-
integrations/aqua-resizer/load.php (modified) (1 diff)
-
integrations/cache/load.php (modified) (2 diffs)
-
integrations/custom-field-template/load.php (modified) (1 diff)
-
integrations/domain-mapping/load.php (modified) (1 diff)
-
integrations/duplicate-post/load.php (modified) (1 diff)
-
integrations/jetpack/load.php (modified) (1 diff)
-
integrations/no-category-base/load.php (modified) (1 diff)
-
integrations/twenty-seventeen/load.php (modified) (1 diff)
-
integrations/wp-importer/load.php (modified) (1 diff)
-
integrations/wp-importer/wordpress-importer.php (modified) (1 diff)
-
integrations/wp-offload-media/as3cf.php (modified) (1 diff)
-
integrations/wp-offload-media/load.php (modified) (2 diffs)
-
integrations/wp-sweep/load.php (modified) (1 diff)
-
integrations/wpseo/load.php (modified) (2 diffs)
-
integrations/wpseo/wpseo-ogp.php (modified) (1 diff)
-
integrations/wpseo/wpseo.php (modified) (2 diffs)
-
integrations/yarpp/load.php (modified) (1 diff)
-
modules/machine-translation (added)
-
modules/machine-translation/load.php (added)
-
modules/machine-translation/settings-preview-machine-translation.php (added)
-
modules/share-slug/load.php (modified) (1 diff)
-
modules/share-slug/settings-preview-share-slug.php (modified) (2 diffs)
-
modules/site-health/admin-site-health.php (modified) (3 diffs)
-
modules/site-health/load.php (modified) (1 diff)
-
modules/sitemaps/load.php (modified) (1 diff)
-
modules/sitemaps/multilingual-sitemaps-provider.php (modified) (1 diff)
-
modules/sync/admin-sync.php (modified) (2 diffs)
-
modules/sync/load.php (modified) (2 diffs)
-
modules/sync/sync-metas.php (modified) (4 diffs)
-
modules/sync/sync-post-metas.php (modified) (1 diff)
-
modules/sync/sync-tax.php (modified) (5 diffs)
-
modules/sync/sync.php (modified) (1 diff)
-
modules/translate-slugs/load.php (modified) (1 diff)
-
modules/translate-slugs/settings-preview-translate-slugs.php (modified) (2 diffs)
-
modules/wizard/html-wizard-notice.php (modified) (1 diff)
-
modules/wizard/js/languages-step.js (modified) (11 diffs)
-
modules/wizard/load.php (modified) (1 diff)
-
modules/wizard/view-wizard-page.php (modified) (1 diff)
-
modules/wizard/view-wizard-step-home-page.php (modified) (1 diff)
-
modules/wizard/view-wizard-step-languages.php (modified) (2 diffs)
-
modules/wizard/view-wizard-step-last.php (modified) (1 diff)
-
modules/wizard/view-wizard-step-licenses.php (modified) (2 diffs)
-
modules/wizard/view-wizard-step-media.php (modified) (1 diff)
-
modules/wizard/view-wizard-step-untranslated-contents.php (modified) (1 diff)
-
modules/wizard/wizard.php (modified) (3 diffs)
-
modules/wpml/load.php (modified) (1 diff)
-
modules/wpml/wpml-api.php (modified) (2 diffs)
-
modules/wpml/wpml-config.php (modified) (8 diffs)
-
modules/wpml/wpml-legacy-api.php (modified) (1 diff)
-
polylang.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
-
settings/flags.php (modified) (1 diff)
-
settings/languages.php (modified) (62 diffs)
-
settings/settings-browser.php (modified) (1 diff)
-
settings/settings-licenses.php (modified) (2 diffs)
-
settings/settings-module.php (modified) (17 diffs)
-
settings/settings-url.php (modified) (2 diffs)
-
settings/settings.php (modified) (9 diffs)
-
settings/table-settings.php (modified) (1 diff)
-
settings/table-string.php (modified) (3 diffs)
-
settings/view-about.php (modified) (1 diff)
-
settings/view-languages.php (modified) (1 diff)
-
settings/view-tab-lang.php (modified) (1 diff)
-
settings/view-tab-settings.php (modified) (1 diff)
-
settings/view-tab-strings.php (modified) (1 diff)
-
uninstall.php (modified) (2 diffs)
-
vendor/composer/autoload_classmap.php (modified) (1 diff)
-
vendor/composer/autoload_static.php (modified) (1 diff)
-
vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
polylang/trunk/admin/admin-base.php
r2974283 r3042028 329 329 /* 330 330 * In some cases data could be a JSON string like in third party plugins. 331 * So we need not to break their process by adding polylang parameters as valid JSON data s.331 * So we need not to break their process by adding polylang parameters as valid JSON data. 332 332 */ 333 333 try { -
polylang/trunk/admin/admin-filters-columns.php
r2974283 r3042028 307 307 // Link to edit term ( or a translation ) 308 308 if ( ( $id = $this->model->term->get( $term_id, $language ) ) && $term = get_term( $id, $taxonomy ) ) { 309 if ( $ link = get_edit_term_link( $id, $taxonomy, $post_type ) ) {309 if ( $term instanceof WP_Term && $link = get_edit_term_link( $id, $taxonomy, $post_type ) ) { 310 310 $flag = ''; 311 311 if ( $id === $term_id ) { … … 423 423 foreach ( $translations as $term_id ) { 424 424 $level = is_taxonomy_hierarchical( $taxonomy ) ? count( get_ancestors( $term_id, $taxonomy ) ) : 0; 425 if ( $tag = get_term( $term_id, $taxonomy ) ) { 426 ob_start(); 427 $wp_list_table->single_row( $tag, $level ); 428 $data = ob_get_clean(); 429 $x->add( array( 'what' => 'row', 'data' => $data, 'supplemental' => array( 'term_id' => $term_id ) ) ); 425 $tag = get_term( $term_id, $taxonomy ); 426 427 if ( ! $tag instanceof WP_Term ) { 428 continue; 430 429 } 430 431 ob_start(); 432 $wp_list_table->single_row( $tag, $level ); 433 $data = ob_get_clean(); 434 $x->add( array( 'what' => 'row', 'data' => $data, 'supplemental' => array( 'term_id' => $term_id ) ) ); 431 435 } 432 436 … … 435 439 436 440 /** 437 * Returns the language flag or t ehlanguage slug if there is no flag.441 * Returns the language flag or the language slug if there is no flag. 438 442 * 439 443 * @since 2.8 -
polylang/trunk/admin/admin-filters-term.php
r2974283 r3042028 303 303 304 304 $this->model->term->set_language( $term_id, $language ); 305 $term = get_term( $term_id, $taxonomy ); 305 $term = get_term( $term_id, $taxonomy ); 306 $terms = array(); 306 307 307 308 // Get all terms with the same name … … 310 311 // $terms = get_terms( $taxonomy, array( 'name' => $term->name, 'hide_empty' => false, 'fields' => 'ids' ) ); should be OK in 4.2 311 312 // I may need to rework the loop below 312 $terms = $wpdb->get_results( 313 $wpdb->prepare( 314 "SELECT t.term_id FROM $wpdb->terms AS t 315 INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id 316 WHERE tt.taxonomy = %s AND t.name = %s", 317 $taxonomy, 318 $term->name 319 ) 320 ); 313 if ( $term instanceof WP_Term ) { 314 $terms = $wpdb->get_results( 315 $wpdb->prepare( 316 "SELECT t.term_id FROM $wpdb->terms AS t 317 INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id 318 WHERE tt.taxonomy = %s AND t.name = %s", 319 $taxonomy, 320 $term->name 321 ) 322 ); 323 } 321 324 322 325 // If we have several terms with the same name, they are translations of each other … … 332 335 } 333 336 334 else { 335 if ( current_user_can( 'edit_term', $term_id ) ) { 336 $this->model->term->set_language( $term_id, $this->model->get_language( sanitize_key( $_GET['inline_lang_choice'] ) ) ); 337 } 337 elseif ( current_user_can( 'edit_term', $term_id ) ) { 338 $this->model->term->set_language( $term_id, $this->model->get_language( sanitize_key( $_GET['inline_lang_choice'] ) ) ); 338 339 } 339 340 } … … 478 479 } 479 480 480 if ( $tag_cloud = wp_tag_cloud( $args ) ) { 481 $tag_cloud = wp_tag_cloud( $args ); 482 483 if ( ! empty( $tag_cloud ) ) { 484 /** @phpstan-var non-falsy-string $tag_cloud */ 481 485 $html = sprintf( '<div class="tagcloud"><h2>%1$s</h2>%2$s</div>', esc_html( $tax->labels->popular_items ), $tag_cloud ); 482 486 $x->Add( array( 'what' => 'tag_cloud', 'data' => $html ) ); … … 559 563 $return[] = array( 560 564 'id' => $term->term_id, 561 'value' => rtrim( $parents_list, ' >' ), // Trim the sep erator added at the end by WP.565 'value' => rtrim( $parents_list, ' >' ), // Trim the separator added at the end by WP. 562 566 'link' => $this->links->edit_term_translation_link( $term->term_id, $term->taxonomy, $post_type ), 563 567 ); … … 603 607 } 604 608 else { 605 $tr_term = get_term( $tr_id, $taxonomy ); 609 $tr_term = get_term( $tr_id, $taxonomy ); 610 611 if ( ! $tr_term instanceof WP_Term ) { 612 continue; 613 } 614 606 615 $split_term_id = _split_shared_term( $tr_id, $tr_term->term_taxonomy_id ); 607 616 -
polylang/trunk/admin/admin-filters-widgets-options.php
r2557081 r3042028 32 32 } 33 33 } 34 35 34 } -
polylang/trunk/admin/admin-model.php
r2907847 r3042028 133 133 134 134 // Delete users options 135 foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) { 136 delete_user_meta( $user_id, 'pll_filter_content', $lang->slug ); 137 delete_user_meta( $user_id, 'description_' . $lang->slug ); 138 } 135 delete_metadata( 'user', 0, 'pll_filter_content', '', true ); 136 delete_metadata( 'user', 0, "description_{$lang->slug}", '', true ); 139 137 140 138 // Delete domain … … 269 267 * @type string $flag Optional, country code, @see flags.php. 270 268 * } 271 * @param PLL_Language $lang Previous value of the language be eing edited.269 * @param PLL_Language $lang Previous value of the language being edited. 272 270 */ 273 271 do_action( 'pll_update_language', $args, $lang ); … … 315 313 /** 316 314 * Allow to add data to store for a language. 317 * `$locale`, `$rtl`, and `$flag_code` cannot be overwrit en.315 * `$locale`, `$rtl`, and `$flag_code` cannot be overwritten. 318 316 * 319 317 * @since 3.4 … … 346 344 $new_data = array_merge( $old_data, $add_data, $new_data ); 347 345 348 /** @var non-empty-string $serialized maybe_serialize() cannot return anything else than a string when fe eded by an array. */346 /** @var non-empty-string $serialized maybe_serialize() cannot return anything else than a string when fed by an array. */ 349 347 $serialized = maybe_serialize( $new_data ); 350 348 return $serialized; -
polylang/trunk/admin/admin-nav-menu.php
r2974283 r3042028 195 195 */ 196 196 public function pre_update_option_theme_mods( $mods ) { 197 if ( current_user_can( 'edit_theme_options' ) && is set( $mods['nav_menu_locations'] ) ) {197 if ( current_user_can( 'edit_theme_options' ) && is_array( $mods ) && isset( $mods['nav_menu_locations'] ) ) { 198 198 199 199 // Manage Locations tab in Appearance -> Menus -
polylang/trunk/admin/view-translations-media.php
r2340428 r3042028 9 9 if ( ! defined( 'ABSPATH' ) ) { 10 10 exit; // Don't access directly 11 } ;11 } 12 12 ?> 13 13 <p><strong><?php esc_html_e( 'Translations', 'polylang' ); ?></strong></p> -
polylang/trunk/admin/view-translations-post.php
r2549758 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 ?> 12 12 <p><strong><?php esc_html_e( 'Translations', 'polylang' ); ?></strong></p> -
polylang/trunk/admin/view-translations-term.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 if ( isset( $term_id ) ) { -
polylang/trunk/changelog.txt
r3008143 r3042028 57 57 * Pro: Fix deactivated language re-activated when it is edited. 58 58 * Pro: Fix language switcher in legacy widget menu not correctly rendered in widget block editor 59 * Pro: Fix error 404 for untranslated attached attach ement59 * Pro: Fix error 404 for untranslated attached attachment 60 60 * Pro: Fix a deprecated notice in ACF integration 61 61 * Pro: Fix update compatibility with WP Umbrella … … 70 70 * Fix a PHP warning `Attempt to read property "home_url" on bool` #1206 71 71 * Fix a conflict leading to a performance issue when translating the theme Astra options #1196 72 * Fix related translations reset tedwhen updating Yoast SEO titles settings #111172 * Fix related translations reset when updating Yoast SEO titles settings #1111 73 73 * Fix a fatal error in case the registered strings option is corrupted #1264 74 74 * Fix the language extraction from the URL in plain permalinks #1270 … … 168 168 * Pro: Fix a fatal error when inserting a term 169 169 * Pro: Fix translation of the block cover when duplicating a post 170 * Pro: Fix a CSS issue in bulk tran late form introduced by WP 6.0170 * Pro: Fix a CSS issue in bulk translate form introduced by WP 6.0 171 171 * Pro: Fix a CSS issue in string import/export metaboxes. 172 172 * Prevent random languages order in WP 6.0 #1041 … … 176 176 = 3.2.2 (2022-04-25) = 177 177 178 * Pro: Fix redirect occur ing for tags sharing the same slug as their translations178 * Pro: Fix redirect occurring for tags sharing the same slug as their translations 179 179 * Fix quick edit allowing to modify the language of the default category when it should not #1018 180 180 … … 183 183 * Pro: Fix users with editor role not able to save or publish posts 184 184 * Pro: Fix FSE compatibility not loaded when the plugin Gütenberg is active 185 * Pro: Fix a fatal error occur ing with Yoast SEO Premium185 * Pro: Fix a fatal error occurring with Yoast SEO Premium 186 186 * Pro: Fix a fatal error with ACF when no language is defined 187 187 … … 211 211 * Fix some PHP 8.1 deprecations #949 #985 212 212 * Fix a fatal error in PHP 8.1 #987 213 * Fix category feed not redirected when the lang age code is wrong #887213 * Fix category feed not redirected when the language code is wrong #887 214 214 * Fix default category not created for secondary languages (introduced in 3.1) #997 215 215 * Fix parent page when the parent post type is not translatable #1001 … … 229 229 * Fix empty search not handled correctly. Props Dominik Schilling #937 230 230 * Fix warning occurring when a 3rd party plugin attempts to register anything else than a string using the WPML API #942 231 * Fix Yoast SEO columns not cor ectly drawn when quick editing a post #943231 * Fix Yoast SEO columns not correctly drawn when quick editing a post #943 232 232 233 233 = 3.1.2 (2021-10-11) = … … 235 235 * Pro: Fix parent page not filtered by language in the block editor since WP 5.6 236 236 * Pro: Fix XLIFF mime type for PHP 7.0 and PHP 7.1 237 * Fix settings page displaying the media modules wh neno language are defined237 * Fix settings page displaying the media modules when no language are defined 238 238 * Enforce Yoast SEO to use dynamic permalinks #882 239 239 * Yoast SEO: Fix static front page and blog page breadcrumb … … 256 256 * Add a warning section to the site health for posts and terms without languages #825 257 257 * Require the simplexml extension in the site health if a wpml-config.xml is found #827 258 * Remove the information about the WPML compa bitility mode in settings #843258 * Remove the information about the WPML compatibility mode in settings #843 259 259 * The browser preferred language detection is now deactivated by default 260 260 * The media are now untranslated by default … … 328 328 * Improve browser language detection #591 329 329 * Improve robustness and documentation of code 330 * Fix media library after the language has been ch naged in the editor metabox330 * Fix media library after the language has been changed in the editor metabox 331 331 * Fix duplicated title attribute on flag link in posts list 332 332 * Fix legacy block editor language metabox compatibility with WordPress 5.6 … … 406 406 * Pro: Fix fatal error with WP 4.9 407 407 * Fix pll_the_languages() with 'raw' option returning html flag instead of flag url #558 408 * Fix compatibility with Duplicate Posts not correc ly loaded #557408 * Fix compatibility with Duplicate Posts not correctly loaded #557 409 409 * Fix custom flag size in admin bar language switcher #559 410 410 * Fix tag clouds mixed in the classic editor #561 … … 495 495 * Allow to translate the Twenty Seventeen header video Youtube url #460 496 496 * Notices are now dismissed per site instead of per user #478 497 * Fix terms not visible in the quick edit when only one language is defined and t ehadmin language filter is active497 * Fix terms not visible in the quick edit when only one language is defined and the admin language filter is active 498 498 * Fix post state not displayed for translations of the privacy policy page #395 499 499 * Fix wildcards not correctly interpreted in wpml-config.xml … … 588 588 * Pro: Fix PHP warning with ACF Pro 5.8.1 589 589 * Pro: Fix ACF clone fields not translated in repeaters 590 * Better management of user capab lities when synchronizing taxonomies terms and custom fields590 * Better management of user capabilities when synchronizing taxonomies terms and custom fields 591 591 * Extend string translations search to translated strings #207 592 592 * Update plugin updater to 1.6.18 … … 1018 1018 * Pro: Fix shared term slugs broken by a late change in WP 4.7 #73 1019 1019 * Pro: Fix media taxonomies lost when creating a media translation when taxonomies sync is activated #72 1020 * Fix fatal error in customizer when Twenty Sevente n is activated and another theme is previewed #711020 * Fix fatal error in customizer when Twenty Seventeen is activated and another theme is previewed #71 1021 1021 * Fix wrong plugin language on admin if user locale is different from site locale in WP 4.7 1022 1022 -
polylang/trunk/frontend/canonical.php
r2802032 r3042028 247 247 */ 248 248 protected function redirect_canonical( $url, $language ) { 249 /** 250 * @var WP_Query 251 */ 249 252 global $wp_query; 250 253 -
polylang/trunk/frontend/frontend-filters-links.php
r2974283 r3042028 19 19 * Our internal non persistent cache object 20 20 * 21 * @var PLL_Cache 21 * @var PLL_Cache<string> 22 22 */ 23 23 public $cache; -
polylang/trunk/frontend/frontend-filters-widgets.php
r2974283 r3042028 13 13 * Internal non persistent cache object. 14 14 * 15 * @var PLL_Cache 15 * @var PLL_Cache<array> 16 16 */ 17 17 public $cache; … … 55 55 } 56 56 57 $cache_key = md5( maybe_serialize( $sidebars_widgets ));58 $_sidebars_widgets = $this->cache->get( "sidebars_widgets_{$cache_key}");57 $cache_key = $this->cache->get_unique_key( 'sidebars_widgets_', $sidebars_widgets ); 58 $_sidebars_widgets = $this->cache->get( $cache_key ); 59 59 60 60 if ( false !== $_sidebars_widgets ) { … … 64 64 $sidebars_widgets = $this->filter_widgets_sidebars( $sidebars_widgets, $wp_registered_widgets ); 65 65 66 $this->cache->set( "sidebars_widgets_{$cache_key}", $sidebars_widgets ); 67 68 return $sidebars_widgets; 66 return $this->cache->set( $cache_key, $sidebars_widgets ); 69 67 } 70 68 -
polylang/trunk/frontend/frontend-links.php
r2974283 r3042028 14 14 * Internal non persistent cache object. 15 15 * 16 * @var PLL_Cache 16 * @var PLL_Cache<string> 17 17 */ 18 18 public $cache; … … 30 30 $this->curlang = &$polylang->curlang; 31 31 $this->cache = new PLL_Cache(); 32 33 32 } 34 33 … … 90 89 if ( $term_id && $term_id = $this->model->term->get_translation( $term_id, $language ) ) { // Get the translated term_id 91 90 $term = get_term( $term_id, $tax->name ); 91 92 if ( ! $term instanceof WP_Term ) { 93 continue; 94 } 95 92 96 $url = str_replace( $slug, $term->slug, $url ); 93 97 } … … 108 112 109 113 elseif ( $tr_id = $this->model->term->get_translation( $term->term_id, $language ) ) { 110 if ( $tr_term = get_term( $tr_id, $term->taxonomy ) ) { 114 $tr_term = get_term( $tr_id, $term->taxonomy ); 115 if ( $tr_term instanceof WP_Term ) { 111 116 // Check if translated term ( or children ) have posts 112 117 $count = $tr_term->count || ( is_taxonomy_hierarchical( $term->taxonomy ) && array_sum( wp_list_pluck( get_terms( array( 'taxonomy' => $term->taxonomy, 'child_of' => $tr_term->term_id, 'lang' => $language->slug ) ), 'count' ) ) ); … … 171 176 * @param string $language The language code of the translation 172 177 */ 173 $translation_url = apply_filters( 'pll_translation_url', $url, $language->slug );178 $translation_url = (string) apply_filters( 'pll_translation_url', $url, $language->slug ); 174 179 175 180 // Don't cache before template_redirect to avoid a conflict with Barrel + WP Bakery Page Builder -
polylang/trunk/frontend/frontend-nav-menu.php
r3008143 r3042028 125 125 $item->menu_order += $offset; 126 126 $new_items[] = $item; 127 $offset++;127 ++$offset; 128 128 } 129 129 130 130 $i = 0; // for incrementation of menu order only in case of dropdown 131 131 foreach ( $the_languages as $lang ) { 132 $i++;132 ++$i; 133 133 $lang_item = clone $item; 134 134 $lang_item->ID = $lang_item->ID . '-' . $lang['slug']; // A unique ID … … 146 146 } 147 147 $new_items[] = $lang_item; 148 $offset++;149 } 150 $offset--;148 ++$offset; 149 } 150 --$offset; 151 151 } else { 152 152 $item->menu_order += $offset; -
polylang/trunk/frontend/frontend-static-pages.php
r2974283 r3042028 227 227 */ 228 228 public function page_for_posts_query( $lang, $query ) { 229 if ( empty( $lang ) && $this->page_for_posts ) { 230 $page_id = $this->get_page_id( $query ); 231 232 if ( ! empty( $page_id ) && in_array( $page_id, $pages = $this->model->get_languages_list( array( 'fields' => 'page_for_posts' ) ) ) ) { 233 // Fill the cache with all pages for posts to avoid one query per page later 234 // The posts_per_page limit is a trick to avoid splitting the query 235 get_posts( array( 'posts_per_page' => 99, 'post_type' => 'page', 'post__in' => $pages, 'lang' => '' ) ); 236 237 $lang = $this->model->post->get_language( $page_id ); 238 $query->is_singular = $query->is_page = false; 239 $query->is_home = $query->is_posts_page = true; 240 } 241 } 229 if ( ! empty( $lang ) || ! $this->page_for_posts ) { 230 return $lang; 231 } 232 233 $page_id = $this->get_page_id( $query ); 234 235 if ( empty( $page_id ) ) { 236 return $lang; 237 } 238 239 $pages = $this->model->get_languages_list( array( 'fields' => 'page_for_posts' ) ); 240 $pages = array_filter( $pages ); 241 242 if ( in_array( $page_id, $pages ) ) { 243 _prime_post_caches( $pages ); // Fill the cache with all pages for posts to avoid one query per page later. 244 245 $lang = $this->model->post->get_language( $page_id ); 246 $query->is_singular = $query->is_page = false; 247 $query->is_home = $query->is_posts_page = true; 248 } 249 242 250 return $lang; 243 251 } -
polylang/trunk/include/base.php
r3008143 r3042028 163 163 * @return bool 164 164 */ 165 protected function is_active_on_current_site() : bool {165 protected function is_active_on_current_site(): bool { 166 166 return pll_is_plugin_active( POLYLANG_BASENAME ) && get_option( 'polylang' ); 167 167 } … … 206 206 $floor = 0; 207 207 if ( ! empty( $this->nav_menu ) && (bool) $wp_filter['customize_register']->has_filter( 'customize_register', array( $this->nav_menu, 'create_nav_menu_locations' ) ) ) { 208 $floor++;208 ++$floor; 209 209 } 210 210 211 211 if ( ! empty( $this->static_pages ) && (bool) $wp_filter['customize_register']->has_filter( 'customize_register', array( $this->static_pages, 'filter_customizer' ) ) ) { 212 $floor++;212 ++$floor; 213 213 } 214 214 -
polylang/trunk/include/cache.php
r2974283 r3042028 8 8 * 9 9 * @since 1.7 10 * 11 * @template TCacheData 10 12 */ 11 13 class PLL_Cache { … … 21 23 * 22 24 * @var array 25 * 26 * @phpstan-var array<int, array<non-empty-string, TCacheData>> 23 27 */ 24 28 protected $cache = array(); … … 47 51 48 52 /** 49 * Add a value in cache.53 * Adds a value in cache. 50 54 * 51 55 * @since 1.7 56 * @since 3.6 Returns the cached value. 52 57 * 53 58 * @param string $key Cache key. 54 59 * @param mixed $data The value to add to the cache. 55 * @return void 60 * @return mixed 61 * 62 * @phpstan-param non-empty-string $key 63 * @phpstan-param TCacheData $data 64 * @phpstan-return TCacheData 56 65 */ 57 66 public function set( $key, $data ) { 58 $this->cache[ $this->blog_id ][ $key ] = $data; 67 if ( ! doing_action( 'switch_blog' ) ) { 68 $this->cache[ $this->blog_id ][ $key ] = $data; 69 } 70 return $data; 59 71 } 60 72 61 73 /** 62 * Getvalue from cache.74 * Returns value from cache. 63 75 * 64 76 * @since 1.7 … … 66 78 * @param string $key Cache key. 67 79 * @return mixed 80 * 81 * @phpstan-param non-empty-string $key 82 * @phpstan-return TCacheData|false 68 83 */ 69 84 public function get( $key ) { … … 72 87 73 88 /** 74 * Clean the cache (for this blog only).89 * Cleans the cache (for this blog only). 75 90 * 76 91 * @since 1.7 77 92 * 78 * @param string $key Cache key. 93 * @param string $key Optional. Cache key. An empty string to clean the whole cache for the current blog. 94 * Default is an empty string. 79 95 * @return void 80 96 */ 81 97 public function clean( $key = '' ) { 82 if ( empty( $key )) {98 if ( '' === $key ) { 83 99 unset( $this->cache[ $this->blog_id ] ); 84 100 } else { … … 86 102 } 87 103 } 104 105 /** 106 * Generates and returns a "unique" cache key, depending on `$data` and prefixed by `$prefix`. 107 * 108 * @since 3.6 109 * 110 * @param string $prefix String to prefix the cache key. 111 * @param string|array|object $data Data. 112 * @return string 113 * 114 * @phpstan-param non-empty-string $prefix 115 * @phpstan-return non-empty-string 116 */ 117 public function get_unique_key( string $prefix, $data ): string { 118 /** @var scalar */ 119 $serialized = maybe_serialize( $data ); 120 return $prefix . md5( (string) $serialized ); 121 } 88 122 } -
polylang/trunk/include/class-polylang.php
r2974283 r3042028 6 6 if ( ! defined( 'ABSPATH' ) ) { 7 7 exit; // Don't access directly 8 } ;8 } 9 9 10 10 // Default directory to store user data such as custom flags … … 22 22 * 23 23 * @since 0.1 24 * 25 * @template TPLLClass of PLL_Base 24 26 */ 25 27 class Polylang { … … 163 165 */ 164 166 public function init() { 165 global $polylang;166 167 167 self::define_constants(); 168 168 $options = get_option( 'polylang' ); … … 225 225 226 226 if ( ! empty( $class ) ) { 227 $links_model = $model->get_links_model(); 228 $polylang = new $class( $links_model ); 229 230 /** 231 * Fires after Polylang's model init. 232 * This is the best place to register a custom table (see `PLL_Model`'s constructor). 233 * /!\ This hook is fired *before* the $polylang object is available. 234 * /!\ The languages are also not available yet. 235 * 236 * @since 3.4 237 * 238 * @param PLL_Model $model Polylang model. 239 */ 240 do_action( 'pll_model_init', $model ); 241 242 $model->maybe_create_language_terms(); 243 244 /** 245 * Fires after the $polylang object is created and before the API is loaded 246 * 247 * @since 2.0 248 * 249 * @param object $polylang 250 */ 251 do_action_ref_array( 'pll_pre_init', array( &$polylang ) ); 252 253 require_once __DIR__ . '/api.php'; // Loads the API 254 255 // Loads the modules. 256 $load_scripts = glob( POLYLANG_DIR . '/modules/*/load.php', GLOB_NOSORT ); 257 if ( is_array( $load_scripts ) ) { 258 foreach ( $load_scripts as $load_script ) { 259 require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable 260 } 227 /** @phpstan-var class-string<TPLLClass> $class */ 228 $this->init_context( $class, $model ); 229 } 230 } 231 232 /** 233 * Polylang initialization. 234 * Setups the Polylang Context, loads the modules and init Polylang. 235 * 236 * @since 3.6 237 * 238 * @param string $class The class name. 239 * @param PLL_Model $model Instance of PLL_Model. 240 * @return PLL_Base 241 * 242 * @phpstan-param class-string<TPLLClass> $class 243 * @phpstan-return TPLLClass 244 */ 245 public function init_context( string $class, PLL_Model $model ): PLL_Base { 246 global $polylang; 247 248 $links_model = $model->get_links_model(); 249 $polylang = new $class( $links_model ); 250 251 /** 252 * Fires after Polylang's model init. 253 * This is the best place to register a custom table (see `PLL_Model`'s constructor). 254 * /!\ This hook is fired *before* the $polylang object is available. 255 * /!\ The languages are also not available yet. 256 * 257 * @since 3.4 258 * 259 * @param PLL_Model $model Polylang model. 260 */ 261 do_action( 'pll_model_init', $model ); 262 263 $model->maybe_create_language_terms(); 264 265 /** 266 * Fires after the $polylang object is created and before the API is loaded 267 * 268 * @since 2.0 269 * 270 * @param object $polylang 271 */ 272 do_action_ref_array( 'pll_pre_init', array( &$polylang ) ); 273 274 // Loads the API 275 require_once POLYLANG_DIR . '/include/api.php'; 276 277 // Loads the modules. 278 $load_scripts = glob( POLYLANG_DIR . '/modules/*/load.php', GLOB_NOSORT ); 279 if ( is_array( $load_scripts ) ) { 280 foreach ( $load_scripts as $load_script ) { 281 require_once $load_script; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable 261 282 } 262 263 $polylang->init(); 264 265 /** 266 * Fires after the $polylang object and the API is loaded 267 * 268 * @since 1.7 269 * 270 * @param object $polylang 271 */ 272 do_action_ref_array( 'pll_init', array( &$polylang ) ); 273 } 274 } 275 } 283 } 284 285 $polylang->init(); 286 287 /** 288 * Fires after the $polylang object and the API is loaded 289 * 290 * @since 1.7 291 * 292 * @param object $polylang 293 */ 294 do_action_ref_array( 'pll_init', array( &$polylang ) ); 295 296 return $polylang; 297 } 298 } -
polylang/trunk/include/crud-posts.php
r3032046 r3042028 228 228 /** 229 229 * Called when a post, page or media is deleted 230 * Don't delete translations if this is a post revision thanks to AndyDeGroo who ca tchedthis bug230 * Don't delete translations if this is a post revision thanks to AndyDeGroo who caught this bug 231 231 * http://wordpress.org/support/topic/plugin-polylang-quick-edit-still-breaks-translation-linking-of-pages-in-072 232 232 * -
polylang/trunk/include/filters-links.php
r2974283 r3042028 201 201 } 202 202 } 203 -
polylang/trunk/include/filters-widgets-options.php
r2974283 r3042028 49 49 $dropdown_html = $dropdown->walk( 50 50 array_merge( 51 array( (object) array( 'slug' => 0, 'name' => __( 'All languages', 'polylang' )) ),51 array( (object) array( 'slug' => 0, 'name' => __( 'All languages', 'polylang' ) ) ), 52 52 $this->model->get_languages_list() 53 53 ), … … 90 90 return $instance; 91 91 } 92 93 92 } -
polylang/trunk/include/language.php
r3008143 r3042028 232 232 * @var array[] Array keys are language term names. 233 233 * 234 * @ex emple array(234 * @example array( 235 235 * 'language' => array( 236 236 * 'term_id' => 7, … … 352 352 353 353 /** 354 * Returns the flag information s.354 * Returns the flag information. 355 355 * 356 356 * @since 2.6 … … 358 358 * @param string $code Flag code. 359 359 * @return array { 360 * Flag information s.360 * Flag information. 361 361 * 362 362 * @type string $url Flag url. … … 392 392 393 393 /** 394 * Filters flag information s:394 * Filters flag information: 395 395 * 396 396 * @since 2.4 -
polylang/trunk/include/license.php
r2974283 r3042028 85 85 $this->api_url = empty( $api_url ) ? $this->api_url : $api_url; 86 86 87 $licenses = get_option( 'polylang_licenses' ); 88 $this->license_key = empty( $licenses[ $this->id ]['key'] ) ? '' : $licenses[ $this->id ]['key']; 89 if ( ! empty( $licenses[ $this->id ]['data'] ) ) { 90 $this->license_data = $licenses[ $this->id ]['data']; 87 $licenses = (array) get_option( 'polylang_licenses', array() ); 88 $license = isset( $licenses[ $this->id ] ) && is_array( $licenses[ $this->id ] ) ? $licenses[ $this->id ] : array(); 89 $this->license_key = ! empty( $license['key'] ) ? (string) $license['key'] : ''; 90 91 if ( ! empty( $license['data'] ) ) { 92 $this->license_data = (object) $license['data']; 91 93 } 92 94 … … 223 225 // Save new license info 224 226 $licenses[ $this->id ] = array( 'key' => $this->license_key ); 225 $data = json_decode( wp_remote_retrieve_body( $response ) );226 227 if ( 'deactivated' !== $data->license ) {227 $data = (object) json_decode( wp_remote_retrieve_body( $response ) ); 228 229 if ( isset( $data->license ) && 'deactivated' !== $data->license ) { 228 230 $licenses[ $this->id ]['data'] = $this->license_data = $data; 229 231 } -
polylang/trunk/include/links-domain.php
r2907847 r3042028 106 106 107 107 // The function idn_to_ascii() is much faster than the WordPress method. 108 if ( function_exists( 'idn_to_ascii' ) ) { 109 // The use of the constant is mandatory in PHP 7.2 and PHP 7.3 to avoid a deprecated notice. 110 $hosts[ $lang ] = defined( 'INTL_IDNA_VARIANT_UTS46' ) ? idn_to_ascii( $host, 0, INTL_IDNA_VARIANT_UTS46 ) : idn_to_ascii( $host ); 108 if ( function_exists( 'idn_to_ascii' ) && defined( 'INTL_IDNA_VARIANT_UTS46' ) ) { 109 $hosts[ $lang ] = idn_to_ascii( $host, 0, INTL_IDNA_VARIANT_UTS46 ); 111 110 } elseif ( class_exists( 'WpOrg\Requests\IdnaEncoder' ) ) { 112 111 // Since WP 6.2. -
polylang/trunk/include/model.php
r2974283 r3042028 13 13 * Internal non persistent cache object. 14 14 * 15 * @var PLL_Cache 15 * @var PLL_Cache<mixed> 16 16 */ 17 17 public $cache; … … 187 187 $languages = array_filter( 188 188 $languages, 189 function ( $lang ) use ( $args ) {189 function ( $lang ) use ( $args ) { 190 190 $keep_empty = empty( $args['hide_empty'] ) || $lang->get_tax_prop( 'language', 'count' ); 191 191 $keep_default = empty( $args['hide_default'] ) || ! $lang->is_default; 192 192 return $keep_empty && $keep_default; 193 194 193 } 195 194 ); … … 587 586 } 588 587 589 $cache_key = 'pll_count_posts_' . md5( maybe_serialize( $q ));590 $counts = wp_cache_get( $cache_key, 'counts' );588 $cache_key = $this->cache->get_unique_key( 'pll_count_posts_', $q ); 589 $counts = wp_cache_get( $cache_key, 'counts' ); 591 590 592 591 if ( ! is_array( $counts ) ) { … … 811 810 * Keep track of types where we set the language: 812 811 * those are types where we may have more items to process if we have more than 1000 items in total. 813 * This will prevent un ecessary SQL queries in the next recursion: if we have 0 items in this recursion for812 * This will prevent unnecessary SQL queries in the next recursion: if we have 0 items in this recursion for 814 813 * a type, we'll still have 0 in the next one, no need for a new query. 815 814 */ … … 918 917 * @param PLL_Language|null $language Optional. A language object. Required to update the existing terms. 919 918 * @param string[] $taxonomies Optional. List of language taxonomies to deal with. An empty value means 920 * all of them. Defaul s to all taxonomies.919 * all of them. Defaults to all taxonomies. 921 920 * @return void 922 921 * -
polylang/trunk/include/rest-request.php
r2907847 r3042028 5 5 6 6 /** 7 * Main Polylang class for REST API requ rests, accessible from @see PLL().7 * Main Polylang class for REST API requests, accessible from @see PLL(). 8 8 * 9 9 * @since 2.6 -
polylang/trunk/include/translatable-object.php
r2925389 r3042028 370 370 /** 371 371 * Returns object IDs without language given a specific SQL query. 372 * Can be overrid en by child classes in case queried object doesn't use372 * Can be overridden by child classes in case queried object doesn't use 373 373 * `wp_cache_set_last_changed()` or another cache system. 374 374 * … … 501 501 502 502 /** 503 * Returns database-related information sthat can be used in some of this class methods.503 * Returns database-related information that can be used in some of this class methods. 504 504 * These are specific to the table containing the objects. 505 505 * -
polylang/trunk/include/translate-option.php
r2974283 r3042028 41 41 * Cache for the translated values. 42 42 * 43 * @var PLL_Cache 43 * @var PLL_Cache<array|string> 44 44 */ 45 45 private $cache; … … 111 111 $lang = $GLOBALS['l10n']['pll_string']->get_header( 'Language' ); 112 112 113 if ( ! is_string( $lang ) || '' === $lang ) { 114 return $value; 115 } 116 113 117 $cache = $this->cache->get( $lang ); 114 118 if ( false === $cache ) { -
polylang/trunk/include/translated-post.php
r2925389 r3042028 14 14 */ 15 15 class PLL_Translated_Post extends PLL_Translated_Object implements PLL_Translatable_Object_With_Types_Interface { 16 17 16 use PLL_Translatable_Object_With_Types_Trait; 18 17 … … 146 145 * @param bool $is_settings True when displaying the list of custom post types in Polylang settings. 147 146 */ 148 $post_types = apply_filters( 'pll_get_post_types', $post_types, false );147 $post_types = (array) apply_filters( 'pll_get_post_types', $post_types, false ); 149 148 150 149 if ( did_action( 'after_setup_theme' ) ) { … … 376 375 377 376 /** 378 * Returns database-related information sthat can be used in some of this class methods.377 * Returns database-related information that can be used in some of this class methods. 379 378 * These are specific to the table containing the objects. 380 379 * -
polylang/trunk/include/translated-term.php
r2925389 r3042028 14 14 */ 15 15 class PLL_Translated_Term extends PLL_Translated_Object implements PLL_Translatable_Object_With_Types_Interface { 16 17 16 use PLL_Translatable_Object_With_Types_Trait; 18 17 … … 214 213 * @param bool $is_settings True when displaying the list of custom taxonomies in Polylang settings. 215 214 */ 216 $taxonomies = apply_filters( 'pll_get_taxonomies', $taxonomies, false );215 $taxonomies = (array) apply_filters( 'pll_get_taxonomies', $taxonomies, false ); 217 216 218 217 if ( did_action( 'after_setup_theme' ) ) { … … 316 315 317 316 /** 318 * Returns database-related information sthat can be used in some of this class methods.317 * Returns database-related information that can be used in some of this class methods. 319 318 * These are specific to the table containing the objects. 320 319 * -
polylang/trunk/install/install-base.php
r2974283 r3042028 5 5 6 6 /** 7 * A generic activation / de-activation class compat ble with multisite7 * A generic activation / de-activation class compatible with multisite 8 8 * 9 9 * @since 1.7 … … 40 40 * @since 1.7 41 41 * 42 * @return bool true if the plugin is currently be eing deactivated42 * @return bool true if the plugin is currently being deactivated 43 43 */ 44 44 public function is_deactivation() { … … 93 93 */ 94 94 protected function _activate() { 95 // Can be overrid en in child class95 // Can be overridden in child class 96 96 } 97 97 … … 116 116 */ 117 117 protected function _deactivate() { 118 // Can be overrid en in child class118 // Can be overridden in child class 119 119 } 120 120 -
polylang/trunk/install/plugin-updater.php
r2699056 r3042028 396 396 397 397 /** 398 * Calls the API and, if successful l, returns the object delivered by the API.398 * Calls the API and, if successful, returns the object delivered by the API. 399 399 * 400 400 * @uses get_bloginfo() -
polylang/trunk/integrations/aqua-resizer/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 PLL_Integrations::instance()->aq_resizer = new PLL_Aqua_Resizer(); -
polylang/trunk/integrations/cache/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( pll_is_cache_active() ) { 16 16 add_action( 'pll_init', array( PLL_Integrations::instance()->cache_compat = new PLL_Cache_Compat(), 'init' ) ); … … 19 19 0 20 20 ); 21 -
polylang/trunk/integrations/custom-field-template/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( class_exists( 'custom_field_template' ) ) { 16 16 PLL_Integrations::instance()->cft = new PLL_Cft(); -
polylang/trunk/integrations/domain-mapping/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 PLL_Integrations::instance()->dm = new PLL_Domain_Mapping(); -
polylang/trunk/integrations/duplicate-post/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( defined( 'DUPLICATE_POST_CURRENT_VERSION' ) ) { 16 16 PLL_Integrations::instance()->duplicate_post = new PLL_Duplicate_Post(); -
polylang/trunk/integrations/jetpack/load.php
r2340428 r3042028 9 9 if ( ! defined( 'ABSPATH' ) ) { 10 10 exit; // Don't access directly. 11 } ;11 } 12 12 13 13 PLL_Integrations::instance()->jetpack = new PLL_Jetpack(); // Must be loaded before the plugin is active. -
polylang/trunk/integrations/no-category-base/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 PLL_Integrations::instance()->no_category_base = new PLL_No_Category_Base(); -
polylang/trunk/integrations/twenty-seventeen/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 'init', array( PLL_Integrations::instance()->twenty_seventeen = new PLL_Twenty_Seventeen(), 'init' ) ); -
polylang/trunk/integrations/wp-importer/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 PLL_Integrations::instance()->wp_importer = new PLL_WordPress_Importer(); -
polylang/trunk/integrations/wp-importer/wordpress-importer.php
r2340428 r3042028 43 43 44 44 $GLOBALS['wp_import'] = new PLL_WP_Import(); 45 register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'polylang' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); // phpcs:ignore WordPress.WP.CapitalPDangit.Misspelled 45 register_importer( 'wordpress', 'WordPress', __( 'Import <strong>posts, pages, comments, custom fields, categories, and tags</strong> from a WordPress export file.', 'polylang' ), array( $GLOBALS['wp_import'], 'dispatch' ) ); // phpcs:ignore WordPress.WP.CapitalPDangit.MisspelledInText 46 46 } 47 47 -
polylang/trunk/integrations/wp-offload-media/as3cf.php
r2802032 r3042028 57 57 * Deletes the WP Offload Media information from the attachment being deleted. 58 58 * That way WP Offload Media won't delete the file stored in the cloud. 59 * Done after Polylang has deleted the translations information s, to avoid the synchronization of the deletion59 * Done after Polylang has deleted the translations information, to avoid the synchronization of the deletion 60 60 * and of course before WP Offload Media deletes the file, normally at priority 20. 61 61 * -
polylang/trunk/integrations/wp-offload-media/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( function_exists( 'as3cf_init' ) && class_exists( 'PLL_AS3CF' ) ) { 16 16 add_action( 'pll_init', array( PLL_Integrations::instance()->as3cf = new PLL_AS3CF(), 'init' ) ); … … 19 19 0 20 20 ); 21 -
polylang/trunk/integrations/wp-sweep/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( defined( 'WP_SWEEP_VERSION' ) ) { 16 16 PLL_Integrations::instance()->wp_sweep = new PLL_WP_Sweep(); -
polylang/trunk/integrations/wpseo/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( defined( 'WPSEO_VERSION' ) ) { 16 16 add_action( 'pll_init', array( PLL_Integrations::instance()->wpseo = new PLL_WPSEO(), 'init' ) ); … … 19 19 0 20 20 ); 21 -
polylang/trunk/integrations/wpseo/wpseo-ogp.php
r2340428 r3042028 53 53 } 54 54 } 55 -
polylang/trunk/integrations/wpseo/wpseo.php
r2974283 r3042028 201 201 202 202 /** 203 * Add filters before the sitemap is evaluated and output ed.203 * Add filters before the sitemap is evaluated and outputted. 204 204 * 205 205 * @since 2.6 … … 423 423 * @param string[] $keys List of custom fields names. 424 424 * @param bool $sync True if it is synchronization, false if it is a copy. 425 * @param int $from Id of the post from which we copy information s.426 * @param int $to Id of the post to which we paste information s.425 * @param int $from Id of the post from which we copy information. 426 * @param int $to Id of the post to which we paste information. 427 427 * @return array 428 428 */ -
polylang/trunk/integrations/yarpp/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 add_action( 13 13 'plugins_loaded', 14 function () {14 function () { 15 15 if ( defined( 'YARPP_VERSION' ) ) { 16 16 add_action( 'init', array( PLL_Integrations::instance()->yarpp = new PLL_Yarpp(), 'init' ) ); -
polylang/trunk/modules/share-slug/load.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 if ( $polylang->model->has_languages() ) { 13 13 add_filter( 14 14 'pll_settings_modules', 15 function ( $modules ) {15 function ( $modules ) { 16 16 $modules[] = 'PLL_Settings_Preview_Share_Slug'; 17 17 return $modules; -
polylang/trunk/modules/share-slug/settings-preview-share-slug.php
r2557081 r3042028 23 23 * @since 1.9 24 24 * 25 * @param object $polylang Polylang object. 25 * @param PLL_Settings $polylang Polylang object. 26 * @param array $args Optional. Addition arguments. 27 * 28 * @phpstan-param array{ 29 * module?: non-falsy-string, 30 * title?: string, 31 * description?: string, 32 * active_option?: non-falsy-string 33 * } $args 26 34 */ 27 public function __construct( &$polylang ) { 28 parent::__construct( 29 $polylang, 30 array( 31 'module' => 'share-slugs', 32 'title' => __( 'Share slugs', 'polylang' ), 33 'description' => $this->get_description(), 34 ) 35 public function __construct( &$polylang, array $args = array() ) { 36 $default = array( 37 'module' => 'share-slugs', 38 'title' => __( 'Share slugs', 'polylang' ), 39 'description' => $this->get_description(), 40 'active_option' => 'preview', 35 41 ); 42 43 parent::__construct( $polylang, array_merge( $default, $args ) ); 36 44 } 37 45 … … 46 54 return __( 'Allows to share the same URL slug across languages for posts and terms.', 'polylang' ); 47 55 } 48 49 /**50 * Tells if the module is active.51 *52 * @since 1.953 *54 * @return bool55 */56 public function is_active() {57 return false;58 }59 60 /**61 * Displays an upgrade message.62 *63 * @since 1.964 *65 * @return string66 */67 public function get_upgrade_message() {68 return $this->default_upgrade_message();69 }70 56 } -
polylang/trunk/modules/site-health/admin-site-health.php
r2974283 r3042028 49 49 add_filter( 'site_status_tests', array( $this, 'status_tests' ) ); 50 50 add_filter( 'site_status_test_php_modules', array( $this, 'site_status_test_php_modules' ) ); // Require simplexml in Site health. 51 52 51 } 53 52 … … 183 182 184 183 /** 185 * Add Polylang Options to Site Health Information stab.184 * Add Polylang Options to Site Health Information tab. 186 185 * 187 186 * @since 2.8 … … 399 398 400 399 /** 401 * Add Polylang Warnings to Site Health Information stab.400 * Add Polylang Warnings to Site Health Information tab. 402 401 * 403 402 * @since 3.1 -
polylang/trunk/modules/site-health/load.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 if ( $polylang instanceof PLL_Admin && $polylang->model->has_languages() ) { -
polylang/trunk/modules/sitemaps/load.php
r2907847 r3042028 6 6 if ( ! defined( 'ABSPATH' ) ) { 7 7 exit; // Don't access directly. 8 } ;8 } 9 9 10 10 if ( $polylang->model->has_languages() ) { -
polylang/trunk/modules/sitemaps/multilingual-sitemaps-provider.php
r2475716 r3042028 110 110 * 111 111 * @param string $object_subtype_name Object subtype name if any. 112 * @param string $lang Option nal language name.112 * @param string $lang Optional language name. 113 113 * @return array 114 114 */ -
polylang/trunk/modules/sync/admin-sync.php
r2974283 r3042028 48 48 49 49 /** 50 * Copy menu order, comment, ping status and optionally the date when creating a new t anslation50 * Copy menu order, comment, ping status and optionally the date when creating a new translation 51 51 * 52 52 * @since 2.5 … … 128 128 $postarr = parent::get_fields_to_sync( $post ); 129 129 130 // For new drafts, save the date now otherwise it is overrid en by WP. Thanks to JoryHogeveen. See #32.130 // For new drafts, save the date now otherwise it is overridden by WP. Thanks to JoryHogeveen. See #32. 131 131 if ( in_array( 'post_date', $this->options['sync'] ) && isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) { 132 132 check_admin_referer( 'new-post-translation' ); -
polylang/trunk/modules/sync/load.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 if ( $polylang->model->has_languages() ) { … … 19 19 add_filter( 20 20 'pll_settings_modules', 21 function ( $modules ) {21 function ( $modules ) { 22 22 $modules[] = 'PLL_Settings_Sync'; 23 23 return $modules; -
polylang/trunk/modules/sync/sync-metas.php
r2974283 r3042028 143 143 * @since 2.3 144 144 * 145 * @param int $from Id of the post from which we copy information s.146 * @param int $to Id of the post to which we paste information s.145 * @param int $from Id of the post from which we copy information. 146 * @param int $to Id of the post to which we paste information. 147 147 * @param string $lang Language slug. 148 148 * @param bool $sync True if it is synchronization, false if it is a copy. … … 158 158 * @param string[] $keys List of custom fields names. 159 159 * @param bool $sync True if it is synchronization, false if it is a copy. 160 * @param int $from Id of the post from which we copy information s.161 * @param int $to Id of the post to which we paste information s.160 * @param int $from Id of the post from which we copy information. 161 * @param int $to Id of the post to which we paste information. 162 162 * @param string $lang Language slug. 163 163 */ … … 350 350 $this->remove_all_meta_actions(); 351 351 352 $to_copy = $this->get_metas_to_copy( $from, $to, $lang, $sync ); 353 $metas = get_metadata( $this->meta_type, $from ); 352 $to_copy = $this->get_metas_to_copy( $from, $to, $lang, $sync ); 353 $metas = get_metadata( $this->meta_type, $from ); 354 $metas = is_array( $metas ) ? $metas : array(); 354 355 $tr_metas = get_metadata( $this->meta_type, $to ); 356 $tr_metas = is_array( $tr_metas ) ? $tr_metas : array(); 355 357 356 358 foreach ( $to_copy as $key ) { … … 360 362 delete_metadata( $this->meta_type, $to, wp_slash( $key ) ); 361 363 } 364 } elseif ( ! empty( $tr_metas[ $key ] ) && 1 === count( $metas[ $key ] ) && 1 === count( $tr_metas[ $key ] ) ) { 365 // One custom field to update 366 $value = reset( $metas[ $key ] ); 367 $value = maybe_unserialize( $value ); 368 $to_value = $this->maybe_translate_value( $value, $key, $from, $to, $lang ); 369 update_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) ); 362 370 } else { 363 if ( ! empty( $tr_metas[ $key ] ) && 1 === count( $metas[ $key ] ) && 1 === count( $tr_metas[ $key ] ) ) { 364 // One custom field to update 365 $value = reset( $metas[ $key ] ); 371 // Multiple custom fields, either in the source or the target 372 if ( ! empty( $tr_metas[ $key ] ) ) { 373 // The synchronization of multiple values custom fields is easier if we delete all metas first 374 delete_metadata( $this->meta_type, $to, wp_slash( $key ) ); 375 } 376 377 foreach ( $metas[ $key ] as $value ) { 366 378 $value = maybe_unserialize( $value ); 367 379 $to_value = $this->maybe_translate_value( $value, $key, $from, $to, $lang ); 368 update_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) ); 369 } else { 370 // Multiple custom fields, either in the source or the target 371 if ( ! empty( $tr_metas[ $key ] ) ) { 372 // The synchronization of multiple values custom fields is easier if we delete all metas first 373 delete_metadata( $this->meta_type, $to, wp_slash( $key ) ); 374 } 375 376 foreach ( $metas[ $key ] as $value ) { 377 $value = maybe_unserialize( $value ); 378 $to_value = $this->maybe_translate_value( $value, $key, $from, $to, $lang ); 379 add_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) ); 380 } 380 add_metadata( $this->meta_type, $to, wp_slash( $key ), is_object( $to_value ) ? $to_value : wp_slash( $to_value ) ); 381 381 } 382 382 } -
polylang/trunk/modules/sync/sync-post-metas.php
r2974283 r3042028 39 39 * @since 2.3 40 40 * 41 * @param int $from Id of the post from which we copy information s.42 * @param int $to Id of the post to which we paste information s.41 * @param int $from Id of the post from which we copy information. 42 * @param int $to Id of the post to which we paste information. 43 43 * @param string $lang Language slug. 44 44 * @param bool $sync True if it is synchronization, false if it is a copy. -
polylang/trunk/modules/sync/sync-tax.php
r2974283 r3042028 5 5 6 6 /** 7 * A class to manage the sy chronization of taxonomy terms across posts translations7 * A class to manage the synchronization of taxonomy terms across posts translations 8 8 * 9 9 * @since 2.3 … … 48 48 * 49 49 * @param bool $sync True if it is synchronization, false if it is a copy. 50 * @param int $from Id of the post from which we copy information s, optional, defaults to null.51 * @param int $to Id of the post to which we paste information s, optional, defaults to null.50 * @param int $from Id of the post from which we copy information, optional, defaults to null. 51 * @param int $to Id of the post to which we paste information, optional, defaults to null. 52 52 * @param string $lang Language slug, optional, defaults to null. 53 53 * @return string[] List of taxonomy names. … … 67 67 * @param string[] $taxonomies List of taxonomy names. 68 68 * @param bool $sync True if it is synchronization, false if it is a copy. 69 * @param int $from Id of the post from which we copy information s.70 * @param int $to Id of the post to which we paste information s.69 * @param int $from Id of the post from which we copy information. 70 * @param int $to Id of the post to which we paste information. 71 71 * @param string $lang Language slug. 72 72 */ … … 150 150 wp_set_object_terms( $tr_id, $newterms, $taxonomy, $append ); 151 151 } 152 153 152 } 154 153 … … 202 201 203 202 /** 204 * Copy terms fro none post to a translation, does not sync203 * Copy terms from one post to a translation, does not sync 205 204 * 206 205 * @since 2.3 -
polylang/trunk/modules/sync/sync.php
r2974283 r3042028 169 169 unset( $tr_arr['post_parent'] ); 170 170 171 // Do not u dpate the translation parent if the user set a parent with no translation.171 // Do not update the translation parent if the user set a parent with no translation. 172 172 if ( isset( $postarr['post_parent'] ) ) { 173 173 $post_parent = $postarr['post_parent'] ? $this->model->post->get_translation( $postarr['post_parent'], $lang ) : 0; -
polylang/trunk/modules/translate-slugs/load.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 if ( $polylang->model->has_languages() ) { 13 13 add_filter( 14 14 'pll_settings_modules', 15 function ( $modules ) {15 function ( $modules ) { 16 16 $modules[] = 'PLL_Settings_Preview_Translate_Slugs'; 17 17 return $modules; -
polylang/trunk/modules/translate-slugs/settings-preview-translate-slugs.php
r2557081 r3042028 23 23 * @since 1.9 24 24 * 25 * @param object $polylang Polylang object. 25 * @param PLL_Settings $polylang Polylang object. 26 * @param array $args Optional. Addition arguments. 27 * 28 * @phpstan-param array{ 29 * module?: non-falsy-string, 30 * title?: string, 31 * description?: string, 32 * active_option?: non-falsy-string 33 * } $args 26 34 */ 27 public function __construct( &$polylang ) { 28 parent::__construct( 29 $polylang, 30 array( 31 'module' => 'translate-slugs', 32 'title' => __( 'Translate slugs', 'polylang' ), 33 'description' => $this->get_description(), 34 ) 35 public function __construct( &$polylang, array $args = array() ) { 36 $default = array( 37 'module' => 'translate-slugs', 38 'title' => __( 'Translate slugs', 'polylang' ), 39 'description' => $this->get_description(), 40 'active_option' => 'preview', 35 41 ); 42 43 parent::__construct( $polylang, array_merge( $default, $args ) ); 36 44 } 37 45 … … 46 54 return __( 'Allows to translate custom post types and taxonomies slugs in URLs.', 'polylang' ); 47 55 } 48 49 /**50 * Tells if the module is active.51 *52 * @since 1.953 *54 * @return bool55 */56 public function is_active() {57 return false;58 }59 60 /**61 * Displays an upgrade message.62 *63 * @since 1.964 *65 * @return string66 */67 public function get_upgrade_message() {68 return $this->default_upgrade_message();69 }70 56 } -
polylang/trunk/modules/wizard/html-wizard-notice.php
r2340428 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $wizard_url = add_query_arg( -
polylang/trunk/modules/wizard/js/languages-step.js
r2544117 r3042028 4 4 5 5 jQuery( 6 function ( $ ) {6 function ( $ ) { 7 7 var addLanguageForm = $( '.languages-step' ); // Form element. 8 8 var languageFields = $( '#language-fields' ); // Element where to append hidden fields for creating language. … … 36 36 ) 37 37 ); 38 // see the comment and the har coded code above. languageTrashIconHtml and languageValueHtml are safe.38 // see the comment and the hardcoded code above. languageTrashIconHtml and languageValueHtml are safe. 39 39 var languageLineHtml = $( '<tr />' ).prepend( languageTrashIconHtml ).prepend( languageValueHtml ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.prepend 40 40 var languageFieldHtml = $( '<input />' ).attr( … … 56 56 'click', 57 57 'span[data-language=' + language.locale + ']', 58 function ( event ) {58 function ( event ) { 59 59 event.preventDefault(); 60 60 // Remove line in languages table. … … 85 85 function showError( message ) { 86 86 messagesContainer.empty(); 87 // html is har coded and use of jQuery text method which is safe to add message value.87 // html is hardcoded and use of jQuery text method which is safe to add message value. 88 88 // In addition message is i18n value which is initialized server side in PLL_Wizard::add_step_languages and correctly escaped. 89 89 messagesContainer.prepend( $( '<p/>' ).addClass( 'error' ).text( message ) ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.prepend … … 140 140 languagesList.on( 141 141 'selectmenuchange', 142 function () {142 function () { 143 143 hideError();; 144 144 } … … 149 149 $( '#add-language' ).on( 150 150 'click', 151 function ( event ) {151 function ( event ) { 152 152 hideError(); 153 153 var selectedOption = event.currentTarget.form.lang_list.options[event.currentTarget.form.lang_list.selectedIndex]; … … 183 183 addLanguageForm.on( 184 184 'submit', 185 function ( event ) {185 function ( event ) { 186 186 // Verify if there is at least one language. 187 187 var isLanguagesAlreadyDefined = definedLanguagesListTable.children().length > 0; … … 261 261 minWidth: 600, 262 262 maxWidth: '100%', 263 open: function ( event, ui ) {263 open: function ( event, ui ) { 264 264 // Change dialog box position for rtl language 265 265 if ( $( 'body' ).hasClass( 'rtl' ) ) { … … 280 280 { 281 281 text: pll_wizard_params.i18n_dialog_yes_button, 282 click: function ( event ) {282 click: function ( event ) { 283 283 confirmDialog( 'yes' ); 284 284 } … … 286 286 { 287 287 text: pll_wizard_params.i18n_dialog_no_button, 288 click: function ( event ) {288 click: function ( event ) { 289 289 confirmDialog( 'no' ); 290 290 } … … 292 292 { 293 293 text: pll_wizard_params.i18n_dialog_ignore_button, 294 click: function ( event ) {294 click: function ( event ) { 295 295 confirmDialog( 'ignore' ); 296 296 } -
polylang/trunk/modules/wizard/load.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 if ( $polylang instanceof PLL_Admin_Base ) { -
polylang/trunk/modules/wizard/view-wizard-page.php
r2974283 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 $admin_body_class = array( 'pll-wizard', 'wp-core-ui' ); 14 14 if ( is_rtl() ) { -
polylang/trunk/modules/wizard/view-wizard-step-home-page.php
r2907847 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $languages = $this->model->get_languages_list(); -
polylang/trunk/modules/wizard/view-wizard-step-languages.php
r2907847 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $existing_languages = $this->model->get_languages_list(); … … 83 83 esc_attr( $lg->locale ), 84 84 esc_html( $lg->name ), 85 $lg->flag, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped85 $lg->flag, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped 86 86 $lg->is_default ? ' <span class="icon-default-lang"><span class="screen-reader-text">' . esc_html__( 'Default language', 'polylang' ) . '</span></span>' : '' 87 87 ); -
polylang/trunk/modules/wizard/view-wizard-step-last.php
r2340428 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 ?> -
polylang/trunk/modules/wizard/view-wizard-step-licenses.php
r2340428 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $licenses = apply_filters( 'pll_settings_licenses', array() ); … … 26 26 </div> 27 27 <div class="form-field"> 28 <table id="pll-licenses-table" class="form-table ">28 <table id="pll-licenses-table" class="form-table pll-table-top"> 29 29 <tbody> 30 30 <?php -
polylang/trunk/modules/wizard/view-wizard-step-media.php
r2549758 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $default_options = PLL_Install::get_default_options(); -
polylang/trunk/modules/wizard/view-wizard-step-untranslated-contents.php
r2907847 r3042028 10 10 if ( ! defined( 'ABSPATH' ) ) { 11 11 exit; // Don't access directly. 12 } ;12 } 13 13 14 14 $languages_list = $this->model->get_languages_list(); -
polylang/trunk/modules/wizard/wizard.php
r2974283 r3042028 62 62 63 63 // Display Wizard page before any other action to ensure displaying it outside the WordPress admin context. 64 // Hooked on admin_init with priority 40 to ensure PLL_Wizard_Pro is corre tly initialized.64 // Hooked on admin_init with priority 40 to ensure PLL_Wizard_Pro is correctly initialized. 65 65 add_action( 'admin_init', array( $this, 'setup_wizard_page' ), 40 ); 66 66 // Add Wizard submenu. … … 366 366 add_action( 'wp_ajax_pll_deactivate_license', array( $this, 'deactivate_license' ) ); 367 367 368 // Be careful pll_admin script is enqueued here without depe dency except jquery because only code useful for deactivate license button is needed.368 // Be careful pll_admin script is enqueued here without dependency except jquery because only code useful for deactivate license button is needed. 369 369 // To be really loaded the script need to be passed to the $steps['licenses']['scripts'] array below with the same handle than in wp_enqueue_script(). 370 370 wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery' ), POLYLANG_VERSION, true ); … … 467 467 public function add_step_languages( $steps ) { 468 468 wp_deregister_script( 'pll_admin' ); // Deregister after the licenses step enqueue to update jquery-ui-selectmenu dependency. 469 // The wp-ajax-response and postbox dependencies is useless in wizard steps esp acially postbox which triggers a javascript error otherwise.469 // The wp-ajax-response and postbox dependencies is useless in wizard steps especially postbox which triggers a javascript error otherwise. 470 470 // To be really loaded the script need to be passed to the $steps['languages']['scripts'] array below with the same handle than in wp_enqueue_script(). 471 471 wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $this->get_suffix() . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true ); -
polylang/trunk/modules/wpml/load.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly. 10 } ;10 } 11 11 12 12 if ( $polylang->model->has_languages() ) { -
polylang/trunk/modules/wpml/wpml-api.php
r2907847 r3042028 27 27 public function __construct() { 28 28 /* 29 * Site Wide Language information s.29 * Site Wide Language information. 30 30 */ 31 31 add_filter( 'wpml_active_languages', array( $this, 'wpml_active_languages' ), 10, 2 ); … … 414 414 * 415 415 * @param string $url The url to filter. 416 * @param null|string $lang Lang age code, optional, defaults to the current language.416 * @param null|string $lang Language code, optional, defaults to the current language. 417 417 * @return string 418 418 */ -
polylang/trunk/modules/wpml/wpml-config.php
r2983561 r3042028 10 10 * 11 11 * @since 1.0 12 * 13 * @phpstan-type ParsedMetas array< 14 * non-falsy-string, 15 * array{ 16 * action: string, 17 * encoding: 'json'|'' 18 * } 19 * > 12 20 */ 13 21 class PLL_WPML_Config { … … 48 56 */ 49 57 private $open_basedir_paths; 58 59 /** 60 * Cache for parsed metas. 61 * 62 * @var array 63 * 64 * @phpstan-var array<non-falsy-string, ParsedMetas> 65 */ 66 private $parsed_metas = array(); 50 67 51 68 /** … … 109 126 add_filter( 'pll_get_post_types', array( $this, 'translate_types' ), 10, 2 ); 110 127 add_filter( 'pll_get_taxonomies', array( $this, 'translate_taxonomies' ), 10, 2 ); 111 add_filter( 'pll_blocks_xpath_rules', array( $this, 'translate_blocks' ) );112 add_filter( 'pll_blocks_rules_for_attributes', array( $this, 'translate_blocks_attributes' ) );113 128 114 129 // Export. 115 130 add_filter( 'pll_post_metas_to_export', array( $this, 'post_metas_to_export' ) ); 116 131 add_filter( 'pll_term_metas_to_export', array( $this, 'term_metas_to_export' ) ); 132 add_filter( 'pll_post_meta_encodings', array( $this, 'add_post_meta_encodings' ), 20 ); 133 add_filter( 'pll_term_meta_encodings', array( $this, 'add_term_meta_encodings' ), 20 ); 134 add_filter( 'pll_blocks_xpath_rules', array( $this, 'translate_blocks' ) ); 135 add_filter( 'pll_blocks_rules_for_attributes', array( $this, 'translate_blocks_attributes' ) ); 117 136 118 137 foreach ( $this->xmls as $context => $xml ) { … … 174 193 175 194 /** 176 * Adds custom fields to the list of metas to copy when creating a new translation.195 * Adds post metas to the list of metas to copy when creating a new translation. 177 196 * 178 197 * @since 1.0 179 198 * 180 * @param string[] $metas The list of custom fields to copy or synchronize.199 * @param string[] $metas The list of post metas to copy or synchronize. 181 200 * @param bool $sync True for sync, false for copy. 182 * @return string[] The list of custom fields to copy or synchronize. 201 * @return string[] The list of post metas to copy or synchronize. 202 * 203 * @phpstan-param array<non-falsy-string> $metas 183 204 */ 184 205 public function copy_post_metas( $metas, $sync ) { 185 foreach ( $this->xmls as $xml ) { 186 $cfs = $xml->xpath( 'custom-fields/custom-field' ); 187 188 if ( ! is_array( $cfs ) ) { 189 continue; 190 } 191 192 foreach ( $cfs as $cf ) { 193 $action = $this->get_field_attribute( $cf, 'action' ); 194 195 if ( 'copy' === $action || ( ! $sync && in_array( $action, array( 'translate', 'copy-once' ), true ) ) ) { 196 $metas[] = (string) $cf; 197 } else { 198 $metas = array_diff( $metas, array( (string) $cf ) ); 199 } 200 } 201 } 202 203 return $metas; 206 return $this->filter_metas_to_copy( (array) $metas, 'custom-fields/custom-field', (bool) $sync ); 204 207 } 205 208 … … 212 215 * @param bool $sync True for sync, false for copy. 213 216 * @return string[] The list of term metas to copy or synchronize. 217 * 218 * @phpstan-param array<non-falsy-string> $metas 214 219 */ 215 220 public function copy_term_metas( $metas, $sync ) { 216 foreach ( $this->xmls as $xml ) { 217 $cfs = $xml->xpath( 'custom-term-fields/custom-term-field' ); 218 219 if ( ! is_array( $cfs ) ) { 220 continue; 221 } 222 223 foreach ( $cfs as $cf ) { 224 $action = $this->get_field_attribute( $cf, 'action' ); 225 226 if ( 'copy' === $action || ( ! $sync && in_array( $action, array( 'translate', 'copy-once' ), true ) ) ) { 227 $metas[] = (string) $cf; 228 } else { 229 $metas = array_diff( $metas, array( (string) $cf ) ); 230 } 231 } 232 } 233 234 return $metas; 221 return $this->filter_metas_to_copy( (array) $metas, 'custom-term-fields/custom-term-field', (bool) $sync ); 235 222 } 236 223 … … 256 243 * @return array 257 244 * 258 * @phpstan-param array< string, mixed> $keys259 * @phpstan-return array< string, mixed>245 * @phpstan-param array<non-falsy-string, mixed> $keys 246 * @phpstan-return array<non-falsy-string, mixed> 260 247 */ 261 248 public function post_metas_to_export( $keys ) { 262 249 // Add keys that have the `action` attribute set to `translate`. 263 foreach ( $this->xmls as $xml ) { 264 $fields = $xml->xpath( 'custom-fields/custom-field' ); 265 266 if ( ! is_array( $fields ) ) { 267 // No custom fields. 268 continue; 269 } 270 271 foreach ( $fields as $field ) { 272 $action = $this->get_field_attribute( $field, 'action' ); 273 274 if ( 'translate' !== $action ) { 275 continue; 276 } 277 278 $keys[ (string) $field ] = 1; 279 } 280 } 250 $keys = $this->add_metas_to_export( (array) $keys, 'custom-fields/custom-field' ); 281 251 282 252 // Deal with sub-field translations. … … 326 296 * @return array 327 297 * 328 * @phpstan-param array< string, mixed> $keys329 * @phpstan-return array< string, mixed>298 * @phpstan-param array<non-falsy-string, mixed> $keys 299 * @phpstan-return array<non-falsy-string, mixed> 330 300 */ 331 301 public function term_metas_to_export( $keys ) { 332 302 // Add keys that have the `action` attribute set to `translate`. 333 foreach ( $this->xmls as $xml ) { 334 $fields = $xml->xpath( 'custom-term-fields/custom-term-field' ); 335 336 if ( ! is_array( $fields ) ) { 337 // No custom fields. 338 continue; 339 } 340 341 foreach ( $fields as $field ) { 342 $action = $this->get_field_attribute( $field, 'action' ); 343 344 if ( 'translate' !== $action ) { 345 continue; 346 } 347 348 $keys[ (string) $field ] = 1; 349 } 350 } 351 352 return $keys; 303 return $this->add_metas_to_export( (array) $keys, 'custom-term-fields/custom-term-field' ); 304 } 305 306 /** 307 * Specifies the encoding for post metas. 308 * 309 * @since 3.6 310 * 311 * @param string[] $metas An array containing meta names as array keys, and their encoding as array values. 312 * @return string[] 313 * 314 * @phpstan-param array<non-falsy-string, non-falsy-string> $metas 315 */ 316 public function add_post_meta_encodings( $metas ) { 317 return $this->add_metas_encodings( (array) $metas, 'custom-fields/custom-field' ); 318 } 319 320 /** 321 * Specifies the encoding for term metas. 322 * 323 * @since 3.6 324 * 325 * @param string[] $metas An array containing meta names as array keys, and their encoding as array values. 326 * @return string[] 327 * 328 * @phpstan-param array<non-falsy-string, non-falsy-string> $metas 329 */ 330 public function add_term_meta_encodings( $metas ) { 331 return $this->add_metas_encodings( (array) $metas, 'custom-term-fields/custom-term-field' ); 353 332 } 354 333 … … 850 829 return $path; 851 830 } 831 832 /** 833 * Adds (or removes) meta names to the list of metas to copy or synchronize. 834 * 835 * @since 3.6 836 * 837 * @param string[] $metas The list of meta names to copy or synchronize. 838 * @param string $xpath Xpath to the meta fields in the xml files. 839 * @param bool $sync Either sync is enabled or not. 840 * @return string[] 841 * 842 * @phpstan-param array<non-falsy-string> $metas 843 * @phpstan-param non-falsy-string $xpath 844 */ 845 private function filter_metas_to_copy( array $metas, string $xpath, bool $sync ): array { 846 $parsed_metas = $this->parse_xml_metas( $xpath ); 847 $metas_to_remove = array(); 848 849 foreach ( $parsed_metas as $name => $parsed_meta ) { 850 if ( 'copy' === $parsed_meta['action'] || ( ! $sync && in_array( $parsed_meta['action'], array( 'translate', 'copy-once' ), true ) ) ) { 851 $metas[] = $name; 852 } else { 853 $metas_to_remove[] = $name; 854 } 855 } 856 857 return array_diff( $metas, $metas_to_remove ); 858 } 859 860 /** 861 * Adds meta keys to export. 862 * 863 * @since 3.6 864 * 865 * @param array $metas { 866 * An array containing meta keys to translate. 867 * Ex: array( 868 * 'meta_to_translate_1' => 1, 869 * 'meta_to_translate_2' => 1, 870 * 'meta_to_translate_3' => array( ... ), 871 * ) 872 * } 873 * @param string $xpath Xpath to the meta fields in the xml files. 874 * @return array 875 * 876 * @phpstan-param array<non-falsy-string, mixed> $metas 877 * @phpstan-param non-falsy-string $xpath 878 * @phpstan-return array<non-falsy-string, mixed> 879 */ 880 private function add_metas_to_export( array $metas, string $xpath ) { 881 $fields = $this->parse_xml_metas( $xpath ); 882 883 foreach ( $fields as $name => $field ) { 884 if ( 'translate' === $field['action'] ) { 885 $metas[ $name ] = 1; 886 } 887 } 888 889 return $metas; 890 } 891 892 /** 893 * Adds encoding of metas. 894 * 895 * @since 3.6 896 * 897 * @param string[] $metas The list of encodings for each metas. Meta names are array keys, encodings are array values. 898 * @param string $xpath Xpath to the meta fields in the xml files. 899 * @return string[] 900 * 901 * @phpstan-param array<non-falsy-string, non-falsy-string> $metas 902 * @phpstan-param non-falsy-string $xpath 903 */ 904 private function add_metas_encodings( array $metas, string $xpath ): array { 905 $parsed_metas = $this->parse_xml_metas( $xpath ); 906 907 foreach ( $parsed_metas as $name => $parsed_meta ) { 908 if ( ! empty( $parsed_meta['encoding'] ) ) { 909 $metas[ $name ] = $parsed_meta['encoding']; 910 } 911 } 912 913 return $metas; 914 } 915 916 /** 917 * Parses all xml files for metas. 918 * Results are cached for each `$xpath`. 919 * 920 * @since 3.6 921 * 922 * @param string $xpath Xpath to the meta fields in the xml files. 923 * @return array 924 * 925 * @phpstan-param non-falsy-string $xpath 926 * @phpstan-return ParsedMetas 927 */ 928 private function parse_xml_metas( string $xpath ): array { 929 if ( isset( $this->parsed_metas[ $xpath ] ) ) { 930 return $this->parsed_metas[ $xpath ]; 931 } 932 933 $this->parsed_metas[ $xpath ] = array(); 934 935 foreach ( $this->xmls as $xml ) { 936 $custom_fields = $xml->xpath( $xpath ); 937 938 if ( ! is_array( $custom_fields ) ) { 939 continue; 940 } 941 942 foreach ( $custom_fields as $custom_field ) { 943 $name = (string) $custom_field; 944 945 if ( empty( $name ) ) { 946 continue; 947 } 948 949 $data = array( 950 'action' => $this->get_field_attribute( $custom_field, 'action' ), 951 'encoding' => $this->get_field_attribute( $custom_field, 'encoding' ), 952 ); 953 954 $data['encoding'] = 'json' === $data['encoding'] ? 'json' : ''; // Only JSON is supported for now. 955 956 $this->parsed_metas[ $xpath ][ $name ] = $data; 957 } 958 } 959 960 return $this->parsed_metas[ $xpath ]; 961 } 852 962 } -
polylang/trunk/modules/wpml/wpml-legacy-api.php
r2802032 r3042028 28 28 * available only on frontend 29 29 * 30 * List of param aters accepted in $args:30 * List of parameters accepted in $args: 31 31 * 32 32 * skip_missing => whether to skip missing translation or not, 0 or 1, defaults to 0 -
polylang/trunk/polylang.php
r3032046 r3042028 11 11 * Plugin URI: https://polylang.pro 12 12 * Description: Adds multilingual capability to WordPress 13 * Version: 3. 5.413 * Version: 3.6-beta1 14 14 * Requires at least: 5.9 15 15 * Requires PHP: 7.0 … … 40 40 if ( ! defined( 'ABSPATH' ) ) { 41 41 exit; // Don't access directly. 42 } ;42 } 43 43 44 44 if ( defined( 'POLYLANG_VERSION' ) ) { … … 54 54 } else { 55 55 // Go on loading the plugin 56 define( 'POLYLANG_VERSION', '3. 5.4' );56 define( 'POLYLANG_VERSION', '3.6-beta1' ); 57 57 define( 'PLL_MIN_WP_VERSION', '5.9' ); 58 58 define( 'PLL_MIN_PHP_VERSION', '7.0' ); -
polylang/trunk/readme.txt
r3032046 r3042028 28 28 * The language is either set by the language code in URL, or you can use a different sub-domain or domain per language. 29 29 * Automatic copy of categories, post tags and other metas when creating a new post or page translation. 30 * Translating menus and widgets.31 * Customizable language switcher available as a widget or anavigation menu item.30 * Translating classic menus and classic widgets. Also accessible with [Site Editor Classic Features](https://wordpress.org/plugins/fse-classic/) in block themes. 31 * Customizable language switcher available as a classic widget or a classic navigation menu item. 32 32 * Compatibility with Yoast SEO. 33 33 … … 65 65 * [WPML to Polylang](https://wordpress.org/plugins/wpml-to-polylang/) allows migrating from WPML to Polylang. 66 66 * [DynaMo](https://wordpress.org/plugins/dynamo/) speeds up the translation of WordPress for all non-English sites. 67 * [Site Editor Classic Features](https://wordpress.org/plugins/fse-classic/) allows to use legacywidgets (including the Polylang language switcher) and menus in the site editor (FSE).67 * [Site Editor Classic Features](https://wordpress.org/plugins/fse-classic/) allows to use classic widgets (including the Polylang language switcher) and menus in the site editor (FSE). 68 68 69 69 = Credits = … … 104 104 105 105 == Changelog == 106 107 == 3.6 == 108 109 * Add compatibility with WP 6.5 110 * Pro: Add DeepL machine translation for posts and terms 111 * Pro: Add export and import of XLIFF 2.0/2.1 112 * Pro: Allow to export and import JSON encoded post and term metas 113 * Pro: Include footer notes block in translation files 114 * Pro: Single files are now exported directly instead of inside a zip 115 * Pro: Fix a race condition which could lead to display a notice to the wrong user 116 * Fix wrong translated post types and taxononies after a `switch_to_blog()` #1415 117 * Fix a minor performance issue for the page for posts #1412 106 118 107 119 = 3.5.4 (2023-02-06) = -
polylang/trunk/settings/flags.php
r2340428 r3042028 6 6 if ( ! defined( 'ABSPATH' ) ) { 7 7 exit; // Don't access directly 8 } ;8 } 9 9 10 10 /** -
polylang/trunk/settings/languages.php
r2939729 r3042028 6 6 if ( ! defined( 'ABSPATH' ) ) { 7 7 exit; // Don't access directly 8 } ;8 } 9 9 10 10 /** … … 81 81 'flag' => 'arab', 82 82 'facebook' => 'ar_AR', 83 'deepl' => 'AR', 83 84 ), 84 85 'arg' => array( … … 99 100 'flag' => 'ma', 100 101 'facebook' => 'ar_AR', 102 'deepl' => 'AR', 101 103 ), 102 104 'as' => array( … … 139 141 'flag' => 'bg', 140 142 'facebook' => 'bg_BG', 143 'deepl' => 'BG', 141 144 ), 142 145 'bn_BD' => array( … … 201 204 'flag' => 'cz', 202 205 'facebook' => 'cs_CZ', 206 'deepl' => 'CS', 203 207 ), 204 208 'cy' => array( … … 217 221 'flag' => 'dk', 218 222 'facebook' => 'da_DK', 223 'deepl' => 'DA', 219 224 ), 220 225 'de_AT' => array( … … 225 230 'flag' => 'at', 226 231 'facebook' => 'de_DE', 232 'deepl' => 'DE', 227 233 ), 228 234 'de_CH' => array( … … 233 239 'flag' => 'ch', 234 240 'facebook' => 'de_DE', 241 'deepl' => 'DE', 235 242 ), 236 243 'de_CH_informal' => array( … … 242 249 'w3c' => 'de-CH', 243 250 'facebook' => 'de_DE', 251 'deepl' => 'DE', 244 252 ), 245 253 'de_DE' => array( … … 250 258 'flag' => 'de', 251 259 'facebook' => 'de_DE', 260 'deepl' => 'DE', 252 261 ), 253 262 'de_DE_formal' => array( … … 259 268 'w3c' => 'de-DE', 260 269 'facebook' => 'de_DE', 270 'deepl' => 'DE', 261 271 ), 262 272 'dsb' => array( … … 282 292 'flag' => 'gr', 283 293 'facebook' => 'el_GR', 294 'deepl' => 'EL', 284 295 ), 285 296 'en_AU' => array( … … 290 301 'flag' => 'au', 291 302 'facebook' => 'en_US', 303 'deepl' => 'EN-US', 292 304 ), 293 305 'en_CA' => array( … … 298 310 'flag' => 'ca', 299 311 'facebook' => 'en_US', 312 'deepl' => 'EN-US', 300 313 ), 301 314 'en_GB' => array( … … 306 319 'flag' => 'gb', 307 320 'facebook' => 'en_GB', 321 'deepl' => 'EN-GB', 308 322 ), 309 323 'en_NZ' => array( … … 314 328 'flag' => 'nz', 315 329 'facebook' => 'en_US', 330 'deepl' => 'EN-US', 316 331 ), 317 332 'en_US' => array( … … 322 337 'flag' => 'us', 323 338 'facebook' => 'en_US', 339 'deepl' => 'EN-US', 324 340 ), 325 341 'en_ZA' => array( … … 330 346 'flag' => 'za', 331 347 'facebook' => 'en_US', 348 'deepl' => 'EN-US', 332 349 ), 333 350 'eo' => array( … … 346 363 'flag' => 'ar', 347 364 'facebook' => 'es_LA', 365 'deepl' => 'ES', 348 366 ), 349 367 'es_CL' => array( … … 354 372 'flag' => 'cl', 355 373 'facebook' => 'es_CL', 374 'deepl' => 'ES', 356 375 ), 357 376 'es_CO' => array( … … 362 381 'flag' => 'co', 363 382 'facebook' => 'es_CO', 383 'deepl' => 'ES', 364 384 ), 365 385 'es_CR' => array( … … 370 390 'flag' => 'cr', 371 391 'facebook' => 'es_LA', 392 'deepl' => 'ES', 372 393 ), 373 394 'es_DO' => array( … … 378 399 'flag' => 'do', 379 400 'facebook' => 'es_LA', 401 'deepl' => 'ES', 380 402 ), 381 403 'es_EC' => array( … … 386 408 'flag' => 'ec', 387 409 'facebook' => 'es_LA', 410 'deepl' => 'ES', 388 411 ), 389 412 'es_ES' => array( … … 394 417 'flag' => 'es', 395 418 'facebook' => 'es_ES', 419 'deepl' => 'ES', 396 420 ), 397 421 'es_GT' => array( … … 402 426 'flag' => 'gt', 403 427 'facebook' => 'es_LA', 428 'deepl' => 'ES', 404 429 ), 405 430 'es_MX' => array( … … 410 435 'flag' => 'mx', 411 436 'facebook' => 'es_MX', 437 'deepl' => 'ES', 412 438 ), 413 439 'es_PE' => array( … … 418 444 'flag' => 'pe', 419 445 'facebook' => 'es_LA', 446 'deepl' => 'ES', 420 447 ), 421 448 'es_PR' => array( … … 426 453 'flag' => 'pr', 427 454 'facebook' => 'es_LA', 455 'deepl' => 'ES', 428 456 ), 429 457 'es_UY' => array( … … 434 462 'flag' => 'uy', 435 463 'facebook' => 'es_LA', 464 'deepl' => 'ES', 436 465 ), 437 466 'es_VE' => array( … … 442 471 'flag' => 've', 443 472 'facebook' => 'es_VE', 473 'deepl' => 'ES', 444 474 ), 445 475 'et' => array( … … 450 480 'flag' => 'ee', 451 481 'facebook' => 'et_EE', 482 'deepl' => 'ET', 452 483 ), 453 484 'eu' => array( … … 482 513 'flag' => 'fi', 483 514 'facebook' => 'fi_FI', 515 'deepl' => 'FI', 484 516 ), 485 517 'fo' => array( … … 498 530 'flag' => 'be', 499 531 'facebook' => 'fr_FR', 532 'deepl' => 'FR', 500 533 ), 501 534 'fr_CA' => array( … … 506 539 'flag' => 'quebec', 507 540 'facebook' => 'fr_CA', 541 'deepl' => 'FR', 508 542 ), 509 543 'fr_FR' => array( … … 514 548 'flag' => 'fr', 515 549 'facebook' => 'fr_FR', 550 'deepl' => 'FR', 516 551 ), 517 552 'fuc' => array( … … 609 644 'flag' => 'hu', 610 645 'facebook' => 'hu_HU', 646 'deepl' => 'HU', 611 647 ), 612 648 'hsb' => array( … … 632 668 'flag' => 'id', 633 669 'facebook' => 'id_ID', 670 'deepl' => 'ID', 634 671 ), 635 672 'ido' => array( … … 651 688 'flag' => 'it', 652 689 'facebook' => 'it_IT', 690 'deepl' => 'IT', 653 691 ), 654 692 'ja' => array( … … 659 697 'flag' => 'jp', 660 698 'facebook' => 'ja_JP', 699 'deepl' => 'JA', 661 700 ), 662 701 'jv_ID' => array( … … 725 764 'flag' => 'kr', 726 765 'facebook' => 'ko_KR', 766 'deepl' => 'KO', 727 767 ), 728 768 'ku' => array( … … 756 796 'flag' => 'lt', 757 797 'facebook' => 'lt_LT', 798 'deepl' => 'LT', 758 799 ), 759 800 'lv' => array( … … 764 805 'flag' => 'lv', 765 806 'facebook' => 'lv_LV', 807 'deepl' => 'LV', 766 808 ), 767 809 'mg_MG' => array( … … 830 872 'flag' => 'no', 831 873 'facebook' => 'nb_NO', 874 'deepl' => 'NB', 832 875 ), 833 876 'ne_NP' => array( … … 846 889 'flag' => 'be', 847 890 'facebook' => 'nl_BE', 891 'deepl' => 'NL', 848 892 ), 849 893 'nl_NL' => array( … … 854 898 'flag' => 'nl', 855 899 'facebook' => 'nl_NL', 900 'deepl' => 'NL', 856 901 ), 857 902 'nl_NL_formal' => array( … … 863 908 'w3c' => 'nl-NL', 864 909 'facebook' => 'nl_NL', 910 'deepl' => 'NL', 865 911 ), 866 912 'nn_NO' => array( … … 898 944 'flag' => 'pl', 899 945 'facebook' => 'pl_PL', 946 'deepl' => 'PL', 900 947 ), 901 948 'ps' => array( … … 914 961 'flag' => 'ao', 915 962 'facebook' => 'pt_PT', 963 'deepl' => 'PT-PT', 916 964 ), 917 965 'pt_BR' => array( … … 922 970 'flag' => 'br', 923 971 'facebook' => 'pt_BR', 972 'deepl' => 'PT-BR', 924 973 ), 925 974 'pt_PT' => array( … … 930 979 'flag' => 'pt', 931 980 'facebook' => 'pt_PT', 981 'deepl' => 'PT-PT', 932 982 ), 933 983 'pt_PT_ao90' => array( … … 938 988 'flag' => 'pt', 939 989 'facebook' => 'pt_PT', 990 'deepl' => 'PT-PT', 940 991 ), 941 992 'rhg' => array( … … 953 1004 'flag' => 'ro', 954 1005 'facebook' => 'ro_RO', 1006 'deepl' => 'RO', 955 1007 ), 956 1008 'roh' => array( … … 965 1017 'flag' => 'ru', 966 1018 'facebook' => 'ru_RU', 1019 'deepl' => 'RU', 967 1020 ), 968 1021 'sa_IN' => array( … … 991 1044 'flag' => 'sk', 992 1045 'facebook' => 'sk_SK', 1046 'deepl' => 'SK', 993 1047 ), 994 1048 'skr' => array( … … 1006 1060 'flag' => 'si', 1007 1061 'facebook' => 'sl_SI', 1062 'deepl' => 'SL', 1008 1063 ), 1009 1064 'sna' => array( … … 1060 1115 'flag' => 'se', 1061 1116 'facebook' => 'sv_SE', 1117 'deepl' => 'SV', 1062 1118 ), 1063 1119 'sw' => array( … … 1137 1193 'flag' => 'tr', 1138 1194 'facebook' => 'tr_TR', 1195 'deepl' => 'TR', 1139 1196 ), 1140 1197 'tt_RU' => array( … … 1167 1224 'flag' => 'ua', 1168 1225 'facebook' => 'uk_UA', 1226 'deepl' => 'UK', 1169 1227 ), 1170 1228 'ur' => array( … … 1212 1270 'flag' => 'cn', 1213 1271 'facebook' => 'zh_CN', 1272 'deepl' => 'ZH', 1214 1273 ), 1215 1274 'zh_HK' => array( … … 1220 1279 'flag' => 'hk', 1221 1280 'facebook' => 'zh_HK', 1281 'deepl' => 'ZH', 1222 1282 ), 1223 1283 'zh_TW' => array( … … 1228 1288 'flag' => 'tw', 1229 1289 'facebook' => 'zh_TW', 1290 'deepl' => 'ZH', 1230 1291 ), 1231 1292 ); -
polylang/trunk/settings/settings-browser.php
r2974283 r3042028 34 34 'title' => __( 'Detect browser language', 'polylang' ), 35 35 'description' => __( 'When the front page is visited, redirects to itself in the browser preferred language. As this doesn\'t work if it is cached, Polylang will attempt to disable the front page cache for known cache plugins.', 'polylang' ), 36 'active_option' => $this->is_available() ? 'browser' : false,36 'active_option' => $this->is_available() ? 'browser' : 'none', 37 37 ) 38 38 ); -
polylang/trunk/settings/settings-licenses.php
r2475716 r3042028 66 66 protected function form() { 67 67 if ( ! empty( $this->items ) ) { ?> 68 <table id="pll-licenses-table" class="form-table ">68 <table id="pll-licenses-table" class="form-table pll-table-top"> 69 69 <?php 70 70 foreach ( $this->items as $item ) { … … 111 111 112 112 // Updated message 113 add_settings_error( ' general', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'updated' );113 add_settings_error( 'polylang', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'success' ); 114 114 ob_start(); 115 settings_errors( );115 settings_errors( 'polylang' ); 116 116 $x->Add( array( 'what' => 'success', 'data' => ob_get_clean() ) ); 117 117 $x->send(); -
polylang/trunk/settings/settings-module.php
r2974283 r3042028 30 30 31 31 /** 32 * Stores if the module is active. 33 * 34 * @var string|false 32 * Key to use to manage the module activation state. 33 * Possible values: 34 * - An option key for a module that can be activated/deactivated. 35 * - 'none' for a module that doesn't have a activation/deactivation setting. 36 * - 'preview' for a preview module whose functionalities are available in the Pro version. 37 * 38 * @var string 39 * 40 * @phpstan-var non-falsy-string 35 41 */ 36 42 public $active_option; … … 47 53 * It must be unique. 48 54 * 49 * @var string|null 55 * @var string 56 * 57 * @phpstan-var non-falsy-string 50 58 */ 51 59 public $module; … … 93 101 * @param object $polylang The Polylang object. 94 102 * @param array $args { 95 * @type string $module Unique module name. 96 * @type string $title The title of the settings module. 97 * @type string $description The description of the settings module. 98 * @type string|false $active_option Optional option name storing if the module is active, false if not used. 103 * @type string $module Unique module name. 104 * @type string $title The title of the settings module. 105 * @type string $description The description of the settings module. 106 * @type string $active_option Optional. Key to use to manage the module activation state. 107 * Possible values: 108 * - An option key for a module that can be activated/deactivated. 109 * - 'none' for a module that doesn't have a activation/deactivation setting. 110 * - 'preview' for a preview module whose functionalities are available in the Pro version. 111 * Default is 'none'. 99 112 * } 113 * 114 * @phpstan-param array{ 115 * module: non-falsy-string, 116 * title: string, 117 * description: string, 118 * active_option?: non-falsy-string 119 * } $args 100 120 */ 101 121 public function __construct( &$polylang, $args ) { 102 $this->options = &$polylang->options;103 $this->model = &$polylang->model;122 $this->options = &$polylang->options; 123 $this->model = &$polylang->model; 104 124 $this->links_model = &$polylang->links_model; 105 125 … … 109 129 'title' => '', 110 130 'description' => '', 111 'active_option' => false,131 'active_option' => 'none', 112 132 ) 113 133 ); 134 135 if ( empty( $args['active_option'] ) ) { 136 // Backward compatibility. 137 $args['active_option'] = 'none'; 138 } 114 139 115 140 foreach ( $args as $prop => $value ) { … … 146 171 ); 147 172 148 // Ajax action to save options 173 // Ajax action to save options. 149 174 add_action( 'wp_ajax_pll_save_options', array( $this, 'save_options' ) ); 150 175 } 151 176 152 177 /** 153 * Tells if the module is active 178 * Tells if the module is active. 154 179 * 155 180 * @since 1.8 … … 158 183 */ 159 184 public function is_active() { 160 return empty( $this->active_option ) || ! empty( $this->options[ $this->active_option ]);161 } 162 163 /** 164 * Activates the module 185 return 'none' === $this->active_option || ( 'preview' !== $this->active_option && ! empty( $this->options[ $this->active_option ] ) ); 186 } 187 188 /** 189 * Activates the module. 165 190 * 166 191 * @since 1.8 … … 169 194 */ 170 195 public function activate() { 171 if ( ! empty( $this->active_option )) {196 if ( 'none' !== $this->active_option && 'preview' !== $this->active_option ) { 172 197 $this->options[ $this->active_option ] = true; 173 198 update_option( 'polylang', $this->options ); … … 176 201 177 202 /** 178 * Deactivates the module 203 * Deactivates the module. 179 204 * 180 205 * @since 1.8 … … 183 208 */ 184 209 public function deactivate() { 185 if ( ! empty( $this->active_option )) {210 if ( 'none' !== $this->active_option && 'preview' !== $this->active_option ) { 186 211 $this->options[ $this->active_option ] = false; 187 212 update_option( 'polylang', $this->options ); … … 190 215 191 216 /** 192 * Protected method to display a configuration form 217 * Protected method to display a configuration form. 193 218 * 194 219 * @since 1.8 … … 197 222 */ 198 223 protected function form() { 199 // Child classes can provide a form 200 } 201 202 /** 203 * Public method returning the form if any 224 // Child classes can provide a form. 225 } 226 227 /** 228 * Public method returning the form if any. 204 229 * 205 230 * @since 1.8 … … 231 256 232 257 /** 233 * Ajax method to save the options 258 * Ajax method to save the options. 234 259 * 235 260 * @since 1.8 … … 260 285 ob_start(); 261 286 262 if ( empty( get_settings_errors( ) ) ) {287 if ( empty( get_settings_errors( 'polylang' ) ) ) { 263 288 // Send update message 264 add_settings_error( ' general', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'updated' );265 settings_errors( );289 add_settings_error( 'polylang', 'settings_updated', __( 'Settings saved.', 'polylang' ), 'success' ); 290 settings_errors( 'polylang' ); 266 291 $x = new WP_Ajax_Response( array( 'what' => 'success', 'data' => ob_get_clean() ) ); 267 292 $x->send(); 268 293 } else { 269 294 // Send error messages 270 settings_errors( );295 settings_errors( 'polylang' ); 271 296 $x = new WP_Ajax_Response( array( 'what' => 'error', 'data' => ob_get_clean() ) ); 272 297 $x->send(); … … 289 314 } 290 315 291 if ( $this->active_option ) {316 if ( 'none' !== $this->active_option && 'preview' !== $this->active_option ) { 292 317 $actions[] = $this->is_active() ? 'deactivate' : 'activate'; 293 318 } … … 312 337 313 338 /** 314 * Default upgrade message ( to Pro version )339 * Default upgrade message (to Pro version). 315 340 * 316 341 * @since 1.9 … … 328 353 329 354 /** 330 * Allows child classes to display an upgrade message 355 * Allows child classes to display an upgrade message. 331 356 * 332 357 * @since 1.9 … … 335 360 */ 336 361 public function get_upgrade_message() { 337 return ' ';362 return 'preview' === $this->active_option ? $this->default_upgrade_message() : ''; 338 363 } 339 364 -
polylang/trunk/settings/settings-url.php
r2974283 r3042028 263 263 $lang = $this->model->get_language( $key ); 264 264 add_settings_error( 265 ' general',266 'pll_invalid_domain',265 'polylang', 266 sprintf( 'pll_invalid_domain_%s', $key ), 267 267 esc_html( 268 268 sprintf( … … 319 319 if ( 200 != $response_code ) { 320 320 add_settings_error( 321 ' general',322 'pll_invalid_domain',321 'polylang', 322 sprintf( 'pll_invalid_domain_%s', $lang->slug ), 323 323 esc_html( 324 324 sprintf( -
polylang/trunk/settings/settings.php
r2974283 r3042028 48 48 add_action( 'admin_init', array( $this, 'register_settings_modules' ) ); 49 49 50 // Adds screen options and the about box in the languages admin panel 50 // Adds screen options and the about box in the languages admin panel. 51 51 add_action( 'load-toplevel_page_mlang', array( $this, 'load_page' ) ); 52 52 add_action( 'load-languages_page_mlang_strings', array( $this, 'load_page_strings' ) ); 53 53 54 // Saves per-page value in screen option 55 add_filter( 'set-screen-option', array( $this, 'set_screen_option' ), 10, 3 ); 54 // Saves the per-page value in screen options. 55 add_filter( 'set_screen_option_pll_lang_per_page', array( $this, 'set_screen_option' ), 10, 3 ); 56 add_filter( 'set_screen_option_pll_strings_per_page', array( $this, 'set_screen_option' ), 10, 3 ); 56 57 } 57 58 … … 152 153 153 154 /** 154 * Save the "Views/Uploads per page" option set by this user155 * Saves the number of rows in the languages or strings table set by this user. 155 156 * 156 157 * @since 0.9.5 157 158 * 158 * @param mixed $status false or value returned by previous filter 159 * @param string $option Name of the option being changed 160 * @param string $value Value of the option 161 * 162 * @return string New value if this is our option, otherwise nothing 163 */ 164 public function set_screen_option( $status, $option, $value ) { 165 return 'pll_lang_per_page' === $option || 'pll_strings_per_page' === $option ? $value : $status; 159 * @param mixed $screen_option False or value returned by a previous filter, not used. 160 * @param string $option The name of the option, not used. 161 * @param int $value The new value of the option to save. 162 * @return int The new value of the option. 163 */ 164 public function set_screen_option( $screen_option, $option, $value ) { 165 return (int) $value; 166 166 } 167 167 … … 181 181 182 182 if ( is_wp_error( $errors ) ) { 183 foreach ( $errors->get_error_ messages() as $message ) {184 add_settings_error( ' general', 'pll_add_language', $message);183 foreach ( $errors->get_error_codes() as $code ) { 184 add_settings_error( 'polylang', $code, $errors->get_error_message( $code ) ); 185 185 } 186 186 } else { 187 add_settings_error( ' general', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'updated' );187 add_settings_error( 'polylang', 'pll_languages_created', __( 'Language added.', 'polylang' ), 'success' ); 188 188 $locale = sanitize_locale_name( $_POST['locale'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated 189 189 … … 192 192 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; 193 193 if ( ! wp_download_language_pack( $locale ) ) { 194 add_settings_error( ' general', 'pll_download_mo', __( 'The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang' ));194 add_settings_error( 'polylang', 'pll_download_mo', __( 'The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang' ), 'warning' ); 195 195 } 196 196 … … 207 207 208 208 if ( ! empty( $_GET['lang'] ) && $this->model->delete_language( (int) $_GET['lang'] ) ) { 209 add_settings_error( ' general', 'pll_languages_deleted', __( 'Language deleted.', 'polylang' ), 'updated' );209 add_settings_error( 'polylang', 'pll_languages_deleted', __( 'Language deleted.', 'polylang' ), 'success' ); 210 210 } 211 211 … … 218 218 219 219 if ( is_wp_error( $errors ) ) { 220 foreach ( $errors->get_error_ messages() as $message ) {221 add_settings_error( ' general', 'pll_update_language', $message);220 foreach ( $errors->get_error_codes() as $code ) { 221 add_settings_error( 'polylang', $code, $errors->get_error_message( $code ) ); 222 222 } 223 223 } else { 224 add_settings_error( ' general', 'pll_languages_updated', __( 'Language updated.', 'polylang' ), 'updated' );224 add_settings_error( 'polylang', 'pll_languages_updated', __( 'Language updated.', 'polylang' ), 'success' ); 225 225 } 226 226 … … 324 324 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; 325 325 326 wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $suffix . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'wp-ajax-response', 'postbox', 'jquery-ui-selectmenu' ), POLYLANG_VERSION, true );326 wp_enqueue_script( 'pll_admin', plugins_url( '/js/build/admin' . $suffix . '.js', POLYLANG_ROOT_FILE ), array( 'jquery', 'wp-ajax-response', 'postbox', 'jquery-ui-selectmenu', 'wp-hooks' ), POLYLANG_VERSION, true ); 327 327 wp_localize_script( 'pll_admin', 'pll_admin', array( 'dismiss_notice' => esc_html__( 'Dismiss this notice.', 'polylang' ) ) ); 328 328 … … 358 358 */ 359 359 public static function redirect( $args = array() ) { 360 $errors = get_settings_errors( );360 $errors = get_settings_errors( 'polylang' ); 361 361 if ( ! empty( $errors ) ) { 362 362 set_transient( 'settings_errors', $errors, 30 ); … … 407 407 $languages = apply_filters( 'pll_predefined_languages', $languages ); 408 408 409 // Keep only languages with all necessary information s409 // Keep only languages with all necessary information 410 410 foreach ( $languages as $k => $lang ) { 411 411 if ( ! isset( $lang['code'], $lang['locale'], $lang['name'], $lang['dir'], $lang['flag'] ) ) { -
polylang/trunk/settings/table-settings.php
r2475716 r3042028 176 176 usort( 177 177 $items, 178 function ( $a, $b ) {178 function ( $a, $b ) { 179 179 return $a->priority > $b->priority ? 1 : -1; 180 180 } -
polylang/trunk/settings/table-string.php
r2974283 r3042028 80 80 * 81 81 * @param array $item Data related to the current string. 82 * @param string $column_name The cur ent column name.82 * @param string $column_name The current column name. 83 83 * @return string 84 84 */ … … 372 372 /** 373 373 * Saves the strings translations in DB 374 * Optional y clean the DB374 * Optionally clean the DB 375 375 * 376 376 * @since 1.9 … … 420 420 } 421 421 422 add_settings_error( ' general', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'updated' );422 add_settings_error( 'polylang', 'pll_strings_translations_updated', __( 'Translations updated.', 'polylang' ), 'success' ); 423 423 424 424 /** -
polylang/trunk/settings/view-about.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 ?> 12 12 <p> -
polylang/trunk/settings/view-languages.php
r2911489 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 12 12 require ABSPATH . 'wp-admin/options-head.php'; // Displays the errors messages as when we were a child of options-general.php -
polylang/trunk/settings/view-tab-lang.php
r2907847 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 ?> 12 12 <div id="col-container"> -
polylang/trunk/settings/view-tab-settings.php
r2340428 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 ?> 12 12 <div class="form-wrap"> -
polylang/trunk/settings/view-tab-strings.php
r2708418 r3042028 8 8 if ( ! defined( 'ABSPATH' ) ) { 9 9 exit; // Don't access directly 10 } ;10 } 11 11 ?> 12 12 <div class="form-wrap"> -
polylang/trunk/uninstall.php
r2907847 r3042028 24 24 global $wpdb; 25 25 26 // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicit ely defined and true.26 // Don't do anything except if the constant PLL_REMOVE_ALL_DATA is explicitly defined and true. 27 27 if ( ! defined( 'PLL_REMOVE_ALL_DATA' ) || ! PLL_REMOVE_ALL_DATA ) { 28 28 return; … … 62 62 63 63 // Delete users options 64 foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) { 65 delete_user_meta( $user_id, 'pll_filter_content' ); 66 delete_user_meta( $user_id, 'pll_dismissed_notices' ); // Legacy meta. 67 foreach ( $languages as $lang ) { 68 delete_user_meta( $user_id, 'description_' . $lang->slug ); 69 } 64 delete_metadata( 'user', 0, 'pll_filter_content', '', true ); 65 delete_metadata( 'user', 0, 'pll_dismissed_notices', '', true ); // Legacy meta. 66 foreach ( $languages as $lang ) { 67 delete_metadata( 'user', 0, "description_{$lang->slug}", '', true ); 70 68 } 71 69 -
polylang/trunk/vendor/composer/autoload_classmap.php
r2974283 r3042028 94 94 'PLL_Settings_Media' => $baseDir . '/settings/settings-media.php', 95 95 'PLL_Settings_Module' => $baseDir . '/settings/settings-module.php', 96 'PLL_Settings_Preview_Machine_Translation' => $baseDir . '/modules/machine-translation/settings-preview-machine-translation.php', 96 97 'PLL_Settings_Preview_Share_Slug' => $baseDir . '/modules/share-slug/settings-preview-share-slug.php', 97 98 'PLL_Settings_Preview_Translate_Slugs' => $baseDir . '/modules/translate-slugs/settings-preview-translate-slugs.php', -
polylang/trunk/vendor/composer/autoload_static.php
r2974283 r3042028 95 95 'PLL_Settings_Media' => __DIR__ . '/../..' . '/settings/settings-media.php', 96 96 'PLL_Settings_Module' => __DIR__ . '/../..' . '/settings/settings-module.php', 97 'PLL_Settings_Preview_Machine_Translation' => __DIR__ . '/../..' . '/modules/machine-translation/settings-preview-machine-translation.php', 97 98 'PLL_Settings_Preview_Share_Slug' => __DIR__ . '/../..' . '/modules/share-slug/settings-preview-share-slug.php', 98 99 'PLL_Settings_Preview_Translate_Slugs' => __DIR__ . '/../..' . '/modules/translate-slugs/settings-preview-translate-slugs.php', -
polylang/trunk/vendor/composer/installed.php
r3008143 r3042028 2 2 'root' => array( 3 3 'name' => 'wpsyntex/polylang', 4 'pretty_version' => ' 3.5.x-dev',5 'version' => ' 3.5.9999999.9999999-dev',6 'reference' => ' a7e301c7219098568feace09fc14cf791d9b5242',4 'pretty_version' => 'dev-master', 5 'version' => 'dev-master', 6 'reference' => '570d8532ad9a968a1147adb3588e67ac357d81c3', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'wpsyntex/polylang' => array( 14 'pretty_version' => ' 3.5.x-dev',15 'version' => ' 3.5.9999999.9999999-dev',16 'reference' => ' a7e301c7219098568feace09fc14cf791d9b5242',14 'pretty_version' => 'dev-master', 15 'version' => 'dev-master', 16 'reference' => '570d8532ad9a968a1147adb3588e67ac357d81c3', 17 17 'type' => 'wordpress-plugin', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.