nxs_showRepostSettings

The NextScripts: Social Networks Auto-Poster nxs showRepostSettings function.

Description

nxs_showRepostSettings( $nt, $ii, $options ); 

Parameters (3)

0. $nt
The nt.
1. $ii
The ii.
2. $options
The options.

Usage

  1. if ( !function_exists( 'nxs_showRepostSettings' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.php'; 
  3.  
  4. // The nt. 
  5. $nt = null; 
  6.  
  7. // The ii. 
  8. $ii = null; 
  9.  
  10. // The options. 
  11. $options = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = nxs_showRepostSettings($nt, $ii, $options); 
  15.  

Defined (1)

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

/nxs_functions.php  
  1. function nxs_showRepostSettings($nt, $ii, $options) { global $nxs_snapAvNts, $nxs_plurl;  
  2. if (empty($options['rpstPostIncl'])) $options['rpstPostIncl'] = 0; if (empty($options['rpstPostIncl'])) $options['rpstLastShTime'] = ''; if (empty($options['rpstNxTime'])) $options['rpstNxTime'] = ''; 
  3. if (empty($options['rpstLastPostID'])) $options['rpstLastPostID'] = ''; 
  4.  
  5. ?> 
  6. <div class="nxs_tls_cpt"> 
  7. <?php _e('Auto Reposting', 'social-networks-auto-poster-facebook-twitter-g'); ?>  <span class="nxsInstrSpan"><a href="http://www.nextscripts.com/snap-features/old-posts-auto-reposting/" target="_blank"><?php _e('[Instructions]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a>    <b style="color: darkred;">Please note:</b> This feature is depreciated, <a href="http://www.nextscripts.com/blog/old-posts-reposting-no-longer-supported/" target="_blank">no longer supported</a> and will be replaced with something much better in the upcoming ver 3.5 </span> 
  8. </div> 
  9.  
  10. <?php $cr = get_option('NXS_cronCheck'); if (!empty($cr) && is_array($cr) && isset($cr['status']) && $cr['status']=='0') {  
  11. global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $gOptions = $plgn_NS_SNAutoPoster->nxs_options;  
  12. if (isset($gOptions['forceBrokenCron']) && $gOptions['forceBrokenCron'] =='1') { ?>  
  13. <span style="color: red"> <?php _e('Your WP Cron is not working correctly. Auto Reposting service is active by force. <br/> This might cause problems. Please see the test results and recommendations', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  14.  - <a target="_blank" href="<?php global $nxs_snapThisPageUrl; echo $nxs_snapThisPageUrl; ?>&do=crtest">WP Cron Test Results</a></span> 
  15. <?php } else { ?> <span style="color: red"> <?php _e('Auto Reposting service is Disabled. Your WP Cron is not working correctly. Please see the test results and recommendations', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  16.  - <a target="_blank" href="<?php global $nxs_snapThisPageUrl; echo $nxs_snapThisPageUrl; ?>&do=crtest">WP Cron Test Results</a></span> 
  17. <?php return; } } ?> 
  18.  
  19.  
  20. <div class="nxs_tls_bd"> 
  21. <div class="nxs_tls_sbInfo"><?php _e('Plugin could autorepost existing posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></div> 
  22. <input value="1" id="riC<?php echo $ii; ?>" <?php if (isset($options['rpstOn']) && trim($options['rpstOn'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOn]"/>  
  23. <b><?php _e('Repost existing posts every', 'social-networks-auto-poster-facebook-twitter-g'); ?> </b> 
  24.  
  25. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstDays]" style="width: 35px;" value="<?php echo isset($options['rpstDays'])?$options['rpstDays']:'0'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  26. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstHrs]" style="width: 35px;" value="<?php echo isset($options['rpstHrs'])?$options['rpstHrs']:'2'; ?>" /> <?php _e('Hours', 'social-networks-auto-poster-facebook-twitter-g'); ?>   
  27. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstMins]" style="width: 35px;" value="<?php echo isset($options['rpstMins'])?$options['rpstMins']:'0'; ?>" /> <?php _e('Minutes', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  28. <div style="padding-left:10px;padding-top:10px;line-height:30px;">  
  29.  
  30. <b><?php _e('Randomize posting time ±', 'social-networks-auto-poster-facebook-twitter-g'); ?> </b> 
  31. <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstRndMins]" style="width: 35px;" value="<?php echo isset($options['rpstRndMins'])?$options['rpstRndMins']:'15'; ?>" onmouseout="hidePopShAtt('RPST1');" onmouseover="showPopShAtt('RPST1', event);" /> <?php _e('Minutes', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  32. <br/>  
  33. <input value="1" id="riOC<?php echo $ii; ?>" <?php if (isset($options['rpstOnlyPUP']) && trim($options['rpstOnlyPUP'])=='1') echo "checked"; ?> type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOnlyPUP]"/>  
  34. <b><?php _e('Repost ONLY previously unautoposted posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  35. <br/> 
  36. <?php $args=array('public'=>true, '_builtin'=>false); $output = 'names'; $operator = 'and'; $post_types = array();  
  37. if (function_exists('get_post_types')) $post_types=get_post_types($args, $output, $operator);  
  38. if (!empty($post_types) && is_array($post_types)) { ?> 
  39. <b><?php _e('Repost: (Choose Posts, Pages, Custom Post Types)', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  40. <?php $post_typesIncl = array('post'=>'post', 'page'=>'page'); $post_types = array_merge($post_typesIncl, $post_types); if ($options['nxsCPTSeld']=='a:1:{i:0;s:1:"0";}') $options['nxsCPTSeld'] = ''; 
  41. if (!empty($options['nxsCPTSeld'])) $nxsCPTSeld = unserialize($options['nxsCPTSeld']); else $nxsCPTSeld = array('post');  
  42. ?> <div class="nxs_box_inside" style="padding: 0px;" > <div class="itemDiv" style="padding: 0px;"> <div class="taxonomydiv"><div class="tabs-panel" style="padding: 10px;"><input type="hidden" name="nxsCPTSeld[]" value="0" /> <?php //prr($nxsCPTSeld); prr($post_types); prr($_POST['nxsCPTSeld']);  
  43. foreach ($post_types as $cptID=>$cptName) { if (in_array($cptID, $nxsCPTSeld)) $dCh = ' checked="checked" '; else $dCh = ""; 
  44. ?><input type="checkbox" name="<?php echo $nt; ?>[<?php echo $ii; ?>][nxsCPTSeld][]" value="<?php echo esc_attr($cptID); ?>"<?php echo $dCh ?>> <?php echo $cptName ?><br/> <?php 
  45. ?></div></div> </div> </div>  
  46. <?php } ?> 
  47. <?php if (function_exists('nxs_doSMAS41')) nxs_doSMAS41($nt, $ii, $options); ?>  
  48. <b><?php _e('Get posts', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> 
  49. <select id="riS<?php echo $nt; ?><?php echo $ii; ?>" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstType]" onchange="nxs_actDeActTurnOff(jQuery(this).attr('id'));"><?php if (function_exists('nxs_doSMAS42')) nxs_doSMAS42($options); ?>  
  50. <option value="2" <?php if (isset($options['rpstType']) && $options['rpstType']=='2') echo 'selected="selected"' ?>>One By One - Old to New</option><option value="3" <?php if (isset($options['rpstType']) && $options['rpstType']=='3') echo 'selected="selected"' ?>>One By One - New to Old</option> 
  51. </select>  
  52. <br/>  
  53. <div style="padding-left: 15px;"> 
  54. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstTimeType]" value="D" <?php if (isset($options['rpstTimeType']) && $options['rpstTimeType']=='D') echo 'checked="checked"'; ?> /> 
  55.  
  56. <?php _e('from', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstFromTime]" style="width: 75px;" value="<?php echo isset($options['rpstFromTime'])?$options['rpstFromTime']:''; ?>" />   
  57. <?php _e('to', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstToTime]" style="width: 75px;" value="<?php echo isset($options['rpstToTime'])?$options['rpstToTime']:''; ?>" /> 
  58. <br/> 
  59. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstTimeType]" value="A" <?php if (!isset($options['rpstTimeType']) || $options['rpstTimeType']=='A') echo 'checked="checked"'; ?> /> 
  60. <?php _e('Older then', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstOLDays]" style="width: 35px;" value="<?php echo isset($options['rpstOLDays'])?$options['rpstOLDays']:'30'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  61. <?php _e('and Newer then', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstNWDays]" style="width: 35px;" value="<?php echo isset($options['rpstNWDays'])?$options['rpstNWDays']:'365'; ?>" /> <?php _e('Days', 'social-networks-auto-poster-facebook-twitter-g'); ?>  
  62. </div> 
  63. <div id="riS<?php echo $nt; ?><?php echo $ii; ?>xd" style="padding-left: 0px;<?php if (isset($options['rpstType']) && $options['rpstType']=='1') echo "display:none;"; ?>"><b><?php _e('When finished', 'social-networks-auto-poster-facebook-twitter-g'); ?>:</b>  
  64. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="O" <?php if (empty($options['rpstStop']) || (isset($options['rpstStop']) && trim($options['rpstStop'])=='O')) echo "checked"; ?> /> <?php _e('Auto Turn Reposting Off', 'social-networks-auto-poster-facebook-twitter-g') ?> 
  65.     
  66. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="W" <?php if (isset($options['rpstStop']) && trim($options['rpstStop'])=='W') echo 'checked="cheXcked"'; ?> /> <?php _e('Wait for new posts', 'social-networks-auto-poster-facebook-twitter-g') ?> 
  67.     
  68. <input type="radio" name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstStop]" value="R" <?php if (isset($options['rpstStop']) && trim($options['rpstStop'])=='R') echo 'checked="cheTcked"'; ?> /> <?php _e('Loop it. Reset and Start from the begining', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  69. </div> 
  70.  
  71. <hr/> 
  72. <strong style="font-size: 12px; margin: 10px; margin-left: 1px;">New posts will be set by default to:</strong> 
  73. <select name="<?php echo $nt; ?>[<?php echo $ii; ?>][rpstPostIncl]"><option <?php echo !empty($options['rpstPostIncl'])?'selected="selected"':''; ?> value="nxsi<?php echo $ii.$nt; ?>">Enabled for Repost</option> 
  74. <option <?php echo empty($options['rpstPostIncl'])?'selected="selected"':''; ?> value="0">Disabled for Repost</option></select><br/> 
  75. <div style="padding-left: 15px;"> <img id="nxsLoadingImg<?php echo $nt; ?><?php echo $ii; ?>" style="display: none;" src='<?php echo $nxs_plurl; ?>img/ajax-loader-sm.gif' />  
  76.  
  77. <?php  
  78. global $nxs_rpst_older, $nxs_rpst_newer, $nxs_rpst_lastID, $nxs_rpst_lastTime, $nxs_rpst_type, $nxs_rpst_code, $nxs_rpst_NT; $ntOpts = $options;  
  79. $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); 
  80. if (!empty($ntOpts['nxsCPTSeld'])) $tpArray = maybe_unserialize($ntOpts['nxsCPTSeld']); else $tpArray = 'post'; 
  81. if ($ntOpts['rpstType']=='1') $args = array ( 'orderby' => 'rand', 'posts_per_page' => '1', 'post_type' => $tpArray, 'ignore_sticky_posts' => 1, 'post_status' => 'publish', 'suppress_filters' => false );  
  82. if ($ntOpts['rpstType']=='2') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'ASC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false ); 
  83. if ($ntOpts['rpstType']=='3') $args = array ( 'posts_per_page' => '1', 'orderby' => 'date ID', 'order'=>'DESC', 'post_type' => $tpArray, 'post_status' => 'publish', 'suppress_filters' => false );  
  84. $rpstToTime = strtotime($ntOpts['rpstToTime']); if ($currTime < $rpstToTime) $rpstToTime = $currTime; 
  85. $rpstFromTime = strtotime($ntOpts['rpstFromTime']); if ($currTime < $rpstFromTime) $rpstFromTime = $currTime; 
  86. if ($ntOpts['rpstTimeType']=='D') { $nxs_rpst_older = ceil(abs($currTime - $rpstToTime) / 86400); $nxs_rpst_newer = ceil(abs($currTime - $rpstFromTime) / 86400);  
  87. } else { $nxs_rpst_older = $ntOpts['rpstOLDays']; $nxs_rpst_newer = $ntOpts['rpstNWDays']; } $ggg = $ntOpts['rpstType']=='1'?'Random':($ntOpts['rpstType']=='3'?'New to Old':'Old to New'); 
  88. if ($nxs_rpst_newer>5000) $nxs_rpst_newer = 5000; if ($nxs_rpst_newer<$nxs_rpst_older) $nxs_rpst_older = 0;  
  89. $nxs_rpst_code = 'nxsi'.$ii.$nt; $nxs_rpst_NT = strtoupper($nt); 
  90. add_filter( 'posts_join' , 'nxs_custom_posts_join'); 
  91. if (isset($ntOpts['rpstOnlyPUP']) && trim($ntOpts['rpstOnlyPUP'])=='1') { add_filter( 'posts_where', 'nxs_filter_where_only' ); } 
  92. add_filter( 'posts_where', 'nxs_filter_where' ); $query = new WP_Query( $args ); remove_filter( 'posts_where', 'filter_where' );  
  93. echo "Total posts included in reposting: ".$query->found_posts;  
  94. ?><br/> 
  95.  
  96. <?php _e('Set All Existing Posts to: ', 'social-networks-auto-poster-facebook-twitter-g'); ?> 
  97.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '1', '<?php echo $ii; ?>'); return false;"><?php _e('[Enabled for Repost]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span> 
  98.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '0', '<?php echo $ii; ?>'); return false;"><?php _e('[Disabled for Repost]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span>  
  99.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', '2', '<?php echo $ii; ?>'); return false;"><?php _e('[Enabled/Disabled for Repost according to Categories/Tags/Taxonomies filters]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span>  
  100.  
  101. </div><hr/> 
  102. <b><?php _e('Last post', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> (ID: <?php echo !empty($options['rpstLastPostID'])?$options['rpstLastPostID']:''; ?>) <b><?php _e('was re-posted on:', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php echo $options['rpstLastShTime']>0?date_i18n('Y-m-d H:i', $options['rpstLastShTime']):'Never'; ?> 
  103.   <b><?php _e('Next post will be ~', 'social-networks-auto-poster-facebook-twitter-g'); ?></b> <?php echo $options['rpstNxTime']>0?date_i18n('Y-m-d H:i', $options['rpstNxTime']):'Never'; ?> <== 
  104.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', 'X', '<?php echo $ii; ?>'); return false;"><?php _e('[Reset]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span> 
  105. <br/> 
  106. <b><?php _e('Set "Last re-posted post ID" to:', 'social-networks-auto-poster-facebook-twitter-g'); ?> <input type="text" id="<?php echo $nt; ?><?php echo $ii; ?>SetLPID" style="width: 65px;" value="<?php echo $options['rpstLastPostID']; ?>" /> 
  107.   <span class="nxsInstrSpan"><a href="#" onclick="nxs_setRpstAll('<?php echo $nt; ?>', 'L', '<?php echo $ii; ?>'); return false;"><?php _e('[Set]', 'social-networks-auto-poster-facebook-twitter-g'); ?></a> </span></b> 
  108. </div>  
  109. </div>  
  110. <?php