| 1 |
<?php |
| 2 |
namespace Elementor\Modules\ElementsColorPicker; |
| 3 |
|
| 4 |
use Elementor\Core\Experiments\Manager; |
| 5 |
use Elementor\Core\Base\Module as BaseModule; |
| 6 |
use Elementor\Core\Experiments\Manager as Experiments_Manager; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
class Module extends BaseModule { |
| 13 |
|
| 14 |
/** |
| 15 |
* Retrieve the module name. |
| 16 |
* |
| 17 |
* @return string |
| 18 |
*/ |
| 19 |
public function get_name() { |
| 20 |
return 'elements-color-picker'; |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Set the Eye-Dropper as an experimental feature. |
| 25 |
* |
| 26 |
* @return array |
| 27 |
*/ |
| 28 |
public static function get_experimental_data() { |
| 29 |
return [ |
| 30 |
'name' => 'elements-color-picker', |
| 31 |
'title' => esc_html__( 'Color Sampler', 'elementor' ), |
| 32 |
'default' => Manager::STATE_ACTIVE, |
| 33 |
'release_status' => Experiments_Manager::RELEASE_STATUS_STABLE, |
| 34 |
'description' => esc_html__( 'Adds a new color picker functionality that allows choose a color from other elements settings.', 'elementor' ), |
| 35 |
]; |
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Enqueue the `Color-Thief` library to pick colors from images. |
| 40 |
* |
| 41 |
* @return void |
| 42 |
*/ |
| 43 |
public function enqueue_scripts() { |
| 44 |
wp_enqueue_script( |
| 45 |
'color-thief', |
| 46 |
$this->get_js_assets_url( 'color-thief', 'assets/lib/color-thief/', true ), |
| 47 |
[ 'elementor-editor' ], |
| 48 |
ELEMENTOR_VERSION, |
| 49 |
true |
| 50 |
); |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* Module constructor - Initialize the Eye-Dropper module. |
| 55 |
* |
| 56 |
* @return void |
| 57 |
*/ |
| 58 |
public function __construct() { |
| 59 |
add_action( 'elementor/editor/after_enqueue_scripts', [ $this, 'enqueue_scripts' ] ); |
| 60 |
} |
| 61 |
} |
| 62 |
|