Server IP : 172.67.216.182 / Your IP : 162.158.106.163 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /www/wwwroot/greenomexim.com/wp-includes/block-supports/ |
Upload File : |
<?php /** * Elements styles block support. * * @package WordPress * @since 5.8.0 */ /** * Gets the elements class names. * * @since 6.0.0 * @access private * * @param array $block Block object. * @return string The unique class name. */ function wp_get_elements_class_name( $block ) { return 'wp-elements-' . md5( serialize( $block ) ); } /** * Updates the block content with elements class names. * * @since 5.8.0 * @access private * * @param string $block_content Rendered block content. * @param array $block Block object. * @return string Filtered block content. */ function wp_render_elements_support( $block_content, $block ) { if ( ! $block_content ) { return $block_content; } $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); if ( $skip_link_color_serialization ) { return $block_content; } $link_color = null; if ( ! empty( $block['attrs'] ) ) { $link_color = _wp_array_get( $block['attrs'], array( 'style', 'elements', 'link', 'color', 'text' ), null ); } /* * For now we only care about link color. * This code in the future when we have a public API * should take advantage of WP_Theme_JSON::compute_style_properties * and work for any element and style. */ if ( null === $link_color ) { return $block_content; } // Like the layout hook this assumes the hook only applies to blocks with a single wrapper. // Add the class name to the first element, presuming it's the wrapper, if it exists. $tags = new WP_HTML_Tag_Processor( $block_content ); if ( $tags->next_tag() ) { $tags->add_class( wp_get_elements_class_name( $block ) ); } return $tags->get_updated_html(); } /** * Renders the elements stylesheet. * * In the case of nested blocks we want the parent element styles to be rendered before their descendants. * This solves the issue of an element (e.g.: link color) being styled in both the parent and a descendant: * we want the descendant style to take priority, and this is done by loading it after, in DOM order. * * @since 6.0.0 * @since 6.1.0 Implemented the style engine to generate CSS and classnames. * @access private * * @param string|null $pre_render The pre-rendered content. Default null. * @param array $block The block being rendered. * @return null */ function wp_render_elements_support_styles( $pre_render, $block ) { $block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block['blockName'] ); $element_block_styles = isset( $block['attrs']['style']['elements'] ) ? $block['attrs']['style']['elements'] : null; /* * For now we only care about link color. */ $skip_link_color_serialization = wp_should_skip_block_supports_serialization( $block_type, 'color', 'link' ); if ( $skip_link_color_serialization ) { return null; } $class_name = wp_get_elements_class_name( $block ); $link_block_styles = isset( $element_block_styles['link'] ) ? $element_block_styles['link'] : null; wp_style_engine_get_styles( $link_block_styles, array( 'selector' => ".$class_name a", 'context' => 'block-supports', ) ); return null; } add_filter( 'render_block', 'wp_render_elements_support', 10, 2 ); add_filter( 'pre_render_block', 'wp_render_elements_support_styles', 10, 2 );