Astra_Elementor::display_global_colors_front_end( object $response, array $handler, ElementorWP_REST_Request $request )
Display global paltte colors on Elementor front end Page.
Description
Parameters
- $response
-
(object) (Required) rest request response.
- $handler
-
(array) (Required) Route handler used for the request.
- $request
-
(ElementorWP_REST_Request) (Required) Request used to generate the response.
Return
(object)
Source
File: inc/compatibility/class-astra-elementor.php
public function display_global_colors_front_end( $response, $handler, $request ) { $route = $request->get_route(); if ( 0 !== strpos( $route, '/elementor/v1/globals' ) ) { return $response; } $slug_map = array(); $palette_slugs = Astra_Global_Palette::get_palette_slugs(); foreach ( $palette_slugs as $key => $slug ) { // Remove hyphens as hyphens do not work with Elementor global styles. $no_hyphens = str_replace( '-', '', $slug ); $slug_map[ $no_hyphens ] = $key; } $rest_id = substr( $route, strrpos( $route, '/' ) + 1 ); if ( ! in_array( $rest_id, array_keys( $slug_map ), true ) ) { return $response; } $colors = astra_get_option( 'global-color-palette' ); $response = rest_ensure_response( array( 'id' => esc_attr( $rest_id ), 'title' => Astra_Global_Palette::get_css_variable_prefix() . esc_html( $slug_map[ $rest_id ] ), 'value' => $colors['palette'][ $slug_map[ $rest_id ] ], ) ); return $response; }
Expand full source code Collapse full source code View on Trac
Changelog
Version | Description |
---|---|
3.7.0 | Introduced. |