' . __('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') . '';
$activate_link = '' . __('Activate premium features for FREE', 'google-maps-widget') . '';
if ($file == plugin_basename(__FILE__)) {
$links[] = $documentation_link;
$links[] = $support_link;
$links[] = $review_link;
$links[] = $donate_link;
if (!self::is_activated()) {
$links[] = $activate_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__, 'notice_min_version_error'));
}
} // check_wp_version
// display error message if WP version is too low
static function notice_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.', 'google-maps-widget'), 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
// handle dismiss button for all notices
// todo - convert all notices
static function dismiss_notice() {
$options = get_option(GMW_OPTIONS, array());
if (isset($_GET['notice']) && $_GET['notice'] == 'upgrade') {
$options['dismiss_notice_upgrade'] = true;
update_option(GMW_OPTIONS, $options);
}
if (isset($_GET['notice']) && $_GET['notice'] == 'rate') {
$options['dismiss_notice_rate'] = true;
update_option(GMW_OPTIONS, $options);
}
if ($_GET['redirect']) {
wp_redirect($_GET['redirect']);
} else {
wp_redirect(admin_url());
}
exit;
} // dismiss_notice
// maybe show some notices
static function add_notices() {
$options = get_option(GMW_OPTIONS, array());
$notice = false;
if ((!isset($options['dismiss_notice_upgrade']) || $options['dismiss_notice_upgrade'] == false) &&
!self::is_activated() &&
(GMW_tracking::count_active_widgets() > 0 || (current_time('timestamp') - $options['first_install']) > (DAY_IN_SECONDS * 3))) {
add_action('admin_notices', array(__CLASS__, 'notice_activate_extra_features'));
$notice = true;
} // show upgrade notice
if (!$notice &&
(!isset($options['dismiss_notice_rate']) || $options['dismiss_notice_rate'] == false) &&
GMW_tracking::count_active_widgets() > 0 &&
(current_time('timestamp') - $options['first_install']) > (DAY_IN_SECONDS * 20)) {
add_action('admin_notices', array(__CLASS__, 'notice_rate_plugin'));
} // show rate notice
} // add_notices
// display message to get extra features for GMW
static function notice_activate_extra_features() {
$activate_url = admin_url('widgets.php?gmw_open_promo_dialog');
$dismiss_url = add_query_arg(array('action' => 'gmw_dismiss_notice', 'notice' => 'upgrade', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
// todo detect WP version and add support for "is-dismissible"
// todo remove style from HTML
echo '
';
} // notice_activate_extra_features
// display message to get extra features for GMW
static function notice_rate_plugin() {
$rate_url = 'https://wordpress.org/support/view/plugin-reviews/google-maps-widget?rate=5#postform';
$dismiss_url = add_query_arg(array('action' => 'gmw_dismiss_notice', 'notice' => 'rate', 'redirect' => urlencode($_SERVER['REQUEST_URI'])), admin_url('admin.php'));
// todo detect WP version and add support for "is-dismissible"
// todo remove style from HTML
echo '