PageRenderTime 76ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/rpx/rpx_v.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 1497 lines | 1494 code | 1 blank | 2 comment | 12 complexity | 9c68ca21522001c385461a5bffae7538 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. // [rpxshare link="permalink" title="the_title" style="icon" label="option label" comment="false" imgsrc="img url"]summary[/rpxshare]
  3. function rpxshare_shortcode($atts, $content=null) {
  4. $output = '';
  5. $rpx_social_option = get_option(RPX_SOCIAL_OPTION);
  6. $rpx_social_pub = get_option(RPX_SOCIAL_PUB);
  7. if ($rpx_social_option !== 'true' || empty($rpx_social_pub) ){
  8. return $output;
  9. }
  10. $att_def = array();
  11. $att_def['link'] = '';
  12. $att_def['title'] = '';
  13. $att_def['style'] = 'icon';
  14. $att_def['label'] = '';
  15. $att_def['comment'] = 'false';
  16. $att_def['imgsrc'] = '';
  17. $attributes = shortcode_atts($att_def, $atts);
  18. if ($attributes['comment'] == 'true') {
  19. $attributes['comment'] = true;
  20. } else {
  21. $attributes['comment'] = false;
  22. }
  23. if ( empty($content) ) {
  24. $content = '';
  25. }
  26. $output = rpx_social_share($content, $attributes['comment'], $attributes['style'], $attributes['label'], $attributes['title'], $attributes['link'], $attributes['imgsrc']);
  27. if ( empty($output) ) {
  28. $output = '';
  29. }
  30. return $output;
  31. }
  32. // [rpxlogin redirect="http://www.janrain.com" prompt="Cool Link" style="large"]
  33. function rpxlogin_shortcode($atts, $content=null) {
  34. $output = '';
  35. $att_def = array();
  36. $att_def['redirect'] = '';
  37. $att_def['prompt'] = '';
  38. $att_def['style'] = 'small';
  39. $attributes = shortcode_atts($att_def, $atts);
  40. if ( !empty($attributes['redirect']) ) {
  41. rpx_set_redirect($attributes['redirect']);
  42. }
  43. if ($attributes['style'] === 'large') {
  44. $output = rpx_large_buttons($attributes['prompt']);
  45. } else {
  46. $output = rpx_small_buttons($attributes['prompt']);
  47. }
  48. if ( empty($output) ) {
  49. $output = '';
  50. }
  51. return $output;
  52. }
  53. function rpx_js_escape($string){
  54. if ( empty($string) ){
  55. $string = ' ';
  56. }
  57. $string = strip_tags($string);
  58. $string = str_replace("\0",' ',$string);
  59. $string = str_replace("\n",' ',$string);
  60. $string = str_replace("\r",' ',$string);
  61. $string = str_replace(' ', ' ', $string);
  62. $string = strip_shortcodes($string);
  63. return addcslashes($string,"\\\'\"&\n\r<>");
  64. }
  65. function rpx_inline_stylesheet(){
  66. ?>
  67. <style type="text/css">
  68. /* Janrain Engage plugin dynamic CSS elements */
  69. .rpx_counter {
  70. background-image:url('<?php echo RPX_IMAGE_URL; ?>bubble-32.png');
  71. }
  72. .rpx_ct_total {
  73. background-image:url('<?php echo RPX_IMAGE_URL; ?>bubble-short.png');
  74. }
  75. .rpx_size30 {
  76. background-image:url('<?php echo RPX_IMAGE_URL; ?>rpx-icons30.png');
  77. }
  78. .rpx_size16 {
  79. background-image:url('<?php echo RPX_IMAGE_URL; ?>rpx-icons16.png');
  80. }
  81. </style>
  82. <?php
  83. }
  84. function rpx_inline_javascript(){
  85. global $rpx_inline_js_done;
  86. if ($rpx_inline_js_done === true) {
  87. return false;
  88. }
  89. $rpx_social_option = get_option(RPX_SOCIAL_OPTION);
  90. $rpx_social_pub = get_option(RPX_SOCIAL_PUB);
  91. if ($rpx_social_option !== 'true' || empty($rpx_social_pub) ){
  92. return false;
  93. }
  94. ?>
  95. <script type="text/javascript"><!--
  96. function rpxWPsocial (rpxLabel, rpxSummary, rpxLink, rpxLinkText, rpxComment, rpxImageSrc, rpxPostID, rpxElement){
  97. if (typeof console != 'object') {
  98. //Dummy console log.
  99. var console = new Object();
  100. console.data = new Array();
  101. console.log = function(err) {
  102. this.data.push(err);
  103. }
  104. }
  105. RPXNOW.init({appId: '<?php echo get_option(RPX_APP_ID_OPTION); ?>', xdReceiver: '<?php echo RPX_PLUGIN_URL; ?>rpx_xdcomm.html'});
  106. RPXNOW.loadAndRun(['Social'], function () {
  107. var activity = new RPXNOW.Social.Activity(
  108. rpxLabel,
  109. rpxLinkText,
  110. rpxLink);
  111. activity.setUserGeneratedContent(rpxComment);
  112. activity.setDescription(rpxSummary);
  113. if (document.getElementById('rpxshareimg') != undefined && (rpxImageSrc == '' || rpxImageSrc == null)) {
  114. rpxImageSrc = document.getElementById('rpxshareimg').src;
  115. }
  116. if (rpxImageSrc != '' && rpxImageSrc != null) {
  117. var shareImage = new RPXNOW.Social.ImageMediaCollection();
  118. shareImage.addImage(rpxImageSrc,rpxLink);
  119. activity.setMediaItem(shareImage);
  120. }
  121. RPXNOW.Social.publishActivity(activity,
  122. {finishCallback:function(data){
  123. var rpxSharePost = new Array();
  124. var rpxShareParams = new Array();
  125. for (i in data) {
  126. try {
  127. var theData = data[i];
  128. if (theData.success == true && (rpxPostID != '' || rpxPostID != null)) {
  129. rpxSharePost[i] = new XMLHttpRequest();
  130. rpxSharePost[i].myData = theData;
  131. rpxSharePost[i].onreadystatechange=function() {
  132. if (this.readyState==4 && this.status==200) {
  133. var rpxShareData = JSON.parse(this.responseText);
  134. if (rpxShareData.stat == 'ok') {
  135. var theDivs = rpxElement.getElementsByTagName('div');
  136. var theTotal = 0;
  137. var totalDiv = null;
  138. for (n in theDivs) {
  139. try {
  140. var theDiv = theDivs[n];
  141. if (typeof theDiv == 'object') {
  142. var classReg = new RegExp('rpx_ct_'+this.myData.provider_name);
  143. if (theDiv.getAttribute('class').search(classReg) >= 0) {
  144. var theCount = Number(theDiv.innerHTML);
  145. theCount++;
  146. theTotal++;
  147. theDiv.innerHTML = String(theCount);
  148. try {
  149. rpx_showhide(theDiv);
  150. } catch(err) {
  151. console.log(err);
  152. }
  153. }
  154. classReg = new RegExp('rpx_ct_total');
  155. if (theDiv.getAttribute('class').search(classReg) >= 0) {
  156. totalDiv = theDiv;
  157. }
  158. }
  159. } catch(err) {
  160. console.log(err);
  161. }
  162. }
  163. if (totalDiv != null) {
  164. totalDiv.innerHTML = String(Number(totalDiv.innerHTML) + theTotal);
  165. totalDiv = null;
  166. }
  167. }
  168. }
  169. }
  170. rpxShareParams[i] = '?post_id='+encodeURIComponent(rpxPostID);
  171. rpxShareParams[i] += '&provider='+encodeURIComponent(theData.provider_name);
  172. rpxShareParams[i] += '&share_url='+encodeURIComponent(theData.provider_activity_url);
  173. rpxSharePost[i].open('GET','<?php echo RPX_PLUGIN_URL; ?>rpx_sharePost.php'+rpxShareParams[i],true);
  174. rpxSharePost[i].send();
  175. }
  176. } catch(err) {
  177. console.log(err);
  178. }
  179. }
  180. }
  181. });
  182. });
  183. }
  184. <?php
  185. if ( get_option(RPX_SHARE_COUNT_OPTION) == 'hover' ) {
  186. ?>
  187. function rpx_jquery_load() {
  188. if (typeof jQuery != 'undefined') {
  189. if (typeof $ == 'undefined') {
  190. $ = jQuery;
  191. }
  192. try{
  193. rpx_effects();
  194. }catch(err){
  195. }
  196. return true;
  197. }
  198. if (typeof rpx_jquery_written == 'undefined'){
  199. document.write("<scr" + "ipt type=\"text/javascript\" src=\"<?php echo RPX_PLUGIN_URL; ?>/files/jquery-1.6.2.min.js\"></scr" + "ipt>");
  200. rpx_jquery_written = true;
  201. }
  202. setTimeout('rpx_jquery_load()', 60);
  203. return false;
  204. }
  205. rpx_jquery_load();
  206. <?php
  207. }
  208. ?>
  209. //--></script>
  210. <?php
  211. $rpx_inline_js_done = true;
  212. return true;
  213. }
  214. function rpx_print_messages(){
  215. global $rpx_messages;
  216. $output = '';
  217. $id = 0;
  218. foreach ($rpx_messages as $key => $message_array){
  219. if ( empty($message_array['message']) ){
  220. $message_array['message'] = 'Empty message.';
  221. }
  222. if ( empty($message_array['class']) ){
  223. $message_array['class'] = 'message';
  224. }
  225. if ($message_array['class'] != 'html'){
  226. $message_array['class'] = htmlentities($message_array['class']);
  227. $message_array['message'] = nl2br(htmlentities($message_array['message']));
  228. $message_array['message'] = str_replace('[br]', '<br>', $message_array['message']);
  229. }else{
  230. $message_array['class'] = 'message updated';
  231. }
  232. $id++;
  233. $output .= '<p id="rpx_message_'.$id.'" class="'.$message_array['class'].'">'.RPX_MESSAGE_PRE.$message_array['message'].'</p>';
  234. }
  235. if ( !empty($output) ){
  236. echo '<div id="rpxmessage" class="message">'.$output.'</div>';
  237. }
  238. }
  239. function rpx_admin_menu_view(){
  240. if (current_user_can(RPX_OPTIONS_ROLE) === false) {
  241. return false;
  242. }
  243. global $rpx_comment_actions;
  244. global $rpx_http_vars;
  245. if ($rpx_http_vars['rpx_cleanup'] == 'true'){
  246. rpx_clean_locked();
  247. }
  248. $rpx_apikey = get_option(RPX_API_KEY_OPTION);
  249. if (strlen($rpx_apikey) != 40){
  250. rpx_message ('<strong>Enter valid API key.</strong><br />'
  251. .'Get your apiKey '
  252. .'<a target="new" href="https://login.janrain.com/openid/v2/signin?token_url=https%3A%2F%2Frpxnow.com%2Ffinish">here</a>'
  253. .' if you have an Engage account.<br />'
  254. .'View the account options '
  255. .'<a target="new" href="http://www.janrain.com/products/engage/get-janrain-engage">here</a>'
  256. .' to become a Janrain Engage customer.', 'html');
  257. }
  258. $rpx_test = rpx_test_api();
  259. $messages = array();
  260. $messages['select'] = 'No supported HTTP option.';
  261. $messages['post'] = 'Unable to send POST to Engage server.';
  262. $messages['api'] = 'Unable to retrive data from Engage API.';
  263. $messages['ssl_valid'] = 'This PHP does not support SSL certificate validation, certificate testing disabled.';
  264. foreach ($messages as $key=>$message){
  265. if ($rpx_test[$key] === false){
  266. rpx_message ($message, 'error');
  267. }
  268. }
  269. ?>
  270. <style type="text/css">
  271. .rpx_tr_sub td {
  272. padding-left:40px;
  273. }
  274. .rpx_tr_lt {
  275. background-color:#EEE;
  276. }
  277. .rpx_tr_dk {
  278. background-color:#DDD;
  279. }
  280. .rpx_td_left {
  281. text-align:left;
  282. }
  283. .rpx_note {
  284. float:left;
  285. }
  286. </style>
  287. <script type="text/javascript">
  288. function rpxshowhide(box,val) {
  289. if(document.getElementById(box).checked==true) {
  290. document.getElementById(val).style.visibility="visible";
  291. } else {
  292. document.getElementById(val).style.visibility="hidden";
  293. }
  294. }
  295. </script>
  296. <div class="wrap">
  297. <h2>Janrain Engage Setup</h2>
  298. <?php rpx_print_messages(); echo $rpx_test['select']; ?>
  299. <form method="post" action="options.php">
  300. <?php settings_fields( 'rpx_settings_group' ); ?>
  301. <table class="form-table">
  302. <tr class="rpx_tr_dk">
  303. <td class="rpx_td">
  304. <label for="rpxapikey">Engage API Key: </label>
  305. <input id="rpxapikey" type="text" name="<?php echo RPX_API_KEY_OPTION; ?>" style="width:40em;" value="<?php echo get_option(RPX_API_KEY_OPTION); ?>" />
  306. </td>
  307. <td class="rpx_td">&nbsp;</td>
  308. </tr><?php
  309. if (strlen(get_option(RPX_API_KEY_OPTION)) == 40){?>
  310. <tr class="rpx_tr_lt">
  311. <td class="rpx_td">
  312. <h3>Sign-In Settings</h3>
  313. Setup Sign-In widget <a target="_blank" href="<?php echo get_option(RPX_ADMIN_URL_OPTION); echo RPX_SIGNIN_SETUP_URL; ?>">here</a>.<br />
  314. Add your site domain to the list <a target="_blank" href="<?php echo get_option(RPX_ADMIN_URL_OPTION); echo RPX_SETTINGS_SETUP_URL; ?>">here</a>.<br />
  315. Click save to update Engage provider icons.<?php echo rpx_small_buttons(); ?>
  316. </td>
  317. <td class="rpx_td">Expert widget options:
  318. <br>
  319. <label for="rpxparamstxt">Additional iframe URL parameters (use &amp; to separate):</label>
  320. <input id="rpxparamstxt" name="<?php echo RPX_PARAMS_OPTION; ?>" type="text" size=50 value="<?php
  321. $rpx_params_txt = get_option(RPX_PARAMS_OPTION);
  322. if ( empty($rpx_params_txt) ) {
  323. $rpx_params_txt = RPX_PARAMS_OPTION_DEFAULT;
  324. }
  325. echo $rpx_params_txt;
  326. ?>" />
  327. </td>
  328. </tr>
  329. <tr class="rpx_tr_lt rpx_tr_sub">
  330. <td class="rpx_td">
  331. <label for="rpxvemail">Allow sign in based on verifiedEmail match:</label>
  332. <input id="rpxvemail" type="checkbox" name="<?php echo RPX_VEMAIL_OPTION; ?>" value="true"<?php if (get_option(RPX_VEMAIL_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  333. </td>
  334. <td class="rpx_td">&nbsp;</td>
  335. </tr>
  336. <tr id="rpx_comment_option" class="rpx_tr_lt rpx_tr_sub">
  337. <td class="rpx_td">
  338. <span class="rpx_note"><label for="rpxcomm">Login link for comments:</label>
  339. <select id="rpxcomm" name="<?php echo RPX_COMMENT_OPTION; ?>">
  340. <option value="none"<?php if (get_option(RPX_COMMENT_OPTION) == 'none'){ echo ' selected="selected"'; } ?>>None</option><?php
  341. foreach($rpx_comment_actions as $key => $val){?>
  342. <option value="<?php echo $val; ?>"<?php if (get_option(RPX_COMMENT_OPTION) == $val){ echo ' selected="selected"'; } ?>><?php echo $key; ?></option><?php
  343. }?>
  344. </select></span>
  345. <span>*&nbsp;Wordpress&nbsp;3&nbsp;themes.<br />&sup1;&nbsp;For&nbsp;&quot;registered&nbsp;and&nbsp;logged&nbsp;in&nbsp;to&nbsp;comment&quot;</span>
  346. </td>
  347. <td class="rpx_td_left">&nbsp;</td>
  348. </tr>
  349. <tr class="rpx_tr_dk">
  350. <td class="rpx_td">
  351. <h3>Sign-In Registration</h3>
  352. Click <a href="?page=<?php echo RPX_MENU_SLUG; ?>&amp;rpx_cleanup=true">here</a> to remove Engage incomplete (no email) accounts older than <?php echo RPX_CLEANUP_AGE; ?> minutes old.
  353. </td>
  354. <td class="rpx_td">&nbsp;</td>
  355. </tr>
  356. <tr class="rpx_tr_dk rpx_tr_sub">
  357. <td class="rpx_td"><?php
  358. $rpx_reg_mesg = '';
  359. if (get_option('users_can_register') != 1){
  360. $rpx_reg_mesg = '(You must enable the Wordpress General Setting for Membership "<a href="./options-general.php#users_can_register">Anyone can register</a>".)';
  361. }
  362. ?>
  363. <label for="rpxautoreg">Enable automatic user registration <?php echo $rpx_reg_mesg; ?></label>
  364. <input id="rpxautoreg" type="checkbox" name="<?php echo RPX_AUTOREG_OPTION; ?>" value="true"<?php if (get_option(RPX_AUTOREG_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  365. </td>
  366. <td class="rpx_td">
  367. <?php if (get_option(RPX_AUTOREG_OPTION) == 'true'){ ?>
  368. <label for="rpxverifyname">Force users to select username:</label>
  369. <input id="rpxverifyname" type="checkbox" name="<?php echo RPX_VERIFYNAME_OPTION; ?>" value="true"<?php if (get_option(RPX_VERIFYNAME_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  370. <?php } else { ?>
  371. &nbsp;
  372. <?php } ?>
  373. </td>
  374. </tr>
  375. <tr class="rpx_tr_lt">
  376. <td class="rpx_td">
  377. <h3>General User Experience</h3>
  378. </td>
  379. <td class="rpx_td">&nbsp;</td>
  380. </tr>
  381. <tr class="rpx_tr_lt rpx_tr_sub">
  382. <td class="rpx_td">
  383. <label for="rpxavatar">Use social provider avatars on comments:</label>
  384. <input id="rpxavatar" type="checkbox" name="<?php echo RPX_AVATAR_OPTION; ?>" value="true"<?php if (get_option(RPX_AVATAR_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  385. </td>
  386. <td class="rpx_td">&nbsp;</td>
  387. </tr>
  388. <tr class="rpx_tr_lt rpx_tr_sub">
  389. <td class="rpx_td">
  390. <label for="rpxremovable">Allow users to remove their Engage provider and data:</label>
  391. <input id="rpxremovable" type="checkbox" name="<?php echo RPX_REMOVABLE_OPTION; ?>" value="true"<?php if (get_option(RPX_REMOVABLE_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  392. </td>
  393. <td class="rpx_td">&nbsp;</td>
  394. </tr>
  395. <?php
  396. $rpx_social_pub = get_option(RPX_SOCIAL_PUB);
  397. if ( !empty($rpx_social_pub) ){?>
  398. <tr class="rpx_tr_dk">
  399. <td class="rpx_td">
  400. <h3>Social Sharing Settings</h3>
  401. Setup Social Sharing widget <a target="_blank" href="<?php echo get_option(RPX_ADMIN_URL_OPTION); echo RPX_SOCIAL_SETUP_URL; ?>">here</a>.
  402. </td>
  403. <td class="rpx_td">&nbsp;</td>
  404. </tr>
  405. <tr class="rpx_tr_dk rpx_tr_sub">
  406. <td class="rpx_td">
  407. <label for="rpxsocial">Enable social sharing:</label>
  408. <input onclick="rpxshowhide('rpxsocial','rpx_share_option');rpxshowhide('rpxsocial','rpx_share_option2');" id="rpxsocial" type="checkbox" name="<?php echo RPX_SOCIAL_OPTION; ?>" value="true"<?php if (get_option(RPX_SOCIAL_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  409. </td>
  410. <td class="rpx_td">&nbsp;</td>
  411. </tr>
  412. <tr id="rpx_share_option" class="rpx_tr_dk rpx_tr_sub">
  413. <td class="rpx_td">
  414. <label for="rpxsloc">Share link on articles:</label>
  415. <select id="rpxsloc" name="<?php echo RPX_S_LOC_OPTION; ?>">
  416. <option value="none"<?php if (get_option(RPX_S_LOC_OPTION) == 'none'){ echo ' selected="selected"'; } ?>>None</option>
  417. <option value="top"<?php if (get_option(RPX_S_LOC_OPTION) == 'top'){ echo ' selected="selected"'; } ?>>at opening of article</option>
  418. <option value="bottom"<?php if (get_option(RPX_S_LOC_OPTION) == 'bottom'){ echo ' selected="selected"'; } ?>>at closing of article</option>
  419. </select>
  420. </td>
  421. <td class="rpx_td">&nbsp;</td>
  422. </tr>
  423. <tr id="rpx_share_option2" class="rpx_tr_dk rpx_tr_sub">
  424. <td class="rpx_td">
  425. <label for="rpxsoccom">Share link on comments:</label>
  426. <input id="rpxsoccom" type="checkbox" name="<?php echo RPX_SOCIAL_COMMENT_OPTION; ?>" value="true"<?php if (get_option(RPX_SOCIAL_COMMENT_OPTION) == 'true'){ echo ' checked="checked"'; } ?> />
  427. </td>
  428. <td class="rpx_td">
  429. <label for="rpxshct">Show count bubbles:</label>
  430. <select id="rpxshct" name="<?php echo RPX_SHARE_COUNT_OPTION; ?>">
  431. <option value="false"<?php if (get_option(RPX_SHARE_COUNT_OPTION) == 'false'){ echo ' selected="selected"'; } ?>>none</option>
  432. <option value="hover"<?php if (get_option(RPX_SHARE_COUNT_OPTION) == 'hover'){ echo ' selected="selected"'; } ?>>on mouse hover</option>
  433. <option value="always"<?php if (get_option(RPX_SHARE_COUNT_OPTION) == 'always'){ echo ' selected="selected"'; } ?>>always on</option>
  434. </select>
  435. </tr>
  436. <tr id="rpx_share_option3" class="rpx_tr_dk rpx_tr_sub">
  437. <td class="rpx_td">
  438. <label for="rpxsloc">Share link style:</label>
  439. <select id="rpxsloc" name="<?php echo RPX_S_STYLE_OPTION; ?>">
  440. <option value="icon"<?php if (get_option(RPX_S_STYLE_OPTION) == 'icon'){ echo ' selected="selected"'; } ?>>Icons</option>
  441. <option value="label"<?php if (get_option(RPX_S_STYLE_OPTION) == 'label'){ echo ' selected="selected"'; } ?>>Text</option>
  442. </select>
  443. </td>
  444. <td class="rpx_td">
  445. <label for="rpxsharetxt">Share label/button text (use &amp;nbsp; for none):</label>
  446. <input id="rpxsharetxt" name="<?php echo RPX_S_TXT_OPTION; ?>" type="text" size=30 value="<?php
  447. $rpx_s_txt = get_option(RPX_S_TXT_OPTION);
  448. if ( empty($rpx_s_txt) ) {
  449. $rpx_s_txt = RPX_S_TXT_OPTION_DEFAULT;
  450. }
  451. echo $rpx_s_txt;
  452. ?>" />
  453. </td>
  454. </tr>
  455. <script type="text/javascript">rpxshowhide('rpxsocial','rpx_share_option');rpxshowhide('rpxsocial','rpx_share_option2');rpxshowhide('rpxsocial','rpx_share_option3');</script><?php
  456. }else{?>
  457. <tr class="rpx_tr_dk rpx_tr_sub">
  458. <td class="rpx_td">
  459. Visit your <a href="<?php echo get_option(RPX_ADMIN_URL_OPTION); echo RPX_SOCIAL_SETUP_URL; ?>" target="_blank">Social Widget Setup</a> if you would like to enable social sharing.<br />
  460. To update the plugin you must click Save after you are done.
  461. </td>
  462. <td class="rpx_td">&nbsp;</td>
  463. </tr><?php
  464. }
  465. }?>
  466. </table>
  467. <p class="submit">
  468. <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
  469. </p>
  470. </form>
  471. </div><?php
  472. }
  473. function rpx_admin_advanced_menu_view() {
  474. if (current_user_can(RPX_OPTIONS_ROLE) === false) {
  475. return false;
  476. }
  477. global $rpx_advanced;
  478. ?>
  479. <style type="text/css">
  480. .rpx_tr_lt {
  481. background-color:#EEE;
  482. }
  483. .rpx_tr_dk {
  484. background-color:#DDD;
  485. }
  486. .rpx_td {
  487. text-align:left;
  488. }
  489. .rpx_td label {
  490. display:block;
  491. float:left;
  492. width:180px;
  493. }
  494. .rpx_string {
  495. width:220px;
  496. }
  497. </style>
  498. <div class="wrap">
  499. <h2>Janrain Engage Expert Options</h2>
  500. <?php rpx_print_messages(); ?>
  501. <p style="font-weight:bold">Do not change these if you are unsure. Erase any setting and Save to reset to default.</p>
  502. <form method="post" action="options.php">
  503. <table class="form-table">
  504. <?php settings_fields( 'rpx_advanced_settings_group' );
  505. $rpx_advanced_array = get_option(RPX_ADVANCED_OPTION);
  506. $rpx_flip = 'lt';
  507. foreach($rpx_advanced as $key => $val) {
  508. if ( !empty($rpx_advanced_array[$key]) ) {
  509. $value = $rpx_advanced_array[$key];
  510. }else{
  511. $value = $val['default'];
  512. }
  513. ?>
  514. <tr class="rpx_tr_<?php echo $rpx_flip; if ($rpx_flip == 'lt') { $rpx_flip = 'dk'; }else{ $rpx_flip = 'lt'; } ?>">
  515. <td class="rpx_td">
  516. <label class="rpx_label" for="<?php echo $key; ?>"><?php echo $key; ?>: </label>
  517. <input id="<?php echo $key; ?>" class="rpx_string" type="text" name="<?php echo RPX_ADVANCED_OPTION.'['.$key.']'; ?>" value="<?php echo $value; ?>" style="width:100%"/>
  518. </td>
  519. <td class="rpx_td"><?php echo $val['desc']; ?></td>
  520. </tr><?php
  521. }
  522. ?>
  523. </table>
  524. <p class="submit">
  525. <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
  526. </p>
  527. </form>
  528. </div>
  529. <?php
  530. }
  531. function rpx_admin_string_menu_view() {
  532. if (current_user_can(RPX_OPTIONS_ROLE) === false) {
  533. return false;
  534. }
  535. global $rpx_strings;
  536. ?>
  537. <style type="text/css">
  538. .rpx_tr_lt {
  539. background-color:#EEE;
  540. }
  541. .rpx_tr_dk {
  542. background-color:#DDD;
  543. }
  544. .rpx_td {
  545. text-align:left;
  546. }
  547. .rpx_td label {
  548. display:block;
  549. float:left;
  550. width:180px;
  551. }
  552. .rpx_string {
  553. width:220px;
  554. }
  555. </style>
  556. <div class="wrap">
  557. <h2>Janrain Engage Strings</h2>
  558. <?php rpx_print_messages(); ?>
  559. <form method="post" action="options.php">
  560. <table class="form-table">
  561. <?php settings_fields( 'rpx_string_settings_group' );
  562. $rpx_strings_array = get_option(RPX_STRINGS_OPTION);
  563. $rpx_flip = 'lt';
  564. foreach($rpx_strings as $key => $val) {
  565. if ( !empty($rpx_strings_array[$key]) ) {
  566. $value = $rpx_strings_array[$key];
  567. }else{
  568. $value = $val['default'];
  569. }
  570. ?>
  571. <tr class="rpx_tr_<?php echo $rpx_flip; if ($rpx_flip == 'lt') { $rpx_flip = 'dk'; }else{ $rpx_flip = 'lt'; } ?>">
  572. <td class="rpx_td">
  573. <label class="rpx_label" for="<?php echo $key; ?>"><?php echo $key; ?>: </label>
  574. <input id="<?php echo $key; ?>" class="rpx_string" type="text" name="<?php echo RPX_STRINGS_OPTION.'['.$key.']'; ?>" value="<?php echo $value; ?>" style="width:100%"/>
  575. </td>
  576. <td class="rpx_td"><?php echo $val['desc']; ?></td>
  577. </tr><?php
  578. }
  579. ?>
  580. </table>
  581. <p class="submit">
  582. <input type="submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
  583. </p>
  584. </form>
  585. </div>
  586. <?php
  587. }
  588. function rpx_admin_help_menu_view() {
  589. if (current_user_can(RPX_OPTIONS_ROLE) === false) {
  590. return false;
  591. }
  592. $readme_txt = file_get_contents(RPX_PATH_ROOT.'/readme.txt');
  593. $readme_txt_lines = explode("\n", $readme_txt);
  594. $readme_txt_clean = '';
  595. foreach ($readme_txt_lines as $key => $val) {
  596. $readme_txt_clean .= htmlentities(wordwrap($val, 90, "\n "));
  597. $readme_txt_clean .= "\n";
  598. }
  599. ?>
  600. <style type="text/css">
  601. .rpx_pre_box {
  602. display:block;
  603. overflow:auto;
  604. font-family:serif;
  605. font-size:14px;
  606. width:760px;
  607. height:570px;
  608. border:5px solid #C6C6C6;
  609. border-top:0;
  610. border-right:2px solid #C6C6C6;
  611. background-color:transparent;
  612. margin:4px;
  613. margin-top:0;
  614. padding:6px;
  615. padding-top:0px;
  616. }
  617. .rpx_pre_box p {
  618. font-family:serif;
  619. font-size:14px;
  620. }
  621. #rpx_help_menu {
  622. width:773px;
  623. margin:4px;
  624. margin-top:16px;
  625. margin-bottom:0;
  626. padding:3px;
  627. background-color:#C6C6C6;
  628. }
  629. #rpx_help_menu span {
  630. padding:6px;
  631. margin:5px;
  632. background-color:#EEE;
  633. }
  634. </style>
  635. <h2>Janrain Engage Help</h2>
  636. <div id="rpx_help_menu">
  637. <span id="rpx_setupguide_button" class="rpx_button" onclick="rpxShowById('rpx_setupguide'); return false"><a href="">setup guide</a></span>
  638. <span id="rpx_shortcodes_button" class="rpx_button" onclick="rpxShowById('rpx_shortcodes'); return false"><a href="">shortcodes</a></span>
  639. <span id="rpx_trouble_button" class="rpx_button" onclick="rpxShowById('rpx_trouble'); return false"><a href="">troubleshooting</a></span>
  640. <span id="rpx_readme_button" class="rpx_button" onclick="rpxShowById('rpx_readme'); return false"><a href="">read me</a></span>
  641. </div>
  642. <div id="rpx_help_items">
  643. <div id="rpx_setupguide" class="rpx_pre_box rpx_help_item">
  644. <h3>Setup Guide</h3>
  645. <p>
  646. Welcome to Janrain Engage for Wordpress. This guide will help you get this plugin setup.
  647. <br>
  648. Use of this plugin requires an Engage application. Janrain offers Engage applications at
  649. multiple service levels and with prices starting at $0. Please visit our
  650. <a href="http://www.janrain.com/products/engage/features-comparison" target="_blank">feature comparison page</a>
  651. to find the service level that is right for your site(s).
  652. </p><p>
  653. Once you
  654. <a href="https://rpxnow.com/" target="_blank">sign in</a> to your Engage application you
  655. can easily access the API key to enable the plugin.
  656. </p>
  657. <h3>Sign In Setup</h3>
  658. <p>
  659. Copy the API key from the Application Info on the main page of your Engage dashboard and paste
  660. into the API key option on the Setup panel for Janrain Engage on your Wordpress admin dashboard.
  661. Click the Save Settings button; the plugin will retrive the needed settings from the Engage system
  662. and save those settings for you. This will unlock the full set of options.
  663. </p><p>
  664. Setup the sign in providers on <a href="https://rpxnow.com/" target="_blank">Engage</a>. Select
  665. the sign-in for web settings. Skip to the Choose Providers step. Drag and drop your desired
  666. providers into the widget. If a provider has a grey gear icon it will require setup steps on
  667. that provider's website. When you drag the provider or click the gear you will be offered a
  668. setup guide to walk you through enabling the provider. Click save when you are done.
  669. </p><p>
  670. After you click save you will see a link to allow you to test the widget. Please test each provider
  671. to ensure that everything works. Providers that offer an email address will work best with
  672. Wordpress due to the requirement for email addresses for each user. Check the
  673. <a href="https://rpxnow.com/docs/providers" target="_blank">provider guide</a> to familiarize
  674. yourself with what each provider offers in the data returned.
  675. </p><p>
  676. Add your site domain to the token URL domain list. Click the settings option on your Engage
  677. dashboard to access the page with the allowed domain list. Add your domain and click save.
  678. </p><p>
  679. Back to the Wordpress Janrain Engage Setup page. Clicking save will update the icons shown to
  680. your visitors. Click it a second time if needed.
  681. </p><p>
  682. The verfiedEmail match setting allows existing users to get automatically connected to thier
  683. existing account if possible. This is not needed for a new site. There are some security concerns
  684. around this feature. Do not enable this if security is a top concern. This feature does not work
  685. to connect to the admin account (id 0). If you would like to connect this account to Engage please
  686. do so via the profile page for that user.
  687. </p><p>
  688. The login link for comments feature can be confusing. This feature adds an Engage login prompt to
  689. the comment area. There are many template action hook options for this area and you may need to
  690. experiment or examine the template source to find the correct option. For a template that is up to
  691. WP3 standards the main question is if you require sign in or not. If you do you will want the hook
  692. named comment_form_must_log_in, and if not you will likely want comment_form_before_fields.
  693. </p><p>
  694. The plugin includes a Wordpress Sidebar Widget. Look in Appearance -&gt; Widgets to find this widget.
  695. </p><p>
  696. If none of these options are working you may want to look at using a shortcode in your template.
  697. <br>See the shortcode page for more info.
  698. </p><p>
  699. Hint:
  700. <br><em>To set a language for the widget you can use the expert option for additional URL parameters.
  701. <br>(e.g. language_preference=fr would set French)</em>
  702. </p>
  703. <h3>Registration Setup</h3>
  704. <p>
  705. Enable automatic user registration if your blog is not using user registration customizations or
  706. supplimentary user registration forms (such as BuddyPress). This feature will enable your visitors
  707. register and sign in very quickly if they have a full profile shared from the Engage sign on.
  708. </p>
  709. <h3>General User Experience Setup</h3>
  710. <p>
  711. Enable social provider icons to display the avatar from the Engage provider instead of the generic
  712. Wordpress icons.
  713. </p>
  714. <h3>Social Sharing Setup</h3>
  715. <p>
  716. Setup the social providers on <a href="https://rpxnow.com/" target="_blank">Engage</a>. Select
  717. the social sharing for websites panel. Skip to the Choose Providers step. Drag and drop your desired
  718. providers into the widget. These providers will require setup steps on each provider's website.
  719. When you drag the provider or click the gear you will be offered a setup guide to walk you through
  720. enabling the provider. Click save when you are done.
  721. </p><p>
  722. <p>
  723. Enable social sharing and click save changes to reveal the full options. These options are intended
  724. to work with fully up to date WP3 templates. The JS for this widget looks for an img element with
  725. id="rpxshareimg" and adds this image to the share if found.
  726. <br>Enable the count bubbles to track and display counters for each successful share per provider.
  727. <br> (counts are not tracked if this feature is not enabled)
  728. <br>
  729. <br>If you are having trouble getting these options to work you may need to add shortcodes to your
  730. template. See the shortcode page for more info.
  731. <br>
  732. The share widget button can be displayed as a row of icons or as a text link.
  733. </p>
  734. </div>
  735. <div id="rpx_shortcodes" class="rpx_pre_box rpx_help_item">
  736. <h3>Shortcodes</h3>
  737. <div id="rpxshare_shortcode" style="width:734px; background-color:#FEFEFE; padding:6px;">
  738. <p><strong>Social share button</strong> (social sharing must be enabled in setup):</p>
  739. Tag name: <em>rpxshare</em>
  740. <br>Parameters:
  741. <ul>
  742. <li>link = URL for the shared comment, defaults to the permalink for the current post or page.</li>
  743. <li>title = TEXT for the link, defaults to the title of the current post or page.</li>
  744. <li>style = "icon" or "label", defaults to "icon" labelled icons style link. The "label" style produces a text only link.</li>
  745. <li>label = TEXT for the link
  746. <li>imgsrc = URL for an image to be shown with the share, defaults to none unless there is an img with id="rpxshareimg" on the page.</li>
  747. <li>[rpxshare]TEXT[/rpxshare] - The text inside the rpxshare shortcode tags is used as the link descriptive summary for the post.</li>
  748. </ul>
  749. <pre style="font-size:10px;">Example shortcode:
  750. [rpxshare link="http://www.janrain.com" title="Cool Link" style="icon" label="cool"]Welcome to social blogging.[/rpxshare]
  751. </pre>
  752. <div style="width:150px; float:left; position:relative;">
  753. Example result:<br><?php
  754. rpx_inline_javascript();
  755. echo do_shortcode('[rpxshare link="http://www.janrain.com" title="Cool Link" style="icon" label="cool"]Welcome to social blogging.[/rpxshare]'); ?>
  756. </div><div class="clear">&nbsp;</div>
  757. </div>
  758. <div id="rpxlogin_shortcode" style="width:734px; background-color:#FEFEFE; padding:6px;">
  759. <p><strong>Social login button</strong> (plugin must be enabled and setup):</p>
  760. Tag name: <em>rpxlogin</em>
  761. <br>Parameters:
  762. <ul>
  763. <li>redirect = URL for the shared comment, defaults to the permalink for the current post or page.</li>
  764. <li>prompt = TEXT for the link, defaults to the title of the current post or page.</li>
  765. <li>style = "small" or "large", defaults to "icon" labelled icons style link. The "label" style produces a text only link.</li>
  766. </ul>
  767. <pre style="font-size:10px;">Example shortcode:
  768. [rpxlogin redirect="http://www.janrain.com" prompt="Authenticate!" style="large"]
  769. </pre>
  770. <div style="width:150px; float:left; position:relative;">
  771. Example result:<br><?php
  772. echo do_shortcode('[rpxlogin redirect="http://www.janrain.com" prompt="Authenticate!" style="large"]'); ?>
  773. </div><div class="clear">&nbsp;</div>
  774. </div>
  775. </div>
  776. <div id="rpx_trouble" class="rpx_pre_box rpx_help_item">
  777. <h3>Troubleshooting</h3>
  778. <p>Visit the Q&amp;A discussion on the <a href="<?php echo RPX_PLUGIN_HELP_URL; ?>" target="_blank">Janrain Support site</a>.</p>
  779. <div id="status" style="display:none"></div>
  780. <div id="ajaxreader"></div>
  781. </div>
  782. <div id="rpx_readme" class="rpx_pre_box rpx_help_item">
  783. <h3>Read Me</h3>
  784. <pre>
  785. <?php echo $readme_txt_clean; ?>
  786. </pre>
  787. </div>
  788. </div>
  789. <script type="text/javascript">
  790. function rpxHideAll() {
  791. var theItems = document.getElementById('rpx_help_items').getElementsByTagName('div');
  792. if (theItems != null) {
  793. for(var i in theItems){
  794. if (theItems[i].id != null) {
  795. if (theItems[i].className.search('rpx_help_item') >= 0) {
  796. rpxHideById(theItems[i].id)
  797. }
  798. }
  799. }
  800. }
  801. var menuItems = document.getElementById('rpx_help_menu').getElementsByTagName('span');
  802. if (menuItems != null) {
  803. for(var i in menuItems){
  804. if (menuItems[i].id != null) {
  805. if (menuItems[i].className.search('rpx_button') >= 0) {
  806. rpxClearOutById(menuItems[i].id)
  807. }
  808. }
  809. }
  810. }
  811. }
  812. function rpxOutById(theId) {
  813. document.getElementById(theId).style.outline = '1px solid #BBB';
  814. }
  815. function rpxClearOutById(theId) {
  816. document.getElementById(theId).style.outline = '';
  817. }
  818. function rpxShowById(theId) {
  819. rpxHideAll();
  820. document.getElementById(theId).style.display = 'block';
  821. rpxOutById(theId+'_button');
  822. }
  823. function rpxHideById(theId) {
  824. document.getElementById(theId).style.display = 'none';
  825. }
  826. rpxShowById('rpx_setupguide');
  827. </script>
  828. <script type="text/javascript">
  829. var RSSRequestObject = false; // XMLHttpRequest Object
  830. var Backend = '<?php echo RPX_PLUGIN_URL; ?>/help_feed.php'; // Backend url
  831. if (window.XMLHttpRequest) // try to create XMLHttpRequest
  832. RSSRequestObject = new XMLHttpRequest();
  833. if (window.ActiveXObject) // if ActiveXObject use the Microsoft.XMLHTTP
  834. RSSRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
  835. /*
  836. * onreadystatechange function
  837. */
  838. function ReqChange() {
  839. // If data received correctly
  840. if (RSSRequestObject.readyState==4) {
  841. // if data is valid
  842. if (RSSRequestObject.responseText.indexOf('invalid') == -1) {
  843. // Parsing RSS
  844. var node = RSSRequestObject.responseXML.documentElement;
  845. // Get Channel information
  846. var channel = node.getElementsByTagName('channel').item(0);
  847. var title = channel.getElementsByTagName('title').item(0).firstChild.data;
  848. var link = channel.getElementsByTagName('link').item(0).firstChild.data;
  849. var link = '<?php echo RPX_PLUGIN_HELP_URL; ?>';
  850. content = '<div class="channeltitle"><a href="'+link+'" target="_blank">'+title+'</a></div><ul>';
  851. // Browse items
  852. var items = channel.getElementsByTagName('item');
  853. for (var n=0; n < items.length; n++) {
  854. var itemTitle = items[n].getElementsByTagName('title').item(0).firstChild.data.replace('in Wordpress Plugin Q&A ','').slice(0,130);
  855. var itemLink = items[n].getElementsByTagName('link').item(0).firstChild.data;
  856. try {
  857. //theDateShort = items[n].getElementsByTagName('pubDate').item(0).firstChild.data;
  858. var theDate = new Date(items[n].getElementsByTagName('pubDate').item(0).firstChild.data);
  859. var theMonth = theDate.getMonth();
  860. theMonth++;
  861. var theDay = theDate.getDate();
  862. var theDateShort = theMonth+'/'+theDay;
  863. var itemPubDate = '<font color=gray>['+theDateShort+'] ';
  864. }
  865. catch (e) {
  866. var itemPubDate = '';
  867. }
  868. content += '<li>'+itemPubDate+'</font><a href="'+itemLink+'" target="_blank">'+itemTitle+'</a></li>';
  869. }
  870. content += '</ul>';
  871. // Display the result
  872. document.getElementById("ajaxreader").innerHTML = content;
  873. // Tell the reader the everything is done
  874. document.getElementById("status").innerHTML = "Done.";
  875. } else {
  876. // Tell the reader that there was error requesting data
  877. document.getElementById("status").innerHTML = "<div class=error>Error requesting data.<div>";
  878. }
  879. HideShow('status');
  880. }
  881. }
  882. /*
  883. * Main AJAX RSS reader request
  884. */
  885. function RSSRequest() {
  886. // change the status to requesting data
  887. HideShow('status');
  888. document.getElementById("status").innerHTML = "Requesting data ...";
  889. // Prepare the request
  890. RSSRequestObject.open("GET", Backend , true);
  891. // Set the onreadystatechange function
  892. RSSRequestObject.onreadystatechange = ReqChange;
  893. // Send
  894. RSSRequestObject.send(null);
  895. }
  896. /*
  897. * Timer
  898. */
  899. function update_timer() {
  900. RSSRequest();
  901. }
  902. function HideShow(id){
  903. var el = GetObject(id);
  904. if(el.style.display=="none")
  905. el.style.display='';
  906. else
  907. el.style.display='none';
  908. }
  909. function GetObject(id){
  910. var el = document.getElementById(id);
  911. return(el);
  912. }
  913. RSSRequest();
  914. </script>
  915. <?php
  916. }
  917. function rpx_message_box($message='') {
  918. if ( empty($message) ){
  919. global $rpx_messages;
  920. $messages = array();
  921. foreach ($rpx_messages as $key=>$msg){
  922. if ($msg['class'] == 'message'){
  923. $messages[] = $msg['message'];
  924. }
  925. }
  926. $message = '<p>'.implode('<br />', $messages).'</p>';
  927. }
  928. ?>
  929. <div id="rpxmsgbox" class="rpxbox rpxmsgbox">
  930. <div id="rpxmsgw1" class="rpxhoriz"></div>
  931. <table id="rpxmsgw2" class="rpxvert"><tr id="rpxvrow" class="rpxvrow"><td id="rpxvcol" class="rpxvcol">
  932. <span id="rpxmsgborder" class="rpxborder">
  933. <span id="rpxmsgclose" class="rpxclose" onclick="hideRPX('rpxmsgbox')"><img src="<?php echo RPX_IMAGE_URL; ?>close.png" alt="close" /></span>
  934. <div id="rpxmsg" class="rpxmsg">
  935. <div id="rpxmessage" class="rpxmessage"><?php echo $message; ?></div>
  936. </div></span></td></tr></table></div>
  937. <script type="text/javascript">
  938. showRPX('rpxmsgbox');
  939. </script>
  940. <?php
  941. }
  942. function rpx_register_form($collect='email') {
  943. global $rpx_http_vars;
  944. if ($rpx_http_vars['rpx_collect'] == 'username'){
  945. $collect = 'username';
  946. }
  947. ?>
  948. <div id="rpxregbox" class="rpxbox rpxregbox" onload="showRPX('rpxregbox');">
  949. <div id="rpxregw1" class="rpxhoriz"></div>
  950. <table id="rpxregw2" class="rpxvert"><tr id="rpxvrow" class="rpxvrow"><td id="rpxvcol" class="rpxvcol">
  951. <span id="rpxregborder" class="rpxborder">
  952. <span id="rpxregclose" class="rpxclose" onclick="hideRPX('rpxregbox');"><img src="<?php echo RPX_IMAGE_URL; ?>close.png" alt="close" /></span>
  953. <div id="rpxregister" class="rpxregister">
  954. <?php rpx_print_messages(); ?>
  955. <form id="rpxregform" class="rpxregform" action="" method="get">
  956. <input type="hidden" name="action" value="<?php echo RPX_REGISTER_FORM_ACTION ?>" />
  957. <input type="hidden" name="rpx_collect" value="<?php echo urlencode($rpx_http_vars['rpx_collect']); ?>" />
  958. <input type="hidden" name="rpx_session" value="<?php echo urlencode($rpx_http_vars['rpx_session']); ?>" />
  959. <input type="hidden" name="rpx_provider" value="<?php echo urlencode($rpx_http_vars['rpx_provider']); ?>" />
  960. <input type="hidden" name="redirect_to" value="<?php echo urlencode($rpx_http_vars['redirect_to']); ?>" />
  961. <?php
  962. if ($collect == 'email'){
  963. echo ' <input type="hidden" name="rpx_username" value="'.urlencode($rpx_http_vars['rpx_username']).'" />'."\n";
  964. echo ' <p><input type="text" name="rpx_email" value="" id="rpxemail" class="rpxemail" size="30" /></p>';
  965. }elseif ($collect == 'username'){
  966. echo ' <input type="hidden" name="rpx_email" value="'.urlencode($rpx_http_vars['rpx_email']).'" />'."\n";
  967. echo ' <p><input type="text" name="rpx_username" value="" id="rpxusername" class="rpxusername" size="30" /></p>';
  968. if (RPX_REQUIRE_EULA == 'true') {
  969. echo ' <p><label for="rpx_eula">'.RPX_EULA_PROMPT.'</label><input id="rpx_eula" name="rpx_eula" type="checkbox" value="eula" /><a href="'.RPX_EULA_URL.'" target="_blank">EULA</a><p>';
  970. }
  971. }else{
  972. echo ' <input type="hidden" name="rpx_username" value="'.urlencode($rpx_http_vars['rpx_username']).'" />'."\n";
  973. echo ' <input type="hidden" name="rpx_email" value="'.urlencode($rpx_http_vars['rpx_email']).'" />'."\n";
  974. echo $collect;//$collect as html to ask for something else, maybe useful later
  975. }
  976. ?>
  977. <input id="rpxsubmit" class="rpxsubmit" type="submit" value="Submit" />
  978. </form>
  979. </div></span></td></tr></table></div>
  980. <script type="text/javascript">
  981. showRPX('rpxregbox');
  982. </script>
  983. <?php
  984. }
  985. function rpx_open_widget(){
  986. global $rpx_http_vars;
  987. $add_parameters = '';
  988. if( !empty($rpx_http_vars['rpx_username']) ){
  989. $add_parameters .= '&rpx_username='.urlencode($rpx_http_vars['rpx_username']);
  990. }
  991. $add_parameters = urlencode($add_parameters);
  992. ?>
  993. <script type="text/javascript">
  994. document.getElementById('rpxiframe').src += '<?php echo $add_parameters; ?>';
  995. showRPX('rpxlogin');
  996. </script>
  997. <?php
  998. }
  999. function rpx_wp_footer(){
  1000. global $rpx_http_vars;
  1001. global $rpx_footer_done;
  1002. if ($rpx_footer_done === true) {
  1003. return false;
  1004. }
  1005. if ($rpx_http_vars['action'] == RPX_REGISTER_FORM_ACTION){
  1006. rpx_register_form();
  1007. }
  1008. $user_data = rpx_user_data();
  1009. if ($user_data != false && !empty($user_data->rpx_provider) && did_action('show_user_profile') === false){
  1010. return true;
  1011. }
  1012. ?>
  1013. <div id="rpxlogin" class="rpxbox" style="display:none">
  1014. <div id="fiftyfifty" class="rpxhoriz"></div>
  1015. <table id="rpxvertical" class="rpxvert"><tr id="rpxvrow" class="rpxvrow"><td id="rpxvcol" class="rpxvcol">
  1016. <span id="rpx_border" class="rpxborder">
  1017. <span id="rpx_close" class="rpxclose" onclick="hideRPX('rpxlogin')"><img src="<?php echo RPX_IMAGE_URL; ?>close.png" alt="close" /></span>
  1018. <?php echo rpx_iframe_widget(); ?>
  1019. </span></td></tr></table></div>
  1020. <?php
  1021. $rpx_footer_done = true;
  1022. }
  1023. function rpx_iframe_widget($redirect_url=NULL) {
  1024. global $rpx_http_vars;
  1025. $iframe = '';
  1026. $realm = get_option(RPX_REALM_OPTION);
  1027. $site_url = site_url();
  1028. $permalink = get_permalink();
  1029. if (stripos($site_url, 'https:') === false){
  1030. $realm_scheme = 'http';
  1031. }else{
  1032. $realm_scheme = 'https';
  1033. }
  1034. if ( empty($redirect_url) && !empty($rpx_http_vars['redirect_to']) ) {
  1035. $redirect_url = $rpx_http_vars['redirect_to'];
  1036. }
  1037. if ( empty($redirect_url) && !empty($permalink) && !is_front_page() ) {
  1038. $redirect_url = $permalink;
  1039. }
  1040. if ( empty($redirect_url) && !empty($site_url) ) {
  1041. $redirect_url = $site_url;
  1042. }
  1043. if ( !empty($redirect_url) ) {
  1044. $redirect_to = urlencode($redirect_url);
  1045. $rpx_token_url = urlencode(RPX_TOKEN_URL . '&redirect_to=' . $redirect_to);
  1046. }
  1047. $add_params = get_option(RPX_PARAMS_OPTION);
  1048. if ( empty($add_params) ) {
  1049. $param_query = '';
  1050. } else {
  1051. $param_query = $add_params.'&';
  1052. }
  1053. //token_url must be the final param to allow for easy JS modification
  1054. $iframe_src = $realm_scheme.'://'.$realm .'/openid/embed?'.$param_query.'token_url='.$rpx_token_url;
  1055. $iframe = '<iframe id="rpxiframe" class="rpxiframe" scrolling="no" src="'.$iframe_src.'"></iframe>';
  1056. return $iframe;
  1057. }
  1058. function rpx_login_form() {
  1059. global $rpx_http_vars;
  1060. if (is_user_logged_in()){
  1061. return true;
  1062. }
  1063. if ($rpx_http_vars['action'] == 'register'){
  1064. if (rpx_allow_register() === false){
  1065. return false;
  1066. }
  1067. $logreg = RPX_OR_REGISTER_PROMPT;
  1068. }else{
  1069. $logreg = RPX_OR_LOGIN_PROMPT;
  1070. }
  1071. rpx_print_messages();
  1072. if ( strstr(wp_login_url(), 'wp-login.php') !== false ) {
  1073. rpx_wp_footer();
  1074. }
  1075. ?>
  1076. <div class="rpx_label"><?php echo $logreg; ?></div><?php echo rpx_large_buttons();
  1077. }
  1078. function rpx_login_head() {
  1079. if ( strstr(wp_login_url(), 'wp-login.php') === false ) {
  1080. return false;
  1081. }
  1082. ?>
  1083. <link rel='stylesheet' type='text/css' media='all' href='<?php echo RPX_FILES_URL; ?>stylesheet.css' />
  1084. <script type='text/javascript' src='<?php echo RPX_FILES_URL; ?>javascript.js'></script>
  1085. <?php
  1086. rpx_inline_stylesheet();
  1087. }
  1088. function rpx_content_filter($content){
  1089. $rpx_social_option = get_option(RPX_SOCIAL_OPTION);
  1090. $rpx_social_pub = get_option(RPX_SOCIAL_PUB);
  1091. $rpx_s_loc_option = get_option(RPX_S_LOC_OPTION);
  1092. $in_the_loop = in_the_loop();
  1093. if ($rpx_social_option != 'true' || empty($rpx_social_pub) || $rpx_s_loc_option == 'none' || $in_the_loop === false){
  1094. return $content;
  1095. }
  1096. $rpx_social = rpx_social_share($content);
  1097. if ($rpx_s_loc_option == 'top'){
  1098. return $rpx_social.$content;
  1099. }else{
  1100. return $content.$rpx_social;
  1101. }
  1102. }
  1103. function rpx_comment_filter($comment){
  1104. $rpx_social_comment_option = get_option(RPX_SOCIAL_COMMENT_OPTION);
  1105. $rpx_social_pub = get_option(RPX_SOCIAL_PUB);
  1106. $in_the_loop = in_the_loop();
  1107. if ($rpx_social_comment_option != 'true' || empty($rpx_social_pub) || $in_the_loop === false){
  1108. return $comment;
  1109. }
  1110. $share = rpx_social_share($comment, true);
  1111. return $comment.$share;
  1112. }
  1113. function rpx_avatar_filter($avatar){
  1114. $rpx_avatar_option = get_option(RPX_AVATAR_OPTION);
  1115. if ($rpx_avatar_option != 'true'){
  1116. return $avatar;
  1117. }
  1118. $rpx_avatar = $avatar;
  1119. $rpx_photo = '';
  1120. if (in_the_loop() != false){
  1121. $zero = 0;
  1122. $comment = get_comment($zero);
  1123. if (!is_wp_error($comment->user_id)){
  1124. $user = get_userdata($comment->user_id);
  1125. if (!is_wp_error($user)){
  1126. if (isset($user->rpx_photo)){
  1127. $rpx_photo = $user->rpx_photo;
  1128. }
  1129. }
  1130. }
  1131. }
  1132. if ( !empty($rpx_photo) ) {
  1133. $avatar = str_replace("'", '"', $avatar);
  1134. $pattern = '/src="[^"]*"/';
  1135. $replace = 'src="'.$rpx_photo.'"';
  1136. $rpx_avatar = preg_replace($pattern, $replace, $avatar);
  1137. }
  1138. return $rpx_avatar;
  1139. }
  1140. function rpx_user_provider_icon($author_name = NULL){
  1141. if (in_the_loop() === false && $author_name != NULL){
  1142. return $author_name;
  1143. }
  1144. global $rpx_providers;
  1145. if ($author_name != NULL){
  1146. $zero = 0;
  1147. $comment = get_comment($zero);
  1148. if (!empty($comment->user_id)){
  1149. $user = get_userdata($comment->user_id);
  1150. }
  1151. }else{
  1152. $user = rpx_user_data();
  1153. $author_name = $user->user_login;
  1154. }
  1155. $icon = '';
  1156. if (!empty($user->rpx_provider)){
  1157. $provider = $user->rpx_provider;
  1158. if ( !empty($provider) ){
  1159. $provider = $rpx_providers["$provider"];
  1160. $author = $user->user_login;
  1161. $url = $user->user_url;
  1162. if ( !empty($user->rpx_url) ){
  1163. $url = $user->rpx_url;
  1164. }
  1165. $icon = '<div class="rpx_icon rpx_size16 rpx_'.$provider.' rpx_author" title="'.$author.'"></div>';
  1166. if ( !empty($url) ){
  1167. $icon = '<a href="'.$url.'" rel="external nofollow" target="_blank">'.$icon.'</a>';
  1168. }
  1169. }
  1170. }
  1171. return $icon.$author_name;
  1172. }
  1173. function rpx_social_share($message, $comment=false, $style=NULL, $share_label=NULL, $title=NULL, $link=NULL, $imgsrc=NULL){
  1174. if ( empty($title) ) {
  1175. $title = get_the_title();
  1176. }
  1177. $posttitle = rpx_js_escape(strip_tags($title));
  1178. if ( empty($link) ) {
  1179. $link = get_permalink();
  1180. }
  1181. $postlink = rpx_js_escape(strip_tags($link));
  1182. if ( empty($share_label) ) {
  1183. $share_label = get_option(RPX_S_TXT_OPTION);
  1184. }
  1185. $share_label = strip_tags($share_label);
  1186. if ( empty($imgsrc) ) {
  1187. $imgsrc = '';
  1188. }
  1189. $post_id = get_the_ID();
  1190. $postsummary = rpx_js_escape(substr(strip_tags(strip_shortcodes($message)), 0, 128)).'...';
  1191. $blogname = rpx_js_escape(strip_tags(get_option('blogdescription')));
  1192. $class = 'rpxsocial';
  1193. $verb = RPX_SHARED;
  1194. $label = RPX_SHARE_LABEL;
  1195. if ($comment === true){
  1196. $postlink = rpx_js_escape(strip_tags(get_comment_link()));
  1197. $class = 'rpxsocial_small';
  1198. $verb = RPX_COMMENTED_ON;
  1199. $label = RPX_COMMENT_LABEL;
  1200. $style = 'label';
  1201. }
  1202. if (empty($style)) {
  1203. $style = get_option(RPX_S_STYLE_OPTION);
  1204. }
  1205. $rpx_share_counts = get_post_meta($post_id, RPX_POST_META_COUNTS);
  1206. $share_icons = rpx_social_icons($share_label,$rpx_share_counts);
  1207. switch ($style){
  1208. case 'icon':
  1209. $button = $share_icons;
  1210. $button_label = '';
  1211. break;
  1212. case 'label':
  1213. $button = $share_label;
  1214. $button_label = '';
  1215. break;
  1216. default:
  1217. $button = $share_icons;
  1218. $button_label = $share_label;
  1219. break;
  1220. }
  1221. $share_open = '<div class="'.$class.'">';
  1222. $share_button = '<div class="rpxsharebutton" onclick="rpxWPsocial(';
  1223. $share_button .= "'".$label."','".$postsummary."','".$postlink."','"
  1224. .$posttitle."','".$verb." ".$posttitle."','".$imgsrc."','".$post_id."', this);".'">'.$button.'</div>';
  1225. $share_label = '';
  1226. if ( !empty($button_label) ) {
  1227. $share_label = '<div class="rpx_share_label">'.$button_label.'</div>';
  1228. }
  1229. $share_close = ' &nbsp;</div> <div class="rpx_clear"></div>';
  1230. $share = $share_open.$share_label.$share_button.$share_close;
  1231. return $share;
  1232. }
  1233. class RPX_Widget extends WP_Widget {
  1234. function RPX_Widget() {
  1235. $widget_options = array('classname' => 'rpx-widget', 'description' => 'Sign in with Janrain Engage.');
  1236. $this->WP_Widget('janrain-engage-widget', RPX_WIDGET_TITLE, $widget_options);
  1237. }
  1238. function widget( $args, $instance ) {
  1239. $user_data = rpx_user_data();
  1240. if ($instance['hide'] != 'true' || ($user_data == false

Large files files are truncated, but you can click here to view the full file