PluginProbe
Polylang / 2.3.6
Polylang v2.3.6
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/mo.php +11 -32 3.0.22.3.6 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Manages strings translations storage
8 5 *
@@ -25,29 +22,26 @@
25 22 }
26 23 }
27 24
28 25 /**
29 - * Writes a PLL_MO object into a custom post meta.
26 + * Writes a PLL_MO object into a custom post meta
30 27 *
31 28 * @since 1.2
32 29 *
33 - * @param PLL_Language $lang The language in which we want to export strings.
34 - * @return void
30 + * @param object $lang The language in which we want to export strings
35 31 */
36 32 public function export_to_db( $lang ) {
37 33 $this->add_entry( $this->make_entry( '', '' ) ); // Empty string translation, just in case
38 34
39 - /*
40 - * It would be convenient to store the whole object but it would take a huge space in DB.
41 - * So let's keep only the strings in an array.
42 - * The strings are slashed to avoid breaking slashed strings in update_post_meta.
43 - * @see https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping.
44 - */
35 + // Would be convenient to store the whole object but it would take a huge space in DB
36 + // So let's keep only the strings in an array
45 37 $strings = array();
46 38 foreach ( $this->entries as $entry ) {
47 - $strings[] = wp_slash( array( $entry->singular, $this->translate( $entry->singular ) ) );
39 + $strings[] = array( $entry->singular, $this->translate( $entry->singular ) );
48 40 }
49 41
42 + $strings = wp_slash( $strings ); // Avoid breaking slashed strings in update_post_meta. See https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping
43 +
50 44 if ( empty( $lang->mo_id ) ) {
51 45 $post = array(
52 46 'post_title' => 'polylang_mo_' . $lang->term_id,
53 47 'post_status' => 'private', // To avoid a conflict with WP Super Cache. See https://wordpress.org/support/topic/polylang_mo-and-404s-take-2
@@ -60,14 +54,13 @@
60 54 }
61 55 }
62 56
63 57 /**
64 - * Reads a PLL_MO object from a custom post meta.
58 + * Reads a PLL_MO object from a custom post meta
65 59 *
66 60 * @since 1.2
67 61 *
68 - * @param PLL_Language $lang The language in which we want to get strings.
69 - * @return void
62 + * @param object $lang The language in which we want to get strings
70 63 */
71 64 public function import_from_db( $lang ) {
72 65 if ( ! empty( $lang->mo_id ) ) {
73 66 $strings = get_post_meta( $lang->mo_id, '_pll_strings_translations', true );
@@ -79,13 +72,13 @@
79 72 }
80 73 }
81 74
82 75 /**
83 - * Returns the post id of the post storing the strings translations.
76 + * Returns the post id of the post storing the strings translations
84 77 *
85 78 * @since 1.4
86 79 *
87 - * @param PLL_Language $lang The language object.
80 + * @param object $lang
88 81 * @return int
89 82 */
90 83 public static function get_id( $lang ) {
91 84 global $wpdb;
@@ -104,23 +97,9 @@
104 97 /**
105 98 * Invalidate the cache when adding a new language
106 99 *
107 100 * @since 2.0.5
108 - *
109 - * @return void
110 101 */
111 102 public function clean_cache() {
112 103 wp_cache_delete( 'polylang_mo_ids' );
113 - }
114 -
115 - /**
116 - * Deletes a string
117 - *
118 - * @since 2.9
119 - *
120 - * @param string $string The source string to remove from the translations.
121 - * @return void
122 - */
123 - public function delete_entry( $string ) {
124 - unset( $this->entries[ $string ] );
125 104 }
126 105 }