| 1 |
<?php |
| 2 |
/** |
| 3 |
* Setup wizard for the plugin |
| 4 |
* |
| 5 |
* @package '' |
| 6 |
* @since 8.4.10 |
| 7 |
*/ |
| 8 |
|
| 9 |
class WPVR_Setup_Wizard |
| 10 |
{ |
| 11 |
|
| 12 |
/** |
| 13 |
* Initialize setup wizards |
| 14 |
* |
| 15 |
* @since 8.4.10 |
| 16 |
*/ |
| 17 |
public function setup_wizard() |
| 18 |
{ |
| 19 |
add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); |
| 20 |
$this->output_html(); |
| 21 |
} |
| 22 |
|
| 23 |
public function enqueue_scripts($hook) { |
| 24 |
if (!isset($_GET['page']) || $_GET['page'] !== 'rex-wpvr-setup-wizard') { |
| 25 |
return; |
| 26 |
} |
| 27 |
wp_enqueue_media(); |
| 28 |
|
| 29 |
wp_enqueue_style( |
| 30 |
'wpvr-admin-post-type', |
| 31 |
plugin_dir_url( __DIR__ ) . 'admin/css/wpvr-admin-post-type.css', |
| 32 |
[], |
| 33 |
WPVR_VERSION |
| 34 |
); |
| 35 |
wp_enqueue_style( |
| 36 |
'wpvr-setup-wizard', |
| 37 |
WPVR_CSS_PATH . 'setup-wizard.css', |
| 38 |
[ 'wpvr-admin-post-type' ], |
| 39 |
WPVR_VERSION |
| 40 |
); |
| 41 |
wp_enqueue_style( |
| 42 |
'wpvr-pannellum-css', |
| 43 |
WPVR_PLUGIN_DIR_URL . 'admin/lib/pannellum/src/css/pannellum.css', |
| 44 |
[], |
| 45 |
WPVR_VERSION |
| 46 |
); |
| 47 |
wp_enqueue_style( |
| 48 |
'wpvr-image-resize-warning', |
| 49 |
WPVR_PLUGIN_DIR_URL . 'admin/css/wpvr-image-resize-warning.css', |
| 50 |
array(), |
| 51 |
filemtime( WPVR_PLUGIN_DIR_PATH . 'admin/css/wpvr-image-resize-warning.css' ) |
| 52 |
); |
| 53 |
|
| 54 |
wp_enqueue_script( |
| 55 |
'wpvr-libpannellum-js', |
| 56 |
WPVR_PLUGIN_DIR_URL . 'admin/lib/pannellum/src/js/libpannellum.js', |
| 57 |
['jquery'], |
| 58 |
WPVR_VERSION, |
| 59 |
true |
| 60 |
); |
| 61 |
wp_enqueue_script( |
| 62 |
'wpvr-pannellum-js', |
| 63 |
WPVR_PLUGIN_DIR_URL . 'admin/lib/pannellum/src/js/pannellum.js', |
| 64 |
['jquery'], |
| 65 |
WPVR_VERSION, |
| 66 |
true |
| 67 |
); |
| 68 |
wp_enqueue_script( |
| 69 |
'wpvr-onboarding-js', |
| 70 |
WPVR_PLUGIN_DIR_URL . 'admin/lib/onboarding/js/onboarding.js', |
| 71 |
['jquery'], |
| 72 |
WPVR_VERSION, |
| 73 |
true |
| 74 |
); |
| 75 |
wp_enqueue_script( |
| 76 |
'wpvr-image-resize-warning', |
| 77 |
WPVR_PLUGIN_DIR_URL . 'admin/js/wpvr-image-resize-warning.js', |
| 78 |
array( 'jquery' ), |
| 79 |
filemtime( WPVR_PLUGIN_DIR_PATH . 'admin/js/wpvr-image-resize-warning.js' ), |
| 80 |
true |
| 81 |
); |
| 82 |
wp_enqueue_script( |
| 83 |
'wpvr-setup-wizard', |
| 84 |
WPVR_JS_PATH . 'setup-wizard.js', |
| 85 |
array( 'jquery', 'wpvr-image-resize-warning' ), |
| 86 |
filemtime( WPVR_PLUGIN_DIR_PATH . 'admin/js/setup-wizard.js' ), |
| 87 |
true |
| 88 |
); |
| 89 |
|
| 90 |
wp_localize_script( |
| 91 |
'wpvr-setup-wizard', |
| 92 |
'wpvrSetupWizardData', |
| 93 |
array( |
| 94 |
'ajaxurl' => admin_url( 'admin-ajax.php' ), |
| 95 |
'ajax_nonce' => wp_create_nonce( 'wpvr' ), |
| 96 |
'is_pro' => (bool) apply_filters( 'is_wpvr_pro_active', false ), |
| 97 |
'hotspot_limit' => 5, |
| 98 |
'upgrade_url' => esc_url( 'https://rextheme.com/wpvr/pricing/' ), |
| 99 |
'image_resize_warning' => array( |
| 100 |
'heading' => __( 'Keep this panorama in High Resolution', 'wpvr' ), |
| 101 |
'scaled_message' => __( 'By default, a resized version is created while the original image is still available.', 'wpvr' ), |
| 102 |
'disable_handler' => __( 'Disable WordPress Large Image Handler on WP VR for future uploads', 'wpvr' ), |
| 103 |
'high_resolution_note' => __( '*Note: Turn this on to use the high-resolution image.', 'wpvr' ), |
| 104 |
'close' => __( 'Close', 'wpvr' ), |
| 105 |
'can_manage_settings' => current_user_can( 'manage_options' ), |
| 106 |
'setting_enabled' => get_option( 'high_res_image' ) === 'true', |
| 107 |
), |
| 108 |
'wizard_strings' => array( |
| 109 |
'limit_heading' => __( 'Limit Reached', 'wpvr' ), |
| 110 |
/* translators: %d: maximum number of hotspots allowed in free version */ |
| 111 |
'limit_line1' => sprintf( __( 'You can add up to %d hotspots on each scene in the Free version.', 'wpvr' ), 5 ), |
| 112 |
'limit_line2' => __( 'Upgrade to Pro to add an unlimited number of hotspots.', 'wpvr' ), |
| 113 |
), |
| 114 |
) |
| 115 |
); |
| 116 |
} |
| 117 |
|
| 118 |
/** |
| 119 |
* Output the rendered contents |
| 120 |
* |
| 121 |
* @since 8.4.10 |
| 122 |
*/ |
| 123 |
private function output_html() |
| 124 |
{ |
| 125 |
require_once plugin_dir_path(__FILE__) . '../admin/partials/wpvr-setup-wizard-views.php'; |
| 126 |
exit(); |
| 127 |
} |
| 128 |
} |
| 129 |
|