Skip to content

Commit a08a61c

Browse files
committedFeb 19, 2025
Merge branch '7567' into shakib-latest-master
2 parents dc4d5e0 + adce58c commit a08a61c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed
 

‎includes/API/Settings.php

+14-1
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,28 @@ public function wpsp_instant_social_share( $data )
216216
do_action('wpsp_instant_social_single_profile_share', $data->get_params());
217217
}
218218

219-
// Fetch option table data
220219
public function wpsp_get_options_data( $request ) {
221220
$option_value = get_option('wpsp_settings_v5');
221+
222222
if ($option_value !== false) {
223+
$option_value = json_decode($option_value, true);
224+
// Check and process `linkedin_profile_list` if it exists
225+
if (isset($option_value['linkedin_profile_list']) && is_array($option_value['linkedin_profile_list'])) {
226+
$option_value['linkedin_profile_list'] = array_map(function($profile) {
227+
if (isset($profile['__id']) && isset($profile['id'])) {
228+
$profile['id'] = $profile['__id'];
229+
unset($profile['__id']);
230+
}
231+
return $profile;
232+
}, $option_value['linkedin_profile_list']);
233+
}
234+
$option_value = json_encode($option_value);
223235
return rest_ensure_response($option_value);
224236
} else {
225237
return new \WP_Error('option_not_found', 'Option not found', array('status' => 40));
226238
}
227239
}
240+
228241

229242
/**
230243
* Return an instance of this class.

‎includes/Social/InstantShare.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,14 @@ public function instant_social_single_profile_share($params)
555555
}
556556
} else if ($platform == 'linkedin') {
557557
$linkedin = \WPSP\Helper::get_social_profile(WPSCP_LINKEDIN_OPTION_NAME);
558-
$platformKey = !empty( $profileID ) ? array_search($profileID, array_column($linkedin, 'id')) : intval($platformKey);
558+
if (($platformKey = array_search($profileID, array_column($linkedin, '__id'))) !== false) {
559+
$platformKey = intval($platformKey);
560+
} elseif (($platformKey = array_search($profileID, array_column($linkedin, 'id'))) !== false) {
561+
$platformKey = intval($platformKey);
562+
} else {
563+
$platformKey = null; // Or any default value
564+
}
565+
559566
// if disable account then it will be off
560567
if ($linkedin[$platformKey]->status == false) {
561568
wp_die();

‎includes/Social/Linkedin.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function remote_post($post_id, $profile_key, $force_share = false)
161161
$get_share_type = get_post_meta($post_id, '_linkedin_share_type', true);
162162
if( $profile->type !== 'organization' && $get_share_type === 'custom' ) {
163163
$get_all_selected_profile = get_post_meta($post_id, '_selected_social_profile', true);
164-
$check_profile_exists = Helper::is_profile_exits( $profile->id, $get_all_selected_profile );
164+
$check_profile_exists = Helper::is_profile_exits( isset( $profile->__id ) ? $profile->__id : $profile->id , $get_all_selected_profile );
165165
if( !$check_profile_exists ) {
166166
return;
167167
}

‎includes/Social/SocialProfile.php

+1
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ public function social_profile_fetch_user_info_and_token()
491491
}
492492
$pages = apply_filters('wpsp_filter_linkedin_pages', $pages, $profiles);
493493
$info = array(
494+
'__id' => time(),
494495
'app_id' => $app_id,
495496
'app_secret' => $app_secret,
496497
'status' => true,

0 commit comments

Comments
 (0)
Please sign in to comment.