theme_name = esc_html__( 'Blogcast', 'blogcast' ); $this->version = wp_get_theme()->get( 'Version' ); $this->demofile = include get_template_directory() . '/inc/admin/assets/demos.php'; $this->blogcast_disable_admin_notices = get_theme_mod( 'blogcast_disable_admin_notices', false ); // some actions of welcome notice if( isset( $_GET['blogcast_welcome_notice_dismiss'] ) ) { update_option( 'blogcast_welcome_notice_dismiss', true ); } //Add the theme page add_action( 'admin_menu', array( $this, 'add_theme_info_menu' ) ); if( ! $this->blogcast_disable_admin_notices ) : add_action( 'admin_notices', array( $this, 'add_welcome_admin_notice' ) ); add_action( 'admin_notices', array( $this, 'add_review_admin_notice' ) ); endif; add_action( 'admin_enqueue_scripts', array( $this, 'theme_info_scripts' ) ); add_action( 'wp_ajax_blogcast_importer_plugin_action', array( $this, 'blogcast_importer_plugin_action' ) ); add_action( 'wp_ajax_blogcast_set_ajax_transient', array( $this, 'blogcast_set_ajax_transient' ) ); add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widgets' ) ); } /** * Enqueue scripts * */ function theme_info_scripts($hook) { if( ! $this->blogcast_disable_admin_notices ) : $blogcast_welcome_notice_dismiss = get_option( 'blogcast_welcome_notice_dismiss' ); if( ! $blogcast_welcome_notice_dismiss ) { wp_enqueue_style( 'blogcast-welcome-notice', get_template_directory_uri() . '/inc/admin/assets/welcome-notice.css', array(), esc_attr( $this->version ), 'all' ); } if( ! get_transient( 'blogcast_show_review_notice' ) ) : wp_enqueue_style( 'blogcast-review-notice', get_template_directory_uri() . '/inc/admin/assets/review-notice.css', array(), esc_attr( $this->version ), 'all' ); wp_enqueue_script( 'blogcast-review-notice', get_template_directory_uri() . '/inc/admin/assets/review-notice.js', array( 'jquery' ), esc_attr( $this->version ), true ); wp_localize_script( 'blogcast-review-notice', 'blogcastThemeInfoObject', array( 'ajaxUrl' => esc_url( admin_url( 'admin-ajax.php' ) ), '_wpnonce' => wp_create_nonce( 'blogcast-theme-info-nonce' ) )); endif; endif; if( $hook != "appearance_page_blogcast-info" ) { return; } wp_enqueue_style( 'blogcast-info', get_template_directory_uri() . '/inc/admin/assets/info-page.css', array(), esc_attr( $this->version ), 'all' ); wp_enqueue_script( 'blogcast-info', get_template_directory_uri() . '/inc/admin/assets/info-page.js', array( 'jquery' ), esc_attr( $this->version ), true ); wp_localize_script( 'blogcast-info', 'blogcastThemeInfoObject', array( 'ajaxUrl' => esc_url( admin_url( 'admin-ajax.php' ) ), '_wpnonce' => wp_create_nonce( 'blogcast-theme-info-nonce' ) )); } // Register admin menu for theme info function add_theme_info_menu() { $theme_info = add_theme_page( esc_html__( 'Blogcast Options', 'blogcast' ), esc_html__( 'Blogcast Options','blogcast' ), 'manage_options', 'blogcast-info', array( $this, 'info_page_callback' ) ); } /** * Theme info page callback * * renders the theme info structure */ function info_page_callback() { ?>

theme_name ). ' - ' . esc_attr( $this->version ); ?>

importer_status = $this->plugin_active_status('blaze-demo-importer/blaze-demo-importer.php'); switch( $this->importer_status ) { case 'inactive' : printf( esc_html__( 'Activate Blazethemes Demo Importer Now and Import any available demo in One Click', 'blogcast') . ' %s', '' ); break; case 'install' : printf( esc_html__( 'Install BlazeThemes Demo Importer and Import any available demo in One Click', 'blogcast') . ' %s', '' ); break; default: esc_html_e( 'All Ready for demo import!! Setup your site exactly like demo', 'blogcast' ); } ?>
theme_display_demos(); ?>
demofile) && !is_null($this->demofile) && !empty($this->demofile)) { $tags = array(); foreach ($this->demofile as $demo_slug => $demo_pack) { if (isset($demo_pack['tags']) && is_array($demo_pack['tags'])) { foreach ($demo_pack['tags'] as $key => $tag) { $tags[$key] = $tag; } } } asort($tags); if ( !empty( $tags ) ) { ?>
demofile as $demo_slug => $demo_pack) { $tags = $class = ''; if (isset($demo_pack['tags'])) { $tags = implode(' ', array_keys($demo_pack['tags'])); } $classes = $tags; $type = isset($demo_pack['type']) ? $demo_pack['type'] : 'free'; ?>

importer_status === 'active' ) { ?>
' .esc_html( $pagebuilder ). ''; } } ?>
demofile) && !is_null($this->demofile)) { foreach ($this->demofile as $demo_slug => $demo_pack) { ?>
ajax_response['status'] = true; $this->ajax_response['message'] = esc_html__( 'Demo importer plugin activated', 'blogcast' ); $this->send_ajax_response(); } else if( $_plugin_action === 'install' ) { $download_link = esc_url( 'https://downloads.wordpress.org/plugin/blaze-demo-importer.zip' ); // Include required libs for installation require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; require_once ABSPATH . 'wp-admin/includes/class-wp-ajax-upgrader-skin.php'; require_once ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php'; $skin = new WP_Ajax_Upgrader_Skin(); $upgrader = new Plugin_Upgrader($skin); $upgrader->install( $download_link ); activate_plugin( $file_path, '', false, true ); $this->ajax_response['status'] = true; $this->ajax_response['message'] = esc_html__( 'Demo importer plugin installed and activated', 'blogcast' ); $this->send_ajax_response(); } $this->ajax_response['status'] = false; $this->ajax_response['message'] = esc_html__( 'Error while trying to install or active the plugin.', 'blogcast' ); $this->send_ajax_response(); } /** * Set transient required for theme * */ function blogcast_set_ajax_transient() { set_transient( 'blogcast_show_review_notice', 'hide' ); $this->ajax_response['status'] = true; $this->ajax_response['message'] = esc_html__( 'Review notice hidden.', 'blogcast' ); $this->send_ajax_response(); } public function send_ajax_response() { $json = wp_json_encode( $this->ajax_response ); echo $json; die(); } /** * Add welcome notice to the admin dashboard * * @since 1.1.0 */ function add_welcome_admin_notice() { if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); $blogcast_welcome_notice_dismiss = get_option( 'blogcast_welcome_notice_dismiss' ); if( $blogcast_welcome_notice_dismiss ) { return; } if( isset( $_GET['page'] ) ) { if( $_GET['page'] == 'blogcast-info' ) { return; } } ?>

'; foreach( $responseBody as $item ) : ?>
  • title->rendered ); ?>
    excerpt->rendered ); ?>
  • '; ?> name = $name; $this->type = $type; $this->dismiss_url = $dismiss_url; $this->temporary_dismiss_url = $temporary_dismiss_url; $this->pricing_url = 'https://blazethemes.com/theme/blogcast-pro/'; $this->current_user_id = get_current_user_id(); // Notice markup. add_action('admin_notices', array($this, 'notice')); if ( $this->is_dismiss_notice() ) { add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) ); } $this->dismiss_notice(); $this->dismiss_notice_temporary(); } public function notice() { if ( ! $this->is_dismiss_notice() ) { $this->notice_markup(); } } // add notice scripts public function add_scripts() { wp_enqueue_style( 'blogcast-upgrade-notice', get_template_directory_uri() . '/inc/admin/assets/upgrade-notice.css', array(), '1.0.3', 'all' ); } private function is_dismiss_notice(){ return apply_filters('blogcast_' . $this->name . '_notice_dismiss', true); } public function notice_markup(){ echo ''; } /** * Hide a notice if the GET variable is set. */ public function dismiss_notice() { if (isset($_GET['blogcast_notice_dismiss']) && isset($_GET['_blogcast_upgrade_notice_dismiss_nonce'])) { // WPCS: input var ok. if (!wp_verify_nonce(wp_unslash($_GET['_blogcast_upgrade_notice_dismiss_nonce']), 'blogcast_upgrade_notice_dismiss_nonce')) { // phpcs:ignore WordPress.VIP.ValidatedSanitizedInput.InputNotSanitized wp_die(__('Action failed. Please refresh the page and retry.', 'blogcast')); // WPCS: xss ok. } if (!current_user_can('publish_posts')) { wp_die(__('Cheatin’ huh?', 'blogcast')); // WPCS: xss ok. } $dismiss_notice = sanitize_text_field(wp_unslash($_GET['blogcast_notice_dismiss'])); // Hide. if ($dismiss_notice === $_GET['blogcast_notice_dismiss']) { add_user_meta(get_current_user_id(), 'blogcast_' . $dismiss_notice . '_notice_dismiss', 'yes', true); } } } public function dismiss_notice_temporary() { if (isset($_GET['blogcast_notice_dismiss_temporary']) && isset($_GET['_blogcast_upgrade_notice_dismiss_temporary_nonce'])) { // WPCS: input var ok. if (!wp_verify_nonce(wp_unslash($_GET['_blogcast_upgrade_notice_dismiss_temporary_nonce']), 'blogcast_upgrade_notice_dismiss_temporary_nonce')) { // phpcs:ignore WordPress.VIP.ValidatedSanitizedInput.InputNotSanitized wp_die(__('Action failed. Please refresh the page and retry.', 'blogcast')); // WPCS: xss ok. } if (!current_user_can('publish_posts')) { wp_die(__('Cheatin’ huh?', 'blogcast')); // WPCS: xss ok. } $dismiss_notice = sanitize_text_field(wp_unslash($_GET['blogcast_notice_dismiss_temporary'])); // Hide. if ($dismiss_notice === $_GET['blogcast_notice_dismiss_temporary']) { add_user_meta(get_current_user_id(), 'blogcast_' . $dismiss_notice . '_notice_dismiss_temporary', 'yes', true); } } } } class Blogcast_Upgrade_Notice extends Blogcast_Notice { public function __construct() { if ( ! current_user_can( 'publish_posts' ) ) { return; } $dismiss_url = wp_nonce_url( add_query_arg( 'blogcast_notice_dismiss', 'upgrade', admin_url() ), 'blogcast_upgrade_notice_dismiss_nonce', '_blogcast_upgrade_notice_dismiss_nonce' ); $temporary_dismiss_url = wp_nonce_url( add_query_arg( 'blogcast_notice_dismiss_temporary', 'upgrade', admin_url() ), 'blogcast_upgrade_notice_dismiss_temporary_nonce', '_blogcast_upgrade_notice_dismiss_temporary_nonce' ); parent::__construct( 'upgrade', 'info', $dismiss_url, $temporary_dismiss_url ); $this->set_notice_time(); $this->set_temporary_dismiss_notice_time(); $this->set_dismiss_notice(); } private function set_notice_time() { if ( ! get_option( 'blogcast_upgrade_notice_start_time' ) ) { update_option( 'blogcast_upgrade_notice_start_time', time() ); } } private function set_temporary_dismiss_notice_time() { if ( isset( $_GET['blogcast_notice_dismiss_temporary'] ) && 'upgrade' === $_GET['blogcast_notice_dismiss_temporary'] ) { update_user_meta( $this->current_user_id, 'blogcast_upgrade_notice_dismiss_temporary_start_time', time() ); } } public function set_dismiss_notice() { /** * Do not show notice if: * * 1. It has not been 5 days since the theme is activated. * 2. If the user has ignored the message partially for 2 days. * 3. Dismiss always if clicked on 'Dismiss' button. */ if ( get_option( 'blogcast_upgrade_notice_start_time' ) > strtotime( '-5 day' ) || get_user_meta( get_current_user_id(), 'blogcast_upgrade_notice_dismiss', true ) || get_user_meta( get_current_user_id(), 'blogcast_upgrade_notice_dismiss_temporary_start_time', true ) > strtotime( '-2 day' ) ) { add_filter( 'blogcast_upgrade_notice_dismiss', '__return_true' ); } else { add_filter( 'blogcast_upgrade_notice_dismiss', '__return_false' ); } } public function notice_markup() { ?>

    ' . esc_html( $current_user->display_name ) . '', 'Blogcast', 'BLOGCAST10', '10%' ); ?>