php 如果在Genesis主题中启用了JavaScript,则添加一个小内联脚本以将`js`类附加到body标记

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 如果在Genesis主题中启用了JavaScript,则添加一个小内联脚本以将`js`类附加到body标记相关的知识,希望对你有一定的参考价值。

<?php

/**
 * Script sample comes from WP SiteCare's carelib
 * https://github.com/wpsitecare/carelib
 *
 * A simplified version of Gary Jones Genesis JS
 * https://github.com/GaryJones/genesis-js-no-js/
 *
 * This produces what the Genesis Sample Theme does in the
 * 'responsive-menu.js' but moves it to a small inline script that
 * is added after the opening <body> tag.
 * Unlike Gary's sample i've skipped adding a no-js body tag as the
 * Genesis Sample Theme does not include it and all styles tied to a
 * JS interaction are styled with .js
 * 
 * If you use this action, you will need to go into 'responsive-menu.js'
 * and remove line 6 '$( 'body' ).addClass( 'js' );'.
 *
 */

// Add JS after opening <body> to append .js to body tag in Genesis
add_action( 'genesis_before', 'pb_add_js_body_class' );
function pb_add_js_body_class() {

	echo '<script type="text/javascript">document.body.classList.add("js");</script>' . "\n";

}

以上是关于php 如果在Genesis主题中启用了JavaScript,则添加一个小内联脚本以将`js`类附加到body标记的主要内容,如果未能解决你的问题,请参考以下文章

php 禁用HTML5的Genesis和Studiopress主题的帖子信息

php 调整FacetWP的寻呼机html以匹配Genesis标记。这允许它继承Genesis主题样式。与[facetwp pager =“true”]一起使用

css 如何在其他Genesis主题中添加News Pro的移动响应菜单

css 删除Genesis主题中链接周围的虚线

拒绝没有启用 javascript 的浏览器使用我的 php 网站

PHP 在论文主题中启用WordPress正文类功能