Skip to content

Commit

Permalink
Social Profile issue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alimuzzaman committed Nov 21, 2023
1 parent f3d679b commit 98bd2e9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion includes/Admin/Settings/app/Settings/helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,17 @@ export const generateTabURL = () => {
}

// Send API request for fetch url
export const socialProfileRequestHandler = async (redirectURI, appID, appSecret, platform, openIDConnect) => {
export const socialProfileRequestHandler = async (redirectURI, appID, appSecret, platform, openIDConnect = false) => {
const account_type = localStorage.getItem('account_type');

const data = {
action: 'wpsp_social_add_social_profile',
redirectURI: redirectURI,
appId: appID,
appSecret: appSecret,
type: platform,
openIDConnect: openIDConnect,
accountType: account_type,
};
const response = await fetchDataFromAPI(data);

Expand Down
2 changes: 1 addition & 1 deletion includes/Admin/Settings/assets/js/admin.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '6535b24dfe887be30054');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-data', 'wp-date', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-primitives', 'wp-url'), 'version' => '2e521e567962d5e272ad');
2 changes: 1 addition & 1 deletion includes/Admin/Settings/assets/js/admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion includes/Social/Linkedin.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function remote_post($post_id, $profile_key, $force_share = false)
$type = isset($profile->type) ? $profile->type : 'person';
$image_path = '';
$socialShareImage = get_post_meta($post_id, '_wpscppro_custom_social_share_image', true);
if ($socialShareImage != "" || $socialShareImage != 0) {
if ($socialShareImage != "" && $socialShareImage != 0) {
$image_path = wp_get_original_image_path($socialShareImage);
} else {
if (has_post_thumbnail($post_id)) { //the post does not have featured image, use a default image
Expand Down
16 changes: 13 additions & 3 deletions includes/Social/SocialProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public function social_profile_fetch_user_info_and_token()
$access_token = $accessToken->access_token;
}
$pages = $linkedin->getCompanyPages($access_token);
if( $openIDConnect && $openIDConnect !== 'false' ) {
if( $openIDConnect && $openIDConnect !== 'false' && $openIDConnect !== 'undefined' ) {
$profiles = $linkedin->userinfo($access_token);
}else{
$profiles = $linkedin->getPerson($access_token);
Expand Down Expand Up @@ -447,6 +447,7 @@ public function add_social_profile()
$app_secret = (isset($_POST['appSecret']) ? $_POST['appSecret'] : '');
$redirectURI = (isset($_POST['redirectURI']) ? $_POST['redirectURI'] : '');
$openIDConnect = (isset($_POST['openIDConnect']) ? $_POST['openIDConnect'] : '');
$accountType = (isset($_POST['accountType']) ? $_POST['accountType'] : '');

if ($type == 'pinterest') {
if (!$this->social_single_profile_checkpoint($type)) {
Expand Down Expand Up @@ -475,7 +476,16 @@ public function add_social_profile()
wp_send_json_error($this->multiProfileErrorMessage);
wp_die();
}
$scope = ($openIDConnect && $openIDConnect !== 'false') ? WPSCP_LINKEDIN_SCOPE_OPENID : WPSCP_LINKEDIN_SCOPE;
$scope = WPSCP_LINKEDIN_SCOPE;
if($openIDConnect && $openIDConnect !== 'false' && $openIDConnect !== 'undefined'){
$scope = WPSCP_LINKEDIN_SCOPE_OPENID;
}
elseif($accountType === 'page'){
$scope = WPSCP_LINKEDIN_BUSINESS_SCOPE;
}
elseif($accountType === 'profile'){
$scope = WPSCP_LINKEDIN_SCOPE;
}

try {
$request['redirect_URI'] = esc_url(admin_url('/admin.php?page=' . WPSP_SETTINGS_SLUG));
Expand All @@ -485,7 +495,7 @@ public function add_social_profile()
$request['appId'],
$app_secret, // unnecessary
$redirectURI,
urlencode($request['appId'] === WPSP_SOCIAL_OAUTH2_LINKEDIN_APP_ID ? WPSCP_LINKEDIN_BUSINESS_SCOPE : $scope ),
urlencode( $scope ),
true,
$state
);
Expand Down

0 comments on commit 98bd2e9

Please sign in to comment.