- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
<分区>
我正在开发一个 Wordpress 主题,我正在尝试让主题附带的自定义联系表单在成功完成后重定向到感谢页面,以便我可以使用 adwords 转化跟踪。
虽然我已经浏览过 Stackflows 之前关于这个主题的问题/答案,但我仍在努力寻找正确的代码/解决方案来解决我的问题(坦率地说,我对代码知之甚少)。如果有任何帮助,我将不胜感激!这是代码...
<?php
/*
Template Name: Contact Form
*/
?>
<?php
global $woo_options;
$nameError = '';
$emailError = '';
$commentError = '';
//If the form is submitted
if(isset($_POST['submitted'])) {
//Check to see if the honeypot captcha field was filled in
if(trim($_POST['checking']) !== '') {
$captchaError = true;
} else {
//Check to make sure that the name field is not empty
if(trim($_POST['contactName']) === '') {
$nameError = __( 'You forgot to enter your name.', 'woothemes' );
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
//Check to make sure sure that a valid email address is submitted
if(trim($_POST['email']) === '') {
$emailError = __( 'You forgot to enter your email address.', 'woothemes' );
$hasError = true;
} else if (!eregi( "^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
$emailError = __( 'You entered an invalid email address.', 'woothemes' );
$hasError = true;
} else {
$email = trim($_POST['email']);
}
//Check to make sure comments were entered
if(trim($_POST['comments']) === '') {
$commentError = __( 'You forgot to enter your comments.', 'woothemes' );
$hasError = true;
} else {
if(function_exists( 'stripslashes')) {
$comments = stripslashes(trim($_POST['comments']));
} else {
$comments = trim($_POST['comments']);
}
}
//If there is no error, send the email
if(!isset($hasError)) {
$emailTo = get_option( 'woo_contactform_email' );
$subject = __( 'Contact Form Submission from ', 'woothemes' ).$name;
$sendCopy = trim($_POST['sendCopy']);
$body = __( "Name: $name \n\nEmail: $email \n\nComments: $comments", 'woothemes' );
$headers = __( 'From: ', 'woothemes') . "$name <$email>" . "\r\n" . __( 'Reply-To: ', 'woothemes' ) . $email;
//Modified 2010-04-29 (fox)
wp_mail($emailTo, $subject, $body, $headers);
if($sendCopy == true) {
$subject = __( 'You emailed ', 'woothemes' ).get_bloginfo( 'title' );
$headers = __( 'From: ', 'woothemes' ) . "$name <$emailTo>";
wp_mail($email, $subject, $body, $headers);
}
$emailSent = true;
}
}
} ?>
<?php get_header(); ?>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery(document).ready(function() {
jQuery( 'form#contactForm').submit(function() {
jQuery( 'form#contactForm .error').remove();
var hasError = false;
jQuery( '.requiredField').each(function() {
if(jQuery.trim(jQuery(this).val()) == '') {
var labelText = jQuery(this).prev( 'label').text();
jQuery(this).parent().append( '<span class="error"><?php _e( 'You forgot to enter your', 'woothemes' ); ?> '+labelText+'.</span>' );
jQuery(this).addClass( 'inputError' );
hasError = true;
} else if(jQuery(this).hasClass( 'email')) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
if(!emailReg.test(jQuery.trim(jQuery(this).val()))) {
var labelText = jQuery(this).prev( 'label').text();
jQuery(this).parent().append( '<span class="error"><?php _e( 'You entered an invalid', 'woothemes' ); ?> '+labelText+'.</span>' );
jQuery(this).addClass( 'inputError' );
hasError = true;
}
}
});
if(!hasError) {
var formInput = jQuery(this).serialize();
jQuery.post(jQuery(this).attr( 'action'),formInput, function(data){
jQuery( 'form#contactForm').slideUp( "fast", function() {
jQuery(this).before( '<p class="tick"><?php _e( '<strong>Thanks!</strong> Your email was successfully sent.', 'woothemes' ); ?></p>' );
});
});
}
return false;
});
});
//-->!]]>
</script>
<div id="content" class="col-full">
<div id="main" class="col-left">
<?php if ( isset($woo_options[ 'woo_breadcrumbs_show' ]) && $woo_options[ 'woo_breadcrumbs_show' ] == 'true' ) { ?>
<div id="breadcrumbs">
<?php woo_breadcrumbs(); ?>
</div><!--/#breadcrumbs -->
<?php } ?>
<div id="contact-page" class="post">
<?php if(isset($emailSent) && $emailSent == true) { ?>
<p class="info"><?php _e( 'Your email was successfully sent.', 'woothemes' ); ?></p>
<?php } else { ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<h1 class="title"><?php the_title(); ?></h1>
<div class="entry">
<?php the_content(); ?>
</div>
<?php $geocoords = $woo_options['woo_contactform_map_coords']; ?>
<?php if ($geocoords != '') { ?>
<?php woo_maps_contact_output("geocoords=$geocoords"); ?>
<?php echo do_shortcode( '[hr]' ); ?>
<?php } ?>
<?php if(isset($hasError) || isset($captchaError) ) { ?>
<p class="alert"><?php _e( 'There was an error submitting the form.', 'woothemes' ); ?></p>
<?php } ?>
<?php if ( get_option( 'woo_contactform_email') == '' ) { ?>
<?php echo do_shortcode( '[box type="alert"]'.__( 'E-mail has not been setup properly. Please add your contact e-mail!', 'woothemes' ).'[/box]' ); ?>
<?php } ?>
<form action="<?php the_permalink(); ?>" id="contactForm" method="post">
<ol class="forms">
<li><label for="contactName"><?php _e( 'Name', 'woothemes' ); ?></label>
<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="txt requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?php echo $nameError;?></span>
<?php } ?>
</li>
<li><label for="email"><?php _e( 'Email', 'woothemes' ); ?></label>
<input type="text" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="txt requiredField email" />
<?php if($emailError != '') { ?>
<span class="error"><?php echo $emailError;?></span>
<?php } ?>
</li>
<li class="textarea"><label for="commentsText"><?php _e( 'Message', 'woothemes' ); ?></label>
<textarea name="comments" id="commentsText" rows="20" cols="30" class="requiredField"><?php if(isset($_POST['comments'])) { if(function_exists( 'stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea>
<?php if($commentError != '') { ?>
<span class="error"><?php echo $commentError;?></span>
<?php } ?>
</li>
<li class="inline"><input type="checkbox" name="sendCopy" id="sendCopy" value="true"<?php if(isset($_POST['sendCopy']) && $_POST['sendCopy'] == true) echo ' checked="checked"'; ?> /><label for="sendCopy"><?php _e( 'Send a copy of this email to yourself', 'woothemes' ); ?></label></li>
<li class="screenReader"><label for="checking" class="screenReader"><?php _e( 'If you want to submit this form, do not enter anything in this field', 'woothemes' ) ?></label><input type="text" name="checking" id="checking" class="screenReader" value="<?php if(isset($_POST['checking'])) echo $_POST['checking'];?>" /></li>
<li class="buttons"><input type="hidden" name="submitted" id="submitted" value="true" /><input class="submit button" type="submit" value="<?php esc_attr_e( 'Submit', 'woothemes' ); ?>" /></li>
</ol>
</form>
<?php endwhile; ?>
<?php endif; ?>
<?php } ?>
</div><!-- /#contact-page -->
</div><!-- /#main -->
<?php get_sidebar(); ?>
</div><!-- /#content -->
<?php get_footer(); ?>
对于发布所有代码(与没有线索有关)表示歉意,但我不确定哪些位是相关的/需要更改的。非常感谢您的帮助!
对于相当简单的表结构,即。人员、标准和 PersonCriteria(组合表),我现在设置了一个查询,选择所有符合所有选定条件的人。 此时查询本身看起来像这样: SELECT p.PersonID
我在使用高级 SQL 查询时遇到了一些问题,而且我已经有很长时间没有使用 SQL 数据库了。我们使用 MySQL。 背景: 我们将使用两个表: “交易表” 表:expire_history +----
我找不到错误。也许你可以帮助我:我的代码如下: var data = {"product":[{"config":[{"id":"1","price":"100","sku":"1054879634
我有一个列表列表的列表(最后一个列表并不重要) data = [[[['f', 0], 'C'], [['X', 0], 'X']], [[['s', 1], 'X'], [['X', 0], 'X'
我想准备将使用表格的 session ,并在另一个网站上将新项目添加到 session 中。 默认.cs string[] tab = new string[100];
我知道有一些像: Bubble sort Insertion sort Shell sort Merge sort Heapsort Quicksort Bucket sort Radix sort
像https://softwareengineering.stackexchange.com/questions/150616/return-random-list-item-by-its-weigh
我正在开发一个 posix 脚本 (Linux),它获取一个网页,将内容存储在一个变量中并查找字符串“SUCCESS”。如果找到字符串,则不执行循环内容,如果没有找到字符串,则反复执行循环,直到找到为
我不确定这个问题是否已在其他地方得到解答,而且我似乎无法通过谷歌找到任何不是“Hello World”示例的内容...我正在使用 C# .NET 4.0 进行编码。 我正在尝试开发一个控制台应用程序,
我创建了一个房地产网站,我希望按照列表的最后更新和完整性对列表进行排序。所以我一直想弄清楚如何结合最近更新的列表按mysql中的字段(completion_score)进行排序。完成分数将采用 1
只所以称为“高级”用法,是因为我连switch的最基础的用法都还没有掌握,so,接下来讲的其实还是它的基础用法! switch 语句和具有同样表达式的一系列的 IF 语句相似。很多场合下需要把同一
之前的章节中,我们学习了 XML DOM,并使用了 XML DOM 的 getElementsByTagName() 方法从 XML 文档中取回数据 本章节我们将继续学习其它重要的 XML DOM
我对我尝试编写的 SQL 查询有疑问。 我需要从数据库中查询数据。该数据库除其他外,还包括以下 3 个字段: Account_ID #, Date_Created, Time_Created 我需要编
我正在使用非常激进的视频压缩,例如 -crf 51 .我将其用于“艺术”效果,因此从普通视频压缩的角度来看,我所做的可能没有意义。 到目前为止,我只使用了非常基本的压缩控制,只使用了 -crf。或 -
我真的在学习 lucene 和 ravendb 上的绳索 - 我在 Raven 中有以下文档 - { "InternalEvent": { "Desec": "MachineInfo: 1
通常 grep 命令用于显示包含指定模式的行。有没有办法在包含指定模式的行之前和之后显示 n 行? 这可以使用awk来实现吗? 最佳答案 是的,使用 grep -B num1 -A num2 在匹配之
我搜索了高低,并尝试了几个小时来操纵似乎适合的各种其他查询,但我没有快乐。 我试图加入 Microsoft SQL Server 2005 中的几个表,其中一个示例是: Company Table (
我有一个如下所示的 XML 文件: teacher1Name
我将如何在 CF 中创建此语句? 显然括号不起作用,但说明了我想要完成的工作。这是什么语法? 编辑: 好的,我了解如何使用 EQ 等等。我有点匆忙地发布了这个。我的问题是关于括号。以这种方式使用它们
主要问题:我需要使用具体对象结构对任何对象结构进行类型扩展。 我在 VS Code 中测试的默认值。 我的解决方案: /** @template A @typedef {{[Ki in keyof A
我是一名优秀的程序员,十分优秀!