Custom_Image_Header::take_action()publicWP 2.6.0

Executes custom header modification.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Custom_Image_Header = new Custom_Image_Header();
$Custom_Image_Header->take_action();

Список изменений

С версии 2.6.0 Введена.

Код Custom_Image_Header::take_action() WP 6.5.2

public function take_action() {
	if ( ! current_user_can( 'edit_theme_options' ) ) {
		return;
	}

	if ( empty( $_POST ) ) {
		return;
	}

	$this->updated = true;

	if ( isset( $_POST['resetheader'] ) ) {
		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

		$this->reset_header_image();

		return;
	}

	if ( isset( $_POST['removeheader'] ) ) {
		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

		$this->remove_header_image();

		return;
	}

	if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) {
		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

		set_theme_mod( 'header_textcolor', 'blank' );
	} elseif ( isset( $_POST['text-color'] ) ) {
		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

		$_POST['text-color'] = str_replace( '#', '', $_POST['text-color'] );

		$color = preg_replace( '/[^0-9a-fA-F]/', '', $_POST['text-color'] );

		if ( strlen( $color ) === 6 || strlen( $color ) === 3 ) {
			set_theme_mod( 'header_textcolor', $color );
		} elseif ( ! $color ) {
			set_theme_mod( 'header_textcolor', 'blank' );
		}
	}

	if ( isset( $_POST['default-header'] ) ) {
		check_admin_referer( 'custom-header-options', '_wpnonce-custom-header-options' );

		$this->set_header_image( $_POST['default-header'] );

		return;
	}
}