WordPresschrome上的自定义预览样式

我要把头发拔出来。我正在添加自定义功能,让我的女朋友风格的网站,我正在建设。她希望能够改变菜单的背景色,考虑到我已经和其他几个div在这个主题上做了这件事,我想这不是什么大问题;但是,她使用chrome,我使用firefox。 我的自定义选项可以修改菜单项背景的样式,我用来抓取主题的样式标签在pageload上也可以很好地工作——在firefox和chrome中都可以。预览在firefox中也可以正常工作,包括选择性刷新和其他一切。但是,当自定义程序在chrome上使用时,选择性刷新会正确地获取样式标记,然后完全打断自定义程序自定义的所有其他样式元素。 如果您修改了另一个控件,设置将恢复,但修改了与其中一个菜单项相关的控件,它将再次中断所有内容(我所说的所有内容都是样式标记,而不是<;链接>;中的任何内容);.css文件类似样式.css例如)。 由于循环遍历所有菜单项并设置所有这些项(对于自定义程序和内联样式标记)会使代码相当冗长,因此我将一个菜单项硬编码到代码中,以便为大家提供一个示例: $wp_customize->add_setting( = => \"menu-item-8_bg_color\")));$wp_customize->selective_refresh->add_partial( => True));function menu_items_style() {return \" I have tried escaping out of php, echoing echoing, and (as above) simply returning out the style tag of menu_items_style(). Also remember, this is a simplified version of what my code is since it requires me to loop through menus and all of that junk. I have simplified this to hardcode the value of a menu-item (which, can obviously change if you add/delete menu-items from a menu) only for the purposes of debugging. I don\"t think the rest of that code has anything to do with this because I\"m experiencing exactly the same thing in chrome (but no problem in firefox). Another point to mention, unless I\"m very foolish, I\"m really confident that the style tag is correct here, because–in chrome–if I simply edit the style element (in the chrome inspector), change nothing, and then exit editing the style element, then Chrome starts displaying all of the styles correctly again. I can even edit a different style element and chrome then updates accordingly. Again, this is ONLY happening in Chrome, and ONLY with the menu-item control(s). All other controls work just fine in the customizer and even in chrome. I\"ve even hardcoded in the background css attribute to something like red, and it still breaks all styles. There are no errors from the javascript console and no errors from php debugging or in debug.log (both of which are obviously turned on). And chrome is definitely getting the updated inline style tag in the preview window, it just breaks everything. I have asked about this on IRC and was recommended to make the post here. My gut tells me that this is a chrome problem (since it works on firefox), but its really driving me up the wall as to why other customize controls work just fine on chrome (that modify background color like this as well). I simply just want to hear if anyone else can replicate the problem to know if this is my own stupidity or if this is a problem with chrome. Thanks for your time. - This topic was modified 10 months ago by nicholasrees. I forgot to add the code that actually defines the section where the menu-item controls sit: $wp_customize->add_section( \"content\",>) ); 很抱歉发表了这么长的文章,我不知道如何简洁地解释这个问题。 也许是语法错误,Chrome没有Firefox那么宽容。 有几件事似乎值得怀疑,但最大的一件事是使用了partial。当您可以简单地使用JS并更改样式时,为什么要使用PHP来生成CSS呢?我发现用CSS变量做颜色是最简单的方法。您会得到即时反馈,而且样式很容易输出到前端。 其他不太一致的内容: 节名是\"菜单\"还是\"内容\"? 消毒回调(它是否包括#或不包括?) True值应该是true? 呈现回调是一个匿名函数,它只调用一个函数(为什么?) background速记重置背景的所有属性 您可以阅读我的主题代码https://wordpress.org/themes/twenty8teen,它使用CSS变量来表示颜色(和其他东西),https://themes.trac.wordpress.org/browser/twenty8teen/20200614/style.css#L334 JS在自定义程序中显示,https://themes.trac.wordpress.org/browser/twenty8teen/20200614/js/customizer preview.js#L29 用于为前端生成CSS的PHP函数,https://themes.trac.wordpress.org/browser/twenty8teen/20200614/functions.php#L464 我使用partial作为标题图像和博客名称。 https://themes.trac.wordpress.org/browser/twenty8teen/20200614/inc/theme customizer.php#L468我使用PHP来生成css,因为在wp_customize_manager下的partials只需输入一个向管理器调用函数,而不必将js排队。此外,您可以编写整个定制只有php,这似乎显然对我有利。我不太明白\"为什么\"这个问题。问我为什么要做某件事实际上并不能解决我遇到的问题。 你说得对,我复制了不正确的部分,在控制参数中确实有一个定义为\"菜单\"的部分。如果这是我的问题,那么我将无法看到控件,但这不是我描述的问题。我所描述的问题是chrome破坏了样式标签–不仅是这个标签,还有站点上的所有标签。 清理回调是针对十六进制代码的。我还使用wpu customizeu coloru控件,所以sanitize回调和color控件应该以这种方式一起使用。我的所有其他控件都同时使用这些函数,没有问题。另外,我可以验证是否将正确的背景值添加到style标记中—只是chrome不会出于某种原因显示它们。 关于布尔值,请参阅PHP布尔值文档: \"若要指定布尔值,请使用常量TRUE或FALSE。这两个函数都不区分大小写。 关于匿名函数,我很难简单地将函数名传递给renderu回调。我不知道问题出在哪里,在这两种情况下,wordpress主题手册基本上做了相同的事情(不过,将参数传递到函数中)。我不明白为什么修改它会改变我的功能。 是的,这正是我想做的。获取已为#menu-item-8定义的任何背景属性,并将其替换为get#theme _mod(\"menu-item-8\")中的值。 也许您可以检查一下样式标记的无效内容? 函数菜单项u style(){return\"<;style> 在渲染部分时也会打断样式。一切

admin_action_{$_REQUEST[‘action’]}

do_action( "admin_action_{$_REQUEST[‘action’]}" )动作钩子::在发送“Action”请求变量时激发。Action Hook: Fires when an ‘action’ request variable is sent.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$_REQUEST['action']引用从GET或POST请求派生的操作。源码(Source)更新版本源码位置使用被使用2.6.0 wp-admin/admin.php:...

日期:2020-09-02 17:44:16 浏览:1159

admin_footer-{$GLOBALS[‘hook_suffix’]}

do_action( "admin_footer-{$GLOBALS[‘hook_suffix’]}", string $hook_suffix )操作挂钩:在默认页脚脚本之后打印脚本或数据。Action Hook: Print scripts or data after the default footer scripts.目录锚点:#说明#参数#源码说明(Description)钩子名的动态部分,$GLOBALS['hook_suffix']引用当前页的全局钩子后缀。参数(Parameters)参数类...

日期:2020-09-02 17:44:20 浏览:1060

customize_save_{$this->id_data[‘base’]}

do_action( "customize_save_{$this-&gt;id_data[‘base’]}", WP_Customize_Setting $this )动作钩子::在调用WP_Customize_Setting::save()方法时激发。Action Hook: Fires when the WP_Customize_Setting::save() method is called.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_data...

日期:2020-08-15 15:47:24 浏览:800

customize_value_{$this->id_data[‘base’]}

apply_filters( "customize_value_{$this-&gt;id_data[‘base’]}", mixed $default )过滤器::过滤未作为主题模式或选项处理的自定义设置值。Filter Hook: Filter a Customize setting value not handled as a theme_mod or option.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分,$this->id_date['base'],指的是设置...

日期:2020-08-15 15:47:24 浏览:888

get_comment_author_url

过滤钩子:过滤评论作者的URL。Filter Hook: Filters the comment author’s URL.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/comment-template.php:32610...

日期:2020-08-10 23:06:14 浏览:925

network_admin_edit_{$_GET[‘action’]}

do_action( "network_admin_edit_{$_GET[‘action’]}" )操作挂钩:启动请求的处理程序操作。Action Hook: Fires the requested handler action.目录锚点:#说明#源码说明(Description)钩子名称的动态部分$u GET['action']引用请求的操作的名称。源码(Source)更新版本源码位置使用被使用3.1.0 wp-admin/network/edit.php:3600...

日期:2020-08-02 09:56:09 浏览:873

network_sites_updated_message_{$_GET[‘updated’]}

apply_filters( "network_sites_updated_message_{$_GET[‘updated’]}", string $msg )筛选器挂钩:在网络管理中筛选特定的非默认站点更新消息。Filter Hook: Filters a specific, non-default site-updated message in the Network admin.目录锚点:#说明#参数#源码说明(Description)钩子名称的动态部分$_GET['updated']引用了非默认的...

日期:2020-08-02 09:56:03 浏览:855

pre_wp_is_site_initialized

过滤器::过滤在访问数据库之前是否初始化站点的检查。Filter Hook: Filters the check for whether a site is initialized before the database is accessed.目录锚点:#源码源码(Source)更新版本源码位置使用被使用 wp-includes/ms-site.php:93910...

日期:2020-07-29 10:15:38 浏览:825

WordPress 的SEO 教学:如何在网站中加入关键字(Meta Keywords)与Meta 描述(Meta Description)?

你想在WordPress 中添加关键字和meta 描述吗?关键字和meta 描述使你能够提高网站的SEO。在本文中,我们将向你展示如何在WordPress 中正确添加关键字和meta 描述。为什么要在WordPress 中添加关键字和Meta 描述?关键字和说明让搜寻引擎更了解您的帖子和页面的内容。关键词是人们寻找您发布的内容时,可能会搜索的重要词语或片语。而Meta Description则是对你的页面和文章的简要描述。如果你想要了解更多关于中继标签的资讯,可以参考Google的说明。Meta 关键字和描...

日期:2020-10-03 21:18:25 浏览:1695

谷歌的SEO是什么

SEO (Search Engine Optimization)中文是搜寻引擎最佳化,意思近于「关键字自然排序」、「网站排名优化」。简言之,SEO是以搜索引擎(如Google、Bing)为曝光媒体的行销手法。例如搜寻「wordpress教学」,会看到本站的「WordPress教学:12个课程…」排行Google第一:关键字:wordpress教学、wordpress课程…若搜寻「网站架设」,则会看到另一个网页排名第1:关键字:网站架设、架站…以上两个网页,每月从搜寻引擎导入自然流量,达2万4千:每月「有机搜...

日期:2020-10-30 17:23:57 浏览:1298