| 1 |
<?php |
| 2 |
/** |
| 3 |
* Legacy Compatibility Layer |
| 4 |
* |
| 5 |
* Re-declares old WP_SUBSCRIPTION_* constants and wp_-prefixed function names |
| 6 |
* as thin wrappers around the canonical SUBSCRPT_* equivalents. |
| 7 |
* |
| 8 |
* This file is loaded immediately after the canonical constants and functions |
| 9 |
* are defined, so Pro plugin and any third-party code that depends on the old |
| 10 |
* names continues to work without modification. |
| 11 |
* |
| 12 |
* @package Subscription |
| 13 |
*/ |
| 14 |
|
| 15 |
// don't call the file directly. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
// --------------------------------------------------------------------------- |
| 21 |
// Legacy constants (WP_SUBSCRIPTION_* → SUBSCRPT_*) |
| 22 |
// --------------------------------------------------------------------------- |
| 23 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound |
| 24 |
$subscrpt_legacy_constants = array( |
| 25 |
'WP_SUBSCRIPTION_VERSION' => SUBSCRPT_VERSION, |
| 26 |
'WP_SUBSCRIPTION_FILE' => SUBSCRPT_FILE, |
| 27 |
'WP_SUBSCRIPTION_PATH' => SUBSCRPT_PATH, |
| 28 |
'WP_SUBSCRIPTION_INCLUDES' => SUBSCRPT_INCLUDES, |
| 29 |
'WP_SUBSCRIPTION_TEMPLATES' => SUBSCRPT_TEMPLATES, |
| 30 |
'WP_SUBSCRIPTION_URL' => SUBSCRPT_URL, |
| 31 |
'WP_SUBSCRIPTION_ASSETS' => SUBSCRPT_ASSETS, |
| 32 |
); |
| 33 |
|
| 34 |
foreach ( $subscrpt_legacy_constants as $subscrpt_old_name => $subscrpt_new_value ) { |
| 35 |
if ( ! defined( $subscrpt_old_name ) ) { |
| 36 |
define( $subscrpt_old_name, $subscrpt_new_value ); |
| 37 |
} |
| 38 |
} |
| 39 |
unset( $subscrpt_legacy_constants, $subscrpt_old_name, $subscrpt_new_value ); |
| 40 |
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound |
| 41 |
|
| 42 |
// --------------------------------------------------------------------------- |
| 43 |
// Legacy functions (wp_-prefixed → subscrpt_-prefixed) |
| 44 |
// --------------------------------------------------------------------------- |
| 45 |
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 46 |
|
| 47 |
if ( ! function_exists( 'wp_subscrpt_write_log' ) ) { |
| 48 |
/** |
| 49 |
* @deprecated Use subscrpt_write_log() instead. |
| 50 |
*/ |
| 51 |
function wp_subscrpt_write_log( $message, bool $should_print = false ): void { |
| 52 |
_deprecated_function( 'wp_subscrpt_write_log', '1.9.2', 'subscrpt_write_log' ); |
| 53 |
subscrpt_write_log( $message, $should_print ); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
if ( ! function_exists( 'wp_subscrpt_write_debug_log' ) ) { |
| 58 |
/** |
| 59 |
* @deprecated Use subscrpt_write_debug_log() instead. |
| 60 |
*/ |
| 61 |
function wp_subscrpt_write_debug_log( $log ): void { |
| 62 |
_deprecated_function( 'wp_subscrpt_write_debug_log', '1.9.2', 'subscrpt_write_debug_log' ); |
| 63 |
|
| 64 |
subscrpt_write_debug_log( $log ); |
| 65 |
} |
| 66 |
} |
| 67 |
|
| 68 |
if ( ! function_exists( 'wp_subs_multiselect_field' ) ) { |
| 69 |
/** |
| 70 |
* @deprecated Use subscrpt_multiselect_field() instead. |
| 71 |
*/ |
| 72 |
function wp_subs_multiselect_field( $field ) { |
| 73 |
_deprecated_function( 'wp_subs_multiselect_field', '1.9.2', 'subscrpt_multiselect_field' ); |
| 74 |
|
| 75 |
subscrpt_multiselect_field( $field ); |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
if ( ! function_exists( 'wp_subscription_register_paypal_block' ) ) { |
| 80 |
/** |
| 81 |
* @deprecated Use subscrpt_register_paypal_block() instead. |
| 82 |
*/ |
| 83 |
function wp_subscription_register_paypal_block() { |
| 84 |
_deprecated_function( 'wp_subscription_register_paypal_block', '1.9.2', 'subscrpt_register_paypal_block' ); |
| 85 |
|
| 86 |
subscrpt_register_paypal_block(); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound |
| 91 |
|
| 92 |
// --------------------------------------------------------------------------- |
| 93 |
// Legacy filters (deprecated hook names bridged onto canonical ones) |
| 94 |
// --------------------------------------------------------------------------- |
| 95 |
|
| 96 |
if ( ! function_exists( 'subscrpt_legacy_split_payment_next_due_date' ) ) { |
| 97 |
/** |
| 98 |
* Bridge the deprecated `subscrpt_split_payment_next_due_date` filter. |
| 99 |
* |
| 100 |
* The split-payment-scoped hook was replaced by the general-purpose |
| 101 |
* `subscrpt_subscription_next_date`. Any code still hooking the old name keeps |
| 102 |
* working (with a deprecation notice) via this bridge. |
| 103 |
* |
| 104 |
* @deprecated 1.11.0 Use the `subscrpt_subscription_next_date` filter instead. |
| 105 |
* |
| 106 |
* @param int|null $next_date Computed next payment timestamp, or null. |
| 107 |
* @param int $subscription_id Subscription ID. |
| 108 |
* @param string $recurr_timing Recurring timing string. |
| 109 |
* @param string $type Subscription history type. |
| 110 |
* |
| 111 |
* @return int|null |
| 112 |
*/ |
| 113 |
function subscrpt_legacy_split_payment_next_due_date( $next_date, $subscription_id, $recurr_timing, $type ) { |
| 114 |
if ( has_filter( 'subscrpt_split_payment_next_due_date' ) ) { |
| 115 |
$next_date = apply_filters_deprecated( |
| 116 |
'subscrpt_split_payment_next_due_date', |
| 117 |
[ $next_date, $subscription_id, $recurr_timing, $type ], |
| 118 |
'1.11.0', |
| 119 |
'subscrpt_subscription_next_date' |
| 120 |
); |
| 121 |
} |
| 122 |
return $next_date; |
| 123 |
} |
| 124 |
} |
| 125 |
add_filter( 'subscrpt_subscription_next_date', 'subscrpt_legacy_split_payment_next_due_date', 5, 4 ); |
| 126 |
|