Filter arguments before creating the setting.

@access public
@since 0.1
@param array                $args         The field arguments.
@param WP_Customize_Manager $wp_customize The customizer instance.
@return array
482180
public function filter_setting_args( $args, $wp_customize ) {

		if ( $args['settings'] !== $args['settings'] ) {
			return $args;
		}

		// Set the sanitize-callback if none is defined.
		if ( ! isset( $args['sanitize_callback'] ) || ! $args['sanitize_callback'] ) {
			$args['sanitize_callback'] = [ __CLASS__, 'sanitize' ];

			// If this is a hue control then its value should be an integer.
			if ( isset( $args['mode'] ) && 'hue' === $args['mode'] ) {
				$args['sanitize_callback'] = 'absint';
			}
		}
		return $args;
	}
124738
public function add_section( $args ) {
		global $wp_customize;

		// The default class to be used when creating a section.
		$section_classname = 'WP_Customize_Section';

		if ( isset( $args['type'] ) && array_key_exists( $args['type'], $this->section_types ) ) {
			$section_classname = $this->section_types[ $args['type'] ];
		}
		if ( isset( $args['type'] ) && 'kirki-outer' === $args['type'] ) {
			$args['type']      = 'outer';
			$section_classname = 'WP_Customize_Section';
		}

		// Add the section.
		$wp_customize->add_section( new $section_classname( $wp_customize, $args['id'], $args ) );
	}
429695
public function add_setting( $wp_customize ) {

		/**
		 * Allow filtering the arguments.
		 *
		 * @since 0.1
		 * @param array                $this->args   The arguments.
		 * @param WP_Customize_Manager $wp_customize The customizer instance.
		 * @return array                             Return the arguments.
		 */
		$args = apply_filters( 'kirki_field_add_setting_args', $this->args, $wp_customize );
		if ( isset( $args['settings'] ) ) {
			$wp_customize->add_setting( $args['settings'], $args );
		}
	}
176977
public function delete( $args, $assoc_args ) {
		list( $object_id ) = $args;

		$meta_key   = ! empty( $args[1] ) ? $args[1] : '';
		$meta_value = ! empty( $args[2] ) ? $args[2] : '';

		if ( empty( $meta_key ) && ! Utils\get_flag_value( $assoc_args, 'all' ) ) {
			WP_CLI::error( 'Please specify a meta key, or use the --all flag.' );
		}

		$object_id = $this->check_object_id( $object_id );

		if ( Utils\get_flag_value( $assoc_args, 'all' ) ) {
			$errors = false;
			foreach ( $this->get_metadata( $object_id ) as $meta_key => $values ) {
				$success = $this->delete_metadata( $object_id, $meta_key );
				if ( $success ) {
					WP_CLI::log( "Deleted '{$meta_key}' custom field." );
				} else {
					WP_CLI::warning( "Failed to delete '{$meta_key}' custom field." );
					$errors = true;
				}
			}
			if ( $errors ) {
				WP_CLI::error( 'Failed to delete all custom fields.' );
			} else {
				WP_CLI::success( 'Deleted all custom fields.' );
			}
		} else {
			$success = $this->delete_metadata( $object_id, $meta_key, $meta_value );
			if ( $success ) {
				WP_CLI::success( 'Deleted custom field.' );
			} else {
				WP_CLI::error( 'Failed to delete custom field.' );
			}
		}
	}
1003222
public function group(array $args) {
        $groupedArgs = [
            'arguments' => [],
            'options' => [],
        ];

        $option = 'arguments';

        foreach ($args as $arg) {
            if ($this->isOptionNameOrAlias($arg)) {
                $option = $arg;

                if ( ! array_has($groupedArgs, $option)) {
                    $groupedArgs[$option] = [];
                    $groupedArgs['options'][$option] = 1;
                } else {
                    $groupedArgs['options'][$option] += 1;
                }
            } else {
                $groupedArgs[$option][] = $arg;
            }
        }

        return $groupedArgs;
    }
1372662
public function adminMenuOrderSetting($args)
    {
        if (empty($args)) {
            return;
        }

        add_filter('custom_menu_order', '__return_true');
        add_filter('menu_order', function ($menu_ord) use ($args) {
            return !$menu_ord ? [] : $args;
        });
    }
1019159
final private function get_control_class_name( $args ) {

		// Set a default class name.
		$class_name = 'WP_Customize_Control';

		// Get the classname from the array of control classnames.
		if ( array_key_exists( $args['type'], self::$control_types ) ) {
			$class_name = self::$control_types[ $args['type'] ];
		}
		return $class_name;
	}
1156399
static function renderRadioButtons( $args ) {
		$defaults = [
			'id' => null,
			'name' => null,
			'option' => null,
			'value' => '',
			'choices' => [],
			'custom' => false,
			'disabled' => false,
		];

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

		$is_custom = false;
		if ( ! array_key_exists( $args['value'], $args['choices'] ) ) {
			$is_custom = true;
		}
		echo '<fieldset>';
		foreach ( $args['choices'] as $key => $label ) {
			printf(
				'<label for="%s"><input type="radio" id="%s" name="%s[%s]" value="%s" %s%s/>%s</label><br />',
				$args['id'] . '_' . sanitize_key( $key ),
				$args['id'] . '_' . sanitize_key( $key ),
				$args['name'],
				$args['option'],
				$key,
				( $args['custom'] && $is_custom && empty( $key ) ) ? 'checked' : checked( $key, $args['value'], false ),
				( ! empty( $args['disabled'] ) ) ? ' disabled' : '',
				$label
			);
		}
		echo '</fieldset>';
	}
1199219
public static function prepareCommand(array $args)
    {
        $return = '*' . \count($args) . "\r\n";
        foreach ($args as $arg) {
            $return .= '$' . \strlen($arg) . "\r\n" . $arg . "\r\n";
        }

        return $return;
    }
749009
public function add_control( $wp_customize ) {

		$control_class = $this->control_class;

		// If no class-name is defined, early exit.
		if ( ! $control_class ) {
			return;
		}

		/**
		 * Allow filtering the arguments.
		 *
		 * @since 0.1
		 * @param array                $this->args   The arguments.
		 * @param WP_Customize_Manager $wp_customize The customizer instance.
		 * @return array                             Return the arguments.
		 */
		$args = apply_filters( 'kirki_field_add_control_args', $this->args, $wp_customize );
		$wp_customize->add_control( new $control_class( $wp_customize, $args['settings'], $args ) );
	}
416196
public function normalize( array $args = [] )
	{
		$defaults = [
			'after'       => '',
			'attributes'  => '',
			'before'      => '',
			'class'       => '',
			'default'     => null,
			'depends'     => null,
			'desc'        => '',
			'errors'      => [],
			'inline'      => false,
			'label'       => '',
			'name'        => '',
			'options'     => [],
			'path'        => '',
			'placeholder' => '',
			'prefix'      => '',
			'render'      => true,
			'suffix'      => null,
			'type'        => 'text',
			'value'       => '',
		];

		$args = $atts = wp_parse_args( $args, $defaults );

		$args['attributes'] = $this->parseAttributes( $atts );
		$args['id']         = $this->parseId( $atts );
		$args['inline']     = $this->parseInline( $atts );
		$args['type']       = $this->parseType( $atts );
		$args['name']       = $this->parseName( $atts );
		$args['options']    = (array) $atts['options']; // make sure this is always an array
		$args['path']       = $atts['name'];
		$args['prefix']     = $this->parsePrefix( $atts );
		$args['value']      = $this->parseValue( $atts );

		$this->args = $args;
		$this->dependencies = $this->getField( $args )->dependencies;

		$this->setDataDepends();
		$this->checkForErrors( $atts );

		return $this;
	}
761788
public function customizeViewArguments($args, $view)
    {
        if ('view' == $view) {
            $session = $this->get('session');

            /** @var \MauticPlugin\MauticContactClientBundle\Entity\ContactClient $item */
            $item = $args['viewParameters']['item'];

            // Setup page forms in session
            if ('POST' == $this->request->getMethod() && $this->request->request->has('contactclient_chart')) {
                $chartFilterValues = $this->request->request->get('contactclient_chart');
            } else {
                $chartFilterValues = $session->get('mautic.contactclient.'.$item->getId().'.chartfilter')
                    ? $session->get('mautic.contactclient.'.$item->getId().'.chartfilter')
                    : [
                        'date_from' => $this->get('mautic.helper.core_parameters')->getParameter(
                            'default_daterange_filter',
                            'midnight -1 month'
                        ),
                        'date_to'   => 'midnight tomorrow -1 second',
                        'type'      => '',
                    ];
            }

            if ($this->request->query->has('campaign')) {
                $chartFilterValues['campaign'] = $this->request->query->get('campaign');
            }

            if (!isset($chartFilterValues['campaign']) || empty($chartFilterValues['campaign'])) {
                $chartFilterValues['campaign'] = null;
            }

            $session->set('mautic.contactclient.'.$item->getId().'.chartfilter', $chartFilterValues);

            //Setup for the chart and stats datatable
            /** @var \MauticPlugin\MauticContactClientBundle\Model\ContactClientModel $model */
            $model = $this->getModel('contactclient');

            $unit = $model->getTimeUnitFromDateRange(
                new \DateTime($chartFilterValues['date_from']),
                new \DateTime($chartFilterValues['date_to'])
            );

            $auditLog = $this->getAuditlogs($item);
            $files    = $this->getFiles($item);
            if (in_array($chartFilterValues['type'], [''])) {
                $stats = $model->getStats(
                    $item,
                    $unit,
                    new \DateTime($chartFilterValues['date_from']),
                    new \DateTime($chartFilterValues['date_to']),
                    $chartFilterValues['campaign']
                );
            } else {
                $stats = $model->getStatsBySource(
                    $item,
                    $unit,
                    $chartFilterValues['type'],
                    new \DateTime($chartFilterValues['date_from']),
                    new \DateTime($chartFilterValues['date_to']),
                    $chartFilterValues['campaign']
                );
            }

            $chartFilterForm = $this->get('form.factory')->create(
                'contactclient_chart',
                $chartFilterValues,
                [
                    'action' => $this->generateUrl(
                        'mautic_contactclient_action',
                        [
                            'objectAction' => 'view',
                            'objectId'     => $item->getId(),
                        ]
                    ),
                ]
            );

            $args['viewParameters']['auditlog']        = $auditLog;
            $args['viewParameters']['files']           = $files;
            $args['viewParameters']['stats']           = $stats;
            $args['viewParameters']['chartFilterForm'] = $chartFilterForm->createView();

            //unset($chartFilterValues['campaign']);
            $session->set('mautic.contactclient.'.$item->getId().'.chartfilter', $chartFilterValues);
        }

        return $args;
    }
1017936
protected function processArgs(array $args) {
		foreach ($args as &$arg) {
			if (is_array($arg)) {
				$arg = $this->processArgs($arg);
				continue;
			}
			
			if ($arg instanceof Argument\ArgumentInterface) {
				$arg = $arg->getValue();
			}
		}
		unset($arg);
		
		return $args;
	}
358974
protected function processArguments(array $args) {
		$definition = [];
		
		foreach ($args as $arg) {
			if ($arg->getName() !== 'argument') {
				throw new InvalidConfig('Unknown element "' . $arg->getName() . '" in arguments definition', null, null, $arg);
			}

			$definition[] = $this->processArgument($arg);
		}
		
		return $definition;
	}
265689
private function prepareOptions(array $args, $defaultMask) {

        $options = ArrayHelper::get($args, "opts", []);

        $options["autoUnmask"]         = ArrayHelper::get($options, "autoUnmask", true);
        $options["removeMaskOnSubmit"] = ArrayHelper::get($options, "removeMaskOnSubmit", true);
        if (null !== $defaultMask) {
            $options["placeholder"] = preg_replace("/[^\ ][.]*/", "_", $defaultMask);
        }

        return $options;
    }
298132
public function filter_function($args)
    {
        return function ($item) use ($args) {
            $columns = $args['columns'];
            $search = $args['search']['value'];
            if (!empty($search)) {
                if ($item instanceof Model) {
                    foreach ($columns as $key => $value) {
                        if ($value['searchable']) {
                            $columnValue = $this->getFiledValue($item, $key);
                            if (strpos($columnValue, $search) !== false) {
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
            return true;
        };
    }
518171
public function selectOptions(array $args = []): string
    {
        // Establish args.

        $default_args = [
            // Unique.
            'allow_empty'              => true,
            'allow_arbitrary'          => true,
            'option_child_indent_char' => '-',
            'option_formatter'         => null,
            'current_post_ids'         => null,

            // Used by {@link all()}.
            'max'         => 1000,
            'fail_on_max' => true,

            // Used by {@link total()}.
            // Used by {@link all()}.
            'for_comments_only' => false,

            'include_post_ids' => [],
            'exclude_post_ids' => [],

            'include_post_types' => !$this->Wp->is_admin
                ? get_post_types(['public' => true, 'exclude_from_search' => false])
                : get_post_types(['exclude_from_search' => false]),
            'exclude_post_types' => [],

            'include_post_statuses' => !$this->Wp->is_admin
                ? get_post_stati(['public' => true, 'exclude_from_search' => false])
                : get_post_stati(['exclude_from_search' => false]),
            'exclude_post_statuses' => [],

            'exclude_drafts'             => true,
            'exclude_revisions'          => true,
            'exclude_trash'              => true,
            'exclude_password_protected' => !$this->Wp->is_admin,
            'exclude_nav_menu_items'     => true,

            'no_cache' => false,
        ];
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);

        // Unique.
        $args['allow_empty']              = (bool) $args['allow_empty'];
        $args['allow_arbitrary']          = (bool) $args['allow_arbitrary'];
        $args['option_child_indent_char'] = (string) $args['option_child_indent_char'];
        $args['option_formatter']         = is_callable($args['option_formatter']) ? $args['option_formatter'] : null;
        $args['current_post_ids']         = isset($args['current_post_ids']) ? (array) $args['current_post_ids'] : null;
        $args['current_post_ids']         = $this->c::removeEmptys(array_map('intval', $args['current_post_ids']));

        // Used by {@link all()}.
        $args['max']         = max(1, (int) $args['max']);
        $args['fail_on_max'] = (bool) $args['fail_on_max'];

        // Used by {@link total()}.
        // Used by {@link all()}.
        $args['for_comments_only'] = (bool) $args['for_comments_only'];

        $args['include_post_ids'] = (array) $args['include_post_ids'];
        $args['exclude_post_ids'] = (array) $args['exclude_post_ids'];

        $args['include_post_types'] = (array) $args['include_post_types'];
        $args['exclude_post_types'] = (array) $args['exclude_post_types'];

        $args['include_post_statuses'] = (array) $args['include_post_statuses'];
        $args['exclude_post_statuses'] = (array) $args['exclude_post_statuses'];

        $args['exclude_drafts']             = (bool) $args['exclude_drafts'];
        $args['exclude_revisions']          = (bool) $args['exclude_revisions'];
        $args['exclude_trash']              = (bool) $args['exclude_trash'];
        $args['exclude_password_protected'] = (bool) $args['exclude_password_protected'];
        $args['exclude_nav_menu_items']     = (bool) $args['exclude_nav_menu_items'];

        $args['no_cache'] = (bool) $args['no_cache'];

        // Check for nothing being available (or too many).

        if (!($posts = $this->all($args))) {
            return ''; // None available.
        }
        // Initialize several working variables needed below.

        $options                 = ''; // Initialize.
        $available_post_ids      = []; // Initialize.
        $selected_post_ids       = []; // Initialize.
        $default_post_type_label = __('Post', 'wp-sharks-core');
        $default_post_title      = __('Untitled', 'wp-sharks-core');

        // Build & return all `<option>` tags.

        if ($args['allow_empty']) { // Allow `0`?
            $options = '<option value="0"></option>';
        }
        $walk = function (// Recursive parent/child walker.
            int $parent_post_id = 0,
            int $parent_depth = 0
        ) use (
            &$walk,
            &$args,
            &$posts,
            &$options,
            &$available_post_ids,
            &$selected_post_ids,
            &$default_post_type_label,
            &$default_post_title
        ) {
            foreach ($posts as $_post) { // \WP_Post objects.
                if ((int) $_post->post_parent !== $parent_post_id) {
                    continue; // Bypass this child for now.
                }
                $available_post_ids[] = (int) $_post->ID; // Record all available.

                if (isset($args['current_post_ids']) && in_array((int) $_post->ID, $args['current_post_ids'], true)) {
                    $selected_post_ids[$_post->ID] = (int) $_post->ID; // Flag selected post ID.
                }
                $_post_type_object = get_post_type_object($_post->post_type); // Anticipate a possible failure.
                $_post_type_label  = !empty($_post_type_object->labels->singular_name) ? $_post_type_object->labels->singular_name : $default_post_type_label;

                $_post_title            = $_post->post_title ?: $default_post_title;
                $_post_date             = $this->s::dateI18nUtc('M jS, Y', strtotime($_post->post_date_gmt));
                $_post_id_selected_attr = isset($selected_post_ids[$_post->ID]) ? ' selected' : '';

                // Format `<option>` tag w/ a custom formatter?

                if ($args['option_formatter']) {
                    $options .= $args['option_formatter']($_post, [
                            'parent_post_id'        => $parent_post_id,
                            'parent_depth'          => $parent_depth,
                            'post_type_object'      => $_post_type_object,
                            'post_type_label'       => $_post_type_label,
                            'post_title'            => $_post_title,
                            'post_date'             => $_post_date,
                            'post_id_selected_attr' => $_post_id_selected_attr,
                        ], $args); // ↑ This allows for a custom option formatter.
                        // The formatter must always return an `<option></option>` tag.

                // Else format the `<option>` tag using a default behavior.
                } elseif ($this->Wp->is_admin) { // Slightly different format in admin area.
                    $options .= '<option value="'.esc_attr($_post->ID).'"'.$_post_id_selected_attr.'>'.
                                    ($parent_depth > 0 ? str_repeat('&nbsp;', $parent_depth).$args['option_child_indent_char'].' ' : '').
                                    esc_html($_post_type_label.' #'.$_post->ID.': '.$_post_title).
                                '</option>';
                } else { // Front-end display should be friendlier in some ways.
                    $options .= '<option value="'.esc_attr($_post->ID).'"'.$_post_id_selected_attr.'>'.
                                    ($parent_depth > 0 ? str_repeat('&nbsp;', $parent_depth).$args['option_child_indent_char'].' ' : '').
                                    esc_html($_post_date.' — '.$_post_title).
                                '</option>';
                }
                $walk((int) $_post->ID, $parent_depth + 1); // Any children this term has.
                //
            } // unset($_post, $_post_type_object, $_post_type_label, $_post_title, $_post_date, $_post_id_selected_attr); // Housekeeping.
        };
        $walk(0, 0); // Start walking/building the parent » child `<option>` tags.

        if ($args['allow_arbitrary'] && $args['current_post_ids']) { // Allow arbitrary select `<option>`s?
            foreach (array_diff($args['current_post_ids'], $available_post_ids) as $_arbitrary_post_id) {
                $options .= '<option value="'.esc_attr($_arbitrary_post_id).'" selected>'.
                                esc_html($default_post_type_label.' #'.$_arbitrary_post_id).
                            '</option>';
            } // unset($_arbitrary_post_id); // Housekeeping.
        }
        return $options; // HTML markup.
    }