本文整理汇总了PHP中wp_delete_link函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_link函数的具体用法?PHP wp_delete_link怎么用?PHP wp_delete_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_delete_link函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bp_groupblog_blog_defaults
function bp_groupblog_blog_defaults($blog_id)
{
global $bp, $wp_rewrite;
// only apply defaults to groupblog blogs
if (bp_is_groups_component()) {
switch_to_blog($blog_id);
// get the site options
$options = get_site_option('bp_groupblog_blog_defaults_options');
foreach ((array) $options as $key => $value) {
update_option($key, $value);
}
// override default themes
if (!empty($options['theme'])) {
// we want something other than the default theme
$values = explode("|", $options['theme']);
switch_theme($values[0], $values[1]);
}
// groupblog bonus options
if (strlen($options['default_cat_name']) > 0) {
global $wpdb;
$cat = $options['default_cat_name'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s WHERE term_id = 1", $cat, $slug));
}
if (strlen($options['default_link_cat']) > 0) {
global $wpdb;
$cat = $options['default_link_cat'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query($wpdb->prepare("UPDATE {$wpdb->terms} SET name = %s, slug = %s WHERE term_id = 2", $cat, $slug));
}
if (isset($options['delete_first_post']) && $options['delete_first_post'] == 1) {
global $wpdb;
$statement = "UPDATE {$wpdb->posts} SET post_status = 'draft' WHERE id = 1";
$results = $wpdb->query($statement);
}
if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1) {
wp_delete_comment(1);
}
if ($options['delete_blogroll_links'] == 1) {
wp_delete_link(1);
//delete Wordpress.com blogroll link
wp_delete_link(2);
//delete Wordpress.org blogroll link
}
if ($options['redirectblog'] == 2) {
$blog_page = array('comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_name' => $options['pageslug'], 'post_title' => $options['pagetitle'], 'post_type' => 'page', 'post_content' => __('<p><strong>This page has been created automatically by the BuddyPress GroupBlog plugin.</strong></p><p>Please contact the site admin if you see this message instead of your blog posts. Possible solution: please advise your site admin to create the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates">page template</a> needed for the BuddyPress GroupBlog plugin.<p>', 'groupblog'));
$blog_page_id = wp_insert_post($blog_page);
if ($blog_page_id) {
add_post_meta($blog_page_id, '_wp_page_template', 'blog.php');
}
add_post_meta($blog_page_id, 'created_by_groupblog_dont_change', '1');
// Set the Blog Reading Settings to load the template page as front page
if ($options['deep_group_integration'] == 1) {
update_option('show_on_front', 'page');
update_option('page_on_front', $blog_page_id);
}
}
restore_current_blog();
}
}
示例2: link_delete
/**
* Deletes plugin link from Blogroll
*
* @return void
*/
public static function link_delete()
{
require_once ABSPATH . 'wp-admin/includes/bookmark.php';
$bookmarks = get_bookmarks();
$link_id = 0;
foreach ($bookmarks as $bookmark) {
if ($bookmark->link_url == W3TC_LINK_URL) {
wp_delete_link($bookmark->link_id);
}
}
}
示例3: delete_wrapped_object
/**
* Delete the bookmark corresponding to this container.
* Also removes the synch. record of the container and removes all associated instances.
*
* @return bool|WP_error
*/
function delete_wrapped_object()
{
if (wp_delete_link($this->container_id)) {
//Note that there is no need to explicitly delete the synch. record and instances
//associated with this link - wp_delete_link() will execute the 'delete_link' action,
//which will be noticed by blcBookmarkManager, which will then delete anything that needs
//to be deleted.
//But in case the (undocumented) behaviour of wp_delete_link() changes in a later WP version,
//add a call to $this->delete() here.
return true;
} else {
$bookmark = $this->get_wrapped_object();
if (is_null($bookmark)) {
$link_name = "[nonexistent]";
} else {
$link_name = sanitize_bookmark_field('link_name', $bookmark->link_name, $this->container_id, 'display');
}
$msg = sprintf(__('Failed to delete blogroll link "%s" (%d)', 'broken-link-checker'), $link_name, $this->container_id);
return new WP_Error('delete_failed', $msg);
}
}
示例4: process
function process()
{
global $wp_rewrite, $wpcc_options;
$langs = array();
foreach ($this->langs as $key => $value) {
if (isset($_POST['wpcco_variant_' . $key])) {
$langs[] = $key;
}
}
$options = array('wpcc_used_langs' => $langs, 'wpcc_search_conversion' => intval($_POST['wpcco_search_conversion']), 'wpcc_browser_redirect' => intval($_POST['wpcco_browser_redirect']), 'wpcc_use_cookie_variant' => intval($_POST['wpcco_use_cookie_variant']), 'wpcc_use_fullpage_conversion' => isset($_POST['wpcco_use_fullpage_conversion']) ? 1 : 0, 'wpcc_trackback_plugin_author' => isset($_POST['wpcco_trackback_plugin_author']) ? intval($_POST['wpcco_trackback_plugin_author']) : 0, 'wpcc_add_author_link' => isset($_POST['wpcco_add_author_link']) ? 1 : 0, 'wpcc_use_permalink' => intval($_POST['wpcco_use_permalink']), 'wpcc_auto_language_recong' => isset($_POST['wpcco_auto_language_recong']) ? 1 : 0, 'wpcc_no_conversion_tag' => trim($_POST['wpcco_no_conversion_tag'], " \t\n\r\v,|"), 'wpcc_no_conversion_ja' => isset($_POST['wpcco_no_conversion_ja']) ? 1 : 0, 'wpcc_no_conversion_qtag' => isset($_POST['wpcco_no_conversion_qtag']) ? 1 : 0, 'nctip' => trim($_POST['wpcco_no_conversion_tip']));
foreach ($this->langs as $lang => $value) {
if (!empty($_POST[$value[1]])) {
$options[$value[1]] = trim($_POST[$value[1]]);
}
}
if ($this->get_cache_status() == 2 && empty($options['wpcc_browser_redirect']) && empty($options['wpcc_use_cookie_variant'])) {
$this->uninstall_cache_module();
}
if ($options['wpcc_trackback_plugin_author'] == 1) {
$options['wpcc_trackback_plugin_author'] = $this->trackback();
if ($options['wpcc_trackback_plugin_author'] == 2) {
$this->message .= '已成功向<a href="https://oogami.name/project/wpcc/" target="_blank">插件主页</a>发送Trackback。感谢您的支持。<br />';
} else {
$this->message .= '向<a href="https://oogami.name/project/wpcc/" target="_blank">插件主页</a>发送Trackback失败,你可以尝试重新提交。<br />';
}
}
if ($options['wpcc_add_author_link'] == 1 && $this->options['wpcc_add_author_link'] == 0) {
if ($options['wpcc_add_author_link'] = wp_insert_link(array('link_target' => '_blank', 'link_description' => '小野大神的 Blog,关注文明与幻想。', 'link_rss' => 'https://oogami.name/feed/', 'link_name' => '小野大神', 'link_url' => 'https://oogami.name/'))) {
$this->message .= '已成功添加<a href="https://oogami.name/" target="_blank">插件作者</a>的主页链接。感谢您的支持<br />';
} else {
$options['wpcc_add_author_link'] = 0;
$this->message .= '添加插件作者主页链接失败。请重试。<br />';
}
} else {
if ($options['wpcc_add_author_link'] == 0 && $this->options['wpcc_add_author_link'] != 0) {
if (wp_delete_link($this->options['wpcc_add_author_link'])) {
$this->message .= '已删除插件作者的主页链接。<br />';
}
}
}
$wpcc_options = $options;
//因为可能需要刷新rewrite规则, 必须立即更新wpcc_options全局变量
if ($this->options['wpcc_use_permalink'] != $options['wpcc_use_permalink'] || $this->options['wpcc_use_permalink'] != 0 && $this->options['wpcc_used_langs'] != $options['wpcc_used_langs']) {
if (!has_filter('rewrite_rules_array', 'wpcc_rewrite_rules')) {
add_filter('rewrite_rules_array', 'wpcc_rewrite_rules');
}
$wp_rewrite->flush_rules();
}
update_option('wpcc_options', $options);
$this->options = $options;
$this->is_success = true;
$this->message .= '<br />设置已更新。';
}
示例5: wpmu_delete_user
function wpmu_delete_user($id)
{
global $wpdb;
$id = (int) $id;
$user = new WP_User($id);
do_action('wpmu_delete_user', $id);
$blogs = get_blogs_of_user($id);
if (!empty($blogs)) {
foreach ($blogs as $blog) {
switch_to_blog($blog->userblog_id);
remove_user_from_blog($id, $blog->userblog_id);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
foreach ((array) $post_ids as $post_id) {
wp_delete_post($post_id);
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
restore_current_blog();
}
}
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
clean_user_cache($user);
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例6: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since unknown
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = 'novalue') {
global $wpdb;
$id = (int) $id;
$user = new WP_User($id);
// allow for transaction statement
do_action('delete_user', $id);
if ($reassign == 'novalue') {
$post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
if ($post_ids) {
foreach ($post_ids as $post_id)
wp_delete_post($post_id);
}
// Clean links
$link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) );
if ( $link_ids ) {
foreach ( $link_ids as $link_id )
wp_delete_link($link_id);
}
} else {
$reassign = (int) $reassign;
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $id) );
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $id) );
}
// FINALLY, delete user
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
$wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->users WHERE ID = %d", $id) );
wp_cache_delete($id, 'users');
wp_cache_delete($user->user_login, 'userlogins');
wp_cache_delete($user->user_email, 'useremail');
wp_cache_delete($user->user_nicename, 'userslugs');
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例7: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since 2.0.0
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = 'novalue')
{
global $wpdb;
$id = (int) $id;
$user = new WP_User($id);
// allow for transaction statement
do_action('delete_user', $id);
if ('novalue' === $reassign || null === $reassign) {
$post_types_to_delete = array();
foreach (get_post_types(array(), 'objects') as $post_type) {
if ($post_type->delete_with_user) {
$post_types_to_delete[] = $post_type->name;
} elseif (null === $post_type->delete_with_user && post_type_supports($post_type->name, 'author')) {
$post_types_to_delete[] = $post_type->name;
}
}
$post_types_to_delete = apply_filters('post_types_to_delete_with_user', $post_types_to_delete, $id);
$post_types_to_delete = implode("', '", $post_types_to_delete);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_type IN ('{$post_types_to_delete}')", $id));
if ($post_ids) {
foreach ($post_ids as $post_id) {
wp_delete_post($post_id);
}
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
} else {
$reassign = (int) $reassign;
$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
}
// FINALLY, delete user
if (is_multisite()) {
remove_user_from_blog($id, get_current_blog_id());
} else {
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
}
clean_user_cache($user);
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例8: delete_links
private static function delete_links($links)
{
$saved_links = self::get_ojsimport_links();
foreach ($links as $url => $id) {
wp_delete_link($id);
unset($saved_links[$url]);
}
update_option('_ojsimportlinks', $saved_links);
}
示例9: WP_AJAX_Response
if (is_wp_error($r)) {
$x = new WP_AJAX_Response(array('what' => 'link-cat', 'id' => $id, 'data' => $r));
$x->send();
}
die('1');
break;
case 'delete-link':
check_ajax_referer("delete-bookmark_{$id}");
if (!current_user_can('manage_links')) {
die('-1');
}
$link = get_bookmark($id);
if (!$link || is_wp_error($link)) {
die('1');
}
if (wp_delete_link($id)) {
die('1');
} else {
die('0');
}
break;
case 'delete-meta':
check_ajax_referer("delete-meta_{$id}");
if (!($meta = get_post_meta_by_id($id))) {
die('1');
}
if (!current_user_can('edit_post', $meta->post_id)) {
die('-1');
}
if (delete_meta($meta->meta_id)) {
die('1');
示例10: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since unknown
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = 'novalue')
{
global $wpdb;
$id = (int) $id;
// allow for transaction statement
do_action('delete_user', $id);
if ('novalue' === $reassign || null === $reassign) {
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
if ($post_ids) {
foreach ($post_ids as $post_id) {
wp_delete_post($post_id);
}
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
} else {
$reassign = (int) $reassign;
$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
}
clean_user_cache($id);
// FINALLY, delete user
if (!is_multisite()) {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->users} WHERE ID = %d", $id));
} else {
$level_key = $wpdb->get_blog_prefix() . 'capabilities';
// wpmu site admins don't have user_levels
$wpdb->query("DELETE FROM {$wpdb->usermeta} WHERE user_id = {$id} AND meta_key = '{$level_key}'");
}
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例11: wp_ajax_delete_link
/**
* Ajax handler for deleting a link.
*
* @since 3.1.0
*/
function wp_ajax_delete_link()
{
$id = isset($_POST['id']) ? (int) $_POST['id'] : 0;
check_ajax_referer("delete-bookmark_{$id}");
if (!current_user_can('manage_links')) {
wp_die(-1);
}
$link = get_bookmark($id);
if (!$link || is_wp_error($link)) {
wp_die(1);
}
if (wp_delete_link($id)) {
wp_die(1);
} else {
wp_die(0);
}
}
示例12: set_blog_defaults
function set_blog_defaults($blog_id, $user_id)
{
global $wp_rewrite, $wpdb, $current_site;
switch_to_blog($blog_id);
// get the site options
$options = get_site_option('cets_blog_defaults_options');
// check for the blogname_flag and if it's 0, then delete the blogname option
if ($options['blogname_flag'] == 0 && isset($options['blogname'])) {
unset($options['blogname']);
}
// check for the blog_public setting and if it's blank, delete it
if (strlen($options['blog_public']) == 0) {
unset($options['blog_public']);
}
// bonus options - set these first and then unset each one so they don't clutter the database
// Add User to Blog
if ($options['add_user_to_blog'] == 1) {
if(strlen($options['add_user_to_blog_id']) == 1) {
add_user_to_blog( $options['add_user_to_blog_id'], $user_id, $options['add_user_to_blog_role'] );
}
elseif (strlen($options['add_user_to_blog_id']) > 1) {
$blogs = explode(',', $options['add_user_to_blog_id']);
foreach ($blogs as $blog){
add_user_to_blog( $blog, $user_id, $options['add_user_to_blog_role'] );
}
}
}
unset($options['add_user_to_blog']);
unset($options['add_user_to_blog_role']);
unset($options['add_user_to_blog_id']);
// Delete Links
if ($options['delete_blogroll_links'] == 1) {
wp_delete_link(1); // documentation
wp_delete_link(2); // wordpress blog
wp_delete_link(3); //delete suggest ideas
wp_delete_link(4); //delete support forum
wp_delete_link(5); //delete plugins
wp_delete_link(6); //delete themes
wp_delete_link(7); //delete wp planet
}
unset($options['delete_blogroll_links']);
// Default Category Name
if (strlen($options['default_cat_name']) > 0){
global $wpdb;
$cat = $options['default_cat_name'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET name = %s, slug = %s WHERE term_id = 1", $cat, $slug ) );
}
unset($options['default_cat_name']);
// Default Link Category
if (strlen($options['default_link_cat']) > 0){
global $wpdb;
$cat = $options['default_link_cat'];
$slug = str_replace(' ', '-', strtolower($cat));
$results = $wpdb->query( $wpdb->prepare("UPDATE $wpdb->terms SET name = %s, slug = %s WHERE term_id = 2", $cat, $slug ) );
}
unset($options['default_link_cat']);
//Delete First Comment
if (isset($options['delete_first_comment']) && $options['delete_first_comment'] == 1){
wp_delete_comment( 1 );
}
unset($options['delete_first_comment']);
// Close Comments on Hello World
if (isset($options['close_comments_on_hello_world']) && $options['close_comments_on_hello_world'] == 1){
global $wpdb;
$statement = "UPDATE $wpdb->posts SET comment_status = 'closed' WHERE id = 1";
$results = $wpdb->query( $statement );
}
unset($options['close_comments_on_hello_world']);
// Close Comments on About Page
if (isset($options['close_comments_on_about_page']) && $options['close_comments_on_about_page'] == 1){
global $wpdb;
$statement = "UPDATE $wpdb->posts SET comment_status = 'closed' WHERE id = 2";
//.........这里部分代码省略.........
示例13: wpmu_delete_user
/**
* Delete a user from the network and remove from all sites.
*
* @since 3.0.0
*
* @todo Merge with wp_delete_user() ?
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $id The user ID.
* @return bool True if the user was deleted, otherwise false.
*/
function wpmu_delete_user($id)
{
global $wpdb;
if (!is_numeric($id)) {
return false;
}
$id = (int) $id;
$user = new WP_User($id);
if (!$user->exists()) {
return false;
}
// Global super-administrators are protected, and cannot be deleted.
$_super_admins = get_super_admins();
if (in_array($user->user_login, $_super_admins, true)) {
return false;
}
/**
* Fires before a user is deleted from the network.
*
* @since MU
*
* @param int $id ID of the user about to be deleted from the network.
*/
do_action('wpmu_delete_user', $id);
$blogs = get_blogs_of_user($id);
if (!empty($blogs)) {
foreach ($blogs as $blog) {
switch_to_blog($blog->userblog_id);
remove_user_from_blog($id, $blog->userblog_id);
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
foreach ((array) $post_ids as $post_id) {
wp_delete_post($post_id);
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
restore_current_blog();
}
}
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
clean_user_cache($user);
/** This action is documented in wp-admin/includes/user.php */
do_action('deleted_user', $id);
return true;
}
示例14: wp_delete_user
/**
* Remove user and optionally reassign posts and links to another user.
*
* If the $reassign parameter is not assigned to an User ID, then all posts will
* be deleted of that user. The action 'delete_user' that is passed the User ID
* being deleted will be run after the posts are either reassigned or deleted.
* The user meta will also be deleted that are for that User ID.
*
* @since 2.0.0
*
* @param int $id User ID.
* @param int $reassign Optional. Reassign posts and links to new User ID.
* @return bool True when finished.
*/
function wp_delete_user($id, $reassign = 'novalue')
{
global $wpdb;
$id = (int) $id;
$user = new WP_User($id);
// allow for transaction statement
do_action('delete_user', $id);
if ('novalue' === $reassign || null === $reassign) {
$post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
if ($post_ids) {
foreach ($post_ids as $post_id) {
wp_delete_post($post_id);
}
}
// Clean links
$link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
if ($link_ids) {
foreach ($link_ids as $link_id) {
wp_delete_link($link_id);
}
}
} else {
$reassign = (int) $reassign;
$wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
$wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
}
// FINALLY, delete user
if (is_multisite()) {
remove_user_from_blog($id, get_current_blog_id());
} else {
$meta = $wpdb->get_col($wpdb->prepare("SELECT umeta_id FROM {$wpdb->usermeta} WHERE user_id = %d", $id));
foreach ($meta as $mid) {
delete_metadata_by_mid('user', $mid);
}
$wpdb->delete($wpdb->users, array('ID' => $id));
}
clean_user_cache($user);
// allow for commit transaction
do_action('deleted_user', $id);
return true;
}
示例15: ReciprocalLinkChecker
function ReciprocalLinkChecker($RecipCheckAddress = '', $recipcheckdelete403 = false)
{
global $wpdb;
if ($RecipCheckAddress != '') {
$linkquery = "SELECT distinct *, l.link_id as proper_link_id, UNIX_TIMESTAMP(l.link_updated) as link_date ";
$linkquery .= "FROM " . $this->db_prefix() . "terms t ";
$linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
$linkquery .= "LEFT JOIN " . $this->db_prefix() . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
$linkquery .= "LEFT JOIN " . $this->db_prefix() . "links l ON (tr.object_id = l.link_id) ";
$linkquery .= "LEFT JOIN " . $this->db_prefix() . "links_extrainfo le ON (l.link_id = le.link_id) ";
$linkquery .= "WHERE tt.taxonomy = 'link_category' ";
$linkquery .= "AND le.link_reciprocal <> '' ";
$linkquery .= "order by l.link_name ASC";
$links = $wpdb->get_results($linkquery);
$output = "<strong>Reciprocal Link Checker Report</strong><br /><br />";
if ($links) {
foreach ($links as $link) {
$sitecontent = file_get_contents($link->link_reciprocal);
$output .= "<a href='" . $link->link_url . "'>" . $link->link_name . "</a>: ";
if (strpos($http_response_header[0], "200")) {
if (strpos($sitecontent, $RecipCheckAddress) === false) {
$output .= "<span style='color: #FF0000'>Not Found</span><br />";
} elseif (strpos($sitecontent, $RecipCheckAddress) !== false) {
$output .= "<span style='color: #00FF00'>OK</span><br />";
}
} elseif (strpos($http_response_header[0], "403") && $recipcheckdelete403 == true) {
wp_delete_link($link->link_id);
$output .= "Error 403: Link Deleted";
} else {
$output .= "Website Unreachable";
}
}
} else {
$output = "There are no links with reciprocal links associated with them.<br />";
}
return $output;
}
}