Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/jetpack/3rd-part...
File: wpml.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Only load these if WPML plugin is installed and active.
[2] Fix | Delete
*
[3] Fix | Delete
* @package automattic/jetpack
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[7] Fix | Delete
exit( 0 );
[8] Fix | Delete
}
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Load routines only if WPML is loaded.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 4.4.0
[14] Fix | Delete
*/
[15] Fix | Delete
function wpml_jetpack_init() {
[16] Fix | Delete
add_action( 'jetpack_widget_get_top_posts', 'wpml_jetpack_widget_get_top_posts', 10, 3 );
[17] Fix | Delete
add_filter( 'grunion_contact_form_field_html', 'grunion_contact_form_field_html_filter', 10, 3 );
[18] Fix | Delete
}
[19] Fix | Delete
add_action( 'wpml_loaded', 'wpml_jetpack_init' );
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* Filter the Top Posts and Pages by language.
[23] Fix | Delete
*
[24] Fix | Delete
* @param array $posts Array of the most popular posts.
[25] Fix | Delete
*
[26] Fix | Delete
* @return array
[27] Fix | Delete
*/
[28] Fix | Delete
function wpml_jetpack_widget_get_top_posts( $posts ) {
[29] Fix | Delete
global $sitepress;
[30] Fix | Delete
[31] Fix | Delete
foreach ( $posts as $k => $post ) {
[32] Fix | Delete
$lang_information = wpml_get_language_information( $post['post_id'] );
[33] Fix | Delete
if ( ! is_wp_error( $lang_information ) ) {
[34] Fix | Delete
$post_language = substr( $lang_information['locale'], 0, 2 );
[35] Fix | Delete
if ( $post_language !== $sitepress->get_current_language() ) {
[36] Fix | Delete
unset( $posts[ $k ] );
[37] Fix | Delete
}
[38] Fix | Delete
}
[39] Fix | Delete
}
[40] Fix | Delete
[41] Fix | Delete
return $posts;
[42] Fix | Delete
}
[43] Fix | Delete
[44] Fix | Delete
/**
[45] Fix | Delete
* Filter the HTML of the Contact Form and output the one requested by language.
[46] Fix | Delete
*
[47] Fix | Delete
* @param string $r Contact Form HTML output.
[48] Fix | Delete
* @param string $field_label Field label.
[49] Fix | Delete
*
[50] Fix | Delete
* @return string
[51] Fix | Delete
*/
[52] Fix | Delete
function grunion_contact_form_field_html_filter( $r, $field_label ) {
[53] Fix | Delete
global $sitepress;
[54] Fix | Delete
[55] Fix | Delete
if ( function_exists( 'icl_translate' ) ) {
[56] Fix | Delete
if ( $sitepress->get_current_language() !== $sitepress->get_default_language() ) {
[57] Fix | Delete
$label_translation = icl_translate( 'jetpack ', $field_label . '_label', $field_label );
[58] Fix | Delete
$r = str_replace( $field_label, $label_translation, $r );
[59] Fix | Delete
}
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
return $r;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function