Register a field group.

@param array $args Field group arguments.
@return void
351575
public function register_field_group( array $args ) {

		if ( ! did_action( 'hogan/modules_included' ) ) {
			_doing_it_wrong( __METHOD__, esc_html__( 'Hogan modules haven\'t been registered yet. Please do field group registration on action hogan/include_field_groups.', 'hogan-core' ), '1.0.0' );
		}

		if ( did_action( 'hogan/field_groups_included' ) ) {
			_doing_it_wrong( __METHOD__, esc_html__( 'Hogan field groups have already been registered. Please register/deregister field groups on action hogan/include_field_groups.', 'hogan-core' ), '1.0.0' );
		}

		$args = wp_parse_args( $args, [
			'name'                           => '',
			'title'                          => __( 'Content Modules', 'hogan-core' ),
			'modules'                        => [], // All modules.
			'location'                       => [],
			'hide_on_screen'                 => [],
			'fields_before_flexible_content' => [],
			'fields_after_flexible_content'  => [],
		] );

		// Sanitized field group name will be used for all filters, and prefix for field group and field names.
		$args['name'] = sanitize_key( $args['name'] );

		if ( empty( $args['name'] ) ) {
			// Everyone should have a name.
			return;
		}

		// Filter for disabling entire field group.
		if ( true !== apply_filters( 'hogan/field_group/' . $args['name'] . '/enabled', true ) ) {
			return; // Don't you want to play with me, Billy?
		}

		// Deprecated filters as of 1.3.0. To be removed as some point in the future.
		$args['fields_before_flexible_content'] = apply_filters_deprecated( 'hogan/field_group/' . $args['name'] . '/fields_before_flexible_content', [ $args['fields_before_flexible_content'] ], '1.3.0', 'hogan/field_group/' . $args['name'] . '/args' );
		$args['fields_after_flexible_content']  = apply_filters_deprecated( 'hogan/field_group/' . $args['name'] . '/fields_after_flexible_content', [ $args['fields_after_flexible_content'] ], '1.3.0', 'hogan/field_group/' . $args['name'] . '/args' );
		$args['location']                       = apply_filters_deprecated( 'hogan/field_group/' . $args['name'] . '/location', [ $args['location'] ], '1.3.0', 'hogan/field_group/' . $args['name'] . '/args' );
		$args['hide_on_screen']                 = apply_filters_deprecated( 'hogan/field_group/' . $args['name'] . '/hide_on_screen', [ $args['hide_on_screen'] ], '1.3.0', 'hogan/field_group/' . $args['name'] . '/args' );

		// Allow all args to be filtered before creating acf field group.
		$args = apply_filters( 'hogan/field_group/' . $args['name'] . '/args', $args );

		// Create a list of flexible content layouts based on selected modules.
		$field_group_layouts = [];

		foreach ( $this->_modules as $module ) {

			if ( is_array( $args['modules'] ) && ! empty( $args['modules'] ) ) {
				// Include a subset of modules.
				if ( in_array( $module->name, $args['modules'], true ) ) {
					$field_group_layouts[] = $module->get_layout_definition();
				}
			} else {
				// Include all modules modules.
				$field_group_layouts[] = $module->get_layout_definition();
			}
		}

		if ( empty( $field_group_layouts ) ) {
			return; // Why keep on living, what's the use?
		}

		// Set field group key based on name, i.e. hogan_default.
		$args['key'] = 'hogan_' . $args['name'];

		// Set field group fields from modules.
		$args['fields'] = array_merge( $args['fields_before_flexible_content'], [
			[
				'type'         => 'flexible_content',
				'key'          => 'hogan_' . $args['name'] . '_modules_key',
				'name'         => 'hogan_' . $args['name'] . '_modules_name',
				'button_label' => __( 'Add module', 'hogan-core' ),
				'layouts'      => $field_group_layouts,
			],
		], $args['fields_after_flexible_content'] );

		// Add to core field groups.
		$this->_field_groups[] = $args['name'];

		// Create ACF field group.
		acf_add_local_field_group( $args );
	}
458390
protected function loadFieldGroups()
    {
        if (function_exists('register_field_group') && ($config = $this->loadConfigFile('field_groups.php'))) {
            foreach ($config as $fieldGroupConfig) {
                register_field_group($fieldGroupConfig);
            }
        }

        return $this;
    }
64937
public function messagePrintf(array $args = array())
    {
        $this->raw_msg = vsprintf($this->raw_msg, $args);
        $this->message = vsprintf($this->message, $args);
    }
206312
public function registerAliases(array $aliasGroup)
    {
        foreach ($aliasGroup as $key => $aliases) {
            foreach ($aliases as $alias) {
                $this->app->alias($key, $alias);
            }
        }
    }
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;
    }
75202
protected function handleArgs(array $args) {
        $groupedArgs = $this->argumentsParser->group($args);
        list($groupedArgs, $continue) = $this->runGlobalCommands($groupedArgs);

        if ($continue === false) {
            return;
        }

        try {
            list($command, $groupedArgs) = $this->argumentsMatcher
                ->matchCommands($this->getNotGlobalCommands(), $groupedArgs);
            $command = clone $command;
            $this->runCommand($command);
        } catch (MissingCommandNameException $ex) {
            array_unshift($args, $this->getDefaultCommandName());
            $this->parseArgs($args);
        } catch (Exception $ex) {
            if ($this->getCatchErrors()) {
                $widget = new ExceptionWidget($this->input, $this->output);
                $widget->render($ex);
            } else {
                throw $ex;
            }
        }
    }
778592
private function instantiateGroup($group)
    {
        if ( !isset($group['instantiate']))
        {
            return;
        }

        foreach ($group['instantiate'] as $nickname => $className)
        {
            $this->objectRegistry->register($nickname, new $className());
        }
    }
63049
public function beforeInsert(array &$args) {
        $data = &$args[1];
        foreach ($this->_fields as $field) {
            if (array_key_exists($field, $data)) {
                $data[$field] = $this->filter($data[$field], $this->getConfig());
            }
        }
    }
964308
public function handleCategoryId($args)
    {
        $productId = $args['row']['product_id'];
        $categoryId = $args['row']['category_id'];

        if (!array_key_exists($productId, $this->categoryIds)) {
            $this->categoryIds[$productId] = [];
        }
        $this->categoryIds[$productId][] = $this->handleCategory($categoryId);
    }
209809
public function registerGroup()
    {
        $app = $this->app;

        $app->bind('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface', function($app)
        {
            return new GroupRepository($app['sentry'], $app['events']);
        });

        $app->bind('Stevemo\Cpanel\Group\Form\GroupFormInterface', function($app)
        {
            return new GroupForm(
                new GroupValidator($app['validator'], new MessageBag),
                $app->make('Stevemo\Cpanel\Group\Repo\CpanelGroupInterface')
            );
        });
    }
968045
public function init($args)
    {
        if (empty($args) || OL_ZEUS_ISADMIN) {
            return;
        }

        // Special case
        if (is_bool($args) && $args) {
            $args = $this->available;
        }

        // Iterate on all
        foreach ($args as $key) {
            $key = strtolower($key);

            if (!in_array($key, $this->available)) {
                continue;
            }

            if (in_array($key, ['index_rel_link', 'parent_post_rel_link', 'rest_output_link_wp_head', 'rsd_link', 'start_post_rel_link', 'wp_dlmp_l10n_style', 'wp_resource_hints', 'wlwmanifest_link'])) {
                $this->headerWpHead($key);
                continue;
            }

            $key = str_replace('_', '-', $key);

            $function = Helpers::toFunctionFormat($key);
            $function = 'header'.ucfirst($function);
            $this->$function();
        }
    }
755990
protected function init_args($args)
    {
        parent::init_args($args);

        $this->env = $this->get_env_for_write_or_fail();
        $api = new Salts();

        try {
            $this->salts = $api->collect();
        } catch (Exception $e) {
            WP_CLI::error($e->getMessage());
        }
    }
1016718
public function setArgs(array $args)
    {
        foreach ($args as $k => $v) {
            if (is_numeric($k)) {
                $this->args[$k] = $v;
            } else {
                $this->kwargs[$k] = $v;
            }
            ksort($this->args);
        }
        return $this;
    }
183885
protected function log(Args $args)
    {
        $message = sprintf("%s%s", $this->render($args), PHP_EOL);
        $this->logger->log($message, null, $this->registry->get());
    }
809824
public function setGroups(array $groups) {
		foreach ($groups as $title => $path) {
			$this->setGroup($title, $path);
		}
	}
815042
protected function setArgument($arg)
    {
        if ($this->checkDiscription($arg)) {
            $this->advanceArg($arg);
        } else {
            $this->simpleArg($arg);
        }
    }
878476
protected function log(Args $args)
    {
        $message = sprintf("%s%s", $this->render($args), PHP_EOL);
        file_put_contents($this->getStream(), $message);
    }