Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/payment-forms-for-paystack/includes/classes/class-form-shortcode.php
+++ b/payment-forms-for-paystack/includes/classes/class-form-shortcode.php
@@ -111,6 +111,9 @@
// First lets check for a public key.
$public_key = $this->helpers->get_public_key();
if ( ! $public_key ) {
+ if ( ! current_user_can( Settings::get_capability() ) ) {
+ return '<h5>' . esc_html__( 'Payment is not available right now. Please contact the site administrator.', 'pff-paystack' ) . '</h5>';
+ }
$settings_link = esc_url( get_admin_url( null, 'edit.php?post_type=paystack_form&page=settings' ) );
return sprintf(
'<h5>%s <a href="%s">%s</a></h5>',
--- a/payment-forms-for-paystack/includes/classes/class-forms-list.php
+++ b/payment-forms-for-paystack/includes/classes/class-forms-list.php
@@ -36,7 +36,9 @@
if ( get_post_type( $post ) === 'paystack_form' ) {
unset( $actions['view'] );
unset( $actions['quick edit'] );
- $actions['export'] = '<a href="' . admin_url( 'edit.php?post_type=paystack_form&page=submissions&form=' . $post->ID ) . '" >' . esc_html__( 'View Payments', 'payment_forms' ) . '</a>';
+ if ( current_user_can( Submissions::get_capability() ) ) {
+ $actions['export'] = '<a href="' . admin_url( 'edit.php?post_type=paystack_form&page=submissions&form=' . $post->ID ) . '" >' . esc_html__( 'View Payments', 'payment_forms' ) . '</a>';
+ }
}
return $actions;
}
@@ -52,9 +54,11 @@
'cb' => '<input type="checkbox" />',
'title' => esc_html__( 'Name', 'pff-paystack' ),
'shortcode' => esc_html__( 'Shortcode', 'pff-paystack' ),
- 'payments' => esc_html__( 'Payments', 'pff-paystack' ),
- 'date' => esc_html__( 'Date', 'pff-paystack' )
);
+ if ( current_user_can( Submissions::get_capability() ) ) {
+ $columns['payments'] = esc_html__( 'Payments', 'pff-paystack' );
+ }
+ $columns['date'] = esc_html__( 'Date', 'pff-paystack' );
return $columns;
}
--- a/payment-forms-for-paystack/includes/classes/class-helpers.php
+++ b/payment-forms-for-paystack/includes/classes/class-helpers.php
@@ -767,7 +767,7 @@
break;
default:
- $display_name = ucwords( str_replace( array( '_', '-', 'pf' ), ' ', $key ) );
+ $display_name = sanitize_text_field( ucwords( str_replace( array( '_', '-', 'pf' ), ' ', $key ) ) );
$fields[] = array(
'display_name' => $display_name,
'variable_name' => $key,
--- a/payment-forms-for-paystack/includes/classes/class-payments-list-table.php
+++ b/payment-forms-for-paystack/includes/classes/class-payments-list-table.php
@@ -164,11 +164,11 @@
}
$new_data[] = array(
'id' => $new_key,
- 'email' => '<a href="mailto:' . $row->email . '">' . $row->email . '</a>',
- 'amount' => $currency . '<b>' . number_format( $row->amount ) . '</b>',
- 'txn_code' => $txn_code,
+ 'email' => '<a href="' . esc_url( 'mailto:' . $row->email ) . '">' . esc_html( $row->email ) . '</a>',
+ 'amount' => esc_html( $currency ) . '<b>' . number_format( $row->amount ) . '</b>',
+ 'txn_code' => esc_html( $txn_code ),
'metadata' => $this->format_metadata( $row->metadata ),
- 'date' => $row->created_at
+ 'date' => esc_html( $row->created_at )
);
}
return $new_data;
@@ -181,26 +181,35 @@
* @return string
*/
public function format_metadata( $data ) {
- $new = json_decode( $data );
+ $new = json_decode( $data, true );
$text = '';
+ if ( ! is_array( $new ) ) {
+ return '';
+ }
+
// Determine both for backwards compatability
- if ( array_key_exists( "0", $new ) ) {
- foreach ( $new as $key => $item ) {
- if ( $item->type == 'text' ) {
- $text .= '<b>' . $item->display_name . ": </b> " . $item->value . "<br />";
+ if ( array_key_exists( 0, $new ) ) {
+ foreach ( $new as $item ) {
+ if ( ! is_array( $item ) ) {
+ continue;
+ }
+ $display_name = isset( $item['display_name'] ) ? esc_html( (string) $item['display_name'] ) : '';
+ $value = isset( $item['value'] ) && is_scalar( $item['value'] ) ? (string) $item['value'] : '';
+ if ( isset( $item['type'] ) && 'text' === $item['type'] ) {
+ $text .= '<b>' . $display_name . ": </b> " . esc_html( $value ) . "<br />";
} else {
- $text .= '<b>' . $item->display_name . ": </b> <a target='_blank' href='" . $item->value . "'>link</a><br />";
+ $text .= '<b>' . $display_name . ": </b> <a target='_blank' rel='noopener noreferrer' href='" . esc_url( $value ) . "'>link</a><br />";
}
}
} else {
- $text = '';
- if ( count( $new ) > 0 ) {
- foreach ( $new as $key => $item ) {
- $text .= '<b>' . $key . ": </b> " . $item . "<br />";
+ foreach ( $new as $key => $item ) {
+ if ( ! is_scalar( $item ) ) {
+ continue;
}
+ $text .= '<b>' . esc_html( $key ) . ": </b> " . esc_html( (string) $item ) . "<br />";
}
}
return $text;
}
-}
No newline at end of file
+}
--- a/payment-forms-for-paystack/includes/classes/class-paystack-forms.php
+++ b/payment-forms-for-paystack/includes/classes/class-paystack-forms.php
@@ -113,6 +113,7 @@
'email-receipt' => 'Email_Receipt',
'email-receipt-owner' => 'Email_Receipt_Owner',
'retry-submit' => 'Retry_Submit',
+ 'php-version-notice' => 'PHP_Version_Notice',
);
}
--- a/payment-forms-for-paystack/includes/classes/class-php-version-notice.php
+++ b/payment-forms-for-paystack/includes/classes/class-php-version-notice.php
@@ -0,0 +1,193 @@
+<?php
+/**
+ * Warns administrators when the server runs a vulnerable PHP version.
+ *
+ * @package paystackpayment_forms
+ */
+
+namespace paystackpayment_forms;
+
+if ( ! defined( 'ABSPATH' ) ) {
+ exit;
+}
+
+/**
+ * PHP version notice class.
+ */
+class PHP_Version_Notice {
+
+ /**
+ * First patched release per supported minor branch.
+ *
+ * CVE-2026-109618 / CVE-2026-109619; 8.1 and older are end of life with no fix.
+ *
+ * @var array
+ */
+ const FIXED_PATCH = array(
+ '8.2' => 35,
+ '8.3' => 36,
+ '8.4' => 27,
+ '8.5' => 12,
+ );
+
+ /**
+ * Construct the class.
+ */
+ public function __construct() {
+ add_filter( 'site_status_tests', array( $this, 'add_site_health_test' ) );
+ add_action( 'admin_notices', array( $this, 'admin_notice' ) );
+ }
+
+ /**
+ * Check whether a PHP version is affected.
+ *
+ * @param string $version PHP version string.
+ *
+ * @return bool
+ */
+ public static function is_affected( $version ) {
+ if ( ! preg_match( '/^(d+).(d+)(?:.(d+))?/', (string) $version, $matches ) ) {
+ return false;
+ }
+
+ $major = (int) $matches[1];
+ $minor = (int) $matches[2];
+ $patch = isset( $matches[3] ) ? (int) $matches[3] : 0;
+
+ if ( $major < 8 || ( 8 === $major && $minor < 2 ) ) {
+ return true;
+ }
+
+ $key = $major . '.' . $minor;
+
+ return isset( self::FIXED_PATCH[ $key ] ) && $patch < self::FIXED_PATCH[ $key ];
+ }
+
+ /**
+ * Get the running PHP release, without any distro suffix.
+ *
+ * @return string
+ */
+ private static function current_version() {
+ return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
+ }
+
+ /**
+ * Whether this is a distro build whose security fixes may be backported.
+ *
+ * @return bool
+ */
+ private static function is_distro_build() {
+ return '' !== PHP_EXTRA_VERSION;
+ }
+
+ /**
+ * Whether the running version is affected, ignoring distro backports.
+ *
+ * @return bool
+ */
+ private function is_vulnerable() {
+ return self::is_affected( self::current_version() ) && apply_filters( 'pff_paystack_php_version_warning', true );
+ }
+
+ /**
+ * Whether the admin notice should be shown.
+ *
+ * @return bool
+ */
+ private function should_warn() {
+ return $this->is_vulnerable() && ! self::is_distro_build();
+ }
+
+ /**
+ * Build the warning message.
+ *
+ * @return string
+ */
+ private function message() {
+ $fixed = array();
+ foreach ( self::FIXED_PATCH as $branch => $patch ) {
+ $fixed[] = $branch . '.' . $patch;
+ }
+
+ return sprintf(
+ /* translators: 1: PHP version, 2: list of fixed PHP versions. */
+ esc_html__( 'Payment Forms for Paystack: this server runs PHP %1$s, which is affected by critical security vulnerabilities (CVE-2026-109618, CVE-2026-109619) that allow remote code execution. Ask your hosting provider to upgrade to PHP %2$s or later. If your host backports security fixes to older PHP builds, this warning may not apply.', 'pff-paystack' ),
+ esc_html( PHP_VERSION ),
+ esc_html( implode( ', ', $fixed ) )
+ );
+ }
+
+ /**
+ * Add the Site Health test.
+ *
+ * @param array $tests Site Health tests.
+ *
+ * @return array
+ */
+ public function add_site_health_test( $tests ) {
+ $tests['direct']['pff_paystack_php_version'] = array(
+ 'label' => esc_html__( 'Payment Forms for Paystack PHP version', 'pff-paystack' ),
+ 'test' => array( $this, 'site_health_result' ),
+ );
+
+ return $tests;
+ }
+
+ /**
+ * Site Health test callback.
+ *
+ * @return array
+ */
+ public function site_health_result() {
+ $affected = $this->is_vulnerable();
+ if ( ! $affected ) {
+ $status = 'good';
+ } else {
+ $status = self::is_distro_build() ? 'recommended' : 'critical';
+ }
+ $colors = array(
+ 'good' => 'blue',
+ 'recommended' => 'orange',
+ 'critical' => 'red',
+ );
+
+ return array(
+ 'label' => $affected
+ ? esc_html__( 'PHP version has known critical vulnerabilities', 'pff-paystack' )
+ : esc_html__( 'PHP version is not affected by CVE-2026-109618 or CVE-2026-109619', 'pff-paystack' ),
+ 'status' => $status,
+ 'badge' => array(
+ 'label' => esc_html__( 'Security', 'pff-paystack' ),
+ 'color' => $colors[ $status ],
+ ),
+ 'description' => '<p>' . ( $affected
+ ? $this->message()
+ : esc_html__( 'This server's PHP version is not affected by CVE-2026-109618 or CVE-2026-109619.', 'pff-paystack' ) ) . '</p>',
+ 'actions' => sprintf(
+ '<p><a href="%s" target="_blank" rel="noopener noreferrer">%s</a></p>',
+ esc_url( 'https://www.php.net/supported-versions.php' ),
+ esc_html__( 'View supported PHP versions', 'pff-paystack' )
+ ),
+ 'test' => 'pff_paystack_php_version',
+ );
+ }
+
+ /**
+ * Display the admin notice.
+ *
+ * @return void
+ */
+ public function admin_notice() {
+ if ( ! current_user_can( Settings::get_capability() ) || ! $this->should_warn() ) {
+ return;
+ }
+
+ $screen = get_current_screen();
+ if ( ! $screen || ( 'plugins' !== $screen->id && 'paystack_form' !== $screen->post_type ) ) {
+ return;
+ }
+
+ echo '<div class="notice notice-warning"><p>' . $this->message() . '</p></div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- escaped in message().
+ }
+}
--- a/payment-forms-for-paystack/includes/classes/class-settings.php
+++ b/payment-forms-for-paystack/includes/classes/class-settings.php
@@ -16,6 +16,8 @@
*/
class Settings {
+ const OPTION_GROUP = 'kkd-pff-paystack-settings-group';
+
/**
* Holdes the array of settings fields.
*
@@ -37,6 +39,7 @@
'tsk' => array(
'title' => esc_html__( 'Test Secret Key', 'pff-paystack' ),
'type' => 'password',
+ 'prefix' => 'sk_test_',
'default' => '',
),
'tpk' => array(
@@ -47,6 +50,7 @@
'lsk' => array(
'title' => esc_html__( 'Live Secret Key', 'pff-paystack' ),
'type' => 'password',
+ 'prefix' => 'sk_live_',
'default' => '',
),
'lpk' => array(
@@ -80,6 +84,100 @@
);
add_action( 'admin_menu', [ $this, 'register_settings_page' ] );
add_action( 'admin_menu', [ $this, 'register_settings_fields' ] );
+ add_action( 'admin_init', [ $this, 'register_secret_key_guards' ] );
+ }
+
+ /**
+ * Returns the capability required to view and save the settings.
+ *
+ * @return string
+ */
+ public static function get_capability() {
+ return apply_filters( 'option_page_capability_' . self::OPTION_GROUP, 'manage_options' );
+ }
+
+ /**
+ * Keeps stored secret keys when left blank and rejects keys with the wrong prefix.
+ *
+ * @return void
+ */
+ public function register_secret_key_guards() {
+ // phpcs:disable WordPress.Security.NonceVerification -- options.php verifies the nonce before update_option runs.
+ $option_page = '';
+ if ( isset( $_POST['option_page'] ) ) {
+ $option_page = sanitize_key( wp_unslash( $_POST['option_page'] ) );
+ } elseif ( isset( $_GET['option_page'] ) ) {
+ $option_page = sanitize_key( wp_unslash( $_GET['option_page'] ) );
+ }
+ // phpcs:enable WordPress.Security.NonceVerification
+ if ( self::OPTION_GROUP !== $option_page ) {
+ return;
+ }
+
+ foreach ( $this->get_settings_fields() as $fields ) {
+ foreach ( $fields as $key => $args ) {
+ if ( ! empty( $args['type'] ) && 'password' === $args['type'] ) {
+ add_filter( "pre_update_option_{$key}", [ $this, 'filter_secret_key' ], 10, 3 );
+ }
+ }
+ }
+ }
+
+ /**
+ * Keeps the stored key when the submitted one is blank or has the wrong prefix.
+ *
+ * @param mixed $new Submitted value.
+ * @param mixed $old Stored value.
+ * @param string $option Option name.
+ * @return mixed
+ */
+ public function filter_secret_key( $new, $old, $option ) {
+ if ( '' === $new ) {
+ return $old;
+ }
+
+ $field = null;
+ foreach ( $this->get_settings_fields() as $fields ) {
+ if ( isset( $fields[ $option ] ) ) {
+ $field = $fields[ $option ];
+ break;
+ }
+ }
+
+ $prefix = isset( $field['prefix'] ) ? $field['prefix'] : '';
+ if ( '' !== $prefix && 0 !== strpos( (string) $new, $prefix ) ) {
+ add_settings_error(
+ self::OPTION_GROUP,
+ "pff-paystack-invalid-{$option}",
+ sprintf(
+ /* translators: 1: field title, 2: required key prefix */
+ esc_html__( 'Invalid %1$s: it must start with %2$s. The previous key was kept; other settings were saved.', 'pff-paystack' ),
+ wp_strip_all_tags( $field['title'] ),
+ $prefix
+ ),
+ 'error'
+ );
+ return $old;
+ }
+
+ return $new;
+ }
+
+ /**
+ * Builds the masked hint for a stored secret key.
+ *
+ * @param string $value Stored key.
+ * @param string $prefix Expected key prefix, or '' if none.
+ * @return string
+ */
+ private function mask_key( $value, $prefix ) {
+ if ( '' === $prefix || 0 !== strpos( $value, $prefix ) ) {
+ return '••••';
+ }
+ if ( strlen( $value ) < strlen( $prefix ) + 20 ) {
+ return $prefix . '••••';
+ }
+ return $prefix . '…' . substr( $value, -4 );
}
/**
@@ -88,7 +186,7 @@
* @return void
*/
public function register_settings_page() {
- add_submenu_page( 'edit.php?post_type=paystack_form', esc_html__( 'Settings', 'pff-paystack' ), esc_html__( 'Settings', 'pff-paystack' ), 'edit_posts', 'settings', [ $this, 'output_settings_page' ] );
+ add_submenu_page( 'edit.php?post_type=paystack_form', esc_html__( 'Settings', 'pff-paystack' ), esc_html__( 'Settings', 'pff-paystack' ), self::get_capability(), 'settings', [ $this, 'output_settings_page' ] );
}
/**
@@ -101,23 +199,27 @@
// Run through each group, and the fields in there.
foreach ( $fields as $group => $fields ) {
foreach ( $fields as $field_key => $args ) {
- register_setting( 'kkd-pff-paystack-settings-group', $field_key, [ $this, 'sanitise_field' ] );
+ register_setting( self::OPTION_GROUP, $field_key, [ $this, 'sanitise_field' ] );
}
}
}
public function output_settings_page() {
+ if ( ! current_user_can( self::get_capability() ) ) {
+ return;
+ }
?>
<div class="wrap">
<h1><?php esc_html_e( 'Paystack Forms Settings', 'pff-paystack' ); ?></h1>
+ <?php settings_errors(); ?>
<h2><?php esc_html_e( 'API Keys Settings', 'pff-paystack' ); ?></h2>
<span><?php echo wp_kses_post( __( 'Get your API Keys <a href="https://dashboard.paystack.co/#/settings/developer" target="_blank">here</a>', 'pff-paystack' ) ); ?> </span>
<form method="post" action="options.php">
<?php
- settings_fields( 'kkd-pff-paystack-settings-group' );
- do_settings_sections( 'kkd-pff-paystack-settings-group' );
+ settings_fields( self::OPTION_GROUP );
+ do_settings_sections( self::OPTION_GROUP );
$settings_fields = $this->get_settings_fields();
?>
<table class="form-table paystack_setting_page">
@@ -134,6 +236,13 @@
<option value="test" <?php echo esc_attr( $this->is_option_selected( 'test', $saved_val ) ); ?>><?php esc_html_e( 'Test Mode', 'pff-paystack' ); ?></option>
<option value="live" <?php echo esc_attr( $this->is_option_selected( 'live', $saved_val ) ); ?>><?php esc_html_e( 'Live Mode', 'pff-paystack' ); ?></option>
</select>
+ <?php } elseif ( 'password' === $field['type'] ) { ?>
+ <input type="password" name="<?php echo esc_attr( $key ); ?>" value="" autocomplete="new-password" />
+ <?php $saved_key = (string) get_option( $key, '' ); ?>
+ <?php if ( '' !== $saved_key ) { ?>
+ <?php /* translators: %s: masked saved key */ ?>
+ <p class="description"><?php echo esc_html( sprintf( __( 'Saved key: %s. Leave blank to keep it.', 'pff-paystack' ), $this->mask_key( $saved_key, isset( $field['prefix'] ) ? $field['prefix'] : '' ) ) ); ?></p>
+ <?php } ?>
<?php } else { ?>
<input type="<?php echo esc_attr( $field['type'] ); ?>" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( get_option( $key, $field['default'] ) ); ?>" />
<?php } ?>
@@ -195,11 +304,10 @@
/**
* Sanitises the field name
*
- * @param string $value
- * /
- *
+ * @param mixed $value
+ * @return string
*/
- private function sanitise_field( $value ) {
- return sanitize_text_field( $value );
+ public function sanitise_field( $value ) {
+ return sanitize_text_field( is_scalar( $value ) ? (string) $value : '' );
}
}
--- a/payment-forms-for-paystack/includes/classes/class-setup.php
+++ b/payment-forms-for-paystack/includes/classes/class-setup.php
@@ -85,6 +85,9 @@
* Add a link to our settings page in the plugin action links.
*/
public function add_action_links( $links ) {
+ if ( ! current_user_can( Settings::get_capability() ) ) {
+ return $links;
+ }
$settings_link = array(
'<a href="' . admin_url( 'edit.php?post_type=paystack_form&page=settings') . '">' . esc_html__( 'Settings', 'pff-paystack' ) . '</a>',
);
--- a/payment-forms-for-paystack/includes/classes/class-submissions.php
+++ b/payment-forms-for-paystack/includes/classes/class-submissions.php
@@ -10,6 +10,8 @@
*/
class Submissions {
+ const EXPORT_NONCE_ACTION = 'pff-paystack-export';
+
/**
* Constructor
*/
@@ -19,12 +21,21 @@
}
/**
+ * Returns the capability required to view and export payment data.
+ *
+ * @return string
+ */
+ public static function get_capability() {
+ return apply_filters( 'pff_paystack_payments_capability', 'manage_options' );
+ }
+
+ /**
* Register the submissions page
*
* @return void
*/
public function register_submissions_page() {
- add_submenu_page( 'edit.php?post_type=paystack_form', esc_html__( 'Submissions', 'pff-paystack' ), esc_html__( 'Submissions', 'pff-paystack' ), 'administrator', 'submissions', [ $this, 'output_submissions_page' ] );
+ add_submenu_page( 'edit.php?post_type=paystack_form', esc_html__( 'Submissions', 'pff-paystack' ), esc_html__( 'Submissions', 'pff-paystack' ), self::get_capability(), 'submissions', [ $this, 'output_submissions_page' ] );
remove_submenu_page( 'edit.php?post_type=paystack_form', 'submissions' );
}
@@ -34,6 +45,10 @@
* @return void
*/
public function output_submissions_page() {
+ if ( ! current_user_can( self::get_capability() ) ) {
+ return;
+ }
+
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( ! isset( $_GET['form'] ) ) {
return esc_html__( 'No form set', 'pff-paystack' );
@@ -61,6 +76,7 @@
<?php if ( $data > 0 ) { ?>
<form action="<?php echo esc_html( admin_url( 'admin-post.php' ) ); ?>" method="post">
<input type="hidden" name="action" value="pff_paystack_export_excel">
+ <?php wp_nonce_field( self::EXPORT_NONCE_ACTION ); ?>
<input type="hidden" name="form_id" value="<?php echo esc_html( $form_id ); ?>">
<button type="submit" class="button button-primary button-hero load-customize"><?php esc_html_e( 'Export Data to Excel', 'pff-paystack' ); ?></button>
</form>
@@ -98,6 +114,19 @@
* @return string
*/
public function prep_csv_data( $item ) {
+ if ( null === $item ) {
+ $item = '';
+ } elseif ( is_scalar( $item ) ) {
+ $item = (string) $item;
+ } else {
+ $item = wp_json_encode( $item );
+ }
+
+ // Neutralise spreadsheet formulas; phone-number-style values are left intact (negatives are escaped).
+ if ( preg_match( '/^(?:[sx00]*[=+-@]|[trn])/', $item ) && ! preg_match( '/^+?d[ds()-]*$/', $item ) ) {
+ $item = "'" . $item;
+ }
+
return '"' . str_replace( '"', '""', $item ) . '"';
}
@@ -109,14 +138,23 @@
public function export_excel() {
global $wpdb;
- // phpcs:ignore WordPress.Security.NonceVerification.Missing
+ if ( ! current_user_can( self::get_capability() ) ) {
+ wp_die( esc_html__( 'You do not have permission to export this data.', 'pff-paystack' ), 403 );
+ }
+
+ check_admin_referer( self::EXPORT_NONCE_ACTION );
+
if ( ! isset( $_POST['form_id'] ) || empty( $_POST['form_id'] ) ) {
return;
}
- // phpcs:ignore WordPress.Security.NonceVerification.Missing
- $form_id = sanitize_text_field( wp_unslash( $_POST['form_id'] ) );
+ $form_id = absint( wp_unslash( $_POST['form_id'] ) );
$obj = get_post( $form_id );
+
+ if ( ! $obj || 'paystack_form' !== $obj->post_type ) {
+ wp_die( esc_html__( 'Form not found.', 'pff-paystack' ), 404 );
+ }
+
$csv_output = '';
$currency = get_post_meta( $form_id, '_currency', true );
@@ -135,10 +173,14 @@
$csv_output .= "Date Paid,";
$csv_output .= "Reference,";
- $new = json_decode( $header->metadata );
+ $new = json_decode( $header->metadata, true );
+ if ( ! is_array( $new ) ) {
+ $new = array();
+ }
if ( array_key_exists( 0, $new ) ) {
foreach ( $new as $item ) {
- $csv_output .= $this->prep_csv_data( $item->display_name ) . ',';
+ $display_name = is_array( $item ) && isset( $item['display_name'] ) ? $item['display_name'] : '';
+ $csv_output .= $this->prep_csv_data( $display_name ) . ',';
}
} elseif ( count( $new ) > 0 ) {
foreach ( $new as $key => $item ) {
@@ -155,13 +197,17 @@
$csv_output .= $this->prep_csv_data( $newkey ) . ',';
$csv_output .= $this->prep_csv_data( $dbdata->email ) . ',';
$csv_output .= $this->prep_csv_data( $currency . ' ' . $dbdata->amount ) . ',';
- $csv_output .= $this->prep_csv_data( substr( $dbdata->paid_at, 0, 10 ) ) . ',';
+ $csv_output .= $this->prep_csv_data( substr( (string) $dbdata->paid_at, 0, 10 ) ) . ',';
$csv_output .= $this->prep_csv_data( $txn_code ) . ',';
- $new = json_decode( $dbdata->metadata );
+ $new = json_decode( $dbdata->metadata, true );
+ if ( ! is_array( $new ) ) {
+ $new = array();
+ }
if ( array_key_exists( 0, $new ) ) {
foreach ( $new as $item ) {
- $csv_output .= $this->prep_csv_data( $item->value ) . ',';
+ $value = is_array( $item ) && isset( $item['value'] ) ? $item['value'] : '';
+ $csv_output .= $this->prep_csv_data( $value ) . ',';
}
} elseif ( count( $new ) > 0 ) {
foreach ( $new as $item ) {
@@ -172,7 +218,7 @@
$csv_output .= "n";
}
- $filename = $obj->post_title . "_payments_" . gmdate( 'Y-m-d_H-i' );
+ $filename = sanitize_file_name( $obj->post_title ) . "_payments_" . gmdate( 'Y-m-d_H-i' );
header( 'Content-Type: application/vnd.ms-excel' );
header( 'Content-Disposition: attachment; filename="' . $filename . '.csv"' );
--- a/payment-forms-for-paystack/paystack-forms.php
+++ b/payment-forms-for-paystack/paystack-forms.php
@@ -3,7 +3,7 @@
Plugin Name: Payment Forms for Paystack
Plugin URI: https://github.com/PaystackHQ/Wordpress-Payment-forms-for-Paystack
Description: Payment Forms for Paystack allows you create forms that will be used to bill clients for goods and services via Paystack.
- Version: 4.0.5
+ Version: 4.0.6
Author: Paystack
Author URI: http://paystack.com
License: GPL-2.0+
@@ -16,7 +16,7 @@
define( 'PFF_PAYSTACK_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
define( 'PFF_PAYSTACK_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'PFF_PAYSTACK_MAIN_FILE', __FILE__ );
-define( 'PFF_PAYSTACK_VERSION', '4.0.5' );
+define( 'PFF_PAYSTACK_VERSION', '4.0.6' );
define( 'PFF_PAYSTACK_TABLE', 'paystack_forms_payments' );
define( 'PFF_PLUGIN_BASENAME', plugin_basename(__FILE__) );
define( 'PFF_PLUGIN_NAME', 'pff-paystack' );