PluginProbe
Nested Pages / 1.0
Nested Pages v1.0
3.3.1 3.2.15 3.2.14 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 All 106 releases
wp-nested-pages / includes / class-np-activate.php
class-np-activate.php
89 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Activation
4 */
5 require_once('class-np-navmenu.php');
6 class NP_Activate {
7
8 /**
9 * Plugin Version
10 */
11 private $version;
12
13
14 public function __construct()
15 {
16 register_activation_hook( dirname( dirname(__FILE__) ) . '/nestedpages.php', array($this, 'install') );
17 $this->version = 1.0;
18 $this->setVersion();
19 $this->addMenu();
20 }
21
22
23 /**
24 * Activation Hook
25 */
26 public function install()
27 {
28 $this->checkVersions();
29 $this->setOptions();
30 }
31
32
33 /**
34 * Check Wordpress and PHP versions
35 */
36 private function checkVersions( $wp = '3.9', $php = '5.3.0' ) {
37 global $wp_version;
38 if ( version_compare( PHP_VERSION, $php, '<' ) )
39 $flag = 'PHP';
40 elseif ( version_compare( $wp_version, $wp, '<' ) )
41 $flag = 'WordPress';
42 else
43 return;
44 $version = 'PHP' == $flag ? $php : $wp;
45 deactivate_plugins( basename( __FILE__ ) );
46
47 wp_die('<p><strong>Nested Pages</strong> plugin requires'.$flag.' version '.$version.' or greater.</p>','Plugin Activation Error', array( 'response'=>200, 'back_link'=>TRUE ) );
48 }
49
50
51 /**
52 * Set the Plugin Version
53 */
54 private function setVersion()
55 {
56 if ( !get_option('nestedpages_version') ){
57 update_option('nestedpages_version', $this->version);
58 }
59 elseif ( get_option('nestedpages_version') < $this->version ){
60 update_option('nestedpages_version', $this->version);
61 }
62 }
63
64
65 /**
66 * Add the nav menu
67 */
68 public function addMenu()
69 {
70 $menu_e = get_term_by('slug', 'nestedpages', 'nav_menu');
71 if ( !$menu_e ){
72 $menu = new NP_NavMenu;
73 $menu->addMenu();
74 }
75 }
76
77
78 /**
79 * Set Default Options
80 */
81 private function setOptions()
82 {
83 if ( !get_option('nestedpages_menusync') ){
84 update_option('nestedpages_menusync', 'sync');
85 }
86 }
87
88
89 }