function set_to_alert($id, $theFeed) { $error_to_alert = get_option(PF_SLUG . '_errors_until_alert', 3); $error_count = pf_retrieve_meta($id, PF_SLUG . '_feed_error_count'); if (!is_numeric($error_count) || '' == $error_count) { $error_count = 0; } if ($error_count >= $error_to_alert) { the_alert_box()->switch_post_type($id); the_alert_box()->add_bug_type_to_post($id, __('Broken RSS feed.', 'pf')); $post_obj = get_post($id); $old_content = $post_obj->post_content; $update_result = pf_update_meta($id, PF_SLUG . '_feed_error_count', 0); if (is_wp_error($theFeed)) { $argup = array('ID' => $id, 'post_content' => $old_content . ' <p>' . $theFeed->get_error_message() . '</p>'); $result = wp_update_post($argup); } return true; } else { $update_result = pf_update_meta($id, PF_SLUG . '_feed_error_count', $error_count + 1); return $update_result; } }
function get_the_word_count() { $m = pf_retrieve_meta(get_the_ID(), 'pf_feed_item_word_count'); return $m; }
/** * An alias for pf_retrieve_meta that allows you to use the standard argument set from get_post_meta. * */ function pf_get_post_meta($id, $field, $single = true, $obj = false) { return pf_retrieve_meta($id, $field, $obj, $single); }
/** * Retrieve the item source's link. * * Retrieve the link for the item's source. Attempt to fully * resolve the URL for known aggregation services. * * @since 3.4.5 * * */ public static function get_source_link($post_id) { $url = pf_retrieve_meta($post_id, 'pf_source_link'); if (empty($url)) { $url = pf_retrieve_meta($post_id, 'item_link'); } $source_url = pressforward()->pf_feed_items->resolve_a_url($url); pf_update_meta($post_id, 'pf_source_link', $source_url); return $source_url; }
$count = 0; $countQ = $nom_query->post_count; $countQT = $nom_query->found_posts; //print_r($countQ); while ($nom_query->have_posts()) { $nom_query->the_post(); //declare some variables for use, mostly in various meta roles. //1773 in rssforward.php for various post meta. //Get the submitter's user slug $metadata['submitters'] = $submitter_slug = get_the_author_meta('user_nicename'); // Nomination (post) ID $metadata['nom_id'] = $nom_id = get_the_ID(); //Get the WP database ID of the original item in the database. $metadata['item_feed_post_id'] = pf_get_post_meta($nom_id, 'item_feed_post_id', true); //Number of Nominations recieved. $metadata['nom_count'] = $nom_count = pf_retrieve_meta($nom_id, 'nomination_count'); //Permalink to orig content $metadata['permalink'] = $nom_permalink = pf_get_post_meta($nom_id, 'item_link', true); $urlArray = parse_url($nom_permalink); //Source Site $metadata['source_link'] = isset($urlArray['host']) ? $sourceLink = 'http://' . $urlArray['host'] : ''; //Source site slug $metadata['source_slug'] = $sourceSlug = isset($urlArray['host']) ? pf_slugger($urlArray['host'], true, false, true) : ''; //RSS Author designation $metadata['authors'] = $item_authorship = pf_get_post_meta($nom_id, 'item_author', true); //Datetime item was nominated $metadata['date_nominated'] = $date_nomed = pf_get_post_meta($nom_id, 'date_nominated', true); //Datetime item was posted to its home RSS $metadata['posted_date'] = $date_posted = pf_get_post_meta($nom_id, 'posted_date', true); //Unique RSS item ID $metadata['item_id'] = $rss_item_id = pf_get_post_meta($nom_id, 'origin_item_ID', true);
public function simple_nom_to_draft($id = false) { global $post; $pf_drafted_nonce = $_POST['pf_nomination_nonce']; if (!wp_verify_nonce($pf_drafted_nonce, 'nomination')) { die(__('Nonce not recieved. Are you sure you should be drafting?', 'pf')); } else { if (!$id) { $id = $_POST['nom_id']; $nom = get_post($id); $item_id = pf_retrieve_meta($id, 'item_id'); } $post_check = $this->is_nominated($item_id, 'post', false); if (true != $post_check) { $item_link = pf_retrieve_meta($id, 'item_link'); $author = get_the_item_author($id); $content = $nom->post_content; $title = $nom->post_title; $data = array('post_status' => 'draft', 'post_type' => 'post', 'post_title' => $title, 'post_content' => $content); # Check if the item was rendered readable, if not, make it so. $readable_state = pf_get_post_meta($id, 'readable_status', true); if ($readable_state != 1) { $readArgs = array('force' => false, 'descrip' => htmlspecialchars_decode($content), 'url' => $item_link, 'authorship' => $author); $readReady = pressforward()->readability->get_readable_text($readArgs); #var_dump($readReady); die(); $data['post_content'] = $readReady['readable']; } $new_post_id = wp_insert_post($data, true); ##Check add_post_meta($id, 'nom_id', $id, true); pf_meta_transition_post($id, $new_post_id); $already_has_thumb = has_post_thumbnail($id); if ($already_has_thumb) { $post_thumbnail_id = get_post_thumbnail_id($id); set_post_thumbnail($new_post_id, $post_thumbnail_id); } $response = array('what' => 'draft', 'action' => 'simple_nom_to_draft', 'id' => $new_post_id, 'data' => $data['post_content'] . ' drafted.', 'supplemental' => array('content' => $content, 'originID' => $id, 'repeat' => $post_check, 'buffered' => ob_get_contents())); } else { $response = array('what' => 'draft', 'action' => 'simple_nom_to_draft', 'id' => $id, 'data' => 'Failed due to existing nomination or lack of ID.', 'supplemental' => array('repeat' => $post_check, 'buffered' => ob_get_contents())); } $xmlResponse = new WP_Ajax_Response($response); $xmlResponse->send(); ob_end_flush(); die; } }