| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Setup filters common to admin and frontend |
| 8 | 5 | * |
| @@ -23,13 +20,8 @@ | ||
| 23 | 20 | $this->model = &$polylang->model; |
| 24 | 21 | $this->options = &$polylang->options; |
| 25 | 22 | $this->curlang = &$polylang->curlang; |
| 26 | 23 | |
| 27 | - // Deletes our cache for sticky posts when the list is updated. | |
| 28 | - add_action( 'update_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) ); | |
| 29 | - add_action( 'add_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) ); | |
| 30 | - add_action( 'delete_option_sticky_posts', array( $this, 'delete_sticky_posts_cache' ) ); | |
| 31 | - | |
| 32 | 24 | // Filters the comments according to the current language |
| 33 | 25 | add_action( 'parse_comment_query', array( $this, 'parse_comment_query' ) ); |
| 34 | 26 | add_filter( 'comments_clauses', array( $this, 'comments_clauses' ), 10, 2 ); |
| 35 | 27 | |
| @@ -53,9 +45,8 @@ | ||
| 53 | 45 | add_filter( 'email_change_email', array( $this, 'translate_user_email' ) ); |
| 54 | 46 | |
| 55 | 47 | // Translates the privacy policy page |
| 56 | 48 | add_filter( 'option_wp_page_for_privacy_policy', array( $this, 'translate_page_for_privacy_policy' ), 20 ); // Since WP 4.9.6 |
| 57 | - add_filter( 'map_meta_cap', array( $this, 'fix_privacy_policy_page_editing' ), 10, 4 ); | |
| 58 | 49 | |
| 59 | 50 | // Personal data exporter |
| 60 | 51 | add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_personal_data_exporter' ), 0 ); // Since WP 4.9.6 |
| 61 | 52 | } |
| @@ -60,17 +51,8 @@ | ||
| 60 | 51 | add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_personal_data_exporter' ), 0 ); // Since WP 4.9.6 |
| 61 | 52 | } |
| 62 | 53 | |
| 63 | 54 | /** |
| 64 | - * Deletes the cache for multilingual sticky posts. | |
| 65 | - * | |
| 66 | - * @since 2.8.4 | |
| 67 | - */ | |
| 68 | - public function delete_sticky_posts_cache() { | |
| 69 | - wp_cache_delete( 'sticky_posts', 'options' ); | |
| 70 | - } | |
| 71 | - | |
| 72 | - /** | |
| 73 | 55 | * Get the language to filter a comments query |
| 74 | 56 | * |
| 75 | 57 | * @since 2.0 |
| 76 | 58 | * |
| @@ -162,9 +144,9 @@ | ||
| 162 | 144 | if ( ! empty( $args['number'] ) && ! $once ) { |
| 163 | 145 | $once = true; // avoid infinite loop |
| 164 | 146 | |
| 165 | 147 | $r = array( |
| 166 | - 'lang' => 0, // So this query is not filtered | |
| 148 | + 'lang' => 0, // So this query is not filtered | |
| 167 | 149 | 'numberposts' => -1, |
| 168 | 150 | 'nopaging' => true, |
| 169 | 151 | 'post_type' => $args['post_type'], |
| 170 | 152 | 'fields' => 'ids', |
| @@ -245,14 +227,15 @@ | ||
| 245 | 227 | * @param string $output language attributes |
| 246 | 228 | * @return string |
| 247 | 229 | */ |
| 248 | 230 | public function language_attributes( $output ) { |
| 249 | - if ( $language = $this->model->get_language( is_admin() ? get_user_locale() : get_locale() ) ) { | |
| 231 | + if ( $language = $this->model->get_language( get_locale() ) ) { | |
| 250 | 232 | $output = str_replace( '"' . get_bloginfo( 'language' ) . '"', '"' . $language->get_locale( 'display' ) . '"', $output ); |
| 251 | 233 | } |
| 252 | 234 | return $output; |
| 253 | 235 | } |
| 254 | 236 | |
| 237 | + | |
| 255 | 238 | /** |
| 256 | 239 | * Prevents deleting all the translations of the default category |
| 257 | 240 | * |
| 258 | 241 | * @since 2.1 |
| @@ -305,30 +288,8 @@ | ||
| 305 | 288 | return empty( $this->curlang ) ? $id : $this->model->post->get( $id, $this->curlang ); |
| 306 | 289 | } |
| 307 | 290 | |
| 308 | 291 | /** |
| 309 | - * Prevents edit and delete links for the translations of the privacy policy page for non admin | |
| 310 | - * | |
| 311 | - * @since 2.3.7 | |
| 312 | - * | |
| 313 | - * @param array $caps The user's actual capabilities. | |
| 314 | - * @param string $cap Capability name. | |
| 315 | - * @param int $user_id The user ID. | |
| 316 | - * @param array $args Adds the context to the cap. The category id. | |
| 317 | - * @return array | |
| 318 | - */ | |
| 319 | - public function fix_privacy_policy_page_editing( $caps, $cap, $user_id, $args ) { | |
| 320 | - if ( in_array( $cap, array( 'edit_page', 'edit_post', 'delete_page', 'delete_post' ) ) ) { | |
| 321 | - $privacy_page = get_option( 'wp_page_for_privacy_policy' ); | |
| 322 | - if ( $privacy_page && array_intersect( $args, $this->model->post->get_translations( $privacy_page ) ) ) { | |
| 323 | - $caps = array_merge( $caps, map_meta_cap( 'manage_privacy_options', $user_id ) ); | |
| 324 | - } | |
| 325 | - } | |
| 326 | - | |
| 327 | - return $caps; | |
| 328 | - } | |
| 329 | - | |
| 330 | - /** | |
| 331 | 292 | * Register our personal data exporter |
| 332 | 293 | * |
| 333 | 294 | * @since 2.3.6 |
| 334 | 295 | * |
| @@ -351,12 +312,12 @@ | ||
| 351 | 312 | * @param string $email_address User email address |
| 352 | 313 | * @return array Personal data |
| 353 | 314 | */ |
| 354 | 315 | public function user_data_exporter( $email_address ) { |
| 355 | - $email_address = trim( $email_address ); | |
| 356 | - $data_to_export = array(); | |
| 357 | - $user_data_to_export = array(); | |
| 316 | + $email_address = trim( $email_address ); | |
| 358 | 317 | |
| 318 | + $data_to_export = array(); | |
| 319 | + | |
| 359 | 320 | if ( $user = get_user_by( 'email', $email_address ) ) { |
| 360 | 321 | foreach ( $this->model->get_languages_list() as $lang ) { |
| 361 | 322 | if ( $lang->slug !== $this->options['default_lang'] && $value = get_user_meta( $user->ID, 'description_' . $lang->slug, true ) ) { |
| 362 | 323 | $user_data_to_export[] = array( |
| @@ -369,9 +330,9 @@ | ||
| 369 | 330 | |
| 370 | 331 | if ( ! empty( $user_data_to_export ) ) { |
| 371 | 332 | $data_to_export[] = array( |
| 372 | 333 | 'group_id' => 'user', |
| 373 | - 'group_label' => __( 'User', 'polylang' ), | |
| 334 | + 'group_label' => __( 'User' ), | |
| 374 | 335 | 'item_id' => "user-{$user->ID}", |
| 375 | 336 | 'data' => $user_data_to_export, |
| 376 | 337 | ); |
| 377 | 338 | } |