' . __('Widgets', 'google-maps-widget') . '';
array_unshift($links, $settings_link);
return $links;
} // plugin_action_links
// add links to plugin's description in plugins table
static function plugin_meta_links($links, $file) {
$documentation_link = ''. __('Documentation', 'google-maps-widget') . '';
$support_link = '' . __('Support', 'google-maps-widget') . '';
$review_link = '' . __('Review the plugin', 'google-maps-widget') . '';
$donate_link = '' . __('Donate', 'google-maps-widget') . '';
if ($file == plugin_basename(__FILE__)) {
$links[] = $documentation_link;
$links[] = $support_link;
$links[] = $review_link;
$links[] = $donate_link;
}
return $links;
} // plugin_meta_links
// check if user has the minimal WP version required by the plugin
static function check_wp_version($min_version) {
if (!version_compare(get_bloginfo('version'), $min_version, '>=')) {
add_action('admin_notices', array(__CLASS__, 'min_version_error'));
}
} // check_wp_version
// display error message if WP version is too low
static function min_version_error() {
echo '
' . sprintf('Google Maps Widget requires WordPress version 3.3 or higher to function properly. You are using WordPress version %s. Please update it.', get_bloginfo('version'), admin_url('update-core.php')) . '
\n";
} // foreach $widgets
echo $out;
} // dialogs_markup
// check availability and register shortcode
static function add_shortcode() {
global $shortcode_tags;
if (isset($shortcode_tags['gmw'])) {
add_action('admin_notices', array(__CLASS__, 'notice_sc_conflict_error'));
} else {
add_shortcode('gmw', array(__CLASS__, 'do_shortcode'));
}
} // add_shortcode
// display notice if shortcode name is already taken
static function notice_sc_conflict_error() {
if (!self::is_activated()) {
return;
}
echo '
' . __('Google Maps Widget shortcode is not active!', 'google-maps-widget') . '' . __(' Shortcode [gmw] is already in use by another plugin or theme. Please deactivate that theme or plugin.', 'google-maps-widget') . '
';
} // notice_sc_conflict_error
// enqueue frontend scripts if necessary
static function enqueue_scripts() {
if (is_active_widget(false, false, 'googlemapswidget', true)) {
wp_enqueue_style('gmw', plugins_url('/css/gmw.css', __FILE__), array(), GMW_VER);
wp_enqueue_script('gmw-colorbox', plugins_url('/js/jquery.colorbox.min.js', __FILE__), array('jquery'), GMW_VER, true);
wp_enqueue_script('gmw', plugins_url('/js/gmw.js', __FILE__), array('jquery'), GMW_VER, true);
}
} // enqueue_scripts
// enqueue CSS and JS scripts on widgets page
static function admin_enqueue_scripts() {
global $wp_customize;
if (self::is_plugin_admin_page() || isset($wp_customize)) {
wp_enqueue_script('jquery-ui-tabs');
wp_enqueue_script('jquery-ui-dialog');
wp_enqueue_script('gmw-cookie', plugins_url('js/jquery.cookie.js', __FILE__), array('jquery'), GMW_VER, true);
wp_enqueue_script('gmw-admin', plugins_url('js/gmw-admin.js', __FILE__), array('jquery'), GMW_VER, true);
wp_enqueue_style('wp-jquery-ui-dialog');
wp_enqueue_style('gmw-admin', plugins_url('css/gmw-admin.css', __FILE__), array(), GMW_VER);
$js_localize = array('subscribe_ok' => __('Check your inbox. Email with activation code is on its way.', 'google-maps-widget'),
'subscribe_duplicate' => __('You are already subscribed to our list. One activation code is valid for all sites so just use the code you already have.', 'google-maps-widget'),
'subscribe_error' => __('Something is not right on our end. Sorry :( Try again later.', 'google-maps-widget'),
'activate_ok' => __('Superb! Extra features are active ;)', 'google-maps-widget'),
'dialog_title' => __('GOOGLE MAPS WIDGET - Activate Extra Features', 'google-maps-widget'));
wp_localize_script('gmw-admin', 'gmw', $js_localize);
} // if
} // admin_enqueue_scripts
// check if plugin's admin page is shown
static function is_plugin_admin_page() {
$current_screen = get_current_screen();
if ($current_screen->id == 'widgets') {
return true;
} else {
return false;
}
} // is_plugin_admin_page
// check if activate-by-subscribing features have been activated
static function is_activated() {
$options = get_option(GMW_OPTIONS);
if (isset($options['activated']) && $options['activated'] === true) {
return true;
} else {
return false;
}
} // is_activated
// echo markup for promo dialog; only on widgets page
static function admin_dialogs_markup() {
if (!self::is_plugin_admin_page()) {
return false;
}
$current_user = wp_get_current_user();
if (empty($current_user->user_firstname)) {
$name = $current_user->display_name;
} else {
$name = $current_user->user_firstname;
}
$out = '
';
$out .= '
' . __('Subscribe to our newsletter and get extra features & options for FREE!', 'google-maps-widget') . '