get_data_from_db( 'map_integration' ); $map_api = ! empty( $map_api_details ) ? $map_api_details['api'] : ''; wp_enqueue_script( 'amm-map-script', 'https://maps.googleapis.com/maps/api/js?key=' . $map_api . '&libraries=drawing,places', array( 'jquery' ), false, true ); // Adding shortcode for displaying related posts on frontside. add_shortcode( 'addmultiplemarker', array( $this, 'display_multiple_marker_map' ) ); // Load text domain. add_action( 'plugins_loaded', array( $this, 'addmultiplemarker_load_textdomain' ) ); // Display notices when key is not API valid. add_action( 'admin_notices', array( $this, 'addmultiplemarker_admin_notice' )); } /** * Include admin style and scripts. */ function addmultiplemarker_admin_scripts() { wp_enqueue_style( 'amm-admin-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/css/amm-style.css' ); wp_enqueue_style( 'amm-font-css', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/fonts/sanasansalt.css' ); wp_enqueue_style( 'wp-color-picker' ); // Include scripts. wp_enqueue_script( 'wp-color-picker' ); wp_enqueue_script( 'amm-admin-script', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-scripts.js', array( ), false, true ); wp_localize_script( 'amm-admin-script', 'amm_plugin_obj', array( 'plugin_path' => ADDMULTIPLEMARKER_PLUGIN_URL, 'amm_save_option' => $this->get_data_from_db( 'marker_settings' ), 'ajax_url' => admin_url( 'admin-ajax.php' ), 'map_settings' => $this->get_data_from_db( 'map_integration' ), ) ); wp_enqueue_script( 'amm-admin-custom-script', ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/js/amm-custom-settings.js', array( ), false, true ); } /** * Include frontend style and scripts. */ function addmultiplemarker_scripts() { wp_enqueue_style( 'amm-frontend-styles', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/css/amm-frontend-style.css' ); // Include scripts. wp_enqueue_script('amm-frontend-scripts', ADDMULTIPLEMARKER_PLUGIN_URL . 'public/js/frontendscript.js', array( 'jquery' ), '', true); wp_localize_script( 'amm-frontend-scripts', 'amm_frontend_obj', array( 'amm_save_marker_option' => $this->get_data_from_db( 'marker_settings' ), 'map_settings' => $this->get_data_from_db( 'map_integration' ), ) ); } /** * Get data from database. */ function get_data_from_db( $option_name ) { if ( $option_name == 'map_integration' ) { $map_details = get_option( 'amm_map_setting' ); } elseif ( $option_name == 'marker_settings' ) { $map_details = get_option( 'amm_maps_marker' ); } return $map_details; } /** * Register admin menu. */ function addmultiplemarker_admin_menu() { add_menu_page( __( 'Add Multiple Marker', 'addmultiplemarker' ), 'Add Multiple Marker', 'manage_options', 'addmultiplemarker', array( $this, 'addmultiplemarker_global_settings_page' ), ADDMULTIPLEMARKER_PLUGIN_URL . 'admin/images/dash-icon.png' ); add_submenu_page( 'addmultiplemarker', __( 'AMM Map integration', 'addmultiplemarker' ), __( 'Map integration', 'addmultiplemarker' ), 'manage_options', 'amm-map-integration', array( $this, 'addmultiplemarker_map_integration_callback' ) ); } /** * Displaying admin notice. */ function addmultiplemarker_admin_notice() { if ( $_REQUEST['page'] == 'addmultiplemarker' || $_REQUEST['page'] == 'amm-map-integration') { $map_details = $this->get_data_from_db( 'map_integration' ); if ( ! empty( $map_details ) && $map_details['api'] == "" ) { echo '
' . __( 'Please enter valid Google Map API for displaying map.', 'addmultiplemarker') . '