nxs_snapClassLI

The NextScripts: Social Networks Auto-Poster nxs snapClassLI class.

Defined (1)

The class is defined in the following location(s).

/inc-cl/li.php  
  1. if (!class_exists("nxs_snapClassLI")) { class nxs_snapClassLI { var $ntInfo = array('code'=>'LI', 'lcode'=>'li', 'name'=>'LinkedIn', 'defNName'=>'ulName', 'tstReq' => true); 
  2. //#### Show Common Settings  
  3. function showGenNTSettings($ntOpts) { global $nxs_snapSetPgURL, $nxs_plurl, $nxs_gOptions; $ntInfo = $this->ntInfo;  
  4. // V2 Auth 
  5. if ( isset($_GET['code']) && $_GET['code']!='' && isset($_GET['state']) && substr($_GET['state'], 0, 7) == 'nxs-li-') { $at = $_GET['code']; $ii = str_replace('nxs-li-', '', $_GET['state']); 
  6. echo "----=={ oAuth 2.0 Wordflow }==----<br/>-= This is normal technical authorization info that will dissapear (Unless you get some errors) =- <br/><br/><br/>";  
  7. $gGet = $_GET; unset($gGet['code']); unset($gGet['state']); unset($gGet['post_type']); $sturl = explode('?', $nxs_snapSetPgURL); $nxs_snapSetPgURL = $sturl[0].((!empty($gGet))?'?'.http_build_query($gGet):'');  
  8.  
  9. $nto = $ntOpts[$ii]; $wprg = array(); $wprg['sslverify'] = false; 
  10. if (isset($nto['liAPIKey'])) { echo "-="; prr($nto);// die(); 
  11. $tknURL = 'https://www.linkedin.com/uas/oauth2/accessToken?grant_type=authorization_code&code='.$at.'&redirect_uri='.urlencode($nxs_snapSetPgURL).'&client_id='.$nto['liAPIKey'].'&client_secret='.$nto['liAPISec'];  
  12. $response = wp_remote_post($tknURL, $wprg); prr($tknURL);  
  13. if((is_object($response)&&(isset($response->errors)))) { prr($response); die(); } 
  14. if (is_array($response)&& stripos($response['body'], '"error":')!==false) { prr($response['body']); prr(json_decode($response['body'], true)); die(); } 
  15. $resp = json_decode($response['body'], true); prr($resp); if (!is_array($resp) || empty($resp['access_token'])) { prr($resp); die(); } 
  16. if (function_exists('get_option')) $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); else $currTime = time(); 
  17. $nto['liAccessToken'] = $resp['access_token']; $nto['liAccessTokenSecret'] = 'No Need for oAuth V2'; $nto['liOAuthVerifier'] = 'No Need for oAuth V2'; 
  18. $nto['liAccessTokenExp'] = $currTime + $resp['expires_in']; echo "<br/>----=={ Expires: ".date('Y-m-d H:i:s', $nto['liAccessTokenExp'])." }==---- <br/>"; 
  19. $tknURL = 'https://api.linkedin.com/v1/people/~:(id, first-name, last-name)?format=json&oauth2_access_token='.$nto['liAccessToken']; 
  20. $response = wp_remote_get($tknURL, $wprg); prr($tknURL); prr($response); $user = json_decode($response['body'], true); 
  21.  
  22. if (!empty($user['id'])) { $nto['liUserID'] = $user['id']; $nto['liUserInfo'] = $user['firstName'].$user['lastName'].(!empty($user['id'])?" (".$user['id'].")":''); $nto['isV2'] = true; 
  23. if (function_exists('get_option')) $nxs_gOptions = get_option('NS_SNAutoPoster'); if(!empty($nxs_gOptions)) { $nxs_gOptions['li'][$ii] = $nto; prr($nto); nxs_settings_save($nxs_gOptions); } 
  24. ?><script type="text/javascript">window.location = "<?php echo $nxs_snapSetPgURL; ?>"</script>  
  25. <?php }  
  26. die(); 
  27. // V1 Auth 
  28. if ( isset($_GET['auth']) && $_GET['auth']=='li') { require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']]; 
  29.  
  30. $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec']; 
  31. $callback_url = $nxs_snapSetPgURL."&auth=lia&acc=".$_GET['acc']; 
  32. $li_oauth = new nsx_LinkedIn($api_key, $api_secret, $callback_url);  
  33. $request_token = $li_oauth->getRequestToken(); //echo "####"; prr($request_token); die(); 
  34. if (!is_object($request_token)) { echo "### LinkedIn Authorization Error:"; prr($request_token); 
  35. if (is_string($request_token) && stripos($request_token, 'timestamp')!==false) { echo "Your Server Time: ".date('m/d/Y h:i:s a'); echo " Correct Time: ".date('m/d/Y h:i:s a', nxs_ntp_time('t1.timegps.net')); } die(); 
  36. $options['liOAuthToken'] = $request_token->key; 
  37. $options['liOAuthTokenSecret'] = $request_token->secret; // prr($li_oauth); 
  38. switch ($li_oauth->http_code) { case 200: $url = $li_oauth->generateAuthorizeUrl();  
  39. $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG); 
  40. echo '<script type="text/javascript">window.location = "'.$url.'"</script>'; break;  
  41. default: echo '<br/><b style="color:red">Could not connect to LinkedIn. Refresh the page or try again later.</b>'; die(); 
  42. }die(); 
  43. if ( isset($_GET['auth']) && $_GET['auth']=='lia') { require_once('apis/liOAuth.php'); $options = $ntOpts[$_GET['acc']]; $api_key = $options['liAPIKey']; $api_secret = $options['liAPISec']; 
  44. $li_oauth = new nsx_LinkedIn($api_key, $api_secret); $li_oauth->request_token = new nsx_trOAuthConsumer($options['liOAuthToken'], $options['liOAuthTokenSecret'], 1);  
  45. $li_oauth->oauth_verifier = $_REQUEST['oauth_verifier']; $li_oauth->getAccessToken($_REQUEST['oauth_verifier']); $options['liOAuthVerifier'] = $_REQUEST['oauth_verifier']; 
  46. $options['liAccessToken'] = $li_oauth->access_token->key; $options['liAccessTokenSecret'] = $li_oauth->access_token->secret;  
  47. try{$xml_response = $li_oauth->getProfile("~:(id, first-name, last-name)");} catch (Exception $o) {prr($o); die("<span style='color:red;'>ERROR: Authorization Error</span>");} 
  48. if (stripos($xml_response, '<first-name>')!==false) $userinfo = CutFromTo($xml_response, '<id>', '</id>')." - ".CutFromTo($xml_response, '<first-name>', '</first-name>')." ".CutFromTo($xml_response, '<last-name>', '</last-name>'); else $userinfo='';  
  49. if ($userinfo!='') { $options['liUserInfo'] = $userinfo; $optionsG = get_option('NS_SNAutoPoster'); $optionsG['li'][$_GET['acc']] = $options; update_option('NS_SNAutoPoster', $optionsG);  
  50. echo '<script type="text/javascript">window.location = "'.$nxs_snapSetPgURL.'"</script>'; die(); 
  51. } prr($xml_response); die("<span style='color:red;'>ERROR: Something is Wrong with your LinkedIn account</span>"); 
  52. }  
  53.  
  54. ?>  
  55. <div class="nxs_box"> 
  56. <div class="nxs_box_header">  
  57. <div class="nsx_iconedTitle" style="margin-bottom:1px;background-image:url(<?php echo $nxs_plurl;?>img/<?php echo $ntInfo['lcode']; ?>16.png);"><?php echo $ntInfo['name']; ?> 
  58. <?php $cbo = count($ntOpts); ?>  
  59. <?php if ($cbo>1) { ?><div class="nsBigText"><?php echo "(".($cbo=='0'?'No':$cbo)." "; _e('accounts', 'social-networks-auto-poster-facebook-twitter-g'); echo ")"; ?></div><?php } ?> 
  60. </div> 
  61. </div> 
  62. <div class="nxs_box_inside"> 
  63. <?php foreach ($ntOpts as $indx=>$pbo) { if (trim($pbo['nName']=='')) $pbo['nName'] = !empty($pbo[$ntInfo['defNName']])?$pbo[$ntInfo['defNName']]:'LinkedIn';  
  64. if (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='') $pbo[$ntInfo['lcode'].'OK'] = (isset($pbo['liAccessToken']) && $pbo['liAccessTokenSecret']!='')?'1':''; 
  65. ?> 
  66. <p style="margin:0px;margin-left:5px;"> <img id="<?php echo $ntInfo['code'].$indx;?>LoadingImg" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' /> 
  67. <input value="0" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="hidden" />  
  68. <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <input type="radio" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" id="rbtn<?php echo $ntInfo['lcode'].$indx; ?>" value="1" checked="checked" onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);" /> <?php } else { ?>  
  69. <input value="1" name="<?php echo $ntInfo['lcode']; ?>[<?php echo $indx; ?>][apDo<?php echo $ntInfo['code']; ?>]" type="checkbox" <?php if ((int)$pbo['do'.$ntInfo['code']] == 1 && $pbo['catSel']!='1') echo "checked"; ?> /> 
  70. <?php } ?> 
  71. <?php if (isset($pbo['catSel']) && (int)$pbo['catSel'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popOnlyCat');" onmouseover="nxs_showPopUpInfo('popOnlyCat', event);"><?php echo "*[".(substr_count($pbo['catSelEd'], ", ")+1)."]*" ?></span><?php } ?> 
  72. <?php if (isset($pbo['rpstOn']) && (int)$pbo['rpstOn'] == 1) { ?> <span onmouseout="nxs_hidePopUpInfo('popReActive');" onmouseover="nxs_showPopUpInfo('popReActive', event);"><?php echo "*[R]*" ?></span><?php } ?> 
  73. <strong><?php _e('Auto-publish to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <?php echo $ntInfo['name']; ?> <i style="color: #005800;"><?php if($pbo['nName']!='') echo "(".$pbo['nName'].")"; ?></i></strong> 
  74.   <?php if ($ntInfo['tstReq'] && (!isset($pbo[$ntInfo['lcode'].'OK']) || $pbo[$ntInfo['lcode'].'OK']=='')) { ?><b style="color: #800000"><?php _e('Attention requred. Unfinished setup', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==></b><?php } ?> <?php if (!empty($pbo['grpID'])) { ?><b style="color: #800000"><?php _e('Attention requred. Groups are no longer supported by LinkedIn Native API', 'social-networks-auto-poster-facebook-twitter-g'); ?> ==></b><?php } ?> <a id="do<?php echo $ntInfo['code'].$indx; ?>AG" href="#" onclick="doGetHideNTBlock('<?php echo $ntInfo['code'];?>' , '<?php echo $indx; ?>');return false;">[<?php _e('Show Settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a>   
  75. <a href="#" onclick="doDelAcct('<?php echo $ntInfo['lcode']; ?>', '<?php echo $indx; ?>', '<?php if (isset($pbo['bgBlogID'])) echo $pbo['nName']; ?>');return false;">[<?php _e('Remove Account', 'social-networks-auto-poster-facebook-twitter-g'); ?>]</a> 
  76. </p><div id="nxsNTSetDiv<?php echo $ntInfo['code'].$indx; ?>"></div><?php //$pbo['ntInfo'] = $ntInfo; $this->showNTSettings($indx, $pbo);  
  77. }?> 
  78. </div> 
  79. </div> <?php  
  80. }  
  81. //#### Show NEW Settings Page 
  82. function showNewNTSettings($bo) { $po = array('nName'=>'', 'ulName'=>'', 'uPass'=>'', 'grpID'=>'', 'uPage'=>'', 'doLI'=>'1', 'liAPIKey'=>'', 'liAPISec'=>'', 'liUserInfo'=>'', 'liOAuthToken'=>'', 'liMsgFormat'=>'New post has been published on %SITENAME%', 'liMsgFormatT'=>'New post - %TITLE%' ); $po['ntInfo']= array('lcode'=>'li'); $this->showNTSettings($bo, $po, true);} 
  83. //#### Show Unit Settings 
  84. function showNTSettings($ii, $options, $isNew=false) { global $nxs_plurl, $nxs_snapSetPgURL; $nt = $options['ntInfo']['lcode']; $ntU = strtoupper($nt); if (!isset($options['liOK'])) $options['liOK'] = '';  
  85.  
  86. if (!isset($options['nHrs'])) $options['nHrs'] = 0; if (!isset($options['nMin'])) $options['nMin'] = 0; if (!isset($options['catSel'])) $options['catSel'] = 0; if (!isset($options['catSelEd'])) $options['catSelEd'] = '';  
  87. if (!isset($options['nDays'])) $options['nDays'] = 0; if (!isset($options['qTLng'])) $options['qTLng'] = ''; if (!isset($options['liMsgAFrmt'])) $options['liMsgAFrmt'] = '';  
  88. if (empty($options['apiToUse'])) { if (!empty($options['liAPIKey'])) $options['apiToUse'] = 'li'; if (!empty($options['ulName']) && !empty($options['uPass'])) $options['apiToUse'] = 'nx'; } ?> 
  89. <div id="doLI<?php echo $ii; ?>Div" class="insOneDiv<?php if ($isNew) echo " clNewNTSets"; ?>"> <input type="hidden" name="apDoSLI<?php echo $ii; ?>" value="0" id="apDoSLI<?php echo $ii; ?>" />  
  90. <?php if ($isNew) { ?> <input type="hidden" name="li[<?php echo $ii; ?>][apDoLI]" value="1" id="apDoNewLI<?php echo $ii; ?>" /> <?php } ?> 
  91. <div id="doLI<?php echo $ii; ?>Div" style="margin-left: 10px;">  
  92.  
  93. <div class="nsx_iconedTitle" style="float: right; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);"><a style="font-size: 12px;" target="_blank" href="http://www.nextscripts.com/setup-installation-linkedin-social-networks-auto-poster-wordpress/"><?php $nType="LinkedIn"; printf( __( 'Detailed %s Installation/Configuration Instructions' , 'social-networks-auto-poster-facebook-twitter-g'), $nType); ?></a></div> 
  94.  
  95. <div style="width:100%;"><strong><?php _e('Account Nickname', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> <i><?php _e('Just so you can easily identify it', 'social-networks-auto-poster-facebook-twitter-g'); ?></i> </div><input name="li[<?php echo $ii; ?>][nName]" id="linName<?php echo $ii; ?>" style="font-weight: bold; color: #005800; border: 1px solid #ACACAC; width: 40%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['nName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/> 
  96. <?php echo nxs_addQTranslSel('li', $ii, $options['qTLng']); ?> 
  97.  
  98. <br/> 
  99. <ul class="nsx_tabs"> 
  100. <li><a href="#nsx<?php echo $nt.$ii ?>_tab1"><?php _e('Account Info', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li>  
  101. <?php if (!$isNew) { ?> <li><a href="#nsx<?php echo $nt.$ii ?>_tab2"><?php _e('Advanced', 'social-networks-auto-poster-facebook-twitter-g'); ?></a></li> <?php } ?> 
  102. </ul> 
  103. <div class="nsx_tab_container"><?php /** ######################## Account Tab ####################### */ ?> 
  104. <div id="nsx<?php echo $nt.$ii ?>_tab1" class="nsx_tab_content" style="background-image: url(<?php echo $nxs_plurl; ?>img/<?php echo $nt; ?>-bg.png); background-repeat: no-repeat; background-position:90% 10%;"> 
  105.  
  106. <div style="display: <?php echo (empty($options['apiToUse']))?"block":"none"; ?>;"> 
  107.  
  108. <div style="width:100%; text-align: center; color:#005800; font-weight: bold; font-size: 14px;">You can choose what API you would like to use. </div>  
  109.  
  110. <span style="color:#005800; font-weight: bold; font-size: 14px;">LinkedIn Native API:</span> Free built-in API from LinkedIn. Can be used for posting to your profile. More secure, more stable. More complicated - requires LinkedIn App and authorization. <br/><br/> 
  111.  
  112. <span style="color:#005800; font-weight: bold; font-size: 14px;">NextScripts API for LinkedIn:</span> Premium API with extended functionality. Can be used for posting to your profile, <b>group page</b> or <b>company page</b>. Easier to configure, but less secure - requires your password.<br/><br/> 
  113.  
  114. <select name="li[<?php echo $ii; ?>][apiToUse]" onchange="if (jQuery(this).val()=='li') { jQuery('.nxs_li_nxapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_li_liapi_<?php echo $ii; ?>').show(); }else { jQuery('.nxs_li_liapi_<?php echo $ii; ?>').hide(); jQuery('.nxs_li_nxapi_<?php echo $ii; ?>').show(); }"><option <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='li')?"selected":""; ?> value="li">LinkedIn API</option><option <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"selected":""; ?> value="nx">NextScripts API</option></select><hr/> 
  115.  
  116. </div> 
  117.  
  118. <div id="nxsAPILI<?php echo $ii; ?>" class="nxs_li_liapi_<?php echo $ii; ?>" style="display: <?php echo (empty($options['apiToUse']) || $options['apiToUse'] =='li')?"block":"none"; ?>;"><h3>LinkedIn API</h3> 
  119.  
  120. <div class="subDiv" id="sub<?php echo $ii; ?>DivL" style="display: block;"> 
  121.  
  122. <?php if (!empty($options['grpID'])) { ?> <span style="color: red;">LinkedIn has <a style="color: red;" target="_blank" href="https://developer.linkedin.com/support/developer-program-transition">discontinued support for groups</a> from it's free native API. This account should be removed or switched to NextScripts API</span> <br/> 
  123. <br/><a onclick="jQuery('#nxsAPILI<?php echo $ii; ?>').hide(); jQuery('#nxsAPINX<?php echo $ii; ?>').show(); jQuery('#liuPage<?php echo $ii; ?>').val('https://www.linkedin.com/groups/?gid=<?php echo $options['grpID']; ?>'); jQuery('#sub<?php echo $ii; ?>DivL').append('<input type=hidden name=li[<?php echo $ii; ?>][apiToUse] value=nx />'); return false;" style="font-size: 16px;" href="#">>>> Switch to NextScripts API Now <<<</a><br/><br/></hr> 
  124.  
  125. <?php } ?> 
  126.  
  127. <div style="width:100%;"><strong>LinkedIn Client ID:</strong> </div><input name="li[<?php echo $ii; ?>][apLIAPIKey]" id="apLIAPIKey" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liAPIKey'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  128. <div style="width:100%;"><strong>LinkedIn Client Secret:</strong> </div><input name="li[<?php echo $ii; ?>][apLIAPISec]" id="apLIAPISec" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liAPISec'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  129. <br/> 
  130. <?php  
  131. if($options['liAPIKey']=='') { ?> 
  132. <b>Authorize Your LinkedIn Account</b>. Please save your settings and come back here to Authorize your account. 
  133. <?php } else { if(isset($options['liAccessToken']) && isset($options['liAccessTokenSecret']) && $options['liAccessTokenSecret']!=='') { ?> 
  134. Your LinkedIn Account has been authorized. <br/>User ID: <?php _e(apply_filters('format_to_edit', $options['liUserInfo']), 'social-networks-auto-poster-facebook-twitter-g') ?>.  
  135. <br/>You can Re- <?php } ?>  
  136.  
  137. <?php if (class_exists("cl_nxsAutoPostToSN")) { ?><a href="https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=<?php echo trim($options['liAPIKey']);?>&scope=r_basicprofile+r_emailaddress+w_share&state=<?php echo 'nxs-li-'.$ii; ?>&redirect_uri=<?php echo trim(urlencode($nxs_snapSetPgURL));?>">Authorize Your LinkedIn Account</a>  
  138. <?php } else { ?><a href="<?php echo $nxs_snapSetPgURL; ?>&auth=li&acc=<?php echo $ii; ?>">Authorize Your LinkedIn Account</a> <?php } ?> 
  139.  
  140. <?php if (!isset($options['liAccessTokenSecret']) || $options['liAccessTokenSecret']=='') { ?> <div class="blnkg"><=== Authorize your account ===</div> <?php } ?> 
  141.  
  142. <?php } ?> 
  143. </div> 
  144. </div> 
  145. <div id="nxsAPINX<?php echo $ii; ?>" class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"><h3>NextScripts API</h3> 
  146.  
  147. <?php if (function_exists("doConnectToLinkedIn")) { ?> 
  148.  
  149. <div class="subDiv" id="sub<?php echo $ii; ?>DivN" style="display: block;">  
  150. <div style="width:100%;"><strong>Your LinkedIn Page URL:</strong> Could be your company page or group page. Leave empty to post to your own profile.</div><input name="li[<?php echo $ii; ?>][uPage]" id="liuPage<?php echo $ii; ?>" style="width: 90%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPage'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  151. <br/> 
  152. <div style="width:100%;"><strong>Your LinkedIn Username/Email:</strong> </div><input name="li[<?php echo $ii; ?>][ulName]" id="liulName" style="width: 70%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['ulName'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" />  
  153. <div style="width:100%;"><strong>Your LinkedIn Password:</strong> </div><input type="password" name="li[<?php echo $ii; ?>][uPass]" id="liuPass" style="width: 75%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['uPass'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  154.  
  155. </div>  
  156. <?php } else { nxs_show_noLibWrn('NextScripts API Library for LinkedIn module NOT found'); } ?>  
  157. </div> 
  158.  
  159. <br/><hr/>  
  160.  
  161. <div id="altFormat"> 
  162. <div style="width:100%;"><strong id="altFormatText"><?php _e('Message text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> </div> 
  163. <textarea cols="150" rows="3" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][apLIMsgFrmt]" style="width:51%;max-width: 650px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 6); mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php _e(apply_filters('format_to_edit', htmlentities($options['liMsgFormat'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?></textarea>  
  164. <?php nxs_doShowHint("apIPMsgFrmt".$ii); ?>  
  165. </div>  
  166.  
  167. <div style="width:100%;"><strong id="altFormatText">Post Type:</strong> </div>  
  168. <div style="margin-left: 10px;"> 
  169. <?php if(empty($options['postType'])) {if ((int)$options['liAttch'] == 1 || $isNew) $options['postType'] = 'A';} ?> 
  170. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if ($options['postType'] == 'T') echo 'checked="checked"'; ?> /> <?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/>  
  171. <span class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"> 
  172. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if ($options['postType'] == 'I') echo 'checked="checked"'; ?> /> <?php _e('Image Post', 'social-networks-auto-poster-facebook-twitter-g'); ?> - <i><?php _e('big image with text message (Profiles and Company pages only)', 'social-networks-auto-poster-facebook-twitter-g'); ?></i><br/> </span>  
  173. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($options['postType']) || $options['postType'] == '' || $options['postType'] == 'A') echo 'checked="checked"'; ?> /> <?php _e('Add blogpost to LinkedIn message as an attachment', 'social-networks-auto-poster-facebook-twitter-g'); ?><br/> 
  174.  
  175. <div style="margin-left: 10px;">  
  176. <strong><?php _e('Attachment Text Format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong><br/>  
  177. <input value="1" id="apLIMsgAFrmtA<?php echo $ii; ?>" <?php if (trim($options['liMsgAFrmt'])=='') echo "checked"; ?> onchange="if (jQuery(this).is(':checked')) { jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').hide(); jQuery('#apLIMsgAFrmt<?php echo $ii; ?>').val(''); }else jQuery('#apLIMsgAFrmtDiv<?php echo $ii; ?>').show();" type="checkbox" name="li[<?php echo $ii; ?>][apLIMsgAFrmtA]"/> <strong><?php _e('Auto', 'social-networks-auto-poster-facebook-twitter-g'); ?></strong> 
  178. <i> - <?php _e('Recommended. Info from SEO Plugins will be used, then post excerpt, then post text', 'social-networks-auto-poster-facebook-twitter-g'); ?> </i><br/> 
  179. <div id="apLIMsgAFrmtDiv<?php echo $ii; ?>" style="<?php if ($options['liMsgAFrmt']=='') echo "display:none;"; ?>" >    <?php _e('Set your own format', 'social-networks-auto-poster-facebook-twitter-g'); ?>:<input name="li[<?php echo $ii; ?>][apLIMsgAFrmt]" id="apLIMsgAFrmt<?php echo $ii; ?>" style="width: 30%;" value="<?php _e(apply_filters('format_to_edit', htmlentities($options['liMsgAFrmt'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g') ?>" /><br/></div> 
  180.  
  181. </div> 
  182.  
  183. </div><br/>  
  184.  
  185. <br/> 
  186. <div id="altFormat" style="display: <?php echo (!empty($options['apiToUse']) && $options['apiToUse'] =='nx')?"block":"none"; ?>;"> 
  187. <div style="width:100%;"><strong id="altFormatText"><?php _e('Message title Format (Groups Only)', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</strong> </div> 
  188.  
  189. <input name="li[<?php echo $ii; ?>][apLIMsgFrmtT]" id="li<?php echo $ii; ?>SNAPformatT" style="width: 50%;" value="<?php if ($isNew) echo "New Post - %TITLE%"; else _e(apply_filters('format_to_edit', htmlentities($options['liMsgFormatT'], ENT_COMPAT, "UTF-8")), 'social-networks-auto-poster-facebook-twitter-g'); ?>" onfocus="mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');" /><?php nxs_doShowHint("apIPMsgFrmt".$ii); ?> 
  190.  
  191. </div>  
  192.  
  193. <br/>  
  194.  
  195. <?php if($options['liAPIKey']!='' || (isset($options['uPass']) && $options['uPass']!='')) { ?> 
  196.  
  197. <br/><b><?php _e('Test your settings', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>    <a href="#" class="NXSButton" onclick="testPost('LI', '<?php echo $ii; ?>'); return false;"><?php printf( __( 'Submit Test Post to %s', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?></a> 
  198.  
  199. <?php if (!isset($options['liOK']) || $options['liOK']=='') { ?> <div class="blnkg"><=== Click "Test" to finish setup ===</div> <?php } ?> 
  200.  
  201. <br/><?php }?> 
  202. </div> 
  203.  
  204. <?php /** ######################## Advanced Tab ####################### */ ?> 
  205. <?php if (!$isNew) { ?> <div id="nsx<?php echo $nt.$ii ?>_tab2" class="nsx_tab_content"> 
  206.  
  207. <?php nxs_showCatTagsCTFilters($nt, $ii, $options);  
  208. nxs_addPostingDelaySelV3($nt, $ii, $options['nHrs'], $options['nMin'], $options['nDays']);  
  209. nxs_showRepostSettings($nt, $ii, $options); ?> 
  210.  
  211.  
  212. </div> <?php } ?> <?php /** #### End of Tab #### */ ?> 
  213. </div><br/> <?php /** #### End of Tabs #### */ ?> 
  214.  
  215. <div class="submitX nxclear" style="padding-bottom: 0px;"><input type="submit" class="button-primary" name="update_NS_SNAutoPoster_settings" value="<?php _e('Update Settings', 'social-networks-auto-poster-facebook-twitter-g') ?>" /></div> 
  216.  
  217. </div> 
  218. </div> 
  219. <?php 
  220.  
  221.  
  222. //#### Set Unit Settings from POST 
  223. function setNTSettings($post, $options) { $code = $this->ntInfo['code']; 
  224. foreach ($post as $ii => $pval) { // prr($ii); prr($pval); 
  225. if ( (isset($pval['apLIAPIKey']) && $pval['apLIAPISec']!='') || (isset($pval['uPass']) && $pval['uPass']!='') ) { if (!isset($options[$ii])) $options[$ii] = array(); $options[$ii]['ii'] = $ii;  
  226. if (isset($pval['apDoLI'])) $options[$ii]['doLI'] = $pval['apDoLI']; else $options[$ii]['doLI'] = 0; 
  227. if (isset($pval['nName'])) $options[$ii]['nName'] = trim($pval['nName']); 
  228.  
  229. if (isset($pval['apiToUse'])) $options[$ii]['apiToUse'] = trim($pval['apiToUse']);  
  230.  
  231. if (isset($options[$ii]['grpID']) && isset($pval['apiToUse']) && ($pval['apiToUse'])=='nx') unset($options[$ii]['grpID']); //## Switch/Upgrade 
  232.  
  233. if (isset($pval['apLIAPIKey']))$options[$ii]['liAPIKey'] = trim($pval['apLIAPIKey']);  
  234. if (isset($pval['apLIAPISec']))$options[$ii]['liAPISec'] = trim($pval['apLIAPISec']);  
  235. if (isset($pval['postType'])) $options[$ii]['postType'] = trim($pval['postType']);  
  236.  
  237. if (isset($pval['apiToUse']) && $pval['apiToUse']=='li' && ($options[$ii]['postType']=='I')) $options[$ii]['postType'] = 'T'; 
  238.  
  239. if (isset($pval['catSel'])) $options[$ii]['catSel'] = trim($pval['catSel']); else $options[$ii]['catSel'] = 0; 
  240. if ($options[$ii]['catSel']=='1' && trim($pval['catSelEd'])!='') $options[$ii]['catSelEd'] = trim($pval['catSelEd']); else $options[$ii]['catSelEd'] = ''; 
  241.  
  242. if (isset($pval['ulName'])) $options[$ii]['ulName'] = trim($pval['ulName']);  
  243. if (isset($pval['uPass'])) $options[$ii]['uPass'] = trim($pval['uPass']);  
  244. if (isset($pval['grpID'])) $options[$ii]['grpID'] = trim($pval['grpID']);  
  245. if (isset($pval['uPage'])) $options[$ii]['uPage'] = trim($pval['uPage']);  
  246. if (isset($pval['apLIMsgFrmt'])) $options[$ii]['liMsgFormat'] = trim($pval['apLIMsgFrmt']);  
  247. if (isset($pval['apLIMsgFrmtT'])) $options[$ii]['liMsgFormatT'] = trim($pval['apLIMsgFrmtT']);  
  248. if (isset($pval['apLIMsgAFrmt'])) $options[$ii]['liMsgAFrmt'] = trim($pval['apLIMsgAFrmt']);  
  249.  
  250. $options[$ii] = nxs_adjRpst($options[$ii], $pval);  
  251.  
  252. if (isset($pval['delayDays'])) $options[$ii]['nDays'] = trim($pval['delayDays']); 
  253. if (isset($pval['delayHrs'])) $options[$ii]['nHrs'] = trim($pval['delayHrs']); if (isset($pval['delayMin'])) $options[$ii]['nMin'] = trim($pval['delayMin']);  
  254. if (isset($pval['qTLng'])) $options[$ii]['qTLng'] = trim($pval['qTLng']);  
  255. } elseif ( count($pval)==1 ) if (isset($pval['apDo'.$code])) $options[$ii]['do'.$code] = $pval['apDo'.$code]; else $options[$ii]['do'.$code] = 0;  
  256. } return $options; 
  257. }  
  258. //#### Show Post->Edit Meta Box Settings 
  259. function showEdPostNTSettings($ntOpts, $post) { global $nxs_plurl; $post_id = $post->ID; $nt = 'li'; $ntU = 'LI'; 
  260. foreach($ntOpts as $ii=>$ntOpt) { $pMeta = maybe_unserialize(get_post_meta($post_id, 'snapLI', true)); if (is_array($pMeta) && isset($pMeta[$ii])) $ntOpt = $this->adjMetaOpt($ntOpt, $pMeta[$ii]);  
  261. if (empty($ntOpt['imgToUse'])) $ntOpt['imgToUse'] = ''; if (empty($ntOpt['urlToUse'])) $ntOpt['urlToUse'] = ''; if (empty($ntOpt['catSel'])) $ntOpt['catSel'] = ''; 
  262. $doLI = $ntOpt['doLI'] && (is_array($pMeta) || $ntOpt['catSel']!='1'); $imgToUse = $ntOpt['imgToUse']; $urlToUse = $ntOpt['urlToUse'];  
  263. $isAvailLI = (isset($ntOpt['liOAuthVerifier']) && $ntOpt['liOAuthVerifier']!='' && $ntOpt['liAccessTokenSecret']!='' && $ntOpt['liAccessToken']!='' && $ntOpt['liAPIKey']!='') || ($ntOpt['ulName']!=='' && $ntOpt['uPass']!==''); 
  264. $liMsgFormat = htmlentities($ntOpt['liMsgFormat'], ENT_COMPAT, "UTF-8"); $liMsgFormatT = htmlentities($ntOpt['liMsgFormatT'], ENT_COMPAT, "UTF-8");  
  265. ?>  
  266.  
  267. <tr><th style="text-align:left;" colspan="2"> 
  268. <?php if ($ntOpt['catSel']=='1' && trim($ntOpt['catSelEd'])!='') { ?> <input type="hidden" class="nxs_SC" id="nxs_SC_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['catSelEd']; ?>" /> <?php } ?> 
  269. <?php if (!empty($ntOpt['tagsSelX'])) { ?> <input type="hidden" class="nxs_TG" id="nxs_TG_<?php echo $ntU; ?><?php echo $ii; ?>" value="<?php echo $ntOpt['tagsSelX']; ?>" /> <?php } ?> 
  270. <?php if ($isAvailLI) { ?><input class="nxsGrpDoChb" value="1" id="doLI<?php echo $ii; ?>" <?php if ($post->post_status == "publish") echo 'disabled="disabled"';?> type="checkbox" name="li[<?php echo $ii; ?>][doLI]" <?php if ((int)$doLI == 1) echo 'checked="checked" title="def"'; ?> />  
  271. <?php if ($post->post_status == "publish") { ?> <input type="hidden" name="li[<?php echo $ii; ?>][doLI]" value="<?php echo $doLI;?>"> <?php } ?> <?php } ?> 
  272. <div class="nsx_iconedTitle" style="display: inline; font-size: 13px; background-image: url(<?php echo $nxs_plurl; ?>img/li16.png);">LinkedIn - <?php _e('publish to', 'social-networks-auto-poster-facebook-twitter-g') ?> (<i style="color: #005800;"><?php echo $ntOpt['nName']; ?></i>)</div></th><td><?php //## Only show RePost button if the post is "published" 
  273. if ($post->post_status == "publish" && $isAvailLI) { ?><input alt="<?php echo $ii; ?>" style="float: right;" onmouseout="hidePopShAtt('SV');" onmouseover="showPopShAtt('SV', event);" onclick="return false;" type="button" class="button" name="rePostToLI_repostButton" id="rePostToLI_button" value="<?php _e('Repost to LinkedIn', 'social-networks-auto-poster-facebook-twitter-g') ?>" /> 
  274. <?php } ?> 
  275.  
  276. <?php if (is_array($pMeta) && isset($pMeta[$ii]) && is_array($pMeta[$ii]) && isset($pMeta[$ii]['pgID']) ) { // prr($pMeta[$ii]);  
  277. ?> <span id="pstdLI<?php echo $ii; ?>" style="float: right;padding-top: 4px; padding-right: 10px;"> 
  278. <a style="font-size: 10px;" href="<?php if ( $pMeta[$ii]['postURL']!='') echo $pMeta[$ii]['postURL']; elseif ($ntOpt['uPage']!='') echo $ntOpt['uPage']; else { } ?>" target="_blank"><?php $nType="LinkedIn"; printf( __( 'Posted on', 'social-networks-auto-poster-facebook-twitter-g' ), $nType); ?> <?php echo (isset($pMeta[$ii]['pDate']) && $pMeta[$ii]['pDate']!='')?(" (".$pMeta[$ii]['pDate'].")"):""; ?></a> 
  279. </span><?php } ?> 
  280.  
  281. </td></tr> 
  282. <?php if (!$isAvailLI) { ?><tr><th scope="row" style="text-align:right; width:150px; padding-top: 5px; padding-right:10px;"></th> <td><b>Setup your LinkedIn Account to AutoPost to LinkedIn</b> 
  283. <?php } else { if ($post->post_status != "publish" && function_exists('nxs_doSMAS5') ) { $ntOpt['postTime'] = get_post_time('U', false, $post_id); nxs_doSMAS5($nt, $ii, $ntOpt); } ?> 
  284.  
  285. <?php if ($ntOpt['rpstOn']=='1') { ?>  
  286.  
  287. <tr id="altFormat1" style=""><th scope="row" class="nxsTHRow"> 
  288. <input value="0" type="hidden" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"/><input value="nxsi<?php echo $ii; ?>li" type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]" <?php if (!empty($ntOpt['rpstPostIncl'])) echo "checked"; ?> /> 
  289. </th> 
  290. <td> <?php _e('Include in "Auto-Reposting" to this network.', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  291. </td></tr> <?php } ?> 
  292.  
  293. <tr><th scope="row" style="text-align:right; width:150px; vertical-align:top; padding-top: 0px; padding-right:10px;"> <?php _e('Post Type:', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  294. </th><td>  
  295.  
  296. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="T" <?php if ($ntOpt['postType'] == 'T') echo 'checked="checked"'; ?> /><?php _e('Text Post', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('just text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/>  
  297. <span class="nxs_li_nxapi_<?php echo $ii; ?>" style="display: <?php echo (!empty($ntOpt['apiToUse']) && $ntOpt['apiToUse'] =='nx')?"block":"none"; ?>;"> 
  298. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="I" <?php if ($ntOpt['postType'] == 'I') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').show();" /> <?php _e('Post to LinkedIn as "Image post"', 'social-networks-auto-poster-facebook-twitter-g') ?> - <i><?php _e('big image with text message', 'social-networks-auto-poster-facebook-twitter-g') ?></i><br/> </span>  
  299. <input type="radio" name="li[<?php echo $ii; ?>][postType]" value="A" <?php if ( !isset($ntOpt['postType']) || $ntOpt['postType'] == '' || $ntOpt['postType'] == 'A') echo 'checked="checked"'; ?> onchange="jQuery('#altFormatIMG<?php echo $nt.$ii;?>').hide();" /><?php _e('Text Post with "attached" blogpost', 'social-networks-auto-poster-facebook-twitter-g') ?>  
  300. </td></tr> 
  301.  
  302. <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Message Format:', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  303. <td>  
  304. <textarea cols="150" rows="1" id="li<?php echo $ii; ?>SNAPformat" name="li[<?php echo $ii; ?>][SNAPformat]" style="width:60%;max-width: 610px;" onfocus="jQuery('#li<?php echo $ii; ?>SNAPformat').attr('rows', 4); jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmt<?php echo $ii; ?>');"><?php echo $liMsgFormat; ?></textarea> 
  305. <?php nxs_doShowHint("apLIMsgFrmt".$ii); ?></td></tr> 
  306.  
  307. <tr id="altFormat1" style=""><th scope="row" style="vertical-align:top; padding-top: 6px; text-align:right; width:60px; padding-right:10px;"><?php _e('Title Format (Groups Only):', 'social-networks-auto-poster-facebook-twitter-g') ?></th> 
  308. <td><input value="<?php echo $liMsgFormatT ?>" type="text" name="li[<?php echo $ii; ?>][SNAPformatT]" style="width:60%;max-width: 610px;" onfocus="jQuery('.nxs_FRMTHint').hide();mxs_showFrmtInfo('apLIMsgFrmtT<?php echo $ii; ?>');"/><?php nxs_doShowHint("apLIMsgFrmtT".$ii, '', '58'); ?></td></tr>  
  309. <?php /** ## Select Image & URL ## */ nxs_showImgToUseDlg($nt, $ii, $imgToUse); nxs_showURLToUseDlg($nt, $ii, $urlToUse); ?> 
  310.  
  311. <?php }  
  312. }  
  313.  
  314. function adjMetaOpt($optMt, $pMeta) { if (isset($pMeta['isPosted'])) $optMt['isPosted'] = $pMeta['isPosted']; else $optMt['isPosted'] = ''; 
  315. if (isset($pMeta['SNAPformat'])) $optMt['liMsgFormat'] = $pMeta['SNAPformat']; if (trim($optMt['liMsgFormat'])=='') $optMt['liMsgFormat'] = ' ';  
  316. if (isset($pMeta['SNAPformatT'])) $optMt['liMsgFormatT'] = $pMeta['SNAPformatT']; if (trim($optMt['liMsgFormatT'])=='') $optMt['liMsgFormatT'] = ' '; 
  317. if (isset($pMeta['imgToUse'])) $optMt['imgToUse'] = $pMeta['imgToUse']; if (isset($pMeta['urlToUse'])) $optMt['urlToUse'] = $pMeta['urlToUse'];  
  318. if (isset($pMeta['postType'])) $optMt['postType'] = $pMeta['postType']; 
  319. if (isset($pMeta['timeToRun'])) $optMt['timeToRun'] = $pMeta['timeToRun']; if (isset($pMeta['rpstPostIncl'])) $optMt['rpstPostIncl'] = $pMeta['rpstPostIncl'];  
  320. if (isset($pMeta['doLI'])) $optMt['doLI'] = $pMeta['doLI'] == 1?1:0; else { if (isset($pMeta['SNAPformat'])) $optMt['doLI'] = 0; }  
  321. if (isset($pMeta['SNAPincludeLI']) && $pMeta['SNAPincludeLI'] == '1' ) $optMt['doLI'] = 1;  
  322. return $optMt; 
  323. }}