GC_Customize_Custom_CSS_Setting::update()

最后更新于:2021-11-27 00:08:59

GC_Customize_Custom_CSS_Setting::update( string$css)

Store the CSS setting value in the custom_css custom post type for the stylesheet.

参数

$css

(string) (Required) The input value.

响应

(int|false) The post ID or false if the value could not be saved.

源文件

文件: gc-includes/customize/class-gc-customize-custom-css-setting.php

	public function update( $css ) {
		if ( empty( $css ) ) {
			$css = '';
		}

		$r = gc_update_custom_css_post(
			$css,
			array(
				'stylesheet' => $this->stylesheet,
			)
		);

		if ( $r instanceof GC_Error ) {
			return false;
		}
		$post_id = $r->ID;

		// Cache post ID in theme mod for performance to avoid additional DB query.
		if ( $this->manager->get_stylesheet() === $this->stylesheet ) {
			set_theme_mod( 'custom_css_post_id', $post_id );
		}

		return $post_id;
	}