I would like to replace part of a string in a plugin I am using that inserts a paypal button.
This string is in this function. I have commented out a lot of the excess and showing which parts I would like to filter:
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;
}
I want to replace this specific string:
<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.'>
with this:
<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.'>
Changing it from an input type='image'
to input type='submit'
I am trying this, but it doesn't seem to catch the operator:
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');