Aucune description

pro-addon.php 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <?php
  2. /** @var $view string */
  3. defined('ABSPATH') || die();
  4. $settings = NextendSocialLogin::$settings;
  5. $state = NextendSocialLoginAdmin::getProState();
  6. function nsl_license_no_capability($view) {
  7. ?>
  8. <div class="nsl-box nsl-box-red nsl-box-error">
  9. <h2 class="title"><?php _e('Error', 'nextend-facebook-connect'); ?></h2>
  10. <p><?php _e('You don’t have sufficient permissions to install and activate plugins. Please contact your site’s administrator!', 'nextend-facebook-connect'); ?></p>
  11. </div>
  12. <?php
  13. }
  14. function nsl_license_installed($view) {
  15. ?>
  16. <div class="nsl-box nsl-box-blue">
  17. <h2 class="title"><?php _e('Activate Pro Addon', 'nextend-facebook-connect'); ?></h2>
  18. <p><?php _e('Pro Addon is installed but not activated. To be able to use the Pro features, you need to activate it.', 'nextend-facebook-connect'); ?></p>
  19. <p>
  20. <a href="<?php echo wp_nonce_url(add_query_arg(array(
  21. 'action' => 'activate',
  22. 'plugin' => urlencode('nextend-social-login-pro/nextend-social-login-pro.php'),
  23. 'plugin_status' => 'all'
  24. ), admin_url('plugins.php')), 'activate-plugin_' . 'nextend-social-login-pro/nextend-social-login-pro.php'); ?>"
  25. target="_blank" onclick="setTimeout(function(){window.location.reload(true)}, 2000)"
  26. class="button button-primary"><?php _e('Activate Pro Addon', 'nextend-facebook-connect'); ?></a>
  27. <a href="<?php echo wp_nonce_url(add_query_arg(array(
  28. 'action' => 'nextend-social-login',
  29. 'view' => 'pro-addon-deauthorize'
  30. ), admin_url('admin-post.php')), 'nextend-social-login'); ?>" class="button button-secondary">
  31. <?php _e('Deactivate Pro Addon', 'nextend-facebook-connect'); ?>
  32. </a>
  33. </p>
  34. </div>
  35. <?php
  36. }
  37. function nsl_license_not_installed($view) {
  38. $plugin_slug = 'nextend-social-login-pro';
  39. ?>
  40. <div class="nsl-box nsl-box-blue plugin-card-<?php echo $plugin_slug; ?>">
  41. <h2 class="title"><?php _e('Pro Addon is not installed', 'nextend-facebook-connect'); ?></h2>
  42. <p><?php _e('To access the Pro features, you need to install and activate the Pro Addon.', 'nextend-facebook-connect'); ?></p>
  43. <p class="submit">
  44. <a class="install-now button button-primary" data-slug="<?php echo $plugin_slug; ?>"
  45. href="<?php echo esc_url(wp_nonce_url(add_query_arg(array(
  46. 'action' => 'install-plugin',
  47. 'plugin' => $plugin_slug,
  48. 'from' => 'nextend-facebook-connect',
  49. ), self_admin_url('update.php')), 'install-plugin_' . $plugin_slug)); ?>"
  50. aria-label="<?php echo esc_attr(sprintf(__('Install %s now'), 'Nextend Social Login PRO Addon')); ?>"
  51. data-name="<?php echo esc_attr('Nextend Social Login PRO Addon'); ?>"><?php _e('Install Pro Addon', 'nextend-facebook-connect'); ?></a>
  52. </p>
  53. </div>
  54. <script type="text/javascript">
  55. (function ($) {
  56. $(document).on('ready', function () {
  57. var $button = $('.install-now').on('click.nsl', function (event) {
  58. if (typeof wp.updates.installPlugin === 'function') {
  59. /** @since WordPress 4.6.0 */
  60. event.preventDefault();
  61. if ($button.hasClass('updating-message') || $button.hasClass('button-disabled')) {
  62. return;
  63. }
  64. if (wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked) {
  65. wp.updates.requestFilesystemCredentials(event);
  66. $(document).on('credential-modal-cancel', function () {
  67. var $message = $('.install-now.updating-message');
  68. $message.removeClass('updating-message').text(wp.updates.l10n.installNow);
  69. wp.a11y.speak(wp.updates.l10n.updateCancel, 'polite');
  70. });
  71. }
  72. wp.updates.installPlugin({
  73. slug: $button.data('slug'),
  74. success: function (response) {
  75. if (response.activateUrl) {
  76. $button.addClass('updating-message')
  77. .text( <?php echo wp_json_encode(__('Activating...', 'nextend-facebook-connect'))?> );
  78. window.onNSLProActivate = function () {
  79. window.location.reload(true);
  80. };
  81. $('<iframe onload="onNSLProActivate()" src="' + response.activateUrl +
  82. '" style="visibility:hidden;"></iframe>').appendTo('body');
  83. }
  84. }
  85. }).always(function () {
  86. $button.off('.nsl');
  87. });
  88. }
  89. });
  90. });
  91. })(jQuery);
  92. </script>
  93. <?php
  94. }
  95. function nsl_not_compatible($view) {
  96. $file = 'nextend-social-login-pro/nextend-social-login-pro.php';
  97. ?>
  98. <div class="nsl-box nsl-box-blue">
  99. <h2 class="title"><?php _e('Not compatible!', 'nextend-facebook-connect'); ?></h2>
  100. <p><?php printf(__('%1$s and %2$s are not compatible. Please update %2$s to version %3$s or newer.', 'nextend-facebook-connect'), "Nextend Social Login", "Nextend Social Login Pro Addon", NextendSocialLogin::$nslPROMinVersion); ?></p>
  101. <p>
  102. <a href="<?php echo esc_url(wp_nonce_url(admin_url('update.php?action=upgrade-plugin&plugin=') . $file, 'upgrade-plugin_' . $file)); ?>"
  103. class="button button-primary"><?php _e('Update Pro Addon', 'nextend-facebook-connect'); ?></a>
  104. </p>
  105. </div>
  106. <?php
  107. }
  108. function nsl_license_activated($view) {
  109. ?>
  110. <div class="nsl-box nsl-box-green">
  111. <h2 class="title"><?php _e('Pro Addon is installed and activated', 'nextend-facebook-connect'); ?></h2>
  112. <p><?php _e('You installed and activated the Pro Addon. If you don’t want to use it anymore, you can deactivate using the button below.', 'nextend-facebook-connect'); ?></p>
  113. <p class="submit">
  114. <a href="<?php echo wp_nonce_url(add_query_arg(array(
  115. 'action' => 'nextend-social-login',
  116. 'view' => 'pro-addon-deauthorize'
  117. ), admin_url('admin-post.php')), 'nextend-social-login'); ?>" class="button button-secondary">
  118. <?php _e('Deactivate Pro Addon', 'nextend-facebook-connect'); ?>
  119. </a>
  120. </p>
  121. </div>
  122. <?php
  123. }
  124. ?>
  125. <div class="nsl-admin-content">
  126. <?php
  127. switch ($state) {
  128. case 'no-capability':
  129. nsl_license_no_capability($view);
  130. break;
  131. case 'installed':
  132. nsl_license_installed($view);
  133. break;
  134. case 'not-installed':
  135. nsl_license_not_installed($view);
  136. break;
  137. case 'no-license':
  138. NextendSocialLoginAdmin::authorizeBox($view);
  139. break;
  140. case 'not-compatible':
  141. nsl_not_compatible($view);
  142. break;
  143. case 'activated':
  144. nsl_license_activated($view);
  145. break;
  146. }
  147. ?>
  148. </div>