ID ); update_option( 'show_on_front', 'page' ); // Set the blog page $blog = get_page_by_title( 'Blog' ); update_option( 'page_for_posts', $blog->ID ); wp_redirect( self_admin_url( 'themes.php?page=bumbeelbee-welcome&tab=' . $active_tab ) ); } } } /** * Creates the dashboard page * * @see add_theme_page() * @since 1.8.2.4 */ public function bumbeelbee_welcome_register_menu() { $action_count = $this->count_actions(); $title = $action_count > 0 ? __( 'About bumbeelbee', 'bumbeelbee' ) . '' . esc_html( $action_count ) . '' : __( 'About bumbeelbee', 'bumbeelbee' ); add_theme_page( __( 'About bumbeelbee', 'bumbeelbee' ), $title, 'edit_theme_options', 'bumbeelbee-welcome', array( $this, 'bumbeelbee_welcome_screen' ) ); } /** * Adds an admin notice upon successful activation. * */ public function bumbeelbee_activation_admin_notice() { global $pagenow; if ( is_admin() && ( 'themes.php' == $pagenow ) && isset( $_GET['activated'] ) ) { add_action( 'admin_notices', array( $this, 'bumbeelbee_welcome_admin_notice' ), 99 ); } } /** * Display an admin notice linking to the welcome screen * */ public function bumbeelbee_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' => __( 'Hooray! There are no required actions for you right now.', 'bumbeelbee' ) ) ); } /** * Load scripts for customizer page * */ public function bumbeelbee_welcome_scripts_for_customizer() { wp_enqueue_style( 'bumbeelbee-welcome-screen-customizer', get_template_directory_uri() . '/include/library/welcome-screen/assets/css/welcome_customizer.css' ); wp_enqueue_script( 'bumbeelbee-welcome-screen-customizer', get_template_directory_uri() . '/include/library/welcome-screen/assets/js/welcome_customizer.js', array( 'jquery' ), '20120206', true ); wp_localize_script( 'bumbeelbee-welcome-screen-customizer', 'bumbeelbeeWelcomeScreenCustomizerObject', array( 'nr_actions_required' => absint( $this->count_actions() ), 'aboutpage' => esc_url( admin_url( 'themes.php?page=bumbeelbee-welcome&tab=recommended_actions' ) ), 'customizerpage' => esc_url( admin_url( 'customize.php#recommended_actions' ) ), 'themeinfo' => __( 'View Theme Info', 'bumbeelbee' ), ) ); } /** * Dismiss required actions * * @since 1.8.2.4 */ public function bumbeelbee_dismiss_required_action_callback() { global $bumbeelbee_required_actions; $action_id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 0; echo $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( 'bumbeelbee_show_required_actions' ) ): $bumbeelbee_show_required_actions = get_option( 'bumbeelbee_show_required_actions' ); switch ( $_GET['todo'] ) { case 'add'; $bumbeelbee_show_required_actions[ $action_id ] = true; break; case 'dismiss'; $bumbeelbee_show_required_actions[ $action_id ] = false; break; } update_option( 'bumbeelbee_show_required_actions', $bumbeelbee_show_required_actions ); /* create the new option,with false for the specified id */ else: $bumbeelbee_show_required_actions_new = array(); if ( ! empty( $bumbeelbee_required_actions ) ): foreach ( $bumbeelbee_required_actions as $bumbeelbee_required_action ): if ( $bumbeelbee_required_action['id'] == $action_id ): $bumbeelbee_show_required_actions_new[ $bumbeelbee_required_action['id'] ] = false; else: $bumbeelbee_show_required_actions_new[ $bumbeelbee_required_action['id'] ] = true; endif; endforeach; update_option( 'bumbeelbee_show_required_actions', $bumbeelbee_show_required_actions_new ); endif; endif; endif; die(); // this is required to return a proper result } /** * */ public function count_actions() { global $bumbeelbee_required_actions; $bumbeelbee_show_required_actions = get_option( 'bumbeelbee_show_required_actions' ); if ( ! $bumbeelbee_show_required_actions ) { $bumbeelbee_show_required_actions = array(); } $i = 0; foreach ( $bumbeelbee_required_actions as $action ) { $true = false; $dismissed = false; if ( ! $action['check'] ) { $true = true; } if ( ! empty( $bumbeelbee_show_required_actions ) && isset( $bumbeelbee_show_required_actions[ $action['id'] ] ) && ! $bumbeelbee_show_required_actions[ $action['id'] ] ) { $true = false; } if ( $true ) { $i ++; } } return $i; } /** * @param $slug * * @return array|mixed|object|WP_Error */ public function call_plugin_api( $slug ) { include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); if ( false === ( $call_api = get_transient( 'bumbeelbee_plugin_information_transient_' . $slug ) ) ) { $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( 'bumbeelbee_plugin_information_transient_' . $slug, $call_api, 30 * MINUTE_IN_SECONDS ); } return $call_api; } /** * @param $slug * * @return array */ public function check_active( $slug, $file ) { $plugin_resource = $slug . '/' . $file; if ( file_exists( ABSPATH . 'wp-content/plugins/' . $plugin_resource ) ) { include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); // var_dump( $plugin_resource); $needs = is_plugin_active( $plugin_resource ) ? 'deactivate' : 'activate'; return array( 'status' => is_plugin_active( $plugin_resource ), 'needs' => $needs ); } return array( 'status' => false, 'needs' => 'install' ); } /** * @param $arr * * @return mixed */ 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; } /** * @param $state * @param $slug * * @return string */ public function create_action_link( $state, $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( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'deactivate-plugin_' . $slug . '/' . $slug . '.php' ), ), network_admin_url( 'plugins.php' ) ); break; case 'activate': return add_query_arg( array( 'action' => 'activate', 'plugin' => rawurlencode( $slug . '/' . $slug . '.php' ), 'plugin_status' => 'all', 'paged' => '1', '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $slug . '/' . $slug . '.php' ), ), network_admin_url( 'plugins.php' ) ); break; } } /** * Welcome screen content * * @since 1.8.2.4 */ public function bumbeelbee_welcome_screen() { require_once( ABSPATH . 'wp-load.php' ); require_once( ABSPATH . 'wp-admin/admin.php' ); require_once( ABSPATH . 'wp-admin/admin-header.php' ); $bumbeelbee = wp_get_theme(); $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'getting_started'; $action_count = $this->count_actions(); ?>