PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.7.2
Block Animations, Motion & Scroll Effects – Ghost Kit v3.7.2
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
← All changes | classes/class-typography.php +368 -357 2.25.03.7.2 View file →
@@ -8,390 +8,401 @@
8 8 /**
9 9 * GhostKit_Typography
10 10 */
11 11 class GhostKit_Typography {
12 - /**
13 - * GhostKit_Typography constructor.
14 - */
15 - public function __construct() {
16 - add_filter( 'gkt_custom_typography', array( $this, 'add_default_typography' ), 9 );
17 - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_typography_assets' ), 100 );
18 - add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_typography_assets' ), 100 );
19 - }
12 + /**
13 + * GhostKit_Typography constructor.
14 + */
15 + public function __construct() {
16 + add_filter( 'gkt_custom_typography', array( $this, 'add_default_typography' ), 9 );
17 + add_action( 'enqueue_block_assets', array( $this, 'enqueue_typography_assets' ), 100 );
18 + }
20 19
21 - /**
22 - * Enqueue Typography assets to editor and front end.
23 - */
24 - public function enqueue_typography_assets() {
25 - $typography_css = $this->generate_typography_styles();
26 - $css = ' ';
20 + /**
21 + * Enqueue Typography assets to editor and front end.
22 + */
23 + public function enqueue_typography_assets() {
24 + $typography_css = $this->generate_typography_styles();
25 + $css = ' ';
27 26
28 - if ( isset( $typography_css ) && ! empty( $typography_css ) && is_array( $typography_css ) ) {
29 - if ( ! is_admin() && isset( $typography_css['front'] ) && ! empty( $typography_css['front'] ) ) {
30 - $css = $typography_css['front'];
31 - }
32 - if ( function_exists( 'register_block_type' ) && is_admin() && isset( $typography_css['editor'] ) && ! empty( $typography_css['editor'] ) ) {
33 - $css = $typography_css['editor'];
34 - }
35 - }
36 - wp_register_style( 'ghostkit-typography', false, array(), '2.25.0' );
37 - wp_enqueue_style( 'ghostkit-typography' );
38 - wp_add_inline_style( 'ghostkit-typography', $css );
39 - }
27 + if ( isset( $typography_css ) && ! empty( $typography_css ) && is_array( $typography_css ) ) {
28 + if ( ! is_admin() && isset( $typography_css['front'] ) && ! empty( $typography_css['front'] ) ) {
29 + $css = $typography_css['front'];
30 + }
31 + if ( is_admin() && isset( $typography_css['editor'] ) && ! empty( $typography_css['editor'] ) ) {
32 + $css = $typography_css['editor'];
33 + }
34 + }
35 + wp_register_style( 'ghostkit-typography', false, array(), GHOSTKIT_VERSION );
36 + wp_enqueue_style( 'ghostkit-typography' );
37 + wp_add_inline_style( 'ghostkit-typography', $css );
38 + }
40 39
41 - /**
42 - * Generate Typography Styles.
43 - *
44 - * @return array - Typography Css.
45 - */
46 - public function generate_typography_styles() {
47 - $typography_prepeare_styles = array();
48 - $typography_css = array(
49 - 'editor' => '',
50 - 'front' => '',
51 - );
52 - $default_typography = apply_filters( 'gkt_custom_typography', array() );
53 - $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
54 - $global_typography = get_option( 'ghostkit_typography', array() );
55 - $is_admin_editor = is_admin() && $screen && $screen->is_block_editor;
40 + /**
41 + * Generate Typography Styles.
42 + *
43 + * @return array - Typography Css.
44 + */
45 + public static function generate_typography_styles() {
46 + $typography_prepeare_styles = array();
47 + $typography_css = array(
48 + 'editor' => '',
49 + 'front' => '',
50 + );
51 + $default_typography = apply_filters( 'gkt_custom_typography', array() );
52 + $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
53 + $global_typography = get_option( 'ghostkit_typography', array() );
54 + $is_admin_editor = is_admin() && $screen && $screen->is_block_editor;
56 55
57 - if ( is_singular() ) {
58 - $post_id = get_the_ID();
59 - } elseif ( $is_admin_editor ) {
60 - global $post;
61 - $post_id = isset( $post->ID ) ? $post->ID : null;
62 - }
56 + if ( is_singular() ) {
57 + $post_id = get_the_ID();
58 + } elseif ( $is_admin_editor ) {
59 + global $post;
60 + $post_id = isset( $post->ID ) ? $post->ID : null;
61 + }
63 62
64 - $is_single = is_singular() && $post_id;
65 - $is_admin_editor = $is_admin_editor && $post_id;
63 + $is_single = is_singular() && $post_id;
64 + $is_admin_editor = $is_admin_editor && $post_id;
66 65
67 - if ( $this->is_exist( $default_typography ) ) {
66 + if ( self::is_exist( $default_typography ) ) {
68 67
69 - foreach ( $default_typography as $key => $typography ) {
70 - if ( $this->is_exist( $typography['output'] ) ) {
71 - $typography_prepeare_styles[ $key ] = array(
72 - 'style-properties' => $typography['defaults'],
73 - 'output' => $typography['output'],
74 - );
75 - }
76 - }
68 + foreach ( $default_typography as $key => $typography ) {
69 + if ( self::is_exist( $typography['output'] ) ) {
70 + $typography_prepeare_styles[ $key ] = array(
71 + 'style-properties' => $typography['defaults'],
72 + 'output' => $typography['output'],
73 + );
74 + }
75 + }
77 76
78 - // Global custom Typography.
79 - if ( $this->is_exist( $global_typography ) && $this->is_exist( $global_typography['ghostkit_typography'] ) ) {
80 - $typography_prepeare_styles = $this->get_typography_values( $global_typography['ghostkit_typography'], $typography_prepeare_styles );
81 - }
77 + // Global custom Typography.
78 + if ( self::is_exist( $global_typography ) && self::is_exist( $global_typography['ghostkit_typography'] ) ) {
79 + $typography_prepeare_styles = self::get_typography_values( $global_typography['ghostkit_typography'], $typography_prepeare_styles );
80 + }
82 81
83 - // Local custom Typography.
84 - if ( $is_single || $is_admin_editor ) {
85 - $meta_typography = get_post_meta( $post_id, 'ghostkit_typography', true );
86 - $typography_prepeare_styles = $this->get_typography_values( $meta_typography, $typography_prepeare_styles );
87 - }
82 + // Local custom Typography.
83 + if ( $is_single || $is_admin_editor ) {
84 + $meta_typography = get_post_meta( $post_id, 'ghostkit_typography', true );
85 + $typography_prepeare_styles = self::get_typography_values( $meta_typography, $typography_prepeare_styles );
86 + }
88 87
89 - // Collect all the styles for further transfer to the inline file on the edit or front page.
90 - foreach ( $typography_prepeare_styles as $typography_prepeare_style ) {
91 - if (
92 - $this->is_exist( $typography_prepeare_style['output'] ) &&
93 - is_array( $typography_prepeare_style['output'] ) &&
94 - ( $this->is_exist( $typography_prepeare_style['style-properties'], 'font-family' ) ||
95 - $this->is_exist( $typography_prepeare_style['style-properties'], 'font-size' ) ||
96 - $this->is_exist( $typography_prepeare_style['style-properties'], 'font-weight' ) ||
97 - $this->is_exist( $typography_prepeare_style['style-properties'], 'line-height' ) ||
98 - $this->is_exist( $typography_prepeare_style['style-properties'], 'letter-spacing' )
99 - )
100 - ) {
101 - foreach ( $typography_prepeare_style['output'] as $output ) {
102 - if ( $this->is_exist( $output['selectors'] ) ) {
103 - $typography_styles = '';
104 - $typography_styles .= $output['selectors'] . '{';
88 + // Collect all the styles for further transfer to the inline file on the edit or front page.
89 + foreach ( $typography_prepeare_styles as $typography_prepeare_style ) {
90 + if (
91 + self::is_exist( $typography_prepeare_style['output'] ) &&
92 + is_array( $typography_prepeare_style['output'] ) &&
93 + ( self::is_exist( $typography_prepeare_style['style-properties'], 'font-family' ) ||
94 + self::is_exist( $typography_prepeare_style['style-properties'], 'font-size' ) ||
95 + self::is_exist( $typography_prepeare_style['style-properties'], 'font-weight' ) ||
96 + self::is_exist( $typography_prepeare_style['style-properties'], 'line-height' ) ||
97 + self::is_exist( $typography_prepeare_style['style-properties'], 'letter-spacing' )
98 + )
99 + ) {
100 + foreach ( $typography_prepeare_style['output'] as $output ) {
101 + if ( self::is_exist( $output['selectors'] ) ) {
102 + $typography_styles = '';
103 + $typography_styles .= $output['selectors'] . '{';
105 104
106 - if ( $this->is_exist( $typography_prepeare_style['style-properties'], 'font-family' ) ) {
107 - $typography_styles .= 'font-family: ' . esc_attr( $typography_prepeare_style['style-properties']['font-family'] ) . ', sans-serif;';
108 - }
105 + if ( self::is_exist( $typography_prepeare_style['style-properties'], 'font-family' ) ) {
106 + // Add double quotes to the font name, because some fonts have a space in the name.
107 + // And if the font name is not in quotes, then the browser will not be able to find it.
108 + // For example font-family: Source Serif 4; - will not work.
109 + $typography_styles .= 'font-family: "' . esc_attr( $typography_prepeare_style['style-properties']['font-family'] ) . '", sans-serif;';
110 + }
109 111
110 - if ( $this->is_exist( $typography_prepeare_style['style-properties'], 'font-size' ) ) {
111 - $typography_styles .= 'font-size: ' . esc_attr( $typography_prepeare_style['style-properties']['font-size'] ) . ';';
112 - }
112 + if ( self::is_exist( $typography_prepeare_style['style-properties'], 'font-size' ) ) {
113 + $typography_styles .= 'font-size: ' . esc_attr( $typography_prepeare_style['style-properties']['font-size'] ) . ';';
114 + }
113 115
114 - if ( $this->is_exist( $typography_prepeare_style['style-properties'], 'font-weight' ) ) {
115 - $font_weight = $typography_prepeare_style['style-properties']['font-weight'];
116 + if ( self::is_exist( $typography_prepeare_style['style-properties'], 'font-weight' ) ) {
117 + $font_weight = $typography_prepeare_style['style-properties']['font-weight'];
116 118
117 - if ( false !== strpos( $font_weight, 'i' ) ) {
118 - $font_weight = str_replace( 'i', '', $font_weight );
119 - $typography_styles .= 'font-style: italic;';
120 - } else {
121 - $typography_styles .= 'font-style: normal;';
122 - }
119 + if ( false !== strpos( $font_weight, 'i' ) ) {
120 + $font_weight = str_replace( 'i', '', $font_weight );
121 + $typography_styles .= 'font-style: italic;';
122 + } else {
123 + $typography_styles .= 'font-style: normal;';
124 + }
123 125
124 - $typography_styles .= 'font-weight: ' . esc_attr( $font_weight ) . ';';
125 - }
126 + $typography_styles .= 'font-weight: ' . esc_attr( $font_weight ) . ';';
127 + }
126 128
127 - if ( $this->is_exist( $typography_prepeare_style['style-properties'], 'line-height' ) ) {
128 - $typography_styles .= 'line-height: ' . esc_attr( $typography_prepeare_style['style-properties']['line-height'] ) . ';';
129 - }
129 + if ( self::is_exist( $typography_prepeare_style['style-properties'], 'line-height' ) ) {
130 + $typography_styles .= 'line-height: ' . esc_attr( $typography_prepeare_style['style-properties']['line-height'] ) . ';';
131 + }
130 132
131 - if ( $this->is_exist( $typography_prepeare_style['style-properties'], 'letter-spacing' ) ) {
132 - $typography_styles .= 'letter-spacing: ' . esc_attr( $typography_prepeare_style['style-properties']['letter-spacing'] ) . ';';
133 - }
133 + if ( self::is_exist( $typography_prepeare_style['style-properties'], 'letter-spacing' ) ) {
134 + $typography_styles .= 'letter-spacing: ' . esc_attr( $typography_prepeare_style['style-properties']['letter-spacing'] ) . ';';
135 + }
134 136
135 - $typography_styles .= '}';
137 + $typography_styles .= '}';
136 138
137 - if ( isset( $output['editor'] ) && true === $output['editor'] ) {
138 - $typography_css['editor'] .= $typography_styles;
139 - } else {
140 - $typography_css['front'] .= $typography_styles;
141 - }
142 - }
143 - }
144 - }
145 - }
146 - }
139 + if ( isset( $output['editor'] ) && true === $output['editor'] ) {
140 + $typography_css['editor'] .= $typography_styles;
141 + } else {
142 + $typography_css['front'] .= $typography_styles;
143 + }
144 + }
145 + }
146 + }
147 + }
148 + }
147 149
148 - return $typography_css;
149 - }
150 + return $typography_css;
151 + }
150 152
151 - /**
152 - * Check value on the existence and emptiness.
153 - *
154 - * @param void $value - Checking value.
155 - * @param bool $attribute - Checking attribute of Array Value.
156 - * @param string $mode - Full or isset for partial check.
157 - * @return bool $value - True or false.
158 - */
159 - public function is_exist( $value, $attribute = false, $mode = 'full' ) {
160 - $check = false;
153 + /**
154 + * Check value on the existence and emptiness.
155 + *
156 + * @param void $value - Checking value.
157 + * @param bool $attribute - Checking attribute of Array Value.
158 + * @param string $mode - Full or isset for partial check.
159 + * @return bool $value - True or false.
160 + */
161 + public static function is_exist( $value, $attribute = false, $mode = 'full' ) {
162 + $check = false;
161 163
162 - if ( $attribute ) {
163 - if ( 'full' === $mode && isset( $value[ $attribute ] ) && ! empty( $value[ $attribute ] ) ) {
164 - $check = true;
165 - }
166 - if ( 'isset' === $mode && isset( $value[ $attribute ] ) ) {
167 - $check = true;
168 - }
169 - } else {
170 - if ( 'full' === $mode ) {
171 - $check = ( isset( $value ) && ! empty( $value ) ) ? true : false;
172 - }
173 - if ( 'isset' === $mode ) {
174 - $check = ( isset( $value ) ) ? true : false;
175 - }
176 - }
164 + if ( $attribute ) {
165 + if ( 'full' === $mode && isset( $value[ $attribute ] ) && ! empty( $value[ $attribute ] ) && 'null' !== $value ) {
166 + $check = true;
167 + }
168 + if ( 'isset' === $mode && isset( $value[ $attribute ] ) ) {
169 + $check = true;
170 + }
171 + } else {
172 + if ( 'full' === $mode ) {
173 + $check = ( isset( $value ) && ! empty( $value ) && 'null' !== $value ) ? true : false;
174 + }
175 + if ( 'isset' === $mode ) {
176 + $check = ( isset( $value ) ) ? true : false;
177 + }
178 + }
177 179
178 - return $check;
179 - }
180 + return $check;
181 + }
180 182
181 - /**
182 - * Function for get Typography Values.
183 - *
184 - * @param object $typography_object - Current typography.
185 - * @param array $typography_prepeare_styles - Previous Array With Current Styles Properties.
186 - * @return mixed - Next Array With Current Styles Properties.
187 - */
188 - public function get_typography_values( $typography_object, $typography_prepeare_styles ) {
189 - $conformity_attributes = array(
190 - 'fontFamily' => 'font-family',
191 - 'fontFamilyCategory' => 'font-family-category',
192 - 'fontSize' => 'font-size',
193 - 'fontWeight' => 'font-weight',
194 - 'lineHeight' => 'line-height',
195 - 'letterSpacing' => 'letter-spacing',
196 - 'label' => 'label',
197 - 'childOf' => 'child-of',
198 - );
183 + /**
184 + * Function for get Typography Values.
185 + *
186 + * @param object $typography_object - Current typography.
187 + * @param array $typography_prepeare_styles - Previous Array With Current Styles Properties.
188 + * @return mixed - Next Array With Current Styles Properties.
189 + */
190 + public static function get_typography_values( $typography_object, $typography_prepeare_styles ) {
191 + $conformity_attributes = array(
192 + 'fontFamily' => 'font-family',
193 + 'fontFamilyCategory' => 'font-family-category',
194 + 'fontSize' => 'font-size',
195 + 'fontWeight' => 'font-weight',
196 + 'lineHeight' => 'line-height',
197 + 'letterSpacing' => 'letter-spacing',
198 + 'label' => 'label',
199 + 'childOf' => 'child-of',
200 + );
199 201
200 - if ( $this->is_exist( $typography_object ) ) {
201 - foreach ( json_decode( $typography_object ) as $meta_typography_key => $meta_typography_value ) {
202 - if ( array_key_exists( $meta_typography_key, $typography_prepeare_styles ) ) {
203 - foreach ( $meta_typography_value as $typography_attribute_key => $typography_attribute ) {
204 - if ( $this->is_exist( $conformity_attributes[ $typography_attribute_key ] ) &&
205 - $this->is_exist( $typography_prepeare_styles[ $meta_typography_key ]['style-properties'], $conformity_attributes[ $typography_attribute_key ], 'isset' ) ) {
206 - if ( '' !== $typography_attribute ) {
207 - $typography_prepeare_styles[ $meta_typography_key ]['style-properties'][ $conformity_attributes[ $typography_attribute_key ] ] = $typography_attribute;
208 - }
209 - }
210 - }
211 - }
212 - }
213 - }
202 + if ( self::is_exist( $typography_object ) ) {
203 + foreach ( json_decode( $typography_object ) as $meta_typography_key => $meta_typography_value ) {
204 + if ( array_key_exists( $meta_typography_key, $typography_prepeare_styles ) ) {
205 + foreach ( $meta_typography_value as $typography_attribute_key => $typography_attribute ) {
206 + if ( self::is_exist( $conformity_attributes[ $typography_attribute_key ] ) &&
207 + self::is_exist( $typography_prepeare_styles[ $meta_typography_key ]['style-properties'], $conformity_attributes[ $typography_attribute_key ], 'isset' ) ) {
208 + if ( '' !== $typography_attribute ) {
209 + $typography_prepeare_styles[ $meta_typography_key ]['style-properties'][ $conformity_attributes[ $typography_attribute_key ] ] = $typography_attribute;
210 + }
211 + }
212 + }
213 + }
214 + }
215 + }
214 216
215 - return $typography_prepeare_styles;
216 - }
217 + return $typography_prepeare_styles;
218 + }
217 219
218 - /**
219 - * Add Default Typography.
220 - *
221 - * @param array $custom_typography - Current typography.
222 - * @return array - New Typography.
223 - */
224 - public function add_default_typography( $custom_typography ) {
225 - $custom_typography = array(
226 - 'body' => array(
227 - 'label' => esc_html__( 'Body', 'ghostkit' ),
228 - 'defaults' => array(
229 - 'font-family-category' => 'default',
230 - 'font-family' => '',
231 - 'font-size' => '',
232 - 'font-weight' => '',
233 - 'line-height' => '',
234 - 'letter-spacing' => '',
235 - ),
236 - 'output' => array(
237 - array(
238 - 'selectors' => 'body',
239 - ),
240 - array(
241 - 'selectors' => '#editor .editor-styles-wrapper, .editor-styles-wrapper p',
242 - 'editor' => true,
243 - ),
244 - ),
245 - ),
246 - 'buttons' => array(
247 - 'label' => esc_html__( 'Buttons', 'ghostkit' ),
248 - 'defaults' => array(
249 - 'font-family-category' => 'default',
250 - 'font-family' => '',
251 - 'font-size' => '',
252 - 'font-weight' => '',
253 - 'line-height' => '',
254 - 'letter-spacing' => '',
255 - ),
256 - 'output' => array(
257 - array(
258 - 'selectors' => '.wp-block-button, .ghostkit-button, .entry .entry-content .wp-block-button .wp-block-button__link',
259 - ),
260 - array(
261 - 'selectors' => '#editor .editor-styles-wrapper .wp-block-button .wp-block-button__link, #editor .editor-styles-wrapper .ghostkit-button',
262 - 'editor' => true,
263 - ),
264 - ),
265 - ),
266 - 'headings' => array(
267 - 'label' => esc_html__( 'Headings', 'ghostkit' ),
268 - 'defaults' => array(
269 - 'font-family-category' => 'default',
270 - 'font-family' => '',
271 - 'font-weight' => '',
272 - 'line-height' => '',
273 - 'letter-spacing' => '',
274 - ),
275 - 'output' => array(
276 - array(
277 - 'selectors' => 'h1, h1.entry-title, h2, h3, h4, h5, h6',
278 - ),
279 - array(
280 - 'selectors' => '#editor .editor-styles-wrapper h1, #editor .editor-styles-wrapper h2, #editor .editor-styles-wrapper h3, #editor .editor-styles-wrapper h4, #editor .editor-styles-wrapper h5, #editor .editor-styles-wrapper h6, #editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input',
281 - 'editor' => true,
282 - ),
283 - ),
284 - ),
285 - 'h1' => array(
286 - 'label' => esc_html__( 'H1', 'ghostkit' ),
287 - 'defaults' => array(
288 - 'font-size' => '',
289 - 'line-height' => '',
290 - 'letter-spacing' => '',
291 - ),
292 - 'child-of' => 'headings',
293 - 'output' => array(
294 - array(
295 - 'selectors' => 'h1, h1.entry-title',
296 - ),
297 - array(
298 - 'selectors' => '#editor .editor-styles-wrapper h1, #editor .editor-styles-wrapper .editor-post-title__block .editor-post-title__input',
299 - 'editor' => true,
300 - ),
301 - ),
302 - ),
303 - 'h2' => array(
304 - 'label' => esc_html__( 'H2', 'ghostkit' ),
305 - 'defaults' => array(
306 - 'font-size' => '',
307 - 'line-height' => '',
308 - 'letter-spacing' => '',
309 - ),
310 - 'child-of' => 'headings',
311 - 'output' => array(
312 - array(
313 - 'selectors' => 'h2',
314 - ),
315 - array(
316 - 'selectors' => '#editor .editor-styles-wrapper h2',
317 - 'editor' => true,
318 - ),
319 - ),
320 - ),
321 - 'h3' => array(
322 - 'label' => esc_html__( 'H3', 'ghostkit' ),
323 - 'defaults' => array(
324 - 'font-size' => '',
325 - 'line-height' => '',
326 - 'letter-spacing' => '',
327 - ),
328 - 'child-of' => 'headings',
329 - 'output' => array(
330 - array(
331 - 'selectors' => 'h3',
332 - ),
333 - array(
334 - 'selectors' => '#editor .editor-styles-wrapper h3',
335 - 'editor' => true,
336 - ),
337 - ),
338 - ),
339 - 'h4' => array(
340 - 'label' => esc_html__( 'H4', 'ghostkit' ),
341 - 'defaults' => array(
342 - 'font-size' => '',
343 - 'line-height' => '',
344 - 'letter-spacing' => '',
345 - ),
346 - 'child-of' => 'headings',
347 - 'output' => array(
348 - array(
349 - 'selectors' => 'h4',
350 - ),
351 - array(
352 - 'selectors' => '#editor .editor-styles-wrapper h4',
353 - 'editor' => true,
354 - ),
355 - ),
356 - ),
357 - 'h5' => array(
358 - 'label' => esc_html__( 'H5', 'ghostkit' ),
359 - 'defaults' => array(
360 - 'font-size' => '',
361 - 'line-height' => '',
362 - 'letter-spacing' => '',
363 - ),
364 - 'child-of' => 'headings',
365 - 'output' => array(
366 - array(
367 - 'selectors' => 'h5',
368 - ),
369 - array(
370 - 'selectors' => '#editor .editor-styles-wrapper h5',
371 - 'editor' => true,
372 - ),
373 - ),
374 - ),
375 - 'h6' => array(
376 - 'label' => esc_html__( 'H6', 'ghostkit' ),
377 - 'defaults' => array(
378 - 'font-size' => '',
379 - 'line-height' => '',
380 - 'letter-spacing' => '',
381 - ),
382 - 'child-of' => 'headings',
383 - 'output' => array(
384 - array(
385 - 'selectors' => 'h6',
386 - ),
387 - array(
388 - 'selectors' => '#editor .editor-styles-wrapper h6',
389 - 'editor' => true,
390 - ),
391 - ),
392 - ),
393 - );
394 - return $custom_typography;
395 - }
220 + /**
221 + * Add Default Typography.
222 + *
223 + * @param array $custom_typography - Current typography.
224 + * @return array - New Typography.
225 + */
226 + public function add_default_typography( $custom_typography ) {
227 + $custom_typography = array(
228 + 'body' => array(
229 + 'label' => esc_html__( 'Body', 'ghostkit' ),
230 + 'defaults' => array(
231 + 'font-family-category' => 'default',
232 + 'font-family' => '',
233 + 'font-size' => '',
234 + 'font-weight' => '',
235 + 'line-height' => '',
236 + 'letter-spacing' => '',
237 + ),
238 + 'output' => array(
239 + array(
240 + 'selectors' => 'body',
241 + ),
242 + array(
243 + 'selectors' => '.editor-styles-wrapper, .editor-styles-wrapper p',
244 + 'editor' => true,
245 + ),
246 + ),
247 + ),
248 + 'buttons' => array(
249 + 'label' => esc_html__( 'Buttons', 'ghostkit' ),
250 + 'defaults' => array(
251 + 'font-family-category' => 'default',
252 + 'font-family' => '',
253 + 'font-size' => '',
254 + 'font-weight' => '',
255 + 'line-height' => '',
256 + 'letter-spacing' => '',
257 + ),
258 + 'output' => array(
259 + array(
260 + 'selectors' => '.wp-block-button, .ghostkit-button, .entry .entry-content .wp-block-button .wp-block-button__link',
261 + ),
262 + array(
263 + 'selectors' => '.editor-styles-wrapper .wp-block-button .wp-block-button__link, .editor-styles-wrapper .ghostkit-button',
264 + 'editor' => true,
265 + ),
266 + ),
267 + ),
268 + 'headings' => array(
269 + 'label' => esc_html__( 'Headings', 'ghostkit' ),
270 + 'defaults' => array(
271 + 'font-family-category' => 'default',
272 + 'font-family' => '',
273 + 'font-weight' => '',
274 + 'line-height' => '',
275 + 'letter-spacing' => '',
276 + ),
277 + 'output' => array(
278 + array(
279 + 'selectors' => 'h1, h1.entry-title, h2, h3, h4, h5, h6, .wp-block-heading, .wp-block-post-title, h2.wp-block-heading, h3.wp-block-heading, h4.wp-block-heading, h5.wp-block-heading, h6.wp-block-heading, .wp-block-heading',
280 + ),
281 + array(
282 + 'selectors' => '.editor-styles-wrapper h1, .editor-styles-wrapper h2, .editor-styles-wrapper h3, .editor-styles-wrapper h4, .editor-styles-wrapper h5, .editor-styles-wrapper h6, .editor-styles-wrapper .editor-post-title__block .editor-post-title__input',
283 + 'editor' => true,
284 + ),
285 + ),
286 + ),
287 + 'h1' => array(
288 + 'label' => esc_html__( 'H1', 'ghostkit' ),
289 + 'defaults' => array(
290 + 'font-size' => '',
291 + 'line-height' => '',
292 + 'letter-spacing' => '',
293 + ),
294 + 'child-of' => 'headings',
295 + 'output' => array(
296 + array(
297 + 'selectors' => 'h1, h1.entry-title, h1.wp-block-heading, h1.wp-block-post-title',
298 + ),
299 + array(
300 + 'selectors' => '.editor-styles-wrapper h1, .editor-styles-wrapper .editor-post-title__block .editor-post-title__input',
301 + 'editor' => true,
302 + ),
303 + ),
304 + ),
305 + 'h2' => array(
306 + 'label' => esc_html__( 'H2', 'ghostkit' ),
307 + 'defaults' => array(
308 + 'font-size' => '',
309 + 'line-height' => '',
310 + 'letter-spacing' => '',
311 + ),
312 + 'child-of' => 'headings',
313 + 'output' => array(
314 + array(
315 + 'selectors' => 'h2, h2.wp-block-heading',
316 + ),
317 + array(
318 + 'selectors' => '.editor-styles-wrapper h2',
319 + 'editor' => true,
320 + ),
321 + ),
322 + ),
323 + 'h3' => array(
324 + 'label' => esc_html__( 'H3', 'ghostkit' ),
325 + 'defaults' => array(
326 + 'font-size' => '',
327 + 'line-height' => '',
328 + 'letter-spacing' => '',
329 + ),
330 + 'child-of' => 'headings',
331 + 'output' => array(
332 + array(
333 + 'selectors' => 'h3, h3.wp-block-heading',
334 + ),
335 + array(
336 + 'selectors' => '.editor-styles-wrapper h3',
337 + 'editor' => true,
338 + ),
339 + ),
340 + ),
341 + 'h4' => array(
342 + 'label' => esc_html__( 'H4', 'ghostkit' ),
343 + 'defaults' => array(
344 + 'font-size' => '',
345 + 'line-height' => '',
346 + 'letter-spacing' => '',
347 + ),
348 + 'child-of' => 'headings',
349 + 'output' => array(
350 + array(
351 + 'selectors' => 'h4, h4.wp-block-heading',
352 + ),
353 + array(
354 + 'selectors' => '.editor-styles-wrapper h4',
355 + 'editor' => true,
356 + ),
357 + ),
358 + ),
359 + 'h5' => array(
360 + 'label' => esc_html__( 'H5', 'ghostkit' ),
361 + 'defaults' => array(
362 + 'font-size' => '',
363 + 'line-height' => '',
364 + 'letter-spacing' => '',
365 + ),
366 + 'child-of' => 'headings',
367 + 'output' => array(
368 + array(
369 + 'selectors' => 'h5, h5.wp-block-heading',
370 + ),
371 + array(
372 + 'selectors' => '.editor-styles-wrapper h5',
373 + 'editor' => true,
374 + ),
375 + ),
376 + ),
377 + 'h6' => array(
378 + 'label' => esc_html__( 'H6', 'ghostkit' ),
379 + 'defaults' => array(
380 + 'font-size' => '',
381 + 'line-height' => '',
382 + 'letter-spacing' => '',
383 + ),
384 + 'child-of' => 'headings',
385 + 'output' => array(
386 + array(
387 + 'selectors' => 'h6, h6.wp-block-heading',
388 + ),
389 + array(
390 + 'selectors' => '.editor-styles-wrapper h6',
391 + 'editor' => true,
392 + ),
393 + ),
394 + ),
395 + );
396 + return $custom_typography;
397 + }
398 +
399 + /**
400 + * Fallback for removed method, which was used in the Pro version priori to v2.2.0.
401 + *
402 + * @return bool
403 + */
404 + public static function typography_exist() {
405 + return false;
406 + }
396 407 }
397 408 new GhostKit_Typography();