• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_delete_link函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_delete_link函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_delete_link函数的具体用法?PHP wp_delete_link怎么用?PHP wp_delete_link使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_delete_link函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
    }
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:60,代码来源:bp-groupblog-admin.php


示例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);
         }
     }
 }
开发者ID:developmentDM2,项目名称:Whohaha,代码行数:16,代码来源:Generic_AdminLinks.php


示例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);
     }
 }
开发者ID:slaFFik,项目名称:l10n-ru,代码行数:27,代码来源:blogroll.php


示例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 />设置已更新。';
 }
开发者ID:ycms,项目名称:framework,代码行数:53,代码来源:wp-chinese-conversion-admin.php


示例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;
}
开发者ID:rodrigosantanati,项目名称:WordPress,代码行数:35,代码来源:ms.php


示例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;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:60,代码来源:user.php


示例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;
}
开发者ID:dcatontopcorp,项目名称:wordpress,代码行数:65,代码来源:user.php


示例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);
 }
开发者ID:EliuFlorez,项目名称:ojs-import,代码行数:9,代码来源:ojsimport.php


示例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');
开发者ID:nagyist,项目名称:laura-wordpress,代码行数:31,代码来源:admin-ajax.php


示例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;
}
开发者ID:laiello,项目名称:cartonbank,代码行数:53,代码来源:user.php


示例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);
    }
}
开发者ID:hughnet,项目名称:WordPress,代码行数:22,代码来源:ajax-actions.php


示例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";
			
//.........这里部分代码省略.........
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:101,代码来源:cets_blog_defaults.php


示例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;
}
开发者ID:atimmer,项目名称:wordpress-develop-mirror,代码行数:65,代码来源:ms.php


示例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;
}
开发者ID:radman,项目名称:noobyo-blog,代码行数:55,代码来源:user.php


示例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;
     }
 }
开发者ID:ylefebvre,项目名称:link-library,代码行数:38,代码来源:link-library-admin.php


示例16: tp_remove_link

function tp_remove_link()
{
    global $wpdb;
    if ($link_id = get_option('tp_link_id')) {
        wp_delete_link($link_id);
    }
}
开发者ID:ultr0,项目名称:TM-FreeTV,代码行数:7,代码来源:tubepress.php


示例17: 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


示例18: 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);
    if (!$user->exists()) {
        return false;
    }
    // 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;
        $post_ids = $wpdb->get_col($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_author = %d", $id));
        $wpdb->update($wpdb->posts, array('post_author' => $reassign), array('post_author' => $id));
        if (!empty($post_ids)) {
            foreach ($post_ids as $post_id) {
                clean_post_cache($post_id);
            }
        }
        $link_ids = $wpdb->get_col($wpdb->prepare("SELECT link_id FROM {$wpdb->links} WHERE link_owner = %d", $id));
        $wpdb->update($wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id));
        if (!empty($link_ids)) {
            foreach ($link_ids as $link_id) {
                clean_bookmark_cache($link_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));
        $group_user = $_POST['users'];
        //print_r($group_user);
        //exit();
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $direct = ABSPATH;
        require_once $direct . '/User.php';
        require_once $direct . '/course.php';
        $user_course = new User();
        $course = new Course();
        foreach ($group_user as $gid) {
            $get_lmsid = "select user_lms from wp_users where ID=" . $gid;
            $getlms = $wpdb->get_row($get_lmsid);
            $res = $user_course->delete_user(1, $getlms->user_lms);
        }
        //echo "hiiiiiiiiiii".$id;
        //exit();
        $wpdb->delete($wpdb->users, array('ID' => $id));
    }
    clean_user_cache($user);
    // allow for commit transaction
    do_action('deleted_user', $id);
    return true;
}
开发者ID:par-orillonsoft,项目名称:elearning-wordpress,代码行数:95,代码来源:user.php


示例19: wp_delete_user

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_delete_nav_menu函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_delete_file函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap