| @@ -25,29 +25,26 @@ | ||
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Writes a PLL_MO object into a custom post meta. | |
| 29 | + * Writes a PLL_MO object into a custom post meta | |
| 30 | 30 | * |
| 31 | 31 | * @since 1.2 |
| 32 | 32 | * |
| 33 | - * @param PLL_Language $lang The language in which we want to export strings. | |
| 34 | - * @return void | |
| 33 | + * @param object $lang The language in which we want to export strings | |
| 35 | 34 | */ |
| 36 | 35 | public function export_to_db( $lang ) { |
| 37 | 36 | $this->add_entry( $this->make_entry( '', '' ) ); // Empty string translation, just in case |
| 38 | 37 | |
| 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 | - */ | |
| 38 | + // Would be convenient to store the whole object but it would take a huge space in DB | |
| 39 | + // So let's keep only the strings in an array | |
| 45 | 40 | $strings = array(); |
| 46 | 41 | foreach ( $this->entries as $entry ) { |
| 47 | - $strings[] = wp_slash( array( $entry->singular, $this->translate( $entry->singular ) ) ); | |
| 42 | + $strings[] = array( $entry->singular, $this->translate( $entry->singular ) ); | |
| 48 | 43 | } |
| 49 | 44 | |
| 45 | + $strings = wp_slash( $strings ); // Avoid breaking slashed strings in update_post_meta. See https://codex.wordpress.org/Function_Reference/update_post_meta#Character_Escaping | |
| 46 | + | |
| 50 | 47 | if ( empty( $lang->mo_id ) ) { |
| 51 | 48 | $post = array( |
| 52 | 49 | 'post_title' => 'polylang_mo_' . $lang->term_id, |
| 53 | 50 | '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 +57,13 @@ | ||
| 60 | 57 | } |
| 61 | 58 | } |
| 62 | 59 | |
| 63 | 60 | /** |
| 64 | - * Reads a PLL_MO object from a custom post meta. | |
| 61 | + * Reads a PLL_MO object from a custom post meta | |
| 65 | 62 | * |
| 66 | 63 | * @since 1.2 |
| 67 | 64 | * |
| 68 | - * @param PLL_Language $lang The language in which we want to get strings. | |
| 69 | - * @return void | |
| 65 | + * @param object $lang The language in which we want to get strings | |
| 70 | 66 | */ |
| 71 | 67 | public function import_from_db( $lang ) { |
| 72 | 68 | if ( ! empty( $lang->mo_id ) ) { |
| 73 | 69 | $strings = get_post_meta( $lang->mo_id, '_pll_strings_translations', true ); |
| @@ -79,13 +75,13 @@ | ||
| 79 | 75 | } |
| 80 | 76 | } |
| 81 | 77 | |
| 82 | 78 | /** |
| 83 | - * Returns the post id of the post storing the strings translations. | |
| 79 | + * Returns the post id of the post storing the strings translations | |
| 84 | 80 | * |
| 85 | 81 | * @since 1.4 |
| 86 | 82 | * |
| 87 | - * @param PLL_Language $lang The language object. | |
| 83 | + * @param object $lang | |
| 88 | 84 | * @return int |
| 89 | 85 | */ |
| 90 | 86 | public static function get_id( $lang ) { |
| 91 | 87 | global $wpdb; |
| @@ -104,10 +100,8 @@ | ||
| 104 | 100 | /** |
| 105 | 101 | * Invalidate the cache when adding a new language |
| 106 | 102 | * |
| 107 | 103 | * @since 2.0.5 |
| 108 | - * | |
| 109 | - * @return void | |
| 110 | 104 | */ |
| 111 | 105 | public function clean_cache() { |
| 112 | 106 | wp_cache_delete( 'polylang_mo_ids' ); |
| 113 | 107 | } |
| @@ -117,9 +111,8 @@ | ||
| 117 | 111 | * |
| 118 | 112 | * @since 2.9 |
| 119 | 113 | * |
| 120 | 114 | * @param string $string The source string to remove from the translations. |
| 121 | - * @return void | |
| 122 | 115 | */ |
| 123 | 116 | public function delete_entry( $string ) { |
| 124 | 117 | unset( $this->entries[ $string ] ); |
| 125 | 118 | } |