nxs_SetRpstAll_ajax

The NextScripts: Social Networks Auto-Poster nxs SetRpstAll ajax function.

Description

nxs_SetRpstAll_ajax(); 

Usage

  1. if ( !function_exists( 'nxs_SetRpstAll_ajax' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/NextScripts_SNAP.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nxs_SetRpstAll_ajax(); 
  7.  

Defined (1)

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

/NextScripts_SNAP.php  
  1. function nxs_SetRpstAll_ajax() { check_ajax_referer('nxsSsPageWPN'); global $plgn_NS_SNAutoPoster; if (!isset($plgn_NS_SNAutoPoster)) return; $options = $plgn_NS_SNAutoPoster->nxs_options;// prr($options[$_POST['t']][$_POST['ii']]);  
  2. if ($_POST['ed']=='X' || $_POST['ed']=='L') { // prr($options[$_POST['t']][$_POST['ii']]); prr($options); die(); 
  3. if ($_POST['ed']=='X') { $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = '';  
  4. $options[$_POST['t']][$_POST['ii']]['rpstLastShTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = ''; $options[$_POST['t']][$_POST['ii']]['rpstNxTime'] = '';  
  5. } elseif ($_POST['ed']=='L' && trim($_POST['lpid'])!='' && (int)$_POST['lpid'] > 0) {  
  6. $post = get_post($_POST['lpid']); 
  7. $options[$_POST['t']][$_POST['ii']]['rpstLastPostTime'] = $post->post_date; 
  8. $options[$_POST['t']][$_POST['ii']]['rpstLastPostID'] = trim($_POST['lpid']);  
  9. if (is_array($options)) { update_option('NS_SNAutoPoster', $options); $plgn_NS_SNAutoPoster->nxs_options = $options; } // echo "|".$_POST['t'].$_POST['ii']."|"; prr($options[$_POST['t']][$_POST['ii']]); 
  10. } else {  
  11. if (!empty($options['nxsCPTSeld'])) $tpArray = maybe_unserialize($options['nxsCPTSeld']); if (!is_array($tpArray)) $tpArray = array('post'); else $tpArray[] = 'post';  
  12. foreach ($tpArray as $tp) if (!empty($tp)) {  
  13. $args = array( 'post_type' => $tp, 'post_status' => 'publish', 'numberposts' => 30, 'offset'=> 0, 'fields'=>'ids' ); $posts = get_posts( $args );  
  14. while (count($posts)>0) { 
  15. foreach ($posts as $postID) { $pMeta = maybe_unserialize(get_post_meta($postID, 'snap'.strtoupper($_POST['t']), true));  
  16. if (!isset($pMeta) || !is_array($pMeta)) $pMeta = array(); if (!isset($pMeta[$_POST['ii']]) || !is_array($pMeta[$_POST['ii']])) $pMeta[$_POST['ii']] = array();  
  17. if ($_POST['ed']!='2') $pMeta[$_POST['ii']]['rpstPostIncl'] = $_POST['ed']=='0'?'0':'nxsi'.$_POST['ii'].$_POST['t']; else {  
  18. $doPost = true; $exclCats = maybe_unserialize($options['exclCats']); $postCats = wp_get_post_categories($postID); 
  19. foreach ($postCats as $pCat) { if ( (is_array($exclCats)) && in_array($pCat, $exclCats)) $doPost = false; else {$doPost = true; break;}} 
  20. $optMt = $options[$_POST['t']][$_POST['ii']]; 
  21. if ( $optMt['catSel']=='1' && trim($optMt['catSelEd'])!='' ) { $inclCats = explode(', ', $optMt['catSelEd']); foreach ($postCats as $pCat) { if (!in_array($pCat, $inclCats)) $doPost = false; else {$doPost = true; break;}} } 
  22. $pMeta[$_POST['ii']]['rpstPostIncl'] = $doPost?'nxsi'.$_POST['ii'].$_POST['t']:'0';  
  23. } delete_post_meta($postID, 'snap'.strtoupper($_POST['t'])); add_post_meta($postID, 'snap'.strtoupper($_POST['t']), serialize($pMeta));  
  24. } $args['offset'] = $args['offset']+30; $posts = get_posts( $args ); 
  25. }  
  26. } echo "OK"; die();  
  27. }}