diff --git a/.vscode/settings.json b/.vscode/settings.json index e6f9dfe..5e30ed3 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,5 +13,6 @@ "liveSassCompile.settings.watchOnLaunch": true, "liveSassCompile.settings.includeItems": [ "wp-content/themes/hello-elementor/assets/css/custom.scss", + "wp-content/plugins/elementor-addon/assets/css/main.scss" ] } diff --git a/wp-content/plugins/elementor-addon/assets/css/main.css b/wp-content/plugins/elementor-addon/assets/css/main.css new file mode 100644 index 0000000..2aa346a --- /dev/null +++ b/wp-content/plugins/elementor-addon/assets/css/main.css @@ -0,0 +1 @@ +.elementor-vertical-separator{display:flex;align-items:center;height:100%}.elementor-vertical-separator__line{width:1px;height:100px;background:#000}/*# sourceMappingURL=main.css.map */ \ No newline at end of file diff --git a/wp-content/plugins/elementor-addon/assets/css/main.css.map b/wp-content/plugins/elementor-addon/assets/css/main.css.map new file mode 100644 index 0000000..1d87010 --- /dev/null +++ b/wp-content/plugins/elementor-addon/assets/css/main.css.map @@ -0,0 +1 @@ +{"version":3,"sources":["main.scss"],"names":[],"mappings":"AAAA,8BACC,YAAA,CACA,kBAAA,CACA,WAAA,CAGD,oCACC,SAAA,CACA,YAAA,CACA,eAAA","file":"main.css"} \ No newline at end of file diff --git a/wp-content/plugins/elementor-addon/assets/css/main.scss b/wp-content/plugins/elementor-addon/assets/css/main.scss new file mode 100644 index 0000000..b9ee65d --- /dev/null +++ b/wp-content/plugins/elementor-addon/assets/css/main.scss @@ -0,0 +1,11 @@ +.elementor-vertical-separator { + display: flex; + align-items: center; + height: 100%; +} + +.elementor-vertical-separator__line { + width: 1px; + height: 100px; + background: #000; +} diff --git a/wp-content/plugins/elementor-addon/assets/js/main.js b/wp-content/plugins/elementor-addon/assets/js/main.js new file mode 100644 index 0000000..e69de29 diff --git a/wp-content/plugins/elementor-addon/elementor-addon.php b/wp-content/plugins/elementor-addon/elementor-addon.php new file mode 100644 index 0000000..41442e4 --- /dev/null +++ b/wp-content/plugins/elementor-addon/elementor-addon.php @@ -0,0 +1,60 @@ +register( new \Elementor_Vertical_Separator() ); +} +add_action( 'elementor/widgets/register', 'register_hello_world_widget' ); + +/** + * Register scripts/styles only. + * Do not enqueue them globally. + */ +function elementor_addon_register_assets() { + $css_path = plugin_dir_path( __FILE__ ) . 'assets/css/main.css'; + $css_url = plugin_dir_url( __FILE__ ) . 'assets/css/main.css'; + $css_ver = file_exists( $css_path ) ? filemtime( $css_path ) : '1.0.0'; + + $js_path = plugin_dir_path( __FILE__ ) . 'assets/js/main.js'; + $js_url = plugin_dir_url( __FILE__ ) . 'assets/js/main.js'; + $js_ver = file_exists( $js_path ) ? filemtime( $js_path ) : '1.0.0'; + + // Widget CSS + wp_register_style( + 'elementor-addon-main-css', + $css_url, + [], + $css_ver + ); + + // Widget JS + wp_register_script( + 'elementor-addon-main-js', + $js_url, + [ 'jquery' ], + $js_ver, + true + ); +} +add_action( 'elementor/frontend/after_register_styles', 'elementor_addon_register_assets' ); +add_action( 'elementor/frontend/after_register_scripts', 'elementor_addon_register_assets' ); diff --git a/wp-content/plugins/elementor-addon/widgets/vertical-separator.php b/wp-content/plugins/elementor-addon/widgets/vertical-separator.php new file mode 100644 index 0000000..7868a19 --- /dev/null +++ b/wp-content/plugins/elementor-addon/widgets/vertical-separator.php @@ -0,0 +1,143 @@ +start_controls_section( + 'section_setting', + [ + 'label' => esc_html__( 'Settings', 'elementor' ), + 'tab' => Controls_Manager::TAB_CONTENT, + ] + ); + + $this->add_control( + 'line_color', + [ + 'label' => esc_html__( 'Color', 'elementor-addon' ), + 'type' => Controls_Manager::COLOR, + 'default' => '#000000', + 'selectors' => [ + '{{WRAPPER}} .elementor-vertical-separator__line' => 'background: {{VALUE}};' + ], + ] + ); + + $this->add_responsive_control( + 'line_thickness', + [ + 'label' => esc_html__( 'Thickness', 'elementor-addon' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px' ], + 'range' => [ + 'px' => [ + 'min' => 1, + 'max' => 20, + ], + ], + 'default' => [ + 'size' => 1, + 'unit' => 'px', + ], + 'selectors' => [ + '{{WRAPPER}} .elementor-vertical-separator__line' => 'width: {{SIZE}}{{UNIT}};' + ], + ] + ); + + $this->add_responsive_control( + 'line_height', + [ + 'label' => esc_html__( 'Height', 'elementor-addon' ), + 'type' => Controls_Manager::SLIDER, + 'size_units' => [ 'px', '%' ], + 'range' => [ + 'px' => [ + 'min' => 10, + 'max' => 600, + ], + '%' => [ + 'min' => 10, + 'max' => 100, + ], + ], + 'default' => [ + 'size' => 100, + 'unit' => 'px', + ], + 'selectors' => [ + '{{WRAPPER}} .elementor-vertical-separator__line' => 'height: {{SIZE}}{{UNIT}};' + ], + ] + ); + + $this->add_responsive_control( + 'line_alignment', + [ + 'label' => esc_html__( 'Alignment', 'elementor-addon' ), + 'type' => Controls_Manager::CHOOSE, + 'default' => 'center', + 'options' => [ + 'flex-start' => [ + 'title' => esc_html__( 'Left', 'elementor-addon' ), + 'icon' => 'eicon-text-align-left', + ], + 'center' => [ + 'title' => esc_html__( 'Center', 'elementor-addon' ), + 'icon' => 'eicon-text-align-center', + ], + 'flex-end' => [ + 'title' => esc_html__( 'Right', 'elementor-addon' ), + 'icon' => 'eicon-text-align-right', + ], + ], + 'selectors' => [ + '{{WRAPPER}} .elementor-vertical-separator' => 'justify-content: {{VALUE}};' + ], + ] + ); + + $this->end_controls_section(); + } + + protected function render() { + ?> +