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' ) ); |
|
|
|
|
29
|
|
|
add_action( 'admin_notices', array( $this, 'php_ver_incompatible' ) ); |
30
|
|
|
add_filter( 'plugin_action_links', array( $this, 'menu_page_link' ), 10, 2 ); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
|
34
|
|
|
|
35
|
|
|
//Load plugin textdomain |
36
|
|
|
public function text_domain_cb() { |
37
|
|
|
|
38
|
|
|
load_plugin_textdomain( $this->textDomin, false, CGSS_LN ); |
|
|
|
|
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' ); |
|
|
|
|
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
|
|
|
} ?> |