<?php

class wpda_pricing_table_admin_panel{
// previus defined admin constants
// wpda_pricing_table_plugin_url
// wpda_pricing_table_plugin_path

	private $text_fileds;
	
	function __construct(){
		$this->admin_filters();
	}

	private function admin_filters(){
		//hook for admin menu
		add_action( 'admin_menu', array($this,'create_admin_menu') );
		/* for post page button*/
		add_filter( 'mce_external_plugins', array( $this ,'mce_external_plugins' ) );
		add_filter( 'mce_buttons', array($this, 'mce_buttons' ) );
		add_action('wp_ajax_wpda_pricing_table_post_page_content', array($this,"post_page_popup_content"));
		if( is_admin() ){
			add_action( 'wp_default_scripts', array($this,'alpha_picker') );
		}
		$this->gutenberg();	
		
	}
	public function alpha_picker( $scripts ){
		$scripts->add( 'wp-color-picker', "/wp-admin/js/color-picker.js", array( 'iris' ), false, 1 );
		did_action( 'init' ) && $scripts->localize(
			'wp-color-picker',
			'wpColorPickerL10n',
			array(
				'clear'            => __( 'Clear' ),
				'clearAriaLabel'   => __( 'Clear color' ),
				'defaultString'    => __( 'Default' ),
				'defaultAriaLabel' => __( 'Select default color' ),
				'pick'             => __( 'Select Color' ),
				'defaultLabel'     => __( 'Color value' ),
			)
		);
	}
	//conect admin menu
	public function create_admin_menu(){
		global $submenu;
		/* conect admin pages to wordpress core*/
		$main_page=add_menu_page( "Pricing Table", "Pricing Table", 'manage_options', "wpda_pricing_table_menu", array($this, 'create_pricing_table'),wpda_pricing_table_plugin_url.'includes/admin/images/test.svg');
		add_submenu_page( "wpda_pricing_table_menu", "Pricing Tables", "Pricing Tables", 'manage_options',"wpda_pricing_table_menu",array($this, 'create_pricing_table'));
		$pricing_table_theme=add_submenu_page( "wpda_pricing_table_menu", "Column Themes", "Column Themes", 'manage_options',"wpda_pricing_table_themes",array($this, 'pricing_table_themes_page'));			
		add_submenu_page( "wpda_pricing_table_menu", "Featured Plugins", "Featured Plugins", 'manage_options',"wpda_pricing_table_featured_plugins",array($this, 'featured_plugins'));
		$hire_expert = add_submenu_page( "wpda_pricing_table_menu", 'Hire an Expert', '<span style="color:#00ff66" >Hire an Expert</span>', 'manage_options',"wpda_pricing_table_hire_expert",array($this, 'hire_expert'));
		/*for including page styles and scripts*/
		add_action('admin_print_styles-' .$main_page, array($this,'create_pricing_table_style_js'));
		add_action('admin_print_styles-' .$pricing_table_theme, array($this,'create_theme_page_style_js'));	
		add_action('admin_print_styles-' .$hire_expert, array($this,'create_hire_expert_style_js'));		
	
		if(isset($submenu['wpda_pricing_table_menu']))
			add_submenu_page( 'wpda_pricing_table_menu', "Support or Any Ideas?", "<span style='color:#00ff66' >Support or Any Ideas?</span>", 'manage_options',"wpdevart_pt_any_ideas",array($this, 'any_ideas'),155);
		if(isset($submenu['wpda_pricing_table_menu']))
			$submenu['wpda_pricing_table_menu'][4][2]=wpdevart_pricing_table_support_url;
	}
	public function any_ideas(){
		
	}
	
	function create_hire_expert_style_js(){
		wp_enqueue_style('wpda_pricing_table_admin_main_css',wpda_pricing_table_plugin_url.'includes/admin/css/hire_expert.css');
	}
	
	/* timer page style and js*/	
	public function create_pricing_table_style_js(){
		
		//scripts
		wp_enqueue_script('jquery');
		wp_enqueue_script('jquery-ui-sortable');
		wp_enqueue_script('jquery-ui-datepicker');		
		wp_enqueue_script( 'jquery-ui-spinner');	
		wp_enqueue_script("jquery-ui-date-time-picker-js");
		wp_enqueue_script("jquery-ui-date-time-picker-js");
		wp_enqueue_script('angularejs',wpda_pricing_table_plugin_url.'includes/admin/js/angular.min.js');
		wp_enqueue_script("wpda_pricing_table_admin_main",wpda_pricing_table_plugin_url.'includes/admin/js/pricing_table.js');
		//styles
		wp_enqueue_style( 'jquery-ui' );
		wp_enqueue_style('wpda_pricing_table_admin_main_css',wpda_pricing_table_plugin_url.'includes/admin/css/pricing_table.css');
		wp_enqueue_style('jquery-ui-date-time-picker-css');
		wp_enqueue_style( 'font-awesome-5');
				
	}
	
	/* Themes page style and js*/	
	public function create_theme_page_style_js(){
		wp_enqueue_script('jquery');
		wp_enqueue_style( 'jquery-ui' );
		wp_enqueue_script('jquery-ui-slider');	
		wp_enqueue_style( 'wp-color-picker' );
		wp_enqueue_script( 'wp-color-picker' );
		wp_enqueue_script( 'alpha-color-picker', wpda_pricing_table_plugin_url.'includes/admin/js/alpha-color-picker.js', array( 'wp-color-picker' ),'2.4',true );
		wp_enqueue_script('angularejs',wpda_pricing_table_plugin_url.'includes/admin/js/angular.min.js');
		wp_enqueue_style('wpda_contdown_extend_timer_page_css',wpda_pricing_table_plugin_url.'includes/admin/css/theme_page.css');
		wp_enqueue_script("wpda_contdown_extend_timer_page_js",wpda_pricing_table_plugin_url.'includes/admin/js/theme_page.js');
	}
	
	/* Popup page style and js*/	
	public function create_popup_page_style_js(){		
		wp_enqueue_style('FontAwesome');
		wp_enqueue_script('jquery');
		wp_enqueue_style( 'jquery-ui' );
		wp_enqueue_style( 'wp-color-picker' );
		wp_enqueue_script( 'wp-color-picker' );
		wp_enqueue_script('jquery-ui-sortable');
		wp_enqueue_script( 'wpdevart_chosen' );
		wp_enqueue_script( 'wpdevart_prism' );
		wp_enqueue_style('wpda_contdown_extend_admin_popup_page_css',wpda_pricing_table_plugin_url.'includes/admin/css/popup_page.css');
		wp_enqueue_script('wpda_contdown_extend_admin_popup_page_css',wpda_pricing_table_plugin_url.'includes/admin/js/popup_page.js');
		if (function_exists('wp_enqueue_media')) wp_enqueue_media();
	}
	
	/* Timer page main*/	
	public function create_pricing_table(){				
		$pricing_table=new wpda_pricing_table_page();
		$pricing_table->controller_page();	
	}	
	/* themes*/		
	public function pricing_table_themes_page(){	
		$theme_page_objet=new wpda_pricing_table_theme_page();	
		$theme_page_objet->controller_page();
	}
	
	
	
	/*post page button*/
	public function mce_external_plugins( $plugin_array ) {
		$plugin_array["wpda_pricing_table"] = wpda_pricing_table_plugin_url.'includes/admin/js/post_page_insert_button.js';
		return $plugin_array;
	}
	/*post page button add_class*/
	public function mce_buttons( $buttons ) {
		array_push( $buttons, "wpda_pricing_table" );
		return $buttons;
	}
	/*post page button insert in content*/
	public function post_page_popup_content(){	
		require_once(wpda_pricing_table_plugin_path.'includes/admin/post_page_popup.php');
		$popup_page_objet=new wpda_pricing_table_post_page_popup();		
	}
	/*concect with gutenberg editor*/
	public function gutenberg(){	
		require_once(wpda_pricing_table_plugin_path.'includes/admin/gutenberg/gutenberg.php');
		$gutenberg=new wpda_pricing_table_gutenberg();		
		
	}
	
	public function hire_expert(){
		$plugins_array=array(
			'custom_site_dev'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/1.png',
				'title'			=>	'Custom WordPress Development',
				'description'	=>	'Hire a WordPress expert and make any custom development for your WordPress website.'
			),
			'custom_plug_dev'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/2.png',
				'title'			=>	'WordPress Plugin Development',
				'description'	=>	'Our developers can create any WordPress plugin from zero. Also, they can customize any plugin and add any functionality.'
			),
			'custom_theme_dev'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/3.png',
				'title'			=>	'WordPress Theme Development',
				'description'	=>	'If you need an unique theme or any customizations for a ready theme, then our developers are ready.'
			),
			'custom_theme_inst'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/4.png',
				'title'			=>	'WordPress Theme Installation and Customization',
				'description'	=>	'If you need a theme installation and configuration, then just let us know, our experts configure it.'
			),
			'gen_wp_speed'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/5.png',
				'title'			=>	'General WordPress Support',
				'description'	=>	'Our developers can provide general support. If you have any problem with your website, then our experts are ready to help.'
			),
			'speed_op'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/6.png',
				'title'			=>	'WordPress Speed Optimization',
				'description'	=>	'Hire an expert from WpDevArt and let him take care of your website speed optimization.'
			),
			'mig_serv'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/7.png',
				'title'			=>	'WordPress Migration Services',
				'description'	=>	'Our developers can migrate websites from any platform to WordPress.'
			),
			'page_seo'=>array(
				'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/hire_expert/8.png',
				'title'			=>	'WordPress On-Page SEO',
				'description'	=>	'On-page SEO is an important part of any website. Hire an expert and they will organize the on-page SEO for your website.'
			)
		);
		$content='';
		
		$content.='<h1 class="wpdev_hire_exp_h1"> Hire an Expert from WpDevArt </h1>';
		$content.='<div class="hire_expert_main">';		
		foreach($plugins_array as $key=>$plugin) {
			$content.='<div class="wpdevart_hire_main"><a target="_blank" class="wpdev_hire_buklet" href="https://wpdevart.com/hire-wordpress-developer-dedicated-experts-are-ready-to-help">';
			$content.='<div class="wpdevart_hire_image"><img src="'.$plugin["image_url"].'"></div>';
			$content.='<div class="wpdevart_hire_information">';
			$content.='<div class="wpdevart_hire_title">'.$plugin["title"].'</div>';			
			$content.='<p class="wpdevart_hire_description">'.$plugin["description"].'</p>';
			$content.='</div></a></div>';		
		} 
		$content.='<div><a target="_blank" class="wpdev_hire_button" href="https://wpdevart.com/hire-wordpress-developer-dedicated-experts-are-ready-to-help">Hire an Expert</a></div>';
		$content.='</div>';
		
		echo $content;
	}
		/*############################### Featured plugins function ########################################*/
	
	public function featured_plugins(){
		$plugins_array=array(
			'gallery_album'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/gallery-album-icon.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-gallery-plugin',
						'title'			=>	'WordPress Gallery plugin',
						'description'	=>	'Gallery plugin is an useful tool that will help you to create Galleries and Albums. Try our nice Gallery views and awesome animations.'
						),		
			'countdown-extended'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/icon-128x128.png',
						'site_url'		=>	'https://wpdevart.com/wordpress-countdown-extended-version/',
						'title'			=>	'WordPress Countdown Extended',
						'description'	=>	'Countdown extended is an fresh and extended version of countdown timer. You can easily create and add countdown timers to your website.'
						),							
			'coming_soon'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/coming_soon.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-coming-soon-plugin/',
						'title'			=>	'Coming soon and Maintenance mode',
						'description'	=>	'Coming soon and Maintenance mode plugin is an awesome tool to show your visitors that you are working on your website to make it better.'
						),
			'Contact forms'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/contact_forms.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-contact-form-plugin/',
						'title'			=>	'Contact Form Builder',
						'description'	=>	'Contact Form Builder plugin is an handy tool for creating different types of contact forms on your WordPress websites.'
						),	
			'Booking Calendar'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/Booking_calendar_featured.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-booking-calendar-plugin/',
						'title'			=>	'WordPress Booking Calendar',
						'description'	=>	'WordPress Booking Calendar plugin is an awesome tool to create a booking system for your website. Create booking calendars in a few minutes.'
						),
			'chart'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/chart-featured.png',
						'site_url'		=>	'https://wpdevart.com/wordpress-organization-chart-plugin/',
						'title'			=>	'WordPress Organization Chart',
						'description'	=>	'WordPress organization chart plugin is a great tool for adding organizational charts to your WordPress websites.'
						),						
			'youtube'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/youtube.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-youtube-embed-plugin',
						'title'			=>	'WordPress YouTube Embed',
						'description'	=>	'YouTube Embed plugin is an convenient tool for adding videos to your website. Use YouTube Embed plugin for adding YouTube videos in posts/pages, widgets.'
						),
            'facebook-comments'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/facebook-comments-icon.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-facebook-comments-plugin/',
						'title'			=>	'Wpdevart Social comments',
						'description'	=>	'WordPress Facebook comments plugin will help you to display Facebook Comments on your website. You can use Facebook Comments on your pages/posts.'
						),						
			'countdown'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/countdown.jpg',
						'site_url'		=>	'http://wpdevart.com/wordpress-countdown-plugin/',
						'title'			=>	'WordPress Countdown plugin',
						'description'	=>	'WordPress Countdown plugin is an nice tool for creating countdown timers for your website posts/pages and widgets.'
						),
			'lightbox'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/lightbox.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-lightbox-plugin',
						'title'			=>	'WordPress Lightbox plugin',
						'description'	=>	'WordPress Lightbox Popup is an high customizable and responsive plugin for displaying images and videos in popup.'
						),
			'facebook'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/facebook.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-facebook-like-box-plugin',
						'title'			=>	'Social Like Box',
						'description'	=>	'Facebook like box plugin will help you to display Facebook like box on your website, just add Facebook Like box widget to sidebar or insert it into posts/pages and use it.'
						),
			'poll'=>array(
						'image_url'		=>	wpda_pricing_table_plugin_url.'includes/admin/images/featured_plugins/poll.png',
						'site_url'		=>	'http://wpdevart.com/wordpress-polls-plugin',
						'title'			=>	'WordPress Polls system',
						'description'	=>	'WordPress Polls system is an handy tool for creating polls and survey forms for your visitors. You can use our polls on widgets, posts and pages.'
						),
		);
		?>
        <style>
         .featured_plugin_main{
			background-color: #ffffff;
			-webkit-box-sizing: border-box;
			-moz-box-sizing: border-box;
			box-sizing: border-box;
			float: left;
			margin-right: 30px;
			margin-bottom: 30px;
			width: calc((100% - 90px)/3);
			border-radius: 15px;
			box-shadow: 1px 1px 7px rgba(0,0,0,0.04);
			padding: 20px 25px;
			text-align: center;
			-webkit-transition:-webkit-transform 0.3s;
			-moz-transition:-moz-transform 0.3s;
			transition:transform 0.3s;   
			-webkit-transform: translateY(0);
			-moz-transform: translateY0);
			transform: translateY(0);
			min-height: 344px;
		 }
		.featured_plugin_main:hover{
			-webkit-transform: translateY(-2px);
			-moz-transform: translateY(-2px);
			transform: translateY(-2px);
		 }
		.featured_plugin_image{
			max-width: 128px;
			margin: 0 auto;
		}
		.blue_button{
    display: inline-block;
    font-size: 15px;
    text-decoration: none;
    border-radius: 5px;
    color: #ffffff;
    font-weight: 400;
    opacity: 1;
    -webkit-transition: opacity 0.3s;
    -moz-transition: opacity 0.3s;
    transition: opacity 0.3s;
    background-color: #7052fb;
    padding: 10px 22px;
    text-transform: uppercase;
		}
		.blue_button:hover,
		.blue_button:focus {
			color:#ffffff;
			box-shadow: none;
			outline: none;
		}
		.featured_plugin_image img{
			max-width: 100%;
		}
		.featured_plugin_image a{
		  display: inline-block;
		}
		.featured_plugin_information{	

		}
		.featured_plugin_title{
	color: #7052fb;
	font-size: 18px;
	display: inline-block;
		}
		.featured_plugin_title a{
	text-decoration:none;
	font-size: 19px;
    line-height: 22px;
	color: #7052fb;
					
		}
		.featured_plugin_title h4{
			margin: 0px;
			margin-top: 20px;		
			min-height: 44px;	
		}
		.featured_plugin_description{
			font-size: 14px;
				min-height: 63px;
		}
		@media screen and (max-width: 1460px){
			.featured_plugin_main {
				margin-right: 20px;
				margin-bottom: 20px;
				width: calc((100% - 60px)/3);
				padding: 20px 10px;
			}
			.featured_plugin_description {
				font-size: 13px;
				min-height: 63px;
			}
		}
		@media screen and (max-width: 1279px){
			.featured_plugin_main {
				width: calc((100% - 60px)/2);
				padding: 20px 20px;
				min-height: 363px;
			}	
		}
		@media screen and (max-width: 768px){
			.featured_plugin_main {
				width: calc(100% - 30px);
				padding: 20px 20px;
				min-height: auto;
				margin: 0 auto 20px;
				float: none;
			}	
			.featured_plugin_title h4{
				min-height: auto;
			}	
			.featured_plugin_description{
				min-height: auto;
					font-size: 14px;
			}	
		}

        </style>
      
		<h1 style="text-align: center;font-size: 50px;font-weight: 700;color: #2b2350;margin: 20px auto 25px;line-height: 1.2;">Featured Plugins</h1>
		<?php foreach($plugins_array as $key=>$plugin) { ?>
		<div class="featured_plugin_main">
			<div class="featured_plugin_image"><a target="_blank" href="<?php echo $plugin['site_url'] ?>"><img src="<?php echo $plugin['image_url'] ?>"></a></div>
			<div class="featured_plugin_information">
				<div class="featured_plugin_title"><h4><a target="_blank" href="<?php echo $plugin['site_url'] ?>"><?php echo $plugin['title'] ?></a></h4></div>
				<p class="featured_plugin_description"><?php echo $plugin['description'] ?></p>
				<a target="_blank" href="<?php echo $plugin['site_url'] ?>" class="blue_button">Check The Plugin</a>
			</div>
			<div style="clear:both"></div>                
		</div>
		<?php } 
	}
	
}
?>
