Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/287.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 替换函数WP中的字符串_Php_Css_String_Wordpress_Replace - Fatal编程技术网

Php 替换函数WP中的字符串

Php 替换函数WP中的字符串,php,css,string,wordpress,replace,Php,Css,String,Wordpress,Replace,我想替换插入paypal按钮的插件中字符串的一部分 此字符串在此函数中。我已经注释掉了很多多余的部分,并显示了我想要过滤的部分: add_shortcode('paypal', 'paypal_options'); function paypal_options($atts) { $atts = shortcode_atts(array('name' => 'Example Name','price' => '0.00','size' => '','align' =>

我想替换插入paypal按钮的插件中字符串的一部分

此字符串在此函数中。我已经注释掉了很多多余的部分,并显示了我想要过滤的部分:

add_shortcode('paypal', 'paypal_options');
function paypal_options($atts) {
  $atts = shortcode_atts(array('name' => 'Example Name','price' => '0.00','size' => '','align' => ''), $atts);
  $options = get_option('paypal_settingsoptions');
  foreach ($options as $k => $v ) { $value[$k] = $v; }

  $output = "";
//commented out excess code
  $output .= "<div $alignment>";
  $output .= "<form target='$target' action='https://www.$path.com/cgi-bin/webscr' method='post'>";
//commented out excess code
  $output .= "<input style='border: none;' class='paypalbuttonimage' type='image' src='$img' border='0' name='submit' alt='Make your payments with PayPal. It is free, secure, effective.'>";

  return $output;
}

我知道这个老问题,但我认为用字符串替换来改变标记可能比使用更脆弱

试着用a代替an;大概是这样的:


我知道这个老问题,但我认为用字符串替换来改变标记可能比使用更脆弱

试着用a代替an;大概是这样的:


再次检查是否在wordperss codex中添加过滤器。第一个参数是标签,而不是您希望筛选的内容。嘿@Luke,我修改了代码,但它似乎仍然没有捕获我的筛选器…编辑的原始问题仔细检查wordperss codex中是否添加了筛选器。第一个参数是标签,而不是你想要过滤的内容。嘿@Luke,我修改了代码,但它似乎仍然没有捕获我的过滤器…编辑了原始问题
function replace_ppbutton($output) {
  $og = "<input style='border: none;' class='paypalbuttonimage' type='image' src='$img' border='0' name='submit' alt='Make your payments with PayPal. It is free, secure, effective.'>";
  $rep = "<input style='border: none;' class='paypalbuttonimage' type='submit' value='Buy Now' border='0' name='submit' alt='Make your payments with PayPal. It is free, secure, effective.'>";
  return str_replace($og, $rep, $output);
}
add_filter('paypal_options', 'replace_ppbutton');