get_post_format_strings example

if ( ! $user ) {
            return $this->error;
        }

        if ( ! current_user_can( 'edit_posts' ) ) {
            return new IXR_Error( 403, __( 'Sorry, you are not allowed to access details about this site.' ) );
        }

        /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
        do_action( 'xmlrpc_call', 'wp.getPostFormats', $args$this );

        $formats = get_post_format_strings();

        // Find out if they want a list of currently supports formats.         if ( isset( $args[3] ) && is_array( $args[3] ) ) {
            if ( $args[3]['show-supported'] ) {
                if ( current_theme_supports( 'post-formats' ) ) {
                    $supported = get_theme_support( 'post-formats' );

                    $data              = array();
                    $data['all']       = $formats;
                    $data['supported'] = $supported[0];

                    
'hide_empty'   => 0,
        'name'         => 'default_category',
        'orderby'      => 'name',
        'selected'     => get_option( 'default_category' ),
        'hierarchical' => true,
    )
);
?> </td> </tr> <?php $post_formats = get_post_format_strings();
unset( $post_formats['standard'] );
?> <tr> <th scope="row"><label for="default_post_format"><?php _e( 'Default Post Format' ); ?></label></th> <td> <select name="default_post_format" id="default_post_format"> <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> <?php foreach ( $post_formats as $format_slug => $format_name ) : ?> <option<?php selected( get_option( 'default_post_format' )$format_slug ); ?> value="<?php echo esc_attr( $format_slug ); ?>"><?php echo esc_html( $format_name ); ?></option> <?php endforeach; ?> </select> </td> </tr>
/** * Searches the object type content for a given search request. * * @since 5.6.0 * * @param WP_REST_Request $request Full REST request. * @return array Associative array containing an `WP_REST_Search_Handler::RESULT_IDS` containing * an array of found IDs and `WP_REST_Search_Handler::RESULT_TOTAL` containing the * total count for the matching search results. */
    public function search_items( WP_REST_Request $request ) {
        $format_strings = get_post_format_strings();
        $format_slugs   = array_keys( $format_strings );

        $query_args = array();

        if ( ! empty( $request['search'] ) ) {
            $query_args['search'] = $request['search'];
        }

        /** * Filters the query arguments for a REST API search request. * * Enables adding extra arguments or setting defaults for a post format search request. * * @since 5.6.0 * * @param array $query_args Key value array of query var to query value. * @param WP_REST_Request $request The request used. */
return $strings;
}

/** * Retrieves the array of post format slugs. * * @since 3.1.0 * * @return string[] The array of post format slugs as both keys and values. */
function get_post_format_slugs() {
    $slugs = array_keys( get_post_format_strings() );
    return array_combine( $slugs$slugs );
}

/** * Returns a pretty, translated version of a post format slug * * @since 3.1.0 * * @param string $slug A post format slug. * @return string The translated post format name. */
Home | Imprint | This part of the site doesn't use cookies.