编程技术记录

世界你好!

GuCherry Blog Theme自身是支持在不修改代码的情况下自定义网页页脚文案的,只不过灵活度不够。
该主题footer部分代码在wordpress安装目录/wp-content/themes/gucherry-blog/footer.php文件中,位置如下:

//该主题footer部分代码在<code>wordpress安装目录/wp-content/themes/gucherry-blog/footer.php</code>文件中,位置如下:

<?php 
$footer_copyright_text = get_theme_mod( 'gucherry_blog_site_footer_copyright_text' );
if( !empty( $footer_copyright_text ) ) {
   /* translators: 1: Copyright Text 2: Theme name, 3: Theme author. */
  printf( esc_html__( '%1$s %2$s by %3$s','gucherry-blog' ), $footer_copyright_text, 'GuCherry Blog', '<a href="'. esc_url( 'https://everestthemes.com' ) . '">Everestthemes</a>' );
 } else {
    /* translators: 1: Theme name, 2: Theme author. */
   printf( esc_html__( '%1$s by %2$s', 'gucherry-blog' ), 'GuCherry Blog', '<a href="'. esc_url( 'https://everestthemes.com' ) . '">Everestthemes</a>' );
}
 ?> 

重点在$footer_copyright_text = get_theme_mod( 'gucherry_blog_site_footer_copyright_text' );,其返回值是我们需要修改的文案。

全目录搜索寻找关键词gucherry_blog_site_footer_copyright_text,按图索骥就好。
应能找到
wordpress安装目录/wp-content/themes/gucherry-blog/inc/customizer/functions/customizer-fields.php

//Option : Footer Copyright Text
$wp_customize->add_setting( 'gucherry_blog_site_footer_copyright_text', array(
    'sanitize_callback'        => 'gucherry_blog_sanitize_copyright_credit',
    'default'                  => '',
) );

$wp_customize->add_control( 'gucherry_blog_site_footer_copyright_text', array(
    'label'                    => esc_html__( 'Copyright Text', 'gucherry-blog' ),
    'description'              => esc_html__( 'You can use <a> & <span> tags with the copyright and credit text.', 'gucherry-blog' ),
    'section'                  => 'gucherry_blog_site_footer_section',
    'type'                     => 'text',
) );

从代码中,可以看到作者只允许两个标签。

继续搜索gucherry_blog_sanitize_copyright_credit

应能找到
wordpress安装目录/wp-content/themes/gucherry-blog/inc/customizer/functions/sanitize-callback.php

if ( !function_exists('gucherry_blog_sanitize_copyright_credit') ) :

    function gucherry_blog_sanitize_copyright_credit( $input ) {

        $allowed_tags = array(
            'a' => array(
                'href' => array(),
                'title' => array(),
                '_target' => array(),
            ),
            'span' => array(),
        );

        return wp_kses( $input, $allowed_tags );
    }

endif;

再次看到作者确实只允许两个标签.
好了,限制代码找到了,那么修改就简单了。

© Beli. All Rights Reserved.