| @@ -1,521 +1,463 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace RadiusTheme\SB\Controllers\Admin; | |
| 4 | - | |
| 5 | -use RadiusTheme\SB\Traits\SingletonTrait; | |
| 6 | - | |
| 7 | -// Do not allow directly accessing this file. | |
| 8 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | - exit( 'This script cannot be accessed directly.' ); | |
| 10 | -} | |
| 11 | - | |
| 12 | -/** | |
| 13 | - * Settings Page. | |
| 14 | - */ | |
| 15 | -class PluginRow { | |
| 16 | - /** | |
| 17 | - * Singleton Trait. | |
| 18 | - */ | |
| 19 | - use SingletonTrait; | |
| 20 | - | |
| 21 | - /** | |
| 22 | - * Template builder post type | |
| 23 | - * | |
| 24 | - * @var string | |
| 25 | - */ | |
| 26 | - public string $textdomain = 'shopbuilder'; | |
| 27 | - | |
| 28 | - /** | |
| 29 | - * Construct function | |
| 30 | - */ | |
| 31 | - private function __construct() { | |
| 32 | - // Plugins Setting Page. | |
| 33 | - add_filter( 'plugin_action_links_' . plugin_basename( RTSB_FILE ), [ $this, 'plugins_setting_links' ] ); | |
| 34 | - add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); | |
| 35 | - add_action( 'admin_footer', [ $this, 'deactivation_popup' ], 99 ); | |
| 36 | - } | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * @param array $links default plugin action link. | |
| 40 | - * | |
| 41 | - * @return array [array] plugin action link | |
| 42 | - */ | |
| 43 | - public function plugins_setting_links( $links ) { | |
| 44 | - $new_links = []; | |
| 45 | - $demo_url = 'https://shopbuilderwp.com/'; | |
| 46 | - $new_links[] = '<a href="' . admin_url( 'admin.php?page=rtsb-settings' ) . '">' . esc_html__( 'Settings', 'shopbuilder' ) . '</a>'; | |
| 47 | - $new_links[] = '<a target="_blank" href="' . esc_url( $demo_url ) . '">' . esc_html__( 'Demo', 'shopbuilder' ) . '</a>'; | |
| 48 | - $new_links[] = '<a target="_blank" href="' . esc_url( 'https://www.radiustheme.com/docs/shopbuilder/getting-started/requirements/' ) . '">' . esc_html__( 'Documentation', 'shopbuilder' ) . '</a>'; | |
| 49 | - | |
| 50 | - $links = array_merge( $new_links, $links ); | |
| 51 | - | |
| 52 | - if ( ! rtsb()->has_pro() ) { | |
| 53 | - $links['shopbuilder_pro'] = '<a href="' . esc_url( rtsb()->pro_version_link() ) . '" target="_blank" style="color: #39b54a; font-weight: bold;">' . esc_html__( 'Go Pro', 'shopbuilder' ) . '</a>'; | |
| 54 | - } | |
| 55 | - | |
| 56 | - return $links; | |
| 57 | - } | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Plugin links row. | |
| 61 | - * | |
| 62 | - * @param array $links Links. | |
| 63 | - * @param string $file File. | |
| 64 | - * | |
| 65 | - * @return array | |
| 66 | - */ | |
| 67 | - public function plugin_row_meta( $links, $file ) { | |
| 68 | - | |
| 69 | - if ( RTSB_ACTIVE_FILE_NAME === $file ) { | |
| 70 | - $report_url = 'https://www.radiustheme.com/contact/'; | |
| 71 | - $row_meta['issues'] = sprintf( | |
| 72 | - '%2$s <a target="_blank" href="%1$s"><span style="color: red">%3$s</span></a>', | |
| 73 | - esc_url( $report_url ), | |
| 74 | - esc_html__( 'Facing issue?', 'shopbuilder' ), | |
| 75 | - esc_html__( 'Please open a support ticket.', 'shopbuilder' ) | |
| 76 | - ); | |
| 77 | - | |
| 78 | - return array_merge( $links, $row_meta ); | |
| 79 | - } | |
| 80 | - | |
| 81 | - return (array) $links; | |
| 82 | - } | |
| 83 | - | |
| 84 | - // Servay | |
| 85 | - | |
| 86 | - /*** | |
| 87 | - * @param $mimes | |
| 88 | - * | |
| 89 | - * @return mixed | |
| 90 | - */ | |
| 91 | - public function deactivation_popup() { | |
| 92 | - global $pagenow; | |
| 93 | - if ( 'plugins.php' !== $pagenow ) { | |
| 94 | - return; | |
| 95 | - } | |
| 96 | - | |
| 97 | - $this->dialog_box_style(); | |
| 98 | - $this->deactivation_scripts(); | |
| 99 | - ?> | |
| 100 | - <div id="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>" title="Quick Feedback"> | |
| 101 | - <!-- Modal content --> | |
| 102 | - <div class="modal-content"> | |
| 103 | - <div id="feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?>"> | |
| 104 | - <div class="feedback-input-header"> | |
| 105 | - <?php echo esc_html__( 'If you have a moment, please share why you are deactivating ShopBuilder:', 'shopbuilder' ); ?> | |
| 106 | - </div> | |
| 107 | - | |
| 108 | - <div class="feedback-input-wrapper"> | |
| 109 | - <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-input" | |
| 110 | - type="radio" name="reason_key" value="bug_issue_detected"> | |
| 111 | - <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-label">Bug Or Issue detected.</label> | |
| 112 | - </div> | |
| 113 | - | |
| 114 | - <div class="feedback-input-wrapper"> | |
| 115 | - <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-input" type="radio" | |
| 116 | - name="reason_key" value="no_longer_needed"> | |
| 117 | - <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-label">I no longer | |
| 118 | - need the plugin</label> | |
| 119 | - </div> | |
| 120 | - <div class="feedback-input-wrapper conditional"> | |
| 121 | - <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-input" | |
| 122 | - type="radio" name="reason_key" value="found_a_better_plugin"> | |
| 123 | - <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-label">I found a | |
| 124 | - better plugin</label> | |
| 125 | - <input class="feedback-feedback-text" type="text" name="reason_found_a_better_plugin" | |
| 126 | - placeholder="Please share the plugin name"> | |
| 127 | - </div> | |
| 128 | - <div class="feedback-input-wrapper"> | |
| 129 | - <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-input" | |
| 130 | - type="radio" name="reason_key" value="couldnt_get_the_plugin_to_work"> | |
| 131 | - <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-label">I | |
| 132 | - couldn't get the plugin to work</label> | |
| 133 | - </div> | |
| 134 | - | |
| 135 | - <div class="feedback-input-wrapper"> | |
| 136 | - <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-input" | |
| 137 | - type="radio" name="reason_key" value="temporary_deactivation"> | |
| 138 | - <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-label">It's a | |
| 139 | - temporary deactivation</label> | |
| 140 | - </div> | |
| 141 | - <span style="color:red;font-size: 13px;"></span> | |
| 142 | - </div> | |
| 143 | - <p style="margin: 10px 0 15px 0;"> | |
| 144 | - Please let us know about any issues you are facing with the plugin. | |
| 145 | - How can we improve the plugin? | |
| 146 | - </p> | |
| 147 | - <div class="feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?>"> | |
| 148 | - <textarea id="deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>" rows="4" cols="40" | |
| 149 | - placeholder=" Write something here. How can we improve the plugin?"></textarea> | |
| 150 | - <span style="display: block;color:red;font-size: 13px;margin-top: 5px;"></span> | |
| 151 | - </div> | |
| 152 | - </div> | |
| 153 | - </div> | |
| 154 | - <?php | |
| 155 | - } | |
| 156 | - | |
| 157 | - /*** | |
| 158 | - * @param $mimes | |
| 159 | - * | |
| 160 | - * @return mixed | |
| 161 | - */ | |
| 162 | - public function dialog_box_style() { | |
| 163 | - ?> | |
| 164 | - <style> | |
| 165 | - /* Add Animation */ | |
| 166 | - @-webkit-keyframes animatetop { | |
| 167 | - from { | |
| 168 | - top: -300px; | |
| 169 | - opacity: 0 | |
| 170 | - } | |
| 171 | - to { | |
| 172 | - top: 0; | |
| 173 | - opacity: 1 | |
| 174 | - } | |
| 175 | - } | |
| 176 | - | |
| 177 | - @keyframes animatetop { | |
| 178 | - from { | |
| 179 | - top: -300px; | |
| 180 | - opacity: 0 | |
| 181 | - } | |
| 182 | - to { | |
| 183 | - top: 0; | |
| 184 | - opacity: 1 | |
| 185 | - } | |
| 186 | - } | |
| 187 | - | |
| 188 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> { | |
| 189 | - display: none; | |
| 190 | - } | |
| 191 | - | |
| 192 | - .ui-dialog-titlebar-close { | |
| 193 | - display: none; | |
| 194 | - } | |
| 195 | - | |
| 196 | - /* The Modal (background) */ | |
| 197 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal { | |
| 198 | - display: none; /* Hidden by default */ | |
| 199 | - position: fixed; /* Stay in place */ | |
| 200 | - z-index: 1; /* Sit on top */ | |
| 201 | - padding-top: 100px; /* Location of the box */ | |
| 202 | - left: 0; | |
| 203 | - top: 0; | |
| 204 | - width: 100%; /* Full width */ | |
| 205 | - height: 100%; /* Full height */ | |
| 206 | - overflow: auto; /* Enable scroll if needed */ | |
| 207 | - } | |
| 208 | - | |
| 209 | - /* Modal Content */ | |
| 210 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content { | |
| 211 | - position: relative; | |
| 212 | - margin: auto; | |
| 213 | - padding: 0; | |
| 214 | - } | |
| 215 | - | |
| 216 | - /*#deactivation-dialog-*/<?php //echo esc_attr( $this->textdomain ); ?>/* .feedback-label {*/ | |
| 217 | - /* font-size: 15px;*/ | |
| 218 | - /*}*/ | |
| 219 | - | |
| 220 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> p { | |
| 221 | - font-size: 15px; | |
| 222 | - } | |
| 223 | - | |
| 224 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content > * { | |
| 225 | - width: 100%; | |
| 226 | - overflow: hidden; | |
| 227 | - } | |
| 228 | - | |
| 229 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea { | |
| 230 | - border: 1px solid rgba(0, 0, 0, 0.3); | |
| 231 | - padding: 15px; | |
| 232 | - width: 100%; | |
| 233 | - } | |
| 234 | - | |
| 235 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea:focus { | |
| 236 | - border-color: #2271b1; | |
| 237 | - } | |
| 238 | - | |
| 239 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input.feedback-feedback-text { | |
| 240 | - border: 1px solid rgba(0, 0, 0, 0.3); | |
| 241 | - min-width: 250px; | |
| 242 | - } | |
| 243 | - | |
| 244 | - /* The Close Button */ | |
| 245 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"] { | |
| 246 | - margin: 0; | |
| 247 | - } | |
| 248 | - | |
| 249 | - .ui-dialog-title { | |
| 250 | - font-size: 18px; | |
| 251 | - font-weight: 600; | |
| 252 | - } | |
| 253 | - | |
| 254 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-body { | |
| 255 | - padding: 2px 16px; | |
| 256 | - } | |
| 257 | - | |
| 258 | - .ui-dialog-buttonset { | |
| 259 | - background-color: #fefefe; | |
| 260 | - padding: 0 17px 25px; | |
| 261 | - display: flex; | |
| 262 | - justify-content: space-between; | |
| 263 | - gap: 10px; | |
| 264 | - } | |
| 265 | - | |
| 266 | - .ui-dialog-buttonset button { | |
| 267 | - min-width: 110px; | |
| 268 | - text-align: center; | |
| 269 | - border: 1px solid rgba(0, 0, 0, 0.1); | |
| 270 | - padding: 0 15px; | |
| 271 | - border-radius: 5px; | |
| 272 | - height: 40px; | |
| 273 | - font-size: 15px; | |
| 274 | - font-weight: 600; | |
| 275 | - display: inline-flex; | |
| 276 | - align-items: center; | |
| 277 | - justify-content: center; | |
| 278 | - cursor: pointer; | |
| 279 | - transition: 0.3s all; | |
| 280 | - background: rgba(0, 0, 0, 0.02); | |
| 281 | - margin: 0; | |
| 282 | - } | |
| 283 | - | |
| 284 | - .ui-dialog-buttonset button:nth-child(2) { | |
| 285 | - background: transparent; | |
| 286 | - } | |
| 287 | - | |
| 288 | - .ui-dialog-buttonset button:hover { | |
| 289 | - background: #2271b1; | |
| 290 | - color: #fff; | |
| 291 | - } | |
| 292 | - | |
| 293 | - .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] { | |
| 294 | - background-color: #fefefe; | |
| 295 | - box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); | |
| 296 | - z-index: 99; | |
| 297 | - } | |
| 298 | - | |
| 299 | - .ui-dialog[aria-describedby="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>"] .ui-dialog-title { | |
| 300 | - text-transform: uppercase; | |
| 301 | - font-weight: 700; | |
| 302 | - font-size: 16px; | |
| 303 | - padding-left: 15px; | |
| 304 | - padding-right: 15px; | |
| 305 | - } | |
| 306 | - | |
| 307 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> { | |
| 308 | - padding: 30px !important; | |
| 309 | - } | |
| 310 | - | |
| 311 | - #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .feedback-input-header { | |
| 312 | - font-weight: 600; | |
| 313 | - font-size: 15px; | |
| 314 | - line-height: 1.4; | |
| 315 | - margin-bottom: 20px; | |
| 316 | - } | |
| 317 | - | |
| 318 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>, | |
| 319 | - .ui-draggable .ui-dialog-titlebar { | |
| 320 | - padding: 18px 15px; | |
| 321 | - box-shadow: 0 0 3px rgba(0, 0, 0, 0.1); | |
| 322 | - text-align: left; | |
| 323 | - } | |
| 324 | - | |
| 325 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper { | |
| 326 | - margin-bottom: 8px; | |
| 327 | - display: flex; | |
| 328 | - align-items: center; | |
| 329 | - gap: 8px; | |
| 330 | - /*line-height: 2;*/ | |
| 331 | - padding: 0 1px; | |
| 332 | - font-size: 14px; | |
| 333 | - } | |
| 334 | - | |
| 335 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional { | |
| 336 | - flex-wrap: wrap; | |
| 337 | - } | |
| 338 | - | |
| 339 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text { | |
| 340 | - flex: 0 0 calc(100% - 24px); | |
| 341 | - margin: 5px 0 10px 24px; | |
| 342 | - min-height: 40px; | |
| 343 | - border: 1px solid rgba(0, 0, 0, 0.3); | |
| 344 | - padding: 0 15px; | |
| 345 | - } | |
| 346 | - | |
| 347 | - div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content .feedback-input-wrapper.conditional .feedback-feedback-text:focus { | |
| 348 | - border-color: #2271b1; | |
| 349 | - } | |
| 350 | - | |
| 351 | - .ui-widget-overlay.ui-front { | |
| 352 | - position: fixed; | |
| 353 | - top: 0; | |
| 354 | - left: 0; | |
| 355 | - right: 0; | |
| 356 | - bottom: 0; | |
| 357 | - z-index: 999; | |
| 358 | - background-color: rgba(0, 0, 0, 0.5); | |
| 359 | - } | |
| 360 | - | |
| 361 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset { | |
| 362 | - background-color: #fefefe; | |
| 363 | - box-shadow: none; | |
| 364 | - z-index: 99; | |
| 365 | - padding-left: 30px; | |
| 366 | - padding-right: 30px; | |
| 367 | - } | |
| 368 | - | |
| 369 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonpane, | |
| 370 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-widget-content { | |
| 371 | - border: 0; | |
| 372 | - } | |
| 373 | - | |
| 374 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-resizable-handle { | |
| 375 | - display: none !important; | |
| 376 | - } | |
| 377 | - | |
| 378 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button { | |
| 379 | - font-size: 12px; | |
| 380 | - font-weight: 500; | |
| 381 | - line-height: 1.2; | |
| 382 | - padding: 8px 16px; | |
| 383 | - outline: none; | |
| 384 | - border: none; | |
| 385 | - } | |
| 386 | - | |
| 387 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child { | |
| 388 | - background: #4360ef; | |
| 389 | - color: #fff; | |
| 390 | - } | |
| 391 | - | |
| 392 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:first-child:hover { | |
| 393 | - background: #1f3edc; | |
| 394 | - } | |
| 395 | - | |
| 396 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child { | |
| 397 | - background: none; | |
| 398 | - } | |
| 399 | - | |
| 400 | - .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] .ui-dialog-buttonset .ui-button:last-child:hover { | |
| 401 | - background: #d80e0e; | |
| 402 | - color: #fff; | |
| 403 | - } | |
| 404 | - </style> | |
| 405 | - | |
| 406 | - <?php | |
| 407 | - } | |
| 408 | - | |
| 409 | - /*** | |
| 410 | - * @param $mimes | |
| 411 | - * | |
| 412 | - * @return mixed | |
| 413 | - */ | |
| 414 | - public function deactivation_scripts() { | |
| 415 | - wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 416 | - ?> | |
| 417 | - <script> | |
| 418 | - jQuery(document).ready(function ($) { | |
| 419 | - | |
| 420 | - // Open the deactivation dialog when the 'Deactivate' link is clicked | |
| 421 | - $('.deactivate #deactivate-shopbuilder').on('click', function (e) { | |
| 422 | - e.preventDefault(); | |
| 423 | - var href = $('.deactivate #deactivate-shopbuilder').attr('href'); | |
| 424 | - $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').hide(); | |
| 425 | - var dialogbox = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog({ | |
| 426 | - modal: true, | |
| 427 | - width: 550, | |
| 428 | - show: { | |
| 429 | - effect: "fadeIn", | |
| 430 | - duration: 400 | |
| 431 | - }, | |
| 432 | - hide: { | |
| 433 | - effect: "fadeOut", | |
| 434 | - duration: 100 | |
| 435 | - }, | |
| 436 | - | |
| 437 | - buttons: { | |
| 438 | - Submit: function () { | |
| 439 | - submitFeedback(); | |
| 440 | - }, | |
| 441 | - Cancel: function () { | |
| 442 | - $(this).dialog('close'); | |
| 443 | - window.location.href = href; | |
| 444 | - } | |
| 445 | - } | |
| 446 | - }); | |
| 447 | - | |
| 448 | - | |
| 449 | - // Close the dialog when clicking outside of it | |
| 450 | - dialogbox.on('change', 'input[type="radio"]', function (event) { | |
| 451 | - var reasons = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"]:checked').val(); | |
| 452 | - if( 'found_a_better_plugin' === reasons ){ | |
| 453 | - $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').show(); | |
| 454 | - } else { | |
| 455 | - $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').hide(); | |
| 456 | - } | |
| 457 | - }); | |
| 458 | - | |
| 459 | - // Close the dialog when clicking outside of it | |
| 460 | - $(document).on('click', '.ui-widget-overlay.ui-front', function (event) { | |
| 461 | - if ($(event.target).closest(dialogbox.parent()).length === 0) { | |
| 462 | - dialogbox.dialog('close'); | |
| 463 | - } | |
| 464 | - }); | |
| 465 | - | |
| 466 | - // Customize the button text | |
| 467 | - $('.ui-dialog-buttonpane button:contains("Submit")').text('Submit & Deactivate'); | |
| 468 | - $('.ui-dialog-buttonpane button:contains("Cancel")').text('Skip & Deactivate'); | |
| 469 | - }); | |
| 470 | - | |
| 471 | - // Submit the feedback | |
| 472 | - function submitFeedback() { | |
| 473 | - var href = $('.deactivate #deactivate-shopbuilder').attr('href'); | |
| 474 | - var reasons = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"]:checked').val(); | |
| 475 | - var feedback = $('#deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>').val(); | |
| 476 | - var better_plugin = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').val(); | |
| 477 | - // Perform AJAX request to submit feedback | |
| 478 | - if (!reasons && !feedback && !better_plugin) { | |
| 479 | - // Define flag variables | |
| 480 | - $('#feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?> span').text('Choose The Reason'); | |
| 481 | - $('.feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?> span').text('Please provide me with some advice.'); | |
| 482 | - return; | |
| 483 | - } | |
| 484 | - | |
| 485 | - if ('temporary_deactivation' == reasons && !feedback) { | |
| 486 | - window.location.href = href; | |
| 487 | - return; | |
| 488 | - } | |
| 489 | - | |
| 490 | - $.ajax({ | |
| 491 | - url: 'https://shopbuilderwp.com/wp-json/RadiusTheme/pluginSurvey/v1/Survey/appendToSheet', | |
| 492 | - method: 'GET', | |
| 493 | - dataType: 'json', | |
| 494 | - data: { | |
| 495 | - website: '<?php echo esc_url( home_url() ); ?>', | |
| 496 | - reasons: reasons ? reasons : '', | |
| 497 | - better_plugin: better_plugin, | |
| 498 | - feedback: feedback, | |
| 499 | - wpplugin: 'ShopBuilder', | |
| 500 | - }, | |
| 501 | - success: function (response) { | |
| 502 | - }, | |
| 503 | - error: function (xhr, status, error) { | |
| 504 | - // Handle the error response | |
| 505 | - console.error('Error', error); | |
| 506 | - }, | |
| 507 | - complete: function (xhr, status) { | |
| 508 | - $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog('close'); | |
| 509 | - window.location.href = href; | |
| 510 | - } | |
| 511 | - | |
| 512 | - }); | |
| 513 | - } | |
| 514 | - | |
| 515 | - }); | |
| 516 | - | |
| 517 | - </script> | |
| 518 | - | |
| 519 | - <?php | |
| 520 | - } | |
| 521 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace RadiusTheme\SB\Controllers\Admin; | |
| 4 | + | |
| 5 | +use RadiusTheme\SB\Traits\SingletonTrait; | |
| 6 | + | |
| 7 | +// Do not allow directly accessing this file. | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + exit( 'This script cannot be accessed directly.' ); | |
| 10 | +} | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * Settings Page. | |
| 14 | + */ | |
| 15 | +class PluginRow { | |
| 16 | + /** | |
| 17 | + * Singleton Trait. | |
| 18 | + */ | |
| 19 | + use SingletonTrait; | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * Template builder post type | |
| 23 | + * | |
| 24 | + * @var string | |
| 25 | + */ | |
| 26 | + public string $textdomain = 'shopbuilder'; | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * Construct function | |
| 30 | + */ | |
| 31 | + private function __construct() { | |
| 32 | + // Plugins Setting Page. | |
| 33 | + add_filter( 'plugin_action_links_' . plugin_basename( RTSB_FILE ), [ $this, 'plugins_setting_links' ] ); | |
| 34 | + add_filter( 'plugin_row_meta', [ $this, 'plugin_row_meta' ], 10, 2 ); | |
| 35 | + add_action( 'admin_footer', [ $this, 'deactivation_popup' ], 99 ); | |
| 36 | + } | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * @param array $links default plugin action link | |
| 40 | + * | |
| 41 | + * @return array [array] plugin action link | |
| 42 | + */ | |
| 43 | + public function plugins_setting_links( $links ) { | |
| 44 | + $demo_url = 'https://shopbuilderwp.com/'; | |
| 45 | + $links[] = '<a href="' . admin_url( 'admin.php?page=rtsb-settings' ) . '">' . esc_html__( 'Settings', 'shopbuilder' ) . '</a>'; | |
| 46 | + $links[] = '<a target="_blank" href="' . esc_url( $demo_url ) . '">' . esc_html__( 'Demo', 'shopbuilder' ) . '</a>'; | |
| 47 | + $links[] = '<a target="_blank" href="' . esc_url( 'https://www.radiustheme.com/docs/shopbuilder/getting-started/requirements/' ) . '">' . esc_html__( 'Documentation', 'shopbuilder' ) . '</a>'; | |
| 48 | + // TODO:: This function will apply after pro version. | |
| 49 | + if ( ! rtsb()->has_pro() ) { | |
| 50 | + // $links['shopbuilder_pro'] = sprintf( '<a href="#" target="_blank" style="color: #39b54a; font-weight: bold;">' . esc_html__( 'Go Pro', 'shopbuilder' ) . '</a>' ); | |
| 51 | + } | |
| 52 | + | |
| 53 | + return $links; | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * Plugin links row. | |
| 58 | + * | |
| 59 | + * @param array $links Links. | |
| 60 | + * @param string $file File. | |
| 61 | + * | |
| 62 | + * @return array | |
| 63 | + */ | |
| 64 | + public function plugin_row_meta( $links, $file ) { | |
| 65 | + | |
| 66 | + if ( RTSB_ACTIVE_FILE_NAME === $file ) { | |
| 67 | + $report_url = 'https://www.radiustheme.com/contact/'; | |
| 68 | + $row_meta['issues'] = sprintf( | |
| 69 | + '%2$s <a target="_blank" href="%1$s"><span style="color: red">%3$s</span></a>', | |
| 70 | + esc_url( $report_url ), | |
| 71 | + esc_html__( 'Facing issue?', 'shopbuilder' ), | |
| 72 | + esc_html__( 'Please open a support ticket.', 'shopbuilder' ) | |
| 73 | + ); | |
| 74 | + | |
| 75 | + return array_merge( $links, $row_meta ); | |
| 76 | + } | |
| 77 | + | |
| 78 | + return (array) $links; | |
| 79 | + } | |
| 80 | + | |
| 81 | + // Servay | |
| 82 | + | |
| 83 | + /*** | |
| 84 | + * @param $mimes | |
| 85 | + * | |
| 86 | + * @return mixed | |
| 87 | + */ | |
| 88 | + public function deactivation_popup() { | |
| 89 | + global $pagenow; | |
| 90 | + if ( 'plugins.php' !== $pagenow ) { | |
| 91 | + return; | |
| 92 | + } | |
| 93 | + | |
| 94 | + $this->dialog_box_style(); | |
| 95 | + $this->deactivation_scripts(); | |
| 96 | + ?> | |
| 97 | + <div id="deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>" title="Quick Feedback"> | |
| 98 | + <!-- Modal content --> | |
| 99 | + <div class="modal-content"> | |
| 100 | + <div id="feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?>"> | |
| 101 | + | |
| 102 | + <div class="feedback-input-wrapper"> | |
| 103 | + <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-input" | |
| 104 | + type="radio" name="reason_key" value="bug_issue_detected"> | |
| 105 | + <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-bug_issue_detected" class="feedback-label">Bug Or Issue detected.</label> | |
| 106 | + </div> | |
| 107 | + | |
| 108 | + <div class="feedback-input-wrapper"> | |
| 109 | + <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-input" type="radio" | |
| 110 | + name="reason_key" value="no_longer_needed"> | |
| 111 | + <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-no_longer_needed" class="feedback-label">I no longer | |
| 112 | + need the plugin</label> | |
| 113 | + </div> | |
| 114 | + <div class="feedback-input-wrapper"> | |
| 115 | + <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-input" | |
| 116 | + type="radio" name="reason_key" value="found_a_better_plugin"> | |
| 117 | + <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-found_a_better_plugin" class="feedback-label">I found a | |
| 118 | + better plugin</label> | |
| 119 | + <input class="feedback-feedback-text" type="text" name="reason_found_a_better_plugin" | |
| 120 | + placeholder="Please share the plugin name"> | |
| 121 | + </div> | |
| 122 | + <div class="feedback-input-wrapper"> | |
| 123 | + <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-input" | |
| 124 | + type="radio" name="reason_key" value="couldnt_get_the_plugin_to_work"> | |
| 125 | + <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-couldnt_get_the_plugin_to_work" class="feedback-label">I | |
| 126 | + couldn't get the plugin to work</label> | |
| 127 | + </div> | |
| 128 | + | |
| 129 | + <div class="feedback-input-wrapper"> | |
| 130 | + <input id="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-input" | |
| 131 | + type="radio" name="reason_key" value="temporary_deactivation"> | |
| 132 | + <label for="feedback-deactivate-<?php echo esc_attr( $this->textdomain ); ?>-temporary_deactivation" class="feedback-label">It's a | |
| 133 | + temporary deactivation</label> | |
| 134 | + </div> | |
| 135 | + <span style="color:red;font-size: 16px;"></span> | |
| 136 | + </div> | |
| 137 | + <p style="margin: 0 0 15px 0;"> | |
| 138 | + Please let us know about any issues you are facing with the plugin. | |
| 139 | + How can we improve the plugin? | |
| 140 | + </p> | |
| 141 | + <div class="feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?>"> | |
| 142 | + <textarea id="deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>" rows="4" cols="40" | |
| 143 | + placeholder=" Write something here. How can we improve the plugin?"></textarea> | |
| 144 | + <span style="color:red;font-size: 16px;"></span> | |
| 145 | + </div> | |
| 146 | + <p style="margin: 0;"> | |
| 147 | + Your satisfaction is our utmost inspiration. Thank you for your feedback. | |
| 148 | + </p> | |
| 149 | + </div> | |
| 150 | + </div> | |
| 151 | + <?php | |
| 152 | + } | |
| 153 | + | |
| 154 | + /*** | |
| 155 | + * @param $mimes | |
| 156 | + * | |
| 157 | + * @return mixed | |
| 158 | + */ | |
| 159 | + public function dialog_box_style() { | |
| 160 | + ?> | |
| 161 | + <style> | |
| 162 | + /* Add Animation */ | |
| 163 | + @-webkit-keyframes animatetop { | |
| 164 | + from { | |
| 165 | + top: -300px; | |
| 166 | + opacity: 0 | |
| 167 | + } | |
| 168 | + to { | |
| 169 | + top: 0; | |
| 170 | + opacity: 1 | |
| 171 | + } | |
| 172 | + } | |
| 173 | + | |
| 174 | + @keyframes animatetop { | |
| 175 | + from { | |
| 176 | + top: -300px; | |
| 177 | + opacity: 0 | |
| 178 | + } | |
| 179 | + to { | |
| 180 | + top: 0; | |
| 181 | + opacity: 1 | |
| 182 | + } | |
| 183 | + } | |
| 184 | + | |
| 185 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> { | |
| 186 | + display: none; | |
| 187 | + } | |
| 188 | + | |
| 189 | + .ui-dialog-titlebar-close { | |
| 190 | + display: none; | |
| 191 | + } | |
| 192 | + | |
| 193 | + /* The Modal (background) */ | |
| 194 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal { | |
| 195 | + display: none; /* Hidden by default */ | |
| 196 | + position: fixed; /* Stay in place */ | |
| 197 | + z-index: 1; /* Sit on top */ | |
| 198 | + padding-top: 100px; /* Location of the box */ | |
| 199 | + left: 0; | |
| 200 | + top: 0; | |
| 201 | + width: 100%; /* Full width */ | |
| 202 | + height: 100%; /* Full height */ | |
| 203 | + overflow: auto; /* Enable scroll if needed */ | |
| 204 | + } | |
| 205 | + | |
| 206 | + /* Modal Content */ | |
| 207 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content { | |
| 208 | + position: relative; | |
| 209 | + margin: auto; | |
| 210 | + padding: 0; | |
| 211 | + } | |
| 212 | + | |
| 213 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ) ; ?> .feedback-label { | |
| 214 | + font-size: 15px; | |
| 215 | + } | |
| 216 | + | |
| 217 | + div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ) ; ?> p { | |
| 218 | + font-size: 16px; | |
| 219 | + } | |
| 220 | + | |
| 221 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content > * { | |
| 222 | + width: 100%; | |
| 223 | + padding: 5px 2px; | |
| 224 | + overflow: hidden; | |
| 225 | + } | |
| 226 | + | |
| 227 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content textarea { | |
| 228 | + border: 1px solid rgba(0, 0, 0, 0.3); | |
| 229 | + padding: 15px; | |
| 230 | + width: 100%; | |
| 231 | + } | |
| 232 | + | |
| 233 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input.feedback-feedback-text { | |
| 234 | + border: 1px solid rgba(0, 0, 0, 0.3); | |
| 235 | + min-width: 250px; | |
| 236 | + } | |
| 237 | + | |
| 238 | + /* The Close Button */ | |
| 239 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"] { | |
| 240 | + margin: 0; | |
| 241 | + } | |
| 242 | + | |
| 243 | + .ui-dialog-title { | |
| 244 | + font-size: 18px; | |
| 245 | + font-weight: 600; | |
| 246 | + } | |
| 247 | + | |
| 248 | + #deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-body { | |
| 249 | + padding: 2px 16px; | |
| 250 | + } | |
| 251 | + | |
| 252 | + .ui-dialog-buttonset { | |
| 253 | + background-color: #fefefe; | |
| 254 | + padding: 0 17px 25px; | |
| 255 | + display: flex; | |
| 256 | + justify-content: space-between; | |
| 257 | + gap: 10px; | |
| 258 | + } | |
| 259 | + | |
| 260 | + .ui-dialog-buttonset button { | |
| 261 | + min-width: 110px; | |
| 262 | + text-align: center; | |
| 263 | + border: 1px solid rgba(0, 0, 0, 0.1); | |
| 264 | + padding: 0 15px; | |
| 265 | + border-radius: 5px; | |
| 266 | + height: 40px; | |
| 267 | + font-size: 15px; | |
| 268 | + font-weight: 600; | |
| 269 | + display: inline-flex; | |
| 270 | + align-items: center; | |
| 271 | + justify-content: center; | |
| 272 | + cursor: pointer; | |
| 273 | + transition: 0.3s all; | |
| 274 | + background: rgba(0, 0, 0, 0.02); | |
| 275 | + margin: 0; | |
| 276 | + } | |
| 277 | + | |
| 278 | + .ui-dialog-buttonset button:nth-child(2) { | |
| 279 | + background: transparent; | |
| 280 | + } | |
| 281 | + | |
| 282 | + .ui-dialog-buttonset button:hover { | |
| 283 | + background: #2271b1; | |
| 284 | + color: #fff; | |
| 285 | + } | |
| 286 | + | |
| 287 | + .ui-dialog[aria-describedby="deactivation-dialog-shopbuilder"] { | |
| 288 | + background-color: #fefefe; | |
| 289 | + box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19); | |
| 290 | + z-index: 99; | |
| 291 | + } | |
| 292 | + | |
| 293 | + div#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>, | |
| 294 | + .ui-draggable .ui-dialog-titlebar { | |
| 295 | + padding: 18px 15px; | |
| 296 | + box-shadow: 0 0 3px rgba(0, 0, 0, 0.1); | |
| 297 | + text-align: left; | |
| 298 | + } | |
| 299 | + | |
| 300 | + .modal-content .feedback-input-wrapper { | |
| 301 | + margin-bottom: 8px; | |
| 302 | + display: flex; | |
| 303 | + align-items: center; | |
| 304 | + gap: 8px; | |
| 305 | + line-height: 2; | |
| 306 | + padding: 0 2px; | |
| 307 | + } | |
| 308 | + | |
| 309 | + .ui-widget-overlay.ui-front { | |
| 310 | + position: fixed; | |
| 311 | + top: 0; | |
| 312 | + left: 0; | |
| 313 | + right: 0; | |
| 314 | + bottom: 0; | |
| 315 | + z-index: 999; | |
| 316 | + background-color: rgba(0, 0, 0, 0.5); | |
| 317 | + } | |
| 318 | + | |
| 319 | + </style> | |
| 320 | + | |
| 321 | + <?php | |
| 322 | + } | |
| 323 | + | |
| 324 | + /*** | |
| 325 | + * @param $mimes | |
| 326 | + * | |
| 327 | + * @return mixed | |
| 328 | + */ | |
| 329 | + public function deactivation_scripts() { | |
| 330 | + wp_enqueue_script( 'jquery-ui-dialog' ); | |
| 331 | + ?> | |
| 332 | + <script> | |
| 333 | + jQuery(document).ready(function ($) { | |
| 334 | + | |
| 335 | + // Open the deactivation dialog when the 'Deactivate' link is clicked | |
| 336 | + $('.deactivate #deactivate-shopbuilder').on('click', function (e) { | |
| 337 | + e.preventDefault(); | |
| 338 | + var href = $('.deactivate #deactivate-shopbuilder').attr('href'); | |
| 339 | + var given = localRetrieveData("feedback-given"); | |
| 340 | + | |
| 341 | + // If set for limited time. | |
| 342 | + if ('given' === given) { | |
| 343 | + // window.location.href = href; | |
| 344 | + // return; | |
| 345 | + } | |
| 346 | + $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog({ | |
| 347 | + modal: true, | |
| 348 | + width: 500, | |
| 349 | + show: { | |
| 350 | + effect: "fadeIn", | |
| 351 | + duration: 400 | |
| 352 | + }, | |
| 353 | + hide: { | |
| 354 | + effect: "fadeOut", | |
| 355 | + duration: 100 | |
| 356 | + }, | |
| 357 | + | |
| 358 | + buttons: { | |
| 359 | + Submit: function () { | |
| 360 | + submitFeedback(); | |
| 361 | + }, | |
| 362 | + Cancel: function () { | |
| 363 | + $(this).dialog('close'); | |
| 364 | + window.location.href = href; | |
| 365 | + } | |
| 366 | + } | |
| 367 | + }); | |
| 368 | + // Customize the button text | |
| 369 | + $('.ui-dialog-buttonpane button:contains("Submit")').text('Send Feedback & Deactivate'); | |
| 370 | + $('.ui-dialog-buttonpane button:contains("Cancel")').text('Skip & Deactivate'); | |
| 371 | + }); | |
| 372 | + | |
| 373 | + // Submit the feedback | |
| 374 | + function submitFeedback() { | |
| 375 | + var href = $('.deactivate #deactivate-shopbuilder').attr('href'); | |
| 376 | + var reasons = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> input[type="radio"]:checked').val(); | |
| 377 | + var feedback = $('#deactivation-feedback-<?php echo esc_attr( $this->textdomain ); ?>').val(); | |
| 378 | + var better_plugin = $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?> .modal-content input[name="reason_found_a_better_plugin"]').val(); | |
| 379 | + // Perform AJAX request to submit feedback | |
| 380 | + if (!reasons && !feedback && !better_plugin) { | |
| 381 | + // Define flag variables | |
| 382 | + $('#feedback-form-body-<?php echo esc_attr( $this->textdomain ); ?> span').text('Choose The Reason'); | |
| 383 | + $('.feedback-text-wrapper-<?php echo esc_attr( $this->textdomain ); ?> span').text('Please provide me with some advice.'); | |
| 384 | + return; | |
| 385 | + } | |
| 386 | + | |
| 387 | + if ('temporary_deactivation' == reasons && !feedback) { | |
| 388 | + window.location.href = href; | |
| 389 | + } | |
| 390 | + | |
| 391 | + $.ajax({ | |
| 392 | + url: 'https://shopbuilderwp.com/wp-json/RadiusTheme/pluginSurvey/v1/Survey/appendToSheet', | |
| 393 | + method: 'GET', | |
| 394 | + dataType: 'json', | |
| 395 | + data: { | |
| 396 | + website: '<?php echo esc_url( home_url() )?>', | |
| 397 | + reasons: reasons ? reasons : '', | |
| 398 | + better_plugin: better_plugin, | |
| 399 | + feedback: feedback, | |
| 400 | + wpplugin: 'ShopBuilder', | |
| 401 | + }, | |
| 402 | + success: function (response) { | |
| 403 | + if (response.success) { | |
| 404 | + console.log('Success'); | |
| 405 | + localStoreData("feedback-given", 'given'); | |
| 406 | + } | |
| 407 | + }, | |
| 408 | + error: function (xhr, status, error) { | |
| 409 | + // Handle the error response | |
| 410 | + console.error('Error', error); | |
| 411 | + }, | |
| 412 | + complete: function (xhr, status) { | |
| 413 | + $('#deactivation-dialog-<?php echo esc_attr( $this->textdomain ); ?>').dialog('close'); | |
| 414 | + window.location.href = href; | |
| 415 | + } | |
| 416 | + | |
| 417 | + }); | |
| 418 | + } | |
| 419 | + | |
| 420 | + // Store data in local storage with an expiration time of 1 hour | |
| 421 | + function localStoreData(key, value) { | |
| 422 | + // Calculate the expiration time in milliseconds (1 hour = 60 minutes * 60 seconds * 1000 milliseconds) | |
| 423 | + var expirationTime = Date.now() + (60 * 60 * 1000); | |
| 424 | + | |
| 425 | + // Create an object to store the data and expiration time | |
| 426 | + var dataObject = { | |
| 427 | + value: value, | |
| 428 | + expirationTime: expirationTime | |
| 429 | + }; | |
| 430 | + | |
| 431 | + // Store the object in local storage | |
| 432 | + localStorage.setItem(key, JSON.stringify(dataObject)); | |
| 433 | + } | |
| 434 | + | |
| 435 | + // Retrieve data from local storage | |
| 436 | + function localRetrieveData(key) { | |
| 437 | + // Get the stored data from local storage | |
| 438 | + var data = localStorage.getItem(key); | |
| 439 | + if (data) { | |
| 440 | + // Parse the stored JSON data | |
| 441 | + var dataObject = JSON.parse(data); | |
| 442 | + // Check if the data has expired | |
| 443 | + if (Date.now() <= dataObject.expirationTime) { | |
| 444 | + // Return the stored value | |
| 445 | + return dataObject.value; | |
| 446 | + } else { | |
| 447 | + // Data has expired, remove it from local storage | |
| 448 | + localStorage.removeItem(key); | |
| 449 | + } | |
| 450 | + } | |
| 451 | + // Return null if data doesn't exist or has expired | |
| 452 | + return null; | |
| 453 | + } | |
| 454 | + | |
| 455 | + }); | |
| 456 | + | |
| 457 | + </script> | |
| 458 | + | |
| 459 | + <?php | |
| 460 | + } | |
| 461 | + | |
| 462 | + | |
| 463 | +} | |