$this->plugin_name, 'php_version' => '7.4', 'wp_version' => '6.0', ] ); if ( $environment->has_error() ) { return; } $this->define(); $this->includes(); if ( get_option( 'nimap_setup_wizard' ) ) { $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( strpos( $page, '9map' ) !== false || strpos( $post_type, 'nimap' ) !== false ) { if ( ! isset( $_GET['nimap_setup_wizard'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $url = admin_url( '?nimap_setup_wizard=true' ); $url = add_query_arg( '_wpnonce', wp_create_nonce( 'nimap_setup_nonce' ), $url ); exit( wp_safe_redirect( $url ) );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } } public function before_woocommerce_init() { if ( class_exists( '\Automattic\WooCommerce\Utilities\FeaturesUtil' ) ) { \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'cart_checkout_blocks', __FILE__, true ); } } protected function define() { $this->plugin_name = '9Map - Map Multi Locations'; define( 'NIMAP_DIR', plugin_dir_path( __FILE__ ) ); define( 'NIMAP_LANGUAGES', NIMAP_DIR . "languages" . DIRECTORY_SEPARATOR ); define( 'NIMAP_INCLUDES', NIMAP_DIR . "includes" . DIRECTORY_SEPARATOR ); define( 'NIMAP_ADMIN', NIMAP_INCLUDES . "admin" . DIRECTORY_SEPARATOR ); define( 'NIMAP_FRONTEND', NIMAP_INCLUDES . "frontend" . DIRECTORY_SEPARATOR ); define( 'NIMAP_TEMPLATES', NIMAP_DIR . "templates" . DIRECTORY_SEPARATOR ); define( 'NIMAP_FONTS', NIMAP_INCLUDES . "assets" . DIRECTORY_SEPARATOR . "fonts" . DIRECTORY_SEPARATOR ); define( 'NIMAP_PLUGINS', NIMAP_INCLUDES . "plugins" . DIRECTORY_SEPARATOR ); define( 'NIMAP_URL', plugins_url( '', __FILE__ ) ); $plugin_url = plugins_url( 'assets/', __FILE__ ); define( 'NIMAP_ASSETS', $plugin_url . "/" ); define( 'NIMAP_CSS', $plugin_url . "css/" ); define( 'NIMAP_JS', $plugin_url . "js/" ); define( 'NIMAP_IMAGES', $plugin_url . "images/" ); } protected function includes() { $files = array( NIMAP_INCLUDES . 'nimap-data.php', NIMAP_INCLUDES . 'nimap-functions.php', NIMAP_INCLUDES . 'nimap-customize-controls.php', NIMAP_INCLUDES . 'support.php', ); foreach ( $files as $file ) { if ( file_exists( $file ) ) { require_once $file; } } villatheme_include_folder( NIMAP_ADMIN, 'NIMAP_' ); villatheme_include_folder( NIMAP_FRONTEND, 'NIMAP_' ); } public function install() { global $wp_version; if ( version_compare( $wp_version, "5.0", "<" ) ) { return; } $g_nimap_settings = get_option( 'nimap_multi_locator', array() ); if ( $g_nimap_settings && is_array( $g_nimap_settings ) && isset( $g_nimap_settings['general_api_key'] ) && ! empty( $g_nimap_settings['general_api_key'] ) ) { return; } update_option( 'nimap_setup_wizard', 1, 'no' ); // add_action( 'activated_plugin', array( $this, 'activated_plugin' ) ); } function setSampleStore( $option_data, $o_temp_name ) { if ( ! $option_data ) { $arg = array( 'post_title' => 'Sample store', 'post_status' => 'publish', 'post_type' => 'nimap_store', '_thumbnail_id' => '' ); $store_id = wp_insert_post( $arg ); $store_address = array( 'address' => '', 'city' => '', 'state' => '', 'country' => '', 'zip' => '', 'latitude' => 0, 'longitude' => 0, ); $store_information = array( 'website' => '', 'email' => '', 'phone' => '', 'fax' => '', 'custom' => '', ); $store_open = array( 'monday' => '', 'tuesday' => '', 'wednesday' => '', 'thursday' => '', 'friday' => '', 'saturday' => '', 'sunday' => '', ); update_post_meta( $store_id, 'nimap_store_description', '' ); update_post_meta( $store_id, 'nimap_store_address', $store_address ); update_post_meta( $store_id, 'nimap_store_information', $store_information ); update_post_meta( $store_id, 'nimap_store_opening', $store_open ); update_post_meta( $store_id, 'nimap_store_image', '' ); delete_option( $o_temp_name ); add_option( $o_temp_name, $store_id ); } } public function activated_plugin( $plugin ) { if ( $plugin === plugin_basename( __FILE__ ) ) { $page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $post_type = isset( $_GET['post_type'] ) ? sanitize_text_field( wp_unslash( $_GET['post_type'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( get_option( 'nimap_setup_wizard' ) && ( strpos( $page, "9map" ) !== false || strpos( $post_type, "nimap" ) !== false ) ) { if ( ! isset( $_GET['nimap_setup_wizard'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $url = admin_url( '?nimap_setup_wizard=true' ); $url = add_query_arg( '_wpnonce', wp_create_nonce( 'nimap_setup_nonce' ), $url ); exit( wp_safe_redirect( $url ) );//phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } } } } } new NIMAP_MULTI_LOCATOR();