*/ if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } class Wpdirectorykit_Admin { /** * The ID of this plugin. * * @since 1.0.0 * @access private * @var string $plugin_name The ID of this plugin. */ private $plugin_name; /** * The version of this plugin. * * @since 1.0.0 * @access private * @var string $version The current version of this plugin. */ private $version; /** * Initialize the class and set its properties. * * @since 1.0.0 * @param string $plugin_name The name of this plugin. * @param string $version The version of this plugin. */ public function __construct( $plugin_name, $version ) { $this->plugin_name = $plugin_name; $this->version = $version; } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Wpdirectorykit_Loader as all of the hooks are defined * in that particular class. * * The Wpdirectorykit_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_register_style( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.css', array(), '1.0.0' ); wp_register_style( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/css/wdk-modal.css', array(), $this->version, 'all'); wp_register_style( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/css/wdk-notify.css', array(), $this->version, 'all'); wp_register_style( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.css', array(), '1.7.1', 'all' ); wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin.css', array(), $this->version, 'all' ); wp_enqueue_style( $this->plugin_name.'-responsive', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin-responsive.css', array(), $this->version, 'all' ); wp_register_style('jquery-ui', 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css', array(), null ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { /** * This function is provided for demonstration purposes only. * * An instance of this class should be passed to the run() function * defined in Wpdirectorykit_Loader as all of the hooks are defined * in that particular class. * * The Wpdirectorykit_Loader will then create the relationship * between the defined hooks and the functions defined in this * class. */ wp_register_script( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.js', array( 'jquery' ), false, false ); wp_register_script( 'wpmediaelement_file', WPDIRECTORYKIT_URL . 'admin/js/jquery.wpmediaelement_file.js', array( 'jquery' ), false, false ); wp_register_script( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/js/wdk-modal.js', array( 'jquery' ), $this->version, false); wp_register_script( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/js/wdk-notify.js', array( 'jquery' ), $this->version, false); wp_register_script( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.js', array( 'jquery' ), '1.7.1', false ); wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpdirectorykit-admin.js', array( 'jquery' ), $this->version, false ); } /** * Admin AJAX */ public function ajax_admin() { global $Winter_MVC_WDK; $page = ''; $function = ''; if(isset($_POST['page']))$page = sanitize_text_field($_POST['page']); if(isset($_POST['function']))$function = sanitize_text_field($_POST['function']); $Winter_MVC_WDK->load_controller($page, $function, array()); } /** * Admin Page Display */ public function admin_page_display() { global $Winter_MVC_WDK, $submenu, $menu; $page = ''; $function = ''; if(isset($_GET['page']))$page = sanitize_text_field($_GET['page']); if(isset($_GET['function']))$function = sanitize_text_field($_GET['function']); $Winter_MVC_WDK->load_controller($page, $function, array()); } /** * To add Plugin Menu and Settings page */ public function plugin_menu() { ob_start(); //require_once WPDIRECTORYKIT_PATH . 'vendor/boo-settings-helper/class-boo-settings-helper.php'; add_menu_page(__('Directory Kit','wpdirectorykit'), __('Directory Kit','wpdirectorykit'), 'manage_options', 'wdk', array($this, 'admin_page_display'), //plugin_dir_url( __FILE__ ) . 'resources/logo.png', 'dashicons-category', 28 ); add_submenu_page('wdk', __('Listings','wpdirectorykit'), __('Listings','wpdirectorykit'), 'manage_options', 'wdk', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Add Listing','wpdirectorykit'), __('Add Listing','wpdirectorykit'), 'manage_options', 'wdk_listing', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Fields','wpdirectorykit'), __('Fields','wpdirectorykit'), 'manage_options', 'wdk_fields', array($this, 'admin_page_display')); if(get_option('wdk_is_category_enabled', FALSE)) add_submenu_page('wdk', __('Categories','wpdirectorykit'), __('Categories','wpdirectorykit'), 'manage_options', 'wdk_category', array($this, 'admin_page_display')); if(get_option('wdk_is_location_enabled', FALSE)) add_submenu_page('wdk', __('Locations','wpdirectorykit'), __('Locations','wpdirectorykit'), 'manage_options', 'wdk_location', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Search Form','wpdirectorykit'), __('Search Form','wpdirectorykit'), 'manage_options', 'wdk_searchform', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Result Card','wpdirectorykit'), __('Result Card','wpdirectorykit'), 'manage_options', 'wdk_resultitem', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Change Currency','wpdirectorykit'), __('Change Currency','wpdirectorykit'), 'manage_options', 'wdk_change_currency', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Messages','wpdirectorykit'), __('Messages','wpdirectorykit'), 'manage_options', 'wdk_messages', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Settings','wpdirectorykit'), __('Settings','wpdirectorykit'), 'manage_options', 'wdk_settings', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Documentation','wpdirectorykit'), __('Documentation','wpdirectorykit'), 'manage_options', 'https://wpdirectorykit.com/documentation'); if(!file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') || defined('WDK_FS_DISABLE')) { if(!file_exists(WP_PLUGIN_DIR.'/wdk-currency-conversion') || !is_plugin_active( 'wdk-currency-conversion/wdk-currency-conversion.php' )) add_submenu_page('wdk', __('Currencies Addon','wpdirectorykit'), __('Currencies Addon','wpdirectorykit'), 'manage_options', 'wdk_addons_currencies', array($this, 'admin_page_display')); if(!file_exists(WP_PLUGIN_DIR.'/wdk-membership') || !is_plugin_active( 'wdk-membership/wdk-membership.php' )) add_submenu_page('wdk', __('Membership Addon','wpdirectorykit'), __('Membership Addon','wpdirectorykit'), 'manage_options', 'wdk_addons_membership', array($this, 'admin_page_display')); if(!file_exists(WP_PLUGIN_DIR.'/wdk-bookings') || !is_plugin_active( 'wdk-bookings/wdk-bookings.php' )) add_submenu_page('wdk', __('Booking Addon','wpdirectorykit'), __('Booking Addon','wpdirectorykit'), 'manage_options', 'wdk_addons_bookings', array($this, 'admin_page_display')); add_submenu_page('wdk', __('More Addons','wpdirectorykit'), __('More Addons','wpdirectorykit'), 'manage_options', 'wdk_addons', array($this, 'admin_page_display')); add_submenu_page('wdk', __('Support Forum','wpdirectorykit'), __('Support Forum','wpdirectorykit'), 'manage_options', 'https://wordpress.org/support/plugin/wpdirectorykit/'); add_submenu_page('wdk', __('Contact','wpdirectorykit'), __('Contact','wpdirectorykit'), 'manage_options', 'https://wpdirectorykit.com/contact.html'); } } }