Custom_Image_Header::take_action()
最后更新于:2021-11-25 19:50:16
Custom_Image_Header::take_action()Execute custom header modification.
源文件
文件: gc-admin/includes/class-custom-image-header.php
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', '_gcnonce-custom-header-options' );
$this->reset_header_image();
return;
}
if ( isset( $_POST['removeheader'] ) ) {
check_admin_referer( 'custom-header-options', '_gcnonce-custom-header-options' );
$this->remove_header_image();
return;
}
if ( isset( $_POST['text-color'] ) && ! isset( $_POST['display-header-text'] ) ) {
check_admin_referer( 'custom-header-options', '_gcnonce-custom-header-options' );
set_theme_mod( 'header_textcolor', 'blank' );
} elseif ( isset( $_POST['text-color'] ) ) {
check_admin_referer( 'custom-header-options', '_gcnonce-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', '_gcnonce-custom-header-options' );
$this->set_header_image( $_POST['default-header'] );
return;
}
}