| 1 |
<?php |
| 2 |
|
| 3 |
// TODO add review notice similar to wpforms |
| 4 |
|
| 5 |
// Load dependency for get_plugins; |
| 6 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 7 |
|
| 8 |
// Add Knit Pay Deactivate Confirmation Box on Plugin Page |
| 9 |
require_once 'includes/plugin-deactivate-confirmation.php'; |
| 10 |
|
| 11 |
// Add Supported Extension and Gateways Sub-menu in Knit Pay Menu |
| 12 |
require_once 'includes/supported-extension-gateway-submenu.php'; |
| 13 |
|
| 14 |
// Add custom Knit Pay Custom Payment Methods. |
| 15 |
require_once 'includes/custom-payment-methods.php'; |
| 16 |
|
| 17 |
// Add custom Knit Pay Custom Settings on the Settings page of Knit Pay. |
| 18 |
require_once 'includes/CustomSettings.php'; |
| 19 |
|
| 20 |
// Currency Converter. |
| 21 |
require_once 'includes/CurrencyConverter.php'; |
| 22 |
|
| 23 |
// Including Knit Pay OmniPay PayPal for better compatibility. |
| 24 |
require_once 'secondary-packages/vendor/knit-pay/omnipay-paypal/src/RestGateway.php'; |
| 25 |
require_once 'secondary-packages/vendor/knit-pay/omnipay-paypal/src/Message/AbstractRestRequest.php'; |
| 26 |
|
| 27 |
require_once 'includes/PaymentRestController.php'; |
| 28 |
|
| 29 |
// WordPress Abilities API integration (WordPress 6.9+). |
| 30 |
require_once 'includes/PaymentAbilities.php'; |
| 31 |
|
| 32 |
require_once 'includes/customizations.php'; |
| 33 |
|
| 34 |
require_once 'includes/hooks_mapping.php'; |
| 35 |
|
| 36 |
/* |
| 37 |
* FIXME: This is workaround for fixing |
| 38 |
* Translation loading for the knit-pay-lang domain was triggered too early. |
| 39 |
* see: https://make.wordpress.org/core/2024/10/21/i18n-improvements-6-7/ |
| 40 |
*/ |
| 41 |
add_filter( |
| 42 |
'lang_dir_for_domain', |
| 43 |
function ( $dir, $domain ) { |
| 44 |
if ( 'knit-pay-lang' === $domain ) { |
| 45 |
return ''; |
| 46 |
} |
| 47 |
return $dir; |
| 48 |
}, |
| 49 |
10, |
| 50 |
2 |
| 51 |
); |
| 52 |
|
| 53 |
add_action( 'plugins_loaded', 'knit_pay_pro_init', -9 ); |
| 54 |
function knit_pay_pro_init() { |
| 55 |
if ( ! defined( 'KNIT_PAY_PRO' ) && ! defined( 'KNIT_PAY_UPI' ) ) { |
| 56 |
return; |
| 57 |
} |
| 58 |
|
| 59 |
if ( ! class_exists( 'KnitPayPro_Setup' ) ) { |
| 60 |
require_once 'includes/knit-pay-pro-setup.php'; |
| 61 |
} |
| 62 |
|
| 63 |
require_once 'includes/pro.php'; |
| 64 |
} |
| 65 |
|
| 66 |
add_action( |
| 67 |
'in_plugin_update_message-knit-pay/knit-pay.php', |
| 68 |
function ( $plugin_data ) { |
| 69 |
$new_version = implode( '.', array_slice( explode( '.', $plugin_data['new_version'] ), 0, 3 ) ); |
| 70 |
if ( version_compare( $new_version, KNITPAY_VERSION, '<=' ) ) { |
| 71 |
return; |
| 72 |
} |
| 73 |
|
| 74 |
?> |
| 75 |
<hr/> |
| 76 |
<h3> |
| 77 |
<?php echo esc_html__( 'Heads up! Please backup before upgrading!', 'knit-pay-lang' ); ?> |
| 78 |
</h3> |
| 79 |
<div> |
| 80 |
<?php echo esc_html__( 'The latest update includes some substantial changes across different areas of the plugin. We highly recommend you backup your site before upgrading, and make sure you first update in a staging environment', 'knit-pay-lang' ); ?> |
| 81 |
</div> |
| 82 |
<?php |
| 83 |
} |
| 84 |
); |
| 85 |
|
| 86 |
// Show notice to write review. |
| 87 |
// require_once 'includes/review-request-notice.php'; |
| 88 |
|
| 89 |
// Global Defines |
| 90 |
define( 'KNITPAY_GLOBAL_GATEWAY_LIST_URL', 'https://wordpress.org/plugins/knit-pay/#:~:text=Supported%20payment%20providers' ); |
| 91 |
|
| 92 |
if ( ! function_exists( 'ppp' ) ) { |
| 93 |
function ppp( $a = '' ) { |
| 94 |
echo '<pre>'; |
| 95 |
print_r( $a ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_print_r |
| 96 |
echo '</pre><br><br>'; |
| 97 |
do_action( 'qm/info', $a ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
if ( ! function_exists( 'ddd' ) ) { |
| 102 |
function ddd( $a = '' ) { |
| 103 |
echo nl2br( '<pre>' . PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL . PHP_EOL ); |
| 104 |
debug_print_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_debug_print_backtrace |
| 105 |
echo '</pre>'; |
| 106 |
wp_die(); |
| 107 |
} |
| 108 |
} |
| 109 |
|
| 110 |
if ( ! function_exists( 'ttt' ) ) { |
| 111 |
function ttt( $operation = '', $name = 'kp_speed' ) { |
| 112 |
switch ( $operation ) { |
| 113 |
case 's': // start |
| 114 |
$operation = 'qm/start'; |
| 115 |
break; |
| 116 |
case 'e': // end |
| 117 |
$operation = 'qm/stop'; |
| 118 |
break; |
| 119 |
case 'l': |
| 120 |
default: |
| 121 |
$operation = 'qm/lap'; |
| 122 |
break; |
| 123 |
} |
| 124 |
|
| 125 |
do_action( $operation, $name ); |
| 126 |
} |
| 127 |
} |
| 128 |
|