set_page( array( 'menu_title' => esc_html__( 'Blue Planet', 'blue-planet' ), 'page_title' => esc_html__( 'Blue Planet', 'blue-planet' ), /* translators: %s: Version */ 'page_subtitle' => sprintf( esc_html__( 'Version: %s', 'blue-planet' ), BLUE_PLANET_VERSION ), 'menu_slug' => 'blue-planet-welcome', 'parent_page' => 'themes.php', ) ); $obj->set_admin_notice( array( 'screens' => array( 'themes', 'dashboard' ), ) ); $obj->set_quick_links( array( array( 'text' => 'Theme Details', 'url' => 'https://www.nilambar.net/2014/03/blue-planet-wordpress-theme-free.html', 'type' => 'primary', ), array( 'text' => 'Get Support', 'url' => 'https://wordpress.org/support/theme/blue-planet/#new-post', 'type' => 'secondary', ), array( 'text' => 'Leave a Review', 'url' => 'https://wordpress.org/support/theme/blue-planet/reviews/#new-post', 'type' => 'secondary', ), ) ); $obj->add_tab( array( 'id' => 'getting-started', 'title' => 'Getting Started', 'type' => 'grid', 'items' => array( array( 'title' => 'Theme Options', 'icon' => 'dashicons dashicons-admin-customizer', 'description' => 'Theme uses Customizer API for theme options. Using the Customizer you can easily customize different aspects of the theme.', 'button_text' => 'Go to Customizer', 'button_url' => wp_customize_url(), 'button_type' => 'primary', ), array( 'title' => 'Get Support', 'icon' => 'dashicons dashicons-editor-help', 'description' => 'Got theme support question or found bug or got some feedbacks? Please visit support forum in the WordPress.org directory.', 'button_text' => 'Visit Support', 'button_url' => 'https://wordpress.org/support/theme/blue-planet/#new-post', 'button_type' => 'secondary', 'is_new_tab' => true, ), array( 'title' => 'Recommended Plugins', 'icon' => 'dashicons dashicons-admin-plugins', 'description' => '
', ), array( 'title' => 'Recommended Themes', 'icon' => 'dashicons dashicons-desktop', 'description' => '', ), ), ) ); $obj->set_sidebar( array( 'render_callback' => 'blue_planet_render_welcome_page_sidebar', ) ); $obj->run(); } ); /** * Return blog posts list. * * @since 1.0.0 * * @return array Posts list. */ function blue_planet_get_blog_feed_items() { $output = array(); $rss = fetch_feed( 'https://www.nilambar.net/category/wordpress/feed' ); $maxitems = 0; $rss_items = array(); if ( ! is_wp_error( $rss ) ) { $maxitems = $rss->get_item_quantity( 5 ); $rss_items = $rss->get_items( 0, $maxitems ); } if ( ! empty( $rss_items ) ) { foreach ( $rss_items as $item ) { $feed_item = array(); $feed_item['title'] = $item->get_title(); $feed_item['url'] = $item->get_permalink(); $output[] = $feed_item; } } return $output; } /** * AJAX callback for blog posts. * * @since 1.0.0 */ function blue_planet_get_blog_posts_ajax_callback() { $output = array(); $posts = blue_planet_get_blog_feed_items(); if ( ! empty( $posts ) ) { $output = $posts; } if ( ! empty( $output ) ) { wp_send_json_success( $output, 200 ); } else { wp_send_json_error( $output, 404 ); } } add_action( 'wp_ajax_nopriv_blue_planet_nsbl_get_posts', 'blue_planet_get_blog_posts_ajax_callback' ); add_action( 'wp_ajax_blue_planet_nsbl_get_posts', 'blue_planet_get_blog_posts_ajax_callback' ); /** * Render welcome page sidebar. * * @since 1.0.0 * * @param Welcome $object Instance of Welcome class. */ function blue_planet_render_welcome_page_sidebar( $object ) { $object->render_sidebar_box( array( 'title' => 'Leave a Review', 'content' => $object->get_stars() . sprintf( 'Are you are enjoying %s? We would appreciate a review.', $object->get_name() ), 'button_text' => 'Submit Review', 'button_url' => 'https://wordpress.org/support/theme/blue-planet/reviews/#new-post', 'button_class' => 'button', ), $object ); $object->render_sidebar_box( array( 'title' => 'Recent Blog Posts', 'content' => '', ), $object ); } /** * Load admin page assets. * * @since 1.0.0 * * @param string $hook Hook name. */ function blue_planet_load_welcome_assets( $hook ) { if ( 'appearance_page_blue-planet-welcome' !== $hook ) { return; } $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'blue-planet-blog-posts', get_template_directory_uri() . '/js/blog-posts' . $min . '.js', array( 'jquery' ), BLUE_PLANET_VERSION, true ); } add_action( 'admin_enqueue_scripts', 'blue_planet_load_welcome_assets' );