Helper = Helpers::getInstance(); // plugin activation hook register_activation_hook(ADQS_DIRECTORY_FILE, array($this, 'plugin_activate')); $this->update_setting(); // 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(); } public function update_setting() { $option = get_option('adqs_admin_settings', array()); $adqs_email_templates = array( 'admin' => array( 'new_user_reg' => array( 'subject' => "A new user has registered", 'html_body' => "

New User Registration

A new user has just registered on your website.

Username: {user_name}

Email: {user_email}

Please review their details and take the necessary actions.

This is an automated message, please do not reply.

" ), 'new_listing_sub' => array( 'subject' => "A new listing has been submitted", 'html_body' => "

New Listing Submitted

A new listing has been submitted on your website.

Listing Title: {listing_title}

Submitted By: {user_name}

Please review the listing for approval.

This is an automated message, please do not reply.

" ), 'new_listing_up' => array( 'subject' => "A listing has been updated", 'html_body' => "

Listing Updated

A listing has been updated on your website.

Listing Title: {listing_title}

Updated By: {user_name}

Please review the changes.

This is an automated message, please do not reply.

" ), 'order_created' => array( 'subject' => "A new order has been created", 'html_body' => "

New Order Created

A new order has been placed on your website.

Order ID: {order_id}

Customer: {customer_name}

Please process the order as soon as possible.

This is an automated message, please do not reply.

" ), 'order_completed' => array( 'subject' => "An order has been completed", 'html_body' => "

Order Completed

An order has been completed on your website.

Order ID: {order_id}

Customer: {customer_name}

Thank you for using our service.

This is an automated message, please do not reply.

" ), ), 'user' => array( 'new_user_reg' => array( 'subject' => "Welcome to the website", 'html_body' => "

Welcome, {user_name}!

Thank you for registering on our website.

We are excited to have you with us. You can now start exploring and make the most of our services.

If you have any questions, feel free to reach out to our support team.

This is an automated message, please do not reply.

" ), 'new_listing_sub' => array( 'subject' => "Your listing has been submitted", 'html_body' => "

Listing Submitted Successfully

Thank you, {user_name}, for submitting your listing on our website.

Listing Title: {listing_title}

Your listing is now under review. You will be notified once it is approved.

This is an automated message, please do not reply.

" ), 'listing_is_approved' => array( 'subject' => "Your listing has been approved", 'html_body' => "

Congratulations, {user_name}!

Your listing titled '{listing_title}' has been approved.

It is now live on our website. We hope it brings you great success.

This is an automated message, please do not reply.

" ), 'listing_about_expire' => array( 'subject' => "Your listing is about to expire", 'html_body' => "

Listing Expiration Notice

Dear {user_name}, your listing titled '{listing_title}' is about to expire.

Please renew your listing to continue its visibility on our website.

This is an automated message, please do not reply.

" ), 'listing_expired' => array( 'subject' => "Your listing has expired", 'html_body' => "

Listing Expired

Dear {user_name}, your listing titled '{listing_title}' has expired.

If you would like to renew your listing, please visit your account dashboard.

This is an automated message, please do not reply.

" ), 'order_created' => array( 'subject' => "Your order has been received", 'html_body' => "

Order Confirmation

Dear {customer_name}, your order has been received successfully.

Order ID: {order_id}

We are processing your order and will notify you once it is completed.

This is an automated message, please do not reply.

" ), 'order_completed' => array( 'subject' => "Your order is complete", 'html_body' => "

Order Completed

Dear {customer_name}, your order has been completed successfully.

Order ID: {order_id}

Thank you for your purchase. We hope you enjoy your product.

This is an automated message, please do not reply.

" ), ), ); if (!array_key_exists('select_currency', $option)) { $option['select_currency'] = 'USD__$__before'; } if (!array_key_exists('adqs_admin_templates', $option)) { $option['adqs_admin_templates'] = $adqs_email_templates; } if (!array_key_exists('adqs_admin_emails_triggers', $option)) { $option['adqs_admin_emails_triggers'] = ['new_user_reg', 'new_listing_sub', 'new_listing_up', 'order_created', 'order_completed']; } if (!array_key_exists('adqs_user_emails_triggers', $option)) { $option['adqs_user_emails_triggers'] = array('new_user_reg', 'new_listing_sub', 'listing_is_approved', 'listing_about_expire', 'listing_expired', 'order_created', 'order_completed'); } if (!array_key_exists('from_email_name', $option)) { $option['from_email_name'] = get_bloginfo('name'); } if (!array_key_exists('from_email_address', $option)) { $option['from_email_address'] = get_option('admin_email'); } if (!array_key_exists('enable_bank_transfer', $option)) { $option['enable_bank_transfer'] = 1; } update_option('adqs_admin_settings', $option); } /** * 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();