| @@ -20,333 +20,472 @@ | ||
| 20 | 20 | * @subpackage Wpdirectorykit/admin |
| 21 | 21 | * @author listing-themes.com <[email protected]> |
| 22 | 22 | */ |
| 23 | 23 | |
| 24 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 25 | - exit; // Exit if accessed directly. | |
| 24 | +if (! defined('ABSPATH')) { | |
| 25 | + exit; // Exit if accessed directly. | |
| 26 | 26 | } |
| 27 | -class Wpdirectorykit_Admin { | |
| 27 | +class Wpdirectorykit_Admin | |
| 28 | +{ | |
| 28 | 29 | |
| 29 | - /** | |
| 30 | - * The ID of this plugin. | |
| 31 | - * | |
| 32 | - * @since 1.0.0 | |
| 33 | - * @access private | |
| 34 | - * @var string $plugin_name The ID of this plugin. | |
| 35 | - */ | |
| 36 | - private $plugin_name; | |
| 30 | + /** | |
| 31 | + * The ID of this plugin. | |
| 32 | + * | |
| 33 | + * @since 1.0.0 | |
| 34 | + * @access private | |
| 35 | + * @var string $plugin_name The ID of this plugin. | |
| 36 | + */ | |
| 37 | + private $plugin_name; | |
| 37 | 38 | |
| 38 | - /** | |
| 39 | - * The version of this plugin. | |
| 40 | - * | |
| 41 | - * @since 1.0.0 | |
| 42 | - * @access private | |
| 43 | - * @var string $version The current version of this plugin. | |
| 44 | - */ | |
| 45 | - private $version; | |
| 39 | + /** | |
| 40 | + * The version of this plugin. | |
| 41 | + * | |
| 42 | + * @since 1.0.0 | |
| 43 | + * @access private | |
| 44 | + * @var string $version The current version of this plugin. | |
| 45 | + */ | |
| 46 | + private $version; | |
| 46 | 47 | |
| 47 | - /** | |
| 48 | - * Initialize the class and set its properties. | |
| 49 | - * | |
| 50 | - * @since 1.0.0 | |
| 51 | - * @param string $plugin_name The name of this plugin. | |
| 52 | - * @param string $version The version of this plugin. | |
| 53 | - */ | |
| 54 | - public function __construct( $plugin_name, $version ) { | |
| 48 | + /** | |
| 49 | + * Initialize the class and set its properties. | |
| 50 | + * | |
| 51 | + * @since 1.0.0 | |
| 52 | + * @param string $plugin_name The name of this plugin. | |
| 53 | + * @param string $version The version of this plugin. | |
| 54 | + */ | |
| 55 | + public function __construct($plugin_name, $version) | |
| 56 | + { | |
| 55 | 57 | |
| 56 | - $this->plugin_name = $plugin_name; | |
| 57 | - $this->version = $version; | |
| 58 | + $this->plugin_name = $plugin_name; | |
| 59 | + $this->version = $version; | |
| 60 | + } | |
| 58 | 61 | |
| 59 | - } | |
| 62 | + /** | |
| 63 | + * Register the stylesheets for the admin area. | |
| 64 | + * | |
| 65 | + * @since 1.0.0 | |
| 66 | + */ | |
| 67 | + public function enqueue_styles() | |
| 68 | + { | |
| 60 | 69 | |
| 61 | - /** | |
| 62 | - * Register the stylesheets for the admin area. | |
| 63 | - * | |
| 64 | - * @since 1.0.0 | |
| 65 | - */ | |
| 66 | - public function enqueue_styles() { | |
| 70 | + /** | |
| 71 | + * This function is provided for demonstration purposes only. | |
| 72 | + * | |
| 73 | + * An instance of this class should be passed to the run() function | |
| 74 | + * defined in Wpdirectorykit_Loader as all of the hooks are defined | |
| 75 | + * in that particular class. | |
| 76 | + * | |
| 77 | + * The Wpdirectorykit_Loader will then create the relationship | |
| 78 | + * between the defined hooks and the functions defined in this | |
| 79 | + * class. | |
| 80 | + */ | |
| 67 | 81 | |
| 68 | - /** | |
| 69 | - * This function is provided for demonstration purposes only. | |
| 70 | - * | |
| 71 | - * An instance of this class should be passed to the run() function | |
| 72 | - * defined in Wpdirectorykit_Loader as all of the hooks are defined | |
| 73 | - * in that particular class. | |
| 74 | - * | |
| 75 | - * The Wpdirectorykit_Loader will then create the relationship | |
| 76 | - * between the defined hooks and the functions defined in this | |
| 77 | - * class. | |
| 78 | - */ | |
| 82 | + wp_register_style('wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.css', array(), '1.0.0'); | |
| 83 | + wp_register_style('wdk-modal', WPDIRECTORYKIT_URL . 'public/css/wdk-modal.css', array(), $this->version, 'all'); | |
| 84 | + wp_register_style('wdk-notify', WPDIRECTORYKIT_URL . 'public/css/wdk-notify.css', array(), $this->version, 'all'); | |
| 85 | + wp_register_style('leaflet', WPDIRECTORYKIT_URL . 'public/js/openstreetmap/leaflet.css', array(), '1.7.1', 'all'); | |
| 86 | + wp_register_style('leaflet-cluster-def', WPDIRECTORYKIT_URL . 'public/js/openstreetmap/MarkerCluster.Default.css', array(), '1.7.1', 'all'); | |
| 87 | + wp_register_style('leaflet-cluster', WPDIRECTORYKIT_URL . 'public/js/openstreetmap/MarkerCluster.css', array(), '1.7.1', 'all'); | |
| 79 | 88 | |
| 80 | - wp_register_style( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.css', array(), '1.0.0' ); | |
| 81 | - wp_register_style( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/css/wdk-modal.css', array(), $this->version, 'all'); | |
| 82 | - wp_register_style( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/css/wdk-notify.css', array(), $this->version, 'all'); | |
| 83 | - wp_register_style( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.css', array(), '1.7.1', 'all' ); | |
| 84 | - wp_register_style( 'leaflet-cluster-def', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/MarkerCluster.Default.css', array(), '1.7.1', 'all' ); | |
| 85 | - wp_register_style( 'leaflet-cluster', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/MarkerCluster.css', array(), '1.7.1', 'all' ); | |
| 89 | + wp_register_style('select2-select2', WPDIRECTORYKIT_URL . 'public/js/select2/css/select2.min.css', array(), '4.0.13', 'all'); | |
| 90 | + wp_register_style('jquery-confirm', WPDIRECTORYKIT_URL . 'public/js/jquery-confirm/css/jquery-confirm.css', array(), '3.3.4', 'all'); | |
| 86 | 91 | |
| 87 | - wp_register_style( 'select2', WPDIRECTORYKIT_URL. 'public/js/select2/css/select2.min.css', array(), '4.0.13', 'all' ); | |
| 88 | - wp_register_style('jquery-confirm', WPDIRECTORYKIT_URL. 'public/js/jquery-confirm/css/jquery-confirm.css', array(), '3.3.4', 'all'); | |
| 92 | + wp_register_style('wdk-treefield-dropdown', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.css', array(), '1.0', 'all'); | |
| 89 | 93 | |
| 90 | - wp_register_style( 'wdk-treefield-dropdown', WPDIRECTORYKIT_URL. 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.css', array(), '1.0', 'all' ); | |
| 94 | + wp_enqueue_style($this->plugin_name, plugin_dir_url(__FILE__) . 'css/wpdirectorykit-admin.css', array(), $this->version, 'all'); | |
| 95 | + wp_enqueue_style($this->plugin_name . '-responsive', plugin_dir_url(__FILE__) . 'css/wpdirectorykit-admin-responsive.css', array(), $this->version, 'all'); | |
| 96 | + wp_register_style('jquery-ui', WPDIRECTORYKIT_URL . 'public/css/jquery-ui.css', array(), null); | |
| 91 | 97 | |
| 92 | - wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin.css', array(), $this->version, 'all' ); | |
| 93 | - wp_enqueue_style( $this->plugin_name.'-responsive', plugin_dir_url( __FILE__ ) . 'css/wpdirectorykit-admin-responsive.css', array(), $this->version, 'all' ); | |
| 94 | - wp_register_style('jquery-ui', WPDIRECTORYKIT_URL. 'public/css/jquery-ui.css', array(), null ); | |
| 95 | - } | |
| 98 | + // Register and enqueue Tribute.js style | |
| 99 | + wp_register_style( | |
| 100 | + 'tribute-css', | |
| 101 | + WPDIRECTORYKIT_URL . 'public/js/tribute/tribute.css', | |
| 102 | + [], | |
| 103 | + '5.1.3' | |
| 104 | + ); | |
| 105 | + | |
| 106 | + | |
| 107 | + } | |
| 96 | 108 | |
| 97 | - /** | |
| 98 | - * Register the JavaScript for the admin area. | |
| 99 | - * | |
| 100 | - * @since 1.0.0 | |
| 101 | - */ | |
| 102 | - public function enqueue_scripts() { | |
| 109 | + /** | |
| 110 | + * Register the JavaScript for the admin area. | |
| 111 | + * | |
| 112 | + * @since 1.0.0 | |
| 113 | + */ | |
| 114 | + public function enqueue_scripts() | |
| 115 | + { | |
| 103 | 116 | |
| 104 | - /** | |
| 105 | - * This function is provided for demonstration purposes only. | |
| 106 | - * | |
| 107 | - * An instance of this class should be passed to the run() function | |
| 108 | - * defined in Wpdirectorykit_Loader as all of the hooks are defined | |
| 109 | - * in that particular class. | |
| 110 | - * | |
| 111 | - * The Wpdirectorykit_Loader will then create the relationship | |
| 112 | - * between the defined hooks and the functions defined in this | |
| 113 | - * class. | |
| 114 | - */ | |
| 117 | + /** | |
| 118 | + * This function is provided for demonstration purposes only. | |
| 119 | + * | |
| 120 | + * An instance of this class should be passed to the run() function | |
| 121 | + * defined in Wpdirectorykit_Loader as all of the hooks are defined | |
| 122 | + * in that particular class. | |
| 123 | + * | |
| 124 | + * The Wpdirectorykit_Loader will then create the relationship | |
| 125 | + * between the defined hooks and the functions defined in this | |
| 126 | + * class. | |
| 127 | + */ | |
| 115 | 128 | |
| 116 | - wp_register_script( 'wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.js', array( 'jquery' ), false, false ); | |
| 117 | - wp_register_script( 'wpmediaelement_file', WPDIRECTORYKIT_URL . 'admin/js/jquery.wpmediaelement_file.js', array( 'jquery' ), false, false ); | |
| 118 | - | |
| 119 | - wp_register_script( 'wdk-modal', WPDIRECTORYKIT_URL. 'public/js/wdk-modal.js', array( 'jquery' ), $this->version, false); | |
| 120 | - wp_register_script( 'wdk-notify', WPDIRECTORYKIT_URL. 'public/js/wdk-notify.js', array( 'jquery' ), $this->version, false); | |
| 121 | - wp_register_script( 'leaflet', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.js', array( 'jquery' ), '1.7.1', false ); | |
| 122 | - | |
| 123 | - wp_register_script( 'leaflet-cluster', WPDIRECTORYKIT_URL. 'public/js/openstreetmap/leaflet.markercluster.js', array( 'jquery' ), '1.7.1', false ); | |
| 129 | + | |
| 130 | + // Register and enqueue Tribute.js script | |
| 131 | + wp_register_script( | |
| 132 | + 'tribute-js', | |
| 133 | + WPDIRECTORYKIT_URL . 'public/js/tribute/tribute.min.js', | |
| 134 | + [], | |
| 135 | + '5.1.3', | |
| 136 | + true | |
| 137 | + ); | |
| 138 | + | |
| 124 | 139 | |
| 140 | + wp_register_script('wdk-treefield', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield/treefield.js', array('jquery'), false, false); | |
| 141 | + wp_register_script('wpmediaelement_file', WPDIRECTORYKIT_URL . 'admin/js/jquery.wpmediaelement_file.js', array('jquery'), false, false); | |
| 125 | 142 | |
| 126 | - wp_register_script('select2', WPDIRECTORYKIT_URL. 'public/js/select2/js/select2.min.js', array( 'jquery' ), '4.0.13', false ); | |
| 127 | - wp_register_script('wdk-select2', WPDIRECTORYKIT_URL. 'public/js/wdk-select2.js', array( 'jquery' ), '4.0.13', false ); | |
| 143 | + wp_register_script('wdk-modal', WPDIRECTORYKIT_URL . 'public/js/wdk-modal.js', array('jquery'), $this->version, false); | |
| 144 | + wp_register_script('wdk-notify', WPDIRECTORYKIT_URL . 'public/js/wdk-notify.js', array('jquery'), $this->version, false); | |
| 145 | + wp_register_script('leaflet', WPDIRECTORYKIT_URL . 'public/js/openstreetmap/leaflet.js', array('jquery'), '1.7.1', false); | |
| 128 | 146 | |
| 129 | - wp_register_script('jquery-confirm', WPDIRECTORYKIT_URL. 'public/js/jquery-confirm/js/jquery-confirm.js', array( 'jquery' ), '3.3.4', false ); | |
| 130 | - wp_register_script( 'wdk-dependfields-submitform', WPDIRECTORYKIT_URL. 'public/js/wdk-dependfields-submitform.js', array( 'jquery' ), false, false ); | |
| 147 | + wp_register_script('leaflet-cluster', WPDIRECTORYKIT_URL . 'public/js/openstreetmap/leaflet.markercluster.js', array('jquery'), '1.7.1', false); | |
| 131 | 148 | |
| 132 | - $params = array( | |
| 133 | - 'ajax_url' => admin_url( 'admin-ajax.php' ) | |
| 149 | + | |
| 150 | + wp_register_script('select2-select2', WPDIRECTORYKIT_URL . 'public/js/select2/js/select2.min.js', array('jquery'), '4.0.13', false); | |
| 151 | + wp_register_script('wdk-select2', WPDIRECTORYKIT_URL . 'public/js/wdk-select2.js', array('jquery'), '4.0.13', false); | |
| 152 | + | |
| 153 | + $params = array( | |
| 154 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 155 | + 'text' => array( | |
| 156 | + 'errorLoading' => esc_html__('The results could not be loaded.', 'wpdirectorykit'), | |
| 157 | + 'loadingMore' => esc_html__('Loading more results…', 'wpdirectorykit'), | |
| 158 | + 'noResults' => esc_html__('No results found', 'wpdirectorykit'), | |
| 159 | + 'searching' => esc_html__('Searching…', 'wpdirectorykit'), | |
| 160 | + 'removeAllItems' => esc_html__('Remove all items', 'wpdirectorykit'), | |
| 161 | + "read_more"=> esc_html__("Read More", 'wpdirectorykit'), | |
| 162 | + "read_less"=> esc_html__("Read Less", 'wpdirectorykit'), | |
| 163 | + ), | |
| 164 | + 'wpApiSettings' => [ | |
| 165 | + 'root'=> esc_url_raw(rest_url()), | |
| 166 | + 'nonce'=> wp_create_nonce('wp_rest'), | |
| 167 | + 'wdk_secure_nonce'=> wp_create_nonce('wdk_secure_ajax'), | |
| 168 | + ] | |
| 134 | 169 | ); |
| 135 | - wp_register_script('wdk-treefield-dropdown', WPDIRECTORYKIT_URL. 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.js', array( 'jquery' ), '1.0', false ); | |
| 136 | - wp_localize_script( 'wdk-treefield-dropdown', 'script_parameters', $params); | |
| 170 | + wp_localize_script('wdk-select2', 'wdk_select2_script_parameters', $params); | |
| 137 | 171 | |
| 138 | - wp_register_script( 'wdk-dependfields-edit', plugin_dir_url( __FILE__ ) . 'js/wdk-dependfields-edit.js', array( 'jquery' ), $this->version, false ); | |
| 172 | + wp_register_script('jquery-confirm', WPDIRECTORYKIT_URL . 'public/js/jquery-confirm/js/jquery-confirm.js', array('jquery'), '3.3.4', false); | |
| 173 | + wp_register_script('wdk-dependfields-submitform', WPDIRECTORYKIT_URL . 'public/js/wdk-dependfields-submitform.js', array('jquery'), false, false); | |
| 174 | + | |
| 175 | + wp_register_script('wdk-treefield-dropdown', WPDIRECTORYKIT_URL . 'public/js/wdk_treefield_dropdown/wdk_treefield_dropdown.js', array('jquery'), '1.0', false); | |
| 176 | + wp_localize_script('wdk-treefield-dropdown', 'script_parameters', $params); | |
| 177 | + wp_localize_script('wdk-treefield-dropdown', 'wdk_script_parameters', $params); | |
| 178 | + | |
| 179 | + wp_register_script('wdk-dependfields-edit', plugin_dir_url(__FILE__) . 'js/wdk-dependfields-edit.js', array('jquery'), $this->version, false); | |
| 139 | 180 | $params = array( |
| 140 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 181 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 141 | 182 | ); |
| 142 | 183 | |
| 143 | 184 | wp_localize_script('wdk-dependfields-edit', 'script_dependfields_parameters', $params); |
| 144 | - | |
| 145 | - $params = array( | |
| 146 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), | |
| 147 | - 'format_date' => wdk_convert_date_format_js(get_option('date_format')), | |
| 148 | - 'format_datetime' => wdk_convert_date_format_js(get_option('date_format').' '.get_option('time_format')), | |
| 149 | - 'format_date_js' => wdk_convert_date_format_jquery(get_option('date_format')), | |
| 150 | - 'format_datetime_js' => wdk_convert_date_format_jquery(get_option('date_format').' '.get_option('time_format')), | |
| 185 | + | |
| 186 | + $params = array( | |
| 187 | + 'ajax_url' => admin_url('admin-ajax.php'), | |
| 188 | + 'format_date' => wdk_convert_date_format_js(get_option('date_format')), | |
| 189 | + 'format_datetime' => wdk_convert_date_format_js(get_option('date_format') . ' ' . get_option('time_format')), | |
| 190 | + 'format_date_js' => wdk_convert_date_format_jquery(get_option('date_format')), | |
| 191 | + 'format_datetime_js' => wdk_convert_date_format_jquery(get_option('date_format') . ' ' . get_option('time_format')), | |
| 192 | + 'text' => array( | |
| 193 | + "read_more"=> esc_html__("Read More", 'wpdirectorykit'), | |
| 194 | + "read_less"=> esc_html__("Read Less", 'wpdirectorykit'), | |
| 195 | + ), | |
| 196 | + 'wpApiSettings' => [ | |
| 197 | + 'root'=> esc_url_raw(rest_url()), | |
| 198 | + 'nonce'=> wp_create_nonce('wp_rest'), | |
| 199 | + 'wdk_secure_nonce'=> wp_create_nonce('wdk_secure_ajax'), | |
| 200 | + ] | |
| 151 | 201 | ); |
| 152 | - wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/wpdirectorykit-admin.js', array( 'jquery' ), $this->version, false ); | |
| 153 | - wp_localize_script( $this->plugin_name, 'script_parameters', $params); | |
| 154 | - | |
| 155 | - | |
| 202 | + wp_enqueue_script($this->plugin_name, plugin_dir_url(__FILE__) . 'js/wpdirectorykit-admin.js', array('jquery'), $this->version, false); | |
| 203 | + wp_localize_script($this->plugin_name, 'script_parameters', $params); | |
| 204 | + wp_localize_script($this->plugin_name, 'wdk_script_parameters', $params); | |
| 205 | + | |
| 156 | 206 | } |
| 157 | 207 | |
| 158 | - /** | |
| 159 | - * Admin AJAX | |
| 160 | - */ | |
| 208 | + /** | |
| 209 | + * Admin AJAX | |
| 210 | + */ | |
| 161 | 211 | |
| 162 | - public function ajax_admin() | |
| 163 | - { | |
| 164 | - global $Winter_MVC_WDK; | |
| 212 | + public function ajax_admin() | |
| 213 | + { | |
| 214 | + global $Winter_MVC_WDK; | |
| 165 | 215 | |
| 166 | - $page = ''; | |
| 167 | - $function = ''; | |
| 216 | + $page = ''; | |
| 217 | + $function = ''; | |
| 168 | 218 | |
| 169 | - if(isset($_POST['page']))$page = sanitize_text_field($_POST['page']); | |
| 170 | - if(isset($_POST['function']))$function = sanitize_text_field($_POST['function']); | |
| 219 | + if (isset($_POST['page'])) $page = sanitize_text_field($_POST['page']); | |
| 220 | + if (isset($_POST['function'])) $function = sanitize_text_field($_POST['function']); | |
| 171 | 221 | |
| 172 | - $Winter_MVC_WDK->load_controller($page, $function, array()); | |
| 173 | - } | |
| 222 | + /* protect access only to ajax controller */ | |
| 223 | + if($page != 'wdk_frontendajax' && $page != 'wdk_backendajax' && $page != 'wdk_fields') { | |
| 224 | + exit(esc_html__('Access denied','wpdirectorykit')); | |
| 225 | + } | |
| 174 | 226 | |
| 227 | + | |
| 228 | + $Winter_MVC_WDK->load_controller($page, $function, array()); | |
| 229 | + } | |
| 230 | + | |
| 175 | 231 | /** |
| 176 | - * Admin Page Display | |
| 177 | - */ | |
| 178 | - public function admin_page_display() { | |
| 179 | - global $Winter_MVC_WDK, $submenu, $menu; | |
| 232 | + * Admin Page Display | |
| 233 | + */ | |
| 234 | + public function admin_page_display() | |
| 235 | + { | |
| 236 | + global $Winter_MVC_WDK, $submenu, $menu; | |
| 180 | 237 | |
| 181 | - $page = ''; | |
| 238 | + $page = ''; | |
| 182 | 239 | $function = ''; |
| 183 | 240 | |
| 184 | - if(isset($_GET['page']))$page = sanitize_text_field($_GET['page']); | |
| 185 | - if(isset($_GET['function']))$function = sanitize_text_field($_GET['function']); | |
| 241 | + if (isset($_GET['page'])) $page = sanitize_text_field(wp_unslash($_GET['page'])); | |
| 242 | + if (isset($_GET['function'])) $function = sanitize_text_field(wp_unslash($_GET['function'])); | |
| 186 | 243 | |
| 187 | - if(substr($function,0,1) == '_') { | |
| 188 | - exit(esc_html__('blocked for public', 'wpdirectorykit')); | |
| 189 | - } | |
| 244 | + if (substr($function, 0, 1) == '_') { | |
| 245 | + exit(esc_html__('blocked for public', 'wpdirectorykit')); | |
| 246 | + } | |
| 190 | 247 | |
| 191 | - $Winter_MVC_WDK->load_controller($page, $function, array()); | |
| 192 | - } | |
| 248 | + $Winter_MVC_WDK->load_controller($page, $function, array()); | |
| 249 | + } | |
| 193 | 250 | |
| 194 | - private function multilingual_register_strings() | |
| 195 | - { | |
| 196 | - if (!function_exists('PLL'))return; | |
| 251 | + private function multilingual_register_strings() | |
| 252 | + { | |
| 253 | + if (!function_exists('PLL')) return; | |
| 197 | 254 | |
| 198 | - global $Winter_MVC_WDK; | |
| 199 | - $Winter_MVC_WDK->model('field_m'); | |
| 200 | - $Winter_MVC_WDK->model('category_m'); | |
| 201 | - $Winter_MVC_WDK->model('location_m'); | |
| 255 | + global $Winter_MVC_WDK; | |
| 256 | + $Winter_MVC_WDK->model('field_m'); | |
| 257 | + $Winter_MVC_WDK->model('category_m'); | |
| 258 | + $Winter_MVC_WDK->model('location_m'); | |
| 202 | 259 | |
| 203 | 260 | $fields = $Winter_MVC_WDK->field_m->get(); |
| 204 | 261 | |
| 205 | - foreach($fields as $field) | |
| 206 | - { | |
| 207 | - if(!empty($field->field_label)) | |
| 208 | - pll_register_string( 'wpdirectorykit', $field->field_label, 'wdk-fields'); | |
| 209 | - | |
| 210 | - if(!empty($field->values_list)) | |
| 211 | - pll_register_string( 'wpdirectorykit', $field->values_list, 'wdk-fields'); | |
| 212 | - | |
| 213 | - if(!empty($field->hint)) | |
| 214 | - pll_register_string( 'wpdirectorykit', $field->hint, 'wdk-fields'); | |
| 262 | + foreach ($fields as $field) { | |
| 263 | + if (!empty($field->field_label)) | |
| 264 | + pll_register_string('wpdirectorykit', $field->field_label, 'wdk-fields'); | |
| 265 | + | |
| 266 | + if (!empty($field->values_list)) | |
| 267 | + pll_register_string('wpdirectorykit', $field->values_list, 'wdk-fields'); | |
| 268 | + | |
| 269 | + if (!empty($field->hint)) | |
| 270 | + pll_register_string('wpdirectorykit', $field->hint, 'wdk-fields'); | |
| 215 | 271 | } |
| 216 | 272 | |
| 217 | 273 | $categories = $Winter_MVC_WDK->category_m->get_tree_table(); |
| 218 | 274 | |
| 219 | - foreach($categories as $category) | |
| 220 | - { | |
| 221 | - pll_register_string( 'wpdirectorykit', $category->category_title, 'wdk-categories'); | |
| 275 | + foreach ($categories as $category) { | |
| 276 | + pll_register_string('wpdirectorykit', $category->category_title, 'wdk-categories'); | |
| 222 | 277 | } |
| 223 | 278 | |
| 224 | 279 | $locations = $Winter_MVC_WDK->location_m->get_tree_table(); |
| 225 | 280 | |
| 226 | - foreach($locations as $location) | |
| 227 | - { | |
| 228 | - pll_register_string( 'wpdirectorykit', $location->location_title, 'wdk-locations'); | |
| 281 | + foreach ($locations as $location) { | |
| 282 | + pll_register_string('wpdirectorykit', $location->location_title, 'wdk-locations'); | |
| 229 | 283 | } |
| 230 | - } | |
| 284 | + } | |
| 231 | 285 | |
| 232 | 286 | /** |
| 233 | 287 | * To add Plugin Menu and Settings page |
| 234 | 288 | */ |
| 235 | - public function plugin_menu() { | |
| 289 | + public function plugin_menu() | |
| 290 | + { | |
| 236 | 291 | |
| 237 | 292 | ob_start(); |
| 238 | 293 | |
| 239 | - $this->multilingual_register_strings(); | |
| 294 | + $this->multilingual_register_strings(); | |
| 240 | 295 | |
| 241 | 296 | //require_once WPDIRECTORYKIT_PATH . 'vendor/boo-settings-helper/class-boo-settings-helper.php'; |
| 242 | 297 | |
| 243 | - add_menu_page(__('Directory Kit','wpdirectorykit'), __('Directory Kit','wpdirectorykit'), | |
| 244 | - 'wdk_listings_manage', 'wdk', array($this, 'admin_page_display'), | |
| 298 | + add_menu_page( | |
| 299 | + __('Directory Kit', 'wpdirectorykit'), | |
| 300 | + __('Directory Kit', 'wpdirectorykit'), | |
| 301 | + 'wdk_listings_manage', | |
| 302 | + 'wdk', | |
| 303 | + array($this, 'admin_page_display'), | |
| 245 | 304 | //plugin_dir_url( __FILE__ ) . 'resources/logo.png', |
| 246 | 305 | 'dashicons-category', |
| 247 | - 28 ); | |
| 248 | - | |
| 249 | - add_submenu_page('wdk', | |
| 250 | - __('Listings','wpdirectorykit'), | |
| 251 | - __('Listings','wpdirectorykit'), | |
| 252 | - 'wdk_listings_manage', 'wdk', array($this, 'admin_page_display')); | |
| 253 | - | |
| 254 | - add_submenu_page('wdk', | |
| 255 | - __('Add Listing','wpdirectorykit'), | |
| 256 | - __('Add Listing','wpdirectorykit'), | |
| 257 | - 'wdk_listings_manage', 'wdk_listing', array($this, 'admin_page_display')); | |
| 306 | + 28 | |
| 307 | + ); | |
| 258 | 308 | |
| 259 | - add_submenu_page('wdk', | |
| 260 | - __('Fields','wpdirectorykit'), | |
| 261 | - __('Fields','wpdirectorykit'), | |
| 262 | - 'wdk_listings_manage', 'wdk_fields', array($this, 'admin_page_display')); | |
| 263 | - | |
| 264 | - if(get_option('wdk_is_category_enabled', FALSE)) | |
| 265 | - add_submenu_page('wdk', | |
| 266 | - __('Categories','wpdirectorykit'), | |
| 267 | - __('Categories','wpdirectorykit'), | |
| 268 | - 'wdk_listings_manage', 'wdk_category', array($this, 'admin_page_display')); | |
| 269 | - | |
| 270 | - if(get_option('wdk_is_location_enabled', FALSE)) | |
| 271 | - add_submenu_page('wdk', | |
| 272 | - __('Locations','wpdirectorykit'), | |
| 273 | - __('Locations','wpdirectorykit'), | |
| 274 | - 'wdk_listings_manage', 'wdk_location', array($this, 'admin_page_display')); | |
| 309 | + add_submenu_page( | |
| 310 | + 'wdk', | |
| 311 | + __('Listings', 'wpdirectorykit'), | |
| 312 | + __('Listings', 'wpdirectorykit'), | |
| 313 | + 'wdk_listings_manage', | |
| 314 | + 'wdk', | |
| 315 | + array($this, 'admin_page_display') | |
| 316 | + ); | |
| 275 | 317 | |
| 276 | - add_submenu_page('wdk', | |
| 277 | - __('Search Form','wpdirectorykit'), | |
| 278 | - __('Search Form','wpdirectorykit'), | |
| 279 | - 'wdk_listings_manage', 'wdk_searchform', array($this, 'admin_page_display')); | |
| 318 | + add_submenu_page( | |
| 319 | + 'wdk', | |
| 320 | + __('Add Listing', 'wpdirectorykit'), | |
| 321 | + __('Add Listing', 'wpdirectorykit'), | |
| 322 | + 'wdk_listings_manage', | |
| 323 | + 'wdk_listing', | |
| 324 | + array($this, 'admin_page_display') | |
| 325 | + ); | |
| 280 | 326 | |
| 281 | - add_submenu_page('wdk', | |
| 282 | - __('Result Card','wpdirectorykit'), | |
| 283 | - __('Result Card','wpdirectorykit'), | |
| 284 | - 'wdk_listings_manage', 'wdk_resultitem', array($this, 'admin_page_display')); | |
| 285 | - | |
| 286 | - add_submenu_page('wdk', | |
| 287 | - __('Change Currency','wpdirectorykit'), | |
| 288 | - __('Change Currency','wpdirectorykit'), | |
| 289 | - 'wdk_listings_manage', 'wdk_change_currency', array($this, 'admin_page_display')); | |
| 327 | + add_submenu_page( | |
| 328 | + 'wdk', | |
| 329 | + __('Fields', 'wpdirectorykit'), | |
| 330 | + __('Fields', 'wpdirectorykit'), | |
| 331 | + 'wdk_listings_manage', | |
| 332 | + 'wdk_fields', | |
| 333 | + array($this, 'admin_page_display') | |
| 334 | + ); | |
| 290 | 335 | |
| 291 | - add_submenu_page('wdk', | |
| 292 | - __('Messages','wpdirectorykit'), | |
| 293 | - __('Messages','wpdirectorykit'), | |
| 294 | - 'wdk_listings_manage', 'wdk_messages', array($this, 'admin_page_display')); | |
| 336 | + if (get_option('wdk_is_category_enabled', FALSE)) | |
| 337 | + add_submenu_page( | |
| 338 | + 'wdk', | |
| 339 | + __('Categories', 'wpdirectorykit'), | |
| 340 | + __('Categories', 'wpdirectorykit'), | |
| 341 | + 'wdk_listings_manage', | |
| 342 | + 'wdk_category', | |
| 343 | + array($this, 'admin_page_display') | |
| 344 | + ); | |
| 295 | 345 | |
| 296 | - add_submenu_page('wdk', | |
| 297 | - __('Settings','wpdirectorykit'), | |
| 298 | - __('Settings','wpdirectorykit'), | |
| 299 | - 'wdk_listings_manage', 'wdk_settings', array($this, 'admin_page_display')); | |
| 346 | + if (get_option('wdk_is_location_enabled', FALSE)) | |
| 347 | + add_submenu_page( | |
| 348 | + 'wdk', | |
| 349 | + __('Locations', 'wpdirectorykit'), | |
| 350 | + __('Locations', 'wpdirectorykit'), | |
| 351 | + 'wdk_listings_manage', | |
| 352 | + 'wdk_location', | |
| 353 | + array($this, 'admin_page_display') | |
| 354 | + ); | |
| 300 | 355 | |
| 301 | - add_submenu_page('wdk', | |
| 302 | - __('Documentation','wpdirectorykit'), | |
| 303 | - __('Documentation','wpdirectorykit'), | |
| 304 | - 'wdk_listings_manage', 'https://wpdirectorykit.com/documentation'); | |
| 356 | + | |
| 357 | + add_submenu_page( | |
| 358 | + 'wdk', | |
| 359 | + __('Search Form', 'wpdirectorykit'), | |
| 360 | + __('Search Form', 'wpdirectorykit'), | |
| 361 | + 'wdk_listings_manage', | |
| 362 | + 'wdk_searchform', | |
| 363 | + array($this, 'admin_page_display') | |
| 364 | + ); | |
| 365 | + | |
| 366 | + if (function_exists('fpai_register_settings')) { | |
| 367 | + add_submenu_page( | |
| 368 | + 'wdk', | |
| 369 | + __('Ai Search', 'wpdirectorykit'), | |
| 370 | + __('Ai Search', 'wpdirectorykit'), | |
| 371 | + 'wdk_listings_manage', | |
| 372 | + 'wdk_aisearch', | |
| 373 | + array($this, 'admin_page_display') | |
| 374 | + ); | |
| 375 | + } | |
| 376 | + add_submenu_page( | |
| 377 | + 'wdk', | |
| 378 | + __('Result Card', 'wpdirectorykit'), | |
| 379 | + __('Result Card', 'wpdirectorykit'), | |
| 380 | + 'wdk_listings_manage', | |
| 381 | + 'wdk_resultitem', | |
| 382 | + array($this, 'admin_page_display') | |
| 383 | + ); | |
| 305 | 384 | |
| 306 | - if(!file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') || defined('WDK_FS_DISABLE')) | |
| 307 | - { | |
| 385 | + add_submenu_page( | |
| 386 | + 'wdk', | |
| 387 | + __('Change Currency', 'wpdirectorykit'), | |
| 388 | + __('Change Currency', 'wpdirectorykit'), | |
| 389 | + 'wdk_listings_manage', | |
| 390 | + 'wdk_change_currency', | |
| 391 | + array($this, 'admin_page_display') | |
| 392 | + ); | |
| 308 | 393 | |
| 309 | - if(!file_exists(WP_PLUGIN_DIR.'/wdk-currency-conversion') || !is_plugin_active( 'wdk-currency-conversion/wdk-currency-conversion.php' )) | |
| 310 | - add_submenu_page('wdk', | |
| 311 | - __('Currencies Addon','wpdirectorykit'), | |
| 312 | - __('Currencies Addon','wpdirectorykit'), | |
| 313 | - 'wdk_listings_manage', 'wdk_addons_currencies', array($this, 'admin_page_display')); | |
| 394 | + add_submenu_page( | |
| 395 | + 'wdk', | |
| 396 | + __('Messages', 'wpdirectorykit'), | |
| 397 | + __('Messages', 'wpdirectorykit'), | |
| 398 | + 'wdk_listings_manage', | |
| 399 | + 'wdk_messages', | |
| 400 | + array($this, 'admin_page_display') | |
| 401 | + ); | |
| 314 | 402 | |
| 315 | - if(!file_exists(WP_PLUGIN_DIR.'/wdk-membership') || !is_plugin_active( 'wdk-membership/wdk-membership.php' )) | |
| 316 | - add_submenu_page('wdk', | |
| 317 | - __('Membership Addon','wpdirectorykit'), | |
| 318 | - __('Membership Addon','wpdirectorykit'), | |
| 319 | - 'wdk_listings_manage', 'wdk_addons_membership', array($this, 'admin_page_display')); | |
| 403 | + add_submenu_page( | |
| 404 | + 'wdk', | |
| 405 | + __('Settings', 'wpdirectorykit'), | |
| 406 | + __('Settings', 'wpdirectorykit'), | |
| 407 | + 'wdk_listings_manage', | |
| 408 | + 'wdk_settings', | |
| 409 | + array($this, 'admin_page_display') | |
| 410 | + ); | |
| 320 | 411 | |
| 321 | - if(!file_exists(WP_PLUGIN_DIR.'/wdk-bookings') || !is_plugin_active( 'wdk-bookings/wdk-bookings.php' )) | |
| 322 | - add_submenu_page('wdk', | |
| 323 | - __('Booking Addon','wpdirectorykit'), | |
| 324 | - __('Booking Addon','wpdirectorykit'), | |
| 325 | - 'wdk_listings_manage', 'wdk_addons_bookings', array($this, 'admin_page_display')); | |
| 412 | + add_submenu_page( | |
| 413 | + 'wdk', | |
| 414 | + __('Documentation', 'wpdirectorykit'), | |
| 415 | + __('Documentation', 'wpdirectorykit'), | |
| 416 | + 'wdk_listings_manage', | |
| 417 | + 'https://wpdirectorykit.com/documentation' | |
| 418 | + ); | |
| 326 | 419 | |
| 327 | - add_submenu_page('wdk', | |
| 328 | - __('More Addons','wpdirectorykit'), | |
| 329 | - __('More Addons','wpdirectorykit'), | |
| 330 | - 'wdk_listings_manage', 'wdk_addons', array($this, 'admin_page_display')); | |
| 420 | + //if(!file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php') || defined('WDK_FS_DISABLE')) | |
| 421 | + //{ | |
| 331 | 422 | |
| 332 | - add_submenu_page('wdk', | |
| 333 | - __('Support Forum','wpdirectorykit'), | |
| 334 | - __('Support Forum','wpdirectorykit'), | |
| 335 | - 'wdk_listings_manage', 'https://wordpress.org/support/plugin/wpdirectorykit/'); | |
| 423 | + if (!file_exists(WP_PLUGIN_DIR . '/wdk-currency-conversion') || !is_plugin_active('wdk-currency-conversion/wdk-currency-conversion.php')) | |
| 424 | + add_submenu_page( | |
| 425 | + 'wdk', | |
| 426 | + __('Currencies Addon', 'wpdirectorykit'), | |
| 427 | + __('Currencies Addon', 'wpdirectorykit'), | |
| 428 | + 'wdk_listings_manage', | |
| 429 | + 'wdk_addons_currencies', | |
| 430 | + array($this, 'admin_page_display') | |
| 431 | + ); | |
| 336 | 432 | |
| 337 | - add_submenu_page('wdk', | |
| 338 | - __('Contact','wpdirectorykit'), | |
| 339 | - __('Contact','wpdirectorykit'), | |
| 340 | - 'wdk_listings_manage', 'https://wpdirectorykit.com/contact.html'); | |
| 341 | - } | |
| 433 | + if (!file_exists(WP_PLUGIN_DIR . '/wdk-membership') || !is_plugin_active('wdk-membership/wdk-membership.php')) | |
| 434 | + add_submenu_page( | |
| 435 | + 'wdk', | |
| 436 | + __('Membership Addon', 'wpdirectorykit'), | |
| 437 | + __('Membership Addon', 'wpdirectorykit'), | |
| 438 | + 'wdk_listings_manage', | |
| 439 | + 'wdk_addons_membership', | |
| 440 | + array($this, 'admin_page_display') | |
| 441 | + ); | |
| 342 | 442 | |
| 443 | + if (!file_exists(WP_PLUGIN_DIR . '/wdk-bookings') || !is_plugin_active('wdk-bookings/wdk-bookings.php')) | |
| 444 | + add_submenu_page( | |
| 445 | + 'wdk', | |
| 446 | + __('Booking Addon', 'wpdirectorykit'), | |
| 447 | + __('Booking Addon', 'wpdirectorykit'), | |
| 448 | + 'wdk_listings_manage', | |
| 449 | + 'wdk_addons_bookings', | |
| 450 | + array($this, 'admin_page_display') | |
| 451 | + ); | |
| 452 | + | |
| 453 | + add_submenu_page( | |
| 454 | + 'wdk', | |
| 455 | + __('More Addons', 'wpdirectorykit'), | |
| 456 | + __('More Addons', 'wpdirectorykit'), | |
| 457 | + 'wdk_listings_manage', | |
| 458 | + 'wdk_addons', | |
| 459 | + array($this, 'admin_page_display') | |
| 460 | + ); | |
| 461 | + | |
| 462 | + add_submenu_page( | |
| 463 | + 'wdk', | |
| 464 | + __('Support Forum', 'wpdirectorykit'), | |
| 465 | + __('Support Forum', 'wpdirectorykit'), | |
| 466 | + 'wdk_listings_manage', | |
| 467 | + 'https://wordpress.org/support/plugin/wpdirectorykit/' | |
| 468 | + ); | |
| 469 | + | |
| 470 | + add_submenu_page( | |
| 471 | + 'wdk', | |
| 472 | + __('Contact', 'wpdirectorykit'), | |
| 473 | + __('Contact', 'wpdirectorykit'), | |
| 474 | + 'wdk_listings_manage', | |
| 475 | + 'https://wpdirectorykit.com/contact.html' | |
| 476 | + ); | |
| 477 | + //} | |
| 478 | + | |
| 343 | 479 | $current_theme = wp_get_theme(); |
| 344 | 480 | |
| 345 | - if( defined( 'WP_DEBUG' ) && WP_DEBUG && $current_theme->get( 'AuthorURI' ) == 'https://wpdirectorykit.com') | |
| 346 | - add_submenu_page('tools.php', | |
| 347 | - esc_html__('WDK Demo Import', 'wpdirectorykit'), esc_html__('WDK Demo Import', 'wpdirectorykit'), 'wdk_listings_manage', 'wdk_demo_import', array($this, 'admin_page_display')); | |
| 348 | - | |
| 349 | - | |
| 481 | + if (defined('WP_DEBUG') && WP_DEBUG && $current_theme->get('AuthorURI') == 'https://wpdirectorykit.com') | |
| 482 | + add_submenu_page( | |
| 483 | + 'tools.php', | |
| 484 | + esc_html__('WDK Demo Import', 'wpdirectorykit'), | |
| 485 | + esc_html__('WDK Demo Import', 'wpdirectorykit'), | |
| 486 | + 'wdk_listings_manage', | |
| 487 | + 'wdk_demo_import', | |
| 488 | + array($this, 'admin_page_display') | |
| 489 | + ); | |
| 350 | 490 | } |
| 351 | - | |
| 352 | 491 | } |