<?php
/*
Plugin Name: Find Us Page Plugin
Description: A Plugin to set find us locations 
Author: The App Concept | Yasmine
Version: 0.1
*/

//Direct access to this file is not permitted
if (!defined('ABSPATH')){
    exit("Do not access this file directly.");
}


define('FIND_US_PATH', dirname(__FILE__) . '/');
define('FIND_US_URL', plugins_url('', __FILE__));
define('FIND_US_DIRNAME', dirname(plugin_basename(__FILE__)));
    

add_action('admin_menu', 'findus_plugin_setup_menu');
function findus_plugin_setup_menu(){

    add_menu_page('Find Us Page', 'Find Us Page', 'manage_options', 'findus-plugin','findus_init');
	add_submenu_page( 'findus-plugin', 'My Custom Page', 'List all',
    'manage_options', 'findus-plugin','findus_init');
	add_submenu_page( 'findus-plugin', 'Add New City', 'Add New City',
    'manage_options', 'add-city-slug','add_city_func');
    add_submenu_page( 'findus-plugin', 'Add New location', 'Add New location',
    'manage_options', 'add-loc-slug','add_loc_func');

}

register_activation_hook( __FILE__, 'activate');
function activate(){

   include(FIND_US_PATH .'classes/class.mq-installation.php');
   MqInstallation::run_safe_installer();

}
 
function findus_init(){
   include('backend/list_city.php');
}

function add_city_func(){
   include('classes/class_cities_add.php');
   $cities = new Cities();
   $cities->handle_cities_menu();

}

function add_loc_func(){
    include('classes/class_locations_add.php');
   $locations = new Locations();
   $locations->handle_locations_menu();

}
   

function findus_list(){
   ob_start();
   include_once(FIND_US_PATH.'frontend/findus_list.php');
   return ob_get_clean();
}
add_shortcode('findus_list', 'findus_list');