theme_name = $theme->get( 'Name' ); $this->theme_version = $theme->get( 'Version' ); $this->theme_slug = $theme->get_template(); $this->page_slug = $this->theme_slug . '-dashboard'; $this->review_url = 'https://wordpress.org/support/theme/' . $this->theme_slug . '/reviews/?rate=5#new-post'; $template_link = add_query_arg( array( 'page' => $this->page_slug, 'section' => 'starter-templates', ), admin_url( 'themes.php' ) ); $this->redirect_template_url = $template_link; // Define Tabs Sections. $this->tab_sections = array( 'getting-started' => __( 'Getting Started', 'blogbyte' ), 'recommended-plugins' => __( 'Recommended Plugins', 'blogbyte' ), 'starter-templates' => __( 'Starter Templates', 'blogbyte' ), 'shortcodes' => __( 'Shortcodes', 'blogbyte' ), 'free-vs-pro' => __( 'Free vs Pro', 'blogbyte' ), ); // List of Plugins used on starter setup. $this->starter_template_plugins = array( array( 'name' => __( 'One Click Demo Import', 'blogbyte' ), 'desc' => __( 'Import your content, widgets and theme settings with one click.', 'blogbyte' ), 'slug' => 'one-click-demo-import', 'path' => 'one-click-demo-import/one-click-demo-import.php', 'status' => self::get_plugin_status( 'one-click-demo-import/one-click-demo-import.php' ), 'icon' => 'https://ps.w.org/one-click-demo-import/assets/icon-256x256.png', ), array( 'name' => __( 'Unfoldwp Import Companion', 'blogbyte' ), 'desc' => __( 'Awesome starter templates for themes made by UnfoldWP.', 'blogbyte' ), 'slug' => 'unfoldwp-import-companion', 'path' => 'unfoldwp-import-companion/unfoldwp-import-companion.php', 'status' => self::get_plugin_status( 'unfoldwp-import-companion/unfoldwp-import-companion.php' ), 'icon' => 'https://ps.w.org/unfoldwp-import-companion/assets/icon-256x256.png', ), ); // And any extra list of Recommended Plugins. $this->recommended_plugins = array_merge( $this->starter_template_plugins, array( array( 'name' => __( 'MailChimp for WordPress', 'blogbyte' ), 'desc' => __( 'Adds various highly effective sign-up methods to your site.', 'blogbyte' ), 'slug' => 'mailchimp-for-wp', 'path' => 'mailchimp-for-wp/mailchimp-for-wp.php', 'status' => self::get_plugin_status( 'mailchimp-for-wp/mailchimp-for-wp.php' ), 'icon' => 'https://ps.w.org/mailchimp-for-wp/assets/icon-256x256.png', ), array( 'name' => __( 'WPForms Lite', 'blogbyte' ), 'desc' => __( 'Beginner friendly WordPress contact form plugin.', 'blogbyte' ), 'slug' => 'wpforms-lite', 'path' => 'wpforms-lite/wpforms.php', 'status' => self::get_plugin_status( 'wpforms-lite/wpforms.php' ), 'icon' => 'https://ps.w.org/wpforms-lite/assets/icon-256x256.png', ), array( 'name' => __( 'Regenerate Thumbnails', 'blogbyte' ), 'desc' => __( 'Regenerate the thumbnails for image uploads. Useful when images are not generating on proper size on frontend.', 'blogbyte' ), 'slug' => 'regenerate-thumbnails', 'path' => 'regenerate-thumbnails/regenerate-thumbnails.php', 'status' => self::get_plugin_status( 'regenerate-thumbnails/regenerate-thumbnails.php' ), 'icon' => 'https://ps.w.org/regenerate-thumbnails/assets/icon-128x128.png', ), array( 'name' => __( 'Social Feed Gallery', 'blogbyte' ), 'desc' => __( 'User-friendly Instagram plugin for displaying your Instagram feed on your site.', 'blogbyte' ), 'slug' => 'insta-gallery', 'path' => 'insta-gallery/insta-gallery.php', 'status' => self::get_plugin_status( 'insta-gallery/insta-gallery.php' ), 'icon' => 'https://ps.w.org/insta-gallery/assets/icon-256x256.jpg', ), ) ); $this->errors = array( 'permission' => __( 'Sorry, you do not have permission to perform this action.', 'blogbyte' ), 'nonce' => __( 'Could not verifry the nonce.', 'blogbyte' ), 'default' => __( 'Oops! something went wrong.', 'blogbyte' ), 'invalid' => __( 'Not found!', 'blogbyte' ), ); if ( current_user_can( 'manage_options' ) ) { // Create admin notices. add_action( 'admin_notices', array( $this, 'display_admin_notice' ), 99 ); // Create a settings page. add_action( 'admin_menu', array( $this, 'add_menu' ) ); add_action( 'admin_bar_menu', array( $this, 'add_bar_menu' ), 999 ); } add_action( 'admin_init', array( $this, 'init_reminder' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'wp_ajax_blogbyte_dismiss_notice', array( $this, 'dismiss_notice' ) ); add_action( 'wp_ajax_blogbyte_install_plugin', 'wp_ajax_install_plugin' ); add_action( 'wp_ajax_blogbyte_activate_plugin', array( $this, 'activate_plugin' ) ); add_action( 'switch_theme', array( $this, 'reset_notices' ) ); add_action( 'after_switch_theme', array( $this, 'reset_notices' ) ); } /** * Update the reminder time. * * @since 1.0.0 */ public function init_reminder() { if ( ! get_option( 'blogbyte_reminder_time' ) ) { update_option( 'blogbyte_reminder_time', time() + 14 * DAY_IN_SECONDS ); } } /** * Delete the saved options. * * @since 1.0.0 */ public function reset_notices() { delete_option( 'blogbyte_reminder_time' ); delete_option( 'blogbyte_dismissed_notices' ); } /** * Generate proper data for starter plugin installation. * * @since 1.0.0 */ public function starter_template_button() { $plugins_active = true; $btn_html = ''; $data = array(); if ( $this->starter_template_plugins && is_array( $this->starter_template_plugins ) ) : foreach ( $this->starter_template_plugins as $plugin_data ) : if ( 'activated' === $plugin_data['status'] ) : $data_action = ''; else : $plugins_active = false; if ( 'install' === $plugin_data['status'] ) { $data_action = 'blogbyte_install_plugin'; } else { $data_action = 'blogbyte_activate_plugin'; } endif; $data_slug = $plugin_data['slug']; $data_path = $plugin_data['path']; $btn_html .= "
"; endforeach; endif; $data['plugins_active'] = $plugins_active; $data['btn_html'] = $btn_html; return $data; } /** * Dislpay admin notices. * * @since 1.0.0 */ public function display_admin_notice() { if ( $this->can_display_notice() && ! $this->is_dismissed( 'welcome' ) ) { $this->display_welcome_notice(); } $reminder_time = get_option( 'blogbyte_reminder_time' ); if ( $this->can_display_notice() && ! $this->is_dismissed( 'review' ) && ! empty( $reminder_time ) && time() > $reminder_time ) { $this->display_review_notice(); } } /** * Display welcome notice. * * @since 1.0.0 */ public function display_welcome_notice() { $user = wp_get_current_user(); $btn_data = $this->starter_template_button(); ?>