PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.14.0
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.14.0
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 2 years ago javascript 2 years ago stylesheet 2 years ago admin.php 2 years ago connect-oneclick.php 2 years ago connect.php 2 years ago dashboard-oneclick.php 2 years ago dashboard.php 2 years ago diag.php 2 years ago help.php 3 years ago oneclick.php 2 years ago safemode.php 2 years ago safemode.tpl 4 years ago
connect.php
140 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 API Key and API Secret Key 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( 'API Key ', 'nitropack' ); ?>">
19 <input id="nitropack-sitesecret-input" name="nitropack-siteSecret" type="text" class="form-control" placeholder="<?php esc_html_e( 'API Secret Key', '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="<?php echo NITROPACK_SUPPORT_BUBBLE_URL; ?>" target="_blank" rel="noreferrer noopener"><?php echo NITROPACK_SUPPORT_BUBBLE_URL; ?></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 let nitroNonce = '<?php echo wp_create_nonce(NITROPACK_NONCE); ?>';
44
45 window.addEventListener("message", function(e) {
46 if (e.data.messageType == "nitropack-connect") {
47 $("#nitropack-siteid-input").val(e.data.api.key);
48 $("#nitropack-sitesecret-input").val(e.data.api.secret);
49 $("#api-details-form-submit").click();
50 connectPopup.close();
51 connectPopup = null;
52 }
53 });
54
55 $("#api-details-form-submit").on("click", function(e) {
56
57 let siteId = $("#nitropack-siteid-input").val();
58 let siteSecret = $("#nitropack-sitesecret-input").val();
59 let isManualConnect = $("#manual-connect-fields").is(":visible");
60
61 if (isManualConnect || (siteId && siteSecret)) {
62 e.preventDefault();
63 $("#connect-spinner").show();
64 $("#connect-text").hide();
65 jQuery.post(ajaxurl, {
66 action: 'nitropack_verify_connect',
67 siteId: siteId,
68 siteSecret: siteSecret,
69 nonce: nitroNonce
70 }, function(response) {
71 $("#connect-spinner").hide();
72
73 var resp = JSON.parse(response);
74 if (resp.status == "success") {
75 location.reload();
76 $("#connect-success").show();
77 $("#api-details-form-submit").hide();
78 //$("#api-details-form").ajaxSubmit({
79 // complete: function() {
80 // location.reload();
81 // }
82 //});
83 return;
84 } else {
85 if (!isManualConnect) {
86 $("#nitropack-siteid-input").val("");
87 $("#nitropack-sitesecret-input").val("");
88 }
89
90 jQuery("#submitdiv .notice").remove();
91
92 if (resp.message) {
93 jQuery('#submitdiv').prepend('<div class="notice notice-error is-dismissible"><p style="word-break: break-word;">' + resp.message + '</p></div>');
94 } else {
95 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>');
96 }
97
98 jQuery(".notice").addClass("shake"); //Adds Shake animation to the error notice box to catch user attention.
99 loadDismissibleNotices();
100 }
101 $("#connect-text").show();
102 });
103 } else if (!isManualConnect) {
104 if (!connectPopup || !connectPopup.window) {
105 let screenWidth = window.screen.availWidth;
106 let screenHeight = window.screen.availHeight;
107 let windowWidth = 500;
108 let windowHeight = 700;
109 let leftPos = window.top.outerWidth / 2 + window.top.screenX - ( windowWidth / 2);
110 let topPos = window.top.outerHeight / 2 + window.top.screenY - ( windowHeight / 2);
111
112 connectPopup = window.open("https://<?php echo NITROPACKIO_HOST; ?>/auth?website=" + homePageUrl, "QuickConnect", "width=" + windowWidth + ",height=" + windowHeight + ",left=" + leftPos + ",top=" + topPos);
113 } else if (connectPopup && connectPopup.window) {
114 connectPopup.focus();
115 }
116 }
117 });
118
119 $('#switch-connect-type').on('click', function(){
120 let connectType = $(this).attr('data-state');
121
122 if ( 'auto' === connectType ) {
123 $('#manual-connect-fields').hide();
124 $('#submitdiv .notice').hide();
125 $('#switch-connect-type').html("<small><?php esc_html_e( 'Connect manually', 'nitropack' ); ?></small>");
126 $('#switch-connect-type').attr('data-state', 'manual');
127 }
128
129 if ( 'manual' === connectType ) {
130 $('#manual-connect-fields').show();
131 $('#submitdiv .notice').show();
132 $('#switch-connect-type').html("<small><?php esc_html_e( 'Connect automatically', 'nitropack' ); ?></small>");
133 $('#switch-connect-type').attr('data-state', 'auto');
134 }
135 });
136
137 })(jQuery);
138 </script>
139
140