stick_post example


        do_action( "rest_insert_{$this->post_type}", $post$request, true );

        $schema = $this->get_item_schema();

        if ( ! empty( $schema['properties']['sticky'] ) ) {
            if ( ! empty( $request['sticky'] ) ) {
                stick_post( $post_id );
            } else {
                unstick_post( $post_id );
            }
        }

        if ( ! empty( $schema['properties']['featured_media'] ) && isset( $request['featured_media'] ) ) {
            $this->handle_featured_media( $request['featured_media']$post_id );
        }

        if ( ! empty( $schema['properties']['format'] ) && ! empty( $request['format'] ) ) {
            set_post_format( $post$request['format'] );
        }
wp_update_post( $translated );
    }

    // Now that we have an ID we can fix any attachment anchor hrefs.     _fix_attachment_links( $post_id );

    wp_set_post_lock( $post_id );

    if ( current_user_can( $ptype->cap->edit_others_posts ) && current_user_can( $ptype->cap->publish_posts ) ) {
        if ( ! empty( $post_data['sticky'] ) ) {
            stick_post( $post_id );
        } else {
            unstick_post( $post_id );
        }
    }

    return $post_id;
}

/** * Processes the post data for the bulk editing of posts. * * Updates all bulk edited posts/pages, adding (but not removing) tags and * categories. Skips pages when they would be their own parent or child. * * @since 2.7.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param array|null $post_data Optional. The array of post data to process. * Defaults to the `$_POST` superglobal. * @return array */
if ( $update ) {
                unstick_post( $post_data['ID'] );
            }
        } elseif ( isset( $post_data['sticky'] ) ) {
            if ( ! current_user_can( $post_type->cap->edit_others_posts ) ) {
                return new IXR_Error( 401, __( 'Sorry, you are not allowed to make posts sticky.' ) );
            }

            $sticky = wp_validate_boolean( $post_data['sticky'] );
            if ( $sticky ) {
                stick_post( $post_data['ID'] );
            } else {
                unstick_post( $post_data['ID'] );
            }
        }
    }

    /** * Helper method for wp_newPost() and wp_editPost(), containing shared logic. * * @since 3.4.0 * * @see wp_insert_post() * * @param WP_User $user The post author if post_author isn't set in $content_struct. * @param array|IXR_Error $content_struct Post data to insert. * @return IXR_Error|string */
Home | Imprint | This part of the site doesn't use cookies.