File: /home/dh_6nhrpv/callhare.com/wp-content/plugins/rank-assassin/includes/RankAssassinCore.php
<?php
/**
* @package RankAssassin
*/
defined( 'ABSPATH' ) or die( 'Looks like someone just took a headshot!' );
require_once plugin_dir_path( __FILE__ ) . 'RankAssassinCityComponents.php';
require_once plugin_dir_path( __FILE__ ) . 'RankAssassinNeighborhoodComponents.php';
require_once plugin_dir_path( __FILE__ ) . 'RankAssassinAppsero.php';
// require ajax handlers
require_once plugin_dir_path( __FILE__ ) . '../admin/ajax-handlers.php';
if (!function_exists('get_plugin_data')) {
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
class RankAssassinCore {
private $plugin_data;
private $city_components_controller;
private $nb_components_controller;
private $appsero_controller;
function __construct() {
$this->plugin_data = get_plugin_data( plugin_dir_path( __FILE__ ) . '../rank-assassin.php' );
$this->create_res_dir();
/**
* initialize rank assassin city components
*/
$this->city_components_controller = new RankAssassinCityComponents();
$this->nb_components_controller = new RankAssassinNeighborhoodComponents();
/**
* Appsero controller
*/
$this->appsero_controller = new RankAssassinAppsero();
/**
* call shortcode initialization
*/
add_action('init', array($this, 'init_city_shortcodes'));
add_action('init', array($this, 'init_neighborhood_shortcodes'));
/**
* load city component styles to frontend
*/
add_action( 'wp_head', array($this, 'load_components_resources'));
add_action( 'admin_menu', array($this, 'initialize_pages'));
add_action('admin_enqueue_scripts', array($this, 'main_dashboard_resources'));
}
/**
* @Desc: resources folder at uploads/rank-local
*/
private function create_res_dir() {
$dir_path = WP_CONTENT_DIR . '/uploads/rank-assassin';
if (!file_exists($dir_path)) {
if (!wp_mkdir_p($dir_path)) {
echo 'Failed to create the directory: ' . $dir_path;
exit;
}
}
}
/**
* @Desc: initializes all rank assassin pages
*/
public function initialize_pages() {
/**
* @Desc: Menu Item: Locations
*/
add_menu_page(
"Rank Assassin Dashboard",
"Rank Assassin",
'manage_options',
"rank-assassin-dashboard",
array($this, 'load_main_dashboard'),
plugin_dir_url(__FILE__) . '../config/admin-menu-icon.svg',
6
);
add_submenu_page(
"rank-assassin-dashboard",
"Rank Assassin Styling",
'Styling',
'manage_options',
"admin.php?page=rank-assassin-dashboard#styling",
null,
);
add_submenu_page(
"rank-assassin-dashboard",
"Rank Assassin Settings",
'Settings',
'manage_options',
"admin.php?page=rank-assassin-dashboard#settings",
null,
);
// REVIEW Activate this code if you need the custom licensing page
/* add_submenu_page(
"rank-assassin-dashboard",
"Rank Assassin Licensing",
'Licensing',
'manage_options',
"admin.php?page=rank-assassin-dashboard#license",
null,
); */
add_submenu_page(
"rank-assassin-dashboard",
"Rank Assassin Support",
'Support',
'manage_options',
"admin.php?page=rank-assassin-dashboard#support",
null,
);
}
/**
* @Desc: Load requested admin pages
*/
public function load_main_dashboard() {
include_once plugin_dir_path(__FILE__) . '../admin/pages/php/main-dashboard.php';
}
/**
* @Desc: load main dashboard js and css file
*/
public function main_dashboard_resources() {
wp_enqueue_style('ra-main-dashboard-style', plugin_dir_url(__FILE__) . '../admin/pages/styles/main-dashboard.css', array(), $this->plugin_data['Version']);
}
/**
* @Desc: initilize city components shortcodes
*/
public function init_city_shortcodes() {
if(!$this->appsero_controller->appsero_check_license()) return;
add_shortcode('rank_assassin_weather', array($this->city_components_controller, 'weather_component'));
add_shortcode('rank_assassin_about', array($this->city_components_controller, 'about_component'));
add_shortcode('rank_assassin_neighborhoods', array($this->city_components_controller, 'neighborhoods_component'));
add_shortcode('rank_assassin_thingstodo', array($this->city_components_controller, 'thingstodo_component'));
add_shortcode('rank_assassin_busstops', array($this->city_components_controller, 'busstops_component'));
add_shortcode('rank_assassin_drivingdirections', array($this->city_components_controller, 'drivingdirections_component'));
add_shortcode('rank_assassin_mapembed', array($this->city_components_controller, 'mapembed_component'));
}
/**
* @Desc: initilize city components shortcodes
*/
public function init_neighborhood_shortcodes() {
if(!$this->appsero_controller->appsero_check_license()) return;
add_shortcode('rank_assassin_nb_content', array($this->nb_components_controller, 'content_component'));
add_shortcode('rank_assassin_nb_services', array($this->nb_components_controller, 'services_component'));
add_shortcode('rank_assassin_nb_about', array($this->nb_components_controller, 'about_component'));
add_shortcode('rank_assassin_nb_drivingdirections', array($this->nb_components_controller, 'drivingdirections_component'));
add_shortcode('rank_assassin_nb_linktonext', array($this->nb_components_controller, 'linktonext_component'));
}
/**
* @Load component scripts/styles on the frontend
*/
public function load_components_resources() {
wp_enqueue_style('ra-components-style', plugin_dir_url(__FILE__) . '../public/styles/default_city_components_styles.css', array(), $this->plugin_data['Version']);
wp_enqueue_script('ra-components-script', plugin_dir_url(__FILE__) . '../public/js/city_component_scripts.js', array(), $this->plugin_data['Version'], true);
wp_enqueue_style('ra-nb-components-style', plugin_dir_url(__FILE__) . '../public/styles/default_nb_components_styles.css', array(), $this->plugin_data['Version']);
}
}