【问题标题】:wordpress external javascript file for inline editor plugin?用于内联编辑器插件的wordpress外部javascript文件?
【发布时间】:2010-02-09 11:59:23
【问题描述】:

你好 php wordpress 人,

我正在为 wordpress 使用内联编辑器插件 我知道出于 seo 的目的,最好确保这些是外部文件。 当我在浏览器中查看源代码时,我可以看到页面代码中显示了用于内联编辑器插件的 javascript。

有没有办法在 wordpress 框架内将其设为外部 js 文件,还是必须在页面内才能使插件工作?

感谢您的帮助

问候 朱迪

有人知道这是从哪里来的吗?我在我的其他网站上没有看到它,所以它必须来自不同的插件?

<script type="text/javascript">
/* <![CDATA[ */
    var ileNicEditor;
    function startEditing(postId) {
        jQuery("#ileEditLink"+postId).hide(); 
        jQuery("#ileEditButton-"+postId).hide();
        jQuery("#ileCancelButton-"+postId).show();
        ileCreateNicEditor(postId);
    }
    function ileCreateNicEditor(postId) {
        jQuery.ajax({async:false,
                     type:"POST",
                     url:"http://fr.com/wp-content/plugins/inline-editor/ajax-content.php",
                     data:"id="+postId,
                     success:function(data){
                        jQuery("#ileContent-"+postId).html(data);
                     }
                     });
        ileNicEditor = new nicEditor({fullPanel:true,
                                      iconsPath:"http://fr.com/wp-content/plugins/inline-editor/nicEditorIcons.gif",
                                      onSave:function(content,id,instance){ileSave(postId,content)}
                                     }).panelInstance("ileContent-"+postId,{hasPanel:true});;
        jQuery("#ileCancelButton"+postId).show();
    }
    function ileSave(postId,content){
        jQuery.post("http://fr.com/wp-content/plugins/inline-editor/ajax-save.php",
                    {"id":postId,
                     "content":content},
                     function(data){
                         alert(data.message)
                         jQuery("#ileCancelButton-"+postId).click();
                     },
                     "json");
    }
/* ]]> */

</script>

【问题讨论】:

    标签: wordpress editor plugins inline


    【解决方案1】:

    这将由插件作者编写它的方式引起,最简单的选择是与作者联系,看看插件是否仍在维护,并询问他们是否会考虑将 javascript 移动到外部样式表。

    如果你想自己做,那么你没有理由不能删除内联代码并创建一个外部 javascript 文件以包含在页面中,但这需要你对修改插件充满信心,因为有wordpress 没有简单的方法将其移动到外部样式表。

    【讨论】:

      【解决方案2】:

      您似乎在询问 WordPress 是否可以处理使用外部 JS 文件而不是将其嵌入脚本标签之间。如果这是您的问题,那么可以,只需打开主题的 header.php 并使用以下命令包含该文件:

      <script src="http://other-site.com/script.js" type="text/javascript"></script>
      

      与任何其他脚本包括相同。 WordPress 可以正常工作。

      【讨论】:

      • 我知道如何为主题创建外部文件,但是为什么我在浏览器中查看源时插件会将其添加到页面中?
      猜你喜欢
      • 2010-10-09
      • 2012-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-03
      • 1970-01-01
      • 1970-01-01
      • 2016-07-29
      相关资源
      最近更新 更多