Passed
Push — master ( bb494a...2d2581 )
by Nirjhar
02:12
created

CGSS_INSTALL::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
if ( ! defined( 'ABSPATH' ) ) exit;
3
4
/**
5
 * Implimentation of WordPress inbuilt functions for plugin activation.
6
 */
7
if ( ! class_exists( 'CGSS_INSTALL' ) ) {
8
9
	final class CGSS_INSTALL {
10
11
		//@string
12
		public $textDomin;
13
		//@string
14
		public $phpVerAllowed;
15
		/**
16
		$pluginPageLinks = array(
17
								array(
18
									'slug' => '',
19
									'label' => ''
20
								),
21
							);
22
		*/
23
		public $pluginPageLinks;
24
25
26
27
		public function execute() {
28
			add_action( 'plugins_loaded', array( $this, 'text_domain_cb' ) );
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

28
			/** @scrutinizer ignore-call */ 
29
   add_action( 'plugins_loaded', array( $this, 'text_domain_cb' ) );
Loading history...
29
			add_action( 'admin_notices', array( $this, 'php_ver_incompatible' ) );
30
			add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 );
0 ignored issues
show
Bug introduced by
The function add_filter was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
			/** @scrutinizer ignore-call */ 
31
   add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 );
Loading history...
31
		}
32
33
34
35
		//Load plugin textdomain
36
		public function text_domain_cb() {
37
38
			load_plugin_textdomain( $this->textDomin, false, CGSS_LN );
0 ignored issues
show
Bug introduced by
The function load_plugin_textdomain was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
			/** @scrutinizer ignore-call */ 
39
   load_plugin_textdomain( $this->textDomin, false, CGSS_LN );
Loading history...
Bug introduced by
The constant CGSS_LN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
39
		}
40
41
42
43
		//Define low php verson errors
44
		public function php_ver_incompatible() {
45
46
			if ( version_compare( phpversion(), $this->phpVerAllowed, '<' ) ) :
47
				$text = __( 'The Plugin can\'t be activated because your PHP version', 'InLinkMaster' );
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
				$text = /** @scrutinizer ignore-call */ __( 'The Plugin can\'t be activated because your PHP version', 'InLinkMaster' );
Loading history...
48
				$text_last = __( 'is less than required 5.3. See more information', 'InLinkMaster' );
49
				$text_link = 'php.net/eol.php'; ?>
50
51
				<div id="message" class="updated notice notice-success is-dismissible"><p><?php echo $text . ' ' . phpversion() . ' ' . $text_last . ': '; ?><a href="http://php.net/eol.php/" target="_blank"><?php echo $text_link; ?></a></p></div>
52
			<?php endif; return;
53
		}
54
55
56
57
		// Add settings link to plugin page
58
		public function menu_page_link( $links, $file ) {
59
60
			if ($this->pluginPageLinks) {
61
				static $this_plugin;
62
				if ( ! $this_plugin ) {
63
					$this_plugin = CGSS_FILE;
64
				}
65
				if ( $file == $this_plugin ) {
66
					$shift_link = array();
67
					foreach ($this->pluginPageLinks as $value) {
68
						$shift_link[] = '<a href="'.$value['slug'].'">'.$value['label'].'</a>';
69
					}
70
					foreach( $shift_link as $val ) {
71
						array_unshift( $links, $val );
72
					}
73
				}
74
				return $links;
75
			}
76
		}
77
	}
78
} ?>