/** * Update the bookmark associated with this container. * * @access protected * * @return bool|WP_Error True on success, an error if something went wrong. */ function update_wrapped_object() { if (is_null($this->wrapped_object)) { return new WP_Error('no_wrapped_object', __('Nothing to update', 'broken-link-checker')); } //wp_update_link() expects it's argument to be an array. $data = (array) $this->wrapped_object; //Update the bookmark $rez = wp_update_link($data); if (!empty($rez)) { return true; } else { return new WP_Error('update_failed', sprintf(__('Updating bookmark %d failed', 'broken-link-checker'), $this->container_id)); } }
function edit_link($link_id = '') { if (!current_user_can('manage_links')) { wp_die(__('Cheatin’ uh?')); } $_POST['link_url'] = wp_specialchars($_POST['link_url']); $_POST['link_url'] = clean_url($_POST['link_url']); $_POST['link_name'] = wp_specialchars($_POST['link_name']); $_POST['link_image'] = wp_specialchars($_POST['link_image']); $_POST['link_rss'] = clean_url($_POST['link_rss']); if (!empty($link_id)) { $_POST['link_id'] = $link_id; return wp_update_link($_POST); } else { return wp_insert_link($_POST); } }
/** * {@internal Missing Short Description}} * * @since unknown * * @param unknown_type $link_id * @return unknown */ function edit_link( $link_id = '' ) { if (!current_user_can( 'manage_links' )) wp_die( __( 'Cheatin’ uh?' )); $_POST['link_url'] = esc_html( $_POST['link_url'] ); $_POST['link_url'] = esc_url($_POST['link_url']); $_POST['link_name'] = esc_html( $_POST['link_name'] ); $_POST['link_image'] = esc_html( $_POST['link_image'] ); $_POST['link_rss'] = esc_url($_POST['link_rss']); if ( !isset($_POST['link_visible']) || 'N' != $_POST['link_visible'] ) $_POST['link_visible'] = 'Y'; if ( !empty( $link_id ) ) { $_POST['link_id'] = $link_id; return wp_update_link( $_POST); } else { return wp_insert_link( $_POST); } }
/** * Updates or inserts a link using values provided in $_POST. * * @since 2.0.0 * * @param int $link_id Optional. ID of the link to edit. Default 0. * @return int|WP_Error Value 0 or WP_Error on failure. The link ID on success. */ function edit_link($link_id = 0) { if (!current_user_can('manage_links')) { wp_die('<h1>' . __('Cheatin’ uh?') . '</h1>' . '<p>' . __('You do not have sufficient permissions to edit the links for this site.') . '</p>', 403); } $_POST['link_url'] = esc_html($_POST['link_url']); $_POST['link_url'] = esc_url($_POST['link_url']); $_POST['link_name'] = esc_html($_POST['link_name']); $_POST['link_image'] = esc_html($_POST['link_image']); $_POST['link_rss'] = esc_url($_POST['link_rss']); if (!isset($_POST['link_visible']) || 'N' != $_POST['link_visible']) { $_POST['link_visible'] = 'Y'; } if (!empty($link_id)) { $_POST['link_id'] = $link_id; return wp_update_link($_POST); } else { return wp_insert_link($_POST); } }
function edit_link($link_id = '') { if (!current_user_can('manage_links')) { die(__("Cheatin' uh ?")); } $_POST['link_url'] = wp_specialchars($_POST['link_url']); $_POST['link_url'] = clean_url($_POST['link_url']); $_POST['link_name'] = wp_specialchars($_POST['link_name']); $_POST['link_image'] = wp_specialchars($_POST['link_image']); $_POST['link_rss'] = clean_url($_POST['link_rss']); $auto_toggle = get_autotoggle($_POST['link_category']); // if we are in an auto toggle category and this one is visible then we // need to make the others invisible before we add this new one. // FIXME Add category toggle func. //if (($auto_toggle == 'Y') && ($link_visible == 'Y')) { // $wpdb->query("UPDATE $wpdb->links set link_visible = 'N' WHERE link_category = $link_category"); //} if (!empty($link_id)) { $_POST['link_id'] = $link_id; return wp_update_link($_POST); } else { return wp_insert_link($_POST); } }
function on_save_changes_settingssets() { //user permission check if (!current_user_can('manage_options')) { wp_die(__('Not allowed', 'link-library')); } //cross check the given referer check_admin_referer('link-library'); $messages = array(); $row = 0; $successfulimport = 0; $successfulupdate = 0; if (isset($_POST['importlinks'])) { wp_suspend_cache_addition(true); set_time_limit(600); global $wpdb; $handle = fopen($_FILES['linksfile']['tmp_name'], "r"); if ($handle) { $skiprow = 1; while (($data = fgetcsv($handle, 5000, ",")) !== false) { $row += 1; if ($skiprow == 1 && isset($_POST['firstrowheaders']) && $row >= 2) { $skiprow = 0; } elseif (!isset($_POST['firstrowheaders'])) { $skiprow = 0; } if (!$skiprow) { if (count($data) == 16) { if (!empty($data[5])) { $existingcatquery = "SELECT t.term_id FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix() . "term_taxonomy tt "; $existingcatquery .= "WHERE t.name = '%s' AND t.term_id = tt.term_id AND tt.taxonomy = 'link_category'"; $existingcatqueryprepped = $wpdb->prepare($existingcatquery, esc_html($data[5])); $existingcat = $wpdb->get_var($existingcatqueryprepped); if (!$existingcat) { $newlinkcatdata = array("cat_name" => $data[5], "category_description" => "", "category_nicename" => esc_sql($data[5])); $newlinkcat = wp_insert_category($newlinkcatdata); $newcatarray = array("term_id" => $newlinkcat); $newcattype = array("taxonomy" => 'link_category'); $wpdb->update($this->db_prefix() . 'term_taxonomy', $newcattype, $newcatarray); $newlinkcat = array($newlinkcat); } else { $newlinkcat = array($existingcat); } $newrating = intval($data[14]); if ($newrating < 0) { $newrating = 0; } elseif ($newrating > 10) { $newrating = 10; } $newlinkid = ''; if (isset($_POST['updatesameurl'])) { $existing_link_query = "SELECT l.link_id FROM " . $this->db_prefix() . "links l "; $existing_link_query .= "WHERE l.link_url = '%s'"; $existing_link_query_prepped = $wpdb->prepare($existing_link_query, esc_url($data[1])); $newlinkid = $wpdb->get_var($existing_link_query_prepped); } $newlink = array("link_name" => esc_html(stripslashes($data[0])), "link_url" => esc_url(stripslashes($data[1])), "link_rss" => esc_html(stripslashes($data[2])), "link_description" => esc_html(stripslashes($data[3])), "link_notes" => esc_html(stripslashes($data[4])), "link_category" => $newlinkcat, "link_visible" => $data[6], "link_image" => $data[11], "link_rating" => $newrating, "link_target" => $data[15]); if (empty($newlinkid)) { $newlinkid = wp_insert_link($newlink); $successfulimport += 1; } elseif (!empty($newlinkid)) { unset($newlink['link_url']); $newlink['link_id'] = $newlinkid; wp_update_link($newlink); $successfulupdate += 1; } if ($newlinkid != 0) { $extradatatable = $this->db_prefix() . "links_extrainfo"; $nofollowvalue = $data[13] == 'Y' ? true : false; $existingextrainfo = "SELECT link_id FROM " . $extradatatable . " "; $existingextrainfo .= "WHERE link_id = '" . $newlinkid . "'"; $existingextrainfoid = $wpdb->get_var($existingextrainfo); if (!empty($existingextrainfoid)) { $wpdb->update($extradatatable, array('link_second_url' => $data[7], 'link_telephone' => $data[8], 'link_email' => $data[9], 'link_reciprocal' => $data[10], 'link_textfield' => $data[12], 'link_no_follow' => $nofollowvalue), array('link_id' => $newlinkid)); } elseif (empty($existingextrainfoid)) { $wpdb->insert($extradatatable, array('link_second_url' => $data[7], 'link_telephone' => $data[8], 'link_email' => $data[9], 'link_reciprocal' => $data[10], 'link_textfield' => $data[12], 'link_no_follow' => $nofollowvalue, 'link_id' => $newlinkid)); } } } else { $messages[] = '10'; } } else { $messages[] = '4'; } } } } if (isset($_POST['firstrowheaders'])) { $row -= 1; } $messages[] = '9'; wp_suspend_cache_addition(false); } elseif (isset($_POST['exportsettings'])) { $upload_dir = wp_upload_dir(); if (is_writable($upload_dir['path'])) { $myFile = $upload_dir['path'] . "/SettingSet" . $_POST['settingsetid'] . "Export.csv"; $fh = fopen($myFile, 'w') or die("can't open file"); $sourcesettingsname = 'LinkLibraryPP' . $_POST['settingsetid']; $sourceoptions = get_option($sourcesettingsname); $headerrow = array(); foreach ($sourceoptions as $key => $option) { $headerrow[] = '"' . $key . '"'; } $headerdata = join(',', $headerrow) . "\n"; fwrite($fh, $headerdata); $datarow = array(); foreach ($sourceoptions as $key => $option) { $datarow[] = '"' . $option . '"'; } $data = join(',', $datarow) . "\n"; fwrite($fh, $data); fclose($fh); if (file_exists($myFile)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($myFile)); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($myFile)); readfile($myFile); exit; } } else { $messages[] = '6'; } } elseif (isset($_POST['importsettings'])) { global $wpdb; if ($_FILES['settingsfile']['tmp_name'] != "") { $handle = fopen($_FILES['settingsfile']['tmp_name'], "r"); $row = 1; $optionnames = ""; $options = ""; while (($data = fgetcsv($handle, 5000, ",")) !== false) { if ($row == 1) { $optionnames = $data; $row++; } else { if ($row == 2) { for ($counter = 0; $counter <= count($data) - 1; $counter++) { $options[$optionnames[$counter]] = $data[$counter]; } $row++; } } } if ($options != "") { $settingsname = 'LinkLibraryPP' . $_POST['settingsetid']; update_option($settingsname, $options); $messages[] = '7'; } fclose($handle); } else { $messages[] = '8'; } } else { $settingsetid = $_POST['settingsetid']; $settings = $_POST['settingsetid']; $settingsname = 'LinkLibraryPP' . $settingsetid; $options = get_option($settingsname); $genoptions = get_option('LinkLibraryGeneral'); foreach (array('order', 'table_width', 'num_columns', 'position', 'beforecatlist1', 'beforecatlist2', 'beforecatlist3', 'catnameoutput', 'linkaddfrequency', 'defaultsinglecat', 'rsspreviewcount', 'rssfeedinlinecount', 'linksperpage', 'catdescpos', 'catlistdescpos', 'rsspreviewwidth', 'rsspreviewheight', 'numberofrssitems', 'displayweblink', 'sourceweblink', 'showtelephone', 'sourcetelephone', 'showemail', 'sourceimage', 'sourcename', 'popup_width', 'popup_height') as $option_name) { if (isset($_POST[$option_name])) { $options[$option_name] = str_replace("\"", "'", strtolower($_POST[$option_name])); } } foreach (array('categorylist', 'excludecategorylist') as $option_name) { if (isset($_POST[$option_name])) { if ($genoptions['catselectmethod'] == 'commalist' || empty($genoptions['catselectmethod'])) { $options[$option_name] = str_replace("\"", "'", strtolower($_POST[$option_name])); } else { if ($genoptions['catselectmethod'] == 'multiselectlist') { $options[$option_name] = implode(',', $_POST[$option_name]); } } } else { $options[$option_name] = ''; } } foreach (array('linkheader', 'descheader', 'notesheader', 'linktarget', 'settingssetname', 'loadingicon', 'direction', 'linkdirection', 'linkorder', 'addnewlinkmsg', 'linknamelabel', 'linkaddrlabel', 'linkrsslabel', 'linkcatlabel', 'linkdesclabel', 'linknoteslabel', 'addlinkbtnlabel', 'newlinkmsg', 'moderatemsg', 'imagepos', 'imageclass', 'rssfeedtitle', 'rssfeeddescription', 'showonecatmode', 'linkcustomcatlabel', 'linkcustomcatlistentry', 'searchlabel', 'dragndroporder', 'cattargetaddress', 'beforeweblink', 'afterweblink', 'weblinklabel', 'beforetelephone', 'aftertelephone', 'telephonelabel', 'beforeemail', 'afteremail', 'emaillabel', 'beforelinkhits', 'afterlinkhits', 'linkreciprocallabel', 'linksecondurllabel', 'linktelephonelabel', 'linkemaillabel', 'emailcommand', 'rewritepage', 'maxlinks', 'beforedate', 'afterdate', 'beforeimage', 'afterimage', 'beforerss', 'afterrss', 'beforenote', 'afternote', 'beforelink', 'afterlink', 'beforeitem', 'afteritem', 'beforedesc', 'afterdesc', 'addbeforelink', 'addafterlink', 'beforelinkrating', 'afterlinkrating', 'linksubmitternamelabel', 'linksubmitteremaillabel', 'linksubmittercommentlabel', 'addlinkcatlistoverride', 'beforelargedescription', 'afterlargedescription', 'customcaptchaquestion', 'customcaptchaanswer', 'rssfeedaddress', 'linklargedesclabel', 'flatlist', 'searchresultsaddress', 'link_popup_text', 'linktitlecontent', 'paginationposition', 'showaddlinkrss', 'showaddlinkdesc', 'showaddlinkcat', 'showaddlinknotes', 'addlinkcustomcat', 'showaddlinkreciprocal', 'showaddlinksecondurl', 'showaddlinktelephone', 'showaddlinkemail', 'showcustomcaptcha', 'showlinksubmittername', 'showaddlinksubmitteremail', 'showlinksubmittercomment', 'showuserlargedescription', 'cat_letter_filter', 'beforefirstlink', 'afterlastlink', 'searchfieldtext', 'catfilterlabel', 'searchnoresultstext', 'addlinkdefaultcat') as $option_name) { if (isset($_POST[$option_name])) { $options[$option_name] = str_replace("\"", "'", $_POST[$option_name]); } } foreach (array('hide_if_empty', 'catanchor', 'showdescription', 'shownotes', 'showrating', 'showupdated', 'show_images', 'use_html_tags', 'show_rss', 'nofollow', 'showcolumnheaders', 'show_rss_icon', 'showcategorydescheaders', 'showcategorydesclinks', 'showadmineditlinks', 'showonecatonly', 'rsspreview', 'rssfeedinline', 'rssfeedinlinecontent', 'pagination', 'hidecategorynames', 'showinvisible', 'showdate', 'showuserlinks', 'emailnewlink', 'usethumbshotsforimages', 'uselocalimagesoverthumbshots', 'addlinkreqlogin', 'showcatlinkcount', 'publishrssfeed', 'showname', 'enablerewrite', 'storelinksubmitter', 'showlinkhits', 'showcaptcha', 'showlargedescription', 'addlinknoaddress', 'featuredfirst', 'usetextareaforusersubmitnotes', 'showcatonsearchresults', 'shownameifnoimage', 'enable_link_popup', 'nocatonstartup', 'showlinksonclick', 'showinvisibleadmin', 'combineresults', 'showifreciprocalvalid', 'cat_letter_filter_autoselect', 'cat_letter_filter_showalloption', 'emailsubmitter', 'addlinkakismet') as $option_name) { if (isset($_POST[$option_name])) { $options[$option_name] = true; } else { $options[$option_name] = false; } } foreach (array('displayastable', 'divorheader') as $option_name) { if ($_POST[$option_name] == 'true') { $options[$option_name] = true; } elseif ($_POST[$option_name] == 'false') { $options[$option_name] = false; } } foreach (array('catlistwrappers') as $option_name) { if (isset($_POST[$option_name])) { $options[$option_name] = (int) $_POST[$option_name]; } } update_option($settingsname, $options); $messages[] = "1"; global $wpdb; if ($options['categorylist'] != '') { $categoryids = explode(',', $options['categorylist']); foreach ($categoryids as $categoryid) { $linkcatquery = "SELECT distinct t.name, t.term_id, t.slug as category_nicename, tt.description as category_description "; $linkcatquery .= "FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix() . "term_taxonomy tt "; if (isset($_POST['hide_if_empty'])) { $linkcatquery .= ", " . $this->db_prefix() . "term_relationships tr, " . $this->db_prefix() . "links l "; } $linkcatquery .= "WHERE t.term_id = tt.term_id AND tt.taxonomy = 'link_category'"; $linkcatquery .= " AND t.term_id = " . $categoryid; $catnames = $wpdb->get_results($linkcatquery); if (!$catnames) { $messages[] = '2'; } } } if ($options['excludecategorylist'] != '') { $categoryids = explode(',', $options['excludecategorylist']); foreach ($categoryids as $categoryid) { $linkcatquery = "SELECT distinct t.name, t.term_id, t.slug as category_nicename, tt.description as category_description "; $linkcatquery .= "FROM " . $this->db_prefix() . "terms t, " . $this->db_prefix() . "term_taxonomy tt "; if (isset($_POST['hide_if_empty'])) { $linkcatquery .= ", " . $this->db_prefix() . "term_relationships tr, " . $this->db_prefix() . "links l "; } $linkcatquery .= "WHERE t.term_id = tt.term_id AND tt.taxonomy = 'link_category'"; $linkcatquery .= " AND t.term_id = " . $categoryid; $catnames = $wpdb->get_results($linkcatquery); if (!$catnames) { $messages[] = '3'; } } } global $wp_rewrite; $wp_rewrite->flush_rules(false); } //lets redirect the post request into get request (you may add additional params at the url, if you need to show save results $messagelist = implode(",", $messages); $cleanredirecturl = $this->remove_querystring_var($_POST['_wp_http_referer'], 'messages'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'currenttab'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'importrowscount'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'successimportcount'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'copy'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'reset'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'resettable'); $cleanredirecturl = $this->remove_querystring_var($cleanredirecturl, 'source'); $redirecturl = $cleanredirecturl; if (!empty($messages)) { $redirecturl = $cleanredirecturl . "&messages=" . $messagelist; } if ($row != 0) { $redirecturl .= "&importrowscount=" . $row; } if ($successfulimport != 0) { $redirecturl .= "&successimportcount=" . $successfulimport; } if ($successfulupdate != 0) { $redirecturl .= "&successupdatecount=" . $successfulupdate; } if (isset($_POST['currenttab'])) { $redirecturl .= "¤ttab=" . $_POST['currenttab']; } wp_redirect($redirecturl); }
/** * Import a single bookmark * * @param array $bookmark * @return array */ protected function import_bookmark($bookmark) { $local_bookmark = $this->get_bookmark_by_url($bookmark['link_url']); // process categories if (!empty($bookmark['link_category'])) { foreach ($bookmark['link_category'] as &$link_category) { $cat = get_term_by('slug', $link_category, 'link_category'); // all taxonomies are imported before bookmarks, so this condition should never come up // even if it does, once these go atomic this'll be moot if (empty($cat) && !empty($this->batch_items['taxonomies']['link_category'][$link_category])) { // link-category not present, perform import $cat_args = $this->import_term($link_category); $cat = get_term($cat_args['term_id'], $link_category['taxonomy']); } if (empty($cat)) { $error = sprintf(__('Could not insert term category "%s" for bookmark "%s".', 'cf-deploy'), $link_category['name'], $bookmark['link_name']); $this->add_import_message('bookmarks', '__error__', $error); return false; } else { $link_category = $cat->term_id; } } } if (!empty($local_bookmark)) { $bookmark['link_id'] = $local_bookmark->link_id; $result = wp_update_link($bookmark); } else { unset($bookmark['link_id']); $result = wp_insert_link($bookmark); } $item_change['bookmarks'][$bookmark['link_url']] = 'new'; if (!empty($local_bookmark)) { foreach ($local_bookmark->link_category as &$_link_cat) { $_cat = get_term($_link_cat, 'link_category'); $_link_cat = $_cat->slug; } $item_change['bookmarks'][$bookmark['link_url']] = get_object_vars($local_bookmark); } $this->log_item_change($item_change); if (!is_wp_error($result)) { $this->add_import_message('bookmarks', '__notice__', sprintf(__('Bookmark "%s" imported.', 'cf-deploy'), $bookmark['link_name'])); return true; } else { $this->add_import_message('bookmarks', '__error__', sprintf(__('Bookmark "%s" not imported. Error: %s', 'cf-deploy'), $bookmark['link_name'], $result->get_error_message())); return false; } }
function edit_link( $link_id = '' ) { if (!current_user_can( 'manage_links' )) wp_die( __( 'Cheatin’ uh?' )); $_POST['link_url'] = wp_specialchars( $_POST['link_url'] ); $_POST['link_url'] = preg_match('/^(https?|ftps?|mailto|news|irc|gopher|nntp|feed|telnet):/is', $_POST['link_url']) ? $_POST['link_url'] : 'http://' . $_POST['link_url']; $_POST['link_name'] = wp_specialchars( $_POST['link_name'] ); $_POST['link_image'] = wp_specialchars( $_POST['link_image'] ); $_POST['link_rss'] = wp_specialchars( $_POST['link_rss'] ); $_POST['link_category'] = $_POST['post_category']; if ( !empty( $link_id ) ) { $_POST['link_id'] = $link_id; return wp_update_link( $_POST); } else { return wp_insert_link( $_POST); } }
function ll_get_link_image($url, $name, $mode, $linkid, $cid, $filepath, $filepathtype) { if ($url != "" && $name != "") { if ($mode == 'thumb' || $mode == 'thumbonly') { if (!empty($cid)) { $genthumburl = "http://images.thumbshots.com/image.aspx?cid=" . rawurlencode($cid) . "&v1=w=120&url=" . esc_html($url); } } elseif ($mode == 'favicon' || $mode == 'favicononly') { $genthumburl = "http://g.etfv.co/" . $url; } $uploads = wp_upload_dir(); if (!file_exists($uploads['basedir'])) { return __('Please create a folder called uploads under your Wordpress /wp-content/ directory with write permissions to use this functionality.', 'link-library'); } elseif (!is_writable($uploads['basedir'])) { return __('Please make sure that the /wp-content/uploads/ directory has write permissions to use this functionality.', 'link-library'); } else { if (!file_exists($uploads['basedir'] . '/' . $filepath)) { mkdir($uploads['basedir'] . '/' . $filepath); } } $img = $uploads['basedir'] . "/" . $filepath . "/" . $linkid . ".jpg"; $status = file_put_contents($img, @file_get_contents($genthumburl)); if ($status !== false) { if ($filepathtype == 'absolute' || empty($filepathtype)) { $newimagedata = array("link_id" => $linkid, "link_image" => $uploads['baseurl'] . "/" . $filepath . "/" . $linkid . ".jpg"); } elseif ($filepathtype == 'relative') { $parsedaddress = parse_url($uploads['baseurl']); $newimagedata = array("link_id" => $linkid, "link_image" => $parsedaddress['path'] . "/" . $filepath . "/" . $linkid . ".jpg"); } if ($mode == 'thumb' || $mode == 'favicon') { wp_update_link($newimagedata); } return $newimagedata['link_image']; } else { return ""; } } return "Parameters are missing"; }
function save_settings($reload = false) { $link = get_bookmark($this->id, ARRAY_A); // Save channel-level meta-data foreach (array('link_name', 'link_description', 'link_url') as $what) { $link[$what] = $this->link->{$what}; } // Save settings to the notes field $link['link_notes'] = $this->settings_to_notes(); $result = wp_update_link($link); if ($reload) { // force reload of link information from DB if (function_exists('clean_bookmark_cache')) { clean_bookmark_cache($this->id); } } }
function fwp_multidelete_page() { // If this is a POST, validate source and user credentials FeedWordPressCompatibility::validate_http_request('feedwordpress_feeds', 'manage_links'); $link_ids = isset($_REQUEST['link_ids']) ? $_REQUEST['link_ids'] : array(); if (isset($_REQUEST['link_id'])) { array_push($link_ids, $_REQUEST['link_id']); } if (isset($GLOBALS['fwp_post']['confirm']) and $GLOBALS['fwp_post']['confirm'] == 'Delete') { if (isset($GLOBALS['fwp_post']['link_action']) and is_array($GLOBALS['fwp_post']['link_action'])) { $actions = $GLOBALS['fwp_post']['link_action']; } else { $actions = array(); } $do_it = array('hide' => array(), 'nuke' => array(), 'delete' => array()); foreach ($actions as $link_id => $what) { $do_it[$what][] = $link_id; } $alter = $errs = array(); if (count($do_it['hide']) > 0) { $links = get_bookmarks(array('include' => implode(',', $do_it['hide']))); if (is_array($links) && !empty($links)) { foreach ($links as $link) { $link->link_visible = 'N'; $alter[] = 'hiding link: ' . $link->link_id; wp_update_link((array) $link); } } } if (count($do_it['nuke']) > 0) { foreach ($do_it['nuke'] as $nuke_id) { // Make a list of the items syndicated from this feed... $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $nuke_id); $posts = get_posts($args); // ... and kill them all if (is_array($posts) && !empty($posts)) { foreach ($posts as $p) { $alter[] = 'deleting post: ' . $p->ID; wp_delete_post($p->ID, true); } } // Then delete the link wp_delete_link($nuke_id); } } if (count($do_it['delete']) > 0) { $deletem = "(" . implode(', ', $do_it['delete']) . ")"; foreach ($do_it['delete'] as $del_id) { // Make a list of the items syndicated from this feed... $args = array('posts_per_page' => -1, 'numberposts' => 0, 'meta_key' => 'syndication_feed_id', 'meta_value' => $del_id); $posts = get_posts($args); // Make the items syndicated from this feed appear to be locally-authored if (is_array($posts) && !empty($posts)) { foreach ($posts as $p) { $alter[] = 'deleting postmeta for post: ' . $p->ID; if (!delete_post_meta($p->ID, 'syndication_feed_id')) { $errs[] = 'Could not delete meta for post: ' . $p->ID; } } } // Then delete the link wp_delete_link($del_id); } } if (count($alter) > 0) { echo "<div class=\"updated\">\n"; if (count($errs) > 0) { echo "There were some problems processing your "; echo "unsubscribe request. [Errors: " . implode('; ', $errs) . "]"; } else { echo "Your unsubscribe request(s) have been processed."; } echo "</div>\n"; } return true; // Continue on to Syndicated Sites listing } else { if (count($link_ids) > 0) { $targets = get_bookmarks(array('include' => implode(',', $link_ids), 'hide_invisible' => 0)); } else { $targets = array(); } ?> <form action="admin.php?page=<?php echo FWP_SYNDICATION_PAGE_SLUG; ?> " method="post"> <div class="wrap"> <?php FeedWordPressCompatibility::stamp_nonce('feedwordpress_feeds'); ?> <input type="hidden" name="action" value="Unsubscribe" /> <input type="hidden" name="confirm" value="Delete" /> <h2>Unsubscribe from Syndicated Links:</h2> <?php foreach ($targets as $link) { $subscribed = 'Y' == strtoupper($link->link_visible); $link_url = esc_html($link->link_url); $link_name = esc_html($link->link_name); $link_description = esc_html($link->link_description); $link_rss = esc_html($link->link_rss); ?> <fieldset> <legend><?php echo $link_name; ?> </legend> <table class="editform" width="100%" cellspacing="2" cellpadding="5"> <tr><th scope="row" width="20%"><?php _e('Feed URI:'); ?> </th> <td width="80%"><a href="<?php echo $link_rss; ?> "><?php echo $link_rss; ?> </a></td></tr> <tr><th scope="row" width="20%"><?php _e('Short description:'); ?> </th> <td width="80%"><?php echo $link_description; ?> </span></td></tr> <tr><th width="20%" scope="row"><?php _e('Homepage:'); ?> </th> <td width="80%"><a href="<?php echo $link_url; ?> "><?php echo $link_url; ?> </a></td></tr> <tr style="vertical-align:top"><th width="20%" scope="row">Subscription <?php _e('Options'); ?> :</th> <td width="80%"><ul style="margin:0; padding: 0; list-style: none"> <?php if ($subscribed) { ?> <li><input type="radio" id="hide-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="hide" checked="checked" /> <label for="hide-<?php echo $link->link_id; ?> ">Turn off the subscription for this syndicated link<br/><span style="font-size:smaller">(Keep the feed information and all the posts from this feed in the database, but don't syndicate any new posts from the feed.)</span></label></li> <?php } ?> <li><input type="radio" id="nuke-<?php echo $link->link_id; ?> "<?php if (!$subscribed) { ?> checked="checked"<?php } ?> name="link_action[<?php echo $link->link_id; ?> ]" value="nuke" /> <label for="nuke-<?php echo $link->link_id; ?> ">Delete this syndicated link and all the posts that were syndicated from it</label></li> <li><input type="radio" id="delete-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="delete" /> <label for="delete-<?php echo $link->link_id; ?> ">Delete this syndicated link, but <em>keep</em> posts that were syndicated from it (as if they were authored locally).</label></li> <li><input type="radio" id="nothing-<?php echo $link->link_id; ?> " name="link_action[<?php echo $link->link_id; ?> ]" value="nothing" /> <label for="nothing-<?php echo $link->link_id; ?> ">Keep this feed as it is. I changed my mind.</label></li> </ul> </table> </fieldset> <?php } ?> <div class="submit"> <input class="delete" type="submit" name="submit" value="<?php _e('Unsubscribe from selected feeds »'); ?> " /> </div> </div> <?php return false; // Don't continue on to Syndicated Sites listing } }
public function update_object($link_id, $fields) { $fields['link_id'] = $link_id; return wp_update_link($fields); }