util = new Util(); $this->settings = new Settings(); } /** * Adds a 'Settings' link for this plugin on plugin listing page * * @param $links * @return array Links array */ public function add_plugin_actions_links($links) { if (current_user_can('manage_options')) { $url = add_query_arg('page', self::PLUGIN_SLUG, 'options-general.php'); array_unshift( $links, sprintf('%s', $url, __('Settings')) ); } return $links; } /** * Register a page to display plugin options */ public function add_link_to_settings_menu() { $page_hook_suffix = add_submenu_page( 'options-general.php', 'Google Map', // page title 'Google Map', // menu text 'manage_options', self::PLUGIN_SLUG, array($this->settings, 'load_option_page') ); // Add help drop down menu on option page add_action("load-$page_hook_suffix", array($this, 'add_help_menu_tab')); add_action('admin_print_scripts-' . $page_hook_suffix, array($this, 'add_admin_assets')); } public function load_text_domain() { load_plugin_textdomain('ank-google-map', false, dirname(plugin_basename(AGM_BASE_FILE)) . '/languages/'); } /** * Returns dynamic javascript options to be used by admin js * @return array */ private function get_js_options() { $db = get_option('ank_google_map'); return array( 'map' => array( 'lat' => esc_attr($db['map_Lat']), 'lng' => esc_attr($db['map_Lng']), 'zoom' => absint($db['map_zoom']), 'style' => absint($db['map_style']), ), 'marker' => array( 'color' => $this->util->get_marker_url($db['marker_color']), 'file' => empty($db['marker_file']) ? false : esc_url($db['marker_file']) ), 'styles' => $this->util->get_styles() ); } /** * Add javascript and css to plugin option page */ public function add_admin_assets() { wp_enqueue_style('wp-color-picker'); wp_enqueue_script('wp-color-picker'); wp_enqueue_media(); $is_min = (defined('WP_DEBUG') && WP_DEBUG == true) ? '' : '.min'; $db = get_option('ank_google_map'); wp_enqueue_style('agm-admin-css', plugins_url('/assets/option-page' . $is_min . '.css', AGM_BASE_FILE), array(), AGM_PLUGIN_VERSION, 'all'); $api_key = empty($db['api_key']) ? '' : '&key=' . esc_js($db['api_key']); wp_enqueue_script('agm-google-map', 'https://maps.googleapis.com/maps/api/js?v=' . AGM_API_VER . '&libraries=places' . $api_key, array(), null, true); wp_enqueue_script('agm-admin-js', plugins_url("/assets/option-page" . $is_min . ".js", AGM_BASE_FILE), array('jquery', 'agm-google-map'), AGM_PLUGIN_VERSION, true); // WP inbuilt hack to print js options object just before this script wp_localize_script('agm-admin-js', '_agmOpt', $this->get_js_options()); } /* * Add a help tab at top of plugin option page */ public function add_help_menu_tab() { $screen = get_current_screen(); $screen->add_help_tab( array( 'id' => 'agm-overview', 'title' => 'Overview', 'content' => '

Thanks for using this plugin.
' . 'This plugin allows you to put a custom Google Map on your website. Just configure options below and ' . 'save your settings.
Copy & paste [ank_google_map] shortcode on your page/post/widget to view your map.

' ) ); $screen->add_help_tab( array( 'id' => 'agm-troubleshoot', 'title' => 'Troubleshoot', 'content' => '

Things to remember
' . '

' ) ); $screen->add_help_tab( array( 'id' => 'agm-more-info', 'title' => 'More', 'content' => '

Need more information ?
' . 'A brief FAQ is available, ' . 'click here for more.
' . 'Support is only available on WordPress Forums, click here to ask anything about this plugin.
' . 'You can also report bugs at plugin's GitHub page. ' . 'I will try to reply as soon as possible.

' ) ); $screen->set_help_sidebar( '

Quick Links

' . '

Plugin FAQ

' . '

Plugin Home

' ); } }