PluginProbe
Yandex Pay and Split / trunk
Yandex Pay and Split vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9
yandex-pay-and-split / yandex-pay-and-split.php

yandex-pay-and-split.php in Yandex Pay and Split trunk, at yandex-pay-and-split.php

174 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Yandex Pay and Split
4 * Plugin URI: https://wordpress.org/plugins/yandex-pay-and-split/
5 * Description: The official Yandex Pay and Split module for WooCommerce
6 * Author: Yandex LLC
7 * Author URI: https://pay.yandex.ru
8 * Version: 1.1.13
9 * Requires at least: 6.0
10 * Requires PHP: 7.3
11 * WC requires at least: 7.7.2
12 * License: GPLv2 or later
13 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
14 * Text Domain: yandex-pay-and-split
15 * Domain Path: /i18n/languages/
16 *
17 * @package WooCommerce\Classes\Payment
18 */
19
20 /*
21 Copyright (C) 2000 - 2025 Yandex LLC
22
23 This program is free software: you can redistribute it and/or
24 modify it under the terms of the GNU General Public License
25 as published by the Free Software Foundation, either version 2
26 of the License, or any later version.
27
28 This program is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU General Public License for more details.
32
33 You should have received a copy of the GNU General Public License
34 along with this program; if not, write to the Free Software
35 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
36 */
37
38 defined( 'ABSPATH' ) || exit();
39
40 defined( 'YANDEX_PAY_AND_SPLIT_ASSETS_PREFIX' ) ||
41 define( 'YANDEX_PAY_AND_SPLIT_ASSETS_PREFIX', 'yandex_pay_and_split' );
42 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_VERSION' ) ||
43 define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_VERSION', '1.1.13' );
44 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_CARD_GATEWAY_ID' ) ||
45 define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_CARD_GATEWAY_ID', 'yandex-pay-and-split-card' );
46 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_SPLIT_GATEWAY_ID' ) ||
47 define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_SPLIT_GATEWAY_ID', 'yandex-pay-and-split-split' );
48 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_DIR' ) || define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_DIR', __DIR__ );
49 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_BASE' ) ||
50 define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_BASE', plugin_basename( __FILE__ ) );
51 defined( 'YANDEX_PAY_AND_SPLIT_PLUGIN_URL' ) ||
52 define( 'YANDEX_PAY_AND_SPLIT_PLUGIN_URL', plugins_url( '', __FILE__ ) );
53 defined( 'YANDEX_PAY_AND_SPLIT_MIN_WC_VERSION' ) ||
54 define( 'YANDEX_PAY_AND_SPLIT_MIN_WC_VERSION', '7.7.2' );
55 defined( 'YANDEX_PAY_AND_SPLIT_MIN_PHP_VERSION' ) ||
56 define( 'YANDEX_PAY_AND_SPLIT_MIN_PHP_VERSION', '7.3.0' );
57 defined( 'YANDEX_PAY_LOG_SOURCE' ) || define( 'YANDEX_PAY_LOG_SOURCE', 'yandex_pay' );
58 defined( 'YANDEX_SPLIT_LOG_SOURCE' ) || define( 'YANDEX_SPLIT_LOG_SOURCE', 'yandex_split' );
59
60 defined( 'YANDEX_PAY_AND_SPLIT_IS_BLOCKS_SUPPORTS' ) || define( 'YANDEX_PAY_AND_SPLIT_IS_BLOCKS_SUPPORTS', false );
61
62 /**
63 * Load lib and vendor solutions
64 */
65 require_once YANDEX_PAY_AND_SPLIT_PLUGIN_DIR . '/lib/class-autoloader.php';
66 if ( \YandexPay\Lib\Autoloader::init() ) {
67 \YandexPay\Lib\Autoloader::init();
68 }
69
70 /**
71 * Checks whether WooCommerce is installed and compatible by version
72 *
73 * @return bool WooCommerce version comparing flag.
74 */
75 function yandex_pay_and_split_check_wc_compare() {
76 if (
77 ! class_exists( 'WooCommerce' ) ||
78 version_compare( WC()->version, YANDEX_PAY_AND_SPLIT_MIN_WC_VERSION, '<' )
79 ) {
80 return false;
81 }
82
83 return true;
84 }
85
86 /**
87 * Checks PHP is compatible by version
88 *
89 * @return bool PHP version comparing flag.
90 */
91 function yandex_pay_and_split_check_php_compare() {
92 if ( version_compare( phpversion(), YANDEX_PAY_AND_SPLIT_MIN_PHP_VERSION, '<' ) ) {
93 return false;
94 }
95
96 return true;
97 }
98
99 /**
100 * Displays a notification for administrator
101 *
102 * @param string $message message for render in admin notice.
103 */
104 function yandex_pay_and_split_render_admin_notice( $message ) {
105 echo '<div class="notice notice-error is-dismissible"><p>' . esc_html( $message ) . '</p></div>';
106 }
107
108 add_action(
109 'admin_notices',
110 function () {
111 if ( ! yandex_pay_and_split_check_wc_compare() ) {
112 yandex_pay_and_split_render_admin_notice(
113 sprintf(
114 /* translators: 1) required WooCommerce version */
115 __(
116 'Yandex Pay and Split for WooCommerce payment gateway requires WooCommerce version %s or higher to work properly. Please update WooCommerce to use this plugin.',
117 'yandex-pay-and-split'
118 ),
119 YANDEX_PAY_AND_SPLIT_MIN_WC_VERSION
120 )
121 );
122 }
123
124 if ( ! yandex_pay_and_split_check_php_compare() ) {
125 yandex_pay_and_split_render_admin_notice(
126 sprintf(
127 /* translators: 1) required PHP version */
128 __(
129 'Yandex Pay and Split for WooCommerce payment gateway requires PHP version %s or higher to work properly. Please update PHP to use this plugin.',
130 'yandex-pay-and-split'
131 ),
132 YANDEX_PAY_AND_SPLIT_MIN_PHP_VERSION
133 )
134 );
135 }
136 }
137 );
138
139 add_action(
140 'plugins_loaded',
141 function () {
142 require_once YANDEX_PAY_AND_SPLIT_PLUGIN_DIR . '/includes/class-wc-yandex-pay-and-split.php';
143
144 if (
145 ! in_array(
146 'woocommerce/woocommerce.php',
147 apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
148 true
149 )
150 ) {
151 return;
152 }
153
154 WC_Yandex_Pay_And_Split::init_translation();
155
156 if ( ! yandex_pay_and_split_check_wc_compare() ) {
157 return;
158 }
159
160 return WC_Yandex_Pay_And_Split::get_instance();
161 },
162 5
163 );
164
165 add_action(
166 'activate_' . YANDEX_PAY_AND_SPLIT_PLUGIN_BASE,
167 array( '\YandexPay\Lib\PLuginLifecycle', 'activate' )
168 );
169
170 add_action(
171 'deactivate_' . YANDEX_PAY_AND_SPLIT_PLUGIN_BASE,
172 array( '\YandexPay\Lib\PLuginLifecycle', 'deactivate' )
173 );
174