PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.5.18
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.5.18
1.19.8 1.19.7 1.19.6 1.19.5 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.12.0 1.13.0 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.16.7 1.16.8 1.17.0 1.17.6 1.17.7 1.17.8 1.17.9 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.18.5 1.18.6 1.18.7 1.18.8 1.18.9 1.19.0 1.19.1 1.19.2 1.19.3 1.19.4 1.3.19 1.3.20 1.4.0 1.4.1 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.8.1 1.8.3 1.9.0 1.9.1 1.9.2
nitropack / view / connect.php
nitropack / view Last commit date
images 3 years ago javascript 3 years ago stylesheet 3 years ago admin.php 3 years ago connect.php 3 years ago dashboard.php 3 years ago diag.php 3 years ago help.php 3 years ago safemode.php 3 years ago safemode.tpl 4 years ago
connect.php
138 lines
1 <div id="nitropack-container" class="wrap" style="visibility: hidden">
2 <div class="row">
3 <div class="col-md-12">
4 <div id="login-container">
5 <h3><?php esc_html_e( 'Welcome to NitroPack for WordPress!', 'nitropack' ); ?></h3>
6 <p><?php esc_html_e( 'This page will help you to connect your WordPress site with NitroPack in few steps.', 'nitropack' ); ?></p>
7 <img src="<?= plugin_dir_url(__FILE__) ?>/images/nitropackwp.jpg" alt="NitroPack"/>
8 <hr />
9 <h3><?php esc_html_e( 'Let\'s Get Started!', 'nitropack' ); ?></h3>
10 <p><?php esc_html_e( 'In order to connect NitroPack with WordPress you need to configure your API details. More information how to obtain these values can be found', 'nitropack' ); ?> <a href="https://nitropack.io/blog/post/how-to-get-your-site-id-and-site-secret" target="_blank">here <i class="fa fa-external-link"></i></a></p>
11 <form class="form-default" action="options.php" method="post" id="api-details-form">
12 <?php settings_fields( NITROPACK_OPTION_GROUP );
13 do_settings_sections( NITROPACK_OPTION_GROUP ); ?>
14 <div id="submitdiv" class="postbox ">
15 <h3><?php esc_html_e( 'Welcome!', 'nitropack' ); ?></h3>
16 <div id="manual-connect-fields" style="display:none;">
17 <h2><?php esc_html_e( 'Enter site ID and site secret to start using NitroPack', 'nitropack' ); ?></h2>
18 <input id="nitropack-siteid-input" name="nitropack-siteId" type="text" class="form-control" placeholder="<?php esc_html_e( 'Site ', 'nitropack' ); ?>">
19 <input id="nitropack-sitesecret-input" name="nitropack-siteSecret" type="text" class="form-control" placeholder="<?php esc_html_e( 'Site Secret', 'nitropack' ); ?>">
20 </div>
21 <div class="e-submit">
22 <a class="btn btn-primary white" id="api-details-form-submit" href="javascript:void(0);">
23 <i id="connect-spinner" class="fa fa-spinner fa-spin white" style="display:none;"></i>
24 <span id="connect-text"><?php esc_html_e( 'Connect to NitroPack', 'nitropack' ); ?></span>
25 </a>
26 <h1 id="connect-success" style="display:none;margin-bottom:auto;font-size:36px;"><i class="fa fa-check-circle"></i></h1>
27 </div>
28 <div class="clearfix"></div>
29 <a id="switch-connect-type" data-state="manual"><small><?php esc_html_e( 'Connect manually', 'nitropack' ); ?></small></a>
30 </div>
31 </form>
32 <p><?php esc_html_e( 'Having trouble connecting? Head over to', 'nitropack' ); ?> <a href="https://support.nitropack.io/" target="_blank" rel="noreferrer noopener">https://support.nitropack.io/</a>.</p>
33 </div>
34 </div>
35 </div>
36 </div>
37
38 <script>
39 (function($) {
40
41 let connectPopup = null;
42 let homePageUrl = "<?php echo get_home_url(); ?>";
43
44 window.addEventListener("message", function(e) {
45 if (e.data.messageType == "nitropack-connect") {
46 $("#nitropack-siteid-input").val(e.data.api.key);
47 $("#nitropack-sitesecret-input").val(e.data.api.secret);
48 $("#api-details-form-submit").click();
49 connectPopup.close();
50 connectPopup = null;
51 }
52 });
53
54 $("#api-details-form-submit").on("click", function(e) {
55
56 let siteId = $("#nitropack-siteid-input").val();
57 let siteSecret = $("#nitropack-sitesecret-input").val();
58 let isManualConnect = $("#manual-connect-fields").is(":visible");
59
60 if (isManualConnect || (siteId && siteSecret)) {
61 e.preventDefault();
62 $("#connect-spinner").show();
63 $("#connect-text").hide();
64 jQuery.post(ajaxurl, {
65 action: 'nitropack_verify_connect',
66 siteId: siteId,
67 siteSecret: siteSecret
68 }, function(response) {
69 $("#connect-spinner").hide();
70
71 var resp = JSON.parse(response);
72 if (resp.status == "success") {
73 location.reload();
74 $("#connect-success").show();
75 $("#api-details-form-submit").hide();
76 //$("#api-details-form").ajaxSubmit({
77 // complete: function() {
78 // location.reload();
79 // }
80 //});
81 return;
82 } else {
83 if (!isManualConnect) {
84 $("#nitropack-siteid-input").val("");
85 $("#nitropack-sitesecret-input").val("");
86 }
87
88 jQuery("#submitdiv .notice").remove();
89
90 if (resp.message) {
91 jQuery('#submitdiv').prepend('<div class="notice notice-error is-dismissible"><p style="word-break: break-word;">' + resp.message + '</p></div>');
92 } else {
93 jQuery('#submitdiv').prepend('<div class="notice notice-error is-dismissible"><p style="word-break: break-word;"><?php esc_html_e( "Api details verification failed! Please check whether you entered correct details.", "nitropack" ); ?></p></div>');
94 }
95
96 jQuery(".notice").addClass("shake"); //Adds Shake animation to the error notice box to catch user attention.
97 loadDismissibleNotices();
98 }
99 $("#connect-text").show();
100 });
101 } else if (!isManualConnect) {
102 if (!connectPopup || !connectPopup.window) {
103 let screenWidth = window.screen.availWidth;
104 let screenHeight = window.screen.availHeight;
105 let windowWidth = 500;
106 let windowHeight = 700;
107 let leftPos = window.top.outerWidth / 2 + window.top.screenX - ( windowWidth / 2);
108 let topPos = window.top.outerHeight / 2 + window.top.screenY - ( windowHeight / 2);
109
110 connectPopup = window.open("https://nitropack.io/auth?website=" + homePageUrl, "QuickConnect", "width=" + windowWidth + ",height=" + windowHeight + ",left=" + leftPos + ",top=" + topPos);
111 } else if (connectPopup && connectPopup.window) {
112 connectPopup.focus();
113 }
114 }
115 });
116
117 $('#switch-connect-type').on('click', function(){
118 let connectType = $(this).attr('data-state');
119
120 if ( 'auto' === connectType ) {
121 $('#manual-connect-fields').hide();
122 $('#submitdiv .notice').hide();
123 $('#switch-connect-type').html("<small><?php esc_html_e( 'Connect manually', 'nitropack' ); ?></small>");
124 $('#switch-connect-type').attr('data-state', 'manual');
125 }
126
127 if ( 'manual' === connectType ) {
128 $('#manual-connect-fields').show();
129 $('#submitdiv .notice').show();
130 $('#switch-connect-type').html("<small><?php esc_html_e( 'Connect automatically', 'nitropack' ); ?></small>");
131 $('#switch-connect-type').attr('data-state', 'auto');
132 }
133 });
134
135 })(jQuery);
136 </script>
137
138