[ [ 'typography_font_family' => get_theme_mod( 'typography_heading_h1_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h1_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h1_font_variant' ) ? get_theme_mod( 'typography_heading_h1_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_heading_h2_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h2_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h2__font_variant' ) ? get_theme_mod( 'typography_heading_h2_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_heading_h3_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h3_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h3_font_variant' ) ? get_theme_mod( 'typography_heading_h3_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_heading_h4_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h4_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h4_font_variant' ) ? get_theme_mod( 'typography_heading_h4_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_heading_h5_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h5_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h5_font_variant' ) ? get_theme_mod( 'typography_heading_h5_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_heading_h6_font_family' ) === 'Default' ? get_theme_mod( 'typography_heading_font_family' ) : get_theme_mod( 'typography_heading_h6_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_heading_h6_font_variant' ) ? get_theme_mod( 'typography_heading_h6_font_variant' ) : '700', 'typography_typography' => 'custom', ], [ 'typography_font_family' => get_theme_mod( 'typography_global_font_family' ), 'typography_font_weight' => get_theme_mod( 'typography_global_font_variant' ) ? get_theme_mod( 'typography_global_font_variant' ) : 'regular', 'typography_typography' => 'custom', ], ], ]; } /** * Global Color Typography Slugs * * @return array */ public function get_typography_slugs() { return array( 'ayyash_h1', 'ayyash_h2', 'ayyash_h3', 'ayyash_h4', 'ayyash_h5', 'ayyash_h6', 'ayyash_text', ); } /** * Global Color Typography labels * * @return array */ public function get_typography_labels() { return array( __( 'Ayyash Heading 1', 'ayyash' ), __( 'Ayyash Heading 2', 'ayyash' ), __( 'Ayyash Heading 3', 'ayyash' ), __( 'Ayyash Heading 4', 'ayyash' ), __( 'Ayyash Heading 5', 'ayyash' ), __( 'Ayyash Heading 6', 'ayyash' ), __( 'Ayyash Text', 'ayyash' ), ); } /** * Theme Typography for elementor * * @param $response * @param $handler * @param $request * * @return mixed * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed */ public function elementor_add_theme_typography( $response, $handler, $request ) { $route = $request->get_route(); if ( '/elementor/v1/globals' != $route ) { return $response; } $global_typo = self::global_typography(); $data = $response->get_data(); $slugs = self::get_typography_slugs(); $labels = self::get_typography_labels(); foreach ( $global_typo['typography'] as $key => $typography ) { $id = $slugs[ $key ] ? $slugs[ $key ] : ''; $label = $labels[ $key ] ? $labels[ $key ] : ''; if ( ! $id || ! $label || ! $typography ) { continue; } $data['typography'][ $id ] = array( 'id' => esc_attr( $id ), 'title' => $label, 'value' => $typography, ); } $response->set_data( $data ); return $response; } /** * Display Typography in frontend * * @param $response * @param $handler * @param $request * * @return mixed|WP_Error|WP_HTTP_Response|WP_REST_Response * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundBeforeLastUsed */ public function display_global_typo_front_end( $response, $handler, $request ) { $route = $request->get_route(); if ( 0 !== strpos( $route, '/elementor/v1/globals' ) ) { return $response; } $slug_map = array(); $typography_slugs = self::get_typography_slugs(); foreach ( $typography_slugs as $key => $slug ) { $slug_map[ $slug ] = $key; } $rest_id = substr( $route, strrpos( $route, '/' ) + 1 ); if ( ! in_array( $rest_id, array_keys( $slug_map ), true ) ) { return $response; } $typo = self::global_typography(); return rest_ensure_response( array( 'id' => esc_attr( $rest_id ), 'title' => esc_html( $slug_map[ $rest_id ] ), 'value' => $typo['typography'][ $slug_map[ $rest_id ] ], ) ); } } new Themeoo_Global_Typography(); }