| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
/** |
| 4 |
* The admin-specific functionality of the plugin. |
| 5 |
* |
| 6 |
* @link http://rextheme.com/ |
| 7 |
* @since 8.0.0 |
| 8 |
* |
| 9 |
* @package Wpvr |
| 10 |
* @subpackage Wpvr/admin/classes |
| 11 |
*/ |
| 12 |
|
| 13 |
class WPVR_Admin_Page { |
| 14 |
|
| 15 |
/** |
| 16 |
* Instance of WPVR_Admin_Page class |
| 17 |
* |
| 18 |
* @var object |
| 19 |
* @since 8.0.0 |
| 20 |
*/ |
| 21 |
static $instance; |
| 22 |
|
| 23 |
|
| 24 |
private function __construct() |
| 25 |
{ |
| 26 |
// Register WPVR menu |
| 27 |
add_action('admin_menu', array($this, 'wpvr_add_admin_pages')); |
| 28 |
// Display confirmation alert |
| 29 |
add_action('admin_footer', array($this, 'vpvr_confirmation_alert_display')); |
| 30 |
} |
| 31 |
|
| 32 |
|
| 33 |
/** |
| 34 |
* Declared to overwrite magic method __clone() |
| 35 |
* In order to prevent object cloning |
| 36 |
* |
| 37 |
* @return void |
| 38 |
* @since 8.0.0 |
| 39 |
*/ |
| 40 |
private function __clone() |
| 41 |
{ |
| 42 |
// Do nothing |
| 43 |
} |
| 44 |
|
| 45 |
|
| 46 |
/** |
| 47 |
* Create instance of this class |
| 48 |
* |
| 49 |
* @return object |
| 50 |
* @since 8.0.0 |
| 51 |
*/ |
| 52 |
public static function getInstance() |
| 53 |
{ |
| 54 |
if(!(self::$instance instanceof self)) { |
| 55 |
self::$instance = new self(); |
| 56 |
} |
| 57 |
return self::$instance; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
/** |
| 62 |
* Admin page setup is specified in this area. |
| 63 |
* |
| 64 |
* @since 8.0.0 |
| 65 |
*/ |
| 66 |
function wpvr_add_admin_pages() { |
| 67 |
add_menu_page( 'WP VR', 'WP VR', 'manage_options', 'wpvr', array( $this, 'wpvr_admin_doc'),plugins_url(). '/wpvr/images/icon.png' , 25); |
| 68 |
add_submenu_page( 'wpvr', 'WP VR', __('Get Started','wpvr'),'manage_options', 'wpvr', array( $this, 'wpvr_admin_doc')); |
| 69 |
remove_submenu_page('wpvr', 'wpvr'); |
| 70 |
|
| 71 |
add_submenu_page( 'wpvr', 'WP VR', __('Tours','wpvr'),'manage_options', 'edit.php?post_type=wpvr_item', NULL); |
| 72 |
|
| 73 |
add_submenu_page( 'wpvr', 'WP VR', __('Add New Tour','wpvr'),'manage_options', 'post-new.php?post_type=wpvr_item', NULL); |
| 74 |
do_action('wpvr_pro_before_guided_tour'); |
| 75 |
add_submenu_page( 'wpvr', 'WP VR', __('Settings','wpvr'),'manage_options', 'wpvr-setting', array($this,'wpvr_setting_page')); |
| 76 |
|
| 77 |
// add_submenu_page( 'wpvr', 'WP VR', __('Guided Tour','wpvr'),'manage_options', 'wpvr-setup-wizard', array($this,'wpvr_setup_wizard')); |
| 78 |
|
| 79 |
if (!is_plugin_active('wpvr-pro/wpvr-pro.php')) { |
| 80 |
add_submenu_page( 'wpvr', 'WP VR', __('Free vs Pro','wpvr'),'manage_options', 'wpvr', array( $this, 'wpvr_admin_doc')); |
| 81 |
} |
| 82 |
|
| 83 |
add_submenu_page( 'wpvr', 'WP VR', __('Setup Wizard','wpvr'),'manage_options', 'rex-wpvr-setup-wizard', array( $this, 'wpvr_new_setup_wizard')); |
| 84 |
do_action('wpvr_pro_license_page'); |
| 85 |
|
| 86 |
|
| 87 |
if(!is_plugin_active('wpvr-pro/wpvr-pro.php')){ |
| 88 |
add_submenu_page( |
| 89 |
'wpvr', |
| 90 |
'', |
| 91 |
'<span id="wpvr-gopro-submenu" class="dashicons dashicons-star-filled" style="font-size: 17px; color:#1fb3fb;"></span> ' . __( 'Go Pro', 'wpvr' ), |
| 92 |
'manage_options', |
| 93 |
esc_url( 'https://rextheme.com/wpvr/wpvr-pricing/' ) |
| 94 |
); |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
/** |
| 100 |
* Provide setup wizard area view for the plugin |
| 101 |
* |
| 102 |
* @since 8.0.0 |
| 103 |
*/ |
| 104 |
function wpvr_setup_wizard(){ |
| 105 |
require_once plugin_dir_path(__FILE__) . '../partials/wpvr_setup_wizard.php'; |
| 106 |
} |
| 107 |
/** |
| 108 |
* Provide setup wizard area view for the plugin |
| 109 |
* |
| 110 |
* @since 8.0.0 |
| 111 |
*/ |
| 112 |
function wpvr_setting_page(){ |
| 113 |
require_once plugin_dir_path(__FILE__) . '../partials/wpvr_setting.php'; |
| 114 |
} |
| 115 |
|
| 116 |
/** |
| 117 |
* Provide a admin area view for the plugin |
| 118 |
* |
| 119 |
* @since 8.0.0 |
| 120 |
*/ |
| 121 |
function wpvr_admin_doc() { |
| 122 |
require_once plugin_dir_path(__FILE__) . '../partials/wpvr_documentation.php'; |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
/** |
| 127 |
* Provide license key submission or plugin activition page |
| 128 |
* |
| 129 |
* @since 8.0.0 |
| 130 |
*/ |
| 131 |
function wpvr_pro_admin_doc() { |
| 132 |
require_once plugin_dir_path(__FILE__) . '../partials/wpvr_license.php'; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
/** |
| 137 |
* Provide cofiramtion alert for events |
| 138 |
* |
| 139 |
* @since 8.0.0 |
| 140 |
*/ |
| 141 |
function vpvr_confirmation_alert_display() { |
| 142 |
require_once plugin_dir_path(__FILE__) . '../partials/wpvr_confirmation_alert.php'; |
| 143 |
} |
| 144 |
|
| 145 |
function wpvr_new_setup_wizard() { |
| 146 |
add_action('admin_menu', function () { |
| 147 |
add_dashboard_page('WPVR Setup', 'WPVR Setup', 'manage_options', 'wpvr-setup-wizard', function () { |
| 148 |
return ''; |
| 149 |
}); |
| 150 |
}); |
| 151 |
add_action('current_screen', function () { |
| 152 |
( new WPVR_Setup_Wizard() )->setup_wizard(); |
| 153 |
}, 999); |
| 154 |
} |
| 155 |
|
| 156 |
} |
| 157 |
|