PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
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/language.php +10 -23 2.7.42.6.2 View file →
@@ -101,9 +101,9 @@
101 101 * @param string $code Flag code.
102 102 * @return array Flag informations.
103 103 */
104 104 public static function get_flag_informations( $code ) {
105 - $flag = array( 'url' => '' );
105 + $flag['url'] = '';
106 106
107 107 // Polylang builtin flags
108 108 if ( ! empty( $code ) && file_exists( POLYLANG_DIR . ( $file = '/flags/' . $code . '.png' ) ) ) {
109 109 $flag['url'] = $_url = plugins_url( $file, POLYLANG_FILE );
@@ -144,9 +144,9 @@
144 144 *
145 145 * @since 1.2
146 146 */
147 147 public function set_flag() {
148 - $flags = array( 'flag' => self::get_flag_informations( $this->flag_code ) );
148 + $flags['flag'] = self::get_flag_informations( $this->flag_code );
149 149
150 150 // Custom flags ?
151 151 $directories = array(
152 152 PLL_LOCAL_DIR,
@@ -209,32 +209,19 @@
209 209 * @param string $slug language code
210 210 */
211 211 $this->{$key} = apply_filters(
212 212 'pll_get_flag',
213 - self::get_flag_html( $flag, $title, $this->name ),
213 + empty( $flag['src'] ) ? '' : sprintf(
214 + '<img src="%s" title="%s" alt="%s"%s%s />',
215 + $flag['src'],
216 + esc_attr( $title ),
217 + esc_attr( $this->name ),
218 + empty( $flag['width'] ) ? '' : sprintf( ' width="%s"', (int) $flag['width'] ),
219 + empty( $flag['height'] ) ? '' : sprintf( ' height="%s"', (int) $flag['height'] )
220 + ),
214 221 $this->slug
215 222 );
216 223 }
217 - }
218 -
219 - /**
220 - * Get HTML code for flag
221 - *
222 - * @since 2.7
223 - *
224 - * @param array $flag flag properties: src, width and height
225 - * @param string $title optional title attribute
226 - * @param string $alt optional alt attribute
227 - */
228 - public static function get_flag_html( $flag, $title = '', $alt = '' ) {
229 - return empty( $flag['src'] ) ? '' : sprintf(
230 - '<img src="%s"%s%s%s%s />',
231 - $flag['src'],
232 - empty( $title ) ? '' : sprintf( ' title="%s"', esc_attr( $title ) ),
233 - empty( $alt ) ? '' : sprintf( ' alt="%s"', esc_attr( $alt ) ),
234 - empty( $flag['width'] ) ? '' : sprintf( ' width="%s"', (int) $flag['width'] ),
235 - empty( $flag['height'] ) ? '' : sprintf( ' height="%s"', (int) $flag['height'] )
236 - );
237 224 }
238 225
239 226 /**
240 227 * Replace flag by custom flag