purchase-helper.php 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. <?php
  2. /**
  3. * Purchase Helper
  4. *
  5. * @package vamtam/consulting
  6. */
  7. /**
  8. * class VamtamPurchaseHelper
  9. */
  10. class VamtamPurchaseHelper extends VamtamAjax {
  11. public static $storage_path;
  12. public static $mu_plugin_version;
  13. public static $mu_plugin_opt_name;
  14. /**
  15. * Hook ajax actions
  16. */
  17. public function __construct() {
  18. parent::__construct();
  19. self::$mu_plugin_version = 1;
  20. self::$mu_plugin_opt_name = 'vamtam_' . VAMTAM_THEME_SLUG . '_mu_plugin_version';
  21. add_action( 'admin_menu', array( __CLASS__, 'admin_menu' ), 20 );
  22. add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
  23. add_action( 'admin_init', array( __CLASS__, 'admin_early_init' ), 5 );
  24. add_action( 'admin_notices', array( __CLASS__, 'notice_early' ), 5 ); // after TGMPA registers its notices, but before printing
  25. add_action( 'admin_notices', array( __CLASS__, 'notice' ), 20 ); // later than TGMPA
  26. add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_scripts' ) );
  27. add_filter( 'tgmpa_update_bulk_plugins_complete_actions', array( __CLASS__, 'tgmpa_plugins_complete_actions' ), 10, 2 );
  28. }
  29. public static function notice_early() {
  30. $screen = get_current_screen();
  31. if ( ! self::is_theme_setup_page() && $screen->id !== 'plugins' ) {
  32. remove_action( 'admin_notices', array( $GLOBALS['tgmpa'], 'notices' ), 10 );
  33. }
  34. }
  35. private static function server_tests() {
  36. $timeout = (int) ini_get( 'max_execution_time' );
  37. $memory = ini_get( 'memory_limit' );
  38. $memoryB = str_replace( array( 'G', 'M', 'K' ), array( '000000000', '000000', '000' ), $memory );
  39. $tests = array(
  40. array(
  41. 'name' => esc_html__( 'PHP Version', 'vamtam-consulting' ),
  42. 'test' => version_compare( phpversion(), '5.5', '<' ),
  43. 'value' => phpversion(),
  44. 'desc' => esc_html__( 'While this theme works with all PHP versions supported by WordPress Core, PHP versions 5.5 and older are no longer maintained by their developers. Consider switching your server to PHP 5.6 or newer.', 'vamtam-consulting' ),
  45. ),
  46. array(
  47. 'name' => esc_html__( 'PHP Time Limit', 'vamtam-consulting' ),
  48. 'test' => $timeout > 0 && $timeout < 30,
  49. 'value' => $timeout,
  50. 'desc' => esc_html__( 'The PHP time limit should be at least 30 seconds. Note that in some configurations your server (Apache/nginx) may have a separate time limit. Please consult with your hosting provider if you get a time out while importing the demo content.', 'vamtam-consulting' ),
  51. ),
  52. array(
  53. 'name' => esc_html__( 'PHP Memory Limit', 'vamtam-consulting' ),
  54. 'test' => (int) $memory > 0 && $memoryB < 96 * 1024 * 1024,
  55. 'value' => $memory,
  56. 'desc' => esc_html__( 'You need a minimum of 96MB memory to use the theme and the bundled plugins. For non-US English websites you need a minimum of 128MB in order to accomodate the translation features which are otherwise disabled.', 'vamtam-consulting' ),
  57. ),
  58. array(
  59. 'name' => esc_html__( 'PHP ZipArchive Extension', 'vamtam-consulting' ),
  60. 'test' => ! class_exists( 'ZipArchive' ),
  61. 'value' => '',
  62. 'desc' => esc_html__( 'ZipArchive is a requirement for importing the demo sliders.', 'vamtam-consulting' ),
  63. ),
  64. );
  65. $fail = 0;
  66. foreach ( $tests as $test ) {
  67. $fail += (int) $test['test'];
  68. }
  69. return array(
  70. 'fail' => $fail,
  71. 'tests' => $tests,
  72. );
  73. }
  74. private static function is_theme_setup_page() {
  75. return isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'vamtam_theme_setup' ) );
  76. }
  77. public static function admin_scripts() {
  78. $theme_version = VamtamFramework::get_version();
  79. wp_register_script( 'vamtam-check-license', VAMTAM_ADMIN_ASSETS_URI . 'js/check-license.js', array( 'jquery-core' ), $theme_version, true );
  80. wp_register_script( 'vamtam-import-buttons', VAMTAM_ADMIN_ASSETS_URI . 'js/import-buttons.js', array( 'jquery-core' ), $theme_version, true );
  81. }
  82. public static function tgmpa_plugins_complete_actions( $update_actions, $plugin_info ) {
  83. if ( isset( $update_actions['dashboard'] ) ) {
  84. $update_actions['dashboard'] = sprintf(
  85. esc_html__( 'All plugins installed and activated successfully. %1$s', 'vamtam-consulting' ),
  86. '<a href="' . esc_url( admin_url( 'admin.php?page=vamtam_theme_setup' ) ) . '" class="button button-primary">' . esc_html__( 'Continue with theme setup.', 'vamtam-consulting' ) . '</a>'
  87. );
  88. $update_actions['dashboard'] .= '
  89. <script>
  90. window.scroll( 0, 10000000 );
  91. </script>
  92. ';
  93. }
  94. return $update_actions;
  95. }
  96. public static function notice() {
  97. if ( self::needs_mu_plugin() && ( ! isset( $_GET['page'] ) || ( $_GET['page'] !== 'vamtam_theme_setup' && $_GET['page'] !== 'tgmpa-install-plugins' ) ) ) {
  98. $url = admin_url( 'admin.php?page=vamtam_theme_setup' );
  99. echo '<div class="notice-warning settings-error notice">';
  100. echo '<p>';
  101. echo wp_kses_post( sprintf( __( 'You have activated your VamTam theme for the first time. <a href="%s">Click here</a> to complete the setup.', 'vamtam-consulting' ), esc_url( $url ) ) );
  102. echo '</p>';
  103. echo '</div>';
  104. }
  105. }
  106. public static function admin_menu() {
  107. add_theme_page( esc_html__( 'VamTam Theme Setup', 'vamtam-consulting' ), esc_html__( 'VamTam Theme Setup', 'vamtam-consulting' ), 'edit_theme_options', 'vamtam_theme_setup', array( __CLASS__, 'page' ) );
  108. }
  109. public static function admin_early_init() {
  110. if ( self::is_theme_setup_page() ) {
  111. add_filter( 'woocommerce_prevent_automatic_wizard_redirect', '__return_true' );
  112. add_filter( 'wp_redirect', array( __CLASS__, 'block_redirects_to_admin' ) ); // prevents redirects out of the theme setup page
  113. }
  114. if ( get_transient( '_fp_activation_redirect' ) ) {
  115. delete_transient( '_fp_activation_redirect' );
  116. }
  117. if ( get_transient( '_booked_welcome_screen_activation_redirect' ) ) {
  118. delete_transient( '_booked_welcome_screen_activation_redirect' );
  119. }
  120. }
  121. public static function block_redirects_to_admin( $location ) {
  122. if ( strpos( $location, 'wp-admin/' ) !== false ) {
  123. return false; // block redirect to other admin pages
  124. }
  125. return $location;
  126. }
  127. public static function admin_init() {
  128. add_settings_section(
  129. 'vamtam_purchase_settings_section',
  130. '',
  131. array( __CLASS__, 'settings_section' ),
  132. 'vamtam_theme_setup'
  133. );
  134. add_settings_field(
  135. 'vamtam-envato-license-key',
  136. esc_html__( 'Envato Purchase Key', 'vamtam-consulting' ),
  137. array( __CLASS__, 'purchase_key' ),
  138. 'vamtam_theme_setup',
  139. 'vamtam_purchase_settings_section',
  140. array(
  141. 'vamtam-envato-license-key',
  142. )
  143. );
  144. register_setting(
  145. 'vamtam_theme_setup',
  146. 'vamtam-envato-license-key',
  147. array( __CLASS__, 'sanitize_license_key' )
  148. );
  149. add_settings_field(
  150. 'vamtam-system-status-opt-in',
  151. esc_html__( 'Enable System Status Information Gathering', 'vamtam-consulting' ),
  152. array( __CLASS__, 'radio' ),
  153. 'vamtam_theme_setup',
  154. 'vamtam_purchase_settings_section',
  155. array(
  156. 'vamtam-system-status-opt-in',
  157. true,
  158. )
  159. );
  160. register_setting(
  161. 'vamtam_theme_setup',
  162. 'vamtam-system-status-opt-in'
  163. );
  164. }
  165. public static function sanitize_license_key( $value ) {
  166. return preg_replace( '/[^-\w\d]/', '', $value );
  167. }
  168. public static function settings_section() {
  169. }
  170. public static function page() {
  171. wp_enqueue_script( 'vamtam-check-license' );
  172. $status = self::server_tests();
  173. ?>
  174. <div class="wrap">
  175. <h1><?php esc_html_e( 'Vamtam Theme Setup', 'vamtam-consulting' ); ?></h1>
  176. <?php if ( ! defined( 'ENVATO_HOSTED_SITE' ) ) : ?>
  177. <h2>
  178. <?php esc_html_e( 'System Status', 'vamtam-consulting' ) ?>
  179. <?php if ( $status['fail'] > 0 ) : ?>
  180. <?php $fail = $status['fail']; ?>
  181. <small><?php printf( esc_html( _n( '(one potential issue)', '(%d potential issues)', $fail, 'vamtam-consulting' ) ), $fail ) ?></small>
  182. <?php endif ?>
  183. </h2>
  184. <?php endif ?>
  185. <table class="form-table vamtam-system-status">
  186. <?php foreach ( $status['tests'] as $test ) : ?>
  187. <tr>
  188. <th><?php echo esc_html( $test['name'] ) ?></th>
  189. <td>
  190. <span class="dashicons <?php echo esc_attr( $test['test'] ? 'dashicons-warning' : 'dashicons-yes' ) ?>"></span>
  191. <?php echo esc_html( $test['value'] ) ?>
  192. <?php if ( $test['test'] ) echo '<br><p><em>' . esc_html( $test['desc'] ) . '</em></p>'; ?>
  193. </td>
  194. </tr>
  195. <?php endforeach ?>
  196. </table>
  197. <h2><?php esc_html_e( 'Step 1', 'vamtam-consulting' ) ?></h2>
  198. <?php
  199. if ( self::needs_mu_plugin() ) {
  200. if ( self::can_install_mu_plugin() ) {
  201. self::install_mu_plugin();
  202. } else {
  203. echo '<p>' . wp_kses_post( __( 'This step is optional, but <em>highly recommended</em>, especially if your server has a low memory limit. ', 'vamtam-consulting' ) ) . '</p>';
  204. echo '<p>' . wp_kses_post( sprintf( __( 'By clicking the button below, we will install a Must-Use plugin on your site. You can remove it by manually deleting the following file: <pre>%s/10-vamtam-exclude-plugins.php</pre> We use this plugin in order to deal with hosting environments with low memory limits, which may prevent us from correctly saving any changes made to the theme options.', 'vamtam-consulting' ), WPMU_PLUGIN_DIR ) ) . '</p>';
  205. echo '<a href="' . esc_url( add_query_arg( 'vamtam-mu-plugin', 'opt-in' ) ) . '" class="button">' . esc_html__( 'Install MU Plugin', 'vamtam-consulting' ) . '</a>';
  206. }
  207. } else {
  208. esc_html_e( 'All done.', 'vamtam-consulting' );
  209. }
  210. ?>
  211. <h2><?php esc_html_e( 'Step 2', 'vamtam-consulting' ) ?></h2>
  212. <?php
  213. if ( defined( 'ENVATO_HOSTED_SITE' ) ) :
  214. esc_html_e( 'All done.', 'vamtam-consulting' );
  215. else :
  216. ?>
  217. <form method="post" action="options.php">
  218. <?php
  219. settings_fields( 'vamtam_theme_setup' );
  220. do_settings_sections( 'vamtam_theme_setup' );
  221. submit_button();
  222. ?>
  223. </form>
  224. <?php endif; ?>
  225. <h3><?php esc_html_e( 'Step 3', 'vamtam-consulting' ) ?></h2>
  226. <?php self::import_buttons() ?>
  227. </div>
  228. <?php
  229. }
  230. public static function can_install_mu_plugin() {
  231. return isset( $_GET['vamtam-mu-plugin'] ) && 'opt-in' === $_GET['vamtam-mu-plugin'];
  232. }
  233. public static function needs_mu_plugin() {
  234. return ! defined( 'ENVATO_HOSTED_SITE' ) && get_option( self::$mu_plugin_opt_name, 0 ) < self::$mu_plugin_version;
  235. }
  236. public static function install_mu_plugin() {
  237. if ( ! self::can_install_mu_plugin() ) {
  238. return false;
  239. }
  240. if ( ! self::needs_mu_plugin() ) {
  241. return true;
  242. }
  243. $url = admin_url( 'admin.php?page=vamtam_theme_setup&vamtam-mu-plugin=opt-in' );
  244. $method = '';
  245. if ( false === ( $creds = request_filesystem_credentials( $url, $method ) ) ) {
  246. return true;
  247. }
  248. if ( ! WP_Filesystem( $creds ) ) {
  249. request_filesystem_credentials( $url, $method, true );
  250. return true;
  251. }
  252. $source_file = VAMTAM_HELPERS . '10-vamtam-exclude-plugins.php';
  253. $target_file = trailingslashit( WPMU_PLUGIN_DIR ) . '10-vamtam-exclude-plugins.php';
  254. global $wp_filesystem;
  255. show_message( esc_html__( 'Creating directory...', 'vamtam-consulting' ) );
  256. wp_mkdir_p( WPMU_PLUGIN_DIR );
  257. show_message( esc_html__( 'Copying file...', 'vamtam-consulting' ) );
  258. if ( ! $wp_filesystem->copy( $source_file, $target_file, FS_CHMOD_FILE ) ) {
  259. printf( esc_html__( "Couldn't install the requisite mu-plugin. Please manually copy <b>%1\$s</b> to <b>%2\$s</b>", 'vamtam-consulting' ), esc_html( $source_file ), esc_html( $target_file ) );
  260. return false;
  261. }
  262. show_message( __( 'All done. Please continue below.', 'vamtam-consulting' ) );
  263. update_option( self::$mu_plugin_opt_name, self::$mu_plugin_version );
  264. }
  265. public static function import_buttons() {
  266. wp_enqueue_script( 'vamtam-import-buttons' );
  267. include_once ABSPATH . 'wp-admin/includes/plugin.php';
  268. $revslider = defined( 'RS_PLUGIN_PATH' );
  269. $ninjaforms = function_exists( 'Ninja_Forms' );
  270. $jetpack = class_exists( 'Jetpack' );
  271. $booked = class_exists( 'booked_plugin' );
  272. $content_allowed = $jetpack;
  273. $content_imported = ! ! get_option( 'vamtam_last_import_map', false );
  274. $content_disable = $content_imported ? '' : ' disabled content-disabled';
  275. $messages = array(
  276. 'success-msg' => esc_html__( 'Imported.', 'vamtam-consulting' ),
  277. 'error-msg ' => esc_html__( 'Failed to import. Please <a href="{fullimport}" target="_blank">click here</a> in order to see the full error message.', 'vamtam-consulting' ),
  278. );
  279. $import_tests = array(
  280. array(
  281. 'test' => true,
  282. 'title' => esc_html__( 'Posts and Pages', 'vamtam-consulting' ),
  283. ),
  284. array(
  285. 'test' => vamtam_has_woocommerce(),
  286. 'title' => esc_html__( 'Products', 'vamtam-consulting' ),
  287. 'failed' => wp_kses_data( __( '(Please install and activate <strong>WooCommerce</strong> first.)', 'vamtam-consulting' ) ),
  288. ),
  289. array(
  290. 'test' => class_exists( 'Tribe__Events__Main' ),
  291. 'title' => esc_html__( 'Events', 'vamtam-consulting' ),
  292. 'failed' => wp_kses_data( __( '(Please install and activate <strong>The Events Calendar</strong> first.)', 'vamtam-consulting' ) ),
  293. ),
  294. array(
  295. 'test' => class_exists( 'Mega_Menu' ),
  296. 'title' => esc_html__( 'Max Mega Menu settings', 'vamtam-consulting' ),
  297. 'failed' => wp_kses_data( __( '(Please install and activate <strong>Max Mega Menu</strong> first.)', 'vamtam-consulting' ) ),
  298. ),
  299. );
  300. $will_import = array();
  301. foreach ( $import_tests as $test ) {
  302. $will_import[] = '<span class="dashicons ' . esc_attr( $test['test'] ? 'dashicons-yes' : 'dashicons-warning' ) . '"></span> <span>' . $test['title'] . ' ' . ( $test['test'] ? '' : $test['failed'] ) . '</span>';
  303. }
  304. $revslider_samples_dir = VAMTAM_SAMPLES_DIR . 'revslider/';
  305. $revslider_samples = is_dir( $revslider_samples_dir ) ? iterator_count( new FilesystemIterator( $revslider_samples_dir , FilesystemIterator::SKIP_DOTS ) ) : 0;
  306. $buttons = array(
  307. array(
  308. 'label' => esc_html__( 'Content Import', 'vamtam-consulting' ),
  309. 'id' => 'content-import-button',
  310. 'description' => esc_html__( 'You are advised to use this importer only on new WordPress sites. Jetpack must be installed and active.', 'vamtam-consulting' ),
  311. 'button_title' => esc_html__( 'Import Dummy Content', 'vamtam-consulting' ),
  312. 'href' => $content_allowed ? wp_nonce_url( admin_url( 'admin.php?import=wpv&step=2' ), 'vamtam-import' ) : 'javascript:void( 0 )',
  313. 'type' => 'button',
  314. 'class' => $content_allowed ? 'vamtam-import-button' : 'disabled',
  315. 'data' => array_merge( $messages, array( 'content-imported', $content_imported ) ),
  316. 'disabled_msg' => wp_kses_data( __( 'Please install and activate <strong>Jetpack</strong> first.', 'vamtam-consulting' ) ),
  317. 'additional_msg' => sprintf( wp_kses_post( __( 'This may take several minutes, due to a number of images which have to be downloaded during the import process.<br><br>Image thumbnails will be generated in the background after the main import is complete.<br>This may take up to half an hour, but you can start using your site after the spinner above is gone.<br><br>Will import:<br>%s', 'vamtam-consulting' ) ), implode( '<br>', $will_import ) ),
  318. ),
  319. array(
  320. 'label' => esc_html__( 'Ninja Forms', 'vamtam-consulting' ),
  321. 'id' => 'widget-import-button',
  322. 'button_title' => esc_html__( 'Import Forms', 'vamtam-consulting' ),
  323. 'href' => $ninjaforms ? wp_nonce_url( admin_url( 'admin.php?import=vamtam_ninjaforms' ), 'vamtam-import-ninja-forms' ) : 'javascript:void( 0 )',
  324. 'type' => 'button',
  325. 'class' => $ninjaforms ? 'vamtam-import-button' : 'disabled',
  326. 'data' => $messages,
  327. 'disabled_msg' => wp_kses_data( __( 'Please install and activate <strong>Ninja Forms</strong> first.', 'vamtam-consulting' ) ),
  328. ),
  329. array(
  330. 'label' => esc_html__( 'Widget Import', 'vamtam-consulting' ),
  331. 'id' => 'widget-import-button',
  332. 'description' => esc_html__( 'Using this importer will overwrite your current sidebar settings', 'vamtam-consulting' ),
  333. 'button_title' => esc_html__( 'Import Widgets', 'vamtam-consulting' ),
  334. 'href' => wp_nonce_url( admin_url( 'admin.php?import=vamtam_widgets' ), 'vamtam-import' ),
  335. 'type' => 'button',
  336. 'class' => 'vamtam-import-button' . $content_disable,
  337. 'data' => $messages,
  338. 'disabled_msg' => wp_kses_data( __( 'You must import the demo content before the widgets.', 'vamtam-consulting' ) ),
  339. 'disabled_msg_href' => 'nolink',
  340. ),
  341. array(
  342. 'label' => esc_html__( 'Slider Revolution', 'vamtam-consulting' ),
  343. 'id' => 'slider-import-button',
  344. 'button_title' => esc_html__( 'Import Slider Revolution Samples', 'vamtam-consulting' ),
  345. 'href' => $revslider && $revslider_samples > 0 ? wp_nonce_url( 'admin.php?import=vamtam_revslider', 'vamtam-import-revslider' ) : 'javascript:void( 0 )',
  346. 'type' => 'button',
  347. 'class' => $revslider && $revslider_samples > 0 ? 'vamtam-import-button' : 'disabled',
  348. 'data' => $messages,
  349. 'disabled_msg' => $revslider ? '' : wp_kses_data( __( 'Please install and activate <strong>Slider Revolution</strong> first. ', 'vamtam-consulting' ) ),
  350. 'disabled_msg_plain' => $revslider_samples > 0 ? '' : wp_kses_data( __( 'Slider samples are misssing. Please contact <a href="mailto:support@vamtam.com">VamTam Support</a>', 'vamtam-consulting' ) ),
  351. ),
  352. array(
  353. 'label' => esc_html__( 'Booked', 'vamtam-consulting' ),
  354. 'id' => 'booked-import-button',
  355. 'description' => esc_html__( 'Using this importer will overwrite your current Booked settings', 'vamtam-consulting' ),
  356. 'button_title' => esc_html__( 'Import Booked Settings', 'vamtam-consulting' ),
  357. 'href' => $booked ? wp_nonce_url( 'admin.php?import=vamtam_booked', 'vamtam-import-booked' ) : 'javascript:void( 0 )',
  358. 'type' => 'button',
  359. 'class' => $booked ? 'vamtam-import-button' : 'disabled',
  360. 'data' => $messages,
  361. 'disabled_msg' => wp_kses_data( __( 'Please install and activate <strong>Booked</strong> first.', 'vamtam-consulting' ) ),
  362. ),
  363. );
  364. echo '<table class="form-table">';
  365. foreach ( $buttons as $button ) {
  366. self::render_button( $button );
  367. }
  368. echo '</table>';
  369. }
  370. public static function render_button( $button ) {
  371. echo '<tr>';
  372. echo '<th scope="row">' . esc_html( $button['label'] ) . '</th>';
  373. $data = array();
  374. if ( isset( $button['data'] ) ) {
  375. foreach ( $button['data'] as $attr_name => $attr_value ) {
  376. $data[] = 'data-' . sanitize_title_with_dashes( $attr_name ) . '="' . esc_attr( $attr_value ) . '"';
  377. }
  378. }
  379. $data = implode( ' ', $data );
  380. echo '<td>';
  381. echo '<a href="' . ( isset( $button['href'] ) ? esc_attr( $button['href'] ) : '#' ) . '" id="' . esc_attr( $button['id'] ) . '" title="' . esc_attr( $button['button_title'] ) . '" class="button ' . esc_attr( $button['class'] ) . '" ' . $data . '>' . esc_html( $button['button_title'] ) . '</a>'; // xss ok - $data escaped above
  382. if ( strpos( $button['class'], 'disabled' ) !== false ) {
  383. $href = isset( $button['disabled_msg_href'] ) ? $button['disabled_msg_href'] : admin_url( 'themes.php?page=tgmpa-install-plugins&plugin_status=all' );
  384. echo '<p class="description">';
  385. if ( $href !== 'nolink' ) {
  386. echo '<a href="' . esc_html( $href ) . '">' . wp_kses_data( $button['disabled_msg'] ) . '</a>';
  387. } else {
  388. echo wp_kses_data( $button['disabled_msg'] );
  389. }
  390. echo '</p>';
  391. if ( isset( $button['disabled_msg_plain'] ) ) {
  392. echo '<p class="description">' . wp_kses_data( $button['disabled_msg_plain'] ) . '</p>';
  393. }
  394. }
  395. if ( isset( $button['additional_msg'] ) ) {
  396. echo '<p class="description">' . $button['additional_msg'] . '</p>'; // xss ok
  397. }
  398. echo '</td>';
  399. echo '</tr>';
  400. }
  401. public static function purchase_key( $args ) {
  402. $option_value = get_option( $args[0] );
  403. $button_data = '';
  404. $data = array(
  405. 'nonce' => wp_create_nonce( 'vamtam-check-license' ),
  406. 'full-info' => wp_kses_post( sprintf( __('
  407. <h5>Licensing Terms</h5>
  408. Please be advised, in order to use the theme in a legal manner, you need to purchase a separate license for each domain you are going to use the theme on. A single license is limited to a single domain/application. For more information please refer to the license included with the theme or <a href="%s" target="_blank">Licensing Terms</a> on the ThemeForest site.', 'vamtam-consulting'), 'http://themeforest.net/licenses' ) ),
  409. );
  410. foreach ( $data as $key => $value ) {
  411. $button_data .= ' data-' . $key . '="' . esc_attr( $value ) . '"';
  412. }
  413. $html = '<input type="text" id="' . esc_attr( $args[0] ) . '" name="' . esc_attr( $args[0] ) . '" value="' . esc_attr( $option_value ) . '" size="64" ' . ( defined( 'SUBSCRIPTION_CODE' ) ? 'disabled' : '' ) . '/>';
  414. if ( ! defined( 'ENVATO_HOSTED_SITE' ) ) {
  415. $html .= '<span>';
  416. $html .= '<button id="vamtam-check-license" class="button" ' . $button_data . '>' . esc_html__( 'Check', 'vamtam-consulting' ) . '</button>';
  417. $html .= '</span>';
  418. $html .= '<p class="description">' . wp_kses_post( sprintf( __( ' <a href="%s" target="_blank">Where can I find my Item Purchase Code?</a>', 'vamtam-consulting' ), 'https://beaver.support.vamtam.com/support/solutions/articles/227253-vamtam-beaver-themes-where-to-get-your-item-purchase-key-from-' ) ) . '</p>';
  419. $html .= '<div id="vamtam-check-license-result"></div>';
  420. }
  421. echo $html; // xss ok
  422. }
  423. public static function radio( $args ) {
  424. $value = vamtam_sanitize_bool( get_option( $args[0], $args[1] ) );
  425. $html = '<label><input type="radio" id="' . esc_attr( $args[0] ) . '" name="' . esc_attr( $args[0] ) . '" value="1" ' . checked( $value, true, false ) . '/> ' . esc_html__( 'On', 'vamtam-consulting' ) . '</label> ';
  426. $html .= '<label><input type="radio" id="' . esc_attr( $args[0] ) . '" name="' . esc_attr( $args[0] ) . '" value="0" ' . checked( $value, false, false ) . '/> ' . esc_html__( 'Off', 'vamtam-consulting' ) . '</label>';
  427. $html .= '<p class="description">' . wp_kses_post( __('By enabling this option you will opt in to automatically send our support system detailed information about your website. Please note that we might be able to respond more quickly if you leave this disabled. We advise you to turn on this option before opening a support ticket. Here is the information that we collect when this option is enabled:
  428. <ul>
  429. <li>memory limit</li>
  430. <li>is wp_debug enabled</li>
  431. <li>list of active plugins and their versions</li>
  432. <li>POST requests limit</li>
  433. <li>allowed number of request variables</li>
  434. <li>default time limit</li>
  435. <li>permissions for the cache/ directory inside the theme</li>
  436. <li>does wp_remote_post() work as expected</li>
  437. </ul>
  438. None of this information will be shared with third parties.
  439. ', 'vamtam-consulting') ) . '</p>';
  440. echo $html; // xss ok
  441. }
  442. }