<?php

if(!defined('ABSPATH'))
    exit;

class SyrusActions {

    public function initialize() {

        $class_methods = get_class_methods($this);

        foreach($class_methods as $method) {
            $priority_default = true;

            if(substr($method,0,6) != "action") 
                continue;
            
            $hook = str_replace('action_','',$method);
            
            $method_obj = new ReflectionMethod($this,$method);
            $parameters = $method_obj->getParameters();

            $priority = 10;

            if(count($parameters) > 0 && $parameters[count($parameters) - 1]->getName() === "priority") {
                $priority = $parameters[count($parameters) - 1]->getDefaultValue();
                $priority_default = false;
            }

            $params_count = count($parameters) > 0 ? count($parameters) : 1;

            add_action($hook,[$this,$method],$priority,$params_count);
        }

        $this->initCustomActions();
    }

    private function initCustomActions() {
        add_action('home-content',[$this,'custom_home_content']);
        add_action('single-post-content',[$this,'custom_single_post_content']);
        add_action('single-page-content',[$this,'custom_single_page_content']);
        add_action('error-404',[$this,'custom_error_404']);
        add_action('related-posts',[$this,'custom_related_posts']);
        add_action('widgets_init',[$this,'widgets_init']);
        add_action('admin_menu',[$this,'after_admin_menu'],99);
        add_action('syrus-whatsapp-chat', [$this, 'syrus_whatsapp_chat']);
    }

    /**
     * 
     * Registered actions
     * 
     */
    public function action_init() {
        $this->initAssetsHandler();
        $this->register_custom_menus();
        $this->add_theme_supports();
    }

    public function action_wp_enqueue_scripts() {
        global $syrusAssetsHandler;
        $syrusAssetsHandler->enqueue_css();
        $syrusAssetsHandler->enqueue_js();
    }

    public function action_customize_controls_enqueue_scripts() {
        global $syrusAssetsHandler;
        $syrusAssetsHandler->enqueue_customizer_js();
    }

    public function action_admin_menu() {
        global $syrus;
        global $syrusFilters;

        $page_title = "Syrus Theme Page";
        $menu_title = "Syrus";
        $capability = "manage_options";
        $menu_slug  = "syrus-theme-page";
        $callback = [$this,"menu_general_page"];
        $position = 1;
        $icon = $syrus->get_img_dir('syrus-logo-cropped-16x16.png');
      
        add_menu_page($page_title,$menu_title,$capability,$menu_slug,$callback,$icon,$position);

        if(!is_plugin_active("syrus-ai/syrus-ai.php"))
            add_submenu_page(
                $menu_slug,
                "AI Support",
                "AI Support",
                "manage_options",
                "syrus-theme-ai-page",
                [$this,"menu_general_page"],
                2
            );

        if(!is_plugin_active("syrus-tools/syrus-tools.php"))
            add_submenu_page(
              $menu_slug,
              "Tools",
              "Tools",
              "manage_options",
              "syrus-theme-tools-page",
              [$this,"menu_general_page"],
              3
          );

    }
    
    public function action_admin_enqueue_scripts() {
        global $syrusAssetsHandler;
        $syrusAssetsHandler->admin_enqueue_css();
        $syrusAssetsHandler->admin_enqueue_js();
    }

    public function widgets_init() {
        global $syrusWidgets;
        $syrusWidgets = new SyrusWidgets();
        $syrusWidgets->initialize();

        register_sidebar([
          'id'            => 'primary-sidebar',
          'name'          => __('Sidebar principale','syrus'),
          'description'   => __("Questa sarà la sidebar principale che apparirà sulla destra",'syrus'),
          'before_widget' => '<div id="%1$s" class="widget %2$s">',
          'after_widget'  => '</div>',
          'before_title'  => '<h2 class="widget-title">',
          'after_title'   => '</h2>',
        ]);
    }

    public function action_template_redirect() {
        global $syrus;

        $uri = $_SERVER['REQUEST_URI'];

        switch($uri){
            case "/ads.txt":
                $syrus->show_virtual_ads_txt();
                exit;
                break;
            case "/wp-admin/export.php":
                print_r($_GET);
    
                if(count($_GET) > 0) {
                    exit;
                }

                break;
        }
    
        return true;
    }

    public function action_after_setup_theme() {

    }

    public function action_customize_register($wp_customize) {
        global $syrusCustomizer;
        $syrusCustomizer = new SyrusCustomizer();
        $syrusCustomizer->initialize($wp_customize);
    }

    public function action_admin_notices() {
        if(get_option('syrus_theme_notice_dismiss') == 1)
            return "";
    
      $required_plugins = [
        [
          'name' => "Content Security Policy Manager",
          'shortname' => "CSP Manager",
          'download_link' => "//wordpress.org/plugins/csp-manager/",
          'required_file' => "csp-manager/csp-manager.php",
        ],
        [
          'name' => "Head, Footer and Post Injections",
          'shortname' => "Head, Footer and Post Injections",
          'download_link' => "//wordpress.org/plugins/header-footer/",
          'required_file' => "header-footer/plugin.php",
        ],
        [
          'name' => "Yoast SEO",
          'shortname' => "Yoast SEO",
          'download_link' => "//wordpress.org/plugins/wordpress-seo/",
          'required_file' => "wordpress-seo/wp-seo.php" 
        ],
        [
          'name' => "Site Kit by Google – Analytics, Search Console, AdSense, Speed",
          'shortname' => "Site Kit by Google",
          'download_link' => "//wordpress.org/plugins/google-site-kit/",
          'required_file' => "google-site-kit/google-site-kit.php"
        ],
        [
          'name' => "Jetpack: sicurezza, backup, velocità e crescita di WP",
          'shortname' => "Jetpack",
          'download_link' => "//wordpress.org/plugins/jetpack/",
          'required_file' => "jetpack/jetpack.php"
        ],
        [
          'name' => "Instant Images – One Click Unsplash, Pixabay and Pexels Uploads",
          'shortname' => "Instant Images",
          'download_link' => "//wordpress.org/plugins/instant-images/",
          'required_file' => "instant-images/instant-images.php"
        ],
        [
          'name' => "Scheduled Post Trigger",
          'shortname' => "Scheduled Post Trigger",
          'download_link' => "//wordpress.org/plugins/scheduled-post-trigger/",
          'required_file' => "scheduled-post-trigger/scheduled-post-trigger.php"
        ],
        [
          'name' => "IndexNow Plugin",
          'shortname' => "IndexNow",
          'download_link' => "//wordpress.org/plugins/indexnow/",
          'required_file' => "indexnow/indexnow-url-submission.php"
        ],
      ];
    
      $testo = '<div data-dismissible="syrus-theme-notice" class="notice notice-warning syrus-theme-notice is-dismissible">
                  <h6 style="margin-top:.5em">Plugin consigliati per il corretto funzionamento del tema:</h6>
      ';
    
      $i = 0;
    
      foreach($required_plugins as $plugin){
        if(is_plugin_active($plugin['required_file']))
          continue;
    
        $testo .= '<p><a href="'.$plugin['download_link'].'" target="_blank"><b>'.$plugin['shortname'].'</b> ('.$plugin['name'].')</a></p>';
        $i++;
      }
    
      $testo .= '<form action="'. admin_url('admin-post.php') .'" method="POST"><input type="hidden" name="action" value="dismiss_notice_syrus"><button class="btn-not-show-again">'."Dont'show again!".'</button></form>';
      $testo .= '</div>';
    
      if($i > 0)
        echo $testo;
    
    
      return true;
    }

    public function action_add_meta_boxes($post_type, $post, $priority = 10) {
      global $syrus, $syrusAI, $syrusDeepL;

      if(current_user_can('edit_others_posts') && !$syrus->is_ai_plugin_active())
        $syrusAI->aggiungi_metabox_generatore_contenuto_post();

      if(current_user_can('edit_posts') && $post_type === 'post')
        $this->add_metabox_content_injection_post();

      if(current_user_can('edit_posts') && $post_type === 'post' && isset($syrusDeepL) && SyrusDeepL::isConfigured())
        $this->add_metabox_deepl_translator();

    }


    public function action_post_submitbox_misc_actions($post) {

        $errori_seo = get_post_meta($post->ID,'syrus_theme_errori_seo',true);

        if(!$errori_seo)
            return true;
        ?>
      
        <div class="misc-pub-section misc-pub-errori-seo">
            <u><?php _e("Found SEO errors",'syrus') ?>:</u>
            <ul class="ps-2">
            <?php foreach(explode(',',$errori_seo) as $i => $errore) { ?>
                <li>
                  <?php
                   switch($errore) {
                    case 'tag-h1-presente':
                      echo ($i + 1).") <b>".__("H1 tag must not be present",'syrus')."</b>";
                      break;
                    case 'tag-h2-non-presente':
                      echo ($i + 1).") <b>".__("There must be at least 1 H2 tag",'syrus')."</b>";
                      break;
                    case 'tag-h3-non-presente':
                      echo ($i + 1).") <b>".__("There must be at least 1 H3 tag",'syrus')."</b>";
                      break;
                    case 'tag-strong-non-presente':
                      echo ($i + 1).") <b>".__("There must be at least 2 strong tags",'syrus')."</b>";
                      break;
                    case 'tag-strong-presente-piu-di-8':
                      echo ($i + 1).") <b>".__("There must be at most 8 strong tags",'syrus')."</b>";
                      break;
                    case 'tag-p-non-presente':
                      echo ($i + 1).") <b>".__("There must be at least 3 paragraphs",'syrus')."</b>";
                      break;
                    case 'tag-h2-uguale-al-titolo':
                      echo ($i + 1).") <b>".__("The text where there are H2 tags cannot be the same as the title",'syrus')."</b>";
                      break;
                    case 'tag-h2-e-h3-duplicato':
                      echo ($i + 1).") <b>".__("The text where there are H3 tags cannot be the same as the text in which there are H2 tags",'syrus')."</b>";
                      break;
                    case 'min-500-parole':
                      echo ($i + 1).") <b>".__("Must have at least of 500 words",'syrus')."</b>";
                      break;
                    case 'min-2-link-interni':
                      echo ($i + 1).") <b>".__("Must have at least of 2 internal links",'syrus')."</b>";
                      break;
                    case 'max-1-link-esterno':
                      echo ($i + 1).") <b>".__("Must have at most 1 external link",'syrus')."</b>";
                      break;
                    case 'max-5-words-min-3-words-per-link':
                      echo ($i + 1).") <b>".__("Each link inserted must have a minimum of 3 words and a maximum of 5",'syrus')."</b>";
                      break;
                    case 'immagine-in-evidenza-non-presente':
                      echo ($i + 1).") <b>".__("The post must have a thumbnail",'syrus')."</b>";
                      break;
                   }
      
                  ?>
                </li>
            <?php } ?>
            </ul>
            <i><?php _e("It will not be possible to make the post public until the errors are resolved!",'syrus') ?></i>
        </div>
    <?php } 


    public function action_rest_api_init() {
        global $syrusRestApi;
        $syrusRestApi = new SyrusRestApi();
        $syrusRestApi->initialize();
    }

    public function action_save_post_post($post_id, $post, $priority = 90) {
        global $syrus;
        $errori_trovati = [];
        $hide_post = false;

        // Content inejctions preferences
        $syrus_options_ads = isset($_POST['syrus_theme_options_ads']) ? array_map('sanitize_text_field', (array) $_POST['syrus_theme_options_ads']) : [];
        update_post_meta($post_id, 'syrus_theme_options_ads', serialize($syrus_options_ads));

        update_post_meta($post_id,'syrus_theme_errori_seo',null);
      
        if(current_user_can('manage_options'))
          return true;
        
        if($post->post_status != "publish" && $post->post_status != "draft")
          return true;
      
        $text = mb_convert_encoding($post->post_content, 'HTML-ENTITIES', 'UTF-8');
        $html = new DOMDocument();
        @$html->loadHTML('<div>'.$text.'</div>', LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
      
        $strong_elements = $html->getElementsByTagName('strong');
        $h1_elements = $html->getElementsByTagName('h1');
        $h2_elements = $html->getElementsByTagName('h2');
        $h3_elements = $html->getElementsByTagName('h3');
        $p_elements = $html->getElementsByTagName('p');
        $a_elements = $html->getElementsByTagName('a');
      
        if($h1_elements->length > 0){
          $errori_trovati[] = "tag-h1-presente";
          $hide_post = true;
        }
      
        if($h2_elements->length < 1){
          $errori_trovati[] = "tag-h2-non-presente";
          $hide_post = true;
        }
      
        if($h3_elements->length < 1){
          $errori_trovati[] = "tag-h3-non-presente";
          $hide_post = true;
        }
      
        if($strong_elements->length < 2) {
          $errori_trovati[] = "tag-strong-non-presente";
          $hide_post = true;
        }
      
        if($strong_elements->length > 8) {
          $errori_trovati[] = "tag-strong-presente-piu-di-8";
          $hide_post = true;
        }
      
        if($p_elements->length < 3) {
          $errori_trovati[] = "tag-p-non-presente";
          $hide_post = true;
        }
      
        $testi_h2 = [];
      
        foreach($h2_elements as $h2tag) {
          $testi_h2[] = strtolower($h2tag->nodeValue);
        }
      
        if(in_array(strtolower($post->post_title),$testi_h2)) {
          $errori_trovati[] = "tag-h2-uguale-al-titolo";
          $hide_post = true;
        }
      
        $testi_h3 = [];
      
        foreach($h3_elements as $h3tag) {
          $testi_h3[] = strtolower($h3tag->nodeValue);
        }
      
        $alert_h3_h2 = false;
      
        foreach($testi_h2 as $th2) {
          if(in_array($th2,$testi_h3))
            $alert_h3_h2 = true;
        }
      
        if($alert_h3_h2) {
          $errori_trovati[] = "tag-h2-e-h3-duplicato";
          $hide_post = true;
        }
      
        $clean_content = trim(strip_tags($post->post_content));
        $parole = count(explode(" ", $clean_content));
      
        if($parole < 501) {
          $errori_trovati[] = "min-500-parole";
          $hide_post = true;
        }
      
        $link_interni = 0;
        $link_esterni = 0;
        $link_non_validi = 0;
      
        foreach($a_elements as $a_tag) {
          $href = $a_tag->getAttribute('href');
          $testo = $a_tag->nodeValue; 
          $parole_testo = explode(' ',$testo);
      
          if(count($parole_testo) < 3 || count($parole_testo) > 5)
            $link_non_validi++;
      
          // se non contiene http/https allora do per scontanto che sia link interno
          if(strpos($href,'http://') === false && strpos($href,'https://') === false) {
            $link_interni++;
            continue;
          }
      
          if(strpos($href,home_url()) !== false) {
            $link_interni++;
            continue;
          }
      
          $link_esterni++;
        }
      
        if($link_interni < 2) {
          $errori_trovati[] = "min-2-link-interni";
          $hide_post = true;
        }
      
        if($link_esterni > 1) {
          $errori_trovati[] = "max-1-link-esterno";
          $hide_post = true;
        }
      
        if($link_non_validi > 0) {
          $errori_trovati[] = "max-5-words-min-3-words-per-link";
          $hide_post = true;
        }
      
        if(!has_post_thumbnail($post_id)) {
          $errori_trovati[] = "immagine-in-evidenza-non-presente";
          $hide_post = true;
        }
      
        $_errori_trovati = [];
        $controlli_seo_abilitati = explode(',',$syrus->get_option("generali","controlli_seo"));
      
        foreach($errori_trovati as $err) {
          if(in_array($err,$controlli_seo_abilitati))
            $_errori_trovati[] = $err;
        }
      
        $errori_trovati = $_errori_trovati;
      
        if($hide_post && count($errori_trovati) > 0) {
          wp_update_post([
            'ID' => $post_id,
            'post_status' => "pending"
          ]);
        }

        update_post_meta($post_id,'syrus_theme_errori_seo',implode(',',$errori_trovati));
    }

    public function action_admin_bar_menu(WP_Admin_Bar $admin_bar, $priority = 100) {
      if(!current_user_can('manage_options'))
        return;

      global $syrus;

      $admin_bar->add_menu([
        'id' => "syrus-theme-admin-bar",
        'parent' => null,
        'group' => null,
        'title' => '<img class="logo-syrus-admin-bar" src="' . $syrus->get_img_dir('syrus-logo-cropped-16x16.png') . '">Syrus',
        'href' => admin_url('admin.php?page=syrus-theme-page'),
        'meta' => [
          'title' => "Syrus"
        ]
      ]);
    }

    public function action_amp_post_template_footer(AMP_Post_Template $amp_template, $priority = 10) {
        $args = [];
        $current_post = get_the_ID();
        $previous_posts = get_posts([
            'post_type' => 'post',
            'posts_per_page' => 6,
            'post_status' => "publish",
            'post__not_in' => [$current_post],
            'orderby' => 'date',
            'order' => 'DESC'
        ]);


        $suffix_url = "/?amp=1";
        $amp_options = get_option('amp-options');
        $paired_url_structure = $amp_options ? $amp_options['paired_url_structure'] : 'query_var';

        switch($suffix_url) {
            case 'query_var':
              $suffix_url = "/?amp=1";
              break;
            case 'path_suffix';
              $suffix_url = "/amp/";
              break;
            case 'legacy_transitional':
              $suffix_url = "/?amp";
              break;
            case 'legacy_reader':
              $suffix_url = "/amp/";
              break;
        }

        $prevs = array_map(function($item) use($suffix_url) {
            return [
              'image' => get_the_post_thumbnail_url($item->ID),
              'title' => $item->post_title,
              'url' => get_permalink($item->ID) . $suffix_url
            ];
        }, $previous_posts);

        $args['prevs'] = $prevs;
        return get_template_part('template-parts/amp/amp','next-page',$args);
    }

    /**
     * 
     * Custom actions
     * 
     */
    public function custom_home_content() {
        global $syrus;

        $current_page = get_query_var('paged');
        $category = get_query_var('cat');
        $search = get_query_var('s');
        $posts_per_page = get_option('posts_per_page') ?: 10;
        
        if($current_page == 0)
            $current_page = 1;

        $args = array(
            'paged' => $current_page,
            'posts_per_page' => $posts_per_page,
            'ignore_sticky_posts' => 1,
            'post_type' => "post",
            'post_status' => "publish" 
        );

        if($category)
            $args['cat'] = $category;
    
        if($search)
            $args['s'] = $search;

        $the_query = new WP_Query( $args );
        set_query_var('the_query',$the_query);

        return get_template_part('template-parts/template-part','home',$args);
    } 

    public function custom_single_post_content() {
        global $post;
        setup_postdata($post);
        $tags = get_the_tag_list(); 
        return get_template_part('template-parts/template-part','single-post');
    }

    public function custom_single_page_content() {
        return get_template_part('template-parts/template-part','single-page');
    }

    public function custom_error_404() {
        return get_template_part('template-parts/template-part','error-404');
    }

    public function custom_related_posts() {
        global $post;
  
        $numero_di_post = 6;
      
        $post_tags = wp_get_post_tags(get_the_ID(),array(
          'orderby' => 'count',
          'order' => "ASC"
        ));
      
        $array_id_tags = array_map(function($item){
          return $item->term_id;
        },$post_tags);
        
        $related_posts = get_posts(array(
          'posts_per_page' => $numero_di_post,
          'exclude' => [get_the_ID()],
          'tag__in' => $array_id_tags,
          'orderby' => 'date',
          'order' => 'DESC',
          'date_query' => array(
            'before' => array(
              'year' => get_the_date('Y'),
              'month' => get_the_date('m'),
              'day' => get_the_date('d'),
              'hour' => get_the_date('H'),
              'minute' => get_the_date('i'),
            )
          )
        ));
      
        if(count($related_posts) == 0){
          $related_posts = get_posts([
            'posts_per_page' => $numero_di_post,
            'exclude' => [get_the_ID()],
            'orderby' => 'date',
            'order' => 'DESC',
            'date_query' => array(
              'before' => array(
                'year' => get_the_date('Y'),
                'month' => get_the_date('m'),
                'day' => get_the_date('d'),
                'hour' => get_the_date('H'),
                'minute' => get_the_date('i'),
              )
            )
          ]);
        }
        
        set_query_var('related_posts',$related_posts);
        return get_template_part('template-parts/template-part','related-posts');
    }

    public function after_admin_menu() {
        global $submenu;

        if(isset($submenu['syrus-theme-page'][0][0]))
          $submenu['syrus-theme-page'][0][0] = __('Settings','syrus');
    }

    public function syrus_whatsapp_chat() {
        return get_template_part('template-parts/template-part','whatsapp-chat');
    }


    /**
     * 
     * Private functions
     * 
     */
    private function initAssetsHandler() {
      global $syrusAssetsHandler;
      $syrusAssetsHandler = new SyrusAssetsHandler();
      $syrusAssetsHandler->initialize();
    }

    private function register_custom_menus() {
        global $syrus;
        $current_layout = $syrus->get_current_layout();
        
        $menus = [
          'syrus-theme-main-menu' => __('Main menu','syrus'),
          'syrus-theme-directories-menu' => __('Directories menu','syrus')
        ];

        if($current_layout == 2)
            $menus['syrus-theme-footer-menu'] = __('Footer menu','syrus');

        register_nav_menus($menus);
    }

    private function add_theme_supports() {
        add_theme_support('post-thumbnails');
        add_theme_support('title-tag');
        add_theme_support('automatic-feed-links');
        add_theme_support('yoast-seo-breadcrumbs');
        add_theme_support("wp-block-styles");
        add_theme_support("responsive-embeds"); 
        add_theme_support("html5",[ 'comment-list', 'comment-form', 'search-form', 'gallery', 'caption', 'style', 'script']); 
        add_theme_support('custom-logo');
        add_theme_support('custom-header');
        add_theme_support('custom-background');
        add_theme_support('align-wide');
        add_theme_support('woocommerce');
    }

    private function add_metabox_content_injection_post() {
        add_meta_box(
            'syrus-theme-options',
            __('Syrus Options','syrus'),
            [$this, 'render_metabox_content_injection_post'],
            'post',
            'side',
            'high'
        );
    }

    public function render_metabox_content_injection_post() {
        global $syrus;
        return include_once $syrus->get_template_parts_admin("meta-boxes/meta-box-content-injection-post");
    }

    private function add_metabox_deepl_translator() {
        add_meta_box(
            'syrus-deepl-translator',
            __('DeepL Translator','syrus'),
            [$this, 'render_metabox_deepl_translator'],
            'post',
            'side',
            'high'
        );
    }

    public function render_metabox_deepl_translator() {
        global $syrus, $syrusDeepL;
        return include_once $syrus->get_template_parts_admin("meta-boxes/meta-box-deepl-translator");
    }

    /**
     * 
     * Dashboard Menu Pages
     * 
     */
    public function menu_general_page() {
        global $syrus;

        // return include_once $syrus->get_template_parts_admin("menu-theme-general-page"); // OLD
        return include_once $syrus->get_template_parts_admin("index"); // NEW
    }

    public function tab_menu() {
        global $syrus;
        $infinite_scroll_chk = $syrus->get_option("generali","infinite_scroll");
        $infinite_scroll_home_chk = $syrus->get_option("generali","infinite_scroll_home");
        $span_replace_chk = $syrus->get_option("generali","span_replace");
        $p_cleaner_chk = $syrus->get_option("generali","p_cleaner");
        $http_cleaner_chk = $syrus->get_option("generali","http_cleaner");
        $controlli_seo_chk = explode(',',$syrus->get_option("generali","controlli_seo"));
      
        $controlli_seo_checkbox = [
          'tag-h1-presente' => "Presenza di tag H1 nel testo",
          'tag-h2-non-presente' => "Minimo un tag H2 presente nel testo",
          'tag-h3-non-presente' => "Minimo un tag H3 presente nel testo",
          'tag-h2-uguale-al-titolo' => "Tag H2 identici al titolo dell'articolo",
          'tag-h2-e-h3-duplicato' => "Tag H2 identici ai tag H3",
          'min-500-parole' => "L'articolo deve contenere almeno 500 parole",
          'immagine-in-evidenza-non-presente' => "Ogni post deve avere un'immmagine di anteprima",
        ];
      
        $chatgpt_token = $syrus->get_option('generali','chatgpt_token');
      
        include_once $syrus->get_template_parts_admin("menu-theme-page");
    }

    public function tab_ads(){
        global $syrus;

        include_once $syrus->get_template_parts_admin("menu-theme-ads-page");
      }
      
    public function tab_robots_ads_txt(){
        global $syrus;
        include_once $syrus->get_template_parts_admin("menu-theme-robots-ads-txt-page");
    }
    
    public function tab_upload_media(){
        global $wp_roles;
        global $syrus;

        $ruoli = $wp_roles->roles;
        include_once $syrus->get_template_parts_admin("menu-theme-upload-media-page");
    }

    public function tab_social(){
        global $syrus;
        $twitter_username = $syrus->get_option("social","twitter_username");
      
        if(!$twitter_username)
          $twitter_username = "";
          
        include_once $syrus->get_template_parts_admin("menu-theme-social-page");
    }

    public function tab_layout() {
      global $syrus;

      $layout = isset($_GET["layout"]) ? $_GET['layout'] : null;

      if(!$layout)
        return include_once $syrus->get_template_parts_admin("menu-theme-layout-page");

      $path = $syrus->get_template_parts_admin('layouts/customize-layout-' . $layout);

      if(!file_exists($path))
        die("File not exist");

      return include_once $path;
    }

    public function tab_syrus_ai() { ?>
        <h3 class="mx-auto mt-5 w-50 text-center">
            <?php _e('We will soon release our Syrus AI plugin for artificial intelligence support, with tons of new features','syrus') ?>
        </h3>
    <?php }
    
    public function tab_syrus_tools() { ?>
        <h3 class="mx-auto mt-5 w-50 text-center">
            <?php _e('We will soon release our Syrus Tools plugin for helping people to improve websites, with tons of new features','syrus') ?>
        </h3>
    <?php }
}
