<?php
/**
 * Handles the display of the plugin sidebar content.
 *
 * The RPGAL_Sidebar class is responsible for rendering the plugin's shortcode usage 
 * instructions and additional plugin information in the admin dashboard sidebar. 
 * It provides flexibility to control the visibility of notes, plugin info, 
 * and allows for custom CSS class inclusion for styling.
 * 
 * @package Responsive Portfolio Image Gallery 1.3 - 10 July, 2025
 * @link https://www.realwebcare.com/
 */
if (!defined('ABSPATH'))
    exit;

if (!class_exists('RPGAL_Sidebar')) {
    class RPGAL_Sidebar
    {
        private static $instance;

        private function __construct()
        {
        }

        public static function get_instances()
        {
            if (self::$instance) {
                return self::$instance;
            }

            self::$instance = new self();

            return self::$instance;
        }

        /**
         * Renders the plugin sidebar with shortcode usage and plugin information.
         *
         * @param mixed $show_promo Determines whether to display the pro version promotion. Default is true.
         * @param mixed $show_note Determines whether to display the shortcode usage instructions. Default is true.
         * @param mixed $show_info Determines whether to display the plugin information. Default is true.
         * @param mixed $class Optional. Custom CSS class for the sidebar container. Default is an empty string.
         * @return string
         */
        public function rpgal_sidebar($show_promo = true, $show_note = true, $show_info = true, $class = '')
        {
            // Initialize content
            $content = '';

            // Add class if provided
            if (!empty($class)) {
                $class = ' ' . esc_attr($class);
            }

            $content .= '<div id="rpgal-sidebar" class="postbox-container' . $class . '">';

            // Instruction section
            if ($show_note) {
                $content .= '<div id="rpgalusage-shortcode" class="rpgalusage-sidebar">
                    <h3>' . esc_html__('[/] Shortcode Usage Instruction', 'responsive-portfolio-image-gallery') . '</h3>
                    <div class="rpgal">
                        <p class="rpgal-first">' . esc_html__('To display a portfolio shortcode in a WordPress post or page, you need to access the post or page editor in the WordPress dashboard. Here\'s how:', 'responsive-portfolio-image-gallery') . '</p>
                        <ol>
                            <li>' . esc_html__('Go to Posts or Pages, depending on where you want to display the portfolio.', 'responsive-portfolio-image-gallery') . '</li>
                            <li>' . esc_html__('Either create a new post or page, or edit an existing one.', 'responsive-portfolio-image-gallery') . '</li>
                            <li>' . esc_html__('Switch to the visual editor if it\'s not already active.', 'responsive-portfolio-image-gallery') . '</li>
                            <li>' . esc_html__('Locate the spot in the post or page where you want to display the portfolio.', 'responsive-portfolio-image-gallery') . '</li>
                            <li class="rpgal-scode">
                                ' . esc_html__('Paste the following shortcode into the editor:', 'responsive-portfolio-image-gallery') . '
                                <pre><code>[rpgal-gallery]</code></pre>
                                <span class="copy-tooltip" id="rpgalTooltip">' . esc_html__('Click to Copy Shortcode!', 'responsive-portfolio-image-gallery') . '</span>
                            </li>
                            <li>' . esc_html__('Save or publish the post or page.', 'responsive-portfolio-image-gallery') . '</li>
                        </ol>
                        <p>' . esc_html__('Once you\'ve saved or published the post or page, the portfolio shortcode will be processed and the portfolio gallery will be displayed on the front end of your site.', 'responsive-portfolio-image-gallery') . '</p>
                    </div>
                </div>';
            }

            // Promotion section
            if ($show_promo) {
                $content .= '<div id="rpgalusage-features" class="rpgalusage-sidebar">' .
                    sprintf(
                        /* translators: 
                        %1s: URL for the Pro version image.
                        %2s: URL for the details of Responsive Portfolio Image Gallery Pro.
                        %3s: URL for the demo page of Responsive Portfolio Image Gallery Pro.
                        */
                        __(
                            '<div class="rpgalusage-feature-header">
                                <img src="%1$s" alt="RPGAL Pro">
                            </div>
                            <div class="rpgalusage-feature-body">
                                <h3>Responsive Portfolio Image Gallery Pro Features</h3>
                                <div class="rpgal">Pro version has been developed to present Portfolio Gallery more proficiently. Some of the most notable features are:</div>
                                <ul class="rpgalusage-list">
                                    <li>Unlimited portfolios by different categories.</li>
                                    <li>Import/Export (Backup) portfolio settings.</li>
                                    <li>Make a copy of a portfolio instantly.</li>
                                    <li>Video support for YouTube and Vimeo.</li>
                                    <li>Unique title &amp; description for each carousel images.</li>
                                    <li>Adjust expanding preview opening speed.</li>
                                    <li>Support for multiple buttons.</li>
                                    <li>Google Fonts and Font Awesome Support.</li>
                                    <li>Click <a href="%2$s" target="_blank">here</a> to learn more...</li>
                                </ul>
                                <a class="btn-demo" href="%3$s" target="_blank">View Demo</a>
                            </div>',
                            'responsive-portfolio-image-gallery'
                        ),
                        esc_url(RPGAL_PLUGIN_URL . 'assets/images/template-pro.png'),
                        esc_url('https://www.realwebcare.com/item/responsive-portfolio-image-gallery-pro/'),
                        esc_url('https://www.realwebcare.com/demo/plugins/?product_id=responsive-portfolio-gallery')
                    ) . '</div>';
            }

            // Plugin Info section
            if ($show_info) {
                $content .= '<div id="rpgalusage-info" class="rpgalusage-sidebar">' .
                    sprintf(
                        /* translators: %1$s: URL for Realwebcare website, %2$s: URL for Realwebcare Facebook page, %3$s: URL for plugin support page, %4$s: URL for plugin review page */
                        __(
                            '<h3>Plugin Info</h3>
                            <ul class="rpgalusage-list">
                                <li>Responsive Portfolio Image Gallery</li>
                                <li>Version: 1.3</li>
                                <li>Scripts: PHP + CSS + JS</li>
                                <li>Requires: WordPress 5.4+</li>
                                <li>First release: 9 August, 2016</li>
                                <li>Last Update: 10 July, 2025</li>
                                <li>By: <a href="%1$s" target="_blank">Realwebcare</a></li>
                                <li>Facebook Page: <a href="%2$s" target="_blank">Realwebcare</a></li>
                                <li>Need Help? <a href="%3$s" target="_blank">Support</a></li>
                                <li>Like it? Please leave us a <a target="_blank" href="%4$s">★★★★★</a> rating. We highly appreciate your support!</li>
                            </ul>',
                            'responsive-portfolio-image-gallery'
                        ),
                        esc_url('https://www.realwebcare.com/'),
                        esc_url('https://www.facebook.com/realwebcare'),
                        esc_url('https://wordpress.org/support/plugin/responsive-portfolio-image-gallery/'),
                        esc_url('https://wordpress.org/support/plugin/responsive-portfolio-image-gallery/reviews/?filter=5/#new-post')
                    ) . '</div>';
            }

            $content .= '</div>';

            return wp_kses_post($content);
        }
    }
}
