Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | // Only load these if WPML is active. |
||
| 4 | if ( defined( 'ICL_SITEPRESS_VERSION' ) ) : |
||
| 5 | |||
| 6 | add_action( 'jetpack_widget_get_top_posts', 'wpml_jetpack_widget_get_top_posts', 10, 3 ); |
||
| 7 | function wpml_jetpack_widget_get_top_posts( $posts, $post_ids, $count ) { |
||
| 8 | global $sitepress; |
||
| 9 | |||
| 10 | foreach ( $posts as $k => $post ) { |
||
| 11 | $lang_information = wpml_get_language_information( $post['post_id'] ); |
||
| 12 | $post_language = substr( $lang_information['locale'], 0, 2 ); |
||
| 13 | if ( $post_language !== $sitepress->get_current_language() ) { |
||
| 14 | unset( $posts[ $k ] ); |
||
| 15 | } |
||
| 16 | } |
||
| 17 | |||
| 18 | return $posts; |
||
| 19 | } |
||
| 20 | |||
| 21 | add_filter( 'grunion_contact_form_field_html', 'grunion_contact_form_field_html_filter', 10, 3 ); |
||
| 22 | function grunion_contact_form_field_html_filter( $r, $field_label, $id ){ |
||
| 23 | global $sitepress; |
||
| 24 | |||
| 25 | if ( function_exists( 'icl_translate' ) ) { |
||
| 26 | if ( $sitepress->get_current_language() !== $sitepress->get_default_language() ) { |
||
| 27 | $label_translation = icl_translate( 'jetpack ', $field_label . '_label', $field_label ); |
||
| 28 | $r = str_replace( $field_label, $label_translation, $r ); |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 29 | } |
||
| 30 | } |
||
| 31 | |||
| 32 | return $r; |
||
| 33 | } |
||
| 34 | |||
| 35 | endif; |
||
| 36 |