wp_resolve_post_date example

 {
            $post_name = $check_name;
        } else { // New post, or slug has changed.             $post_name = sanitize_title( $post_name );
        }
    }

    /* * Resolve the post date from any provided post date or post date GMT strings; * if none are provided, the date will be set to now. */
    $post_date = wp_resolve_post_date( $postarr['post_date']$postarr['post_date_gmt'] );

    if ( ! $post_date ) {
        if ( $wp_error ) {
            return new WP_Error( 'invalid_date', __( 'Invalid date.' ) );
        } else {
            return 0;
        }
    }

    if ( empty( $postarr['post_date_gmt'] ) || '0000-00-00 00:00:00' === $postarr['post_date_gmt'] ) {
        if ( ! in_array( $post_statusget_post_stati( array( 'date_floating' => true ) ), true ) ) {
            
// Populate the menu item object.     $post = array(
        'menu_order'   => $args['menu-item-position'],
        'ping_status'  => 0,
        'post_content' => $args['menu-item-description'],
        'post_excerpt' => $args['menu-item-attr-title'],
        'post_parent'  => $original_parent,
        'post_title'   => $args['menu-item-title'],
        'post_type'    => 'nav_menu_item',
    );

    $post_date = wp_resolve_post_date( $args['menu-item-post-date']$args['menu-item-post-date-gmt'] );
    if ( $post_date ) {
        $post['post_date'] = $post_date;
    }

    $update = 0 != $menu_item_db_id;

    // New menu item. Default is draft status.     if ( ! $update ) {
        $post['ID']          = 0;
        $post['post_status'] = 'publish' === $args['menu-item-status'] ? 'publish' : 'draft';
        $menu_item_db_id     = wp_insert_post( $post, true, $fire_after_hooks );
        
Home | Imprint | This part of the site doesn't use cookies.