$archived_status_string = ''; $archived_user_string_match = 'archived_' . $current_user_id; foreach ($archived_status as $user_archived_status) { if ($user_archived_status == $archived_user_string_match) { $archived_status_string = 'archived'; $dependent_style = 'display:none;'; } } } elseif (1 == pf_get_relationship_value('archive', $nom_id, $user_id)) { $archived_status_string = 'archived'; $dependent_style = 'display:none;'; } else { $dependent_style = ''; $archived_status_string = ''; } $item = pf_feed_object(get_the_title(), pf_get_post_meta($nom_id, 'source_title', true), $date_posted, $item_authorship, get_the_content(), $nom_permalink, get_the_post_thumbnail($nom_id), $rss_item_id, pf_get_post_meta($nom_id, 'item_wp_date', true), $nom_tags, $date_nomed, $source_repeat, $nom_id, '1'); $this->form_of_an_item($item, $c, 'nomination', $metadata); $count++; $c++; } // Reset Post Data wp_reset_postdata(); ?> <div class="clear"></div><?php echo '</div><!-- End entries -->'; echo '</div><!-- End main -->'; if ($countQT > $countQ) { //Nasty hack because infinite scroll only works starting with page 2 for some reason. if ($page == 0) { $page = 1; }
function build_nom_draft() { global $post; // verify if this is an auto save routine. // If it is our form has not been submitted, so we dont want to do anything //if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) $pf_drafted_nonce = $_POST['pf_drafted_nonce']; if (!wp_verify_nonce($pf_drafted_nonce, 'drafter')) { die(__('Nonce not recieved. Are you sure you should be drafting?', 'pf')); } else { ##Check # print_r(__('Sending to Draft.', 'pf')); ##Check //print_r($_POST); ob_start(); $item_content = $_POST['nom_content']; $item_content = htmlspecialchars_decode($item_content); #$args_fi['url'] = $_POST['item_link']; #$posts = $pf->pf_feed_items->get($args_fi); $linked = get_option('pf_link_to_source', 0); if ($linked < 1) { $item_content = $item_content . $this->get_the_source_statement($_POST['nom_id']); } $item_title = $_POST['nom_title']; $data = array('post_status' => 'draft', 'post_type' => 'post', 'post_title' => $item_title, 'post_content' => $item_content); //Will need to use a meta field to pass the content's md5 id around to check if it has already been posted. //We assume that it is already in nominations, so no need to check there. This might be why we can't use post_exists here. //No need to origonate the check at the time of the feed item either. It can't become a post with the proper meta if it wasn't a nomination first. $item_id = $_POST['item_id']; //YYYY-MM-DD $nom_date = strtotime($_POST['nom_date']); $nom_date = date('Y-m-d', $nom_date); //Now function will not update nomination count when it pushes nomination to publication. $post_check = $this->is_nominated($item_id, 'post', false); $newPostID = 'repeat'; # # Check if the item was rendered readable, if not, make it so. $readable_state = pf_get_post_meta($_POST['nom_id'], 'readable_status', true); if ($readable_state != 1) { $readArgs = array('force' => false, 'descrip' => htmlspecialchars_decode($item_content), 'url' => $_POST['item_link'], 'authorship' => $_POST['item_author']); $readReady = pressforward()->readability->get_readable_text($readArgs); #var_dump($readReady); die(); $data['post_content'] = $readReady['readable']; } # //Alternative check with post_exists? or use same as above? if ($post_check != true) { ##Check #var_dump($data); die(); //print_r('No Post exists.'); $newPostID = wp_insert_post($data, true); ##Check add_post_meta($_POST['nom_id'], 'nom_id', $_POST['nom_id'], true); pf_meta_transition_post($_POST['nom_id'], $newPostID); $already_has_thumb = has_post_thumbnail($_POST['nom_id']); if ($already_has_thumb) { $post_thumbnail_id = get_post_thumbnail_id($_POST['nom_id']); set_post_thumbnail($newPostID, $post_thumbnail_id); } } $response = array('what' => 'draft', 'action' => 'build_nom_draft', 'id' => $newPostID, 'data' => $data['post_content'] . ' drafted.', 'supplemental' => array('content' => $item_content, 'originID' => $item_id, 'repeat' => $post_check, 'buffered' => ob_get_contents())); $xmlResponse = new WP_Ajax_Response($response); $xmlResponse->send(); ob_end_flush(); die; } }