/** * Creates a blacklist entry for the given feed item. * * @since 4.4 * @param int|string The ID of the feed item to add to the blacklist */ function wprss_blacklist_item($ID) { // Return if feed item is null if (is_null($ID)) { return; } // Get the feed item data $item_title = get_the_title($ID); $item_permalink = get_post_meta($ID, 'wprss_item_permalink', TRUE); // If not an imported item, stop if ($item_permalink === '') { wprss_log_obj('An item being blacklisted was ignored for not being an imported item', $ID, null, WPRSS_LOG_LEVEL_INFO); return; } // Prepare the data for blacklisting $title = apply_filters('wprss_blacklist_title', trim($item_title)); $permalink = apply_filters('wprss_blacklist_permalink', trim($item_permalink)); // Get the blacklisted items $blacklist = wprss_get_blacklist(); // Add the item to the blacklist $blacklist[$permalink] = $title; // Delete the item wp_delete_post($ID, TRUE); // Add the blacklisted item $id = wp_insert_post(array('post_title' => $title, 'post_type' => 'wprss_blacklist', 'post_status' => 'publish')); update_post_meta($id, 'wprss_permalink', $permalink); }
/** * Creates a blacklist entry for the given feed item. * * @since 4.4 * @param int|string The ID of the feed item to add to the blacklist */ function wprss_blacklist_item($ID) { // Return if feed item is null if (is_null($ID)) { return; } // Get the feed item data $item_title = get_the_title($ID); $item_permalink = get_post_meta($ID, 'wprss_item_permalink', TRUE); // Prepare the data for blacklisting $title = apply_filters('wprss_blacklist_title', trim($item_title)); $permalink = apply_filters('wprss_blacklist_permalink', trim($item_permalink)); // Get the blacklisted items $blacklist = wprss_get_blacklist(); // Add the item to the blacklist $blacklist[$permalink] = $title; // Delete the item wp_delete_post($ID, TRUE); // Add the blacklisted item $id = wp_insert_post(array('post_title' => $title, 'post_type' => 'wprss_blacklist', 'post_status' => 'publish')); update_post_meta($id, 'wprss_permalink', $permalink); }