| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Shapes; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Module extends \Elementor\Core\Base\Module { |
| 10 |
|
| 11 |
public function __construct() { |
| 12 |
parent::__construct(); |
| 13 |
|
| 14 |
add_action( 'elementor/frontend/after_register_styles', [ $this, 'register_styles' ] ); |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* Register styles. |
| 19 |
* |
| 20 |
* At build time, Elementor compiles `/modules/shapes/assets/scss/frontend.scss` |
| 21 |
* to `/assets/css/widget-shapes.min.css`. |
| 22 |
* |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
public function register_styles() { |
| 26 |
wp_register_style( |
| 27 |
'widget-text-path', |
| 28 |
$this->get_css_assets_url( 'widget-text-path', null, true, true ), |
| 29 |
[ 'elementor-frontend' ], |
| 30 |
ELEMENTOR_VERSION |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Return a translated user-friendly list of the available SVG shapes. |
| 36 |
* |
| 37 |
* @param bool $add_custom Determine if the output should include the `Custom` option. |
| 38 |
* |
| 39 |
* @return array List of paths. |
| 40 |
*/ |
| 41 |
public static function get_paths( $add_custom = true ) { |
| 42 |
$paths = [ |
| 43 |
'wave' => esc_html__( 'Wave', 'elementor' ), |
| 44 |
'arc' => esc_html__( 'Arc', 'elementor' ), |
| 45 |
'circle' => esc_html__( 'Circle', 'elementor' ), |
| 46 |
'line' => esc_html__( 'Line', 'elementor' ), |
| 47 |
'oval' => esc_html__( 'Oval', 'elementor' ), |
| 48 |
'spiral' => esc_html__( 'Spiral', 'elementor' ), |
| 49 |
]; |
| 50 |
|
| 51 |
if ( $add_custom ) { |
| 52 |
$paths['custom'] = esc_html__( 'Custom', 'elementor' ); |
| 53 |
} |
| 54 |
|
| 55 |
return $paths; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Get an SVG Path URL from the pre-defined ones. |
| 60 |
* |
| 61 |
* @param string $path - Path name. |
| 62 |
* |
| 63 |
* @return string |
| 64 |
*/ |
| 65 |
public static function get_path_url( $path ) { |
| 66 |
return ELEMENTOR_ASSETS_URL . 'svg-paths/' . $path . '.svg'; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get the module's associated widgets. |
| 71 |
* |
| 72 |
* @return string[] |
| 73 |
*/ |
| 74 |
protected function get_widgets() { |
| 75 |
return [ |
| 76 |
'TextPath', |
| 77 |
]; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* Retrieve the module name. |
| 82 |
* |
| 83 |
* @return string |
| 84 |
*/ |
| 85 |
public function get_name() { |
| 86 |
return 'shapes'; |
| 87 |
} |
| 88 |
} |
| 89 |
|