<?php
/**
 * Info Admin Menu
 */
add_action( 'after_setup_theme', function() {
if ( ! class_exists( 'Soledad_Blog_LITE_Theme_Info' ) ) {
    class Soledad_Blog_LITE_Theme_Info{

        private $config;
        private $theme_name;
        private $theme_slug;
        private $theme_version;
        private $page_title;

        /**
         * Constructor.
         */
        public function __construct( $config ) {
            $this->config = $config;
            $this->prepare_class();

            /* Admin menu */
            add_action( 'admin_menu', array( $this, 'soledad_blog_lite_admin_menu' ) );

            /* Enqueue script and style for about page */
            add_action( 'admin_enqueue_scripts', array( $this, 'style_and_scripts' ) );
        }

        /**
         * Prepare and setup class properties.
         */
        public function prepare_class() {
            $theme = wp_get_theme();
            $this->theme_name    = esc_attr( $theme->get( 'Name' ) );
            $this->theme_slug    = $theme->get_template();
            $this->theme_version = $theme->get( 'Version' );
            $this->page_title    = $this->theme_name . esc_html__( ' Info', 'soledad-blog-lite' );
        }
        
        /**
         * Adding Theme Info Menu under Appearance.
         */
        function soledad_blog_lite_admin_menu() {
            if ( ! empty( $this->page_title ) ) {
                add_theme_page( $this->page_title, esc_html__( 'Soledad Blog Lite Theme', 'soledad-blog-lite' ), 'edit_theme_options', $this->theme_slug . '-info', array(
                    $this,
                    'soledad_blog_lite_theme_info_screen',
                ) );
            }
        }

        /**
         * Render the info content screen.
         */
        public function soledad_blog_lite_theme_info_screen() {

            $theme_name_config = esc_attr ( wp_get_theme()->get('Name') );
            $theme_name_config_url = strtolower( str_replace( ' ', '-', $theme_name_config ) );

            if ( ! empty( $this->config[ 'info_title' ] ) ) {
                $welcome_title = $this->config[ 'info_title' ];
            }
            if ( ! empty( $this->config[ 'info_content' ] ) ) {
                $welcome_content = $this->config[ 'info_content' ];
            }
            if ( ! empty( $this->config[ 'quick_links' ] ) ) {
                $quick_links = $this->config[ 'quick_links' ];
            }

            if (
                ! empty( $welcome_title ) ||
                ! empty( $welcome_content ) ||
                ! empty( $quick_links )
            ) {

               //echo '<div class="theme-wrap_banner"> <img src="' . esc_url( get_template_directory_uri() . "/assets/images/offer-banner.jpg" ) . '" alt="screenshot" /></div>';
               

                echo '<div class="wrap">';
                echo '<hr class="wp-header-end" />';
                echo '<div class="about-wrap info-wrap epsilon-wrap">';
                echo '<div class="header-wrap display-grid col-grid-2 align-center">';
                echo '<div class="theme-detail col">';

                if ( ! empty( $welcome_title ) ) {
                    echo '<h1>';
                    echo esc_html( $welcome_title );
                    if ( ! empty( $this->theme_version ) ) {
                        echo esc_html( $this->theme_version );
                    }
                    echo '</h1>';
                }
                if ( ! empty( $welcome_content ) ) {
                    echo '<div class="about-text">' . wp_kses_post( $welcome_content ) . '</div>';
                }

                /*quick links*/
                if( !empty( $quick_links ) && is_array( $quick_links ) ){
                    echo '<p class="quick-links">';
                    foreach ( $quick_links as $quick_key => $quick_link ) {
                        $button = 'button button-primary button-hero';
                        echo '<a href="'.esc_url( $quick_link['url'] ).'" class="button button-hero '.esc_attr( $button ).'" rel="nofollow" target="_blank">'.esc_html( $quick_link['text'] ).'</a>';
                    }
                    echo "</p>";
                }
                echo '</div>';
                echo '<div class="theme-img col">';
                echo '<a href="' . esc_url( 'https://www.templatehouse.net/themes/soledad-optimized-personal-blog-wordpress-theme-free/' ).'" rel="nofollow" target="_blank">';
                echo '<img src="' . esc_url( get_template_directory_uri() . "/screenshot.png" ) . '" alt="screenshot" />';
                echo '</a>';
                echo '</div>';
                echo '</div>';
                if ( function_exists( 'soledad_blog_lite_render_pro_themes_section' ) ) {
                    soledad_blog_lite_render_pro_themes_section();
                }
                echo '</div><!--/.about-wrap-->';
                echo '</div><!--/.wrap-->';
            }
        }

        /**
         * Load css and scripts for the theme info page
         */
        public function style_and_scripts() {
            wp_enqueue_style( 'soledad-blog-lite-theme-info-css', get_template_directory_uri() . '/inc/admin/info.css' );

        }
    }
}

$theme_name_config = esc_attr ( wp_get_theme()->get('Name') );
$theme_name_config_url = strtolower( str_replace( ' ', '-', $theme_name_config ) );

$config = array(

    // Main welcome title
    'info_title' => sprintf( esc_html__( 'Welcome to %s - ', 'soledad-blog-lite' ), $theme_name_config ),

    // Main welcome content
    'info_content' => sprintf( esc_html__( 'Soledad â€“ Optimized Personal Blog WordPress Theme comes with plenty of additional options, which will surely fulfill your desires. What is an all-in-one theme? Itâ€™s pretty simple. That is a theme that consists of several separate templates with thousands of extraordinary characteristics. Itâ€™s highly unlikely that you may obtain such features in common themes. The WordPress website template for blogging provides you with multiple listing variations. A smart and flexible list widget is a thing in posts editing. Now it takes a short time to change the structure of the columns and modify the style according to your demands. No limits for creating content with dragging and dropping boxes. Agreed, that post customization is one of the key points for bloggers and journalists. You need to be sure that your feed looks engaging and bright enough to draw attention. That is why the developers created a long list of possibilities and options for fast customization.', 'soledad-blog-lite' ), '<b>'.$theme_name_config.'</b>' ),


    /**
     * Quick links
     */
    'quick_links' => array(
        'theme_url'  => array(
            'text' => __( 'Download PRO Version', 'soledad-blog-lite' ),
            'url' => 'https://www.templatehouse.net/themes/soledad-optimized-personal-blog-wordpress-theme-free/'
        ),
        
        'demo_theme_url'  => array(
            'text' => __( 'Live Demo', 'soledad-blog-lite' ),
            'url' => 'https://demo.templatehouse.net/soledad/'
        ),

        'custom_theme_url'  => array(
            'text' => __( 'Need WordPress Website Design Services?', 'soledad-blog-lite' ),
            'url' => 'https://www.templatehouse.net/wordpress-website-design-services/'
        )
    ),
);

return new Soledad_Blog_LITE_Theme_Info( $config );
});