<?php
function magazina_admin_assets(){
wp_enqueue_script( 'magazina_customizer_admin', get_template_directory_uri() . '/inc/theme-setup/customizer-popup.js', array("jquery"), '', true  );
  wp_enqueue_style('magazina_customizer_admin', get_template_directory_uri() . '/inc/theme-setup/customizer-popup-styles.css');

}
     add_action('admin_enqueue_scripts', 'magazina_admin_assets');

class Magazina_Popup {
  function  __construct(){
             if (shortcode_exists('blogwings-companion-magazina')!=true):
                $this->active();
            endif;
    }
  function active(){
    if(!get_option( "magazina_disable_popup")):
    add_action('customize_controls_print_styles', array($this,'popup_styles'));
    add_action('customize_controls_print_footer_scripts',array(__CLASS__,'popup_message'));
    add_action( 'customize_controls_enqueue_scripts', array($this,'popup_scripts'));
    endif;
  }

    function active_plugin(){
            $plugin_slug = 'blogwings-companion';
            $active_file_name =  $plugin_slug.'/'.$plugin_slug.'.php';
            $button_class = 'install-now button button-primary button-large';

                    $button_txt = esc_html__( 'One click Setup', 'magazina' );
                    $status     = is_dir( WP_PLUGIN_DIR . '/'.$plugin_slug );

                    if ( ! $status ) {
                        $install_url = wp_nonce_url(
                            add_query_arg(
                                array(
                                    'action' => 'install-plugin',
                                    'plugin' => $plugin_slug
                                ),
                                network_admin_url( 'update.php' )
                            ),
                            'install-plugin_'.$plugin_slug
                        );

                    } else {
                        $install_url = add_query_arg(array(
                            'action' => 'activate',
                            'plugin' => rawurlencode( $active_file_name ),
                            'plugin_status' => 'all',
                            'paged' => '1',
                            '_wpnonce' => wp_create_nonce('activate-plugin_' . $active_file_name ),
                        ), network_admin_url('plugins.php'));
                        $button_class = 'activate-now button-primary button-large';
                        $button_txt = esc_html__( 'Setup Homepage', 'magazina' ); 
                      }
                      $url = esc_url($install_url);
                      $return  = "<a href='javascript:void' onclick=\"magazina_install('{$url}'); return false;\"  data-slug='".esc_attr($plugin_slug)."' class='".esc_attr( $button_class )."'>{$button_txt}</a>";

                      if(shortcode_exists('blogwings-companion-magazina')){
                        $button_txt = esc_html__( 'Homepage Activated!', 'magazina' );

                        $return  = "<a class='".esc_attr( $button_class )."' disabled>{$button_txt}</a>";
                      }
                      return $return;
    }

    function popup_message() {
       // require_once( get_parent_theme_file_path('/inc/theme-setup/customizer-popup.php') );
    } 

    function popup_styles() {
        wp_enqueue_style('magazina_customizer_popup', get_template_directory_uri() . '/inc/theme-setup/customizer-popup-styles.css');
    }

    function popup_scripts() {
        wp_enqueue_script( 'magazina_customizer_popup', get_template_directory_uri() . '/inc/theme-setup/customizer-popup.js', array("jquery"), '', true  );
    }
}


// home page setup 

function active_plugin(){
       $plugin_slug = 'blogwings-companion';
            $active_file_name =  $plugin_slug.'/'.$plugin_slug.'.php';
            $button_class = 'install-now button button-primary button-large';
      $install_url = add_query_arg(array(
                            'action' => 'activate',
                            'plugin' => rawurlencode( $active_file_name ),
                            'plugin_status' => 'all',
                            'paged' => '1',
                            '_wpnonce' => wp_create_nonce('activate-plugin_' . $active_file_name ),
                        ), network_admin_url('plugins.php'));
                        $button_class = 'activate-now button-primary button-large';
                        $button_txt = esc_html__( 'Setup Homepage', 'magazina' );
    if ( is_plugin_active( $active_file_name ) ) {
      echo false;
    }else{
      echo $install_url;

} 
        
}

add_action( 'wp_ajax_magazina_default_home', 'magazina_default_home' );
function magazina_default_home() {

 $pages = get_pages(array(
        'meta_key' => '_wp_page_template',
        'meta_value' => 'magazine-template.php'
    ));
    $post_id = isset($pages[0]->ID)?$pages[0]->ID:false;



if(empty($pages)){
      $post_id = wp_insert_post(array (
       'post_type'    => 'page',
       'post_title'   => 'Home',
       'post_content' => '',
       'post_name'    => 'magazine-home',
       'post_status'  => 'publish',
       'comment_status' => 'closed',   // if you prefer
       'ping_status'   => 'closed',      // if you prefer
       'page_template' =>'magazine-template.php', //Sets the template for the page.
    ));
  }
      if($post_id){
        update_option( 'page_on_front', $post_id );
        update_option( 'show_on_front', 'page' );
    }
 active_plugin();

    wp_die(); // this is required to terminate immediately and return a proper response
}

function magazina_customizer_disable_popup(){
      $value = intval(@$_POST['value']);
      update_option( "magazina_disable_popup", $value );
      die();
  }
add_action('wp_ajax_customizer_disable_popup', 'magazina_customizer_disable_popup');


/**
 * Add admin notice when active theme, just show one time
 *
 * @return bool|null
 */
add_action( 'admin_notices', 'magazina_admin_notice' );

function magazina_admin_notice() {
  global $current_user;
  $user_id   = $current_user->ID;
  $theme_data  = wp_get_theme();
  if ( !get_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore' ) ) {
    ?>
    <div class="notice thunk-notice">

      <h1>
        <?php
        /* translators: %1$s: theme name, %2$s theme version */
        printf( esc_html__( 'Welcome to %1$s - Version %2$s', 'magazina' ), esc_html( $theme_data->Name ), esc_html( $theme_data->Version ) );
        ?>
      </h1>
      <p>
        <?php
        /* translators: %1$s: theme name, %2$s link */
        printf( __( 'Thank You for choosing %1$s! To take full advantage of our theme, please visit to <a href="%2$s">Welcome page</a>', 'magazina' ), esc_html( $theme_data->Name ), esc_url( admin_url( 'themes.php?page=th_magazina' ) ) );
        printf( '<a href="%1$s" class="notice-dismiss dashicons dashicons-dismiss dashicons-dismiss-icon"></a>', '?' . esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore=0' );
        ?>
      </p>
      <p>
        <a href="<?php echo esc_url( admin_url( 'themes.php?page=th_magazina' ) ) ?>" class="button button-primary button-hero" style="text-decoration: none;">
          <?php
          /* translators: %s theme name */
          printf( esc_html__( 'Get started with %s', 'magazina' ), esc_html( $theme_data->Name ) )
          ?>
        </a>
      </p>
    </div>
    <?php
  }
}

add_action( 'admin_init', 'smagazina_notice_ignore' );

function smagazina_notice_ignore() {
  global $current_user;
  $theme_data  = wp_get_theme();
  $user_id   = $current_user->ID;
  /* If user clicks to ignore the notice, add that to their user meta */
  if ( isset( $_GET[ esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore' ] ) && '0' == $_GET[ esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore' ] ) {
    add_user_meta( $user_id, esc_html( $theme_data->get( 'TextDomain' ) ) . '_notice_ignore', 'true', true );
  }
}
function magazina_tab_config($theme_data){
    $config = array(
        'theme_brand' => __('Blogwings','magazina'),
        'theme_brand_url' => esc_url('https://blogwings.com','magazina' ),
        'welcome'=>sprintf(esc_html__('Welcome to Magazina - Version %1s', 'magazina'), $theme_data->get( 'Version' ) ),
        'welcome_desc' => esc_html__( 'Magazina is a powerful theme made with love for Magazine, Newspaper and Personal blog.', 'magazina' ),
        'tab_one' =>esc_html__('Get Started with Magazina', 'magazina' ),
        'tab_two' =>esc_html__( 'Recommended Actions', 'magazina' ),
        'tab_three' =>esc_html__( 'Free VS Pro', 'magazina' ),
        'tab_four' =>esc_html__( 'Demo Import', 'magazina' ),
        'tab_five' =>esc_html__( 'FREE VS PRO', 'magazina' ),


        'plugin_title' => esc_html__( 'Step 1 - Read Full Documentation', 'magazina' ),
        'plugin_link' => esc_url('https://blogwings.com/docs-cate/magazina/','magazina' ),
        'plugin_text' => esc_html__('', 'magazina'),
        'plugin_button' => esc_html__('Documentation', 'magazina'),

        'desire_title' => esc_html__( 'Step 2 - One Click Homepage Set up', 'magazina' ),
		
		    'customizer_title' => esc_html__( 'Step 3 - Import Demo Content', 'magazina' ),
        'customizer_text' =>  sprintf(esc_html__('Do you want to import demo file? This action will make your site look like theme demo (Showcased at our site).', 'magazina'), $theme_data->Name),
        'customizer_button' => sprintf( esc_html__('Import Demo', 'magazina')),

        'support_title' => esc_html__( 'Step 5 - Having trouble? Need support?', 'magazina' ),
        'support_link' => esc_url('//blogwings.com/contact-us/'),
        'support_forum' => sprintf(esc_html__('Contact Us', 'magazina'), $theme_data->get( 'Name' )),
        'doc_link' => esc_url('//blogwings.com/docs/magazina-theme/'),
        'doc_link_text' => sprintf(esc_html__('Contact Us', 'magazina'), $theme_data->get( 'Name' )),

        'support_text' => sprintf(esc_html__('If you need any help you can contact to our support team, our team is always ready to help you.', 'magazina'), $theme_data->get( 'Name' )),
        'support_button' => sprintf( esc_html__('Create a support ticket', 'magazina'), $theme_data->get( 'Name' )),
        );
    return $config;
}


if ( ! function_exists( 'magazina_admin_scripts' ) ) :
    /**
     * Enqueue scripts for admin page only: Theme info page
     */
    function magazina_admin_scripts( $hook ) {
        wp_enqueue_style( 'magazina-admin-css', get_template_directory_uri() . '/css/admin.css' );

        if ($hook === 'appearance_page_th_magazina'  ) {
            // Add recommend plugin css
            wp_enqueue_style( 'plugin-install' );
            wp_enqueue_script( 'plugin-install' );
            wp_enqueue_script( 'updates' );
            add_thickbox();
        }
    }
endif;
add_action( 'admin_enqueue_scripts', 'magazina_admin_scripts' );

function magazina_count_active_plugins() {
   $i = 3;

  $recommend_plugins = get_theme_support( 'recommend-plugins' );
    if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){

        foreach($recommend_plugins[0] as $slug=>$plugin){
                  $active_file_name = $slug . '/' . $slug . '.php';

      if (is_plugin_active( $active_file_name ) ):
           $i--;
       endif;
            
        }
    }
       return $i;
}
function magazina_tab_count(){
       $count = '';
       $number_count = magazina_count_active_plugins();
           if( $number_count >0):
           $count = "<span class='update-plugins count-".esc_attr( $number_count )."' title='".esc_attr( $number_count )."'><span class='update-count'>" . number_format_i18n($number_count) . "</span></span>";
           endif;
           return $count;
}

/**
    * Menu tab
    */
function magazina_tab() {
               $number_count = magazina_count_active_plugins();
               $menu_title = esc_html__('Get Started with magazina', 'magazina');
           if( $number_count >0):
           $count = "<span class='update-plugins count-".esc_attr( $number_count )."' title='".esc_attr( $number_count )."'><span class='update-count'>" . number_format_i18n($number_count) . "</span></span>";
               $menu_title = sprintf( esc_html__('Get Started with magazina %s', 'magazina'), $count );
           endif;


   add_theme_page( esc_html__( 'Magazina', 'magazina' ), $menu_title, 'edit_theme_options', 'th_magazina', 'magazina_tab_page');
}
add_action('admin_menu', 'magazina_tab');


function magazina_theme(){ ?>
  <div class="freeevspro-img">
    <img src="<?php echo get_template_directory_uri(); ?>/inc/theme-setup/images/free-pro.png" alt="free vs pro" />
    <p>
     <a class="button button-secondary" target="_blank" href="<?php echo esc_url('https://blogwings.com/magazina/'); ?>"><?php esc_html_e('Check Pro version for more features','magazina'); ?></a>
    </p>
  </div>
<?php }


// demo import
function magazina_demo_import(){ ?>

<div class="theme_demo">
  <div class="inner-wrp">
  <h3><?php esc_html_e( 'Step 1', 'magazina' ); ?></h3>
  <p class="about"><?php esc_html_e( 'Before importing demo content please make confirm that you have installed (Blogwings companion plugin). This will help importer to import complete demo data.', 'magazina' ); ?></p>
    <p>
    <a href="?page=th_magazina&amp;tab=actions_required" class="button button-secondary"><?php esc_html_e( 'Install Recommended Plugin', 'magazina' ); ?></a>
  </p>
</div>
</div>

<div class="theme_demo">
   <div class="inner-wrp">
  <h3><?php esc_html_e( 'Step 2', 'magazina' ); ?></h3>
    <p class="about"><?php esc_html_e( 'Click "One Click Install" button, Install the plugin and then go to the Appearance > Import Demo Data and click "Import Demo Data" button.', 'magazina' ); ?>
    </p>
    <p>
<?php if ( !class_exists('OCDI_Plugin') ) : ?>
<?php $odi_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=one-click-demo-import'), 'install-plugin_one-click-demo-import'); ?>
            <p>
              <a target="_blank" class="install-now button importer-install" href="<?php echo esc_url( $odi_url ); ?>"><?php esc_html_e( 'One Click Install', 'magazina' ); ?></a>
              <a style="display:none;" class="button button-primary button-large importer-button" href="<?php echo admin_url( 'themes.php?page=pt-one-click-demo-import.php' ); ?>"><?php esc_html_e( 'Go to the importer', 'magazina' ); ?></a>            
            </p>
            <?php else : ?>
              <p style="color:#e45f12;font-style:italic;font-size:14px;"><?php esc_html_e( 'Plugin installed and active!', 'magazina' ); ?></p>
              <a class="button button-primary button-large" href="<?php echo admin_url( 'themes.php?page=pt-one-click-demo-import.php' ); ?>"><?php esc_html_e( 'Go to the automatic importer', 'magazina' ); ?></a>
            <?php endif;  ?>
   <img src="<?php echo get_template_directory_uri(); ?>/inc/theme-setup/images/demo-import.png" alt="free vs pro" />
  </p>
</div>
</div>
<?php }


function magazina_tab_page() {
    $theme_data = wp_get_theme();
    $theme_config = magazina_tab_config($theme_data);


    // Check for current viewing tab
    $tab = null;
    if ( isset( $_GET['tab'] ) ) {
        $tab = $_GET['tab'];
    } else {
        $tab = null;
    }

    $actions_r = magazina_get_actions_required();
    $actions = $actions_r['actions'];

    $current_action_link =  admin_url( 'themes.php?page=th_magazina&tab=actions_required' );

    $recommend_plugins = get_theme_support( 'recommend-plugins' );
    if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){
        $recommend_plugins = $recommend_plugins[0];
    } else {
        $recommend_plugins[] = array();
    }
    ?>
    <div class="wrap about-wrap theme_info_wrapper">
        <h1><?php  echo $theme_config['welcome']; ?></h1>
        <div class="about-text"><?php echo $theme_config['welcome_desc']; ?></div>
        <a target="_blank" href="<?php echo $theme_config['theme_brand_url']; ?>" class="blogwingshemes-badge wp-badge"><span><?php echo $theme_config['theme_brand']; ?></span></a>
        <h2 class="nav-tab-wrapper">
            <a href="?page=th_magazina" class="nav-tab<?php echo is_null($tab) ? ' nav-tab-active' : null; ?>"><?php  echo $theme_config['tab_one']; ?></a>
            <a href="?page=th_magazina&tab=actions_required" class="nav-tab<?php echo $tab == 'actions_required' ? ' nav-tab-active' : null; ?>"><?php echo $theme_config['tab_two'];  echo magazina_tab_count();?></a>
            <!-- <a href="?page=th_magazina&tab=theme-pro" class="nav-tab<?php echo $tab == 'theme-pro' ? ' nav-tab-active' : null; ?>"><?php echo $theme_config['tab_three']; ?></span></a> -->
            <a href="?page=th_magazina&tab=demo-import" class="nav-tab<?php echo $tab == 'demo-import' ? ' nav-tab-active' : null; ?>"><?php echo $theme_config['tab_four']; ?></span></a>
            <a href="?page=th_magazina&tab=free-pro" class="nav-tab<?php echo $tab == 'free-pro' ? ' nav-tab-active' : null; ?>"><?php echo $theme_config['tab_five']; ?></span></a>
        </h2>
        <?php if ( is_null( $tab ) ) { 
          ?>
            <div class="theme_info info-tab-content">
                <div class="theme_info_column clearfix">
                    <div class="theme_info_left">
                    <div class="theme_link one"><div class="inner-wrp">
                            <h3><?php echo $theme_config['plugin_title']; ?></h3>
                            <p class="about"><ul>
                                <li><p>
                                <?php echo $theme_config['plugin_text'];?></p></li></ul></p>
                            <p>
                                <a target="_blank" href="<?php echo esc_url($theme_config['plugin_link'] ); ?>" class="button button-secondary"><?php echo $theme_config['plugin_button']; ?></a>
                            </p>
                          </div>
                        </div>
                          <div class="theme_link two"><div class="inner-wrp">
                            <h3><?php echo $theme_config['desire_title']; ?></h3>
                            <h4><?php esc_html_e('Automatic process:','magazina');?></h4>
                              <p><?php esc_html_e('Click to set up homepage. This action will install "Blogwings companion" plugin ( Highly recommend to install this plugin ) and create home page with magazine template.','magazina');?></p>
                                 <a class="activate-now button-primary button-large flactvate"><?php _e('Activating homepage...','magazina'); ?></a><div class='loader'></div><strong class="flactvate-activating"> <?php _e('It may take few seconds...','magazina'); ?></strong>

                              <?php  $obj = New Magazina_Popup(); 
                                    echo $obj->active_plugin();
                              ?>
                              <h4><?php esc_html_e('Manual process:','magazina');?></h4>
                              <p><?php esc_html_e('We highly recommend to install Blogwings companion plugin. It will enable complete settings required to create Magazine site.','magazina');?>
                              </p>
                                <a target="_blank" href="<?php echo admin_url('themes.php?page=th_magazina&tab=actions_required'); ?>" class="button button-secondary"><?php echo esc_html_e('Install Plugin','magazina'); ?></a>
                              <ol>
                                <li>
                                   <p><?php esc_html_e('Go to wp Dashboard > Pages > Add new page and select Magazine Template from "Page Attributes" and Publish it.','magazina'); ?>
                                    </p>
                                </li>
                        <li><p><?php esc_html_e('Now go to the Dashboard > Settings > Reading and set newly created page as a "Static front page" and save it.
                        ','magazina')?>
                        </p>
                        
                </li>
                </ol>
                </p></div>
                 </div>

						      <div class="theme_link three"><div class="inner-wrp">
                            <h3><?php echo $theme_config['customizer_title']; ?></h3>
                            <p class="about"><?php  echo $theme_config['customizer_text']; ?>
                            </p>
                            <a href="<?php echo admin_url( 'themes.php?page=th_magazina&tab=demo-import' )?>" class="button button-secondary"><?php echo $theme_config['customizer_button']; ?></a>
                        </div>
                      </div>
                        <div class="theme_link four"><div class="inner-wrp">
                            <h3><?php esc_html_e('Step 4 - Go to Customizer','magazina');?></h3>
                            <p><?php esc_html_e('Using the WordPress Customizer you can easily customize every aspect of the theme.','magazina'); ?>
                           </p>
                             <p>
                              <a target="_blank" class="button button-secondary" href="<?php echo admin_url('customize.php'); ?>"><?php echo esc_html_e('Go to the Customizer','magazina'); ?></a>
                            </p>
                        </div></div>
                        <div class="theme_link five"><div class="inner-wrp">
                            <h3><?php echo $theme_config['support_title']; ?></h3>
            <p><a target="_blank" class="button button-secondary" href="<?php echo $theme_config['support_link']; ?>"><?php echo $theme_config['support_forum']; ?></a></p></div>
                        </div>
                        <div class="theme_link six"><div class="inner-wrp">
                            <h3><?php esc_html_e('Step 6 - Need more features?','magazina');?></h3>
                            <p><?php esc_html_e('Upgrade to Pro version for more exciting features.','magazina'); ?>
                           </p>
                             <p>
                              <a target="_blank" class="button button-secondary" href="https://blogwings.com/magazina/"><?php echo esc_html_e('View Pro Version','magazina'); ?></a>
                            </p>
                        </div></div>
                    </div>
                </div>
            </div>
        <?php } ?>

        <?php if ( $tab == 'actions_required' ) { ?>
            <div class="action-required-tab info-tab-content">
                <div id="plugin-filter" class="recommend-plugins action-required">

                    <?php if ( isset($actions['recommend_plugins']) && $actions['recommend_plugins'] == 'active' ) {  ?>
                        <h3><?php esc_html_e( 'Recommended Plugins', 'magazina' ); ?></h3>
                            <?php magazina_plugin_api(); ?>
                    <?php } else {  
                            echo '<p style="color:#e45f12;font-style:italic;font-size:14px;">'.esc_html_e( 'Plugin installed and active!', 'magazina' ).'</p>';
                    } ?> 
                                        </div>                          
            </div>
        <?php } ?>

        <?php if ( $tab == 'free-pro' ) { ?>

            <?php magazina_theme(); ?>

        <?php  } elseif ( $tab == 'demo-import' ) {

                     magazina_demo_import();

        } ?>


    </div> <!-- END .theme_info -->
    <?php

}

 function magazina_plugin_api() {
 if ( ! function_exists( 'plugins_api' ) ) {
      require ABSPATH . 'wp-admin/includes/plugin-install.php';
}

        $recommend_plugins = get_theme_support( 'recommend-plugins' );
    if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){

        foreach($recommend_plugins[0] as $slug=>$plugin){
              $plugin_info = plugins_api( 'plugin_information', array(
                  'slug' => $slug,
                  'fields' => array(
                      'sections'          => true,
                      'homepage'          => true,
                      'added'             => false,
                      'last_updated'      => false,
                      'compatibility'     => false,
                      'tested'            => false,
                      'requires'          => false,
                      'downloadlink'      => false,
                      'icons'             => true,
                  )
              ) );
              //foreach($plugin_info as $plugin_info){
                  $plugin_name = $plugin_info->name;
                  $plugin_slug = $plugin_info->slug;
                  $version = $plugin_info->version;
                  $author = $plugin_info->author;
                  $download_link = $plugin_info->download_link;
                  $icons = (isset($plugin_info->icons['1x']))?$plugin_info->icons['1x']:$plugin_info->icons['default'];
              $status = is_dir( WP_PLUGIN_DIR . '/' . $plugin_slug );
              $active_file_name = $plugin_slug . '/' . $plugin_slug . '.php';
              $button_class = 'install-now button';

            if ( ! is_plugin_active( $active_file_name ) ) {
                $button_txt = esc_html__( 'Install Now', 'magazina' );
                  if ( ! $status ) {
                    $install_url = wp_nonce_url(
                    add_query_arg(
                    array(
                    'action' => 'install-plugin',
                    'plugin' => $plugin_slug
                    ),
                    network_admin_url( 'update.php' )
                    ),
                    'install-plugin_'.$plugin_slug
                    );
                  } else {
                    $install_url = add_query_arg(array(
                    'action' => 'activate',
                    'plugin' => rawurlencode( $active_file_name ),
                    'plugin_status' => 'all',
                    'paged' => '1',
                    '_wpnonce' => wp_create_nonce('activate-plugin_' . $active_file_name ),
                    ), network_admin_url('plugins.php'));
                    $button_class = 'activate-now button-primary';
                    $button_txt = esc_html__( 'Active Now', 'magazina' );
                  }


                $detail_link = add_query_arg(
                array(
                'tab' => 'plugin-information',
                'plugin' => $plugin_slug,
                'TB_iframe' => 'true',
                'width' => '772',
                'height' => '349',

                ),
                network_admin_url( 'plugin-install.php' )
                );
                $detail = '';
                echo '<div class="rcp">';
                echo '<h4 class="rcp-name">';
                echo esc_html( $plugin_name );
                echo '</h4>';
                echo '<img src="'.$icons.'" />';
                if($plugin_slug=='one-click-demo-import'){
                		$detail = esc_html__('The best feature of this plugin is, that theme authors can define import files in their themes and so all you (the user of the theme) have to do is click on the “Import Demo Data” button.','magazina');
                } elseif($plugin_slug=='blogwings-companion'){
                    $detail= esc_html__('blogwings customizer - blogwings customizer plugin will allow you to add  unlimited number of columns for services, Testimonial, and Team with widget support. It will add slider section, Ribbon section, latest post, Contact us and Woocommerce section. These will be visible on front page of your site.','magazina');

                }elseif($plugin_slug=='mailchimp-for-wp'){
                		$detail= esc_html__('This plugin helps you grow your MailChimp lists and write better newsletters through various methods. You can create good looking opt-in forms or integrate with any existing form on your site, like your comment, contact or checkout form.','magazina');

                }

                echo '<p class="rcp-detail">'.$detail.' </p>';

                echo '<p class="action-btn plugin-card-'.esc_attr( $plugin_slug ).'"><span>Version:'.$version.'</span>
                      '.$author.'<a href="'.esc_url( $install_url ).'" data-slug="'.esc_attr( $plugin_slug ).'" class="'.esc_attr( $button_class ).'">'.$button_txt.'</a>
                </p>';
                echo '<a class="plugin-detail thickbox open-plugin-details-modal" href="'.esc_url( $detail_link ).'">'.esc_html__( 'Details', 'magazina' ).'</a>';
                echo '</div>';

            } else {

              }

        }

    }

}


function magazina_get_actions_required( ) {

    $actions = array();

    $recommend_plugins = get_theme_support( 'recommend-plugins' );
    if ( is_array( $recommend_plugins ) && isset( $recommend_plugins[0] ) ){
        $recommend_plugins = $recommend_plugins[0];
    } else {
        $recommend_plugins[] = array();
    }

    if ( ! empty( $recommend_plugins ) ) {

        foreach ( $recommend_plugins as $plugin_slug => $plugin_info ) {
            $plugin_info = wp_parse_args( $plugin_info, array(
                'name' => '',
                'active_filename' => '',
            ) );
            if ( $plugin_info['active_filename'] ) {
                $active_file_name = $plugin_info['active_filename'] ;
            } 
            else {
                $active_file_name = $plugin_slug . '/' . $plugin_slug . '.php';
            }
            if ( ! is_plugin_active( $active_file_name ) ) {
                $actions['recommend_plugins'] = 'active';
            }
        }

    }

    $actions = apply_filters( 'magazina_get_actions_required', $actions );

    $return = array(
        'actions' => $actions,
        'number_actions' => count( $actions ),
    );

    return $return;
}