当前位置: 首页>>代码示例>>PHP>>正文


PHP delete_metadata_by_mid函数代码示例

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


在下文中一共展示了delete_metadata_by_mid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: delete_term_meta_when_term_is_deleted

/**
 * Hook into the delete_term action and make sure any meta is also delete
 * @param int $term_id
 */
function delete_term_meta_when_term_is_deleted($term_id)
{
    global $wpdb;
    $term_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->termmeta} WHERE term_id = %d ", $term_id));
    foreach ($term_meta_ids as $mid) {
        delete_metadata_by_mid('term', $mid);
    }
}
开发者ID:humanmade,项目名称:hm-core,代码行数:12,代码来源:hm-core.termmeta.php

示例2: test_delete_metadata_by_mid

 function test_delete_metadata_by_mid()
 {
     // Let's try and delete a non-existing ID, non existing meta
     $this->assertFalse(delete_metadata_by_mid('user', 0));
     $this->assertFalse(delete_metadata_by_mid('non_existing_meta', $this->delete_meta_id));
     // Now let's delete the real meta data
     $this->assertTrue(delete_metadata_by_mid('user', $this->delete_meta_id));
     // And make sure it's been deleted
     $this->assertFalse(get_metadata_by_mid('user', $this->delete_meta_id));
     // Make sure the caches are cleared
     $this->assertFalse((bool) get_user_meta($this->author->ID, 'delete_meta_key'));
 }
开发者ID:rmccue,项目名称:wordpress-unit-tests,代码行数:12,代码来源:meta.php

示例3: delete

 public function delete()
 {
     global $wpdb;
     //Delete cache
     wp_cache_delete($this->reaction_id, 'post_reactions');
     //Delete meta
     $reaction_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->reactionmeta} WHERE reaction_id = %d ", $this->reaction_id));
     foreach ($reaction_meta_ids as $mid) {
         delete_metadata_by_mid('reaction', $mid);
     }
     //Delete db row
     return (bool) $wpdb->delete($wpdb->reactions, array('reaction_id' => $this->reaction_id));
 }
开发者ID:funkedgeek,项目名称:reactpress,代码行数:13,代码来源:reaction.php

示例4: dcr_usage_count

 /**
  * Decrease usage count fo current coupon.
  *
  * @access public
  * @param  string $used_by Either user ID or billing email
  * @return void
  */
 public function dcr_usage_count($used_by = '')
 {
     global $wpdb;
     $this->usage_count--;
     update_post_meta($this->id, 'usage_count', $this->usage_count);
     // Delete 1 used by meta
     $meta_id = $wpdb->get_var($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key = '_used_by' AND meta_value = %s AND post_id = %d LIMIT 1;", $used_by, $this->id));
     if ($meta_id) {
         delete_metadata_by_mid('post', $meta_id);
     }
 }
开发者ID:vanminh0910,项目名称:shangri-la,代码行数:18,代码来源:class-wc-coupon.php

示例5: wp_delete_attachment

/**
 * Trash or delete an attachment.
 *
 * When an attachment is permanently deleted, the file will also be removed.
 * Deletion removes all post meta fields, taxonomy, comments, etc. associated
 * with the attachment (except the main post).
 *
 * The attachment is moved to the trash instead of permanently deleted unless trash
 * for media is disabled, item is already in the trash, or $force_delete is true.
 *
 * @since 2.0.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @param int  $post_id      Attachment ID.
 * @param bool $force_delete Optional. Whether to bypass trash and force deletion.
 *                           Default false.
 * @return mixed False on failure. Post data on success.
 */
function wp_delete_attachment($post_id, $force_delete = false)
{
    global $wpdb;
    if (!($post = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d", $post_id)))) {
        return $post;
    }
    if ('attachment' != $post->post_type) {
        return false;
    }
    if (!$force_delete && EMPTY_TRASH_DAYS && MEDIA_TRASH && 'trash' != $post->post_status) {
        return wp_trash_post($post_id);
    }
    delete_post_meta($post_id, '_wp_trash_meta_status');
    delete_post_meta($post_id, '_wp_trash_meta_time');
    $meta = wp_get_attachment_metadata($post_id);
    $backup_sizes = get_post_meta($post->ID, '_wp_attachment_backup_sizes', true);
    $file = get_attached_file($post_id);
    if (is_multisite()) {
        delete_transient('dirsize_cache');
    }
    /**
     * Fires before an attachment is deleted, at the start of wp_delete_attachment().
     *
     * @since 2.0.0
     *
     * @param int $post_id Attachment ID.
     */
    do_action('delete_attachment', $post_id);
    wp_delete_object_term_relationships($post_id, array('category', 'post_tag'));
    wp_delete_object_term_relationships($post_id, get_object_taxonomies($post->post_type));
    // Delete all for any posts.
    delete_metadata('post', null, '_thumbnail_id', $post_id, true);
    wp_defer_comment_counting(true);
    $comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d", $post_id));
    foreach ($comment_ids as $comment_id) {
        wp_delete_comment($comment_id, true);
    }
    wp_defer_comment_counting(false);
    $post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d ", $post_id));
    foreach ($post_meta_ids as $mid) {
        delete_metadata_by_mid('post', $mid);
    }
    /** This action is documented in wp-includes/post.php */
    do_action('delete_post', $post_id);
    $result = $wpdb->delete($wpdb->posts, array('ID' => $post_id));
    if (!$result) {
        return false;
    }
    /** This action is documented in wp-includes/post.php */
    do_action('deleted_post', $post_id);
    $uploadpath = wp_upload_dir();
    if (!empty($meta['thumb'])) {
        // Don't delete the thumb if another attachment uses it.
        if (!$wpdb->get_row($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE meta_key = '_wp_attachment_metadata' AND meta_value LIKE %s AND post_id <> %d", '%' . $wpdb->esc_like($meta['thumb']) . '%', $post_id))) {
            $thumbfile = str_replace(basename($file), $meta['thumb'], $file);
            /** This filter is documented in wp-includes/functions.php */
            $thumbfile = apply_filters('wp_delete_file', $thumbfile);
            @unlink(path_join($uploadpath['basedir'], $thumbfile));
        }
    }
    // Remove intermediate and backup images if there are any.
    if (isset($meta['sizes']) && is_array($meta['sizes'])) {
        foreach ($meta['sizes'] as $size => $sizeinfo) {
            $intermediate_file = str_replace(basename($file), $sizeinfo['file'], $file);
            /** This filter is documented in wp-includes/functions.php */
            $intermediate_file = apply_filters('wp_delete_file', $intermediate_file);
            @unlink(path_join($uploadpath['basedir'], $intermediate_file));
        }
    }
    if (is_array($backup_sizes)) {
        foreach ($backup_sizes as $size) {
            $del_file = path_join(dirname($meta['file']), $size['file']);
            /** This filter is documented in wp-includes/functions.php */
            $del_file = apply_filters('wp_delete_file', $del_file);
            @unlink(path_join($uploadpath['basedir'], $del_file));
        }
    }
    wp_delete_file($file);
    clean_post_cache($post);
    return $post;
}
开发者ID:SayenkoDesign,项目名称:ividf,代码行数:100,代码来源:post.php

示例6: do_all_pings

/**
 * Perform all pingbacks, enclosures, trackbacks, and send to pingback services.
 *
 * @since 2.1.0
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 */
function do_all_pings()
{
    global $wpdb;
    // Do pingbacks
    while ($ping = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_pingme' LIMIT 1")) {
        delete_metadata_by_mid('post', $ping->meta_id);
        pingback($ping->post_content, $ping->ID);
    }
    // Do Enclosures
    while ($enclosure = $wpdb->get_row("SELECT ID, post_content, meta_id FROM {$wpdb->posts}, {$wpdb->postmeta} WHERE {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id AND {$wpdb->postmeta}.meta_key = '_encloseme' LIMIT 1")) {
        delete_metadata_by_mid('post', $enclosure->meta_id);
        do_enclose($enclosure->post_content, $enclosure->ID);
    }
    // Do Trackbacks
    $trackbacks = $wpdb->get_col("SELECT ID FROM {$wpdb->posts} WHERE to_ping <> '' AND post_status = 'publish'");
    if (is_array($trackbacks)) {
        foreach ($trackbacks as $trackback) {
            do_trackbacks($trackback);
        }
    }
    //Do Update Services/Generic Pings
    generic_ping();
}
开发者ID:hadywisam,项目名称:WordPress,代码行数:30,代码来源:comment-functions.php

示例7: test_get_post_meta_by_id

 function test_get_post_meta_by_id()
 {
     $mid = add_post_meta($this->post_id, 'get_post_meta_by_key', 'get_post_meta_by_key_value', true);
     $this->assertInternalType('integer', $mid);
     $mobj = new stdClass();
     $mobj->meta_id = $mid;
     $mobj->post_id = $this->post_id;
     $mobj->meta_key = 'get_post_meta_by_key';
     $mobj->meta_value = 'get_post_meta_by_key_value';
     $this->assertEquals($mobj, get_post_meta_by_id($mid));
     delete_metadata_by_mid('post', $mid);
     $mid = add_post_meta($this->post_id, 'get_post_meta_by_key', array('foo', 'bar'), true);
     $this->assertInternalType('integer', $mid);
     $mobj->meta_id = $mid;
     $mobj->meta_value = array('foo', 'bar');
     $this->assertEquals($mobj, get_post_meta_by_id($mid));
     delete_metadata_by_mid('post', $mid);
 }
开发者ID:boonebgorges,项目名称:wp,代码行数:18,代码来源:meta.php

示例8: delete_meta

/**
 * Delete post meta data by meta ID.
 *
 * @since 1.2.0
 *
 * @param int $mid
 * @return bool
 */
function delete_meta($mid)
{
    return delete_metadata_by_mid('post', $mid);
}
开发者ID:nicholasgriffintn,项目名称:WordPress,代码行数:12,代码来源:post.php

示例9: wp_delete_user

/**
 * Remove user and optionally reassign posts and links to another user.
 *
 * If the $reassign parameter is not assigned to a 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
 *
 * @global wpdb $wpdb WordPress database abstraction object.
 *
 * @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 = null)
{
    global $wpdb;
    if (!is_numeric($id)) {
        return false;
    }
    $id = (int) $id;
    $user = new WP_User($id);
    if (!$user->exists()) {
        return false;
    }
    // Normalize $reassign to null or a user ID. 'novalue' was an older default.
    if ('novalue' === $reassign) {
        $reassign = null;
    } elseif (null !== $reassign) {
        $reassign = (int) $reassign;
    }
    /**
     * Fires immediately before a user is deleted from the database.
     *
     * @since 2.0.0
     *
     * @param int      $id       ID of the user to delete.
     * @param int|null $reassign ID of the user to reassign posts and links to.
     *                           Default null, for no reassignment.
     */
    do_action('delete_user', $id, $reassign);
    if (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;
            }
        }
        /**
         * Filter the list of post types to delete with a user.
         *
         * @since 3.4.0
         *
         * @param array $post_types_to_delete Post types to delete.
         * @param int   $id                   User ID.
         */
        $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 {
        $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));
        foreach ($meta as $mid) {
            delete_metadata_by_mid('user', $mid);
        }
        $wpdb->delete($wpdb->users, array('ID' => $id));
//.........这里部分代码省略.........
开发者ID:huchka,项目名称:WordPress,代码行数:101,代码来源:user.php

示例10: delete_meta

 /**
  * Delete meta from a post
  *
  * @param int $id Post ID
  * @param int $mid Metadata ID
  * @return array|WP_Error Message on success, WP_Error otherwise
  */
 public function delete_meta($id, $mid)
 {
     $id = (int) $id;
     if (empty($id)) {
         return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
     }
     $post = get_post($id, ARRAY_A);
     if (empty($post['ID'])) {
         return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404));
     }
     if (!$this->check_edit_permission($post)) {
         return new WP_Error('json_cannot_edit', __('Sorry, you cannot edit this post'), array('status' => 403));
     }
     $current = get_metadata_by_mid('post', $mid);
     if (empty($current)) {
         return new WP_Error('json_meta_invalid_id', __('Invalid meta ID.'), array('status' => 404));
     }
     if (absint($current->post_id) !== $id) {
         return new WP_Error('json_meta_post_mismatch', __('Meta does not belong to this post'), array('status' => 400));
     }
     // for now let's not allow updating of arrays, objects or serialized values.
     if (!$this->is_valid_meta_data($current->meta_value)) {
         return new WP_Error('json_post_invalid_action', __('Invalid existing meta data for action.'), array('status' => 400));
     }
     if (is_protected_meta($current->meta_key)) {
         return new WP_Error('json_meta_protected', sprintf(__('%s is marked as a protected field.'), $current->meta_key), array('status' => 403));
     }
     if (!delete_metadata_by_mid('post', $mid)) {
         return new WP_Error('json_meta_could_not_add', __('Could not delete post meta.'), array('status' => 500));
     }
     return array('message' => __('Deleted meta'));
 }
开发者ID:elangovanaspire,项目名称:bimini,代码行数:39,代码来源:class-wp-json-posts.php

示例11: mpp_delete_media

/**
 * Remove a Media entry from gallery
 * 
 * @param type $media_id
 */
function mpp_delete_media($media_id)
{
    global $wpdb;
    if (!($media = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->posts} WHERE ID = %d", $media_id)))) {
        return $post;
    }
    if (mpp_get_media_post_type() != $media->post_type) {
        return false;
    }
    //firs of all delete all media associated with this post
    $storage_manager = mpp_get_storage_manager($media_id);
    $storage_manager->delete($media_id);
    //now proceed to delete the post
    mpp_delete_media_meta($media_id, '_wp_trash_meta_status');
    mpp_delete_media_meta($media_id, '_wp_trash_meta_time');
    do_action('mpp_delete_media', $media_id);
    wp_delete_object_term_relationships($media_id, array('category', 'post_tag'));
    wp_delete_object_term_relationships($media_id, get_object_taxonomies(mpp_get_media_post_type()));
    delete_metadata('post', null, '_thumbnail_id', $media_id, true);
    // delete all for any posts.
    //dele if it is set as cover
    delete_metadata('post', null, '_mpp_cover_id', $media_id, true);
    // delete all for any posts.
    $comment_ids = $wpdb->get_col($wpdb->prepare("SELECT comment_ID FROM {$wpdb->comments} WHERE comment_post_ID = %d", $media_id));
    foreach ($comment_ids as $comment_id) {
        wp_delete_comment($comment_id, true);
    }
    //if media has cover, delete the cover
    if (mpp_media_has_cover_image($media_id)) {
        mpp_delete_media(mpp_get_media_cover_id($media_id));
    }
    //delete met
    $post_meta_ids = $wpdb->get_col($wpdb->prepare("SELECT meta_id FROM {$wpdb->postmeta} WHERE post_id = %d ", $media_id));
    foreach ($post_meta_ids as $mid) {
        delete_metadata_by_mid('post', $mid);
    }
    $result = $wpdb->delete($wpdb->posts, array('ID' => $media_id));
    if (!$result) {
        return false;
    }
    //decrease the media_count in gallery by 1
    mpp_gallery_decrement_media_count($media->post_parent);
    //delete all activities related to this media
    mpp_media_delete_activities($media_id);
    //delete all activity meta key where this media is associated
    mpp_media_delete_activity_meta($media_id);
    clean_post_cache($media);
    do_action('mpp_media_deleted', $media_id);
    return $media;
}
开发者ID:baden03,项目名称:mediapress,代码行数:55,代码来源:functions.php

示例12: delete_meta

 /**
  * Deletes meta based on meta ID.
  *
  * @since  2.7.0
  * @param  WC_Data
  * @param  stdClass (containing at least ->id)
  * @return array
  */
 public function delete_meta(&$object, $meta)
 {
     delete_metadata_by_mid($this->meta_type, $meta->id);
 }
开发者ID:woocommerce,项目名称:woocommerce,代码行数:12,代码来源:class-wc-data-store-wp.php

示例13: do_enclose

/**
 * Check content for video and audio links to add as enclosures.
 *
 * Will not add enclosures that have already been added and will
 * remove enclosures that are no longer in the post. This is called as
 * pingbacks and trackbacks.
 *
 * @package WordPress
 * @since 1.5.0
 *
 * @uses $wpdb
 *
 * @param string $content Post Content
 * @param int $post_ID Post ID
 */
function do_enclose( $content, $post_ID ) {
	global $wpdb;

	//TODO: Tidy this ghetto code up and make the debug code optional
	include_once( ABSPATH . WPINC . '/class-IXR.php' );

	$post_links = array();

	$pung = get_enclosed( $post_ID );

	$ltrs = '\w';
	$gunk = '/#~:.?+=&%@!\-';
	$punc = '.:?\-';
	$any = $ltrs . $gunk . $punc;

	preg_match_all( "{\b http : [$any] +? (?= [$punc] * [^$any] | $)}x", $content, $post_links_temp );

	foreach ( $pung as $link_test ) {
		if ( !in_array( $link_test, $post_links_temp[0] ) ) { // link no longer in post
			$mids = $wpdb->get_col( $wpdb->prepare("SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $link_test ) . '%') );
			foreach ( $mids as $mid )
				delete_metadata_by_mid( 'post', $mid );
		}
	}

	foreach ( (array) $post_links_temp[0] as $link_test ) {
		if ( !in_array( $link_test, $pung ) ) { // If we haven't pung it already
			$test = @parse_url( $link_test );
			if ( false === $test )
				continue;
			if ( isset( $test['query'] ) )
				$post_links[] = $link_test;
			elseif ( isset($test['path']) && ( $test['path'] != '/' ) &&  ($test['path'] != '' ) )
				$post_links[] = $link_test;
		}
	}

	foreach ( (array) $post_links as $url ) {
		if ( $url != '' && !$wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE (%s)", $post_ID, like_escape( $url ) . '%' ) ) ) {

			if ( $headers = wp_get_http_headers( $url) ) {
				$len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;
				$type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';
				$allowed_types = array( 'video', 'audio' );

				// Check to see if we can figure out the mime type from
				// the extension
				$url_parts = @parse_url( $url );
				if ( false !== $url_parts ) {
					$extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION );
					if ( !empty( $extension ) ) {
						foreach ( get_allowed_mime_types( ) as $exts => $mime ) {
							if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) {
								$type = $mime;
								break;
							}
						}
					}
				}

				if ( in_array( substr( $type, 0, strpos( $type, "/" ) ), $allowed_types ) ) {
					add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" );
				}
			}
		}
	}
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:82,代码来源:functions.php

示例14: write_post


//.........这里部分代码省略.........
                  * EG: array( 'twitter', 'facebook') will only publicize to those, ignoring the other available services
                  * 		Form data: publicize[]=twitter&publicize[]=facebook
                  * EG: array( 'twitter' => '(int) $pub_conn_id_0, (int) $pub_conn_id_3', 'facebook' => (int) $pub_conn_id_7 ) will publicize to two Twitter accounts, and one Facebook connection, of potentially many.
                  * 		Form data: publicize[twitter]=$pub_conn_id_0,$pub_conn_id_3&publicize[facebook]=$pub_conn_id_7
                  * EG: array( 'twitter', 'facebook' => '(int) $pub_conn_id_0, (int) $pub_conn_id_3' ) will publicize to all available Twitter accounts, but only 2 of potentially many Facebook connections
                  * 		Form data: publicize[]=twitter&publicize[facebook]=$pub_conn_id_0,$pub_conn_id_3
                  */
                 if (!in_array($name, $publicize) && !array_key_exists($name, $publicize)) {
                     // Skip the whole service
                     update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $name, 1);
                 } else {
                     if (!empty($publicize[$name])) {
                         // Seems we're being asked to only push to [a] specific connection[s].
                         // Explode the list on commas, which will also support a single passed ID
                         $requested_connections = explode(',', preg_replace('/[\\s]*/', '', $publicize[$name]));
                         // Get the user's connections and flag the ones we can't match with the requested list to be skipped.
                         $service_connections = $GLOBALS['publicize_ui']->publicize->get_connections($name);
                         foreach ($service_connections as $service_connection) {
                             if (!in_array($service_connection->meta['connection_data']->id, $requested_connections)) {
                                 update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_SKIP . $service_connection->unique_id, 1);
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!empty($publicize_custom_message)) {
         update_post_meta($post_id, $GLOBALS['publicize_ui']->publicize->POST_MESS, trim($publicize_custom_message));
     }
     set_post_format($post_id, $insert['post_format']);
     if (!empty($featured_image)) {
         $this->parse_and_set_featured_image($post_id, $delete_featured_image, $featured_image);
     }
     if (!empty($metadata)) {
         foreach ((array) $metadata as $meta) {
             $meta = (object) $meta;
             $existing_meta_item = new stdClass();
             if (empty($meta->operation)) {
                 $meta->operation = 'update';
             }
             if (!empty($meta->value)) {
                 if ('true' == $meta->value) {
                     $meta->value = true;
                 }
                 if ('false' == $meta->value) {
                     $meta->value = false;
                 }
             }
             if (!empty($meta->id)) {
                 $meta->id = absint($meta->id);
                 $existing_meta_item = get_metadata_by_mid('post', $meta->id);
             }
             $unslashed_meta_key = wp_unslash($meta->key);
             // should match what the final key will be
             $meta->key = wp_slash($meta->key);
             $unslashed_existing_meta_key = wp_unslash($existing_meta_item->meta_key);
             $existing_meta_item->meta_key = wp_slash($existing_meta_item->meta_key);
             switch ($meta->operation) {
                 case 'delete':
                     if (!empty($meta->id) && !empty($existing_meta_item->meta_key) && current_user_can('delete_post_meta', $post_id, $unslashed_existing_meta_key)) {
                         delete_metadata_by_mid('post', $meta->id);
                     } elseif (!empty($meta->key) && !empty($meta->previous_value) && current_user_can('delete_post_meta', $post_id, $unslashed_meta_key)) {
                         delete_post_meta($post_id, $meta->key, $meta->previous_value);
                     } elseif (!empty($meta->key) && current_user_can('delete_post_meta', $post_id, $unslashed_meta_key)) {
                         delete_post_meta($post_id, $meta->key);
                     }
                     break;
                 case 'add':
                     if (!empty($meta->id) || !empty($meta->previous_value)) {
                         continue;
                     } elseif (!empty($meta->key) && !empty($meta->value) && current_user_can('add_post_meta', $post_id, $unslashed_meta_key) || $this->is_metadata_public($meta->key)) {
                         add_post_meta($post_id, $meta->key, $meta->value);
                     }
                     break;
                 case 'update':
                     if (!isset($meta->value)) {
                         continue;
                     } elseif (!empty($meta->id) && !empty($existing_meta_item->meta_key) && (current_user_can('edit_post_meta', $post_id, $unslashed_existing_meta_key) || $this->is_metadata_public($meta->key))) {
                         update_metadata_by_mid('post', $meta->id, $meta->value);
                     } elseif (!empty($meta->key) && !empty($meta->previous_value) && (current_user_can('edit_post_meta', $post_id, $unslashed_meta_key) || $this->is_metadata_public($meta->key))) {
                         update_post_meta($post_id, $meta->key, $meta->value, $meta->previous_value);
                     } elseif (!empty($meta->key) && (current_user_can('edit_post_meta', $post_id, $unslashed_meta_key) || $this->is_metadata_public($meta->key))) {
                         update_post_meta($post_id, $meta->key, $meta->value);
                     }
                     break;
             }
         }
     }
     do_action('rest_api_inserted_post', $post_id, $insert, $new);
     $return = $this->get_post_by('ID', $post_id, $args['context']);
     if (!$return || is_wp_error($return)) {
         return $return;
     }
     if ('revision' === $input['type']) {
         $return['preview_nonce'] = wp_create_nonce('post_preview_' . $input['parent']);
     }
     do_action('wpcom_json_api_objects', 'posts');
     return $return;
 }
开发者ID:lokenxo,项目名称:familygenerator,代码行数:101,代码来源:class.wpcom-json-api-update-post-endpoint.php

示例15: wpmu_delete_user

 public static function wpmu_delete_user($id)
 {
     global $wpdb;
     $id = (int) $id;
     $user = new WP_User($id);
     if (!$user->exists()) {
         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);
     $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);
     do_action('deleted_user', $id);
     return true;
 }
开发者ID:geminorum,项目名称:gmember,代码行数:25,代码来源:spam.class.php


注:本文中的delete_metadata_by_mid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。