- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试编写一个插件,用于注册用于某些特殊目的的小部件表单,以便在 CiviCRM 中支付应付款项,但我无法在插件代码中使用 cookie。正如我所看到的,我的cookie 放置在插件表单 html 代码之前,但我仍然收到 header 已发送错误,所以我想知道如何修复它?
如果有人能帮助我解决这个问题,我将不胜感激。
这是我的完整插件代码:
<?php
/*
Plugin Name: CiviCRM Contribution Later Payment
Plugin URI: http://www.stackoverflow.com/cv/nicefellow1234
Description: This plugin helps in paying due contribution payments through a web form by entering Contribution ID.
Author: Umair Shah Yousafzai
Version: 1.0
Author URI: http://www.huntedhunter.com/mycv/
*/
function my_plugin_activate()
{
// DO your activation task.
/* $post_id = wp_insert_post( array(
'post_status' => 'publish',
'post_type' => 'page',
'post_title' => 'Contribution Later Payment Page',
'post_content' => 'Pay Your Contribution Payment Now.'
) );
if ($post_id)
{
error_log("New Page Added.");
} */
}
register_activation_hook(__FILE__,"my_plugin_activate");
function cl_pay() {
if ($_POST) {
if ($_POST['cl_check_email']) {
$contact_email = $_POST["contact_email"];
global $wpdb;
$sql = $wpdb->prepare("SELECT * FROM civicrm_contact WHERE sort_name = %s", $contact_email);
$results = $wpdb->get_results($sql);
$count = count($results);
$contact_id = $results[0]->id;
if (!$count > 0 ) {
$sql = $wpdb->prepare("SELECT * FROM civicrm_email WHERE email = %s", $contact_email);
$results = $wpdb->get_results($sql);
$count = count($results);
$contact_id = $results[0]->contact_id;
}
}
if ($_POST['cl_check_phone']) {
$contact_phone = $_POST["contact_phone"];
global $wpdb;
$sql = $wpdb->prepare("SELECT * FROM civicrm_phone WHERE phone = %s", $contact_phone);
$results = $wpdb->get_results($sql);
$count = count($results);
$contact_id = $results[0]->contact_id;
}
if ($_POST['cl_check_full_name']) {
$first_name = $_POST["first_name"];
$last_name = $_POST["last_name"];
$full_name = $first_name." ".$last_name;
global $wpdb;
$sql = $wpdb->prepare("SELECT * FROM civicrm_contact WHERE display_name = %s", $full_name);
$results = $wpdb->get_results($sql);
$count = count($results);
$contact_id = $results[0]->id;
//echo "<pre>";
//print_r($results);
//echo "</pre>";
}
$sql = $wpdb->prepare("SELECT * FROM civicrm_contribution WHERE contact_id = %s", $contact_id);
$results = $wpdb->get_results($sql);
$count = count($results);
$amount = $results[0]->total_amount;
if ($count > 0) {
setcookie("display_check", "none", time()+5);
}
if (isset($amount)) { setcookie("display_amount", "block", time()+5); }
}
?>
<link href='http://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#choice').change(function () {
if ( this.value === 'option_1' ) {
$("#option_1").show("slow");
$("#option_2").hide("slow");
$("#option_3").hide("slow");
}
else if ( this.value === 'option_2' ) {
$("#option_2").show("slow");
$("#option_1").hide("slow");
$("#option_3").hide("slow");
}
else if ( this.value === 'option_3' ) {
$("#option_3").show("slow");
$("#option_1").hide("slow");
$("#option_2").hide("slow");
} else if ( this.value === 'not_specified' ) {
$("#option_1").hide("slow");
$("#option_2").hide("slow");
$("#option_3").hide("slow");
}
});
});
</script>
<style>
html {
height: 100%;
/*Image only BG fallback*/
background: url('http://thecodeplayer.com/uploads/media/gs.png');
/*background = gradient + image pattern combo*/
background:
linear-gradient(rgba(196, 102, 0, 0.2), rgba(155, 89, 182, 0.2)),
url('http://thecodeplayer.com/uploads/media/gs.png');
}
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6,
pre, form, fieldset, input, textarea, p, blockquote, th, td {
padding:0;
margin:0;}
fieldset, img {border:0}
ol, ul, li {list-style:none}
:focus {outline:none}
body,
input,
textarea,
select {
font-family: 'Open Sans', sans-serif;
font-size: 16px;
color: #4c4c4c;
}
p {
font-size: 12px;
width: 150px;
display: inline-block;
margin-left: 18px;
}
h1.testboxh1 {
font-size: 32px;
font-weight: 300;
color: #4c4c4c;
text-align: center;
padding-top: 10px;
margin-bottom: 10px;
}
html{
background-color: #ffffff;
}
.testbox {
margin: 20px auto;
width: 455px;
-webkit-border-radius: 8px/7px;
-moz-border-radius: 8px/7px;
border-radius: 8px/7px;
background-color: #ebebeb;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.31);
box-shadow: 1px 2px 5px rgba(0,0,0,.31);
border: solid 1px #cbc9c9;
}
input[type=radio] {
visibility: hidden;
}
form{
margin: 0 30px;
text-align:center;
}
label.radio {
cursor: pointer;
text-indent: 35px;
overflow: visible;
display: inline-block;
position: relative;
margin-bottom: 15px;
}
label.radio:before {
background: #3a57af;
content:'';
position: absolute;
top:2px;
left: 0;
width: 20px;
height: 20px;
border-radius: 100%;
}
label.radio:after {
opacity: 0;
content: '';
position: absolute;
width: 0.5em;
height: 0.30em;
background: transparent;
top: 7.5px;
left: 4.5px;
border: 3px solid #ffffff;
border-top: none;
border-right: none;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
transform: rotate(-45deg);
}
input[type=radio]:checked + label:after {
opacity: 1;
}
hr{
color: #a9a9a9;
}
input[type=text],input[type=password],select {
text-align:center;
width: 200px;
height: 39px;
-webkit-border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
-moz-border-radius: 0px 4px 4px 0px/0px 0px 4px 4px;
border-radius: 0px 4px 4px 0px/5px 5px 4px 4px;
background-color: #fff;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
box-shadow: 1px 2px 5px rgba(0,0,0,.09);
border: solid 1px #cbc9c9;
margin-left: -5px;
margin-top: 13px;
padding-left: 10px;
}
input[type=password]{
margin-bottom: 25px;
}
#icon {
width: 30px;
height:20px;
background-color: #3a57af;
padding: 8px 0px 8px 15px;
margin-left: 15px;
margin-top: -10px;
-webkit-border-radius: 4px 0px 0px 4px;
-moz-border-radius: 4px 0px 0px 4px;
border-radius: 4px 0px 0px 4px;
color: white;
-webkit-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
-moz-box-shadow: 1px 2px 5px rgba(0,0,0,.09);
box-shadow: 1px 2px 5px rgba(0,0,0,.09);
border: solid 0px #cbc9c9;
}
.gender {
margin-left: 30px;
margin-bottom: 30px;
}
.accounttype{
margin-left: 8px;
margin-top: 20px;
}
input.button {
text-align:center;
font-size: 14px;
font-weight: 600;
color: white;
padding : 8px 30px 8px 30px;
text-decoration: none;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
background-color: #3a57af;
-webkit-box-shadow: 0 3px rgba(58,87,175,.75);
-moz-box-shadow: 0 3px rgba(58,87,175,.75);
box-shadow: 0 3px rgba(58,87,175,.75);
transition: all 0.1s linear 0s;
}
input.button:hover {
top: 3px;
background-color:#2e458b;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
</style>
</br></br></br></br>
<div class="testbox">
<h1 class="testboxh1">Pay Due Contribution Pay</h1>
<div class="pay_check" style="display:<?php if (!isset($_COOKIE['display_check'])) {echo "block";} else {echo $_COOKIE['display_check']; }?>;">
<form action="" method="post" >
<hr>
<!---<div class="accounttype">
<input type="radio" value="None" id="radioOne" name="account" checked/>
<label for="radioOne" class="radio" chec>Personal</label>
<input type="radio" value="None" id="radioTwo" name="account" />
<label for="radioTwo" class="radio">Company</label>
</div> --->
<center><h3>::Search By::</h3></center>
<select name="choice" id="choice">
</br>
<option value="not_specified">Not Specified</option>
<option value="option_1">Contact Email</option>
<option value="option_2">Contact Phone</option>
<option value="option_3">Full Name</option>
</select>
<div id="option_1" style="display:none;">
<hr>
<center><h3 style="padding-top: 10px;">::Enter Contact Email::</h3></center>
<form action="" method="post" >
<input type="text" name="contact_email" placeholder="Contact Email" style="width:250px;"></br>
</br> <input type="submit" name="cl_check_email" class="button" value="Check">
</form>
</br><hr>
</div>
<div id="option_2" style="display:none;">
<hr>
<center><h3 style="padding-top: 10px;">::Enter Contact Phone No::</h3></center>
<form action="" method="post" >
<input type="text" name="contact_phone" placeholder="Contact Phone No" style="width:250px;"> </br>
</br> <input type="submit" name="cl_check_phone" class="button" value="Check">
</form>
</br><hr>
</div>
<div id="option_3" style="display:none;">
<hr>
<form action="" method="post" >
<center><h3 style="padding-top: 10px;">::Enter Full Name::</h3></center>
<input type="text" name="first_name" placeholder="First Name">
<input type="text" name="last_name" placeholder="Last Name"></br>
</br> <input type="submit" name="cl_check_full_name" class="button" value="Check">
</form>
</br><hr>
</div>
</br>
<!-- <label id="icon" for="cl_id"><i class="fa fa-tag " style="padding-right: 13px;"></i></label>
<input type="text" name="cl_id" id="cl_id" placeholder="Contribution ID" required/></br> -->
</br></br>
</div>
<div class="cl_pay" style="display:<?php if (!isset($_COOKIE['display_amount'])) {echo "none";} else {echo $_COOKIE['display_amount']; }?>;">
<form action="" method="post" >
<hr>
<label id="icon" for="cl_pay" style="border-radius:4px;padding-right: 100px;padding-left: 100px;background-color:#422252;"><i class="fa fa-usd " style="">
<strong><?php echo $amount; ?></strong></i></label>
</br>
<hr> <input type="submit" name="cl_pay" class="button" value="Pay">
</br></br>
</form>
</div>
</div>
<?php
}
add_shortcode("cl-pay", "cl_pay");
function my_plugin_deactivate()
{
// DO your activation task.
error_log("My Plugin Got Deactivated.");
}
register_deactivation_hook(__FILE__,"my_plugin_deactivate");
?>
我收到的错误是:
Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\civicrm_development\wp-includes\class.wp-scripts.php:180) in D:\xampp\htdocs\civicrm_development\wp-content\plugins\civicrm_later_contribution_pay.php on line 97
Warning: Cannot modify header information - headers already sent by (output started at D:\xampp\htdocs\civicrm_development\wp-includes\class.wp-scripts.php:180) in D:\xampp\htdocs\civicrm_development\wp-content\plugins\civicrm_later_contribution_pay.php on line 100
除了第 97 行和第 100 行之外,我还有以下代码:
97:
if ($count > 0) {
setcookie("display_check", "none", time()+5);
}
100:
if (isset($amount)) { setcookie("display_amount", "block", time()+5); }
}
最佳答案
当我使用新的 PHP 服务器时,我遇到了同样的事情。您需要做两件事来解决这个问题。
要打开输出缓冲,您需要在php.ini
中进行设置:
output_buffering On
或者在你的程序中:
ini_set("output_buffering", 1); // OR
ob_start();
关于javascript - 在开发 WordPress 插件时无法解决使用 cookie 已发送 header 的问题吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35939206/
SQLite、Content provider 和 Shared Preference 之间的所有已知区别。 但我想知道什么时候需要根据情况使用 SQLite 或 Content Provider 或
警告:我正在使用一个我无法完全控制的后端,所以我正在努力解决 Backbone 中的一些注意事项,这些注意事项可能在其他地方更好地解决......不幸的是,我别无选择,只能在这里处理它们! 所以,我的
我一整天都在挣扎。我的预输入搜索表达式与远程 json 数据完美配合。但是当我尝试使用相同的 json 数据作为预取数据时,建议为空。点击第一个标志后,我收到预定义消息“无法找到任何内容...”,结果
我正在制作一个模拟 NHL 选秀彩票的程序,其中屏幕右侧应该有一个 JTextField,并且在左侧绘制弹跳的选秀球。我创建了一个名为 Ball 的类,它实现了 Runnable,并在我的主 Draf
这个问题已经有答案了: How can I calculate a time span in Java and format the output? (18 个回答) 已关闭 9 年前。 这是我的代码
我有一个 ASP.NET Web API 应用程序在我的本地 IIS 实例上运行。 Web 应用程序配置有 CORS。我调用的 Web API 方法类似于: [POST("/API/{foo}/{ba
我将用户输入的时间和日期作为: DatePicker dp = (DatePicker) findViewById(R.id.datePicker); TimePicker tp = (TimePic
放宽“邻居”的标准是否足够,或者是否有其他标准行动可以采取? 最佳答案 如果所有相邻解决方案都是 Tabu,则听起来您的 Tabu 列表的大小太长或您的释放策略太严格。一个好的 Tabu 列表长度是
我正在阅读来自 cppreference 的代码示例: #include #include #include #include template void print_queue(T& q)
我快疯了,我试图理解工具提示的行为,但没有成功。 1. 第一个问题是当我尝试通过插件(按钮 1)在点击事件中使用它时 -> 如果您转到 Fiddle,您会在“内容”内看到该函数' 每次点击都会调用该属
我在功能组件中有以下代码: const [ folder, setFolder ] = useState([]); const folderData = useContext(FolderContex
我在使用预签名网址和 AFNetworking 3.0 从 S3 获取图像时遇到问题。我可以使用 NSMutableURLRequest 和 NSURLSession 获取图像,但是当我使用 AFHT
我正在使用 Oracle ojdbc 12 和 Java 8 处理 Oracle UCP 管理器的问题。当 UCP 池启动失败时,我希望关闭它创建的连接。 当池初始化期间遇到 ORA-02391:超过
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve
引用这个plunker: https://plnkr.co/edit/GWsbdDWVvBYNMqyxzlLY?p=preview 我在 styles.css 文件和 src/app.ts 文件中指定
为什么我的条形这么细?我尝试将宽度设置为 1,它们变得非常厚。我不知道还能尝试什么。默认厚度为 0.8,这是应该的样子吗? import matplotlib.pyplot as plt import
当我编写时,查询按预期执行: SELECT id, day2.count - day1.count AS diff FROM day1 NATURAL JOIN day2; 但我真正想要的是右连接。当
我有以下时间数据: 0 08/01/16 13:07:46,335437 1 18/02/16 08:40:40,565575 2 14/01/16 22:2
一些背景知识 -我的 NodeJS 服务器在端口 3001 上运行,我的 React 应用程序在端口 3000 上运行。我在 React 应用程序 package.json 中设置了一个代理来代理对端
我面临着一个愚蠢的问题。我试图在我的 Angular 应用程序中延迟加载我的图像,我已经尝试过这个2: 但是他们都设置了 src attr 而不是 data-src,我在这里遗漏了什么吗?保留 d
我是一名优秀的程序员,十分优秀!