| 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 WIDGET_HAS_CUSTOM_BREAKPOINTS = true; |
| 17 |
|
| 18 |
public function get_name(): string { |
| 19 |
return 'link-in-bio'; |
| 20 |
} |
| 21 |
|
| 22 |
public function get_widgets(): array { |
| 23 |
return [ |
| 24 |
'Link_In_Bio', |
| 25 |
]; |
| 26 |
} |
| 27 |
|
| 28 |
public function __construct() { |
| 29 |
parent::__construct(); |
| 30 |
|
| 31 |
add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Register styles. |
| 36 |
* |
| 37 |
* At build time, Elementor compiles `/modules/link-in-bio/assets/scss/widgets/*.scss` |
| 38 |
* to `/assets/css/widget-*.min.css`. |
| 39 |
* |
| 40 |
* @return void |
| 41 |
*/ |
| 42 |
public function register_styles() { |
| 43 |
$direction_suffix = is_rtl() ? '-rtl' : ''; |
| 44 |
$widget_styles = $this->get_widgets_style_list(); |
| 45 |
$has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints(); |
| 46 |
|
| 47 |
foreach ( $widget_styles as $widget_style_name => $widget_has_responsive_style ) { |
| 48 |
$should_load_responsive_css = $widget_has_responsive_style ? $has_custom_breakpoints : false; |
| 49 |
|
| 50 |
wp_register_style( |
| 51 |
$widget_style_name, |
| 52 |
$this->get_frontend_file_url( "{$widget_style_name}{$direction_suffix}.min.css", $should_load_responsive_css ), |
| 53 |
[ 'elementor-frontend' ], |
| 54 |
$should_load_responsive_css ? null : ELEMENTOR_VERSION |
| 55 |
); |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
private function get_widgets_style_list(): array { |
| 60 |
return [ |
| 61 |
'widget-link-in-bio' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS, // TODO: Remove in v3.27.0 [ED-15717] |
| 62 |
'widget-link-in-bio-base' => self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 63 |
'widget-link-in-bio-var-2' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 64 |
'widget-link-in-bio-var-3' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 65 |
'widget-link-in-bio-var-4' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 66 |
'widget-link-in-bio-var-5' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 67 |
'widget-link-in-bio-var-7' => ! self::WIDGET_HAS_CUSTOM_BREAKPOINTS, |
| 68 |
]; |
| 69 |
} |
| 70 |
} |
| 71 |
|