草庐IT

php - WordPress PHP Hack 中不允许使用 HTML

coder 2024-04-21 原文

我现在负责我们教会基于 WordPress 的网站。我正在尝试找出对主题选项的这些调整。

基本上,“欢迎消息”和“页脚”中允许使用 HTML,但如果我在其他任何地方使用它,它就可以工作,直到您再次更新,在这种情况下它会中断并且 HTML 被删除。我也想弄清楚如何在事件描述中允许使用 HTML,这样我就可以放置链接,而不是在更新选项中的其他内容后让它们停止。

我正在寻找一些帮助来理解这个 PHP 文件并弄清楚是什么允许 HTML 在一个地方而不是在另一个地方。

主题选项(控制添加文本的 WordPress 管理面板):

<?php

add_action('init','of_options');

if (!function_exists('of_options')) {
function of_options(){

// VARIABLES
$themename = get_theme_data(STYLESHEETPATH . '/style.css');
$themename = $themename['Name'];
$shortname = "fumco";

// Populate OptionsFramework option in array for use in theme
global $of_options;
$of_options = get_option('of_options');

$GLOBALS['template_path'] = get_bloginfo('stylesheet_directory');

//Access the WordPress Categories via an Array
$of_categories = array();  
$of_categories_obj = get_categories('hide_empty=0');
foreach ($of_categories_obj as $of_cat) {
    $of_categories[$of_cat->cat_ID] = $of_cat->cat_name;}
$categories_tmp = array_unshift($of_categories, "Select a category:");    

//Access the WordPress Pages via an Array
$of_pages = array();
$of_pages_obj = get_pages('sort_column=post_parent,menu_order');    
foreach ($of_pages_obj as $of_page) {
    $of_pages[$of_page->ID] = $of_page->post_name; }
$of_pages_tmp = array_unshift($of_pages, "Select a page:");       

// Image Alignment radio box
$options_thumb_align = array("alignleft" => "Left","alignright" => "Right","aligncenter" => "Center"); 

// Image Links to Options
$options_image_link_to = array("image" => "The Image","post" => "The Post"); 

//Testing 
$options_select = array("one","two","three","four","five"); 
$options_radio = array("one" => "One","two" => "Two","three" => "Three","four" => "Four","five" => "Five"); 

//Stylesheets Reader
$alt_stylesheet_path = STYLESHEETPATH . '/styles/';
$alt_stylesheets = array();

if ( is_dir($alt_stylesheet_path) ) {
    if ($alt_stylesheet_dir = opendir($alt_stylesheet_path) ) { 
        while ( ($alt_stylesheet_file = readdir($alt_stylesheet_dir)) !== false ) {
            if(stristr($alt_stylesheet_file, ".css") !== false) {
                $alt_stylesheets[] = $alt_stylesheet_file;
            }
        }    
    }
}

//More Options
$uploads_arr = wp_upload_dir();
$all_uploads_path = $uploads_arr['path'];
$all_uploads = get_option('of_uploads');
$other_entries = array("Select a number:","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19");
$body_repeat = array("no-repeat","repeat-x","repeat-y","repeat");
$body_pos = array("top left","top center","top right","center left","center center","center right","bottom left","bottom center","bottom right");

// Set the Options Array
$options = array();


/* Home page banners set (upto 4 banners with alt, link and target url) */
$options[] = array( "name" => "Home Banners",
                    "type" => "heading");

$options[] = array( "name" => "Banner Image #1",
                                        "desc" => "Upload the banner image. Banner size should be 980x325 pixels. Leave blank if not required.",
                                        "id" => $shortname."_banner01",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the banner image. Leave blank if not required.",
                    "id" => $shortname."_banner01_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Banner",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_banner01_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_banner01_target",
                    "type" => "checkbox");

$options[] = array( "name" => "Banner Image #2",
                                        "desc" => "Upload the banner image. Banner size should be 980x325 pixels. Leave blank if not required.",
                                        "id" => $shortname."_banner02",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the banner image. Leave blank if not required.",
                    "id" => $shortname."_banner02_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Banner",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_banner02_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_banner02_target",
                    "type" => "checkbox");

$options[] = array( "name" => "Banner Image #3",
                                        "desc" => "Upload the banner image. Banner size should be 980x325 pixels. Leave blank if not required.",
                                        "id" => $shortname."_banner03",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the banner image. Leave blank if not required.",
                    "id" => $shortname."_banner03_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Banner",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_banner03_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_banner03_target",
                    "type" => "checkbox");

$options[] = array( "name" => "Banner Image #4",
                                        "desc" => "Upload the banner image. Banner size should be 980x325 pixels. Leave blank if not required.",
                                        "id" => $shortname."_banner04",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the banner image. Leave blank if not required.",
                    "id" => $shortname."_banner04_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Banner",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_banner04_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_banner04_target",
                    "type" => "checkbox");


/* Welcome Message */
$options[] = array( "name" => "Welcome Message",
                    "type" => "heading");                                       
$options[] = array( "name" => "Title",
                                        "desc" => "Enter Title for the welcome text. Use '&lt;span&gt;...&lt;/span&gt; tags for highlight in red.",
                                        "id" => $shortname."_welcome_title",
                                        "std" => "<span>Welcome</span> to First United Methodist Chuch of Orlando.",
                                        "type" => "text"); 
$options[] = array( "name" => "Message",
                    "desc" => "Enter welcome message. You allowed to use HTML tags to style the message.",
                    "id" => $shortname."_welcome_message",
                    "std" => "Come worship and connect with us. We pray that you have a rejuvenating experience. Know that we welcome all seekers of Christ, recognizing that all individuals are unique creations of God. We welcome you &ndash; just as you are. <br />Here, there is a place for everyone.<br />&ldquo;Come and you will see.&rdquo; - John 1:39",
                    "type" => "textarea");


/* Worship Time - Add upto 3 worship times */
$options[] = array( "name" => "Worship Times",
                    "type" => "heading");

$options[] = array( "name" => "Worship Times #1",
                                        "desc" => "Enter title for worship time.",
                                        "id" => $shortname."_worship01_title",
                                        "type" => "text"); 
$options[] = array( "name" => "Date and Time",
                                        "desc" => "Enter worship date and time here. It will displayed in same manner as you write here.",
                                        "id" => $shortname."_worship01_time",
                                        "type" => "text");          
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Worship.",
                                        "id" => $shortname."_worship01_text",
                                        "type" => "text");

$options[] = array( "name" => "Worship Times #2",
                                        "desc" => "Enter title for worship time.",
                                        "id" => $shortname."_worship02_title",
                                        "type" => "text");
$options[] = array( "name" => "Date and Time",
                                        "desc" => "Enter worship date and time here. It will displayed in same manner as you write here.",
                                        "id" => $shortname."_worship02_time",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Worship.",
                                        "id" => $shortname."_worship02_text",
                                        "type" => "text");

$options[] = array( "name" => "Worship Times #3",
                                        "desc" => "Enter title for worship time.",
                                        "id" => $shortname."_worship03_title",
                                        "type" => "text");
$options[] = array( "name" => "Date and Time",
                                        "desc" => "Enter worship date and time here. It will displayed in same manner as you write here.",
                                        "id" => $shortname."_worship03_time",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Worship.",
                                        "id" => $shortname."_worship03_text",
                                        "type" => "text");


/* Upcoming Events - Add upto 3 events */
$options[] = array( "name" => "Upcoming Events",
                    "type" => "heading");

$options[] = array( "name" => "Event #1",
                                        "desc" => "Enter title for events.",
                                        "id" => $shortname."_event01_title",
                                        "type" => "text");
$options[] = array( "name" => "Sub Heading",
                                        "desc" => "Enter sub heading for the event.",
                                        "id" => $shortname."_event01_subheading",
                                        "std" => "",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Event.",
                                        "id" => $shortname."_event01_text",
                                        "type" => "text");
$options[] = array( "name" => "Event #2",
                                        "desc" => "Enter title for events.",
                                        "id" => $shortname."_event02_title",
                                        "type" => "text");
$options[] = array( "name" => "Sub Heading",
                                        "desc" => "Enter sub heading for the event.",
                                        "id" => $shortname."_event02_subheading",
                                        "std" => "",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Event.",
                                        "id" => $shortname."_event02_text",
                                        "type" => "text");
$options[] = array( "name" => "Event #3",
                                        "desc" => "Enter title for events.",
                                        "id" => $shortname."_event03_title",
                                        "type" => "text");
$options[] = array( "name" => "Sub Heading",
                                        "desc" => "Enter sub heading for the event.",
                                        "id" => $shortname."_event03_subheading",
                                        "std" => "",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Event.",
                                        "id" => $shortname."_event03_text",
                                        "type" => "text");

$options[] = array( "name" => "Event #4",
                                        "desc" => "Enter title for events.",
                                        "id" => $shortname."_event04_title",
                                        "type" => "text");
$options[] = array( "name" => "Sub Heading",
                                        "desc" => "Enter sub heading for the event.",
                                        "id" => $shortname."_event04_subheading",
                                        "std" => "",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Event.",
                                        "id" => $shortname."_event04_text",
                                        "type" => "text");
$options[] = array( "name" => "Event #5",
                                        "desc" => "Enter title for events.",
                                        "id" => $shortname."_event05_title",
                                        "type" => "text");
$options[] = array( "name" => "Sub Heading",
                                        "desc" => "Enter sub heading for the event.",
                                        "id" => $shortname."_event05_subheading",
                                        "std" => "",
                                        "type" => "text");
$options[] = array( "name" => "Description",
                                        "desc" => "Enter 2-3 line description for the Event.",
                                        "id" => $shortname."_event05_text",
                                        "type" => "text");


/* Advertisement / Campaign Banners (displayed on home page and sidebar) */
$options[] = array( "name" => "Campaign Banners",
                    "type" => "heading");

$options[] = array( "name" => "Campaign Image #1",
                                        "desc" => "Upload the campaign banner image for the home page. Banner size should be 494x168 pixels.",
                                        "id" => $shortname."_campaign01_image",
                                        "type" => "upload");
$options[] = array( "name" => "Campaign Sidebar Image",
                                        "desc" => "Upload the campaign banner image for the sidebar. Banner size should be 307x86 pixels.",
                                        "id" => $shortname."_campaign01_small",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the campaign image. Leave blank if not required.",
                    "id" => $shortname."_campaign01_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Campaign",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_campaign01_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_campaign01_target",
                    "type" => "checkbox");

$options[] = array( "name" => "Campaign Image #2",
                                        "desc" => "Upload the campaign banner image for the home page. Banner size should be 494x168 pixels.",
                                        "id" => $shortname."_campaign02_image",
                                        "type" => "upload");
$options[] = array( "name" => "Campaign Sidebar Image",
                                        "desc" => "Upload the campaign banner image for the sidebar. Banner size should be 307x86 pixels.",
                                        "id" => $shortname."_campaign02_small",
                                        "type" => "upload");
$options[] = array( "name" => "Alternative Text",
                    "desc" => "Provide alternative text for the campaign image. Leave blank if not required.",
                    "id" => $shortname."_campaign02_alt",
                    "type" => "text");
$options[] = array( "name" => "Link on Campaign",
                    "desc" => "Provide hyperlink url if required.",
                    "id" => $shortname."_campaign02_href",
                    "type" => "text");
$options[] = array( "name" => "Link Target",
                    "desc" => "Open link in new window",
                    "id" => $shortname."_campaign02_target",
                    "type" => "checkbox");


/* Footer address and copyright statement */
$options[] = array( "name" => "Footer Text",
                    "type" => "heading");   
$options[] = array( "name" => "Address",
                                        "desc" => "Enter address which will be displayed in footer. Use HTML tags to format the text.",
                                        "id" => $shortname."_footer_address",
                                        "std" => "<strong>First United Methodist Church of Orlando</strong><br />142 East Jackson Street, Orlando, FL 32801<br />Telephone 407.849.6080 <br />Email: <a href='mailto:Contact@FirstChurchOrlando.org'>Contact@FirstChurchOrlando.org</a>",
                                        "type" => "textarea");
$options[] = array( "name" => "Copyright Text",
                                        "desc" => "Enter copyright text here..",
                                        "id" => $shortname."_footer_copyright",
                                        "std" => "&copy;Copyright2011. First United Methodist Church of Orlando, All right reserved",
                                        "type" => "textarea");

update_option('of_template',$options);                    
update_option('of_themename',$themename);   
update_option('of_shortname',$shortname);

}
}
?>

插入的 HTML 在此处插入模板时不起作用:

    <ul><?php
for ($i=1; $i<=5; $i++) {
  if (get_option('fumco_event0'.$i.'_title')== '') {
    // Do nothing
  } else {

    if (get_option('fumco_event0'.$i.'_title')) {
      echo '<li>';
      echo '<h3>'.get_option('fumco_event0'.$i.'_title').'</h3>';
      echo '<span class="event-datetime">';
      if (get_option('fumco_event0'.$i.'_subheading')) {
        echo get_option('fumco_event0'.$i.'_subheading');
      }
      echo '</span>';
      if (get_option('fumco_event0'.$i.'_text')) {
        echo '<p>'.get_option('fumco_event0'.$i.'_text').'</p>';
      }
      echo '</li>';
    }
  }
}
?></ul>

添加的 HTML 在此位置有效:

<?php if (get_option('fumco_footer_address')) {
      echo get_option('fumco_footer_address');
    } else {
      echo '<strong>First United Methodist Church of Orlando</strong><br />
            142 East Jackson Street, Orlando, FL 32801<br />
            Telephone 407.849.6080 <br />
            Email: <a href="mailto:Contact@FirstChurchOrlando.org">Contact@FirstChurchOrlando.org</a>';
    } ?>

最佳答案

尝试将事件的类型更改为文本区域,如下所示:

$options[] = array( "name" => "Event #1",
                                    "desc" => "Enter title for events.",
                                    "id" => $shortname."_event01_title",
                                    "type" => "textarea");

关于php - WordPress PHP Hack 中不允许使用 HTML,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20010355/

有关php - WordPress PHP Hack 中不允许使用 HTML的更多相关文章

  1. ruby - 如何使用 Nokogiri 的 xpath 和 at_xpath 方法 - 2

    我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div

  2. ruby - 使用 RubyZip 生成 ZIP 文件时设置压缩级别 - 2

    我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看ruby​​zip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d

  3. ruby - 为什么我可以在 Ruby 中使用 Object#send 访问私有(private)/ protected 方法? - 2

    类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc

  4. ruby-on-rails - 使用 Ruby on Rails 进行自动化测试 - 最佳实践 - 2

    很好奇,就使用ruby​​onrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提

  5. ruby - 在 Ruby 中使用匿名模块 - 2

    假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于

  6. ruby - 使用 ruby​​ 和 savon 的 SOAP 服务 - 2

    我正在尝试使用ruby​​和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我

  7. python - 如何使用 Ruby 或 Python 创建一系列高音调和低音调的蜂鸣声? - 2

    关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。

  8. ruby-on-rails - 'compass watch' 是如何工作的/它是如何与 rails 一起使用的 - 2

    我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t

  9. ruby - 使用 ruby​​ 将 HTML 转换为纯文本并维护结构/格式 - 2

    我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h

  10. ruby - 在 64 位 Snow Leopard 上使用 rvm、postgres 9.0、ruby 1.9.2-p136 安装 pg gem 时出现问题 - 2

    我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po

随机推荐