文件操作 - functions.php
返回文件管理
返回主菜单
删除本文件
文件: /storage/v12552/i2kdefense/public_html/wp-content/themes/flatsome-child/functions.php
编辑文件内容
<?php // Add custom Theme Functions here /*function your_theme_enqueue_styles() { $parent_style = 'parent-style'; wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css'); wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array($parent_style)); } add_action('wp_enqueue_scripts', 'your_theme_enqueue_styles');*/ add_action('init', 'remove_filters_actions'); function remove_filters_actions(){ remove_action('wp_head', 'viewport_meta', 1); } /* Add meta viewport */ add_action( 'wp_head', 'add_viewport_meta_tag' , '1' ); function add_viewport_meta_tag() { echo '<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" scalable="yes" maximum-scale="{2 or higher}">'; } /** * Enables the HTTP Strict Transport Security (HSTS) header in WordPress. */ add_action( 'send_headers', 'enable_strict_transport_security_hsts_header_wordpress' ); function enable_strict_transport_security_hsts_header_wordpress() { header( 'Strict-Transport-Security: max-age=31536000; includeSubDomains; preload' ); } /* custom script in header */ add_action('wp_head', 'add_custom_script', 10); function add_custom_script(){ ?> <script type="text/javascript"> jQuery(document).ready(function(){ setTimeout(function(){ if(jQuery('.zsiq_flt_rel').length > 0){ jQuery('.zsiq_flt_rel').attr('role', 'button'); jQuery('.zsiq_flt_rel').attr('tabindex', '0'); } }, 2000); if(jQuery('.quote-btn').length > 0){ jQuery('.quote-btn').attr('role', 'button'); } if(jQuery('.header-bg-image').length > 0){ jQuery('.header-bg-image').attr('aria-label', 'Background Image'); jQuery('.header-bg-image').attr('role', 'img'); } if(jQuery('.bg.bg-fill').length > 0){ jQuery('.bg.bg-fill').attr('aria-label', 'Background Image'); jQuery('.bg.bg-fill').attr('role', 'img'); } if(jQuery('.icon-phone').length > 0){ jQuery('.icon-phone').attr('role', 'none'); } if(jQuery('.icon-angle-down').length > 0){ jQuery('.icon-angle-down').attr('role', 'none'); } }); </script> <?php } /* Change Author URL */ add_filter( 'request', 'wpse_request' ); function wpse_request( $query_vars ){ if ( array_key_exists( 'author_name', $query_vars ) ) { global $wpdb; $author_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='nickname' AND meta_value = %s", $query_vars['author_name'] ) ); if ( $author_id ) { $query_vars['author'] = $author_id; unset( $query_vars['author_name'] ); } } return $query_vars; } /* replacing the standard author part (indicated by $author_nicename) with the nickname */ add_filter( 'author_link', 'wpse_author_link', 10, 3 ); function wpse_author_link( $link, $author_id, $author_nicename ){ $author_nickname = get_user_meta( $author_id, 'nickname', true ); if ( $author_nickname ) { $new_slug = str_replace(' ', '-', strtolower($author_nickname)); $new_slug = str_replace('_', '-', $new_slug); $link = str_replace( $author_nicename, $new_slug, $link ); } return $link; } /* Changing the data that forms the author URL */ add_action( 'user_profile_update_errors', 'wpse_set_user_nicename_to_nickname', 10, 3 ); function wpse_set_user_nicename_to_nickname( &$errors, $update, &$user ){ if ( ! empty( $user->nickname ) ) { $user_nickname = str_replace(' ', '-', strtolower($user->nickname)); $user_nickname = str_replace('_', '-', $user_nickname); $user_displayname = str_replace(' ', '-', strtolower($user->display_name)); $user_displayname = str_replace('_', '-', $user_displayname); $user->user_nicename = sanitize_title( $user_nickname, $user_displayname ); } } /* Set canonical url for Alternate page with proper canonical tag */ add_filter( 'rank_math/frontend/canonical', function( $canonical ) { global $wp; if(isset($_SERVER['QUERY_STRING']) && $_SERVER['QUERY_STRING'] != ''){ $New_canonical = $canonical; return $New_canonical; } else { return $canonical; } });
修改文件时间
将文件时间修改为当前时间的前一年
删除文件