C:\xampp\htdocs\landing\wp-content\updraft\plugins-old\olympus-google-fonts\blocks\init.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<?php
/**
 * Blocks Package
 *
 * @package   olympus-google-fonts
 * @copyright Copyright (c) 2020, Fonts Plugin
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU Public License
 */

// Exit if accessed directly.
if ( ! defined'ABSPATH' ) ) {
    exit;
}

/**
 * Enqueue Gutenberg block assets for backend editor.
 */
function olympus_google_fonts_block_js() {
    
wp_enqueue_script(
        
'olympus-google-fonts-block-js',
        
plugins_url'/dist/blocks.build.js'__FILE__ ),
        array( 
'wp-blocks''wp-i18n''wp-element''wp-components''wp-editor' ),
        
OGF_VERSION,
        
false
    
);
    
wp_localize_script'olympus-google-fonts-block-js''ogf_custom_fonts'ogf_custom_fonts() );
}

add_action'enqueue_block_editor_assets''olympus_google_fonts_block_js' );

/**
 * Registers the 'olympus-google-fonts/google-fonts' block on server.
 */
function olympus_google_fonts_register_block() {
    
// Check if the register function exists.
    
if ( ! function_exists'register_block_type' ) ) {
        return;
    }
    
register_block_type(
        
'olympus-google-fonts/google-fonts',
        array(
            
'attributes'      => array(
                
'blockType'  => array(
                    
'type'    => 'string',
                    
'default' => 'p',
                ),
                
'fontID'     => array(
                    
'type'    => 'string',
                    
'default' => '',
                ),
                
'variant'    => array(
                    
'type'    => 'string',
                    
'default' => 'normal',
                ),
                
'fontSize'   => array(
                    
'type' => 'number',
                ),
                
'lineHeight' => array(
                    
'type' => 'number',
                ),
                
'align'      => array(
                    
'type' => 'string',
                ),
                
'content'    => array(
                    
'type' => 'string',
                ),
                
'color'      => array(
                    
'type' => 'string',
                ),
            ),
            
'render_callback' => 'olympus_google_fonts_block_render',
        )
    );
}
add_action'init''olympus_google_fonts_register_block' );

/**
 * Front end render function for 'olympus-google-fonts/google-fonts'.
 *
 * @param array $attributes The block attributes.
 */
function olympus_google_fonts_block_render$attributes ) {

    
$block_type  = isset( $attributes['blockType'] ) ? esc_attr$attributes['blockType'] ) : 'p';
    
$font_id     = isset( $attributes['fontID'] ) ? sanitize_text_field$attributes['fontID'] ) : '';
    
$variant     = isset( $attributes['variant'] ) ? sanitize_text_field$attributes['variant'] ) : '';
    
$font_size   = isset( $attributes['fontSize'] ) ? intval$attributes['fontSize'] ) : '';
    
$line_height = isset( $attributes['lineHeight'] ) ? floatval$attributes['lineHeight'] ) : '';
    
$align       = isset( $attributes['align'] ) ? sanitize_text_field$attributes['align'] ) : '';
    
$content     = isset( $attributes['content'] ) ? wp_kses_post$attributes['content'] ) : '';
    
$color       = isset( $attributes['color'] ) ? sanitize_text_field$attributes['color'] ) : '';
    
$output      '';
    
$style       '';

    if ( 
$font_id ) {

        
// standardize the format.
        
$font_id_standardized str_replace'+''-'strtolower$font_id ) );

        if ( 
array_key_exists$font_id_standardizedOGF_Fonts::$google_fonts ) ) {
            
$variants OGF_Fonts::$google_fonts$font_id_standardized ]['v'];

            
$variants_for_url join','array_keys$variants ) );

            
wp_enqueue_style'google-font-' $font_id_standardized'https://fonts.googleapis.com/css?family=' $font_id ':' $variants_for_url '&display=swap', array(), OGF_VERSION );

            
$font_family esc_attrstr_replace'+'' '$font_id ) );
        } else {
            
$font_family $font_id;
        }

        
$style "font-family: {$font_family};";
    }

    if ( 
$variant && '0' !== $variant ) {
        
$style .= "font-weight: {$variant};";
    }

    if ( 
$font_size ) {
        
$style .= "font-size: {$font_size}px;";
    }

    if ( 
$line_height ) {
        
$style .= "line-height: {$line_height};";
    }

    if ( 
$align ) {
        
$style .= "text-align: {$align};";
    }

    if ( 
$color ) {
        
$style .= "color: {$color};";
    }

    
$output .= '<' $block_type ' class="fonts-plugin-block" style="' $style '">';
    
$output .= $content;
    
$output .= '</' $block_type '>';

    return 
$output;
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586