Paypal Donate Plugin [message #186541] |
Thu, 25 September 2014 17:50 |
Kermit
Messages: 35 Registered: November 2004
Karma: 0
|
Member |
add to buddy list ignore all messages by this user
|
|
Hi, I wanted a Paypal donate button on my forum and discovered the Adsense plugin worked with the paypal generated code but I wanted both
With this in mind, I've hacked (I'm not programmer) the google_adsense.plugin plugin to paypal_donate.plugin and changed the code were applicable to make it its own plugin which lives in /plugins/donate
I'd post the code as it works nicely but don't know given I hacked someone elses code (even though its a GNU license) if its ok to post the code here for someone to possibly properly publish or use on future releases.
If you want to have a look at it, its http://honda-forums.com/forum/index.php and the only thing I did after generating the code on paypal's donate wizard (I opted for a small logo and no pics of credit cards etc underneath) and pasting into the plugin was to add <div align="right"> and </div> to the end of paypals code to make it sit to the right.
So is it ok to post the code here for anyone to use as I know I could probably google if someone elses GNU code can be hacked and reposted as another plugin but its eaier to post a question as afterall thats what forums are for
[Updated on: Thu, 25 September 2014 17:53] Report message to a moderator
|
|
|
|
Re: Paypal Donate Plugin [message #186554 is a reply to message #186546] |
Sat, 27 September 2014 18:26 |
Kermit
Messages: 35 Registered: November 2004
Karma: 0
|
Member |
add to buddy list ignore all messages by this user
|
|
Ok, thanks, here's the code then
Paypal_donate.plugin and locate in \plugins\donate\
<?php
/**
* copyright : (C) 2001-2013 Advanced Internet Designs Inc.
* email : forum(at)prohost(dot)org
* $Id: paypal_donate.plugin 25-09-2014 KermitX Honda-forums.com $
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; version 2 of the License.
**/
// Initialize plugin.
plugin_add_hook('COMPILER_EXPAND_TEMPLATE', 'plugin_paypal_donate');
function plugin_paypal_donate($array) {
list($tmpl, $tag, $sec, $name, $file) = $array;
if ((@include $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
die('ERROR: Please configure the paypal_donate plugin from the Plugin Manager Control panel.');
}
if ($name == 'usercp' && $ini['PAYPAL_DONATE_POS'] == 0) {
$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
} else if ($name == 'header' && $ini['PAYPAL_DONATE_POS'] == 1) {
$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
} else if ($name == 'header' && $ini['PAYPAL_DONATE_POS'] == 2) {
$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
} else if ($name == 'curtime' && $ini['PAYPAL_DONATE_POS'] == 3) {
$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
} else if ($name == 'curtime' && $ini['PAYPAL_DONATE_POS'] == 4) {
$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
} else if ($name == 'footer' && $ini['PAYPAL_DONATE_POS'] == 5) {
$tmpl = $ini['PAYPAL_DONATE_CODE'] . $tmpl;
} else if ($name == 'footer' && $ini['PAYPAL_DONATE_POS'] == 6) {
$tmpl = $tmpl . $ini['PAYPAL_DONATE_CODE'];
}
return array($tmpl, $tag, $sec, $name, $file);
}
function paypal_donate_info() {
return array('name' => 'Paypal Donate',
'desc' => 'Display Donate button on your forum\'s web pages.',
'cat' => 'Third-party Integration',
'version' => '1.0');
}
function paypal_donate_enable() {
if ((@include_once $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
return array(null, 'Please configure the paypal_donate plugin before enabling it.'); // OK, Err.
}
@define('REBUILD_THEMES', 1);
}
function paypal_donate_disable() {
@define('REBUILD_THEMES', 1);
}
function paypal_donate_config() {
if ((@include $GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini') === false) {
$ini = NULL;
}
if (isset($_POST['Set'])) {
foreach (array_keys($_POST) as $key) {
if (substr($key,0,14) == 'PAYPAL_DONATE_') {
$ini[$key] = trim($_POST[$key]);
}
}
$fp = fopen($GLOBALS['PLUGIN_PATH'] .'donate/paypal_donate.ini', 'w');
fwrite($fp, '<?php $ini = '. var_export($ini, 1) .'; ?>');
fclose($fp);
pf(successify('Settings successfully saved.'));
compile_themes();
}
?>
<p>Where should it be displayed:<br />
<select name="PAYPAL_DONATE_POS">
<option value="0" <?php if($ini['PAYPAL_DONATE_POS']==0) echo 'selected="selected"'; ?>>After top level menu.</option>
<option value="1" <?php if($ini['PAYPAL_DONATE_POS']==1) echo 'selected="selected"'; ?>>Before page header.</option>
<option value="2" <?php if($ini['PAYPAL_DONATE_POS']==2) echo 'selected="selected"'; ?>>After page header.</option>
<option value="3" <?php if($ini['PAYPAL_DONATE_POS']==3) echo 'selected="selected"'; ?>>Before current time.</option>
<option value="4" <?php if($ini['PAYPAL_DONATE_POS']==4) echo 'selected="selected"'; ?>>After current time.</option>
<option value="5" <?php if($ini['PAYPAL_DONATE_POS']==5) echo 'selected="selected"'; ?>>Before page footer.</option>
<option value="6" <?php if($ini['PAYPAL_DONATE_POS']==6) echo 'selected="selected"'; ?>>After page footer.</option>
</select>
</p>
<p>Your Paypal Donate code (get it from <a href="https://www.paypal.com/">paypal.com</a>):<br />
<textarea name="PAYPAL_DONATE_CODE" cols="72" rows="10"><?php echo $ini['PAYPAL_DONATE_CODE'] ?></textarea>
<font size="-1">Tip: you can add additional HTML as well. For example, use the CENTRE tag to center your donate button.</font>
</p>
<?php
}
?>
|
|
|
|