__('An undocumented error has occurred. Please refresh the page and try again.', 'advanced-google-recaptcha'),
'documented_error' => __('An error has occurred.', 'advanced-google-recaptcha'),
'plugin_name' => __('WP Captcha', 'advanced-google-recaptcha'),
'plugin_url' => WPCAPTCHA_PLUGIN_URL,
'icon_url' => WPCAPTCHA_PLUGIN_URL . 'images/wp-captcha-loader.gif',
'settings_url' => admin_url('options-general.php?page=wpcaptcha'),
'version' => self::$version,
'site' => get_home_url(),
'url' => WPCAPTCHA_PLUGIN_URL,
'cancel_button' => __('Cancel', 'advanced-google-recaptcha'),
'ok_button' => __('OK', 'advanced-google-recaptcha'),
'run_tool_nonce' => wp_create_nonce('wpcaptcha_run_tool'),
'stats_unavailable' => 'Stats will be available once enough data is collected.',
'stats_locks' => WPCaptcha_Stats::get_stats('locks'),
'stats_fails' => WPCaptcha_Stats::get_stats('fails'),
'wp301_install_url' => add_query_arg(array('action' => 'wpcaptcha_install_wp301', '_wpnonce' => wp_create_nonce('install_wp301'), 'rnd' => rand()), admin_url('admin.php')),
);
$js_localize['chart_colors'] = array('#4285f4', '#ff5429', '#ff7d5c', '#ffac97');
wp_enqueue_script('wpcaptcha-admin', WPCAPTCHA_PLUGIN_URL . 'js/wpcaptcha.js', array('jquery'), self::$version, true);
wp_localize_script('wpcaptcha-admin', 'wpcaptcha_vars', $js_localize);
// fix for aggressive plugins that include their CSS or JS on all pages
wp_dequeue_style('uiStyleSheet');
wp_dequeue_style('wpcufpnAdmin');
wp_dequeue_style('unifStyleSheet');
wp_dequeue_style('wpcufpn_codemirror');
wp_dequeue_style('wpcufpn_codemirrorTheme');
wp_dequeue_style('collapse-admin-css');
wp_dequeue_style('jquery-ui-css');
wp_dequeue_style('tribe-common-admin');
wp_dequeue_style('file-manager__jquery-ui-css');
wp_dequeue_style('file-manager__jquery-ui-css-theme');
wp_dequeue_style('wpmegmaps-jqueryui');
wp_dequeue_style('wp-botwatch-css');
wp_dequeue_style('njt-filebird-admin');
wp_dequeue_style('ihc_jquery-ui.min.css');
wp_dequeue_style('badgeos-juqery-autocomplete-css');
wp_dequeue_style('mainwp');
wp_dequeue_style('mainwp-responsive-layouts');
wp_dequeue_style('jquery-ui-style');
wp_dequeue_style('additional_style');
wp_dequeue_style('wobd-jqueryui-style');
wp_dequeue_style('wpdp-style3');
wp_dequeue_style('jquery_smoothness_ui');
wp_dequeue_style('uap_main_admin_style');
wp_dequeue_style('uap_font_awesome');
wp_dequeue_style('uap_jquery-ui.min.css');
wp_dequeue_style('wqm-select2-style');
wp_deregister_script('wqm-select2-script');
WPCaptcha_Utility::dismiss_pointer_ajax();
}
$pointers = get_option(WPCAPTCHA_POINTERS_KEY);
if ('settings_page_wpcaptcha' != $hook) {
if ($pointers) {
$pointers['run_tool_nonce'] = wp_create_nonce('wpcaptcha_run_tool');
wp_enqueue_script('wp-pointer');
wp_enqueue_style('wp-pointer');
wp_localize_script('wp-pointer', 'wpcaptcha_pointers', $pointers);
}
if ($pointers) {
wp_enqueue_script('wpcaptcha-pointers', WPCAPTCHA_PLUGIN_URL . 'js/wpcaptcha-pointers.js', array('jquery'), self::$version, true);
}
}
} // admin_enqueue_scripts
static function admin_notices()
{
$notices = get_option(WPCAPTCHA_NOTICES_KEY);
if (is_array($notices)) {
foreach ($notices as $id => $notice) {
WPCaptcha_Utility::wp_kses_wf('
' . $notice['text'] . '
');
if ($notice['once'] == true) {
unset($notices[$id]);
update_option(WPCAPTCHA_NOTICES_KEY, $notices);
}
}
}
} // notices
static function add_notice($id = false, $text = '', $type = 'warning', $show_once = false)
{
if ($id) {
$notices = get_option(WPCAPTCHA_NOTICES_KEY, array());
$notices[$id] = array('text' => $text, 'type' => $type, 'once' => $show_once);
update_option(WPCAPTCHA_NOTICES_KEY, $notices);
}
}
/**
* Admin menu entry
*
* @since 5.0
*
* @return null
*/
static function admin_menu()
{
add_options_page(
__('Advanced Google reCAPTCHA', 'advanced-google-recaptcha'),
__('Advanced Google reCAPTCHA', 'advanced-google-recaptcha'),
'manage_options',
'wpcaptcha',
array(__CLASS__, 'main_page')
);
} // admin_menu
/**
* Add settings link to plugins page
*
* @since 5.0
*
* @return null
*/
static function plugin_action_links($links)
{
$settings_link = '' . __('Settings', 'advanced-google-recaptcha') . '';
$pro_link = '' . __('Get EXTRA protection', 'advanced-google-recaptcha') . '';
array_unshift($links, $settings_link);
array_unshift($links, $pro_link);
return $links;
} // plugin_action_links
/**
* Add links to plugin's description in plugins table
*
* @since 5.0
*
* @return null
*/
static function plugin_meta_links($links, $file)
{
if ($file !== 'advanced-google-recaptcha/advanced-google-recaptcha.php') {
return $links;
}
$support_link = '' . __('Support', 'advanced-google-recaptcha') . '';
$links[] = $support_link;
return $links;
} // plugin_meta_links
/**
* Admin footer text
*
* @since 5.0
*
* @return null
*/
static function admin_footer_text($text)
{
if (!self::is_plugin_page()) {
return $text;
}
$text = '';
return $text;
} // admin_footer_text
/**
* Helper function for generating UTM tagged links
*
* @param string $placement Optional. UTM content param.
* @param string $page Optional. Page to link to.
* @param array $params Optional. Extra URL params.
* @param string $anchor Optional. URL anchor part.
*
* @return string
*/
static function generate_web_link($placement = '', $page = '/', $params = array(), $anchor = '')
{
$base_url = 'https://getwpcaptcha.com';
if ('/' != $page) {
$page = '/' . trim($page, '/') . '/';
}
if ($page == '//') {
$page = '/';
}
$parts = array_merge(array('utm_source' => 'advanced-google-recaptcha', 'utm_medium' => 'plugin', 'utm_content' => $placement, 'utm_campaign' => 'wpcaptcha-v' . self::$version), $params);
if (!empty($anchor)) {
$anchor = '#' . trim($anchor, '#');
}
$out = $base_url . $page . '?' . http_build_query($parts, '', '&') . $anchor;
return $out;
} // generate_web_link
/**
* Test if we're on plugin's page
*
* @since 5.0
*
* @return null
*/
static function is_plugin_page()
{
$current_screen = get_current_screen();
if ($current_screen->id == 'settings_page_wpcaptcha') {
return true;
} else {
return false;
}
} // is_plugin_page
/**
* Settings Page HTML
*
* @since 5.0
*
* @return null
*/
static function main_page()
{
if (!current_user_can('manage_options')) {
wp_die('You do not have sufficient permissions to access this page.');
}
$options = WPCaptcha_Setup::get_options();
// auto remove welcome pointer when options are opened
$pointers = get_option(WPCAPTCHA_POINTERS_KEY);
if (isset($pointers['welcome'])) {
unset($pointers['welcome']);
update_option(WPCAPTCHA_POINTERS_KEY, $pointers);
}
echo '';
echo '';
echo '
';
echo '
';
echo '
';
echo '
'; // wrap
} // options_page
/**
* Reset pointers
*
* @since 5.0
*
* @return null
*/
static function reset_pointers()
{
$pointers = array();
$pointers['welcome'] = array('target' => '#menu-settings', 'edge' => 'left', 'align' => 'right', 'content' => 'Thank you for installing the Advanced Google reCAPTCHA plugin! Please open Settings - Advanced Google reCaptcha to set up your captcha and website protection settings.');
update_option(WPCAPTCHA_POINTERS_KEY, $pointers);
} // reset_pointers
/**
* Settings footer submit button HTML
*
* @since 5.0
*
* @return null
*/
static function footer_save_button()
{
echo '';
echo '';
echo '
';
} // footer_save_button
} // class