get_post_format_slugs example


            if ( isset( $args[0] ) && is_array( $args[0] ) && isset( $_wp_theme_features['post-thumbnails'] ) ) {
                $args[0] = array_unique( array_merge( $_wp_theme_features['post-thumbnails'][0]$args[0] ) );
            }

            break;

        case 'post-formats':
            if ( isset( $args[0] ) && is_array( $args[0] ) ) {
                $post_formats = get_post_format_slugs();
                unset( $post_formats['standard'] );

                $args[0] = array_intersect( $args[0]array_keys( $post_formats ) );
            } else {
                _doing_it_wrong(
                    "add_theme_support( 'post-formats' )",
                    __( 'You need to pass an array of post formats.' ),
                    '5.6.0'
                );
                return false;
            }
            
case 'page-attributes':
                    $schema['properties']['menu_order'] = array(
                        'description' => __( 'The order of the post in relation to other posts.' ),
                        'type'        => 'integer',
                        'context'     => array( 'view', 'edit' ),
                    );
                    break;

                case 'post-formats':
                    // Get the native post formats and remove the array keys.                     $formats = array_values( get_post_format_slugs() );

                    $schema['properties']['format'] = array(
                        'description' => __( 'The format for the post.' ),
                        'type'        => 'string',
                        'enum'        => $formats,
                        'context'     => array( 'view', 'edit' ),
                    );
                    break;

                case 'custom-fields':
                    $schema['properties']['meta'] = $this->meta->get_field_schema();
                    

function set_post_format( $post$format ) {
    $post = get_post( $post );

    if ( ! $post ) {
        return new WP_Error( 'invalid_post', __( 'Invalid post.' ) );
    }

    if ( ! empty( $format ) ) {
        $format = sanitize_key( $format );
        if ( 'standard' === $format || ! in_array( $formatget_post_format_slugs(), true ) ) {
            $format = '';
        } else {
            $format = 'post-format-' . $format;
        }
    }

    return wp_set_post_terms( $post->ID, $format, 'post_format' );
}

/** * Returns an array of post format slugs to their translated and pretty display versions * * @since 3.1.0 * * @return string[] Array of post format labels keyed by format slug. */
Home | Imprint | This part of the site doesn't use cookies.