<?php

function wpfresh5_print_plugins_table( $plugins, $free_only = 1 ) {
    if( empty( $plugins ) )
        return;
    $free = $plugins['free'];
    $str = '<h1>'.$plugins['type'].'</h1>';
    if( !$free_only )
      $str .= '<h2>Free Plugins</h2>';
    else
      $str .= '<br/>';
    $str .= '<table class="widefat"><thead>';
    $str .= '<tr><th class="row-title" scope="col" style="width:35%">Name</th><th class="row-title" scope="col">Description</th><th class="row-title" scope="col" style="width:180px;text-align:center">Install</th></tr>';
    $str .= '</thead><tbody>';
    $i = 0;
    foreach( $free as $plugin )
        $str .= wpfresh5_free_plugin_row( $plugin, $i++ );
    $str .= '</tbody></table><br/>';
    echo $str;

    if( $free_only )
        return;

    $paid = $plugins['paid'];
    if( !empty( $paid ) ) {
        $str = '<h2>Premium Plugins</h2>';
        $str .= '<table class="widefat"><thead>';
        $str .= '<tr><th class="row-title" scope="col" style="width:35%">Name</th><th class="row-title" scope="col">Description</th><th class="row-title" scope="col" style="width:180px;text-align:center">Download</th></tr>';
        $str .= '</thead><tbody>';
        $i = 0;
        foreach( $paid as $plugin )
            $str .= wpfresh5_paid_plugin_row( $plugin, $i++ );
        $str .= '</tbody></table><br/>';
        echo $str;
    }
}

function wpfresh5_free_plugin_row( $plugin, $i ) {
    $str = '<tr '.(($i%2) ? 'class="alternate"' : '').'>
        <th class="row-title" scope="row"><a href="'.$plugin['url'].'" target="_blank">'.$plugin['name'].'</a></th>
        <td>'.$plugin['description'].'</td>
        <td style="text-align:center">'.wpfresh5_plugin_status( $plugin ).'</td>
    </tr>';
    return $str;
}

function wpfresh5_paid_plugin_row( $plugin, $i ) {
    $str = '<tr '.(($i%2) ? 'class="alternate"' : '').'>
        <th class="row-title" scope="row"><a href="'.$plugin['url'].'" target="_blank">'.$plugin['name'].'</a></th>
        <td>'.$plugin['description'].'</td>
        <td style="text-align:center"><a href="'.$plugin['url'].'" class="button button-secondary" target="_blank"><i class="fa fa-download"></i> Download</a></td>
    </tr>';
    return $str;
}

function wpfresh5_plugin_status( $plugin ) {
    if( $phpfile = wpfresh5_is_plugin_there( $plugin['slug'] ) ) {
        if( $phpfile ) {
            $first_value = reset($phpfile); // First Element's Value
            $first_key = key($phpfile); // First Element's Key
            // $phpfile = key( reset( $phpfile ) );
        }
    	if( wpfresh5_is_plugin_active( $plugin['slug'].'/'.$first_key ) ) {
    		return '<i class="fa fa-check-square-o"></i> Active';
    	}
    	else {
    		return '<i class="fa fa-minus-square-o"></i> Inactive';
    	}
    }
    else
    	return '<input type="checkbox" name="wpfresh5_rec_plugins['.$plugin['slug'].']"/>';
}

function wpfresh5_get_plugin_list( $slug ) {
	if( !$slug )
		return false;
	// $file = WPFRESH5_DIR.'/lib/plugins/plugins-'.$slug.'.json';

    // wpfresh5_print_plugins();
  $plugins = wpfresh5_get_plugins();
  return $plugins[ $slug ];
/*	if( file_exists( $file ) )
		$contents = json_decode( file_get_contents( $file ), true );
	else
		return false;
	return $contents;*/
}

// Utils
function wpfresh5_is_plugin_there( $plugin_dir ) {
    $plugins = get_plugins( '/'.$plugin_dir );
    // var_dump($plugin_dir.'/'.$plugin_dir.'.php');
    // var_dump($plugins);
	if ( $plugins )
		return $plugins;
	return false;
}

function wpfresh5_is_plugin_active( $slug ) {
	return is_plugin_active( $slug/*'HangoutPlugin/google_hangout_plugin.php'*/ );
}

function wpfresh5_install_plugins( $multiple ) {
	$urls = explode(',', $multiple );
    for ($i = 0; $i < count( $urls ); $i++) {
        wpfresh5_install_plugin( trim( $urls[$i] ) );
    }
}

function wpfresh5_install_plugins_by_slug( $slugs ) {
    if( empty( $slugs ) )
        return;
    foreach( $slugs as $slug ) {
        wpfresh5_install_plugin( 'https://wordpress.org/plugins/'.trim( $slug ).'/' );
    }
}
function wpfresh5_install_plugin( $url )
{
	require_once(ABSPATH . 'wp-admin/includes/class-wp-upgrader.php');
	require_once(ABSPATH . 'wp-admin/includes/plugin-install.php');
	$url = trim( $url );
    if (strstr($url, '.zip') != FALSE) {
        $download_link = $url;
    } else {
        $slug = explode('/', $url);
        $slug = $slug[count($slug) - 2];
        $api = plugins_api('plugin_information', array('slug' => $slug, 'fields' => array('sections' => 'false')));
        $download_link = $api->download_link;
    }

    $upgrader = new Plugin_Upgrader();
    if (!$upgrader->install($download_link))
        return 0;
    $plugin_to_activate = $upgrader->plugin_info();
    $activate = activate_plugin($plugin_to_activate);
    wp_cache_flush();

    return 1;
}

function wpfresh5_get_plugins() {
    $seo = array(
        'type' => 'SEO',
        'free' => array(
            array(
                'name' => 'Yoast SEO',
                'description' => 'One of the best SEO plugins for WordPress',
                'slug' => 'wordpress-seo',
                'url' => 'https://wordpress.org/plugins/wordpress-seo/'
            ),
            array(
                'name' => 'All in One SEO',
                'description' => 'An All in One solution for your SEO',
                'slug' => 'all-in-one-seo-pack',
                'url' => 'https://wordpress.org/plugins/all-in-one-seo-pack/'
            ),
              array(
                  'name' => 'SEO Ultimate',
                  'description' => 'A great SEO plugin with tons of features',
                  'slug' => 'seo-ultimate',
                  'url' => 'https://wordpress.org/plugins/seo-ultimate/'
              ),
              array(
                  'name' => 'Redirection',
                  'description' => 'Redirection is a WordPress plugin to manage 301 redirections, keep track of 404 errors, and generally tidy up any loose ends your site may have.',
                  'slug' => 'redirection',
                  'url' => 'https://wordpress.org/plugins/redirection/'
              ),
              array(
                  'name' => 'All In One Schema.org Rich Snippets',
                  'description' => 'Adds rich schema snippets for Search Engines',
                  'slug' => 'all-in-one-schemaorg-rich-snippets',
                  'url' => 'https://wordpress.org/plugins/all-in-one-schemaorg-rich-snippets/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'WP Tag Machine',
                'description' => 'Use WP tags to supercharge your SEO',
                'slug' => 'wp-tag-machine',
                'url' => 'https://jvz9.com/c/545869/260675?tid=iwpf5'
            ),
            array(
                'name' => 'Backlink Machine',
                'description' => 'Get Backlinks on autopilot',
                'slug' => 'wp-backlink-machine',
                'url' => 'https://jvz9.com/c/545869/269925?tid=iwpf5'
            ),
            array(
                'name' => 'SEOPressor',
                'description' => 'Saves lots of time with your SEO efforts',
                'slug' => 'seopressor',
                'url' => 'http://forexrt.seopressor.hop.clickbank.net?tid=iwpf5'
            )
        )
    );

    // wpfresh5_print_encoded( $arrayp );

    $content = array(
        'type' => 'Content',
        'free' => array(
            array(
                'name' => 'Contact Form 7',
                'description' => 'Create Contact forms in an easy Way',
                'slug' => 'contact-form-7',
                'url' => 'https://wordpress.org/plugins/contact-form-7/'
            ),
            array(
                'name' => 'WP Forms',
                'description' => 'WPForms allow you to create beautiful contact forms, subscription forms, payment forms, and other type of forms for your site in minutes',
                'slug' => 'wpforms-lite',
                'url' => 'https://wordpress.org/plugins/wpforms-lite/'
            ),
            array(
                'name' => 'Ninja Forms',
                'description' => 'Great form creation tool for WordPress. Build forms within minutes using a simple yet powerful drag-and-drop form creator',
                'slug' => 'ninja-forms',
                'url' => 'https://wordpress.org/plugins/ninja-forms/'
            ),
              array(
                  'name' => 'TablePress',
                  'description' => 'Embed beautiful and feature-rich tables into your posts and pages, without having to write code',
                  'slug' => 'tablepress',
                  'url' => 'https://wordpress.org/plugins/tablepress/'
              ),
              array(
                  'name' => 'The Events Calendar',
                  'description' => 'One of the bests plugins for Events',
                  'slug' => 'seo-internal-links',
                  'url' => 'https://wordpress.org/plugins/the-events-calendar/'
              ),
              array(
                  'name' => 'Contextual Related Posts',
                  'description' => 'Allows you to display a list of related posts on your website and in your feed',
                  'slug' => 'contextual-related-posts',
                  'url' => 'https://wordpress.org/plugins/contextual-related-posts/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'WP Auto Content',
                'description' => 'Build content for your site on autopilot',
                'slug' => 'wp-auto-content',
                'url' => 'https://jvz8.com/c/545869/295273?tid=iwpf5'
            ),
            array(
                'name' => 'WP FotoPress',
                'description' => 'Find copyright free images and edit them inside your WP panel',
                'slug' => 'wp-fotopress',
                'url' => 'https://jvz9.com/c/545869/199265?tid=iwpf5'
            ),
            array(
                'name' => 'WP Video Profits',
                'description' => 'Monetize your Videos inside WP',
                'slug' => 'wp-video-profits',
                'url' => 'https://jvz9.com/c/545869/238985?tid=iwpf5'
            )
        )
    );

    // wpfresh5_print_encoded( $arrayp );

    $affiliate = array(
        'type' => 'Affiliate',
        'free' => array(
            array(
                'name' => 'Pretty Links',
                'description' => 'Cloak your links and see stats for clicks from your visitors',
                'slug' => 'pretty-link',
                'url' => 'https://wordpress.org/plugins/pretty-link/'
            ),
            array(
                'name' => 'ThirstyAffiliates Affiliate Link Manager',
                'description' => 'Affiliate link management & cloaker tool. Easily manage, shrink and track your affiliate links in WordPress.',
                'slug' => 'wpforms-lite',
                'url' => 'https://wordpress.org/plugins/thirstyaffiliates/'
            ),
              array(
                  'name' => 'Auto Affiliate Links',
                  'description' => 'Automatically display affiliate links in your website content. You can specify the keywords and affiliate links you want to automatically link',
                  'slug' => 'wp-auto-affiliate-links',
                  'url' => 'https://wordpress.org/plugins/wp-auto-affiliate-links/'
              ),
              array(
                  'name' => 'Amazon Auto Links',
                  'description' => 'Add Amazon affiliate links in your site with ease',
                  'slug' => 'amazon-auto-links',
                  'url' => 'https://wordpress.org/plugins/amazon-auto-links/'
              ),
              array(
                  'name' => 'WP Product Review',
                  'description' => 'Easily create product review articles in your WP site',
                  'slug' => 'siteorigin-panels',
                  'url' => 'https://wordpress.org/plugins/wp-product-review/'
              ),
              array(
                  'name' => 'Quick Adsense',
                  'description' => 'Add Adsense ads to your site quickly',
                  'slug' => 'quick-adsense',
                  'url' => 'https://wordpress.org/plugins/quick-adsense/'
              ),
              array(
                  'name' => 'AdRotate Banner Manager',
                  'description' => ' Place advertising banners pretty anywhere on your site and track them',
                  'slug' => 'adrotate',
                  'url' => 'https://wordpress.org/plugins/adrotate/'
              ),
              array(
                  'name' => 'Advanced Ads',
                  'description' => 'An excellent ad manager plugin',
                  'slug' => 'advanced-ads',
                  'url' => 'https://wordpress.org/plugins/advanced-ads/'
              )
        ),
        'paid' => array(
            array(
                'name' => 'Azon Profit Builder',
                'description' => 'Build Amazon affiliate stores on autoplito',
                'slug' => 'azon-profit-builder',
                'url' => 'https://jvz1.com/c/545869/252559?tid=iwpf5'
            ),
            array(
                'name' => 'Ultimate Affiliate Pro',
                'description' => 'Build your own affiliate program inside WP',
                'slug' => 'ultimate-affiliate-pro',
                'url' => 'https://codecanyon.net/item/ultimate-affiliate-pro-wordpress-plugin/16527729?ref=raulmellado'
            )
        )
    );

    // wpfresh5_print_encoded( $arrayp );

    $social = array(
        'type' => 'Social',
        'free' => array(
            array(
                'name' => 'BuddyPress',
                'description' => 'Create your own private social network with WordPress',
                'slug' => 'buddypress',
                'url' => 'https://wordpress.org/plugins/buddypress/'
            ),
              array(
                  'name' => 'AddToAny Share Buttons',
                  'description' => 'Share buttons for WordPress including the AddToAny sharing button, Facebook, Twitter, Google+, Pinterest, WhatsApp and many others',
                  'slug' => 'add-to-any',
                  'url' => 'https://wordpress.org/plugins/add-to-any/'
              ),
              array(
                  'name' => 'Share Buttons by AddThis',
                  'description' => 'Share buttons from AddThis help you get more traffic from sharing through social networks',
                  'slug' => 'addthis',
                  'url' => 'https://wordpress.org/plugins/addthis/'
              ),
              array(
                  'name' => 'MashShare',
                  'description' => 'Highly customizable ecosystem for social media sharing and optimizing of your content.',
                  'slug' => 'mashsharer',
                  'url' => 'https://wordpress.org/plugins/mashsharer/'
              ),
              array(
                  'name' => 'Simple Share Buttons Adder',
                  'description' => 'A simple plugin that enables you to add share buttons to all of your posts',
                  'slug' => 'simple-share-buttons-adder',
                  'url' => 'https://wordpress.org/plugins/simple-share-buttons-adder/'
              ),
              array(
                  'name' => 'NextScripts: Social Networks Auto-Poster',
                  'description' => 'Automatically publishes blogposts to profiles/pages/groups on Facebook, Twitter, Instagram, Google+, Pinterest, LinkedIn, Blogger, Tumblr',
                  'slug' => 'social-networks-auto-poster-facebook-twitter-g',
                  'url' => 'https://wordpress.org/plugins/social-networks-auto-poster-facebook-twitter-g/'
              ),
              array(
                  'name' => 'WordPress Social Login',
                  'description' => 'WordPress Social Login allow your visitors to comment and login with social networks',
                  'slug' => 'wordpress-social-login',
                  'url' => 'https://wordpress.org/plugins/wordpress-social-login/'
              ),
              array(
                  'name' => 'Facebook Pixel by PixelYourSite',
                  'description' => 'Manage the New Facebook Pixel With Just a Few Clicks. WooCommerce and Easy Digital Downloads integration',
                  'slug' => 'pixelyoursite',
                  'url' => 'https://wordpress.org/plugins/pixelyoursite/'
              ),
              array(
                  'name' => 'Instagram Feed',
                  'description' => 'Display beautifully clean, customizable, and responsive feeds from multiple Instagram accounts',
                  'slug' => 'instagram-feed',
                  'url' => 'https://wordpress.org/plugins/instagram-feed/'
              ),
        ),
        'paid' => array(
            /*array(
                'name' => 'WP Fan Machine',
                'description' => 'Add Fans to your FB Pages on autopilot',
                'slug' => 'wp-fan-machine',
                'url' => 'https://jvz9.com/c/545869/204585?tid=iwpf5'
            ),*/
            array(
                'name' => 'WP Tweet Machine',
                'description' => 'Get Twitter followers on autopilot',
                'slug' => 'wp-tweet-machine',
                'url' => 'https://jvz1.com/c/545869/191911?tid=iwpf5'
            ),
            array(
                'name' => 'WP 1 Click Traffic',
                'description' => 'Get Fully automated social traffic to your website',
                'slug' => 'wp-1click-traffic',
                'url' => 'https://jvz1.com/c/545869/276448?tid=iwpf5'
            ),
            array(
                'name' => 'WP Social Traffic',
                'description' => 'Get 100% FREE - Fully AUTOMATED Traffic from Facebook to Any Wordpress Site You Want',
                'slug' => 'wp-social-traffic',
                'url' => 'https://jvz9.com/c/545869/235541?tid=iwpf5'
            )
        )
    );
        // echo json_encode($arrayp).'<br/>';
    // wpfresh5_print_encoded( $arrayp );

    $performance = array(
        'type' => 'Performance',
        'free' => array(
            array(
                'name' => 'WP Super Cache',
                'description' => 'A very fast caching engine for WordPress that produces static html files',
                'slug' => 'wp-super-cache',
                'url' => 'https://wordpress.org/plugins/wp-super-cache/'
            ),
            array(
                'name' => 'W3 Total Cache',
                'description' => 'W3 Total Cache improves the SEO and user experience of your site by increasing website page load speed',
                'slug' => 'w3-total-cache',
                'url' => 'https://wordpress.org/plugins/w3-total-cache/'
            ),
              array(
                  'name' => 'Smush Image Compression and Optimization',
                  'description' => 'Compress and optimize image files',
                  'slug' => 'wp-smushit',
                  'url' => 'https://wordpress.org/plugins/wp-smushit/'
              ),
              array(
                  'name' => 'WP-Optimize',
                  'description' => 'WP-Optimize is an effective tool for automatically cleaning your WordPress database so that it runs at maximum efficiency',
                  'slug' => 'wp-optimize',
                  'url' => 'https://wordpress.org/plugins/wp-optimize/'
              ),
              array(
                  'name' => 'EWWW Image Optimizer',
                  'description' => 'Speed up your website and improve your visitors experience by automatically compressing and resizing images',
                  'slug' => 'ewww-image-optimizer',
                  'url' => 'https://wordpress.org/plugins/ewww-image-optimizer/'
              ),
              array(
                  'name' => 'Autoptimize',
                  'description' => 'Autoptimize makes optimizing your site really easy. It can aggregate, minify and cache scripts and styles, etc',
                  'slug' => 'autoptimize',
                  'url' => 'https://wordpress.org/plugins/autoptimize/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'Viper Cache',
                'description' => 'Make Your WordPress Sites up to 10x Faster In 1 Click ',
                'slug' => 'viper-cache',
                'url' => 'https://jvz5.com/c/545869/301007?tid=iwpf5'
            ),
            array(
                'name' => 'WP Rocket',
                'description' => 'One of the best caching plugins in the market',
                'slug' => 'wp-rocket',
                'url' => 'https://wp-rocket.me/'
            )
        )
    );

    $pagebuilders = array(
        'type' => 'Page Builders',
        'free' => array(
            array(
                'name' => 'Page Builder by SiteOrigin',
                'description' => 'A Drag and Drop content editor',
                'slug' => 'siteorigin-panels',
                'url' => 'https://wordpress.org/plugins/siteorigin-panels/'
            ),
            array(
                'name' => 'Elementor',
                'description' => 'A page builder that delivers high-end page designs and advanced capabilities',
                'slug' => 'elementor',
                'url' => 'https://es.wordpress.org/plugins/elementor/'
            ),
              array(
                  'name' => 'Beaver Builder',
                  'description' => 'Flexible drag and drop page builder that works on the front end of your WordPress website',
                  'slug' => 'beaver-builder-lite-version',
                  'url' => 'https://wordpress.org/plugins/beaver-builder-lite-version/'
              )
        ),
        'paid' => array(
            array(
                'name' => 'Visual Composer',
                'description' => 'The top seller page builder on the market',
                'slug' => 'js_builder',
                'url' => 'https://codecanyon.net/item/visual-composer-page-builder-for-wordpress/242431?s_rank=1&ref=raulmellado'
            )
        )
    );
    // wpfresh5_print_encoded( $arrayp );

    $ecommerce = array(
        'type' => 'Ecommerce',
        'free' => array(
            array(
                'name' => 'WooCommerce',
                'description' => 'Set up your own online store in minutes',
                'slug' => 'woocommerce',
                'url' => 'https://wordpress.org/plugins/woocommerce/'
            ),
            array(
                'name' => 'WooCommerce PDF Invoices & Packing Slips',
                'description' => 'Create, print & automatically email PDF invoices & packing slips for WooCommerce orders',
                'slug' => 'woocommerce-pdf-invoices-packing-slips',
                'url' => 'https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/'
            ),
            array(
                'name' => 'YITH WooCommerce Wishlist',
                'description' => 'Add wishlist features to your Woocommerce store',
                'slug' => 'yith-woocommerce-wishlist',
                'url' => 'https://wordpress.org/plugins/yith-woocommerce-wishlist/'
            ),
              array(
                  'name' => 'WooCommerce PayPal Express Checkout Payment Gateway',
                  'description' => 'Accept PayPal, Credit Cards and Debit Cards on your WooCommerce store',
                  'slug' => 'woocommerce-gateway-paypal-express-checkout',
                  'url' => 'https://wordpress.org/plugins/woocommerce-gateway-paypal-express-checkout/'
              ),
              array(
                  'name' => 'WooCommerce Stripe Payment Gateway',
                  'description' => 'Take credit card payments on your store using Stripe',
                  'slug' => 'woocommerce-gateway-stripe',
                  'url' => 'https://wordpress.org/plugins/woocommerce-gateway-stripe/'
              ),
              array(
                  'name' => 'YITH WooCommerce Compare',
                  'description' => 'Allow your users to compare some products of your shop',
                  'slug' => 'yith-woocommerce-compare',
                  'url' => 'https://wordpress.org/plugins/yith-woocommerce-compare/'
              ),
              array(
                  'name' => 'WooCommerce Checkout Field Editor Manager',
                  'description' => 'Edit checkout fields for your customers',
                  'slug' => 'woo-checkout-field-editor-pro',
                  'url' => 'https://wordpress.org/plugins/woo-checkout-field-editor-pro/'
              ),
              array(
                  'name' => 'Easy Digital Downloads',
                  'description' => 'Sell digital products with WordPress',
                  'slug' => 'easy-digital-downloads',
                  'url' => 'https://wordpress.org/plugins/easy-digital-downloads/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'WooCommerce Extra Product Options',
                'description' => 'A more versatile product option creator for Woocommerce',
                'slug' => 'wp-extra-product-options',
                'url' => 'https://codecanyon.net/item/woocommerce-extra-product-options/7908619?s_rank=15&ref=raulmellado'
            ),
            array(
                'name' => 'WooCommerce Advanced Bulk Edit',
                'description' => 'Easily edit your products and variations individually or in bulk in WooCommerce',
                'slug' => 'wc-advanced-bulk',
                'url' => 'https://codecanyon.net/item/woocommerce-advanced-bulk-edit/8011417?s_rank=41&ref=raulmellado'
            )
        )
    );
    // wpfresh5_print_encoded( $arrayp );

    $backup = array(
        'type' => 'Backup',
        'free' => array(
            array(
                'name' => 'Updraftplus',
                'description' => 'An excellent plugin to do a full backup of your site',
                'slug' => 'updraftplus',
                'url' => 'https://wordpress.org/plugins/updraftplus/'
            ),
            array(
                'name' => 'All-in-One WP Migration',
                'description' => 'Move, transfer, copy, migrate, and backup a site with 1-click. Quick, easy, and reliable',
                'slug' => 'all-in-one-wp-migration',
                'url' => 'https://wordpress.org/plugins/all-in-one-wp-migration/'
            ),
              array(
                  'name' => 'BackWPup',
                  'description' => 'Schedule complete automatic backups of your WordPress installation',
                  'slug' => 'backwpup',
                  'url' => 'https://wordpress.org/plugins/backwpup/'
              ),
              array(
                  'name' => 'WP-DB-Backup',
                  'description' => 'On-demand backup of your WordPress database',
                  'slug' => 'wp-db-backup',
                  'url' => 'https://wordpress.org/plugins/wp-db-backup/'
              ),
              array(
                  'name' => 'Duplicator',
                  'description' => 'Gives the ability to migrate, copy, move or clone a site from one location to another and also serves as a simple backup utility.',
                  'slug' => 'duplicator',
                  'url' => 'https://wordpress.org/plugins/duplicator/'
              )
        ),
        'paid' => array(
            array(
                'name' => 'BackupBuddy',
                'description' => 'The best WP Backup suite',
                'slug' => 'backup-buddy',
                'url' => 'https://ithemes.com/purchase/backupbuddy/'
            ),
            array(
                'name' => 'UpdraftPlus Premium',
                'description' => 'If the basic version is not enough, the Pro version has some extra functionality',
                'slug' => 'uplus-premium',
                'url' => 'https://updraftplus.com/shop/updraftplus-premium/'
            )
        )
    );
    // wpfresh5_print_encoded( $arrayp );

    $security = array(
        'type' => 'Security',
        'free' => array(
            array(
                'name' => 'Wordfence Security',
                'description' => 'Secure your website with the most comprehensive WordPress security plugin.',
                'slug' => 'wordfence',
                'url' => 'https://wordpress.org/plugins/wordfence/'
            ),
            array(
                'name' => 'iThemes Security',
                'description' => 'Gives you over 30+ ways to secure and protect your WordPress site',
                'slug' => 'better-wp-security',
                'url' => 'https://wordpress.org/plugins/better-wp-security/'
            ),
              array(
                  'name' => 'Limit Login Attempts',
                  'description' => 'Limit rate of login attempts, including by way of cookies, for each IP. Fully customizable',
                  'slug' => 'limit-login-attempts',
                  'url' => 'https://wordpress.org/plugins/limit-login-attempts/'
              ),
              array(
                  'name' => 'Sucuri Security',
                  'description' => 'A complete security suite for your WordPress site',
                  'slug' => 'sucuri-scanner',
                  'url' => 'https://wordpress.org/plugins/sucuri-scanner/'
              ),
              array(
                  'name' => 'All In One WP Security & Firewall',
                  'description' => 'Run a Complete Scan to automatically remove known security threats and backdoor scripts',
                  'slug' => 'all-in-one-wp-security-and-firewall',
                  'url' => 'https://wordpress.org/plugins/all-in-one-wp-security-and-firewall/'
              ),
              array(
                  'name' => 'Anti-Malware Security and Brute-Force Firewall',
                  'description' => 'A comprehensive, easy to use, stable WordPress security plugin',
                  'slug' => 'gotmls',
                  'url' => 'https://wordpress.org/plugins/gotmls/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'Hide my WP',
                'description' => 'Top seller security plugin, with lots of functionality to protect your site from hackers',
                'slug' => 'hide-my-wp',
                'url' => 'https://codecanyon.net/item/hide-my-wp-amazing-security-plugin-for-wordpress/4177158?s_rank=1&ref=raulmellado'
            ),
            array(
                'name' => 'iThemes Security Pro',
                'description' => 'A great plugin to Secure & Protect WordPress',
                'slug' => 'ithemes-security-pro',
                'url' => 'https://ithemes.com/security/'
            ),
            array(
                'name' => 'Blog Defender',
                'description' => 'Protects your WordPress site against 99% of all threats',
                'slug' => 'blog-defender',
                'url' => 'https://warriorplus.com/o2/a/ywn13/0'
            ),
        )
    );
    // wpfresh5_print_encoded( $arrayp );

    $others = array(
        'type' => 'Others',
        'free' => array(
            array(
                'name' => 'Google Analytics Dashboard for WP',
                'description' => 'Connects Google Analytics with your WordPress site.',
                'slug' => 'google-analytics-dashboard-for-wp',
                'url' => 'https://wordpress.org/plugins/google-analytics-dashboard-for-wp/'
            ),
            array(
                'name' => 'WP Maintenance Mode',
                'description' => 'Adds a splash page to your site that lets visitors know your site is down',
                'slug' => 'wp-maintenance-mode',
                'url' => 'https://wordpress.org/plugins/wp-maintenance-mode/'
            ),
              array(
                  'name' => 'Loco Translate',
                  'description' => 'Translate WordPress plugins and themes directly in your browser',
                  'slug' => 'loco-translate',
                  'url' => 'https://wordpress.org/plugins/loco-translate/'
              ),
              array(
                  'name' => 'Polylang',
                  'description' => 'Polylang allows you to create a bilingual or multilingual WordPress site',
                  'slug' => 'polylang',
                  'url' => 'https://wordpress.org/plugins/polylang/'
              ),
              array(
                  'name' => 'AMP',
                  'description' => 'This plugin adds support for the Accelerated Mobile Pages (AMP) Project',
                  'slug' => 'amp',
                  'url' => 'https://wordpress.org/plugins/amp/'
              ),
              array(
                  'name' => 'Post Duplicator',
                  'description' => 'Creates functionality to duplicate any and all post types, including taxonomies & custom fields',
                  'slug' => 'post-duplicator',
                  'url' => 'https://wordpress.org/plugins/post-duplicator/'
              ),
              array(
                  'name' => 'Popup Maker',
                  'description' => 'Create any type of modal or content overlay for your WordPress website.',
                  'slug' => 'popup-maker',
                  'url' => 'https://wordpress.org/plugins/popup-maker/'
              ),
              array(
                  'name' => 'Heartbeat Control',
                  'description' => 'Allows you to easily manage the frequency of the WordPress heartbeat API',
                  'slug' => 'heartbeat-control',
                  'url' => 'https://wordpress.org/plugins/heartbeat-control/'
              ),
              array(
                  'name' => 'WP-Members',
                  'description' => 'WP-Members is a free membership management framework for WordPress that restricts content to registered users',
                  'slug' => 'wp-members',
                  'url' => 'https://wordpress.org/plugins/wp-members/'
              ),
        ),
        'paid' => array(
            array(
                'name' => 'WP Leads Machine',
                'description' => 'Turns All Your Blogs & Websites Into List Building Machines',
                'slug' => 'wp-leads-machine',
                'url' => 'https://jvz8.com/c/545869/263767?tid=iwpf5'
            ),
            array(
                'name' => 'WP ZeroBounce 2.0',
                'description' => 'This plugin helps you stop losing visitors and reduce your bounce rate',
                'slug' => 'wp-zero-bounce',
                'url' => 'https://jvz1.com/c/545869/147494?tid=iwpf5'
            ),
            array(
                'name' => 'WP Coursify',
                'description' => 'Easily Create Udemy like sites with online courses',
                'slug' => 'wp-coursify',
                'url' => 'https://jvz1.com/c/545869/229739?tid=iwpf5'
            )
        )
    );
    // wpfresh5_print_encoded( $arrayp );
    return array(
      'seo' => $seo,
      'content' => $content,
      'affiliate' => $affiliate,
      'social' => $social,
      'performance' => $performance,
      'ecommerce' => $ecommerce,
      'pagebuilders' => $pagebuilders,
      'backup' => $backup,
      'security' => $security,
      'others' => $others
    );
}

function wpfresh5_print_encoded( $arrayp ) {
  echo '<br/>';
  echo json_encode($arrayp);
  echo '<br/>';
}
?>