![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/www/wp-content/plugins/the7-block-editor/Modules/GridResponsive/ |
<?php namespace DtCr\Modules\GridResponsive; use DtCr\Base\ModuleBase; use DtCr\Base\ManagableModuleInterface; use DtCr\Core\BlockUtils; use DtCr\Core\CssMediaBreakpoints; defined( 'ABSPATH' ) || exit; class Module extends ModuleBase implements ManagableModuleInterface { const MODULE_IDENTIFIER = 'grid-responsive'; const ASSETS_BUILD_PATH = 'editor/blocks/grid/stack-on-responsive/'; const ATTRIBUTES = 'dtCrStackOn'; const ATTRIBUTE_BREAKPOINT = 'breakpoint'; const ATTRIBUTE_BREAKPOINT_CUSTOM_VALUE = 'breakpointCustomValue'; const BlOCK_NAME = 'core/group'; const SETTINGS_ORDER = 250; public function setup_hooks() { add_filter( 'render_block', array( $this, 'render' ), 20, 3 ); } function render( $block_content, $block ) { if ( ( $block['blockName'] ?? null ) !== self::BlOCK_NAME ) { return $block_content; } $attributes = $block['attrs'] ?? array(); if ( ( $attributes['layout']['type'] ?? null ) !== 'grid' || ! isset( $attributes[ self::ATTRIBUTES ] ) ) { return $block_content; } $switch_width = CssMediaBreakpoints::getSwitchWidth( $attributes[ self::ATTRIBUTES ][ self::ATTRIBUTE_BREAKPOINT ] ?? null, $attributes[ self::ATTRIBUTES ][ self::ATTRIBUTE_BREAKPOINT_CUSTOM_VALUE ] ?? null ); if ( null === $switch_width ) { return $block_content; } $class_id = BlockUtils::get_unique_class_id( $block_content ); $block_content = BlockUtils::append_classes( $block_content, array( $class_id ) ); BlockUtils::add_styles_from_css_rules( array( array( 'selector' => "@media screen and (width <= {$switch_width})", 'declarations' => array( array( 'selector' => 'body .' . $class_id, 'declarations' => array( 'grid-template-columns' => 'repeat(1, 1fr)' ), ), ), ), ) ); return $block_content; } public static function get_title() { return __( 'Responsive Grid', 'dt-cr' ); } public static function get_label() { return __( 'Add responsiveness settings to Grid block.', 'dt-cr' ); } }