Adams 主题 functions.php 修改记录

/ 960 阅读 / 0

好记性不如烂笔头,免得到时候又找不到需要的痕迹信息。结合之前做的一些 CSS 修改调整,将修改的内容在操作上整合到 functions.php 里面,间接提升效率,也为以后主题升级或者更新后覆盖代码做准备。


具体代码如下:

// 让 WordPress 支持上传 WebP 格式的图片
function bzg_filter_mime_types( $array ) {
    $array['webp'] = 'image/webp';
    return $array; 
}
add_filter( 'mime_types', 'bzg_filter_mime_types', 10, 1 );
// 让 WordPress 媒体库可以看到 WebP 格式的图片
function bzg_file_is_displayable_image($result, $path) {
    $info = @getimagesize( $path );
    if($info['mime'] == 'image/webp') {
        $result = true;
    }
    return $result;
}
add_filter( 'file_is_displayable_image', 'bzg_file_is_displayable_image', 10, 2 );

//添加 HTML 编辑器自定义快捷标签按钮
add_action('after_wp_tiny_mce', 'my_quicktags');
function my_quicktags($mce_settings) {
?>
<script type="text/javascript">
QTags.addButton( 'black', ' 后面的是自定义按钮--->', "", "" );
QTags.addButton( 'wp_page', ' 分页按钮', "<!--nextpage-->\n", "" );
QTags.addButton( 'btn-zd', ' 直达按钮', '<a class="btn-zd" href="#" target="_blank" rel="nofollow">', '</a>' ); 
QTags.addButton( 'btn-dl', ' Download', '<a class="btn-dl" href="#" target="_blank" rel="nofollow">', '</a>' );  
QTags.addButton( 'btn-dh', ' 提示&警告', '<p class="btn-dh">', '</p>' ); 
QTags.addButton( 'bzyy', ' 标注引用', '<p class="bzyy">', '</p>' ); 
QTags.addButton( 'btk1', ' 标题&引用', '<p class="btk1">', '</p>' ); 
QTags.addButton( 'step', ' 步骤标签', '<p class="step">', '</p>' ); 
function my_quicktags() {
}
</script>
<?php
}
404 Not Found

404

Not Found

The resource requested could not be found on this server!


Proudly powered by LiteSpeed Web Server

Please be advised that LiteSpeed Technologies Inc. is not a web hosting company and, as such, has no control over content found on this site.