diff --git a/cashtippr.php b/cashtippr.php
index b8e3f1a..32faf0b 100644
--- a/cashtippr.php
+++ b/cashtippr.php
@@ -3,7 +3,7 @@
* Plugin Name: CashTippr: Bitcoin Cash instant tips & payments for your content
* Plugin URI: https://cashtippr.com/
* Description: Earn money for your content using instant Bitcoin Cash tips (0 conf).
- * Version: 1.1.13
+ * Version: 1.1.17
* Author: Ekliptor
* Author URI: https://twitter.com/ekliptor
* License: GPLv3
@@ -18,7 +18,7 @@
exit ();
}
-define ( 'CASHTIPPR_VERSION', '1.1.13' );
+define ( 'CASHTIPPR_VERSION', '1.1.17' );
define ( 'CASHTIPPR__MINIMUM_WP_VERSION', '4.7' );
define ( 'CASHTIPPR__PLUGIN_DIR', plugin_dir_path ( __FILE__ ) );
diff --git a/classes/Cashtippr.class.php b/classes/Cashtippr.class.php
index 89d5ed0..9cb3c7f 100644
--- a/classes/Cashtippr.class.php
+++ b/classes/Cashtippr.class.php
@@ -330,6 +330,18 @@ public function setIncludedMoneybuttonScript(bool $included) {
$this->includedMoneybuttonScript = $included;
}
+ public function getIncludedQrCodeTemplate() {
+ return $this->includedQrCodeTemplate;
+ }
+
+ public function setIncludedQrCodeTemplate(bool $included) {
+ $this->includedQrCodeTemplate = $included;
+ }
+
+ public function getSessionID(): string {
+ return session_id(); // ID or empty string
+ }
+
/**
* Generate a QR code for the payment
* @param string $txid The internal MySQL transaction ID (not the on-chain TXID).
@@ -581,7 +593,7 @@ public function restrictPostText(string $content) {
}
public function addFooterCode() {
- $cfg = array(
+ $cfg = $this->getPluginJsConfigData(array(
'cookieLifeDays' => ceil(static::SESSION_LIFETIME_SEC / DAY_IN_SECONDS),
'cookiePath' => $this->siteUrlParts['path'],
'siteUrl' => $this->getSiteUrl(),
@@ -599,7 +611,7 @@ public function addFooterCode() {
'tipAmount' => $this->getTipAmount(),
// TODO move localized strings into a separate .js file generated from PHP if we have more strings
'badgerLocked' => __('Your BadgerWallet is locked. Please open it in your browser toolbar and enter your password before sending money.', 'ekliptor'),
- );
+ ));
if ($this->settings->get('show_cookie_consent') === true && !isset($_COOKIE[static::CONSENT_COOKIE_NAME])) {
// TODO add option to only show this to specific countries
// from get_the_privacy_policy_link()
@@ -623,6 +635,14 @@ public function addPluginScripts() {
wp_enqueue_script( 'cashtippr-bundle', plugins_url( 'tpl/js/bundle.js', CASHTIPPR__PLUGIN_DIR . 'cashtippr.php' ), array(), CASHTIPPR_VERSION, true );
}
+ public function getPluginJsConfigData(array $existingConfig = array()): array {
+ return array_merge($existingConfig, array(
+ 'cookieLifeDays' => ceil(static::SESSION_LIFETIME_SEC / DAY_IN_SECONDS),
+ 'cookiePath' => $this->siteUrlParts['path'],
+ 'siteUrl' => $this->getSiteUrl(),
+ ));
+ }
+
public function getSettings(): CTIP_Settings {
return $this->settings;
}
diff --git a/classes/CashtipprAdmin.class.php b/classes/CashtipprAdmin.class.php
index b1c1689..181c260 100644
--- a/classes/CashtipprAdmin.class.php
+++ b/classes/CashtipprAdmin.class.php
@@ -53,6 +53,7 @@ public function init() {
//add_action( 'admin_init', array( $this, 'loadAssets' ) ); // done after screen setup
add_action( 'admin_init', array( $this, 'displayAdminNotices' ) );
add_action( 'admin_init', array( $this, 'addPrivacyPolicyContent' ) );
+ add_action('admin_footer', array($this, 'addAdminJavascript'));
add_filter('removable_query_args', array($this, 'addRemovableAdminArgs'));
add_filter('cashtippr_settings_change_xPub', array($this, 'onUpdateXpub'), 10, 4);
@@ -133,6 +134,12 @@ public function loadAssets() {
add_action( "load-{$this->pageHook}", array( $this, 'addMetaboxScripts' ) );
}
+ public function addAdminJavascript() {
+ $cfg = $this->cashtippr->getPluginJsConfigData();
+ $cfg = apply_filters('cashtippr_admin_js_config', $cfg);
+ echo '';
+ }
+
public function addMetaboxScripts() {
wp_enqueue_script( 'common' );
wp_enqueue_script( 'wp-lists' );
@@ -181,7 +188,9 @@ public function addMetaBoxes(string $post_type/*, WP_Post $post*/) {
$pluginBoxes = array(
'BlurryImage' => false,
'Shout' => false,
- 'Woocommerce' => false
+ 'SlpPress' => false,
+ 'Woocommerce' => false,
+ 'SlpPayments' => defined('BCHSLP_PAYMENTS_VERSION') === true // faster than get_option('slp_payments_installed')
);
$pluginBoxes = apply_filters('cashtippr_admin_metaboxes', $pluginBoxes, $post_type); // allows plugins to add metaboxes
if ($this->pageHook === static::PAGE_HOOK && $this->allPluginsEnabled($pluginBoxes) === false) { // advertise our plugin addons
diff --git a/classes/Sanitizer.php b/classes/Sanitizer.php
index 333b358..0972985 100644
--- a/classes/Sanitizer.php
+++ b/classes/Sanitizer.php
@@ -20,6 +20,7 @@ public function sanitizeByType($defaultValue) {
case 'integer': return array($this, 'formatInteger');
case 'double': return array($this, 'formatFloat'); // float
case 'string': return array($this, 'formatString');
+ case 'array': return array($this, 'formatArray');
}
return array($this, 'formatUnknown'); // shouldn't be reached since array, object,... can not be passed in via HTML forms
}
@@ -81,6 +82,14 @@ public function formatUnknown($newValue, string $settingName) {
return sanitize_text_field($newValue);
}
+ public function formatArray($newValue, string $settingName) {
+ // cashtippr_settings[slp_press_pages][] becomes a numeric PHP array with values of select options
+ // we don't pass along if array values are supposed to be numbers or strings, so assume strings
+ for ($i = 0; $i < count($newValue); $i++)
+ $newValue[$i] = sanitize_text_field($newValue[$i]);
+ return $newValue;
+ }
+
/**
* Sanitize a user input of html via text/textarea input. This will also keep