我的父主题中有一个文件夹,它覆盖了一个插件的外观.如果我不将该文件夹复制到我的子主题,则子主题的外观将与父主题不同.
有可能以某种方式,在子主题的functions.php文件中,包含该文件夹(使子主题使用该文件夹).我搜遍了所有但没有找到任何东西.
使子主题看起来像父(我可以修改)的唯一方法是将该文件夹复制到子主题文件夹中.
我试过了
$theme_folder = scandir(get_template_directory_uri().'/folder');
Run Code Online (Sandbox Code Playgroud)
但我收到以下警告
Warning: scandir(...): failed to open dir: not implemented in \functions.php on line 20
Warning: scandir(): (errno 9): Bad file descriptor in \functions.php on line 20
Run Code Online (Sandbox Code Playgroud)
我读过这可能是因为服务器上缺少权限.
我有一个标题,菜单和搜索标题.当我在桌面上时,我按顺序显示所有元素,但如果我的窗口宽度小于980px,则菜单隐藏(获取切换),徽标与徽标分离nav并附加.如果宽度更大,徽标将再次分离并附加到DOM中的旧位置.
$(window).on('resize', function() {
if ($(window).width() < 980) {
$('#search-container').detach().insertAfter('#logo');
} else {
$('#search-container').detach().insertAfter('#main_menu');
}
});Run Code Online (Sandbox Code Playgroud)
#logo {
display: block;
margin: 10px auto 15px;
text-align: center;
}
#search-container {
display: inline-block;
vertical-align: top;
margin-top: 8px;
background: #fff;
border-radius: 5px;
padding: 1px 10px;
}
#search-container .header_search {
display: inline-block;
line-height: 6px;
}
#search-container input {
border: 0;
background-color: transparent;
font-style: italic;
color: rgb(114, 114, 114);
color: rgba(114, 114, 114, 0.5);
font-size: 14px;
line-height: 25px;
font-weight: 400;
text-align: left;
display: …Run Code Online (Sandbox Code Playgroud)我正在尝试创建一个子主题。父主题有一个 style.css 和所有,我在看wp_enqueue_style()函数,它说你可以引入依赖项。所以这意味着主题自己style.css可以是活动的,并且在我的子主题中,如果我在 style.css 中指定相同的规则,它应该覆盖它。
但是依赖是一个句柄数组。我如何找到这些句柄?
wp_enqueue_style( 'mytheme-style', get_stylesheet_directory_uri().'/style.css', array('main_css') );
Run Code Online (Sandbox Code Playgroud)
我尝试了上面的方法,但它只从子主题加载 style.css,而不是从父主题加载。
我在哪里可以找到这些手柄?
编辑:
我找到了重现句柄和脚本的代码:
function wpa54064_inspect_scripts() {
global $wp_scripts;
foreach( $wp_scripts->queue as $handle ) :
echo $handle,' ';
endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_scripts' );
function wpa54064_inspect_style() {
global $wp_styles;
foreach( $wp_styles->queue as $handle ) :
echo $handle,' ';
endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_style' );
Run Code Online (Sandbox Code Playgroud)
但它仍然无法像我想象的那样工作。
wpml-config.xmlWPML 中文件的确切用途是什么?特别是如果我启用了翻译管理和字符串翻译加载项?使用那些我只扫描主题的插件,插件会找到所有可翻译的字符串,然后我就可以翻译它们了。而且我在翻译页面时会复制页面等。
那么该.xml文件的确切目的是什么?我有点不解:\
教育编辑
在使用wpml进行更多工作之后,我还发现,如果创建了一个版权文本,该文本将显示在定制器的页脚中,那么使用wpml转换该文本的唯一方法就是使用wpml-config.xml文件。因此,基本上,对于主题中任何基于文本的输入字段,您都需要向wpml指定它可以是可翻译文本。您可以这样:
<wpml-config>
<admin-texts>
<key name="blogname" />
<key name="blogdescription" />
<key name="theme_mods_language_textdomain">
<key name="copyright" />
</key>
</admin-texts>
</wpml-config>
Run Code Online (Sandbox Code Playgroud)
您需要在其中指定语言textdomain的地方(或主题名称,目前还不确定100%)。在内部定位具有输入字段(个'type' => 'text'字段)的设置名称。
我确认可以对在前端输出内容的元框进行相同的操作,但是您需要在中使用其他标签.xml。
最近我在wordpress上发出了此警告错误消息:
警告:hash_equals():预期的user_string是一个字符串,在1662行的C:\ xampp3\htdocs\Plurielles\wordpress\wp-includes\pluggable.php中给出null
警告:hash_equals():预期的user_string是一个字符串,在1668行的C:\ xampp3\htdocs\Plurielles\wordpress\wp-includes\pluggable.php中给出null
它在我的网站上禁用了很多功能(添加图像等等......)我一直在php文件中查找这两行,它们是:
第1662行:
if ( hash_equals( $expected, $nonce ) ) {
return 1;
}
Run Code Online (Sandbox Code Playgroud)
1668行:
if ( hash_equals( $expected, $nonce ) ) {
return 2;
}
Run Code Online (Sandbox Code Playgroud)
你知道我怎么解决它吗?我是PHP的新手,所以我很抱歉,如果这很容易解决(你可以扔我摇滚).
我正在创建一个每周工作的表日历.日历看起来像这样
我使用我在这里找到的代码来设置标题日期.我的代码看起来像这样:
$dt = new DateTime;
$dt->setISODate($dt->format('o'), $dt->format('W'));
$year = $dt->format('o');
$week = $dt->format('W');
$current_time = time();
$return .= '<table class="reservation_time_table">
<tr><th>'.esc_html__('Hours', 'time_reservation').'</th>';
do {
$return .= '<th>' . $dt->format('l') . '<br>' . $dt->format('d M Y') . '</th>';
$dt->modify('+1 day');
} while ($week == $dt->format('W'));
$return .= '</tr>';
for ($hour=8; $hour < 23 ; $hour++) {
$return .= '<tr>';
$return .= '<th>'.$hour.':00</th>';
for ($i=0; $i <7 ; $i++) {
$return .= '<td data-reservation_time=""></td>';
}
$return .= '</tr>';
} …Run Code Online (Sandbox Code Playgroud) 我创建了自己的孩子主题.一切都很好,除了我似乎无法取消注册.
$这是类TC_footer_main ,下面的代码在__construct
add_action ( '__colophon' , array( $this , 'tc_colophon_center_block' ), 20 );
Run Code Online (Sandbox Code Playgroud)
我尝试了几次删除操作但没有成功.我只是想改变/删除页脚:
remove_action( '__colophon' , 'tc_colophon_center_block' , 55);
要么
remove_action( '__colophon' , array('TC_footer_main','tc_colophon_center_block') , 55);
我也试过了
remove_action( '__colophon' , TC_footer_main::$instance->tc_colophon_center_block() , 55);
但是,由于TC_footer_main我的functions.php文件运行时没有加载,因此引发了错误.
在WordPress中,我正在创建一个向用户发送电子邮件的插件。为此,我正在使用WordPress cron工作。因此,基本上,它的工作就是每小时发送一封电子邮件给用户。所以我的代码看起来像这样
public function __construct() {
add_action('init', array( $this, 'send_emails_to_users') );
add_action('cliv_recurring_cron_job', array( $this, 'send_email') );
}
public function send_emails_to_users() {
if(!wp_next_scheduled('cliv_recurring_cron_job')) {
wp_schedule_event (time(), 'hourly', 'cliv_recurring_cron_job');
}
}
public function send_email() {
//send email code goes here
}
Run Code Online (Sandbox Code Playgroud)
在这里,一切看起来不错,但不会发送电子邮件。
如果我这样编写代码
public function __construct() {
add_action('head', array( $this, 'send_email') );
}
Run Code Online (Sandbox Code Playgroud)
然后它发送电子邮件。但是问题出在这里,它在每次页面加载或用户访问站点时都会发送电子邮件。
这就是为什么我想wp_schedule_event每小时都发送电子邮件。
那么有人可以告诉我如何解决这个问题吗?
任何建议或帮助将是非常可观的。
在使用节点脚本进行一些搜索替换后,我试图重命名一个文件夹(WordPress 主题),但该文件夹的重命名似乎失败了。
我想要这个
public_html/wp-content/my_theme/
Run Code Online (Sandbox Code Playgroud)
成为
public_html/wp-content/something_other/
Run Code Online (Sandbox Code Playgroud)
文件夹的名称取自提示(这部分有效,因为文件中的搜索替换工作正常)。
脚本看起来像这样
const fs = require('fs');
const path = require('path');
const rootDir = path.join(__dirname, '..');
// themePackageName is taken from the prompt and is defined
if (themePackageName !== 'my_theme') {
fs.renameSync(`${rootDir}/wp-content/my_theme/`, `${rootDir}/wp-content/${themePackageName}/`, (err) => {
if (err) {
throw err;
}
fs.statSync(`${rootDir}/wp-content/${themePackageName}/`, (error, stats) => {
if (error) {
throw error;
}
console.log(`stats: ${JSON.stringify(stats)}`);
});
});
}
Run Code Online (Sandbox Code Playgroud)
这基本上是从这里获取的
我收到的错误是
fs.js:781
return binding.rename(pathModule.toNamespacedPath(oldPath),
^
Error: ENOENT: no such file or directory, rename '/vagrant-local/www/me/wp-boilerplate/public_html/wp-content/my_theme/' -> …Run Code Online (Sandbox Code Playgroud) 我正在使用 PHPUnit 在我的 WordPress 插件上运行集成测试,当我生成覆盖率和clover.xml文件时,文件名属性clover.xml将具有我的文件的绝对路径,例如
<file name="/Users/denis/vagrant-local/www/project/public_html/wp-content/plguins/my-plugin/file-that-is-tested.php">
Run Code Online (Sandbox Code Playgroud)
由于我需要将此文件发送到 SonarQube,因此每次发送到 SonarQube 时我都需要修改此文件,以便我只有相对路径(从wp-config文件夹开始)
<file name="wp-content/plguins/my-plugin/file-that-is-tested.php">
Run Code Online (Sandbox Code Playgroud)
如果我发送第一个版本,SonarQube 会将代码覆盖率报告为 0.0%,如果我发送另一个版本,它将显示一些覆盖率(它与 PHPUnit 创建的不同,但这并不重要)。
有没有办法在 PHPUnit 配置中指定这个文件名属性,或者我每次运行测试时都需要运行一个 bash 脚本来删除这个额外的部分吗?
该phpunit.xml.dist如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
beStrictAboutCoversAnnotation="true"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
verbose="true"
>
<testsuites>
<testsuite name="integration">
<directory prefix="test-" suffix=".php">./tests/integration/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>./</directory>
<exclude>
<directory>./node_modules</directory>
<directory>./vendor</directory>
<directory>./tests</directory>
<directory suffix=".php">./src/old</directory>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="tests/_reports/coverage" lowUpperBound="35" highLowerBound="80" />
<log …Run Code Online (Sandbox Code Playgroud)