<?php
add_action( 'tgmpa_register', 'butuh_plugins' );
function butuh_plugins() {
	$plugins = array(	
	array(
		'name'	=> 'One Click Demo Import ',
		'slug'	=> 'one-click-demo-import',
		'required'	=> true,
	), 
	array(
		'name'	=> 'Redux Framework',
		'slug'	=> 'redux-framework',
		'required'	=> true,
	),
	array(
		'name'	=> 'Classic Editor',
		'slug'	=> 'classic-editor',
		'required'	=> false,
	),
	array(
		'name'	=> 'Classic Widgets',
		'slug'	=> 'classic-widgets',
		'required'	=> false,
	), 
	array(
		'name'	=> 'Term Management Tools',
		'slug'	=> 'term-management-tools',
		'required'	=> true,
	), 
	array(
		'name'	=> 'React & Share',
		'slug'	=> 'react-and-share',
		'required'	=> false,
	),  	
    array(
		'name'	=> 'Customizer Export/Import',
		'slug'	=> 'customizer-export-import',
		'required'	=> false,        
    ), 
    array(
		'name'	=> 'Widget Importer & Exporter',
		'slug'	=> 'widget-importer-exporter',
		'required'	=> false,        
    ), 	
	array(
		'name'	=> 'TranslatePress - Multilingual',
		'slug'	=> 'translatepress-multilingual',
		'required'	=> false,
	),
	array(
		'name'	=> 'AI Translation for TranslatePress',
		'slug'	=> 'automatic-translate-addon-for-translatepress',
		'required'	=> false,
	), 	
	/* 
	
	//array(
		//'name'	=> 'CMB2',
		//'slug'	=> 'cmb2',
		//'required'	=> true,
	//),  
	array(
		'name'	=> 'Rate My Posts', // The plugin name.
		'slug'	=> 'rate-my-post',
		'required'	=> false,
	),
	array(
		'name'	=> 'Comments Like Dislike',
		'slug'	=> 'comments-like-dislike',
		'required'	=> false,
	),
	array(
		'name'	=> 'Report Post Content', 
		'slug'	=> 'report-content', 
		'source'	=> get_stylesheet_directory() . '/libs/plugins/report-content.zip', 
		'required'	=> false, 
	), 
	array(
		'name'	=> 'Fix My Feed RSS', 
		'slug'	=> 'fix-rss', 
		'source'	=> 'https://www.dropbox.com/s/desv6uuc9au4ex4/fix-rss.zip?dl=1',
		'required'	=> false, 
	), 
	*/
	 
	 

	);

	$config = array(
	'id'	   => 'ex_themes',
	'default_path' => '',
	'menu'	 => 'tgmpa-install-plugins',
	'has_notices'  => true,
	'dismissable'  => true,
	'dismiss_msg'  => '',
	'is_automatic' => true, 
	'message'      => '',   
	);

	tgmpa( $plugins, $config );
}



function ocdi_register_plugins( $plugins ) {
 
  // Required: List of plugins used by all theme demos.
  $theme_plugins = [  
    [
		'name'	=> 'One Click Demo Import',
		'slug'	=> 'one-click-demo-import',
		'required'	=> false,	
    ], 
	[
		'name'	=> 'Redux Framework',
		'slug'	=> 'redux-framework',
		'required'	=> true,	
    ],
    [
		'name'	=> 'Term Management Tools',
		'slug'	=> 'term-management-tools',
		'required'	=> true,	
    ],
    [
		'name'	=> 'Classic Editor',
		'slug'	=> 'classic-editor',
		'required'	=> false,	
    ],
    [
		'name'	=> 'Classic Widgets',
		'slug'	=> 'classic-widgets',
		'required'	=> false,	
    ],
    [
		'name'	=> 'React & Share',
		'slug'	=> 'react-and-share',
		'required'	=> false,
    ],    	
	[
		'name'	=> 'TranslatePress - Multilingual',
		'slug'	=> 'translatepress-multilingual',
		'required'	=> false,
	],  		
	[
		'name'	=> 'AI Translation for TranslatePress',
		'slug'	=> 'automatic-translate-addon-for-translatepress',
		'required'	=> false,
	], 
	
	/* 
	   
	//[
	//	'name'	=> 'CMB2',
	//	'slug'	=> 'cmb2',
	//	'required'	=> true,
	//],   
    [
		'name'	=> 'Rate my Post - WP Rating System',
		'slug'	=> 'rate-my-post',
		'required'	=> false,
    ],
    [
		'name'	=> 'Comments Like Dislike',
		'slug'	=> 'comments-like-dislike',
		'required'	=> false,
    ],
	
    [
      'name'	=> 'Report Post Content',
      'slug'	=> 'report-content',       
      'source'	=> get_template_directory_uri() . '/libs/plugins/report-content.zip',
      'required'	=> false,
    ], 
    [
      'name'     => 'Some Bundled Plugin',
      'slug'     => 'bundled-plugin',       
      'source'   => get_template_directory_uri() . '/bundled-plugins/bundled-plugin.zip',
      'required' => false,
    ],
    [
		'name'		=> 'Self Hosted Plugin',
		'description' 	=> 'This is the plugin description',
		'slug'		=> 'self-hosted-plugin', 
		'source'      	=> 'https://example.com/my-site/self-hosted-plugin.zip',
		'preselected' 	=> true,
		'required' 		=> true, 
    ],
	 */
  ];
 
  // Check if user is on the theme recommeneded plugins step and a demo was selected.
  if ( isset( $_GET['step'] ) && $_GET['step'] === 'import' && isset( $_GET['import'] ) ) {
 
    // Adding one additional plugin for the first demo import ('import' number = 0).
    if ( $_GET['import'] === '1' ) {
      /* 
	  $theme_plugins[] = [
	'name'     => 'Page Builder by SiteOrigin',
	'slug'     => 'siteorigin-panels',
	'required' => true,
      ];
 
      $theme_plugins[] = [
	'name'     => 'SiteOrigin Widgets Bundle',
	'slug'     => 'so-widgets-bundle',
	'required' => true,
      ]; 
	  */
    }
 
    // List of all plugins only used by second demo import [overwrite the list] ('import' number = 1).
    if ( $_GET['import'] === '1' ) {
      /* 
	  $theme_plugins = [
	[
	  'name'     => 'Advanced Custom Fields',
	  'slug'     => 'advanced-custom-fields',
	  'required' => true,
	],
	[
	  'name'     => 'Portfolio Post Type',
	  'slug'     => 'portfolio-post-type',
	  'required' => false,
	], 
      ];
	  */
    }
  }
 
  return array_merge( $plugins, $theme_plugins );
}
add_filter( 'ocdi/register_plugins', 'ocdi_register_plugins' );