PluginProbe
Elementor Website Builder – more than just a page builder / 3.6.0-dev1
Elementor Website Builder – more than just a page builder v3.6.0-dev1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / modules / shapes / module.php

module.php in Elementor Website Builder – more than just a page builder 3.6.0-dev1, at modules/shapes/module.php

91 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 * Read SVG contents.
37 *
38 * @param $path - The SVG file path.
39 *
40 * @return false|string
41 */
42 public static function read_svg( $path ) {
43 if ( ! $path || ! is_file( $path ) || ! is_readable( $path ) ) {
44 return '';
45 }
46
47 // Get the file contents only if it's svg.
48 if ( 'svg' !== pathinfo( $path, PATHINFO_EXTENSION ) ) {
49 return '';
50 }
51
52 $svg = file_get_contents( $path );
53
54 return $svg ? $svg : '';
55 }
56
57 /**
58 * Gets an SVG path name as a parameter and returns its SVG markup from the `svg-paths`
59 * folder under the assets directory.
60 *
61 * @param $path string Path name.
62 *
63 * @return string The path SVG markup.
64 */
65 public static function get_path_svg( $path ) {
66 $file_name = ELEMENTOR_ASSETS_PATH . 'svg-paths/' . $path . '.svg';
67
68 return static::read_svg( $file_name );
69 }
70
71 /**
72 * Get the module's associated widgets.
73 *
74 * @return string[]
75 */
76 protected function get_widgets() {
77 return [
78 'TextPath',
79 ];
80 }
81
82 /**
83 * Retrieve the module name.
84 *
85 * @return string
86 */
87 public function get_name() {
88 return 'shapes';
89 }
90 }
91