PHP 8.1.33
Preview: site-logo.php Size: 6.19 KB
/home/jambtst2015/public_html/aef.ng/wp-includes/blocks/site-logo.php

<?php
/**
 * Server-side rendering of the `core/site-logo` block.
 *
 * @package WordPress
 */

/**
 * Renders the `core/site-logo` block on the server.
 *
 * @since 5.8.0
 *
 * @param array $attributes The block attributes.
 *
 * @return string The render.
 */
function render_block_core_site_logo( $attributes ) {
	$adjust_width_height_filter = static function ( $image ) use ( $attributes ) {
		if ( empty( $attributes['width'] ) || empty( $image ) || ! $image[1] || ! $image[2] ) {
			return $image;
		}
		$height = (float) $attributes['width'] / ( (float) $image[1] / (float) $image[2] );
		return array( $image[0], (int) $attributes['width'], (int) $height );
	};

	add_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter );

	$custom_logo = get_custom_logo();

	remove_filter( 'wp_get_attachment_image_src', $adjust_width_height_filter );

	if ( empty( $custom_logo ) ) {
		return ''; // Return early if no custom logo is set, avoiding extraneous wrapper div.
	}

	if ( ! $attributes['isLink'] ) {
		// Remove the link.
		$custom_logo = preg_replace( '#<a.*?>(.*?)</a>#i', '\1', $custom_logo );
	}

	if ( $attributes['isLink'] && '_blank' === $attributes['linkTarget'] ) {
		// Add the link target after the rel="home".
		// Add an aria-label for informing that the page opens in a new tab.
		$processor = new WP_HTML_Tag_Processor( $custom_logo );
		$processor->next_tag( 'a' );
		if ( 'home' === $processor->get_attribute( 'rel' ) ) {
			$processor->set_attribute( 'aria-label', __( '(Home link, opens in a new tab)' ) );
			$processor->set_attribute( 'target', $attributes['linkTarget'] );
		}
		$custom_logo = $processor->get_updated_html();
	}

	$classnames = array();
	if ( empty( $attributes['width'] ) ) {
		$classnames[] = 'is-default-size';
	}

	$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => implode( ' ', $classnames ) ) );
	$html               = sprintf( '<div %s>%s</div>', $wrapper_attributes, $custom_logo );
	return $html;
}

/**
 * Register a core site setting for a site logo
 *
 * @since 5.8.0
 */
function register_block_core_site_logo_setting() {
	register_setting(
		'general',
		'site_logo',
		array(
			'show_in_rest' => array(
				'name' => 'site_logo',
			),
			'type'         => 'integer',
			'label'        => __( 'Logo' ),
			'description'  => __( 'Site logo.' ),
		)
	);
}

add_action( 'rest_api_init', 'register_block_core_site_logo_setting', 10 );

/**
 * Register a core site setting for a site icon
 *
 * @since 5.9.0
 */
function register_block_core_site_icon_setting() {
	register_setting(
		'general',
		'site_icon',
		array(
			'show_in_rest' => true,
			'type'         => 'integer',
			'label'        => __( 'Icon' ),
			'description'  => __( 'Site icon.' ),
		)
	);
}

add_action( 'rest_api_init', 'register_block_core_site_icon_setting', 10 );

/**
 * Registers the `core/site-logo` block on the server.
 *
 * @since 5.8.0
 */
function register_block_core_site_logo() {
	register_block_type_from_metadata(
		__DIR__ . '/site-logo',
		array(
			'render_callback' => 'render_block_core_site_logo',
		)
	);
}

add_action( 'init', 'register_block_core_site_logo' );

/**
 * Overrides the custom logo with a site logo, if the option is set.
 *
 * @since 5.8.0
 *
 * @param string $custom_logo The custom logo set by a theme.
 *
 * @return string The site logo if set.
 */
function _override_custom_logo_theme_mod( $custom_logo ) {
	$site_logo = get_option( 'site_logo' );
	return false === $site_logo ? $custom_logo : $site_logo;
}

add_filter( 'theme_mod_custom_logo', '_override_custom_logo_theme_mod' );

/**
 * Updates the site_logo option when the custom_logo theme-mod gets updated.
 *
 * @since 5.8.0
 *
 * @param  mixed $value Attachment ID of the custom logo or an empty value.
 * @return mixed
 */
function _sync_custom_logo_to_site_logo( $value ) {
	if ( empty( $value ) ) {
		delete_option( 'site_logo' );
	} else {
		update_option( 'site_logo', $value );
	}

	return $value;
}

add_filter( 'pre_set_theme_mod_custom_logo', '_sync_custom_logo_to_site_logo' );

/**
 * Deletes the site_logo when the custom_logo theme mod is removed.
 *
 * @since 5.8.0
 *
 * @global array $_ignore_site_logo_changes
 *
 * @param array $old_value Previous theme mod settings.
 * @param array $value     Updated theme mod settings.
 */
function _delete_site_logo_on_remove_custom_logo( $old_value, $value ) {
	global $_ignore_site_logo_changes;

	if ( $_ignore_site_logo_changes ) {
		return;
	}

	// If the custom_logo is being unset, it's being removed from theme mods.
	if ( isset( $old_value['custom_logo'] ) && ! isset( $value['custom_logo'] ) ) {
		delete_option( 'site_logo' );
	}
}

/**
 * Deletes the site logo when all theme mods are being removed.
 *
 * @since 5.8.0
 *
 * @global array $_ignore_site_logo_changes
 */
function _delete_site_logo_on_remove_theme_mods() {
	global $_ignore_site_logo_changes;

	if ( $_ignore_site_logo_changes ) {
		return;
	}

	if ( false !== get_theme_support( 'custom-logo' ) ) {
		delete_option( 'site_logo' );
	}
}

/**
 * Hooks `_delete_site_logo_on_remove_custom_logo` in `update_option_theme_mods_$theme`.
 * Hooks `_delete_site_logo_on_remove_theme_mods` in `delete_option_theme_mods_$theme`.
 *
 * Runs on `setup_theme` to account for dynamically-switched themes in the Customizer.
 *
 * @since 5.8.0
 */
function _delete_site_logo_on_remove_custom_logo_on_setup_theme() {
	$theme = get_option( 'stylesheet' );
	add_action( "update_option_theme_mods_$theme", '_delete_site_logo_on_remove_custom_logo', 10, 2 );
	add_action( "delete_option_theme_mods_$theme", '_delete_site_logo_on_remove_theme_mods' );
}
add_action( 'setup_theme', '_delete_site_logo_on_remove_custom_logo_on_setup_theme', 11 );

/**
 * Removes the custom_logo theme-mod when the site_logo option gets deleted.
 *
 * @since 5.9.0
 *
 * @global array $_ignore_site_logo_changes
 */
function _delete_custom_logo_on_remove_site_logo() {
	global $_ignore_site_logo_changes;

	// Prevent _delete_site_logo_on_remove_custom_logo and
	// _delete_site_logo_on_remove_theme_mods from firing and causing an
	// infinite loop.
	$_ignore_site_logo_changes = true;

	// Remove the custom logo.
	remove_theme_mod( 'custom_logo' );

	$_ignore_site_logo_changes = false;
}
add_action( 'delete_option_site_logo', '_delete_custom_logo_on_remove_site_logo' );

Directory Contents

Dirs: 93 × Files: 72

Name Size Perms Modified Actions
archives DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
audio DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
avatar DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
block DIR
- drwxr-xr-x 2024-07-23 22:10:57
Edit Download
button DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
buttons DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
calendar DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
code DIR
- drwxr-xr-x 2022-11-02 11:25:20
Edit Download
column DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
columns DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
comments DIR
- drwxr-xr-x 2022-11-02 11:25:21
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
cover DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
details DIR
- drwxr-xr-x 2023-08-08 22:41:20
Edit Download
embed DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
file DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
footnotes DIR
- drwxr-xr-x 2023-08-08 22:41:20
Edit Download
freeform DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
gallery DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
group DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
heading DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
home-link DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
html DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
image DIR
- drwxr-xr-x 2023-11-07 22:25:16
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
list DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
list-item DIR
- drwxr-xr-x 2022-11-02 11:25:21
Edit Download
loginout DIR
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
missing DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
more DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2023-11-07 22:25:18
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
nextpage DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
page-list DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2023-03-30 00:07:26
Edit Download
paragraph DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
pattern DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
post-date DIR
- drwxr-xr-x 2022-11-02 11:25:21
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2023-03-30 00:07:26
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
pullquote DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
query DIR
- drwxr-xr-x 2024-04-02 22:06:51
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-11-02 11:25:20
Edit Download
quote DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
read-more DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
rss DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
search DIR
- drwxr-xr-x 2023-08-08 22:41:20
Edit Download
separator DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
shortcode DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
site-logo DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2023-03-30 00:07:26
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
spacer DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
table DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
tag-cloud DIR
- drwxr-xr-x 2024-11-13 20:41:34
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2023-08-08 22:41:20
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
verse DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
video DIR
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
- drwxr-xr-x 2022-06-03 10:06:43
Edit Download
2.92 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
5.61 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
3.13 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
182.84 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.76 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
5.93 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.92 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
2.08 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.40 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.82 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.67 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.03 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
4.39 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.88 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.59 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.75 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.17 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.71 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
6.61 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.04 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.75 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
3.68 KB lrw-r--r-- 2024-04-02 22:06:50
Edit Download
6.29 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.27 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
5.60 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
11.82 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
4.99 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
4.92 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
8.34 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
3.90 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.24 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.38 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
4.28 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
13.21 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
9.09 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
57.90 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
361 B lrw-r--r-- 2024-07-16 22:10:09
Edit Download
13.29 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
2.14 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.49 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.78 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.54 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.74 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.11 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.05 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
3.37 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
9.14 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
4.72 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
5.61 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.60 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.09 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.80 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.70 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
4.66 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.10 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.15 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.05 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
5.56 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.79 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
4.01 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
501 B lrw-r--r-- 2024-07-16 22:10:09
Edit Download
3.88 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
22.51 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
735 B lrw-r--r-- 2024-07-16 22:10:09
Edit Download
6.19 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
1.17 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.77 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
62.67 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.55 KB lrw-r--r-- 2024-11-13 20:41:34
Edit Download
9.86 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
1.30 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download
2.38 KB lrw-r--r-- 2024-07-16 22:10:09
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).