# templately/trunk/modules/full-site-import/Runners/CustomCSS.php

Templately – Elementor &amp; Gutenberg Template Library: 6500+ Free &amp; Pro Ready Templates And Cloud!, version trunk. 64 lines.

- Page: https://pluginprobe.com/plugins/templately/trunk/code/modules/full-site-import/Runners/CustomCSS.php
- Raw: https://pluginprobe.com/plugins/templately/trunk/raw/modules/full-site-import/Runners/CustomCSS.php
- Modified: 2026-09-24T05:45:44+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/templately/trunk/code/modules/full-site-import/Runners/CustomCSS.php#L10-L20`.

```php
<?php

namespace Templately\Modules\FullSiteImport\Runners;

use Templately\Modules\FullSiteImport\Runners\BaseRunner;
use Templately\Modules\FullSiteImport\Utils\Utils;

/**
 * Imports the pack's site-wide custom CSS (`custom.css` at the pack root) into
 * the `templately_custom_css` option, which Settings::add_custom_css() prints
 * inside a <style> tag on wp_head.
 *
 * The value is written through Utils::update_option(), so the previous value is
 * backed up to `__templately_templately_custom_css` and import_revert() restores
 * it — the same backup/revert path every other imported option uses.
 */
class CustomCSS extends BaseRunner {

	const OPTION_KEY = 'templately_custom_css';
	const FILE_NAME  = 'custom.css';

	public function get_name(): string {
		return 'custom-css';
	}

	public function get_label(): string {
		return __( 'Custom CSS', 'templately' );
	}

	public function should_log(): bool {
		return true;
	}

	public function get_action(): string {
		return 'eventLog';
	}

	public function log_message(): string {
		return __( 'Importing custom CSS.', 'templately' );
	}

	public function should_run( $data, $imported_data = [] ): bool {
		$file = $this->dir_path . self::FILE_NAME;
		return is_readable( $file ) && filesize( $file ) > 0;
	}

	public function import( $data, $imported_data ): array {
		$this->log( 0 );

		$file = $this->dir_path . self::FILE_NAME;
		$css  = file_get_contents( $file );

		if ( false === $css || '' === trim( $css ) ) {
			return [];
		}

		// Backup the current value then write the pack CSS. The backup lands in
		// `__templately_templately_custom_css`; import_revert() restores it.
		Utils::update_option( self::OPTION_KEY, $css );

		return [ 'custom_css' => true ];
	}
}

```
