Edit File by line
/home/barbar84/public_h.../wp-conte.../themes/twentyni...
File: functions.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Twenty Nineteen functions and definitions
[2] Fix | Delete
*
[3] Fix | Delete
* @link https://developer.wordpress.org/themes/basics/theme-functions/
[4] Fix | Delete
*
[5] Fix | Delete
* @package WordPress
[6] Fix | Delete
* @subpackage Twenty_Nineteen
[7] Fix | Delete
* @since Twenty Nineteen 1.0
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Twenty Nineteen only works in WordPress 4.7 or later.
[12] Fix | Delete
*/
[13] Fix | Delete
if ( version_compare( $GLOBALS['wp_version'], '4.7', '<' ) ) {
[14] Fix | Delete
require get_template_directory() . '/inc/back-compat.php';
[15] Fix | Delete
return;
[16] Fix | Delete
}
[17] Fix | Delete
[18] Fix | Delete
if ( ! function_exists( 'twentynineteen_setup' ) ) :
[19] Fix | Delete
/**
[20] Fix | Delete
* Sets up theme defaults and registers support for various WordPress features.
[21] Fix | Delete
*
[22] Fix | Delete
* Note that this function is hooked into the after_setup_theme hook, which
[23] Fix | Delete
* runs before the init hook. The init hook is too late for some features, such
[24] Fix | Delete
* as indicating support for post thumbnails.
[25] Fix | Delete
*/
[26] Fix | Delete
function twentynineteen_setup() {
[27] Fix | Delete
/*
[28] Fix | Delete
* Make theme available for translation.
[29] Fix | Delete
* Translations can be filed in the /languages/ directory.
[30] Fix | Delete
* If you're building a theme based on Twenty Nineteen, use a find and replace
[31] Fix | Delete
* to change 'twentynineteen' to the name of your theme in all the template files.
[32] Fix | Delete
*/
[33] Fix | Delete
load_theme_textdomain( 'twentynineteen', get_template_directory() . '/languages' );
[34] Fix | Delete
[35] Fix | Delete
// Add default posts and comments RSS feed links to head.
[36] Fix | Delete
add_theme_support( 'automatic-feed-links' );
[37] Fix | Delete
[38] Fix | Delete
/*
[39] Fix | Delete
* Let WordPress manage the document title.
[40] Fix | Delete
* By adding theme support, we declare that this theme does not use a
[41] Fix | Delete
* hard-coded <title> tag in the document head, and expect WordPress to
[42] Fix | Delete
* provide it for us.
[43] Fix | Delete
*/
[44] Fix | Delete
add_theme_support( 'title-tag' );
[45] Fix | Delete
[46] Fix | Delete
/*
[47] Fix | Delete
* Enable support for Post Thumbnails on posts and pages.
[48] Fix | Delete
*
[49] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
[50] Fix | Delete
*/
[51] Fix | Delete
add_theme_support( 'post-thumbnails' );
[52] Fix | Delete
set_post_thumbnail_size( 1568, 9999 );
[53] Fix | Delete
[54] Fix | Delete
// This theme uses wp_nav_menu() in two locations.
[55] Fix | Delete
register_nav_menus(
[56] Fix | Delete
array(
[57] Fix | Delete
'menu-1' => __( 'Primary', 'twentynineteen' ),
[58] Fix | Delete
'footer' => __( 'Footer Menu', 'twentynineteen' ),
[59] Fix | Delete
'social' => __( 'Social Links Menu', 'twentynineteen' ),
[60] Fix | Delete
)
[61] Fix | Delete
);
[62] Fix | Delete
[63] Fix | Delete
/*
[64] Fix | Delete
* Switch default core markup for search form, comment form, and comments
[65] Fix | Delete
* to output valid HTML5.
[66] Fix | Delete
*/
[67] Fix | Delete
add_theme_support(
[68] Fix | Delete
'html5',
[69] Fix | Delete
array(
[70] Fix | Delete
'search-form',
[71] Fix | Delete
'comment-form',
[72] Fix | Delete
'comment-list',
[73] Fix | Delete
'gallery',
[74] Fix | Delete
'caption',
[75] Fix | Delete
'script',
[76] Fix | Delete
'style',
[77] Fix | Delete
'navigation-widgets',
[78] Fix | Delete
)
[79] Fix | Delete
);
[80] Fix | Delete
[81] Fix | Delete
/**
[82] Fix | Delete
* Add support for core custom logo.
[83] Fix | Delete
*
[84] Fix | Delete
* @link https://codex.wordpress.org/Theme_Logo
[85] Fix | Delete
*/
[86] Fix | Delete
add_theme_support(
[87] Fix | Delete
'custom-logo',
[88] Fix | Delete
array(
[89] Fix | Delete
'height' => 190,
[90] Fix | Delete
'width' => 190,
[91] Fix | Delete
'flex-width' => false,
[92] Fix | Delete
'flex-height' => false,
[93] Fix | Delete
)
[94] Fix | Delete
);
[95] Fix | Delete
[96] Fix | Delete
// Add theme support for selective refresh for widgets.
[97] Fix | Delete
add_theme_support( 'customize-selective-refresh-widgets' );
[98] Fix | Delete
[99] Fix | Delete
// Add support for Block Styles.
[100] Fix | Delete
add_theme_support( 'wp-block-styles' );
[101] Fix | Delete
[102] Fix | Delete
// Add support for full and wide align images.
[103] Fix | Delete
add_theme_support( 'align-wide' );
[104] Fix | Delete
[105] Fix | Delete
// Add support for editor styles.
[106] Fix | Delete
add_theme_support( 'editor-styles' );
[107] Fix | Delete
[108] Fix | Delete
// Enqueue editor styles.
[109] Fix | Delete
add_editor_style( 'style-editor.css' );
[110] Fix | Delete
[111] Fix | Delete
// Add custom editor font sizes.
[112] Fix | Delete
add_theme_support(
[113] Fix | Delete
'editor-font-sizes',
[114] Fix | Delete
array(
[115] Fix | Delete
array(
[116] Fix | Delete
'name' => __( 'Small', 'twentynineteen' ),
[117] Fix | Delete
'shortName' => __( 'S', 'twentynineteen' ),
[118] Fix | Delete
'size' => 19.5,
[119] Fix | Delete
'slug' => 'small',
[120] Fix | Delete
),
[121] Fix | Delete
array(
[122] Fix | Delete
'name' => __( 'Normal', 'twentynineteen' ),
[123] Fix | Delete
'shortName' => __( 'M', 'twentynineteen' ),
[124] Fix | Delete
'size' => 22,
[125] Fix | Delete
'slug' => 'normal',
[126] Fix | Delete
),
[127] Fix | Delete
array(
[128] Fix | Delete
'name' => __( 'Large', 'twentynineteen' ),
[129] Fix | Delete
'shortName' => __( 'L', 'twentynineteen' ),
[130] Fix | Delete
'size' => 36.5,
[131] Fix | Delete
'slug' => 'large',
[132] Fix | Delete
),
[133] Fix | Delete
array(
[134] Fix | Delete
'name' => __( 'Huge', 'twentynineteen' ),
[135] Fix | Delete
'shortName' => __( 'XL', 'twentynineteen' ),
[136] Fix | Delete
'size' => 49.5,
[137] Fix | Delete
'slug' => 'huge',
[138] Fix | Delete
),
[139] Fix | Delete
)
[140] Fix | Delete
);
[141] Fix | Delete
[142] Fix | Delete
// Editor color palette.
[143] Fix | Delete
add_theme_support(
[144] Fix | Delete
'editor-color-palette',
[145] Fix | Delete
array(
[146] Fix | Delete
array(
[147] Fix | Delete
'name' => 'default' === get_theme_mod( 'primary_color' ) ? __( 'Blue', 'twentynineteen' ) : null,
[148] Fix | Delete
'slug' => 'primary',
[149] Fix | Delete
'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 33 ),
[150] Fix | Delete
),
[151] Fix | Delete
array(
[152] Fix | Delete
'name' => 'default' === get_theme_mod( 'primary_color' ) ? __( 'Dark Blue', 'twentynineteen' ) : null,
[153] Fix | Delete
'slug' => 'secondary',
[154] Fix | Delete
'color' => twentynineteen_hsl_hex( 'default' === get_theme_mod( 'primary_color' ) ? 199 : get_theme_mod( 'primary_color_hue', 199 ), 100, 23 ),
[155] Fix | Delete
),
[156] Fix | Delete
array(
[157] Fix | Delete
'name' => __( 'Dark Gray', 'twentynineteen' ),
[158] Fix | Delete
'slug' => 'dark-gray',
[159] Fix | Delete
'color' => '#111',
[160] Fix | Delete
),
[161] Fix | Delete
array(
[162] Fix | Delete
'name' => __( 'Light Gray', 'twentynineteen' ),
[163] Fix | Delete
'slug' => 'light-gray',
[164] Fix | Delete
'color' => '#767676',
[165] Fix | Delete
),
[166] Fix | Delete
array(
[167] Fix | Delete
'name' => __( 'White', 'twentynineteen' ),
[168] Fix | Delete
'slug' => 'white',
[169] Fix | Delete
'color' => '#FFF',
[170] Fix | Delete
),
[171] Fix | Delete
)
[172] Fix | Delete
);
[173] Fix | Delete
[174] Fix | Delete
// Add support for responsive embedded content.
[175] Fix | Delete
add_theme_support( 'responsive-embeds' );
[176] Fix | Delete
[177] Fix | Delete
// Add support for custom line height.
[178] Fix | Delete
add_theme_support( 'custom-line-height' );
[179] Fix | Delete
}
[180] Fix | Delete
endif;
[181] Fix | Delete
add_action( 'after_setup_theme', 'twentynineteen_setup' );
[182] Fix | Delete
[183] Fix | Delete
/**
[184] Fix | Delete
* Register widget area.
[185] Fix | Delete
*
[186] Fix | Delete
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
[187] Fix | Delete
*/
[188] Fix | Delete
function twentynineteen_widgets_init() {
[189] Fix | Delete
[190] Fix | Delete
register_sidebar(
[191] Fix | Delete
array(
[192] Fix | Delete
'name' => __( 'Footer', 'twentynineteen' ),
[193] Fix | Delete
'id' => 'sidebar-1',
[194] Fix | Delete
'description' => __( 'Add widgets here to appear in your footer.', 'twentynineteen' ),
[195] Fix | Delete
'before_widget' => '<section id="%1$s" class="widget %2$s">',
[196] Fix | Delete
'after_widget' => '</section>',
[197] Fix | Delete
'before_title' => '<h2 class="widget-title">',
[198] Fix | Delete
'after_title' => '</h2>',
[199] Fix | Delete
)
[200] Fix | Delete
);
[201] Fix | Delete
[202] Fix | Delete
}
[203] Fix | Delete
add_action( 'widgets_init', 'twentynineteen_widgets_init' );
[204] Fix | Delete
[205] Fix | Delete
/**
[206] Fix | Delete
* Replaces "[...]" (appended to automatically generated excerpts) with ... and
[207] Fix | Delete
* a 'Continue reading' link.
[208] Fix | Delete
*
[209] Fix | Delete
* @since Twenty Nineteen 2.0
[210] Fix | Delete
*
[211] Fix | Delete
* @param string $link Link to single post/page.
[212] Fix | Delete
* @return string 'Continue reading' link prepended with an ellipsis.
[213] Fix | Delete
*/
[214] Fix | Delete
function twentynineteen_excerpt_more( $link ) {
[215] Fix | Delete
if ( is_admin() ) {
[216] Fix | Delete
return $link;
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
$link = sprintf(
[220] Fix | Delete
'<p class="link-more"><a href="%1$s" class="more-link">%2$s</a></p>',
[221] Fix | Delete
esc_url( get_permalink( get_the_ID() ) ),
[222] Fix | Delete
/* translators: %s: Post title. */
[223] Fix | Delete
sprintf( __( 'Continue reading<span class="screen-reader-text"> "%s"</span>', 'twentynineteen' ), get_the_title( get_the_ID() ) )
[224] Fix | Delete
);
[225] Fix | Delete
return ' &hellip; ' . $link;
[226] Fix | Delete
}
[227] Fix | Delete
add_filter( 'excerpt_more', 'twentynineteen_excerpt_more' );
[228] Fix | Delete
[229] Fix | Delete
/**
[230] Fix | Delete
* Set the content width in pixels, based on the theme's design and stylesheet.
[231] Fix | Delete
*
[232] Fix | Delete
* Priority 0 to make it available to lower priority callbacks.
[233] Fix | Delete
*
[234] Fix | Delete
* @global int $content_width Content width.
[235] Fix | Delete
*/
[236] Fix | Delete
function twentynineteen_content_width() {
[237] Fix | Delete
// This variable is intended to be overruled from themes.
[238] Fix | Delete
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
[239] Fix | Delete
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
[240] Fix | Delete
$GLOBALS['content_width'] = apply_filters( 'twentynineteen_content_width', 640 );
[241] Fix | Delete
}
[242] Fix | Delete
add_action( 'after_setup_theme', 'twentynineteen_content_width', 0 );
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Enqueue scripts and styles.
[246] Fix | Delete
*/
[247] Fix | Delete
function twentynineteen_scripts() {
[248] Fix | Delete
wp_enqueue_style( 'twentynineteen-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) );
[249] Fix | Delete
[250] Fix | Delete
wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' );
[251] Fix | Delete
[252] Fix | Delete
if ( has_nav_menu( 'menu-1' ) ) {
[253] Fix | Delete
wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '20181214', true );
[254] Fix | Delete
wp_enqueue_script( 'twentynineteen-touch-navigation', get_theme_file_uri( '/js/touch-keyboard-navigation.js' ), array(), '20181231', true );
[255] Fix | Delete
}
[256] Fix | Delete
[257] Fix | Delete
wp_enqueue_style( 'twentynineteen-print-style', get_template_directory_uri() . '/print.css', array(), wp_get_theme()->get( 'Version' ), 'print' );
[258] Fix | Delete
[259] Fix | Delete
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
[260] Fix | Delete
wp_enqueue_script( 'comment-reply' );
[261] Fix | Delete
}
[262] Fix | Delete
}
[263] Fix | Delete
add_action( 'wp_enqueue_scripts', 'twentynineteen_scripts' );
[264] Fix | Delete
[265] Fix | Delete
/**
[266] Fix | Delete
* Fix skip link focus in IE11.
[267] Fix | Delete
*
[268] Fix | Delete
* This does not enqueue the script because it is tiny and because it is only for IE11,
[269] Fix | Delete
* thus it does not warrant having an entire dedicated blocking script being loaded.
[270] Fix | Delete
*
[271] Fix | Delete
* @link https://git.io/vWdr2
[272] Fix | Delete
*/
[273] Fix | Delete
function twentynineteen_skip_link_focus_fix() {
[274] Fix | Delete
// The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
[275] Fix | Delete
?>
[276] Fix | Delete
<script>
[277] Fix | Delete
/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
[278] Fix | Delete
</script>
[279] Fix | Delete
<?php
[280] Fix | Delete
}
[281] Fix | Delete
add_action( 'wp_print_footer_scripts', 'twentynineteen_skip_link_focus_fix' );
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Enqueue supplemental block editor styles.
[285] Fix | Delete
*/
[286] Fix | Delete
function twentynineteen_editor_customizer_styles() {
[287] Fix | Delete
[288] Fix | Delete
wp_enqueue_style( 'twentynineteen-editor-customizer-styles', get_theme_file_uri( '/style-editor-customizer.css' ), false, '1.1', 'all' );
[289] Fix | Delete
[290] Fix | Delete
if ( 'custom' === get_theme_mod( 'primary_color' ) ) {
[291] Fix | Delete
// Include color patterns.
[292] Fix | Delete
require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
[293] Fix | Delete
wp_add_inline_style( 'twentynineteen-editor-customizer-styles', twentynineteen_custom_colors_css() );
[294] Fix | Delete
}
[295] Fix | Delete
}
[296] Fix | Delete
add_action( 'enqueue_block_editor_assets', 'twentynineteen_editor_customizer_styles' );
[297] Fix | Delete
[298] Fix | Delete
/**
[299] Fix | Delete
* Display custom color CSS in customizer and on frontend.
[300] Fix | Delete
*/
[301] Fix | Delete
function twentynineteen_colors_css_wrap() {
[302] Fix | Delete
[303] Fix | Delete
// Only include custom colors in customizer or frontend.
[304] Fix | Delete
if ( ( ! is_customize_preview() && 'default' === get_theme_mod( 'primary_color', 'default' ) ) || is_admin() ) {
[305] Fix | Delete
return;
[306] Fix | Delete
}
[307] Fix | Delete
[308] Fix | Delete
require_once get_parent_theme_file_path( '/inc/color-patterns.php' );
[309] Fix | Delete
[310] Fix | Delete
$primary_color = 199;
[311] Fix | Delete
if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) {
[312] Fix | Delete
$primary_color = get_theme_mod( 'primary_color_hue', 199 );
[313] Fix | Delete
}
[314] Fix | Delete
?>
[315] Fix | Delete
[316] Fix | Delete
<style type="text/css" id="custom-theme-colors" <?php echo is_customize_preview() ? 'data-hue="' . absint( $primary_color ) . '"' : ''; ?>>
[317] Fix | Delete
<?php echo twentynineteen_custom_colors_css(); ?>
[318] Fix | Delete
</style>
[319] Fix | Delete
<?php
[320] Fix | Delete
}
[321] Fix | Delete
add_action( 'wp_head', 'twentynineteen_colors_css_wrap' );
[322] Fix | Delete
[323] Fix | Delete
/**
[324] Fix | Delete
* SVG Icons class.
[325] Fix | Delete
*/
[326] Fix | Delete
require get_template_directory() . '/classes/class-twentynineteen-svg-icons.php';
[327] Fix | Delete
[328] Fix | Delete
/**
[329] Fix | Delete
* Custom Comment Walker template.
[330] Fix | Delete
*/
[331] Fix | Delete
require get_template_directory() . '/classes/class-twentynineteen-walker-comment.php';
[332] Fix | Delete
[333] Fix | Delete
/**
[334] Fix | Delete
* Common theme functions.
[335] Fix | Delete
*/
[336] Fix | Delete
require get_template_directory() . '/inc/helper-functions.php';
[337] Fix | Delete
[338] Fix | Delete
/**
[339] Fix | Delete
* SVG Icons related functions.
[340] Fix | Delete
*/
[341] Fix | Delete
require get_template_directory() . '/inc/icon-functions.php';
[342] Fix | Delete
[343] Fix | Delete
/**
[344] Fix | Delete
* Enhance the theme by hooking into WordPress.
[345] Fix | Delete
*/
[346] Fix | Delete
require get_template_directory() . '/inc/template-functions.php';
[347] Fix | Delete
[348] Fix | Delete
/**
[349] Fix | Delete
* Custom template tags for the theme.
[350] Fix | Delete
*/
[351] Fix | Delete
require get_template_directory() . '/inc/template-tags.php';
[352] Fix | Delete
[353] Fix | Delete
/**
[354] Fix | Delete
* Customizer additions.
[355] Fix | Delete
*/
[356] Fix | Delete
require get_template_directory() . '/inc/customizer.php';
[357] Fix | Delete
[358] Fix | Delete
/**
[359] Fix | Delete
* Block Patterns.
[360] Fix | Delete
*/
[361] Fix | Delete
require get_template_directory() . '/inc/block-patterns.php';
[362] Fix | Delete
[363] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function