1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | defined( 'ABSPATH' ) || die( 'This plugin must be run within the scope of WordPress.' ); |
||
3 | |||
4 | /* |
||
5 | * Plugin Name: EduAdmin Booking - Klarna Checkout-plugin |
||
6 | * Plugin URI: https://www.eduadmin.se |
||
7 | * Description: Plugin to EduAdmin Booking to enable Klarna Checkout-integration |
||
8 | * Version: 1.0.3 |
||
9 | * GitHub Plugin Uri: https://github.com/MultinetInteractive/eduadmin-wp-klarna-checkout |
||
10 | * Requires at least: 4.7 |
||
11 | * Tested up to: 4.9 |
||
12 | * Author: Chris Gårdenberg, MultiNet Interactive AB |
||
13 | * Author URI: https://www.multinet.com |
||
14 | * License: GPL3 |
||
15 | * Text Domain: eduadmin-wp-klarna-checkout |
||
16 | */ |
||
17 | /* |
||
18 | EduAdmin Booking plugin |
||
19 | Copyright (C) 2015-2018 Chris Gårdenberg, MultiNet Interactive AB |
||
20 | This program is free software: you can redistribute it and/or modify |
||
21 | it under the terms of the GNU General Public License as published by |
||
22 | the Free Software Foundation, either version 3 of the License, or |
||
23 | (at your option) any later version. |
||
24 | This program is distributed in the hope that it will be useful, |
||
25 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
26 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
27 | GNU General Public License for more details. |
||
28 | You should have received a copy of the GNU General Public License |
||
29 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
||
30 | */ |
||
31 | |||
32 | add_action( 'admin_init', function () { |
||
33 | if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) { |
||
34 | add_action( 'admin_notices', function () { |
||
35 | ?> |
||
36 | <div class="error"> |
||
37 | <p><?php esc_html_e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-wp-klarna-checkout' ); ?></p> |
||
38 | </div> |
||
39 | <?php |
||
40 | } ); |
||
41 | deactivate_plugins( plugin_basename( __FILE__ ) ); |
||
42 | if ( isset( $_GET['activate'] ) ) { |
||
0 ignored issues
–
show
|
|||
43 | unset( $_GET['activate'] ); |
||
0 ignored issues
–
show
|
|||
44 | } |
||
45 | } |
||
46 | } ); |
||
47 | |||
48 | if ( ! class_exists( 'EDU_KlarnaCheckout_Loader' ) ) { |
||
49 | final class EDU_KlarnaCheckout_Loader { |
||
50 | public function __construct() { |
||
51 | add_action( 'plugins_loaded', array( $this, 'init' ) ); |
||
52 | } |
||
53 | |||
54 | public function init() { |
||
55 | if ( ! class_exists( 'Klarna_Checkout_Connector' ) ) { |
||
56 | require_once __DIR__ . '/klarna_kco_php_4.0.0/src/Klarna/Checkout.php'; |
||
57 | } |
||
58 | |||
59 | if ( class_exists( 'EDU_Integration' ) ) { |
||
60 | |||
61 | require_once __DIR__ . '/class-edu-klarnacheckout.php'; |
||
62 | |||
63 | add_filter( 'edu_integrations', array( $this, 'add_integration' ) ); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | public function add_integration( $integrations ) { |
||
68 | $integrations[] = 'EDU_KlarnaCheckout'; |
||
69 | |||
70 | return $integrations; |
||
71 | } |
||
72 | } |
||
73 | |||
74 | $edu_klarnacheckout_loader = new EDU_KlarnaCheckout_Loader(); |
||
75 | } |
||
76 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.