C:\xampp\htdocs\landing\wp-content\updraft\themes-old\twentytwentyone\inc\template-functions.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<?php
/**
 * Functions which enhance the theme by hooking into WordPress
 *
 * @package WordPress
 * @subpackage Twenty_Twenty_One
 * @since 1.0.0
 */

/**
 * Adds custom classes to the array of body classes.
 *
 * @since 1.0.0
 *
 * @param array $classes Classes for the body element.
 *
 * @return array
 */
function twenty_twenty_one_body_classes$classes ) {

    
// Helps detect if JS is enabled or not.
    
$classes[] = 'no-js';

    
// Adds `singular` to singular pages, and `hfeed` to all other pages.
    
$classes[] = is_singular() ? 'singular' 'hfeed';

    
// Add a body class if main navigation is active.
    
if ( has_nav_menu'primary' ) ) {
        
$classes[] = 'has-main-navigation';
    }

    
// Add a body class if there are no footer widgets.
    
if ( ! is_active_sidebar'sidebar-1' ) ) {
        
$classes[] = 'no-widgets';
    }

    return 
$classes;
}
add_filter'body_class''twenty_twenty_one_body_classes' );

/**
 * Adds custom class to the array of posts classes.
 *
 * @since 1.0.0
 *
 * @param array $classes An array of CSS classes.
 *
 * @return array
 */
function twenty_twenty_one_post_classes$classes ) {
    
$classes[] = 'entry';

    return 
$classes;
}
add_filter'post_class''twenty_twenty_one_post_classes'10);

/**
 * Add a pingback url auto-discovery header for single posts, pages, or attachments.
 *
 * @since 1.0.0
 *
 * @return void
 */
function twenty_twenty_one_pingback_header() {
    if ( 
is_singular() && pings_open() ) {
        echo 
'<link rel="pingback" href="'esc_urlget_bloginfo'pingback_url' ) ), '">';
    }
}
add_action'wp_head''twenty_twenty_one_pingback_header' );

/**
 * Remove the `no-js` class from body if JS is supported.
 *
 * @since 1.0.0
 *
 * @return void
 */
function twenty_twenty_one_supports_js() {
    echo 
'<script>document.body.classList.remove("no-js");</script>';
}
add_action'wp_footer''twenty_twenty_one_supports_js' );

/**
 * Changes comment form default fields.
 *
 * @since 1.0.0
 *
 * @param array $defaults The form defaults.
 *
 * @return array
 */
function twenty_twenty_one_comment_form_defaults$defaults ) {

    
// Adjust height of comment form.
    
$defaults['comment_field'] = preg_replace'/rows="\d+"/''rows="5"'$defaults['comment_field'] );

    return 
$defaults;
}
add_filter'comment_form_defaults''twenty_twenty_one_comment_form_defaults' );

/**
 * Determines if post thumbnail can be displayed.
 *
 * @since 1.0.0
 *
 * @return bool
 */
function twenty_twenty_one_can_show_post_thumbnail() {
    return 
apply_filters(
        
'twenty_twenty_one_can_show_post_thumbnail',
        ! 
post_password_required() && ! is_attachment() && has_post_thumbnail()
    );
}

/**
 * Returns the size for avatars used in the theme.
 *
 * @since 1.0.0
 *
 * @return int
 */
function twenty_twenty_one_get_avatar_size() {
    return 
60;
}

/**
 * Creates continue reading text
 */
function twenty_twenty_one_continue_reading_text() {
    
$continue_reading sprintf(
        
/* translators: %s: Name of current post. */
        
esc_html__'Continue reading %s''twentytwentyone' ),
        
the_title'<span class="screen-reader-text">''</span>'false )
    );

    return 
$continue_reading;
}

/**
 * Create the continue reading link for excerpt.
 */
function twenty_twenty_one_continue_reading_link_excerpt() {
    if ( ! 
is_admin() ) {
        return 
'&hellip; <a class="more-link" href="' esc_urlget_permalink() ) . '">' twenty_twenty_one_continue_reading_text() . '</a>';
    }
}

// Filter the excerpt more link.
add_filter'excerpt_more''twenty_twenty_one_continue_reading_link_excerpt' );

/**
 * Create the continue reading link.
 */
function twenty_twenty_one_continue_reading_link() {
    if ( ! 
is_admin() ) {
        return 
'<div class="more-link-container"><a class="more-link" href="' esc_urlget_permalink() ) . '#more-' esc_attrget_the_ID() ) . '">' twenty_twenty_one_continue_reading_text() . '</a></div>';
    }
}

// Filter the excerpt more link.
add_filter'the_content_more_link''twenty_twenty_one_continue_reading_link' );

if ( ! 
function_exists'twenty_twenty_one_post_title' ) ) {
    
/**
     * Add a title to posts and pages that are missing titles.
     *
     * @since 1.0.0
     *
     * @param string $title The title.
     *
     * @return string
     */
    
function twenty_twenty_one_post_title$title ) {
        return 
'' === $title esc_html_x'Untitled''Added to posts and pages that are missing titles''twentytwentyone' ) : $title;
    }
}
add_filter'the_title''twenty_twenty_one_post_title' );

/**
 * Gets the SVG code for a given icon.
 *
 * @since 1.0.0
 *
 * @param string $group The icon group.
 * @param string $icon The icon.
 * @param int    $size The icon size in pixels.
 *
 * @return string
 */
function twenty_twenty_one_get_icon_svg$group$icon$size 24 ) {
    return 
Twenty_Twenty_One_SVG_Icons::get_svg$group$icon$size );
}

/**
 * Changes the default navigation arrows to svg icons
 *
 * @param string $calendar_output The generated HTML of the calendar.
 *
 * @return string
 */
function twenty_twenty_one_change_calendar_nav_arrows$calendar_output ) {
    
$calendar_output str_replace'&laquo; 'is_rtl() ? twenty_twenty_one_get_icon_svg'ui''arrow_right' ) : twenty_twenty_one_get_icon_svg'ui''arrow_left' ), $calendar_output );
    
$calendar_output str_replace' &raquo;'is_rtl() ? twenty_twenty_one_get_icon_svg'ui''arrow_left' ) : twenty_twenty_one_get_icon_svg'ui''arrow_right' ), $calendar_output );
    return 
$calendar_output;
}
add_filter'get_calendar''twenty_twenty_one_change_calendar_nav_arrows' );

/**
 * Get custom CSS.
 *
 * Return CSS for non-latin language, if available, or null
 *
 * @param string $type Whether to return CSS for the "front-end", "block-editor" or "classic-editor".
 *
 * @return string
 */
function twenty_twenty_one_get_non_latin_css$type 'front-end' ) {

    
// Fetch site locale.
    
$locale get_bloginfo'language' );

    
// Define fallback fonts for non-latin languages.
    
$font_family apply_filters(
        
'twenty_twenty_one_get_localized_font_family_types',
        array(

            
// Arabic.
            
'ar'    => array( 'Tahoma''Arial''sans-serif' ),
            
'ary'   => array( 'Tahoma''Arial''sans-serif' ),
            
'azb'   => array( 'Tahoma''Arial''sans-serif' ),
            
'ckb'   => array( 'Tahoma''Arial''sans-serif' ),
            
'fa-IR' => array( 'Tahoma''Arial''sans-serif' ),
            
'haz'   => array( 'Tahoma''Arial''sans-serif' ),
            
'ps'    => array( 'Tahoma''Arial''sans-serif' ),

            
// Chinese Simplified (China) - Noto Sans SC.
            
'zh-CN' => array( '\'PingFang SC\'''\'Helvetica Neue\'''\'Microsoft YaHei New\'''\'STHeiti Light\'''sans-serif' ),

            
// Chinese Traditional (Taiwan) - Noto Sans TC.
            
'zh-TW' => array( '\'PingFang TC\'''\'Helvetica Neue\'''\'Microsoft YaHei New\'''\'STHeiti Light\'''sans-serif' ),

            
// Chinese (Hong Kong) - Noto Sans HK.
            
'zh-HK' => array( '\'PingFang HK\'''\'Helvetica Neue\'''\'Microsoft YaHei New\'''\'STHeiti Light\'''sans-serif' ),

            
// Cyrillic.
            
'bel'   => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'bg-BG' => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'kk'    => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'mk-MK' => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'mn'    => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'ru-RU' => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'sah'   => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'sr-RS' => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'tt-RU' => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),
            
'uk'    => array( '\'Helvetica Neue\'''Helvetica''\'Segoe UI\'''Arial''sans-serif' ),

            
// Devanagari.
            
'bn-BD' => array( 'Arial''sans-serif' ),
            
'hi-IN' => array( 'Arial''sans-serif' ),
            
'mr'    => array( 'Arial''sans-serif' ),
            
'ne-NP' => array( 'Arial''sans-serif' ),

            
// Greek.
            
'el'    => array( '\'Helvetica Neue\', Helvetica, Arial, sans-serif' ),

            
// Gujarati.
            
'gu'    => array( 'Arial''sans-serif' ),

            
// Hebrew.
            
'he-IL' => array( '\'Arial Hebrew\'''Arial''sans-serif' ),

            
// Japanese.
            
'ja'    => array( 'sans-serif' ),

            
// Korean.
            
'ko-KR' => array( '\'Apple SD Gothic Neo\'''\'Malgun Gothic\'''\'Nanum Gothic\'''Dotum''sans-serif' ),

            
// Thai.
            
'th'    => array( '\'Sukhumvit Set\'''\'Helvetica Neue\'''Helvetica''Arial''sans-serif' ),

            
// Vietnamese.
            
'vi'    => array( '\'Libre Franklin\'''sans-serif' ),

        )
    );

    
// Return if the selected language has no fallback fonts.
    
if ( empty( $font_family$locale ] ) ) {
        return 
'';
    }

    
// Define elements to apply fallback fonts to.
    
$elements apply_filters(
        
'twenty_twenty_one_get_localized_font_family_elements',
        array(
            
'front-end'      => array( 'body''input''textarea''button''.button''.faux-button''.wp-block-button__link''.wp-block-file__button''.has-drop-cap:not(:focus)::first-letter''.has-drop-cap:not(:focus)::first-letter''.entry-content .wp-block-archives''.entry-content .wp-block-categories''.entry-content .wp-block-cover-image''.entry-content .wp-block-latest-comments''.entry-content .wp-block-latest-posts''.entry-content .wp-block-pullquote''.entry-content .wp-block-quote.is-large''.entry-content .wp-block-quote.is-style-large''.entry-content .wp-block-archives *''.entry-content .wp-block-categories *''.entry-content .wp-block-latest-posts *''.entry-content .wp-block-latest-comments *''.entry-content p''.entry-content ol''.entry-content ul''.entry-content dl''.entry-content dt''.entry-content cite''.entry-content figcaption''.entry-content .wp-caption-text''.comment-content p''.comment-content ol''.comment-content ul''.comment-content dl''.comment-content dt''.comment-content cite''.comment-content figcaption''.comment-content .wp-caption-text''.widget_text p''.widget_text ol''.widget_text ul''.widget_text dl''.widget_text dt''.widget-content .rssSummary''.widget-content cite''.widget-content figcaption''.widget-content .wp-caption-text' ),
            
'block-editor'   => array( '.editor-styles-wrapper > *''.editor-styles-wrapper p''.editor-styles-wrapper ol''.editor-styles-wrapper ul''.editor-styles-wrapper dl''.editor-styles-wrapper dt''.editor-post-title__block .editor-post-title__input''.editor-styles-wrapper .wp-block h1''.editor-styles-wrapper .wp-block h2''.editor-styles-wrapper .wp-block h3''.editor-styles-wrapper .wp-block h4''.editor-styles-wrapper .wp-block h5''.editor-styles-wrapper .wp-block h6''.editor-styles-wrapper .has-drop-cap:not(:focus)::first-letter''.editor-styles-wrapper cite''.editor-styles-wrapper figcaption''.editor-styles-wrapper .wp-caption-text' ),
            
'classic-editor' => array( 'body#tinymce.wp-editor''body#tinymce.wp-editor p''body#tinymce.wp-editor ol''body#tinymce.wp-editor ul''body#tinymce.wp-editor dl''body#tinymce.wp-editor dt''body#tinymce.wp-editor figcaption''body#tinymce.wp-editor .wp-caption-text''body#tinymce.wp-editor .wp-caption-dd''body#tinymce.wp-editor cite''body#tinymce.wp-editor table' ),
        )
    );

    
// Return if the specified type doesn't exist.
    
if ( empty( $elements$type ] ) ) {
        return 
'';
    }

    
// Include file if function doesn't exist.
    
if ( ! function_exists'twenty_twenty_one_generate_css' ) ) {
        require_once 
get_theme_file_path'inc/custom-css.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
    
}

    
// Return the specified styles.
    
return twenty_twenty_one_generate_css// @phpstan-ignore-line.
        
implode','$elements$type ] ),
        
'font-family',
        
implode','$font_family$locale ] ),
        
null,
        
null,
        
false
    
);
}

/**
 * Print the first instance of a block in the content, and then break away.
 *
 * @since 1.0.0
 *
 * @param string      $block_name The full block type name, or a partial match.
 *                                Example: `core/image`, `core-embed/*`.
 * @param string|null $content    The content to search in. Use null for get_the_content().
 * @param int         $instances  How many instances of the block will be printed (max). Defaults to 1.
 *
 * @return bool Returns true if a block was located & printed, otherwise false.
 */
function twenty_twenty_one_print_first_instance_of_block$block_name$content null$instances ) {
    
$instances_count 0;
    
$blocks_content  '';

    if ( ! 
$content ) {
        
$content get_the_content();
    }

    
// Parse blocks in the content.
    
$blocks parse_blocks$content );

    
// Loop blocks.
    
foreach ( $blocks as $block ) {

        
// Sanity check.
        
if ( ! isset( $block['blockName'] ) ) {
            continue;
        }

        
// Check if this the block matches the $block_name.
        
$is_matching_block false;

        
// If the block ends with *, try to match the first portion.
        
if ( '*' === $block_name[-1] ) {
            
$is_matching_block === strpos$block['blockName'], rtrim$block_name'*' ) );
        } else {
            
$is_matching_block $block_name === $block['blockName'];
        }

        if ( 
$is_matching_block ) {
            
// Increment count.
            
$instances_count++;

            
// Add the block HTML.
            
$blocks_content .= render_block$block );

            
// Break the loop if the $instances count was reached.
            
if ( $instances_count >= $instances ) {
                break;
            }
        }
    }

    if ( 
$blocks_content ) {
        echo 
apply_filters'the_content'$blocks_content ); // phpcs:ignore WordPress.Security.EscapeOutput
        
return true;
    }

    return 
false;
}

/**
 * Retrieve protected post password form content.
 *
 * @since 1.0.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
 * @return string HTML content for password form for password protected post.
 */
function twenty_twenty_one_password_form$post ) {
    
$post   get_post$post );
    
$label  'pwbox-' . ( empty( $post->ID ) ? wp_rand() : $post->ID );
    
$output '<p class="post-password-message">' esc_html__'This content is password protected. Please enter a password to view.''twentytwentyone' ) . '</p>
    <form action="' 
esc_urlsite_url'wp-login.php?action=postpass''login_post' ) ) . '" class="post-password-form" method="post">
    <label class="post-password-form__label" for="' 
esc_attr$label ) . '">' esc_html_x'Password''Post password form''twentytwentyone' ) . '</label><input class="post-password-form__input" name="post_password" id="' esc_attr$label ) . '" type="password" size="20" /><input type="submit" class="post-password-form__submit" name="' esc_attr_x'Submit''Post password form''twentytwentyone' ) . '" value="' esc_attr_x'Enter''Post password form''twentytwentyone' ) . '" /></form>
    '
;
    return 
$output;
}
add_filter'the_password_form''twenty_twenty_one_password_form' );

/**
 * Filters the list of attachment image attributes.
 *
 * @since 1.0.0
 *
 * @param array        $attr       Array of attribute values for the image markup, keyed by attribute name.
 *                                 See wp_get_attachment_image().
 * @param WP_Post      $attachment Image attachment post.
 * @param string|array $size       Requested size. Image size or array of width and height values
 *                                 (in that order). Default 'thumbnail'.
 *
 * @return array
 */
function twenty_twenty_one_get_attachment_image_attributes$attr$attachment$size ) {

    if ( isset( 
$attr['class'] ) && false !== strpos$attr['class'], 'custom-logo' ) ) {
        return 
$attr;
    }

    
$width  false;
    
$height false;

    if ( 
is_array$size ) ) {
        
$width  = (int) $size[0];
        
$height = (int) $size[1];
    } elseif ( 
$attachment && is_object$attachment ) && $attachment->ID ) {
        
$meta wp_get_attachment_metadata$attachment->ID );
        if ( 
$meta['width'] && $meta['height'] ) {
            
$width  = (int) $meta['width'];
            
$height = (int) $meta['height'];
        }
    }

    if ( 
$width && $height ) {

        
// Add style.
        
$attr['style'] = isset( $attr['style'] ) ? $attr['style'] : '';
        
$attr['style'] = 'width:100%;height:' round100 $height $width) . '%;max-width:' $width 'px;' $attr['style'];
    }

    return 
$attr;
}
add_filter'wp_get_attachment_image_attributes''twenty_twenty_one_get_attachment_image_attributes'10);
x

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