PluginProbe
Polylang / 2.1
Polylang v2.1
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | include/mo.php +9 -32 3.02.1 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,27 +22,22 @@
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
50 42 if ( empty( $lang->mo_id ) ) {
51 43 $post = array(
@@ -60,14 +52,13 @@
60 52 }
61 53 }
62 54
63 55 /**
64 - * Reads a PLL_MO object from a custom post meta.
56 + * Reads a PLL_MO object from a custom post meta
65 57 *
66 58 * @since 1.2
67 59 *
68 - * @param PLL_Language $lang The language in which we want to get strings.
69 - * @return void
60 + * @param object $lang The language in which we want to get strings
70 61 */
71 62 public function import_from_db( $lang ) {
72 63 if ( ! empty( $lang->mo_id ) ) {
73 64 $strings = get_post_meta( $lang->mo_id, '_pll_strings_translations', true );
@@ -79,13 +70,13 @@
79 70 }
80 71 }
81 72
82 73 /**
83 - * Returns the post id of the post storing the strings translations.
74 + * Returns the post id of the post storing the strings translations
84 75 *
85 76 * @since 1.4
86 77 *
87 - * @param PLL_Language $lang The language object.
78 + * @param object $lang
88 79 * @return int
89 80 */
90 81 public static function get_id( $lang ) {
91 82 global $wpdb;
@@ -104,23 +95,9 @@
104 95 /**
105 96 * Invalidate the cache when adding a new language
106 97 *
107 98 * @since 2.0.5
108 - *
109 - * @return void
110 99 */
111 100 public function clean_cache() {
112 101 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 102 }
126 103 }