From 52805c21f53e976d2b840ebdaff77f22a9124e82 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Thu, 30 Jan 2025 17:31:53 +0530 Subject: [PATCH 1/4] Remove rop_wpml_lang filter --- .../admin/models/class-rop-posts-selector-model.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/includes/admin/models/class-rop-posts-selector-model.php b/includes/admin/models/class-rop-posts-selector-model.php index a62921b7..129e8395 100644 --- a/includes/admin/models/class-rop-posts-selector-model.php +++ b/includes/admin/models/class-rop-posts-selector-model.php @@ -777,14 +777,10 @@ public function rop_wpml_id( $post_id, $account_id = '' ) { $post_format_model = new Rop_Post_Format_Model(); $rop_account_post_format = $post_format_model->get_post_format( $account_id ); // If no language set, use default WPML language - $rop_account_lang_code = ! empty( $rop_account_post_format['wpml_language'] ) ? $rop_account_post_format['wpml_language'] : $default_lang; + $lang_code = ! empty( $rop_account_post_format['wpml_language'] ) ? $rop_account_post_format['wpml_language'] : $default_lang; } - if ( ! empty( $rop_account_lang_code ) ) { - $lang_code = apply_filters( 'rop_wpml_lang', $rop_account_lang_code ); - } - if ( is_array( $post_id ) ) { $post = array(); @@ -842,12 +838,8 @@ public function rop_wpml_link( $url, $account_id ) { $post_format_model = new Rop_Post_Format_Model(); $rop_account_post_format = $post_format_model->get_post_format( $account_id ); // If no language set, use default WPML language - $rop_account_lang_code = ! empty( $rop_account_post_format['wpml_language'] ) ? $rop_account_post_format['wpml_language'] : $default_lang; - - } + $lang_code = ! empty( $rop_account_post_format['wpml_language'] ) ? $rop_account_post_format['wpml_language'] : $default_lang; - if ( ! empty( $rop_account_lang_code ) ) { - $lang_code = apply_filters( 'rop_wpml_lang', $rop_account_lang_code ); } $wpml_url = apply_filters( 'wpml_permalink', $url, $lang_code ); From c7276868c72c595ccdbbd49a95ca514f39c75132 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Thu, 30 Jan 2025 18:59:44 +0530 Subject: [PATCH 2/4] Add compatibility TranslatePress plugin --- includes/admin/class-rop-admin.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/includes/admin/class-rop-admin.php b/includes/admin/class-rop-admin.php index 0dce1cbf..823fd734 100644 --- a/includes/admin/class-rop-admin.php +++ b/includes/admin/class-rop-admin.php @@ -1537,7 +1537,7 @@ private function rop_hide_add_own_app_option() { */ public function rop_get_wpml_active_status() { - if ( function_exists( 'icl_object_id' ) ) { + if ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) { return true; } else { return false; @@ -1572,17 +1572,26 @@ public function rop_get_yoast_seo_active_status() { public function rop_get_wpml_languages() { if ( $this->rop_get_wpml_active_status() === false ) { - return; + return; } $wpml_active_languages = apply_filters( 'wpml_active_languages', null, array('skip_missing' => 1) ); + // Get TranslatePress publish plugin languages. + if ( empty( $wpml_active_languages ) && class_exists( 'TRP_Translate_Press' ) ) { + $trp_settings = TRP_Translate_Press::get_trp_instance()->get_component( 'settings' )->get_settings(); + if ( $trp_settings ) { + $trp_languages = TRP_Translate_Press::get_trp_instance()->get_component( 'languages' ); + $publish_languages = ! empty( $trp_settings['publish-languages'] ) ? $trp_settings['publish-languages'] : array(); + $wpml_active_languages = $trp_languages->get_language_names( $publish_languages, 'english_name' ); + } + } $languages_array = array(); foreach ( $wpml_active_languages as $key => $value ) { - $languages_array[] = array( 'code' => $key, 'label' => $value['native_name'] ); + $key = false !== strpos( $key, '_' ) ? substr( $key, 0, strpos( $key, '_' ) ) : $key; + $languages_array[] = array( 'code' => $key, 'label' => isset( $value['native_name'] ) ? $value['native_name'] : $value ); } - return $languages_array; } From b5989fab056c8a4c6c39999f56fa011e831f7676 Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 31 Jan 2025 11:09:42 +0530 Subject: [PATCH 3/4] fix: review feedback --- includes/admin/class-rop-admin.php | 43 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/includes/admin/class-rop-admin.php b/includes/admin/class-rop-admin.php index 823fd734..d4bf56b3 100644 --- a/includes/admin/class-rop-admin.php +++ b/includes/admin/class-rop-admin.php @@ -1575,22 +1575,11 @@ public function rop_get_wpml_languages() { return; } - $wpml_active_languages = apply_filters( 'wpml_active_languages', null, array('skip_missing' => 1) ); - - // Get TranslatePress publish plugin languages. - if ( empty( $wpml_active_languages ) && class_exists( 'TRP_Translate_Press' ) ) { - $trp_settings = TRP_Translate_Press::get_trp_instance()->get_component( 'settings' )->get_settings(); - if ( $trp_settings ) { - $trp_languages = TRP_Translate_Press::get_trp_instance()->get_component( 'languages' ); - $publish_languages = ! empty( $trp_settings['publish-languages'] ) ? $trp_settings['publish-languages'] : array(); - $wpml_active_languages = $trp_languages->get_language_names( $publish_languages, 'english_name' ); - } - } + $languages = $this->get_languages(); $languages_array = array(); - foreach ( $wpml_active_languages as $key => $value ) { - $key = false !== strpos( $key, '_' ) ? substr( $key, 0, strpos( $key, '_' ) ) : $key; - $languages_array[] = array( 'code' => $key, 'label' => isset( $value['native_name'] ) ? $value['native_name'] : $value ); + foreach ( $languages as $key => $value ) { + $languages_array[] = array( 'code' => $key, 'label' => $value['native_name'] ); } return $languages_array; } @@ -1821,4 +1810,30 @@ public function rop_upgrade_to_pro_plugin_action( $actions, $plugin_file ) { return $actions; } + + /** + * Get available languages. + * + * @return array + */ + public function get_languages() { + // Get TranslatePress publish plugin languages. + if ( class_exists( 'TRP_Translate_Press' ) ) { + $trp_settings = TRP_Translate_Press::get_trp_instance()->get_component( 'settings' )->get_settings(); + if ( $trp_settings ) { + $trp_languages = TRP_Translate_Press::get_trp_instance()->get_component( 'languages' ); + $publish_languages = ! empty( $trp_settings['publish-languages'] ) ? $trp_settings['publish-languages'] : array(); + $publish_languages = $trp_languages->get_language_names( $publish_languages, 'native_name' ); + $languages = array(); + foreach ( $publish_languages as $key => $publish_language ) { + $key = false !== strpos( $key, '_' ) ? substr( $key, 0, strpos( $key, '_' ) ) : $key; + $languages[ $key ] = array( + 'native_name' => $publish_language, + ); + } + return $languages; + } + } + return apply_filters( 'wpml_active_languages', null, array( 'skip_missing' => 1 ) ); + } } From f225afa44ac328f157ee2f1a30a366a86e66024d Mon Sep 17 00:00:00 2001 From: girishpanchal30 Date: Fri, 31 Jan 2025 16:03:25 +0530 Subject: [PATCH 4/4] feat: share translated content --- includes/admin/class-rop-admin.php | 11 ++- .../helpers/class-rop-post-format-helper.php | 35 ++++++- .../models/class-rop-posts-selector-model.php | 94 +++++++++++++++---- .../services/class-rop-facebook-service.php | 4 +- .../admin/services/class-rop-gmb-service.php | 2 +- .../services/class-rop-pinterest-service.php | 6 +- .../services/class-rop-tumblr-service.php | 4 +- .../services/class-rop-twitter-service.php | 2 +- .../admin/services/class-rop-vk-service.php | 4 +- .../services/class-rop-webhook-service.php | 2 +- 10 files changed, 125 insertions(+), 39 deletions(-) diff --git a/includes/admin/class-rop-admin.php b/includes/admin/class-rop-admin.php index d4bf56b3..9ed69af4 100644 --- a/includes/admin/class-rop-admin.php +++ b/includes/admin/class-rop-admin.php @@ -1603,7 +1603,10 @@ public function rop_wpml_filter_accounts( $post_id, $share_to_accounts ) { $post_format_model = new Rop_Post_Format_Model(); $filtered_share_to_accounts = array(); - $post_lang_code = apply_filters( 'wpml_post_language_details', '', $post_id )['language_code']; + $post_lang_code = ''; + if ( function_exists( 'icl_object_id' ) ) { + $post_lang_code = apply_filters( 'wpml_post_language_details', '', $post_id )['language_code']; + } foreach ( $share_to_accounts as $account_id ) { @@ -1614,8 +1617,9 @@ public function rop_wpml_filter_accounts( $post_id, $share_to_accounts ) { }; $rop_account_lang_code = $rop_account_post_format['wpml_language']; - - if ( $post_lang_code === $rop_account_lang_code ) { + if ( class_exists( 'TRP_Translate_Press' ) ) { + $filtered_share_to_accounts[] = $account_id; + } elseif ( $post_lang_code === $rop_account_lang_code ) { $filtered_share_to_accounts[] = $account_id; } } @@ -1826,7 +1830,6 @@ public function get_languages() { $publish_languages = $trp_languages->get_language_names( $publish_languages, 'native_name' ); $languages = array(); foreach ( $publish_languages as $key => $publish_language ) { - $key = false !== strpos( $key, '_' ) ? substr( $key, 0, strpos( $key, '_' ) ) : $key; $languages[ $key ] = array( 'native_name' => $publish_language, ); diff --git a/includes/admin/helpers/class-rop-post-format-helper.php b/includes/admin/helpers/class-rop-post-format-helper.php index 0590d95b..bffaeacc 100644 --- a/includes/admin/helpers/class-rop-post-format-helper.php +++ b/includes/admin/helpers/class-rop-post-format-helper.php @@ -69,7 +69,7 @@ public function get_formated_object( $post_id, $account_id = 0 ) { } } - if ( function_exists( 'icl_object_id' ) ) { + if ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) { $selector = new Rop_Posts_Selector_Model; $post_id = $selector->rop_wpml_id( $post_id, $this->account_id ); } @@ -78,7 +78,7 @@ public function get_formated_object( $post_id, $account_id = 0 ) { $content = $this->build_content( $post_id ); $filtered_post = array(); $filtered_post['post_id'] = $post_id; - $filtered_post['title'] = html_entity_decode( get_the_title( $post_id ) ); + $filtered_post['title'] = html_entity_decode( $this->get_translate_content( get_the_title( $post_id ) ) ); $filtered_post['account_id'] = $this->account_id; $filtered_post['service'] = $service; $filtered_post['content'] = apply_filters( 'rop_content_filter', $content['display_content'], $post_id, $account_id, $service ); @@ -289,10 +289,10 @@ public function build_content( $post_id ) { */ private function build_base_content( $post_id ) { - $post_title = apply_filters( 'rop_share_post_title', get_the_title( $post_id ), $post_id ); + $post_title = apply_filters( 'rop_share_post_title', $this->get_translate_content( get_the_title( $post_id ) ), $post_id ); $post_title = html_entity_decode( $post_title ); - $post_content = apply_filters( 'rop_share_post_content', get_post_field( 'post_content', $post_id ), $post_id ); + $post_content = apply_filters( 'rop_share_post_content', $this->get_translate_content( get_post_field( 'post_content', $post_id ) ), $post_id ); $content = ''; $post_format = $this->post_format['post_content']; @@ -322,9 +322,11 @@ private function build_base_content( $post_id ) { } else { $content = $post_content; } + $content = $this->get_translate_content( $content ); break; case 'custom_field': $content = $this->get_custom_field_value( $post_id, $this->post_format['custom_meta_field'] ); + $content = $this->get_translate_content( $content ); break; case 'custom_content': $content = ''; @@ -336,6 +338,7 @@ private function build_base_content( $post_id ) { } else { $content = $post_title; } + $content = $this->get_translate_content( $content ); break; case 'yoast_seo_description': if ( function_exists( 'YoastSEO' ) ) { @@ -348,6 +351,7 @@ private function build_base_content( $post_id ) { if ( empty( $content ) ) { $content = $post_content; } + $content = $this->get_translate_content( $content ); break; case 'yoast_seo_title_description': if ( function_exists( 'YoastSEO' ) ) { @@ -364,6 +368,7 @@ private function build_base_content( $post_id ) { } else { $content = $post_title . apply_filters( 'rop_title_content_separator', ' ' ) . $post_content; } + $content = $this->get_translate_content( $content ); break; default: $content = $post_title; @@ -839,7 +844,7 @@ public function build_url( $post_id ) { } // WPML compatibility - if ( function_exists( 'icl_object_id' ) ) { + if ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) { $selector = new Rop_Posts_Selector_Model; $post_url = $selector->rop_wpml_link( $post_url, $this->account_id ); } @@ -1074,4 +1079,24 @@ public function remove_divi_shortcodes( $content ) { return $content; } + /** + * Get translated content if TranslatePress plugin is activated. + * + * @param string $content Orignal content. + * + * @return string + */ + private function get_translate_content( $content ) { + if ( ! class_exists( 'TRP_Translate_Press' ) || empty( $this->post_format['wpml_language'] ) ) { + return $content; + } + + trp_switch_language( $this->post_format['wpml_language'] ); + + $trp = TRP_Translate_Press::get_trp_instance(); + $languages = $trp->get_component( 'languages' ); + $translation_render = $trp->get_component( 'translation_render' ); + return $translation_render->translate_page( $content ); + } + } diff --git a/includes/admin/models/class-rop-posts-selector-model.php b/includes/admin/models/class-rop-posts-selector-model.php index 129e8395..ff6320f0 100644 --- a/includes/admin/models/class-rop-posts-selector-model.php +++ b/includes/admin/models/class-rop-posts-selector-model.php @@ -89,17 +89,17 @@ public function get_taxonomies( $data = array() ) { $taxonomies = array(); - $wpml_current_lang = apply_filters( 'wpml_current_language', null ); + $wpml_current_lang = $this->get_current_language(); - if ( function_exists( 'icl_object_id' ) && ! empty( $language_code ) ) { + if ( ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) && ! empty( $language_code ) ) { // changes the language of global query to use the specfied language - do_action( 'wpml_switch_language', $language_code ); + $this->switch_language( $language_code ); } // Here We are refreshing the taxonomies "on page load" // This method fires whenever the post format page is brought into view. // We're refreshing the taxonomies based on whether that first account has a language assigned or not - if ( function_exists( 'icl_object_id' ) && empty( $language_code ) ) { + if ( ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) && empty( $language_code ) ) { // check the first active account and it's post format and see if it has a language code. $first_account_id = array_keys( $this->data['active_accounts'] )[0]; $post_format_model = new Rop_Post_Format_Model; @@ -108,7 +108,7 @@ public function get_taxonomies( $data = array() ) { if ( ! empty( $first_account_lang ) ) { // changes the language of global query to use the specfied language - do_action( 'wpml_switch_language', $first_account_lang ); + $this->switch_language( $first_account_lang ); } } @@ -154,9 +154,9 @@ public function get_taxonomies( $data = array() ) { } } - if ( function_exists( 'icl_object_id' ) && ! ( empty( $language_code ) && empty( $first_account_lang ) ) ) { + if ( ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) && ! ( empty( $language_code ) && empty( $first_account_lang ) ) ) { // set language back to original - do_action( 'wpml_switch_language', $wpml_current_lang ); + $this->switch_language( $wpml_current_lang ); } if ( empty( $taxonomies ) ) { @@ -351,10 +351,10 @@ public function select( $account_id = false ) { $post_format_model = new Rop_Post_Format_Model( $service ); $post_format = $post_format_model->get_post_format( $account_id ); - if ( function_exists( 'icl_object_id' ) && ! empty( $post_format['wpml_language'] ) ) { - $wpml_current_lang = apply_filters( 'wpml_current_language', null ); - // changes the language of global query to use the specfied language for the account - do_action( 'wpml_switch_language', $post_format['wpml_language'] ); + if ( ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) && ! empty( $post_format['wpml_language'] ) ) { + $wpml_current_lang = $this->get_current_language(); + // changes the language of global query to use the specfied language for the account. + $this->switch_language( $post_format['wpml_language'] ); } $custom_data = array(); @@ -430,9 +430,9 @@ public function select( $account_id = false ) { $this->selection = $results; - if ( function_exists( 'icl_object_id' ) && ! empty( $post_format['wpml_language'] ) ) { - // Sets WP language back to what user set it. - do_action( 'wpml_switch_language', $wpml_current_lang ); + if ( ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) && ! empty( $post_format['wpml_language'] ) ) { + // Sets WP language back to what user set it. + $this->switch_language( $wpml_current_lang ); } return $results; @@ -490,7 +490,7 @@ private function query_results( $account_id, $post_types, $tax_queries, $exclude */ $posts = array_values( $posts ); - if ( function_exists( 'icl_object_id' ) ) { + if ( function_exists( 'icl_object_id' ) || class_exists( 'TRP_Translate_Press' ) ) { $posts = $this->rop_wpml_id( $posts, $account_id ); } @@ -767,7 +767,7 @@ public function get_publish_now_posts() { */ public function rop_wpml_id( $post_id, $account_id = '' ) { - $default_lang = apply_filters( 'wpml_default_language', null ); + $default_lang = $this->get_default_language(); $lang_code = ''; $post = $post_id; @@ -830,7 +830,7 @@ public function rop_wpml_id( $post_id, $account_id = '' ) { */ public function rop_wpml_link( $url, $account_id ) { - $default_lang = apply_filters( 'wpml_default_language', null ); + $default_lang = $this->get_default_language(); $lang_code = ''; if ( ! empty( $account_id ) ) { @@ -842,8 +842,66 @@ public function rop_wpml_link( $url, $account_id ) { } - $wpml_url = apply_filters( 'wpml_permalink', $url, $lang_code ); + $wpml_url = $this->converter_permalink( $url, $lang_code ); return $wpml_url; } + + /** + * Get default language. + * + * @return string + */ + public function get_default_language() { + if ( class_exists( 'TRP_Translate_Press' ) ) { + $trp_settings = TRP_Translate_Press::get_trp_instance()->get_component( 'settings' )->get_settings(); + $default_language = isset( $trp_settings['default-language'] ) ? $trp_settings['default-language'] : ''; + return $default_language; + } + return apply_filters( 'wpml_default_language', null ); + } + + /** + * Converter post permalink using language code. + * + * @param string $url Post URL. + * @param string $lang_code Language code. + * + * @return string + */ + public function converter_permalink( $url, $lang_code ) { + if ( class_exists( 'TRP_Translate_Press' ) ) { + $url_converter = TRP_Translate_Press::get_trp_instance()->get_component( 'url_converter' ); + return $url_converter->get_url_for_language( $lang_code, $url ); + } + return apply_filters( 'wpml_permalink', $url, $lang_code ); + } + + /** + * Get current language code. + * + * @return string + */ + public function get_current_language() { + if ( class_exists( 'TRP_Translate_Press' ) ) { + global $TRP_LANGUAGE; + return $TRP_LANGUAGE; + } + return apply_filters( 'wpml_current_language', null ); + } + + /** + * Language Switch. + * + * @param string $language_code Language code. + * + * @return void + */ + public function switch_language( $language_code ) { + if ( class_exists( 'TRP_Translate_Press' ) ) { + trp_switch_language( $language_code ); + } else { + do_action( 'wpml_switch_language', $language_code ); + } + } } diff --git a/includes/admin/services/class-rop-facebook-service.php b/includes/admin/services/class-rop-facebook-service.php index 6591bdd2..fe6a80cc 100644 --- a/includes/admin/services/class-rop-facebook-service.php +++ b/includes/admin/services/class-rop-facebook-service.php @@ -543,7 +543,7 @@ public function share( $post_details, $args = array() ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on %s ', - html_entity_decode( get_the_title( $post_id ), ENT_QUOTES ), // TODO Set ENT_QUOTES for all other entity decode occurences in plugin + html_entity_decode( $post_details['title'], ENT_QUOTES ), // TODO Set ENT_QUOTES for all other entity decode occurences in plugin $args['user'], $post_details['service'] ) @@ -635,7 +635,7 @@ private function fb_video_post( $post_details, $hashtags ) { $image = $this->get_path_by_url( $post_details['post_image'], $post_details['mimetype'] ); $new_post['source'] = $image; // $new_post['source'] = $api->videoToUpload( $image ); - $new_post['title'] = html_entity_decode( get_the_title( $post_details['post_id'] ), ENT_QUOTES ); + $new_post['title'] = html_entity_decode( $post_details['title'], ENT_QUOTES ); $post_url = empty( $this->share_link_text ) ? $this->get_url( $post_details ) : ''; $new_post['description'] = $post_details['content'] . $post_url . $hashtags; diff --git a/includes/admin/services/class-rop-gmb-service.php b/includes/admin/services/class-rop-gmb-service.php index 90af9f13..55afdfb2 100644 --- a/includes/admin/services/class-rop-gmb-service.php +++ b/includes/admin/services/class-rop-gmb-service.php @@ -524,7 +524,7 @@ public function share( $post_details, $args = array() ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on Google My Business ', - html_entity_decode( get_the_title( $post_details['post_id'] ) ), + html_entity_decode( $post_details['title'] ), $args['user'] ) ); diff --git a/includes/admin/services/class-rop-pinterest-service.php b/includes/admin/services/class-rop-pinterest-service.php index 74baac72..beaca2c6 100644 --- a/includes/admin/services/class-rop-pinterest-service.php +++ b/includes/admin/services/class-rop-pinterest-service.php @@ -397,14 +397,14 @@ public function share( $post_details, $args = array() ) { // Check if image is present. if ( empty( $post_details['post_image'] ) ) { - $this->logger->alert_error( sprintf( 'No featured image set for %s cannot pin to %s on Pinterest', html_entity_decode( get_the_title( $post_details['post_id'] ) ), $args['id'] ) ); + $this->logger->alert_error( sprintf( 'No featured image set for %s cannot pin to %s on Pinterest', html_entity_decode( $post_details['title'] ), $args['id'] ) ); return false; } if ( strpos( $post_details['mimetype']['type'], 'image' ) === false ) { - $this->logger->alert_error( sprintf( 'No valid image present in %s to pin to %s for %s', html_entity_decode( get_the_title( $post_details['post_id'] ) ), $args['id'], $post_details['service'] ) ); + $this->logger->alert_error( sprintf( 'No valid image present in %s to pin to %s for %s', html_entity_decode( $post_details['title'] ), $args['id'], $post_details['service'] ) ); return false; } @@ -453,7 +453,7 @@ public function share( $post_details, $args = array() ) { sprintf( 'Successfully pinned %s in %s to %s on %s', basename( $post_details['post_image'] ), - html_entity_decode( get_the_title( $post_id ) ), + html_entity_decode( $post_details['title'] ), $args['id'], $post_details['service'] ) diff --git a/includes/admin/services/class-rop-tumblr-service.php b/includes/admin/services/class-rop-tumblr-service.php index a7094900..25899044 100644 --- a/includes/admin/services/class-rop-tumblr-service.php +++ b/includes/admin/services/class-rop-tumblr-service.php @@ -513,7 +513,7 @@ public function share( $post_details, $args = array() ) { $new_post['type'] = 'link'; $new_post['url'] = trim( $this->get_url( $post_details ) ); - $new_post['title'] = html_entity_decode( get_the_title( $post_details['post_id'] ), ENT_QUOTES ); + $new_post['title'] = html_entity_decode( $post_details['title'], ENT_QUOTES ); $new_post['description'] = $this->strip_excess_blank_lines( html_entity_decode( $post_details['content'], ENT_QUOTES ) ); $new_post['author'] = $this->get_author( $post_id ); $new_post['tags'] = $hashtags; @@ -573,7 +573,7 @@ public function share( $post_details, $args = array() ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on %s ', - html_entity_decode( get_the_title( $post_id ) ), + html_entity_decode( $post_details['title'] ), $args['user'], $post_details['service'] ) diff --git a/includes/admin/services/class-rop-twitter-service.php b/includes/admin/services/class-rop-twitter-service.php index 1e9da636..61da99e5 100644 --- a/includes/admin/services/class-rop-twitter-service.php +++ b/includes/admin/services/class-rop-twitter-service.php @@ -767,7 +767,7 @@ public function share( $post_details, $args = array() ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on %s ', - html_entity_decode( get_the_title( $post_id ) ), + html_entity_decode( $post_details['title'] ), $args['user'], $post_details['service'] ) diff --git a/includes/admin/services/class-rop-vk-service.php b/includes/admin/services/class-rop-vk-service.php index 0652f424..e7546d00 100644 --- a/includes/admin/services/class-rop-vk-service.php +++ b/includes/admin/services/class-rop-vk-service.php @@ -334,7 +334,7 @@ private function vk_media_post( $post_details, $hashtags, $args, $owner_id, $cli private function vk_video_post( $post_details, $hashtags, $attachment_path, $args, $owner_id, $client, $access_token ) { $params = array( - 'name' => get_the_title( $post_details['post_id'] ), + 'name' => $post_details['title'], 'description' => $post_details['content'], ); @@ -523,7 +523,7 @@ public function share( $post_details, $args = array() ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on Vkontakte ', - html_entity_decode( get_the_title( $post_details['post_id'] ) ), + html_entity_decode( $post_details['title'] ), $args['user'] ) ); diff --git a/includes/admin/services/class-rop-webhook-service.php b/includes/admin/services/class-rop-webhook-service.php index 42f1e28e..a171956d 100644 --- a/includes/admin/services/class-rop-webhook-service.php +++ b/includes/admin/services/class-rop-webhook-service.php @@ -149,7 +149,7 @@ function( $header ) { $this->logger->alert_success( sprintf( 'Successfully shared %s to %s on %s ', - html_entity_decode( get_the_title( $post_details['post_id'] ), ENT_QUOTES ), + html_entity_decode( $post_details['title'], ENT_QUOTES ), $this->display_name, $this->service_name )