diff --git a/.standard.json b/.standard.json index 5d326d2..8891683 100644 --- a/.standard.json +++ b/.standard.json @@ -1 +1 @@ -{"404.php":[],"archive-jetpack-portfolio.php":[],"archive.php":[],"attachment.php":[],"comments.php":[],"footer.php":[],"functions.php":[],"header.php":[],"inc/admin/welcome-screen/class-shapely-notify-system.php":[],"inc/admin/welcome-screen/class-shapely-welcome.php":[],"inc/admin/welcome-screen/sections/actions-required.php":[],"inc/admin/welcome-screen/sections/getting-started.php":[],"inc/admin/welcome-screen/sections/recommended-plugins.php":[],"inc/admin/welcome-screen/sections/support.php":[],"inc/class-shapely-related-posts.php":[],"inc/class-wp-bootstrap-navwalker.php":[],"inc/custom-controls/class-shapely-logo-dimensions.php":[],"inc/customizer.php":[],"inc/extras.php":[],"inc/jetpack.php":[],"inc/libraries/epsilon-framework/class-epsilon-autoloader.php":[],"inc/libraries/epsilon-framework/class-epsilon-framework.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-color-coded-categories.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-color-scheme.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-content-backup.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-customizer.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-notifications.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-notify-system.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-repeater-templates.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-sanitizers.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-typography.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-color-picker.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-color-scheme.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-customizer-navigation.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-icon-picker.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-image.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-layouts.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-repeater.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-section-repeater.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-slider.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-text-editor.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-toggle.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-typography.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-upsell.php":[],"inc/libraries/epsilon-framework/customizer/sections/class-epsilon-section-pro.php":[],"inc/libraries/epsilon-framework/customizer/sections/class-epsilon-section-recommended-actions.php":[],"inc/libraries/epsilon-framework/customizer/settings/class-epsilon-setting-repeater.php":[],"inc/socialnav.php":[],"inc/template-tags.php":[],"index.php":[],"page-templates/full-width.php":[],"page-templates/no-sidebar.php":[],"page-templates/sidebar-left.php":[],"page-templates/sidebar-right.php":[],"page-templates/template-home.php":[],"page.php":[],"search.php":[],"sidebar-footer.php":[],"sidebar.php":[],"single-jetpack-portfolio.php":[],"single.php":[],"template-parts/content-attachment.php":[],"template-parts/content-grid-small.php":[],"template-parts/content-grid-wide.php":[],"template-parts/content-none.php":[],"template-parts/content-page.php":[],"template-parts/content-portfolio.php":[],"template-parts/content-search.php":[],"template-parts/content.php":[],"template-parts/layouts/blog-grid.php":[],"template-parts/layouts/blog-large-image-grid.php":[],"template-parts/layouts/blog-large-image.php":[],"woocommerce.php":[],"woocommerce/product-searchform.php":[]} \ No newline at end of file +{"404.php":[],"archive-jetpack-portfolio.php":[],"archive.php":[],"attachment.php":[],"comments.php":[],"footer.php":[],"functions.php":[],"header.php":[],"inc/admin/welcome-screen/class-shapely-notify-system.php":[],"inc/admin/welcome-screen/class-shapely-welcome.php":[],"inc/admin/welcome-screen/sections/actions-required.php":[],"inc/admin/welcome-screen/sections/getting-started.php":[],"inc/admin/welcome-screen/sections/recommended-plugins.php":[],"inc/admin/welcome-screen/sections/support.php":[],"inc/class-shapely-builder.php":[],"inc/class-shapely-notify-system.php":[],"inc/class-shapely-related-posts.php":[],"inc/class-shapely.php":[],"inc/class-wp-bootstrap-navwalker.php":[],"inc/custom-controls/class-shapely-logo-dimensions.php":[],"inc/customizer.php":[],"inc/extras.php":[],"inc/jetpack.php":[],"inc/libraries/epsilon-framework/class-epsilon-autoloader.php":[],"inc/libraries/epsilon-framework/class-epsilon-framework.php":[],"inc/libraries/epsilon-framework/classes/backend/class-epsilon-content-backup.php":[],"inc/libraries/epsilon-framework/classes/backend/class-epsilon-notifications.php":[],"inc/libraries/epsilon-framework/classes/backend/class-epsilon-notify-system.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-ajax-controller.php":[],"inc/libraries/epsilon-framework/classes/class-epsilon-customizer.php":[],"inc/libraries/epsilon-framework/classes/helpers/class-epsilon-helper.php":[],"inc/libraries/epsilon-framework/classes/helpers/class-epsilon-sanitizers.php":[],"inc/libraries/epsilon-framework/classes/output/class-epsilon-color-coded-categories.php":[],"inc/libraries/epsilon-framework/classes/output/class-epsilon-color-scheme.php":[],"inc/libraries/epsilon-framework/classes/output/class-epsilon-page-generator.php":[],"inc/libraries/epsilon-framework/classes/output/class-epsilon-repeater-templates.php":[],"inc/libraries/epsilon-framework/classes/output/class-epsilon-typography.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-button-group.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-color-picker.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-color-scheme.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-customizer-navigation.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-icon-picker.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-image.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-layouts.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-repeater.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-section-repeater.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-slider.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-text-editor.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-toggle.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-typography.php":[],"inc/libraries/epsilon-framework/customizer/controls/class-epsilon-control-upsell.php":[],"inc/libraries/epsilon-framework/customizer/panels/class-epsilon-panel-regular.php":[],"inc/libraries/epsilon-framework/customizer/sections/class-epsilon-section-doubled.php":[],"inc/libraries/epsilon-framework/customizer/sections/class-epsilon-section-pro.php":[],"inc/libraries/epsilon-framework/customizer/sections/class-epsilon-section-recommended-actions.php":[],"inc/libraries/epsilon-framework/customizer/settings/class-epsilon-setting-repeater.php":[],"inc/libraries/welcome-screen/class-epsilon-welcome-screen.php":[],"inc/libraries/welcome-screen/sections/getting-started.php":[],"inc/libraries/welcome-screen/sections/recommended-actions.php":[],"inc/libraries/welcome-screen/sections/recommended-plugins.php":[],"inc/libraries/welcome-screen/sections/support.php":[],"inc/socialnav.php":[],"inc/template-tags.php":[],"index.php":[],"page-templates/full-width.php":[],"page-templates/no-sidebar.php":[],"page-templates/sidebar-left.php":[],"page-templates/sidebar-right.php":[],"page-templates/template-home.php":[],"page-templates/template-widget.php":[],"page.php":[],"search.php":[],"sidebar-footer.php":[],"sidebar.php":[],"single-jetpack-portfolio.php":[],"single.php":[],"template-parts/content-attachment.php":[],"template-parts/content-grid-small.php":[],"template-parts/content-grid-wide.php":[],"template-parts/content-none.php":[],"template-parts/content-page.php":[],"template-parts/content-portfolio.php":[],"template-parts/content-search.php":[],"template-parts/content.php":[],"template-parts/layouts/blog-grid.php":[],"template-parts/layouts/blog-large-image-grid.php":[],"template-parts/layouts/blog-large-image.php":[],"woocommerce.php":[],"woocommerce/product-searchform.php":[]} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 94ce7a1..c4f48cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,9 +38,7 @@ script: - mkdir -p build/logs - find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l - if [[ "$SNIFF" == "1" ]]; then jshint ./assets/js/*.js; fi -- if [[ "$SNIFF" == "1" ]]; then jshint ./inc/admin/welcome-screen/js/*.js; fi - if [[ "$SNIFF" == "1" ]]; then jscs ./assets/js/*.js; fi -- if [[ "$SNIFF" == "1" ]]; then jscs ./inc/admin/welcome-screen/js/*.js; fi - if [[ "$SNIFF" == "1" ]]; then grunt textdomain; fi - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/scripts/phpcs -p -s -v -n ./*.php --standard=./phpcs.ruleset.xml --extensions=php; fi diff --git a/assets/js/customizer.js b/assets/js/customizer.js index 2c87b44..1a1c571 100644 --- a/assets/js/customizer.js +++ b/assets/js/customizer.js @@ -35,15 +35,19 @@ } ); control.widthElement.keyup( function() { - if ( control.respectRatio && control.hasLogo ) { - control.calculateRatio( 'width' ); + if ( control.hasLogo ) { + if ( control.respectRatio ) { + control.calculateRatio( 'width' ); + } control.shapelyInterval = setInterval( control.updateControl, 1000, control ); } } ); control.heightElement.keyup( function() { - if ( control.respectRatio && control.hasLogo ) { - control.calculateRatio( 'height' ); + if ( control.hasLogo ) { + if ( control.respectRatio ) { + control.calculateRatio( 'height' ); + } control.shapelyInterval = setInterval( control.updateControl, 1000, control ); } } ); diff --git a/assets/js/shapely-scripts.js b/assets/js/shapely-scripts.js index 93d0602..5d396c5 100644 --- a/assets/js/shapely-scripts.js +++ b/assets/js/shapely-scripts.js @@ -341,6 +341,7 @@ } ); } else { + $( play ).on( 'click', function( e ) { var parent = $( this ).parents( '.video-widget' ), instance = $( parent ).data( 'vide' ), diff --git a/changelog.txt b/changelog.txt index bd09f61..c14ca0e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +### 1.2.1 + Implemented milestone https://github.com/puikinsh/shapely/milestone/5 + ### 1.1.6 Implemented milestone https://github.com/puikinsh/shapely/milestone/2 diff --git a/functions.php b/functions.php index 386674f..82f9cf9 100644 --- a/functions.php +++ b/functions.php @@ -114,71 +114,6 @@ function shapely_setup() { add_theme_support( 'wc-product-gallery-slider' ); add_theme_support( 'customize-selective-refresh-widgets' ); - // Welcome screen - if ( is_admin() ) { - global $shapely_required_actions, $shapely_recommended_plugins; - - $shapely_recommended_plugins = array( - 'contact-form-7' => array( - 'recommended' => false, - ), - 'fancybox-for-wordpress' => array( - 'recommended' => false, - ), - 'wordpress-seo' => array( - 'recommended' => false, - ), - ); - - /* - * id - unique id; required - * title - * description - * check - check for plugins (if installed) - * plugin_slug - the plugin's slug (used for installing the plugin) - * - */ - $path = WPMU_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php'; - if ( ! file_exists( $path ) ) { - $path = WP_PLUGIN_DIR . '/shapely-companion/inc/views/shapely-demo-content.php'; - if ( ! file_exists( $path ) ) { - $path = false; - } - } - - $shapely_required_actions = array( - array( - 'id' => 'shapely-req-ac-install-companion-plugin', - 'title' => Shapely_Notify_System::shapely_companion_title(), - 'description' => Shapely_Notify_System::shapely_companion_description(), - 'check' => Shapely_Notify_System::shapely_has_plugin( 'shapely-companion' ), - 'plugin_slug' => 'shapely-companion', - ), - array( - 'id' => 'shapely-req-ac-install-wp-jetpack-plugin', - 'title' => Shapely_Notify_System::shapely_jetpack_title(), - 'description' => Shapely_Notify_System::shapely_jetpack_description(), - 'check' => Shapely_Notify_System::shapely_has_plugin( 'jetpack' ), - 'plugin_slug' => 'jetpack', - ), - array( - 'id' => 'shapely-req-ac-install-contact-form-7', - 'title' => Shapely_Notify_System::shapely_cf7_title(), - 'description' => Shapely_Notify_System::shapely_cf7_description(), - 'check' => Shapely_Notify_System::shapely_has_plugin( 'contact-form-7' ), - 'plugin_slug' => 'contact-form-7', - ), - array( - 'id' => 'shapely-req-import-content', - 'title' => esc_html__( 'Import content', 'shapely' ), - 'external' => $path, - 'check' => Shapely_Notify_System::shapely_check_import_req(), - ), - - ); - - require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-welcome.php'; - }// End if(). // Enable Shortcodes in widgets add_filter( 'widget_text', 'do_shortcode' ); @@ -328,16 +263,6 @@ function shapely_scripts() { add_action( 'wp_enqueue_scripts', 'shapely_scripts' ); -// Include Epsilon Framework -require_once 'inc/libraries/epsilon-framework/class-epsilon-autoloader.php'; -$args = array( - 'controls' => array( 'slider', 'toggle' ), // array of controls to load - 'sections' => array( 'recommended-actions', 'pro' ), // array of sections to load - 'backup' => false, -); - -new Epsilon_Framework( $args ); - /** * Custom template tags for this theme. */ @@ -374,9 +299,9 @@ function shapely_scripts() { require get_template_directory() . '/inc/class-shapely-related-posts.php'; /** - * Load the system checks ( used for notifications ) + * Load the shapely class */ -require get_template_directory() . '/inc/admin/welcome-screen/class-shapely-notify-system.php'; +require get_template_directory() . '/inc/class-shapely.php'; /** * Load the shapely page builder class diff --git a/inc/admin/welcome-screen/class-shapely-welcome.php b/inc/admin/welcome-screen/class-shapely-welcome.php deleted file mode 100644 index ac95567..0000000 --- a/inc/admin/welcome-screen/class-shapely-welcome.php +++ /dev/null @@ -1,417 +0,0 @@ -theme_name = $theme->get( 'Name' ); - $this->theme_slug = $theme->get( 'TextDomain' ); - - /** - * Add the notice in the admin backend - */ - $this->shapely_activation_admin_notice(); - - } - - /** - * Creates the dashboard page - * - * @see add_theme_page() - * @since 1.8.2.4 - */ - public function shapely_welcome_register_menu() { - $action_count = $this->count_actions(); - $title = $action_count > 0 ? esc_html__( 'About Shapely', 'shapely' ) . '' . esc_html( $action_count ) . '' : esc_html__( 'About Shapely', 'shapely' ); - - add_theme_page( - 'About shapely', $title, 'edit_theme_options', 'shapely-welcome', array( - $this, - 'shapely_welcome_screen', - ) - ); - } - - /** - * Adds an admin notice upon successful activation. - * - * @since 1.8.2.4 - */ - public function shapely_activation_admin_notice() { - if ( ! class_exists( 'Epsilon_Notifications' ) ) { - return; - } - - if ( empty( $this->notice ) ) { - $this->notice = ''; - - /* Translators: %1$s - Theme Name */ - $this->notice .= '
'; - $this->notice .= - sprintf( /* Translators: Notice */ - esc_html__( 'Welcome! Thank you for choosing %3$s! To fully take advantage of the best our theme can offer please make sure you visit our %1$swelcome page%2$s.', 'shapely' ), - '', - '', - $this->theme_name - ); - $this->notice .= '
'; - /* Translators: %1$s - Theme Name */ - $this->notice .= '' . sprintf( esc_html__( 'Get started with %1$s', 'shapely' ), $this->theme_name ) . '
'; - - } - - $notifications = Epsilon_Notifications::get_instance(); - $notifications->add_notice( - array( - 'id' => 'shapely_install_notice', - 'type' => 'notice epsilon-big', - 'message' => $this->notice, - ) - ); - } - - /** - * Display an admin notice linking to the welcome screen - * - * @since 1.8.2.4 - */ - public function shapely_welcome_admin_notice() { - ?> - - absint( $this->count_actions() ), - 'ajaxurl' => esc_url( admin_url( 'admin-ajax.php' ) ), - 'template_directory' => esc_url( get_template_directory_uri() ), - 'no_required_actions_text' => esc_html__( 'Hooray! There are no required actions for you right now.', 'shapely' ), - ) - ); - - } - - /** - * Load scripts for customizer page - * - * @since 1.8.2.4 - */ - public function shapely_welcome_scripts_for_customizer() { - - wp_enqueue_style( 'shapely-welcome-screen-customizer-css', get_template_directory_uri() . '/inc/admin/welcome-screen/css/welcome_customizer.css' ); - - } - - /** - * Dismiss required actions - * - * @since 1.8.2.4 - */ - public function shapely_dismiss_required_action_callback() { - - global $shapely_required_actions; - - $action_id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0; - - echo esc_html( wp_unslash( $action_id ) ); /* this is needed and it's the id of the dismissable required action */ - - if ( ! empty( $action_id ) ) : - - /* if the option exists, update the record for the specified id */ - if ( get_option( 'shapely_show_required_actions' ) ) : - - $shapely_show_required_actions = get_option( 'shapely_show_required_actions' ); - - switch ( esc_html( $_GET['todo'] ) ) { - case 'add': - $shapely_show_required_actions[ $action_id ] = true; - break; - case 'dismiss': - $shapely_show_required_actions[ $action_id ] = false; - break; - default: - return new WP_Error( 'Action denied!', __( 'I\'ve fallen and can\'t get up', 'shapely' ) ); - break; - } - - update_option( 'shapely_show_required_actions', $shapely_show_required_actions ); - - /* create the new option,with false for the specified id */ - else : - - $shapely_show_required_actions_new = array(); - - if ( ! empty( $shapely_required_actions ) ) : - - foreach ( $shapely_required_actions as $shapely_required_action ) : - - if ( $shapely_required_action['id'] == $action_id ) : - $shapely_show_required_actions_new[ $shapely_required_action['id'] ] = false; - else : - $shapely_show_required_actions_new[ $shapely_required_action['id'] ] = true; - endif; - - endforeach; - - update_option( 'shapely_show_required_actions', $shapely_show_required_actions_new ); - - endif; - - endif; - - endif; - - die(); // this is required to return a proper result - } - - /** - * - */ - public function count_actions() { - global $shapely_required_actions; - - $shapely_show_required_actions = get_option( 'shapely_show_required_actions' ); - if ( ! $shapely_show_required_actions ) { - $shapely_show_required_actions = array(); - } - - $i = 0; - foreach ( $shapely_required_actions as $action ) { - $true = false; - $dismissed = false; - - if ( ! $action['check'] ) { - $true = true; - } - - if ( ! empty( $shapely_show_required_actions ) && isset( $shapely_show_required_actions[ $action['id'] ] ) && ! $shapely_show_required_actions[ $action['id'] ] ) { - $true = false; - } - - if ( $true ) { - $i ++; - } - } - - return $i; - } - - public function call_plugin_api( $slug ) { - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); - $call_api = get_transient( 'shapely_plugin_information_transient_' . $slug ); - if ( false === $call_api ) { - $call_api = plugins_api( - 'plugin_information', array( - 'slug' => $slug, - 'fields' => array( - 'downloaded' => false, - 'rating' => false, - 'description' => false, - 'short_description' => true, - 'donate_link' => false, - 'tags' => false, - 'sections' => true, - 'homepage' => true, - 'added' => false, - 'last_updated' => false, - 'compatibility' => false, - 'tested' => false, - 'requires' => false, - 'downloadlink' => false, - 'icons' => true, - ), - ) - ); - set_transient( 'shapely_plugin_information_transient_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); - } - - return $call_api; - } - - public function check_active( $slug ) { - $slug2 = Shapely_Notify_System::_get_plugin_basename_from_slug( $slug ); - - $path = WP_PLUGIN_DIR . '/' . $slug2; - if ( ! file_exists( $path ) ) { - $path = false; - } - - if ( file_exists( $path ) ) { - include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); - - $needs = is_plugin_active( $slug2 ) ? 'deactivate' : 'activate'; - - return array( - 'status' => is_plugin_active( $slug2 ), - 'needs' => $needs, - ); - } - - return array( - 'status' => false, - 'needs' => 'install', - ); - } - - public function check_for_icon( $arr ) { - if ( ! empty( $arr['svg'] ) ) { - $plugin_icon_url = $arr['svg']; - } elseif ( ! empty( $arr['2x'] ) ) { - $plugin_icon_url = $arr['2x']; - } elseif ( ! empty( $arr['1x'] ) ) { - $plugin_icon_url = $arr['1x']; - } else { - $plugin_icon_url = $arr['default']; - } - - return $plugin_icon_url; - } - - public function create_action_link( $state, $slug ) { - $slug2 = Shapely_Notify_System::_get_plugin_basename_from_slug( $slug ); - - switch ( $state ) { - case 'install': - return wp_nonce_url( - add_query_arg( - array( - 'action' => 'install-plugin', - 'plugin' => $slug, - ), - network_admin_url( 'update.php' ) - ), - 'install-plugin_' . $slug - ); - break; - case 'deactivate': - return add_query_arg( - array( - 'action' => 'deactivate', - 'plugin' => rawurlencode( $slug2 ), - 'plugin_status' => 'all', - 'paged' => '1', - '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug2 ), - ), admin_url( 'plugins.php' ) - ); - break; - case 'activate': - return add_query_arg( - array( - 'action' => 'activate', - 'plugin' => rawurlencode( $slug2 ), - 'plugin_status' => 'all', - 'paged' => '1', - '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug2 ), - ), admin_url( 'plugins.php' ) - ); - break; - } - } - - /** - * Welcome screen content - * - * @since 1.8.2.4 - */ - public function shapely_welcome_screen() { - require_once( ABSPATH . 'wp-load.php' ); - require_once( ABSPATH . 'wp-admin/admin.php' ); - require_once( ABSPATH . 'wp-admin/admin-header.php' ); - - $shapely = wp_get_theme(); - $active_tab = isset( $_GET['tab'] ) ? wp_unslash( $_GET['tab'] ) : 'getting_started'; - $action_count = $this->count_actions(); - - ?> - -- - ' . wp_kses_post( $shapely_required_action_value['help'] ); -endif; -?> -
- - check_active( $shapely_required_action_value['plugin_slug'] ); - $url = $this->create_action_link( $active['needs'], $shapely_required_action_value['plugin_slug'] ); - $label = ''; - - switch ( $active['needs'] ) { - case 'install': - $class = 'install-now button'; - $label = esc_html__( 'Install', 'shapely' ); - break; - case 'activate': - $class = 'activate-now button button-primary'; - $label = esc_html__( 'Activate', 'shapely' ); - break; - case 'deactivate': - $class = 'deactivate-now button'; - $label = esc_html__( 'Deactivate', 'shapely' ); - break; - } - - ?> - - -' . __( 'Import Demo Content', 'shapely' ) . ''; + $html .= '' . __( 'Advanced', 'shapely' ) . '
'; + $html .= ' '; + } + + return $html; + + } + + private function generate_checkbox( $id, $label, $name = 'options', $block = false ) { + $string = ''; + return sprintf( $string, $name, $id, $label ); + } + +} +new Shapely(); diff --git a/inc/customizer.php b/inc/customizer.php index d1e4ec0..ecdcbfd 100644 --- a/inc/customizer.php +++ b/inc/customizer.php @@ -75,60 +75,15 @@ function shapely_customize_register( $wp_customize ) { */ function shapely_customizer( $wp_customize ) { - // Recomended actions - global $shapely_required_actions, $shapely_recommended_plugins; - require_once get_template_directory() . '/inc/custom-controls/class-shapely-logo-dimensions.php'; - $customizer_recommended_plugins = array(); - if ( is_array( $shapely_recommended_plugins ) ) { - foreach ( $shapely_recommended_plugins as $k => $s ) { - if ( $s['recommended'] ) { - $customizer_recommended_plugins[ $k ] = $s; - } - } - } - - $customizer_shapely_required_actions = array(); - if ( ! empty( $shapely_required_actions ) ) { - foreach ( $shapely_required_actions as $required_action ) { - if ( 'shapely-req-import-content' == $required_action['id'] ) { - $required_action['description'] = sprintf( - esc_html__( 'In oder to import the demo content go %s', 'shapely' ), - '' . esc_html__( 'here', 'shapely' ) . '' - ); - } - $customizer_shapely_required_actions[] = $required_action; - } - } - - $theme_slug = 'shapely'; - - $wp_customize->add_section( - new Epsilon_Section_Recommended_Actions( - $wp_customize, 'epsilon_recomended_section', array( - 'title' => esc_html__( 'Recomended Actions', 'shapely' ), - 'social_text' => esc_html__( 'We are social', 'shapely' ), - 'plugin_text' => esc_html__( 'Recomended Plugins', 'shapely' ), - 'actions' => $customizer_shapely_required_actions, - 'plugins' => $customizer_recommended_plugins, - 'theme_specific_option' => $theme_slug . '_show_required_actions', - 'theme_specific_plugin_option' => $theme_slug . '_show_recommended_plugins', - 'facebook' => 'https://www.facebook.com/colorlib', - 'twitter' => 'https://twitter.com/colorlib', - 'wp_review' => true, - 'priority' => 0, - ) - ) - ); - $wp_customize->add_section( new Epsilon_Section_Pro( $wp_customize, 'epsilon-section-pro', array( 'title' => esc_html__( 'Theme documentation', 'shapely' ), 'button_text' => esc_html__( 'Learn more', 'shapely' ), 'button_url' => 'https://colorlib.com/wp/support/shapely/', - 'priority' => 0, + 'priority' => 1, ) ) ); @@ -1234,6 +1189,13 @@ function shapely_customizer_custom_control_css() { .shapely-logo-dimension .ratio { clear: both; } + .widget-content .iris-picker .iris-strip .ui-slider-handle { + top: auto; + transform: translateX(0); + } + .widget-content .iris-picker .iris-slider-offset { + margin: 0; + } $theme->get( 'Name' ), + 'theme-slug' => $theme->get( 'TextDomain' ), + 'author-logo' => get_template_directory_uri() . '/inc/libraries/welcome-screen/img/colorlib.png', + 'actions' => array(), + 'plugins' => array(), + 'notice' => '', + 'sections' => array(), + 'edd' => false, + 'download_id' => '', + ); + + $config = wp_parse_args( $config, $defaults ); + + /** + * Configure our welcome screen + */ + $this->theme_name = $config['theme-name']; + $this->theme_slug = $config['theme-slug']; + $this->author_logo = $config['author-logo']; + $this->actions = $config['actions']; + $this->actions_count = $this->count_actions(); + $this->plugins = $config['plugins']; + $this->notice = $config['notice']; + $this->sections = $config['sections']; + $this->edd = $config['edd']; + $this->download_id = $config['download_id']; + + if ( $this->edd ) { + $this->strings = EDD_Theme_Helper::get_strings(); + } + + if ( empty( $config['sections'] ) ) { + $this->sections = $this->set_default_sections( $config ); + } + + /** + * Create the dashboard page + */ + add_action( 'admin_menu', array( $this, 'welcome_screen_menu' ) ); + + /** + * Load the welcome screen styles and scripts + */ + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) ); + + /** + * Add the notice in the admin backend + */ + $this->add_admin_notice(); + + /** + * Ajax callbacks + */ + add_action( + 'wp_ajax_welcome_screen_ajax_callback', array( + $this, + 'welcome_screen_ajax_callback', + ) + ); + add_action( + 'wp_ajax_nopriv_welcome_screen_ajax_callback', array( + $this, + 'welcome_screen_ajax_callback', + ) + ); + + if ( $this->edd ) { + /** + * Initiate EDD Stuff + */ + add_action( 'admin_init', array( 'EDD_Theme_Helper', 'init' ) ); + add_filter( 'http_request_args', array( 'EDD_Theme_Helper', 'disable_wporg_request' ), 5, 2 ); + + add_action( + 'update_option_' . $this->theme_slug . '_license_key', + array( + 'EDD_Theme_Helper', + 'license_activator_deactivator', + ), + 10, + 2 + ); + } + } + + /** + * AJAX Handler + */ + public function welcome_screen_ajax_callback() { + if ( isset( $_POST['args'], $_POST['args']['nonce'] ) && ! wp_verify_nonce( sanitize_key( $_POST['args']['nonce'] ), 'welcome_nonce' ) ) { + wp_die( + wp_json_encode( + array( + 'status' => false, + 'error' => esc_html__( 'Not allowed', 'epsilon-framework' ), + ) + ) + ); + } + + $args_action = array_map( 'sanitize_text_field', wp_unslash( $_POST['args']['action'] ) ); + + if ( count( $args_action ) !== 2 ) { + wp_die( + wp_json_encode( + array( + 'status' => false, + 'error' => esc_html__( 'Not allowed', 'epsilon-framework' ), + ) + ) + ); + } + + if ( ! class_exists( $args_action[0] ) ) { + wp_die( + wp_json_encode( + array( + 'status' => false, + 'error' => esc_html__( 'Class does not exist', 'epsilon-framework' ), + ) + ) + ); + } + + $class = $args_action[0]; + $method = $args_action[1]; + $args = array(); + + if ( is_array( $_POST['args']['args'] ) ) { + $args = Epsilon_Sanitizers::array_map_recursive( 'sanitize_text_field', wp_unslash( $_POST['args']['args'] ) ); + } + + $response = $class::$method( $args ); + + if ( is_array( $response ) ) { + wp_die( wp_json_encode( $response ) ); + } + + if ( 'ok' === $response ) { + wp_die( + wp_json_encode( + array( + 'status' => true, + 'message' => 'ok', + ) + ) + ); + } + + wp_die( + wp_json_encode( + array( + 'status' => false, + 'message' => 'nok', + ) + ) + ); + } + + /** + * Instance constructor + * + * @param array $config Configuration array. + * + * @returns object + */ + public static function get_instance( $config = array() ) { + static $inst; + + if ( ! $inst ) { + $inst = new Epsilon_Welcome_Screen( $config ); + } + + return $inst; + } + + /** + * Load welcome screen css and javascript + */ + public function enqueue() { + if ( is_admin() ) { + wp_enqueue_style( + 'welcome-screen', + get_template_directory_uri() . '/inc/libraries/welcome-screen/css/welcome.css' + ); + + wp_enqueue_script( + 'welcome-screen', + get_template_directory_uri() . '/inc/libraries/welcome-screen/js/welcome.js', + array( + 'jquery-ui-slider', + ), + '12123' + ); + + wp_localize_script( + 'welcome-screen', + 'welcomeScreen', + array( + 'nr_actions_required' => absint( $this->count_actions() ), + 'template_directory' => esc_url( get_template_directory_uri() ), + 'no_required_actions_text' => esc_html__( 'Hooray! There are no required actions for you right now.', 'epsilon-framework' ), + 'ajax_nonce' => wp_create_nonce( 'welcome_nonce' ), + 'activating_string' => esc_html__( 'Activating', 'epsilon-framework' ), + 'body_class' => 'appearance_page_' . $this->theme_slug . '-welcome', + 'no_actions' => esc_html__( 'Hooray! There are no required actions for you right now.', 'epsilon-framework' ), + ) + ); + } + } + + /** + * Return the actions left + * + * @return array|mixed + */ + private function get_actions_left() { + if ( ! empty( $this->actions ) ) { + $actions_left = get_option( $this->theme_slug . '_actions_left', array() ); + return $actions_left; + } + + return array(); + } + + /** + * Returns the plugins left to be installed + * + * @return array|mixed + */ + private function get_plugins_left() { + if ( ! empty( $this->plugins ) ) { + $plugins_left = get_option( $this->theme_slug . '_plugins_left', array() ); + if ( empty( $plugins_left ) ) { + foreach ( $this->plugins as $plugin => $prop ) { + $plugins_left[ $plugin ] = true; + } + + return $plugins_left; + } + + return $plugins_left; + } + + return array(); + } + + /** + * Adds an admin notice in the backend + * + * If the Epsilon Notification class does not exist, we stop + */ + private function add_admin_notice() { + if ( ! class_exists( 'Epsilon_Notifications' ) ) { + return; + } + + if ( empty( $this->notice ) ) { + if ( ! empty( $this->author_logo ) ) { + $this->notice .= ''; + } + /* Translators: Notice Title */ + $this->notice .= ''; + $this->notice .= + sprintf( /* Translators: Notice */ + esc_html__( 'Welcome! Thank you for choosing %3$s! To fully take advantage of the best our theme can offer please make sure you visit our %1$swelcome page%2$s.', 'epsilon-framework' ), + '', + '', + $this->theme_name + ); + $this->notice .= '
'; + /* Translators: Notice URL */ + $this->notice .= '' . sprintf( esc_html__( 'Get started with %1$s', 'epsilon-framework' ), $this->theme_name ) . '
'; + + } + + $notifications = Epsilon_Notifications::get_instance(); + $notifications->add_notice( + array( + 'id' => 'shapely_welcome_notification', + 'type' => 'notice epsilon-big', + 'message' => $this->notice, + ) + ); + } + + /** + * Registers the welcome screen menu + */ + public function welcome_screen_menu() { + /* Translators: Menu Title */ + $title = sprintf( esc_html__( 'About %1$s', 'epsilon-framework' ), esc_html( $this->theme_name ) ); + + if ( 0 < $this->actions_count ) { + $title .= '' . esc_html( $this->actions_count ) . ''; + } + + add_theme_page( + $this->theme_name, + $title, + 'edit_theme_options', + $this->theme_slug . '-welcome', + array( + $this, + 'render_welcome_screen', + ) + ); + } + + /** + * Render the welcome screen + */ + public function render_welcome_screen() { + require_once( ABSPATH . 'wp-load.php' ); + require_once( ABSPATH . 'wp-admin/admin.php' ); + require_once( ABSPATH . 'wp-admin/admin-header.php' ); + + $theme = wp_get_theme(); + $tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'getting-started'; + + ?> +Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius.
", + "doctor_image": "/assets/images/05_doctors_02.jpg", + "doctor_social_facebook": "https://facebook.com", + "doctor_social_twitter": "https://twitter.com", + "doctor_social_google": "https://google.com", + "doctor_social_linkedin": "https://linkedin.com" + }, + "1": { + "doctor_name": "Dr. Jonathan Doe", + "doctor_group": "Surgeon", + "doctor_description": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius.
", + "doctor_image": "/assets/images/05_doctors_01.jpg", + "doctor_social_facebook": "https://facebook.com", + "doctor_social_twitter": "https://twitter.com", + "doctor_social_google": "https://google.com", + "doctor_social_linkedin": "https://linkedin.com" + }, + "2": { + "doctor_name": "Dr. Jean Doe", + "doctor_group": "Surgeon", + "doctor_description": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius.
", + "doctor_image": "/assets/images/05_doctors_03.jpg", + "doctor_social_facebook": "https://facebook.com", + "doctor_social_twitter": "https://twitter.com", + "doctor_social_google": "https://google.com", + "doctor_social_linkedin": "https://linkedin.com" + }, + "3": { + "doctor_name": "Dr. Lisa Cuddy", + "doctor_group": "General", + "doctor_description": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius.
", + "doctor_image": "/assets/images/05_doctors_04.jpg", + "doctor_social_facebook": "https://facebook.com", + "doctor_social_twitter": "https://twitter.com", + "doctor_social_google": "https://google.com", + "doctor_social_linkedin": "https://linkedin.com" + } + } + }, + "hero_cta": { + "id": "hero_cta", + "setting": "medzone_cta_services", + "label": "Hero CTA Services", + "content": { + "0": { + "service_title": "Ambulance", + "service_icon": "fa fa-ambulance", + "service_description": "Wrroom Wroom!" + }, + "1": { + "service_title": "Cardiology Department", + "service_icon": "fa fa-heartbeat", + "service_description": "Tristique senectus et netus et malesuada fames ac turpis egestas." + }, + "2": { + "service_title": "Doctors Appointments", + "service_icon": "fa fa-stethoscope", + "service_description": "Get Free help Now!" + }, + "3": { + "service_title": "Extra services", + "service_icon": "fa fa-hospital-o", + "service_description": "Get Free help Now!" + }, + "4": { + "service_title": "No minuses", + "service_icon": "fa fa-wheelchair", + "service_description": "Wrroom Wroom!" + } + } + }, + "specialties": { + "id": "specialties", + "setting": "medzone_specialties", + "label": "Specialties", + "content": { + "0": { + "specialties_title": "Neurology", + "specialties_icon": "fa fa-stethoscope", + "specialties_description": "Outside of a medical emergency, your primary care physician is the \"first responder\" to your healthcare needs" + }, + "1": { + "specialties_title": "Surgery", + "specialties_icon": "fa fa-cut", + "specialties_description": "State-of-the-art surgical facilities where expert surgeons perform a full complement of procedures." + }, + "2": { + "specialties_title": "Cardio", + "specialties_icon": "fa fa-heartbeat", + "specialties_description": "Few of us like to even think about having a heart attack or being with someone when they have one." + }, + "3": { + "specialties_title": "Oncology", + "specialties_icon": "fa fa-hand-stop-o", + "specialties_description": "Rehabilitation services for conditions ranging from stroke and brain injury to neurological disorders." + } + } + }, + "about": { + "id": "about", + "setting": "medzone_about_info", + "label": "About", + "content": { + "0": { + "info_title": "Mission", + "info_description": "Our mission is to raise the long-term health status of our community by providing personalized, quality care with compassion, dignity, and respect.
" + }, + "1": { + "info_title": "Vision", + "info_description": "We are a community of caring health professionals, recognized for promoting wellness through early detection and prevention.
" + }, + "2": { + "info_title": "Admission", + "info_description": "When you arrive, unless you’re told otherwise, please go directly to the Admitting Department, located in the main hospital lobby.
" + } + } + }, + "information": { + "id": "information", + "setting": "medzone_hospital_information", + "label": "General Information", + "content": { + "0": { + "info_title": "24 Hours Support", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + }, + "1": { + "info_title": "Emergency Services", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + }, + "2": { + "info_title": "Online Appointment", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + }, + "3": { + "info_title": "Best Specialists", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + }, + "4": { + "info_title": "Latest Medical Equipments On The Market", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + }, + "5": { + "info_title": "Amazing Pacient Care", + "info_text": "Pellentesque dapibus tristique ornare. Quisque vitanimate viverra lorem. animatenean luctus lorem mi, et lobortis turpis porttitor ut. Donec dictum dolor varius metus pellentesque, quis elementum massa varius." + } + } + }, + "schedule": { + "id": "schedule", + "setting": "medzone_hospital_schedule", + "label": "Schedule", + "content": { + "0": { + "schedule_days": "Monday - Thursday", + "schedule_hours": "9:30 am - 8:30 pm" + }, + "1": { + "schedule_days": "Friday", + "schedule_hours": "9:30 am - 8:30 pm" + }, + "2": { + "schedule_days": "Weekend", + "schedule_hours": "10:30 am - 5:30 pm" + }, + "3": { + "schedule_days": "Holiday", + "schedule_hours": "Check Dates " + } + } + }, + "testimonials": { + "id": "testimonials", + "setting": "medzone_testimonials", + "label": "Testimonials", + "content": { + "0": { + "testimonial_title": "Doe Jane", + "testimonial_subtitle": "Attending Staff", + "testimonial_text": "\"One of the cleanest and professional plaes I had the chance to be in. The staff was friendly, The rooms very bright and the pacient care excellent. I went home after 3 days spent very well at Regina hospital.\"", + "testimonial_image": "/assets/images/08_testimonial.jpg" + }, + "1": { + "testimonial_title": "Jane Doe", + "testimonial_subtitle": "Attending Staff", + "testimonial_text": "\"One of the cleanest and professional place I had the chance to be in. The staff was friendly, The rooms very bright and the pacient care excellent. I went home after 3 days spent very well at Regina hospital.\"", + "testimonial_image": "/assets/images/08_testimonial.jpg" + } + } + } + }, + "sections": { + "hero": { + "id": "hero", + "label": "Hero", + "setting": "medzone_frontpage_sections", + "content": { + "hero_background_color": "#f9f9fa", + "hero_background": "/assets/images/01_header_01.png", + "hero_cta": "Best Medical Care you can get for you and your family.", + "hero_small": "More than 3000 specialists are here for you", + "hero_navigation": "", + "hero_repeater_field": "medzone_cta_services", + "type": "hero" + } + }, + "about": { + "id": "about", + "label": "About", + "setting": "medzone_frontpage_sections", + "content": { + "about_title": "Watch our impact in theWe are a a full-service, non-profit community hospital, offering comprehensive medical, surgical and therapeutic services. With 281 beds, more than 1900 employees and a world-class medical staff, we provide innovative, technologically advanced care on a patient-friendly, just north of Seattle.
", + "about_image": "/assets/images/01_our_impact.jpg", + "about_grouping": [ + "all" + ], + "about_navigation": "", + "about_repeater_field": "medzone_about_info", + "type": "about" + } + }, + "specialties": { + "id": "specialties", + "label": "Specialties", + "setting": "medzone_frontpage_sections", + "content": { + "main_specialty_title": "Main Specialties", + "main_specialty": "We value our patients", + "main_specialty_description": "MedZone provides complete medical and surgical services in both inpatient and outpatient settings, at in several convenient locations.
", + "specialties_grouping": [ + "all" + ], + "specialties_navigation": "", + "specialties_repeater_field": "medzone_specialties", + "type": "specialties" + } + }, + "openhours": { + "id": "openhours", + "label": "Open Hours", + "setting": "medzone_frontpage_sections", + "content": { + "openhours_background": "/assets/images/03_top_experience.png", + "openhours_title": "Top notchOur specialist make sure you get the best care there is.
", + "openhours_navigation": "", + "openhours_repeater_field": "medzone_hospital_schedule", + "type": "openhours" + } + }, + "accordion": { + "id": "openhours", + "label": "General Information", + "setting": "medzone_frontpage_sections", + "content": { + "accordion_title": "Why Choose Us?", + "accordion_text": "We are a full-service, non-profit community hospital, offering comprehensive medical, surgical and therapeutic services.
", + "accordion_image": "/assets/images/04_why_choose_us.jpg", + "accordion_navigation": "", + "accordion_repeater_field": "medzone_hospital_information", + "type": "accordion" + } + }, + "doctors": { + "id": "doctors", + "label": "Doctors", + "setting": "medzone_frontpage_sections", + "content": { + "doctors_title": "Meet our Doctors", + "doctors_subtitle": "Our experts are here for you every single day! We care about our patients and we
do our best to make them happy.
MedZone Hospital is dedicated to improving the quality of care for the patients who suffer a heart attack and related illnesses.
VIew our rooms", + "hospital_image_1": "/assets/images/06_explore_hospital.jpg", + "hospital_image_2": "/assets/images/06_explore_hospital.jpg", + "hospital_image_3": "/assets/images/06_explore_hospital.jpg", + "type": "hospital" + } + }, + "involvement": { + "id": "involvement", + "label": "Involvement", + "setting": "medzone_frontpage_sections", + "content": { + "involvement_image": "/assets/images/07_involvment.jpg", + "involvement_title": "True Involvement in Pacient Care", + "involvement_text": "MedZone earned the award by meeting specific criteria and standards of performance for the quick and appropriate treatment of STEMI patients by providing emergency procedures to re-establish blood flow to blocked arteries when needed.
Eligible hospitals must adhere to these measures at a set level for a designated period to receive the awards.
", + "type": "involvement" + } + }, + "testimonials": { + "id": "testimonials", + "label": "Testimonials", + "setting": "medzone_frontpage_sections", + "content": { + "testimonials_title": "Why Choose Us?", + "testimonials_navigation": "", + "testimonials_repeater_field": "medzone_testimonials", + "type": "testimonials" + } + } + } + } +} diff --git a/inc/admin/welcome-screen/img/ajax-loader.gif b/inc/libraries/welcome-screen/img/ajax-loader.gif similarity index 100% rename from inc/admin/welcome-screen/img/ajax-loader.gif rename to inc/libraries/welcome-screen/img/ajax-loader.gif diff --git a/inc/libraries/welcome-screen/img/colorlib.png b/inc/libraries/welcome-screen/img/colorlib.png new file mode 100644 index 0000000..fbd4735 Binary files /dev/null and b/inc/libraries/welcome-screen/img/colorlib.png differ diff --git a/inc/libraries/welcome-screen/js/welcome.js b/inc/libraries/welcome-screen/js/welcome.js new file mode 100644 index 0000000..a23ba26 --- /dev/null +++ b/inc/libraries/welcome-screen/js/welcome.js @@ -0,0 +1,292 @@ +var welcomeScreenFunctions = { + /** + * Import demo content + */ + importDemoContent: function() { + var self = this; + jQuery( '.epsilon-ajax-button' ).click( function( e ) { + var action = jQuery( this ).attr( 'data-action' ) ? jQuery( this ).attr( 'data-action' ) : jQuery( this ).attr( 'id' ), + container = jQuery( this ).parents( '.action-required-box' ), + checkboxes = container.find( ':checkbox' ), + importThis = { + 'plugins': [], + 'options': [] + }; + + e.preventDefault(); + + jQuery.each( checkboxes, function( k, item ) { + + if ( jQuery( item ).prop( 'checked' ) ) { + importThis[ jQuery( item ).attr( 'name' ) ].push( jQuery( item ).val() ); + } + + } ); + + self._importPlugins( importThis[ 'plugins' ] ); + + if ( importThis[ 'plugins' ].length ) { + jQuery( document ).on( 'epsilon-all-plugins-imported', function() { + self._importContent( importThis, container ); + } ); + } else { + self._importContent( importThis, container ); + } + + } ); + }, + /** + * Import the actual content + * + * @param $import + * @param action + * @param container + * @private + * + * @todo send "argument" with demo slug + */ + _importContent: function( $import, container ) { + + var needImported = 'import-all'; + + if ( $import.options.length < 1 ) { + location.reload(); + return; + } + + if ( $import.options.length < 2 ) { + needImported = $import.options[0]; + } + + jQuery.ajax( { + type: 'POST', + data: { action: 'shapely_companion_import_content', 'import' : needImported }, + dataType: 'json', + url: ajaxurl, + success: function( json ) { + if ( container.length ) { + container.html( '
+
+
+
+