<?php
/*
* Plugin-Name: Product Designer App
* Plugin-URI: https://productdesignerapp.com
* Author: productdesignerapp
* Backend menus
*/

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

if(!class_exists('PDAPP_AdminMenus'))
{
	class PDAPP_AdminMenus
	{
		public function __construct()
		{
			add_action('admin_menu', array(&$this, 'pdapp_add_menu'));
			add_filter('plugin_action_links_'. PDAPP_BASE_NAME, array(&$this, 'pdapp_links'));
		}

		public function pdapp_add_menu()
		{
			add_menu_page(
				pdapp_lang('menu.pda', 'admin'),
				pdapp_lang('menu.pda', 'admin'),
				PDAPP_CAP_ACCESS,
				PDAPP_PLUGIN_SLUG,
				array($this, 'pdapp_dashboard'),
				PDAPP_PLUGIN_URL .'admin/assets/images/logo-menu.png'
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.dashboards', 'admin'),
				pdapp_lang('menu.dashboards', 'admin'),
				PDAPP_CAP_ACCESS,
				PDAPP_PLUGIN_SLUG,
				array($this, 'pdapp_dashboard')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.orders', 'admin'),
				pdapp_lang('menu.orders', 'admin'),
				PDAPP_CAP_ORDERS,
				PDAPP_PLUGIN_SLUG .'-orders',
				array($this, 'pdapp_orders')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.quotes', 'admin'),
				pdapp_lang('menu.quotes', 'admin'),
				PDAPP_CAP_QUOTES,
				PDAPP_PLUGIN_SLUG .'-quotes',
				array($this, 'pdapp_quotes')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.products', 'admin'),
				pdapp_lang('menu.products', 'admin'),
				PDAPP_CAP_PRODUCTS,
				PDAPP_PLUGIN_SLUG .'-products',
				array($this, 'pdapp_products')
			);
			
			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.arts', 'admin'),
				pdapp_lang('menu.arts', 'admin'),
				PDAPP_CAP_ARTS,
				PDAPP_PLUGIN_SLUG .'-arts',
				array($this, 'pdapp_arts')
			);
			
			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.templates', 'admin'),
				pdapp_lang('menu.templates', 'admin'),
				PDAPP_CAP_TEMPLATES,
				PDAPP_PLUGIN_SLUG .'-templates',
				array($this, 'pdapp_templates')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.printings', 'admin'),
				pdapp_lang('menu.printings', 'admin'),
				PDAPP_CAP_PRINTINGS,
				PDAPP_PLUGIN_SLUG .'-printings',
				array($this, 'pdapp_printings')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.addons', 'admin'),
				pdapp_lang('menu.addons', 'admin'),
				PDAPP_CAP_ADDONS,
				PDAPP_PLUGIN_SLUG .'-addons',
				array($this, 'pdapp_addons')
			);
			
			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.themes', 'admin'),
				pdapp_lang('menu.themes', 'admin'),
				PDAPP_CAP_THEMES,
				PDAPP_PLUGIN_SLUG .'-themes',
				array($this, 'pdapp_themes')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.settings', 'admin'),
				pdapp_lang('menu.settings', 'admin'),
				PDAPP_CAP_SETTINGS,
				PDAPP_PLUGIN_SLUG .'-settings',
				array($this, 'pdapp_settings')
			);

			add_submenu_page(
				PDAPP_PLUGIN_SLUG,
				pdapp_lang('menu.upgrades', 'admin'),
				pdapp_lang('menu.upgrades', 'admin'),
				PDAPP_CAP_UPGRADE,
				PDAPP_PLUGIN_SLUG .'-upgrade',
				array($this, 'pdapp_upgrade')
			);

			wp_enqueue_style('pdapp-menu-style', PDAPP_PLUGIN_URL . 'admin/assets/css/pdapp-menu.css', array(), PDAPP_VERSION, 'all');
		}
		
		public function pdapp_dashboard()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/dashboard/index.php';
		}

		public function pdapp_orders()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/orders/index.php';
		}

		public function pdapp_quotes()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/quotes/index.php';
		}

		public function pdapp_products()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/products/index.php';
		}
		
		public function pdapp_arts()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/arts/index.php';
		}
		
		public function pdapp_templates()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/templates/index.php';
		}

		public function pdapp_printings()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/printings/index.php';
		}

		public function pdapp_addons()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/addons/index.php';
		}
		
		public function pdapp_themes()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/themes/index.php';
		}
		
		public function pdapp_upgrade()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/upgrade/index.php';
		}
		
		public function pdapp_settings()
		{
			require PDAPP_ADMIN_PLUGIN_DIR .'pages/settings/index.php';
		}
		
		public function pdapp_links($links)
		{
			return array_merge(array(
				'<a href="'. PDAPP_HOME_URL .'/shop/woocommerce" target="_blank" style="color: #00a32a; font-weight: bold;">Upgrade to Pro</a>',
				'<a href="'. PDAPP_DOCS_URL .'/docs/wordpress" target="_blank">Docs</a>',
				'<a href="'. PDAPP_SITE_URL .'/wp-admin/admin.php?page='.PDAPP_PLUGIN_SLUG.'-settings" target="_blank">Settings</a>',
			), $links);
		}
	}
}

new PDAPP_AdminMenus();

?>