本文整理汇总了PHP中wp_update_link函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_update_link函数的具体用法?PHP wp_update_link怎么用?PHP wp_update_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_update_link函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: update_wrapped_object
/**
* 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));
}
}
开发者ID:gumbysgoo,项目名称:bestilblomster,代码行数:22,代码来源:blogroll.php
示例2: edit_link
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);
}
}
开发者ID:helmonaut,项目名称:owb-mirror,代码行数:17,代码来源:bookmark.php
示例3: edit_link
/**
* {@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);
}
}
开发者ID:realfluid,项目名称:umbaugh,代码行数:27,代码来源:bookmark.php
示例4: edit_link
/**
* 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);
}
}
开发者ID:AndreyLanko,项目名称:perevorot-prozorro-wp,代码行数:28,代码来源:bookmark.php
示例5: edit_link
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);
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:24,代码来源:admin-functions.php
示例6: on_save_changes_settingssets
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();
//.........这里部分代码省略.........
开发者ID:wenhao87,项目名称:WPPlugins,代码行数:101,代码来源:link-library-admin.php
示例7: import_bookmark
/**
* 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;
}
}
开发者ID:niko-lgdcom,项目名称:wp-install,代码行数:53,代码来源:deploy.class.php
示例8: edit_link
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);
}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:18,代码来源:admin-functions.php
示例9: ll_get_link_image
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";
}
开发者ID:ylefebvre,项目名称:link-library,代码行数:39,代码来源:link-library-admin.php
示例10: save_settings
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);
}
}
}
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:17,代码来源:syndicatedlink.class.php
示例11: fwp_multidelete_page
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);
//.........这里部分代码省略.........
开发者ID:gopinathshiva,项目名称:wordpress-vip-plugins,代码行数:101,代码来源:syndication.php
示例12: update_object
public function update_object($link_id, $fields)
{
$fields['link_id'] = $link_id;
return wp_update_link($fields);
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:5,代码来源:class-wp-unittest-factory-for-bookmark.php
注:本文中的wp_update_link函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论