views:

12

answers:

1

Hi

I'm developing a wordpress plugin and I've hit a problem.

The problem is being caused by this code:

<?php

function gs_subscribe_button ($type) {
    global $wpdb;
    $id = get_option('google_merchant');
    $table_name = $wpdb->prefix . "subscription_types";
    $result = mysql_query ("SELECT * FROM $table_name WHERE id = $type");

    echo '<form method="POST" action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/'.$id.'" accept-charset="utf-8">';

        while ($row = mysql_fetch_array($result)) {

    echo  '<input type="hidden" name="shopping-cart.items.item-1.item-name" value="'.$row['name'].'"/>
  <input type="hidden" name="shopping-cart.items.item-1.item-description" value="Your chossen Subscription"/>
  <input type="hidden" name="shopping-cart.items.item-1.unit-price" value="'.$row['price'].'"/>
  <input type="hidden" name="shopping-cart.items.item-1.unit-price.currency" value="GBP"/>
  <input type="hidden" name="shopping-cart.items.item-1.quantity" value="1"/>';

        }


    echo '<input type="hidden" name="_charset_" />';

    echo '<input type="image"
    name="Google Checkout"
    alt="Fast checkout through Google"
    src="http://checkout.google.com/buttons/checkout.gif?merchant_id=';
    echo $id;
    echo '&w=180&h=46&style=white&variant=text&loc=en_US"
    height="46"
    width="180" />';

    echo '</form>';


}

?>

Something in this is causing all the admin screens to lock-up. Is there a way to tell Wordpress to apply functions in the front end only?

A: 

the solution was:

if (!is_admin()) { include ('template.php'); }

Didn't find is_admin the first time.

YsoL8
Don't forget to accept your solution ;)
antyrat