| 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 |
/** |
| 12 |
* Return a translated user-friendly list of the available SVG shapes. |
| 13 |
* |
| 14 |
* @param bool $add_custom Determine if the output should include the `Custom` option. |
| 15 |
* |
| 16 |
* @return array List of paths. |
| 17 |
*/ |
| 18 |
public static function get_paths( $add_custom = true ) { |
| 19 |
$paths = [ |
| 20 |
'wave' => esc_html__( 'Wave', 'elementor' ), |
| 21 |
'arc' => esc_html__( 'Arc', 'elementor' ), |
| 22 |
'circle' => esc_html__( 'Circle', 'elementor' ), |
| 23 |
'line' => esc_html__( 'Line', 'elementor' ), |
| 24 |
'oval' => esc_html__( 'Oval', 'elementor' ), |
| 25 |
'spiral' => esc_html__( 'Spiral', 'elementor' ), |
| 26 |
]; |
| 27 |
|
| 28 |
if ( $add_custom ) { |
| 29 |
$paths['custom'] = esc_html__( 'Custom', 'elementor' ); |
| 30 |
} |
| 31 |
|
| 32 |
return $paths; |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Gets an SVG path name as a parameter and returns its SVG markup from the `svg-paths` |
| 37 |
* folder under the assets directory. |
| 38 |
* |
| 39 |
* @param $path string Path name. |
| 40 |
* |
| 41 |
* @return string The path SVG markup. |
| 42 |
*/ |
| 43 |
public static function get_path_svg( $path ) { |
| 44 |
$file_name = ELEMENTOR_ASSETS_PATH . 'svg-paths/' . $path . '.svg'; |
| 45 |
|
| 46 |
if ( ! is_file( $file_name ) ) { |
| 47 |
return ''; |
| 48 |
} |
| 49 |
|
| 50 |
return file_get_contents( $file_name ); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Get the module's associated widgets. |
| 55 |
* |
| 56 |
* @return string[] |
| 57 |
*/ |
| 58 |
protected function get_widgets() { |
| 59 |
return [ |
| 60 |
'TextPath', |
| 61 |
]; |
| 62 |
} |
| 63 |
|
| 64 |
/** |
| 65 |
* Retrieve the module name. |
| 66 |
* |
| 67 |
* @return string |
| 68 |
*/ |
| 69 |
public function get_name() { |
| 70 |
return 'shapes'; |
| 71 |
} |
| 72 |
} |
| 73 |
|