| @@ -1,10 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace Elementor\Modules\Variables\Classes; |
| 4 | 4 | |
| 5 | -use Elementor\Modules\Variables\Services\Variables_Service; | |
| 6 | -use Elementor\Modules\Variables\Storage\Repository as Variables_Repository; | |
| 5 | +use Elementor\Modules\Variables\PropTypes\Color_Variable_Prop_Type; | |
| 6 | +use Elementor\Modules\Variables\PropTypes\Font_Variable_Prop_Type; | |
| 7 | 7 | |
| 8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| @@ -9,14 +9,180 @@ | ||
| 9 | 9 | exit; // Exit if accessed directly. |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | class Variables { |
| 13 | - private static $lookup = []; | |
| 13 | + const FILTER = 'elementor/atomic-variables/variables'; | |
| 14 | 14 | |
| 15 | - public static function init( Variables_Service $service ) { | |
| 16 | - self::$lookup = $service->get_variables_list(); | |
| 15 | + public function get_all() { | |
| 16 | + $variables = array_merge( $this->get_color_variables(), $this->get_font_variables() ); | |
| 17 | + | |
| 18 | + return apply_filters( self::FILTER, $variables ); | |
| 17 | 19 | } |
| 18 | 20 | |
| 19 | - public static function by_id( string $id ) { | |
| 20 | - return self::$lookup[ $id ] ?? null; | |
| 21 | + private function get_color_variables(): array { | |
| 22 | + $type = Color_Variable_Prop_Type::get_key(); | |
| 23 | + | |
| 24 | + return [ | |
| 25 | + 'e-gc-001' => [ | |
| 26 | + 'type' => $type, | |
| 27 | + 'value' => '#ffffff', | |
| 28 | + 'label' => 'Main: white', | |
| 29 | + ], | |
| 30 | + 'e-gc-002' => [ | |
| 31 | + 'type' => $type, | |
| 32 | + 'value' => '#000000', | |
| 33 | + 'label' => 'Main: black', | |
| 34 | + ], | |
| 35 | + 'e-gc-003' => [ | |
| 36 | + 'type' => $type, | |
| 37 | + 'value' => '#404040', | |
| 38 | + 'label' => 'Main: text', | |
| 39 | + ], | |
| 40 | + | |
| 41 | + 'e-gc-a01' => [ | |
| 42 | + 'type' => $type, | |
| 43 | + 'value' => '#FF0000', | |
| 44 | + 'label' => 'Danger: red', | |
| 45 | + ], | |
| 46 | + 'e-gc-a02' => [ | |
| 47 | + 'type' => $type, | |
| 48 | + 'value' => '#0000FF', | |
| 49 | + 'label' => 'Informative: blue', | |
| 50 | + ], | |
| 51 | + 'e-gc-a03' => [ | |
| 52 | + 'type' => $type, | |
| 53 | + 'value' => '#FF7BE5', | |
| 54 | + 'label' => 'Elementor: pink', | |
| 55 | + ], | |
| 56 | + 'e-gc-a04' => [ | |
| 57 | + 'type' => $type, | |
| 58 | + 'value' => '#808080', | |
| 59 | + 'label' => 'Gray: background', | |
| 60 | + ], | |
| 61 | + | |
| 62 | + 'e-gc-b01' => [ | |
| 63 | + 'type' => $type, | |
| 64 | + 'value' => '#213555', | |
| 65 | + 'label' => 'Navy: primary', | |
| 66 | + ], | |
| 67 | + 'e-gc-b02' => [ | |
| 68 | + 'type' => $type, | |
| 69 | + 'value' => '#3E5879', | |
| 70 | + 'label' => 'Navy: secondary', | |
| 71 | + ], | |
| 72 | + 'e-gc-b03' => [ | |
| 73 | + 'type' => $type, | |
| 74 | + 'value' => '#D8C4B6', | |
| 75 | + 'label' => 'Navy: light', | |
| 76 | + ], | |
| 77 | + 'e-gc-b04' => [ | |
| 78 | + 'type' => $type, | |
| 79 | + 'value' => '#F5EFE7', | |
| 80 | + 'label' => 'Navy long text variable name: background', | |
| 81 | + ], | |
| 82 | + | |
| 83 | + 'e-gc-d01' => [ | |
| 84 | + 'type' => $type, | |
| 85 | + 'value' => '#123524', | |
| 86 | + 'label' => 'Green: primary', | |
| 87 | + ], | |
| 88 | + 'e-gc-d02' => [ | |
| 89 | + 'type' => $type, | |
| 90 | + 'value' => '#3E7B27', | |
| 91 | + 'label' => 'Green: secondary', | |
| 92 | + ], | |
| 93 | + 'e-gc-d03' => [ | |
| 94 | + 'type' => $type, | |
| 95 | + 'value' => '#85A947', | |
| 96 | + 'label' => 'Green: light', | |
| 97 | + ], | |
| 98 | + 'e-gc-d04' => [ | |
| 99 | + 'type' => $type, | |
| 100 | + 'value' => '#85A947', | |
| 101 | + 'label' => 'Green: background', | |
| 102 | + ], | |
| 103 | + | |
| 104 | + 'e-gc-c01' => [ | |
| 105 | + 'type' => $type, | |
| 106 | + 'value' => '#3B1E54', | |
| 107 | + 'label' => 'Violet: primary', | |
| 108 | + ], | |
| 109 | + 'e-gc-c02' => [ | |
| 110 | + 'type' => $type, | |
| 111 | + 'value' => '#9B7EBD', | |
| 112 | + 'label' => 'Violet: secondary', | |
| 113 | + ], | |
| 114 | + 'e-gc-c03' => [ | |
| 115 | + 'type' => $type, | |
| 116 | + 'value' => '#D4BEE4', | |
| 117 | + 'label' => 'Violet: light', | |
| 118 | + ], | |
| 119 | + 'e-gc-c04' => [ | |
| 120 | + 'type' => $type, | |
| 121 | + 'value' => '#EEEEEE', | |
| 122 | + 'label' => 'Violet: background', | |
| 123 | + ], | |
| 124 | + ]; | |
| 125 | + } | |
| 126 | + | |
| 127 | + private function get_font_variables(): array { | |
| 128 | + $type = Font_Variable_Prop_Type::get_key(); | |
| 129 | + | |
| 130 | + return [ | |
| 131 | + 'e-gf-001' => [ | |
| 132 | + 'type' => $type, | |
| 133 | + 'value' => 'Almendra SC', | |
| 134 | + 'label' => 'Almendra', | |
| 135 | + ], | |
| 136 | + 'e-gf-002' => [ | |
| 137 | + 'type' => $type, | |
| 138 | + 'value' => 'Montserrat', | |
| 139 | + 'label' => 'Montserrat', | |
| 140 | + ], | |
| 141 | + 'e-gf-003' => [ | |
| 142 | + 'type' => $type, | |
| 143 | + 'value' => 'Raleway', | |
| 144 | + 'label' => 'Raleway', | |
| 145 | + ], | |
| 146 | + 'e-gf-004' => [ | |
| 147 | + 'type' => $type, | |
| 148 | + 'value' => 'ADLaM Display', | |
| 149 | + 'label' => 'ADLaM', | |
| 150 | + ], | |
| 151 | + 'e-gf-005' => [ | |
| 152 | + 'type' => $type, | |
| 153 | + 'value' => 'Aclonica', | |
| 154 | + 'label' => 'Aclonica', | |
| 155 | + ], | |
| 156 | + 'e-gf-006' => [ | |
| 157 | + 'type' => $type, | |
| 158 | + 'value' => 'Aguafina Script', | |
| 159 | + 'label' => 'Aguafina', | |
| 160 | + ], | |
| 161 | + 'e-gf-007' => [ | |
| 162 | + 'type' => $type, | |
| 163 | + 'value' => 'Alfa Slab One', | |
| 164 | + 'label' => 'Alfa Slab', | |
| 165 | + ], | |
| 166 | + 'e-gf-008' => [ | |
| 167 | + 'type' => $type, | |
| 168 | + 'value' => 'Bruno Ace SC', | |
| 169 | + 'label' => 'Bruno Ace', | |
| 170 | + ], | |
| 171 | + 'e-gf-009' => [ | |
| 172 | + 'type' => $type, | |
| 173 | + 'value' => 'Bungee Shade', | |
| 174 | + 'label' => 'Bungee', | |
| 175 | + ], | |
| 176 | + 'e-gf-010' => [ | |
| 177 | + 'type' => $type, | |
| 178 | + 'value' => 'Uncial Antiqua', | |
| 179 | + 'label' => 'Uncial', | |
| 180 | + ], | |
| 181 | + 'e-gf-011' => [ | |
| 182 | + 'type' => $type, | |
| 183 | + 'value' => 'Vast Shadow', | |
| 184 | + 'label' => 'Vast', | |
| 185 | + ], | |
| 186 | + ]; | |
| 21 | 187 | } |
| 22 | 188 | } |