WPCF7_ContactForm::get_template()public staticCF7 1.0

Returns a contact form data filled by default template contents.

Метод класса: WPCF7_ContactForm{}

Хуки из метода

Возвращает

WPCF7_ContactForm. A new contact form object.

Использование

$result = WPCF7_ContactForm::get_template( $args );
$args(строка|массив)
Contact form options.
По умолчанию: ''

Код WPCF7_ContactForm::get_template() CF7 5.9.3

public static function get_template( $args = '' ) {
	$args = wp_parse_args( $args, array(
		'locale' => null,
		'title' => __( 'Untitled', 'contact-form-7' ),
	) );

	if ( ! isset( $args['locale'] ) ) {
		$args['locale'] = determine_locale();
	}

	$callback = static function ( $args ) {
		$contact_form = new self;
		$contact_form->title = $args['title'];
		$contact_form->locale = $args['locale'];

		$properties = $contact_form->get_properties();

		foreach ( $properties as $key => $value ) {
			$default_template = WPCF7_ContactFormTemplate::get_default( $key );

			if ( isset( $default_template ) ) {
				$properties[$key] = $default_template;
			}
		}

		$contact_form->properties = $properties;

		return $contact_form;
	};

	$contact_form = wpcf7_switch_locale(
		$args['locale'],
		$callback,
		$args
	);

	self::$current = apply_filters( 'wpcf7_contact_form_default_pack',
		$contact_form, $args
	);

	return self::$current;
}