st_id ) ); $string_value = $data->value; $string_type = $wpdb->get_var( $wpdb->prepare( "SELECT type FROM {$wpdb->prefix}icl_strings WHERE id=%d", $data->string_id ) ); if ( 'LINK' === $string_type ) { $string_value_up = $this->convert_url( $string_value, $data->language ); } else { $string_value_up = $this->convert_text( $string_value ); } if ( $string_value_up !== $string_value ) { $wpdb->update( $table, [ 'value' => $string_value_up, 'status' => ICL_STRING_TRANSLATION_COMPLETE, ], [ 'id' => $st_id ] ); } } } public function process_post( $post_id ) { global $wpdb, $sitepress; delete_post_meta( $post_id, '_alp_broken_links' ); $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->posts} WHERE ID = %s", $post_id ) ); $this_post_language = $sitepress->get_language_for_element( $post_id, 'post_' . $post->post_type ); $current_language = $sitepress->get_current_language(); $sitepress->switch_lang( $this_post_language ); $post_content = $this->convert_text( $post->post_content ); $sitepress->switch_lang( $current_language ); if ( $post_content !== $post->post_content ) { $wpdb->update( $wpdb->posts, [ 'post_content' => $post_content ], [ 'ID' => $post_id ] ); } update_post_meta( $post_id, '_alp_processed', time() ); } public function convert_text( $text ) { $alp_broken_links = []; return $this->_process_generic_text( $text, $alp_broken_links ); } public function convert_url( $url, $lang = null ) { global $sitepress; if ( $this->is_home( $url ) ) { $absolute_url = $sitepress->convert_url( $url, $lang ); } else { $html = 'removeit'; $html = $this->convert_text( $html ); $absolute_url = str_replace( [ 'removeit' ], [ '', '' ], $html ); } return $absolute_url; } public function is_home( $url ) { return untrailingslashit( get_home_url() ) === untrailingslashit( $url ); } /** * Check if the link is the pagination inside the post. * * @param string $url * @param string $post_name * * @return bool */ private function is_pagination_in_post( $url, $post_name ) { $is_pagination_url_in_post = false !== mb_strpos( $url, $post_name . '/page/' ); /** * Check if the given URL is the pagination inside the post. * * @param bool $is_pagination_url_in_post * @param string $url * @param string $post_name */ return apply_filters( 'wpml_is_pagination_url_in_post', $is_pagination_url_in_post, $url, $post_name ); } }