Helper = new Helpers(); // plugin activation hook register_activation_hook(ADQS_DIRECTORY_FILE, array($this, 'plugin_activate')); // when plugin loaded add_action('plugins_loaded', array($this, 'init_plugin')); add_action('init', array($this, 'permalinks_flushed')); add_action('init', array($this, 'blocks_init'), 10090); } /** * Method blocks_init * * @return void */ public function blocks_init() { $this->load_translation(); if (!get_option('adqs_admin_settings')) { $adqs_settings_array = Setting::get_settings_fields(); $admin_setting = array(); if (is_array($adqs_settings_array)) { foreach ($adqs_settings_array as $single_setting) { if (isset($single_setting['option_name'])) { $admin_setting[$single_setting['option_name']] = isset($single_setting['value']) ? $single_setting['value'] : ''; } } update_option('adqs_admin_settings', $admin_setting); } update_option('adqs_admin_settings', $admin_setting); } $checkHasTerms = (term_exists('general', 'adqs_listing_types') || get_option('adqs_term_builder_default')) ? true : false; if (!$checkHasTerms) { $id = wp_insert_term('General', 'adqs_listing_types'); $deafult_fields = array( array( 'sectiontitle' => esc_html__('General Section', 'adirectory'), 'id' => '02652d5f-7374-43b5-be3d-8ad92345c11d', 'fields' => array( array( 'fieldid' => '9c206ad8-8110-495b-82f8-40ff45bb92c5', 'input_type' => 'pricing', 'label' => esc_html__('Pricing', 'adirectory'), 'name' => esc_html__('Pricing', 'adirectory'), 'placeholder' => esc_html__('Pricing placeholder', 'adirectory'), 'is_required' => 1, ), array( 'fieldid' => '90641e6c-d62d-4e36-af4c-77ecc34193f4', 'input_type' => 'view_count', 'label' => esc_html__('View Count', 'adirectory'), 'name' => esc_html__('View Count', 'adirectory'), 'placeholder' => esc_html__('view count placeholder', 'adirectory'), 'is_required' => 1, ), ), ), array( 'sectiontitle' => esc_html__('Contact Section', 'adirectory'), 'id' => '80dc2f81-fbe6-4b55-ad6c-7a9c04e1e639', 'fields' => array( array( 'fieldid' => '607f0712-44a5-4379-92e6-598fb932c9af', 'input_type' => 'phone', 'label' => esc_html__('Phone', 'adirectory'), 'name' => esc_html__('Phone', 'adirectory'), 'placeholder' => esc_html__('Enter phone number', 'adirectory'), 'is_required' => 1, ), array( 'fieldid' => 'e0b3572d-a708-4461-af7c-cc4386d43866', 'input_type' => 'zip', 'label' => esc_html__('Zip Code', 'adirectory'), 'name' => esc_html__('Zip Code', 'adirectory'), 'placeholder' => esc_html__('Enter zip code', 'adirectory'), ), array( 'fieldid' => 'a66f663a-2465-4d42-a0ca-77463173fd41', 'input_type' => 'website', 'label' => esc_html__('Website', 'adirectory'), 'name' => esc_html__('Website', 'adirectory'), 'placeholder' => esc_html__('Enter website url', 'adirectory'), ), ), ), array( 'sectiontitle' => esc_html__('Map and Address', 'adirectory'), 'id' => 'ac1f4d3a-bca0-41fd-be1c-e6caf65649e7', 'fields' => array( array( 'fieldid' => 'f45b3f63-1a9e-4143-b0a1-e9c8a3009988', 'input_type' => 'address', 'label' => esc_html__('Address', 'adirectory'), 'name' => esc_html__('Address', 'adirectory'), 'placeholder' => esc_html__('Enter address', 'adirectory'), 'is_required' => 1, ), array( 'fieldid' => '4c50f6ff-cdc4-4b29-96df-50468aee20ef', 'input_type' => 'map', 'label' => esc_html__('Map', 'adirectory'), 'name' => esc_html__('Map', 'adirectory'), 'placeholder' => esc_html__('Enter map', 'adirectory'), 'is_required' => 1, ), ), ), array( 'sectiontitle' => esc_html__('Images & Video', 'adirectory'), 'id' => '98d51901-c1a2-4a44-b9c6-51ad84e2a494', 'fields' => array( array( 'fieldid' => '9d3c1b4e-29f0-42ed-8d2c-30cddaec8a77', 'input_type' => 'video', 'label' => esc_html__('Video', 'adirectory'), 'name' => esc_html__('Video', 'adirectory'), 'placeholder' => esc_html__('Enter video url', 'adirectory'), ), ), ), ); update_term_meta(absint($id['term_id']) ?? 0, 'adqs_metafields_types', $deafult_fields); update_term_meta(absint($id['term_id']) ?? 0, 'adqs_term_icon', 'fas fa-map'); update_term_meta(absint($id['term_id']) ?? 0, 'adqs_term_default_expiry', '15'); update_option('adqs_term_builder_default', 1); } } /** * Method plugin_activate * * @return void */ public function plugin_activate() { update_option('adqs_permalinks_flushed', 0); $this->adqs_onborading_pages(); } /** * Method adqs_onborading_pages * * @return void */ public function adqs_onborading_pages() { $option_key = 'adqs_onboarding_pages'; if (empty(get_option($option_key))) { $insertPages = array( array( 'post_title' => esc_html__('All Listings', 'adirectory'), 'post_content' => '[adqs_listings]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_all_listing', ), array( 'post_title' => esc_html__('All Location', 'adirectory'), 'post_content' => '[adqs_taxonomies tax_name="adqs_location"]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_all_locations', ), array( 'post_title' => esc_html__('All Categories', 'adirectory'), 'post_content' => '[adqs_taxonomies tax_name="adqs_category"]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_all_categories', ), array( 'post_title' => esc_html__('Add Listing', 'adirectory'), 'post_content' => '[adqs_add_listing]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_add_listing', ), array( 'post_title' => esc_html__('User Dashboard', 'adirectory'), 'post_content' => '[adqs_dashboard]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_user_dashboard', ), array( 'post_title' => esc_html__('Login - Registration', 'adirectory'), 'post_content' => '[adqs_user_log_regi]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_login_regi', ), array( 'post_title' => esc_html__('All Agents', 'adirectory'), 'post_content' => '[adqs_agents]', 'post_status' => 'publish', 'post_type' => 'page', 'page_key' => 'adqs_agents', ), ); $allPages = []; if (is_array($insertPages) && !empty($insertPages)) { foreach ($insertPages as $insert) { $get_page_id = wp_insert_post(array( 'post_title' => sprintf(esc_html__("%s", "adirectory"), $insert['post_title']), 'post_content' => $insert['post_content'], 'post_status' => $insert['post_status'], 'post_type' => $insert['post_type'], )); if (!empty($get_page_id)) { $allPages[$insert['page_key']] = $get_page_id; } } } if (!empty($allPages)) { update_option($option_key, $allPages); } } } /** * Method permalinks_flushed * * @return void */ public function permalinks_flushed() { if (!get_option('adqs_permalinks_flushed')) { flush_rewrite_rules(false); update_option('adqs_permalinks_flushed', 1); } } /** * Initializes a singleton instance */ public static function instance() { static $instance = false; if (!$instance) { $instance = new self(); } return $instance; } /** * Include Files */ public function inlcude_files() { if (file_exists(ADQS_DIRECTORY_INC . '/Functions.php')) { require_once ADQS_DIRECTORY_INC . '/Functions.php'; } } /** * Load translation for both server and client side */ public function load_translation() { load_plugin_textdomain('adirectory', false, dirname(ADQS_DIRECTORY_PLUGIN_BASE) . '/languages'); } /** * Initialize the plugin * * @return void */ public function init_plugin() { // load functions php files $this->inlcude_files(); // loaded all required plugin new Frontend(); new Addons(); new Database(); new Formhandler(); if (is_admin()) { new Admin(); } } } /* ADQS_Directory Loder */ function AD() { return ADQS_Init::instance(); } AD();