文件操作 - functions.php
返回文件管理
返回主菜单
删除本文件
文件: /storage/v12552/i2kairpad/public_html/wp-content/themes/astra-child/functions.php
编辑文件内容
<?php /** * Astra Child Theme functions and definitions * * @link https://developer.wordpress.org/themes/basics/theme-functions/ * * @package Astra Child * @since 1.0.0 */ /** * Define Constants */ define( 'CHILD_THEME_ASTRA_CHILD_VERSION', time()); /** * Enqueue styles */ function child_enqueue_styles() { wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' ); //wp_enqueue_style( 'astra-child-theme-css', get_stylesheet_directory_uri() . '/style.min.css', array('astra-theme-css'), CHILD_THEME_ASTRA_CHILD_VERSION, 'all' ); } add_action( 'wp_enqueue_scripts', 'child_enqueue_styles', 15 ); /** * 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' ); } /** * Modify Post pages title */ /*add_action('init', 'remove_hooks'); function remove_hooks(){ if(is_singular('post')){ remove_action('wp_head', '_wp_render_title_tag', 1); } }*/ /*add_action( 'wp_head', 'post_render_title_tag', 1); function post_render_title_tag(){ if (is_singular('post')) { echo "<title> i2k AirPad: " . get_the_title() . "</title>"; } }*/ add_action('wp_head', 'custom_javascript', 10); function custom_javascript(){ ?> <script type="text/javascript"> jQuery(document).ready(function(){ if(jQuery(".premium-image-hotspots-main-icons").length > 0){ jQuery(".premium-image-hotspots-main-icons").attr('role', 'button'); jQuery(".premium-image-hotspots-main-icons").attr('aria-label', 'tooltip'); jQuery(".premium-image-hotspots-main-icons").attr('tabindex', '0'); } if(jQuery("span.sub-arrow i.fa-caret-down").length > 0){ jQuery("span.sub-arrow i.fa-caret-down").attr('role', 'none'); } }); </script> <?php } add_filter( 'nav_menu_link_attributes', function ( $atts, $item, $args ) { if ( 1765 === $item->ID ) { $atts['role'] = 'button'; } return $atts; }, 10, 3 ); /* Programtically add Async to styles and scripts */ add_filter('style_loader_tag', 'add_async_attribute', 10, 2); function add_async_attribute($html, $handle) { $styles_to_async = array('google-fonts-1'); if (!in_array($handle, $styles_to_async)) { return $html; } else { return str_replace('href', ' async="async" href', $html); } return $html; } /* 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 ); } } add_filter('get_avatar', 'set_gravatar_alt'); function set_gravatar_alt($bloggerpilotGravatar) { if (have_comments()) { $alt = get_comment_author(); } else { $alt = get_the_author_meta('display_name'); } $bloggerpilotGravatar = str_replace('alt=\'\'', 'alt=\'Avatar for ' . $alt . '\'', $bloggerpilotGravatar); return $bloggerpilotGravatar; }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件