module.php
84 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Elementor\Modules\LinkInBio; |
| 4 | |
| 5 | use Elementor\Core\Base\Module as BaseModule; |
| 6 | use Elementor\Core\Experiments\Manager; |
| 7 | use Elementor\Plugin; |
| 8 | use Elementor\Utils; |
| 9 | |
| 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | exit; // Exit if accessed directly |
| 12 | } |
| 13 | |
| 14 | class Module extends BaseModule { |
| 15 | |
| 16 | const EXPERIMENT_NAME = 'link-in-bio'; |
| 17 | const WIDGET_HAS_CUSTOM_BREAKPOINTS = true; |
| 18 | |
| 19 | public function get_name(): string { |
| 20 | return static::EXPERIMENT_NAME; |
| 21 | } |
| 22 | |
| 23 | public function get_widgets(): array { |
| 24 | return [ |
| 25 | 'Link_In_Bio', |
| 26 | ]; |
| 27 | } |
| 28 | |
| 29 | // TODO: This is a hidden experiment which needs to remain enabled like this until 3.26 for pro compatibility. |
| 30 | public static function get_experimental_data() { |
| 31 | return [ |
| 32 | 'name' => self::EXPERIMENT_NAME, |
| 33 | 'title' => esc_html__( 'Link In Bio', 'elementor' ), |
| 34 | 'hidden' => true, |
| 35 | 'default' => Manager::STATE_ACTIVE, |
| 36 | 'release_status' => Manager::RELEASE_STATUS_STABLE, |
| 37 | 'mutable' => false, |
| 38 | ]; |
| 39 | } |
| 40 | |
| 41 | public function __construct() { |
| 42 | parent::__construct(); |
| 43 | |
| 44 | add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Register styles. |
| 49 | * |
| 50 | * At build time, Elementor compiles `/modules/link-in-bio/assets/scss/widgets/*.scss` |
| 51 | * to `/assets/css/widget-*.min.css`. |
| 52 | * |
| 53 | * @return void |
| 54 | */ |
| 55 | public function register_styles() { |
| 56 | $direction_suffix = is_rtl() ? '-rtl' : ''; |
| 57 | $widget_styles = $this->get_widgets_style_list(); |
| 58 | $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints(); |
| 59 | |
| 60 | foreach ( $widget_styles as $widget_style_name => $widget_has_responsive_style ) { |
| 61 | $should_load_responsive_css = $widget_has_responsive_style ? $has_custom_breakpoints : false; |
| 62 | |
| 63 | wp_register_style( |
| 64 | $widget_style_name, |
| 65 | $this->get_frontend_file_url( "{$widget_style_name}{$direction_suffix}.min.css", $should_load_responsive_css ), |
| 66 | [ 'elementor-frontend' ], |
| 67 | $should_load_responsive_css ? null : ELEMENTOR_VERSION |
| 68 | ); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | private function get_widgets_style_list():array { |
| 73 | return [ |
| 74 | 'widget-link-in-bio' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS, // TODO: Remove in v3.27.0 [ED-15717] |
| 75 | 'widget-link-in-bio-base' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 76 | 'widget-link-in-bio-var-2' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 77 | 'widget-link-in-bio-var-3' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 78 | 'widget-link-in-bio-var-4' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 79 | 'widget-link-in-bio-var-5' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 80 | 'widget-link-in-bio-var-7' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 81 | ]; |
| 82 | } |
| 83 | } |
| 84 |