Completed
Push — master ( 764d24...7cd13b )
by Chris
01:37
created

src/eduadmin-wordpress-sveawebpay.php (5 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
defined( 'ABSPATH' ) or die( 'This plugin must be run within the scope of WordPress.' );
3
4
/*
5
 * Plugin Name:	EduAdmin Booking - SVEA Webpay-plugin
6
 * Plugin URI:	http://www.eduadmin.se
7
 * Description:	EduAdmin plugin to allow visitors to book courses at your website
8
 * Tags:	booking, participants, courses, events, eduadmin, lega online
9
 * Version:	$PLUGINVERSION$
10
 * GitHub Plugin URI: multinetinteractive/eduadmin-wordpress-sveawebpay
11
 * GitHub Plugin URI: https://github.com/multinetinteractive/eduadmin-wordpress-sveawebpay
12
 * Requires at least: $PLUGINATLEAST$
13
 * Tested up to: $PLUGINTESTEDTO$
14
 * Author:	Chris Gårdenberg, MultiNet Interactive AB
15
 * Author URI:	http://www.multinet.se
16
 * License:	GPL3
17
 * Text Domain:	eduadmin-sveawebpay
18
 * Domain Path: /languages/
19
 */
20
/*
21
    EduAdmin Booking plugin
22
    Copyright (C) 2015-2021 Chris Gårdenberg, MultiNet Interactive AB
23
24
    This program is free software: you can redistribute it and/or modify
25
    it under the terms of the GNU General Public License as published by
26
    the Free Software Foundation, either version 3 of the License, or
27
    (at your option) any later version.
28
29
    This program is distributed in the hope that it will be useful,
30
    but WITHOUT ANY WARRANTY; without even the implied warranty of
31
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
32
    GNU General Public License for more details.
33
34
    You should have received a copy of the GNU General Public License
35
    along with this program. If not, see <http://www.gnu.org/licenses/>.
36
 */
37
38
add_action( 'admin_init', 'checkForEduAdminPlugin' );
39 View Code Duplication
function checkForEduAdminPlugin() {
0 ignored issues
show
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
The function checkForEduAdminPlugin() has been defined more than once; this definition is ignored, only the first definition in eduadmin-wordpress-sveawebpay.php (L39-53) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
40
	if ( is_admin() && current_user_can( 'activate_plugins' ) && ( ! is_plugin_active( 'eduadmin-booking/eduadmin.php' ) && ! is_plugin_active( 'eduadmin/eduadmin.php' ) ) ) {
41
		add_action( 'admin_notices', function () {
42
			?>
43
            <div class="error">
44
            <p><?php _e( 'This plugin requires the EduAdmin-WordPress-plugin to be installed and activated.', 'eduadmin-sveawebpay' ); ?></p>
45
            </div><?php
46
		} );
47
		deactivate_plugins( plugin_basename( __FILE__ ) );
48
49
		if ( isset( $_GET['activate'] ) ) {
50
			unset( $_GET['activate'] );
51
		}
52
	}
53
}
54
55 View Code Duplication
if ( ! class_exists( 'EDU_SveaWebPay_Loader' ) ):
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
57
	final class EDU_SveaWebPay_Loader {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type EDU_SveaWebPay_Loader has been defined more than once; this definition is ignored, only the first definition in eduadmin-wordpress-sveawebpay.php (L57-76) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
58
		public function __construct() {
59
			add_action( 'plugins_loaded', array( $this, 'init' ) );
60
		}
61
62
		public function init() {
63
			if ( class_exists( 'EDU_Integration' ) ) {
64
				require_once( __DIR__ . '/vendor/autoload.php' ); // Load dependencies
65
				require_once( __DIR__ . '/class/class-edu-sveawebpay.php' );
66
67
				add_filter( 'edu_integrations', array( $this, 'add_integration' ) );
68
			}
69
		}
70
71
		public function add_integration( $integrations ) {
72
			$integrations[] = 'EDU_SveaWebPay';
73
74
			return $integrations;
75
		}
76
	}
77
78
	$edu_sveawebpay_loader = new EDU_SveaWebPay_Loader( __FILE__ );
0 ignored issues
show
The call to EDU_SveaWebPay_Loader::__construct() has too many arguments starting with __FILE__.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
79
endif;
80