id !== 'plugins' ) { remove_action( 'admin_notices', array( $GLOBALS['tgmpa'], 'notices' ), 10 ); } } private static function server_tests() { $timeout = (int) ini_get( 'max_execution_time' ); $memory = ini_get( 'memory_limit' ); $memoryB = str_replace( array( 'G', 'M', 'K' ), array( '000000000', '000000', '000' ), $memory ); $tests = array( array( 'name' => esc_html__( 'PHP Version', 'vamtam-consulting' ), 'test' => version_compare( phpversion(), '5.5', '<' ), 'value' => phpversion(), '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' ), ), array( 'name' => esc_html__( 'PHP Time Limit', 'vamtam-consulting' ), 'test' => $timeout > 0 && $timeout < 30, 'value' => $timeout, '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' ), ), array( 'name' => esc_html__( 'PHP Memory Limit', 'vamtam-consulting' ), 'test' => (int) $memory > 0 && $memoryB < 96 * 1024 * 1024, 'value' => $memory, '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' ), ), array( 'name' => esc_html__( 'PHP ZipArchive Extension', 'vamtam-consulting' ), 'test' => ! class_exists( 'ZipArchive' ), 'value' => '', 'desc' => esc_html__( 'ZipArchive is a requirement for importing the demo sliders.', 'vamtam-consulting' ), ), ); $fail = 0; foreach ( $tests as $test ) { $fail += (int) $test['test']; } return array( 'fail' => $fail, 'tests' => $tests, ); } private static function is_theme_setup_page() { return isset( $_GET['page'] ) && in_array( $_GET['page'], array( 'vamtam_theme_setup' ) ); } public static function admin_scripts() { $theme_version = VamtamFramework::get_version(); wp_register_script( 'vamtam-check-license', VAMTAM_ADMIN_ASSETS_URI . 'js/check-license.js', array( 'jquery-core' ), $theme_version, true ); wp_register_script( 'vamtam-import-buttons', VAMTAM_ADMIN_ASSETS_URI . 'js/import-buttons.js', array( 'jquery-core' ), $theme_version, true ); } public static function tgmpa_plugins_complete_actions( $update_actions, $plugin_info ) { if ( isset( $update_actions['dashboard'] ) ) { $update_actions['dashboard'] = sprintf( esc_html__( 'All plugins installed and activated successfully. %1$s', 'vamtam-consulting' ), '' . esc_html__( 'Continue with theme setup.', 'vamtam-consulting' ) . '' ); $update_actions['dashboard'] .= ' '; } return $update_actions; } public static function notice() { if ( self::needs_mu_plugin() && ( ! isset( $_GET['page'] ) || ( $_GET['page'] !== 'vamtam_theme_setup' && $_GET['page'] !== 'tgmpa-install-plugins' ) ) ) { $url = admin_url( 'admin.php?page=vamtam_theme_setup' ); echo '
'; echo '

'; echo wp_kses_post( sprintf( __( 'You have activated your VamTam theme for the first time. Click here to complete the setup.', 'vamtam-consulting' ), esc_url( $url ) ) ); echo '

'; echo '
'; } } public static function admin_menu() { 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' ) ); } public static function admin_early_init() { if ( self::is_theme_setup_page() ) { add_filter( 'woocommerce_prevent_automatic_wizard_redirect', '__return_true' ); add_filter( 'wp_redirect', array( __CLASS__, 'block_redirects_to_admin' ) ); // prevents redirects out of the theme setup page } if ( get_transient( '_fp_activation_redirect' ) ) { delete_transient( '_fp_activation_redirect' ); } if ( get_transient( '_booked_welcome_screen_activation_redirect' ) ) { delete_transient( '_booked_welcome_screen_activation_redirect' ); } } public static function block_redirects_to_admin( $location ) { if ( strpos( $location, 'wp-admin/' ) !== false ) { return false; // block redirect to other admin pages } return $location; } public static function admin_init() { add_settings_section( 'vamtam_purchase_settings_section', '', array( __CLASS__, 'settings_section' ), 'vamtam_theme_setup' ); add_settings_field( 'vamtam-envato-license-key', esc_html__( 'Envato Purchase Key', 'vamtam-consulting' ), array( __CLASS__, 'purchase_key' ), 'vamtam_theme_setup', 'vamtam_purchase_settings_section', array( 'vamtam-envato-license-key', ) ); register_setting( 'vamtam_theme_setup', 'vamtam-envato-license-key', array( __CLASS__, 'sanitize_license_key' ) ); add_settings_field( 'vamtam-system-status-opt-in', esc_html__( 'Enable System Status Information Gathering', 'vamtam-consulting' ), array( __CLASS__, 'radio' ), 'vamtam_theme_setup', 'vamtam_purchase_settings_section', array( 'vamtam-system-status-opt-in', true, ) ); register_setting( 'vamtam_theme_setup', 'vamtam-system-status-opt-in' ); } public static function sanitize_license_key( $value ) { return preg_replace( '/[^-\w\d]/', '', $value ); } public static function settings_section() { } public static function page() { wp_enqueue_script( 'vamtam-check-license' ); $status = self::server_tests(); ?>

0 ) : ?>

' . esc_html( $test['desc'] ) . '

'; ?>

' . wp_kses_post( __( 'This step is optional, but highly recommended, especially if your server has a low memory limit. ', 'vamtam-consulting' ) ) . '

'; echo '

' . 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:

%s/10-vamtam-exclude-plugins.php
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 ) ) . '

'; echo '' . esc_html__( 'Install MU Plugin', 'vamtam-consulting' ) . ''; } } else { esc_html_e( 'All done.', 'vamtam-consulting' ); } ?>

copy( $source_file, $target_file, FS_CHMOD_FILE ) ) { printf( esc_html__( "Couldn't install the requisite mu-plugin. Please manually copy %1\$s to %2\$s", 'vamtam-consulting' ), esc_html( $source_file ), esc_html( $target_file ) ); return false; } show_message( __( 'All done. Please continue below.', 'vamtam-consulting' ) ); update_option( self::$mu_plugin_opt_name, self::$mu_plugin_version ); } public static function import_buttons() { wp_enqueue_script( 'vamtam-import-buttons' ); include_once ABSPATH . 'wp-admin/includes/plugin.php'; $revslider = defined( 'RS_PLUGIN_PATH' ); $ninjaforms = function_exists( 'Ninja_Forms' ); $jetpack = class_exists( 'Jetpack' ); $booked = class_exists( 'booked_plugin' ); $content_allowed = $jetpack; $content_imported = ! ! get_option( 'vamtam_last_import_map', false ); $content_disable = $content_imported ? '' : ' disabled content-disabled'; $messages = array( 'success-msg' => esc_html__( 'Imported.', 'vamtam-consulting' ), 'error-msg ' => esc_html__( 'Failed to import. Please click here in order to see the full error message.', 'vamtam-consulting' ), ); $import_tests = array( array( 'test' => true, 'title' => esc_html__( 'Posts and Pages', 'vamtam-consulting' ), ), array( 'test' => vamtam_has_woocommerce(), 'title' => esc_html__( 'Products', 'vamtam-consulting' ), 'failed' => wp_kses_data( __( '(Please install and activate WooCommerce first.)', 'vamtam-consulting' ) ), ), array( 'test' => class_exists( 'Tribe__Events__Main' ), 'title' => esc_html__( 'Events', 'vamtam-consulting' ), 'failed' => wp_kses_data( __( '(Please install and activate The Events Calendar first.)', 'vamtam-consulting' ) ), ), array( 'test' => class_exists( 'Mega_Menu' ), 'title' => esc_html__( 'Max Mega Menu settings', 'vamtam-consulting' ), 'failed' => wp_kses_data( __( '(Please install and activate Max Mega Menu first.)', 'vamtam-consulting' ) ), ), ); $will_import = array(); foreach ( $import_tests as $test ) { $will_import[] = ' ' . $test['title'] . ' ' . ( $test['test'] ? '' : $test['failed'] ) . ''; } $revslider_samples_dir = VAMTAM_SAMPLES_DIR . 'revslider/'; $revslider_samples = is_dir( $revslider_samples_dir ) ? iterator_count( new FilesystemIterator( $revslider_samples_dir , FilesystemIterator::SKIP_DOTS ) ) : 0; $buttons = array( array( 'label' => esc_html__( 'Content Import', 'vamtam-consulting' ), 'id' => 'content-import-button', 'description' => esc_html__( 'You are advised to use this importer only on new WordPress sites. Jetpack must be installed and active.', 'vamtam-consulting' ), 'button_title' => esc_html__( 'Import Dummy Content', 'vamtam-consulting' ), 'href' => $content_allowed ? wp_nonce_url( admin_url( 'admin.php?import=wpv&step=2' ), 'vamtam-import' ) : 'javascript:void( 0 )', 'type' => 'button', 'class' => $content_allowed ? 'vamtam-import-button' : 'disabled', 'data' => array_merge( $messages, array( 'content-imported', $content_imported ) ), 'disabled_msg' => wp_kses_data( __( 'Please install and activate Jetpack first.', 'vamtam-consulting' ) ), '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.

Image thumbnails will be generated in the background after the main import is complete.
This may take up to half an hour, but you can start using your site after the spinner above is gone.

Will import:
%s', 'vamtam-consulting' ) ), implode( '
', $will_import ) ), ), array( 'label' => esc_html__( 'Ninja Forms', 'vamtam-consulting' ), 'id' => 'widget-import-button', 'button_title' => esc_html__( 'Import Forms', 'vamtam-consulting' ), 'href' => $ninjaforms ? wp_nonce_url( admin_url( 'admin.php?import=vamtam_ninjaforms' ), 'vamtam-import-ninja-forms' ) : 'javascript:void( 0 )', 'type' => 'button', 'class' => $ninjaforms ? 'vamtam-import-button' : 'disabled', 'data' => $messages, 'disabled_msg' => wp_kses_data( __( 'Please install and activate Ninja Forms first.', 'vamtam-consulting' ) ), ), array( 'label' => esc_html__( 'Widget Import', 'vamtam-consulting' ), 'id' => 'widget-import-button', 'description' => esc_html__( 'Using this importer will overwrite your current sidebar settings', 'vamtam-consulting' ), 'button_title' => esc_html__( 'Import Widgets', 'vamtam-consulting' ), 'href' => wp_nonce_url( admin_url( 'admin.php?import=vamtam_widgets' ), 'vamtam-import' ), 'type' => 'button', 'class' => 'vamtam-import-button' . $content_disable, 'data' => $messages, 'disabled_msg' => wp_kses_data( __( 'You must import the demo content before the widgets.', 'vamtam-consulting' ) ), 'disabled_msg_href' => 'nolink', ), array( 'label' => esc_html__( 'Slider Revolution', 'vamtam-consulting' ), 'id' => 'slider-import-button', 'button_title' => esc_html__( 'Import Slider Revolution Samples', 'vamtam-consulting' ), 'href' => $revslider && $revslider_samples > 0 ? wp_nonce_url( 'admin.php?import=vamtam_revslider', 'vamtam-import-revslider' ) : 'javascript:void( 0 )', 'type' => 'button', 'class' => $revslider && $revslider_samples > 0 ? 'vamtam-import-button' : 'disabled', 'data' => $messages, 'disabled_msg' => $revslider ? '' : wp_kses_data( __( 'Please install and activate Slider Revolution first. ', 'vamtam-consulting' ) ), 'disabled_msg_plain' => $revslider_samples > 0 ? '' : wp_kses_data( __( 'Slider samples are misssing. Please contact VamTam Support', 'vamtam-consulting' ) ), ), array( 'label' => esc_html__( 'Booked', 'vamtam-consulting' ), 'id' => 'booked-import-button', 'description' => esc_html__( 'Using this importer will overwrite your current Booked settings', 'vamtam-consulting' ), 'button_title' => esc_html__( 'Import Booked Settings', 'vamtam-consulting' ), 'href' => $booked ? wp_nonce_url( 'admin.php?import=vamtam_booked', 'vamtam-import-booked' ) : 'javascript:void( 0 )', 'type' => 'button', 'class' => $booked ? 'vamtam-import-button' : 'disabled', 'data' => $messages, 'disabled_msg' => wp_kses_data( __( 'Please install and activate Booked first.', 'vamtam-consulting' ) ), ), ); echo ''; foreach ( $buttons as $button ) { self::render_button( $button ); } echo '
'; } public static function render_button( $button ) { echo ''; echo '' . esc_html( $button['label'] ) . ''; $data = array(); if ( isset( $button['data'] ) ) { foreach ( $button['data'] as $attr_name => $attr_value ) { $data[] = 'data-' . sanitize_title_with_dashes( $attr_name ) . '="' . esc_attr( $attr_value ) . '"'; } } $data = implode( ' ', $data ); echo ''; echo '' . esc_html( $button['button_title'] ) . ''; // xss ok - $data escaped above if ( strpos( $button['class'], 'disabled' ) !== false ) { $href = isset( $button['disabled_msg_href'] ) ? $button['disabled_msg_href'] : admin_url( 'themes.php?page=tgmpa-install-plugins&plugin_status=all' ); echo '

'; if ( $href !== 'nolink' ) { echo '' . wp_kses_data( $button['disabled_msg'] ) . ''; } else { echo wp_kses_data( $button['disabled_msg'] ); } echo '

'; if ( isset( $button['disabled_msg_plain'] ) ) { echo '

' . wp_kses_data( $button['disabled_msg_plain'] ) . '

'; } } if ( isset( $button['additional_msg'] ) ) { echo '

' . $button['additional_msg'] . '

'; // xss ok } echo ''; echo ''; } public static function purchase_key( $args ) { $option_value = get_option( $args[0] ); $button_data = ''; $data = array( 'nonce' => wp_create_nonce( 'vamtam-check-license' ), 'full-info' => wp_kses_post( sprintf( __('
Licensing Terms
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 Licensing Terms on the ThemeForest site.', 'vamtam-consulting'), 'http://themeforest.net/licenses' ) ), ); foreach ( $data as $key => $value ) { $button_data .= ' data-' . $key . '="' . esc_attr( $value ) . '"'; } $html = ''; if ( ! defined( 'ENVATO_HOSTED_SITE' ) ) { $html .= ''; $html .= ''; $html .= ''; $html .= '

' . wp_kses_post( sprintf( __( ' Where can I find my Item Purchase Code?', 'vamtam-consulting' ), 'https://beaver.support.vamtam.com/support/solutions/articles/227253-vamtam-beaver-themes-where-to-get-your-item-purchase-key-from-' ) ) . '

'; $html .= '
'; } echo $html; // xss ok } public static function radio( $args ) { $value = vamtam_sanitize_bool( get_option( $args[0], $args[1] ) ); $html = ' '; $html .= ''; $html .= '

' . 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:

None of this information will be shared with third parties. ', 'vamtam-consulting') ) . '

'; echo $html; // xss ok } }