Completed
Push — fix/normalize-www-in-site-url-... ( e67e76 )
by
unknown
13:13 queued 02:59
created

wpml.php ➔ wpml_jetpack_widget_get_top_posts()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 8
nc 3
nop 3
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
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 ) {
0 ignored issues
show
Unused Code introduced by
The parameter $post_ids is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $count is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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 ){
0 ignored issues
show
Unused Code introduced by
The parameter $id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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
Consider using a different name than the parameter $r. This often makes code more readable.
Loading history...
29
		}
30
	}
31
32
	return $r;
33
}
34
35
endif;
36