wp_parse_args example


    public function __construct( $args = array() ) {
        $defaults = array(
            'url'    => '',
            'plugin' => '',
            'nonce'  => '',
            'title'  => __( 'Update Plugin' ),
        );
        $args     = wp_parse_args( $args$defaults );

        $this->plugin = $args['plugin'];

        $this->plugin_active         = is_plugin_active( $this->plugin );
        $this->plugin_network_active = is_plugin_active_for_network( $this->plugin );

        parent::__construct( $args );
    }

    /** * Performs an action following a single plugin update. * * @since 2.8.0 */
/** * Outputs the Custom HTML widget settings form. * * @since 4.8.1 * @since 4.9.0 The form contains only hidden sync inputs. For the control UI, see `WP_Widget_Custom_HTML::render_control_template_scripts()`. * * @see WP_Widget_Custom_HTML::render_control_template_scripts() * * @param array $instance Current instance. */
    public function form( $instance ) {
        $instance = wp_parse_args( (array) $instance$this->default_instance );
        ?> <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" class="title sync-input" type="hidden" value="<?php echo esc_attr( $instance['title'] ); ?>" /> <textarea id="<?php echo $this->get_field_id( 'content' ); ?>" name="<?php echo $this->get_field_name( 'content' ); ?>" class="content sync-input" hidden><?php echo esc_textarea( $instance['content'] ); ?></textarea> <?php     }

    /** * Render form template scripts. * * @since 4.9.0 */
    


    /** * If empty comments are not allowed, checks if the provided comment content is not empty. * * @since 5.6.0 * * @param array $prepared_comment The prepared comment data. * @return bool True if the content is allowed, false otherwise. */
    protected function check_is_comment_content_allowed( $prepared_comment ) {
        $check = wp_parse_args(
            $prepared_comment,
            array(
                'comment_post_ID'      => 0,
                'comment_author'       => null,
                'comment_author_email' => null,
                'comment_author_url'   => null,
                'comment_parent'       => 0,
                'user_id'              => 0,
            )
        );

        

        } elseif ( null !== $template && 'custom' !== $template->source ) {
            $changes->post_title = $template->title;
        }
        if ( isset( $request['description'] ) ) {
            $changes->post_excerpt = $request['description'];
        } elseif ( null !== $template && 'custom' !== $template->source ) {
            $changes->post_excerpt = $template->description;
        }

        if ( 'wp_template' === $this->post_type && isset( $request['is_wp_suggestion'] ) ) {
            $changes->meta_input     = wp_parse_args(
                array(
                    'is_wp_suggestion' => $request['is_wp_suggestion'],
                ),
                $changes->meta_input = array()
            );
        }

        if ( 'wp_template_part' === $this->post_type ) {
            if ( isset( $request['area'] ) ) {
                $changes->tax_input['wp_template_part_area'] = _filter_block_template_part_area( $request['area'] );
            } elseif ( null !== $template && 'custom' !== $template->source && $template->area ) {
                
 elseif ( is_numeric( $args ) ) {
        $args = array( 'post_parent' => (int) $args );
    }

    $defaults = array(
        'numberposts' => -1,
        'post_type'   => 'any',
        'post_status' => 'any',
        'post_parent' => 0,
    );

    $parsed_args = wp_parse_args( $args$defaults );

    $children = get_posts( $parsed_args );

    if ( ! $children ) {
        return $kids;
    }

    if ( ! empty( $parsed_args['fields'] ) ) {
        return $children;
    }

    

    public function __construct( $args = array() ) {
        $defaults = array(
            'url'   => '',
            'theme' => '',
            'nonce' => '',
            'title' => __( 'Update Theme' ),
        );
        $args     = wp_parse_args( $args$defaults );

        $this->theme = $args['theme'];

        parent::__construct( $args );
    }

    /** * Performs an action following a single theme update. * * @since 2.8.0 */
    
$defaults = array(
        'network_id' => get_current_network_id(),
        'public'     => null,
        'archived'   => null,
        'mature'     => null,
        'spam'       => null,
        'deleted'    => null,
        'limit'      => 100,
        'offset'     => 0,
    );

    $args = wp_parse_args( $args$defaults );

    // Backward compatibility.     if( is_array( $args['network_id'] ) ){
        $args['network__in'] = $args['network_id'];
        $args['network_id'] = null;
    }

    if( is_numeric( $args['limit'] ) ){
        $args['number'] = $args['limit'];
        $args['limit'] = null;
    } elseif ( ! $args['limit'] ) {
        


    /** * Sets block type properties. * * @since 5.0.0 * * @param array|string $args Array or string of arguments for registering a block type. * See WP_Block_Type::__construct() for information on accepted arguments. */
    public function set_props( $args ) {
        $args = wp_parse_args(
            $args,
            array(
                'render_callback' => null,
            )
        );

        $args['name'] = $this->name;

        // Setup attributes if needed.         if ( ! isset( $args['attributes'] ) || ! is_array( $args['attributes'] ) ) {
            $args['attributes'] = array();
        }
'who'                 => '',
            'has_published_posts' => null,
            'nicename'            => '',
            'nicename__in'        => array(),
            'nicename__not_in'    => array(),
            'login'               => '',
            'login__in'           => array(),
            'login__not_in'       => array(),
            'cache_results'       => true,
        );

        return wp_parse_args( $args$defaults );
    }

    /** * Prepares the query variables. * * @since 3.1.0 * @since 4.1.0 Added the ability to order by the `include` value. * @since 4.2.0 Added 'meta_value_num' support for `$orderby` parameter. Added multi-dimensional array syntax * for `$orderby` parameter. * @since 4.3.0 Added 'has_published_posts' parameter. * @since 4.4.0 Added 'paged', 'role__in', and 'role__not_in' parameters. The 'role' parameter was updated to * permit an array or comma-separated list of values. The 'number' parameter was updated to support * querying for all users with using -1. * @since 4.7.0 Added 'nicename', 'nicename__in', 'nicename__not_in', 'login', 'login__in', * and 'login__not_in' parameters. * @since 5.1.0 Introduced the 'meta_compare_key' parameter. * @since 5.3.0 Introduced the 'meta_type_key' parameter. * @since 5.9.0 Added 'capability', 'capability__in', and 'capability__not_in' parameters. * @since 6.3.0 Added 'cache_results' parameter. * * @global wpdb $wpdb WordPress database abstraction object. * @global WP_Roles $wp_roles WordPress role management object. * * @param string|array $query { * Optional. Array or string of query parameters. * * @type int $blog_id The site ID. Default is the current site. * @type string|string[] $role An array or a comma-separated list of role names that users must match * to be included in results. Note that this is an inclusive list: users * must match *each* role. Default empty. * @type string[] $role__in An array of role names. Matched users must have at least one of these * roles. Default empty array. * @type string[] $role__not_in An array of role names to exclude. Users matching one or more of these * roles will not be included in results. Default empty array. * @type string|string[] $meta_key Meta key or keys to filter by. * @type string|string[] $meta_value Meta value or values to filter by. * @type string $meta_compare MySQL operator used for comparing the meta value. * See WP_Meta_Query::__construct() for accepted values and default value. * @type string $meta_compare_key MySQL operator used for comparing the meta key. * See WP_Meta_Query::__construct() for accepted values and default value. * @type string $meta_type MySQL data type that the meta_value column will be CAST to for comparisons. * See WP_Meta_Query::__construct() for accepted values and default value. * @type string $meta_type_key MySQL data type that the meta_key column will be CAST to for comparisons. * See WP_Meta_Query::__construct() for accepted values and default value. * @type array $meta_query An associative array of WP_Meta_Query arguments. * See WP_Meta_Query::__construct() for accepted values. * @type string|string[] $capability An array or a comma-separated list of capability names that users must match * to be included in results. Note that this is an inclusive list: users * must match *each* capability. * Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Default empty. * @type string[] $capability__in An array of capability names. Matched users must have at least one of these * capabilities. * Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Default empty array. * @type string[] $capability__not_in An array of capability names to exclude. Users matching one or more of these * capabilities will not be included in results. * Does NOT work for capabilities not in the database or filtered via {@see 'map_meta_cap'}. * Default empty array. * @type int[] $include An array of user IDs to include. Default empty array. * @type int[] $exclude An array of user IDs to exclude. Default empty array. * @type string $search Search keyword. Searches for possible string matches on columns. * When `$search_columns` is left empty, it tries to determine which * column to search in based on search string. Default empty. * @type string[] $search_columns Array of column names to be searched. Accepts 'ID', 'user_login', * 'user_email', 'user_url', 'user_nicename', 'display_name'. * Default empty array. * @type string|array $orderby Field(s) to sort the retrieved users by. May be a single value, * an array of values, or a multi-dimensional array with fields as * keys and orders ('ASC' or 'DESC') as values. Accepted values are: * - 'ID' * - 'display_name' (or 'name') * - 'include' * - 'user_login' (or 'login') * - 'login__in' * - 'user_nicename' (or 'nicename'), * - 'nicename__in' * - 'user_email (or 'email') * - 'user_url' (or 'url'), * - 'user_registered' (or 'registered') * - 'post_count' * - 'meta_value', * - 'meta_value_num' * - The value of `$meta_key` * - An array key of `$meta_query` * To use 'meta_value' or 'meta_value_num', `$meta_key` * must be also be defined. Default 'user_login'. * @type string $order Designates ascending or descending order of users. Order values * passed as part of an `$orderby` array take precedence over this * parameter. Accepts 'ASC', 'DESC'. Default 'ASC'. * @type int $offset Number of users to offset in retrieved results. Can be used in * conjunction with pagination. Default 0. * @type int $number Number of users to limit the query for. Can be used in * conjunction with pagination. Value -1 (all) is supported, but * should be used with caution on larger sites. * Default -1 (all users). * @type int $paged When used with number, defines the page of results to return. * Default 1. * @type bool $count_total Whether to count the total number of users found. If pagination * is not needed, setting this to false can improve performance. * Default true. * @type string|string[] $fields Which fields to return. Single or all fields (string), or array * of fields. Accepts: * - 'ID' * - 'display_name' * - 'user_login' * - 'user_nicename' * - 'user_email' * - 'user_url' * - 'user_registered' * - 'user_pass' * - 'user_activation_key' * - 'user_status' * - 'spam' (only available on multisite installs) * - 'deleted' (only available on multisite installs) * - 'all' for all fields and loads user meta. * - 'all_with_meta' Deprecated. Use 'all'. * Default 'all'. * @type string $who Type of users to query. Accepts 'authors'. * Default empty (all users). * @type bool|string[] $has_published_posts Pass an array of post types to filter results to users who have * published posts in those post types. `true` is an alias for all * public post types. * @type string $nicename The user nicename. Default empty. * @type string[] $nicename__in An array of nicenames to include. Users matching one of these * nicenames will be included in results. Default empty array. * @type string[] $nicename__not_in An array of nicenames to exclude. Users matching one of these * nicenames will not be included in results. Default empty array. * @type string $login The user login. Default empty. * @type string[] $login__in An array of logins to include. Users matching one of these * logins will be included in results. Default empty array. * @type string[] $login__not_in An array of logins to exclude. Users matching one of these * logins will not be included in results. Default empty array. * @type bool $cache_results Whether to cache user information. Default true. * } */
return $instance;
    }

    /** * Outputs the settings form for the Calendar widget. * * @since 2.8.0 * * @param array $instance Current settings. */
    public function form( $instance ) {
        $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
        ?> <p> <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label> <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>" /> </p> <?php     }
}
$defaults = array(
            'with_front'  => true,
            'ep_mask'     => EP_NONE,
            'paged'       => true,
            'feed'        => true,
            'forcomments' => false,
            'walk_dirs'   => true,
            'endpoints'   => true,
        );

        $args = array_intersect_key( $args$defaults );
        $args = wp_parse_args( $args$defaults );

        if ( $args['with_front'] ) {
            $struct = $this->front . $struct;
        } else {
            $struct = $this->root . $struct;
        }

        $args['struct'] = $struct;

        $this->extra_permastructs[ $name ] = $args;
    }

    
/** * Handles updating settings for the current Text widget instance. * * @since 2.8.0 * * @param array $new_instance New settings for this instance as input by the user via * WP_Widget::form(). * @param array $old_instance Old settings for this instance. * @return array Settings to save or bool false to cancel saving. */
    public function update( $new_instance$old_instance ) {
        $new_instance = wp_parse_args(
            $new_instance,
            array(
                'title'  => '',
                'text'   => '',
                'filter' => false, // For back-compat.                 'visual' => null,  // Must be explicitly defined.             )
        );

        $instance = $old_instance;

        


    /** * Filters the sidebar default arguments. * * @since 5.3.0 * * @see register_sidebar() * * @param array $defaults The default sidebar arguments. */
    $sidebar = wp_parse_args( $argsapply_filters( 'register_sidebar_defaults', $defaults ) );

    if ( $id_is_empty ) {
        _doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: 1: The 'id' argument, 2: Sidebar name, 3: Recommended 'id' value. */
                __( 'No %1$s was set in the arguments array for the "%2$s" sidebar. Defaulting to "%3$s". Manually set the %1$s to "%3$s" to silence this notice and keep existing sidebar content.' ),
                '<code>id</code>',
                $sidebar['name'],
                $sidebar['id']
            ),
            
// Set an empty array and allow default arguments to take over.         $args = array();
    }

    // Defaults are to echo and to output no custom label on the form.     $defaults = array(
        'echo'       => $echo,
        'aria_label' => '',
    );

    $args = wp_parse_args( $args$defaults );

    /** * Filters the array of arguments used when generating the search form. * * @since 5.2.0 * * @param array $args The array of arguments for building the search form. * See get_search_form() for information on accepted arguments. */
    $args = apply_filters( 'search_form_args', $args );

    


            foreach ( $handlers as $key => &$handler ) {

                if ( ! is_numeric( $key ) ) {
                    // Route option, move it to the options.                     $this->route_options[ $route ][ $key ] = $handler;
                    unset( $handlers[ $key ] );
                    continue;
                }

                $handler = wp_parse_args( $handler$defaults );

                // Allow comma-separated HTTP methods.                 if ( is_string( $handler['methods'] ) ) {
                    $methods = explode( ',', $handler['methods'] );
                } elseif ( is_array( $handler['methods'] ) ) {
                    $methods = $handler['methods'];
                } else {
                    $methods = array();
                }

                $handler['methods'] = array();

                
Home | Imprint | This part of the site doesn't use cookies.