parent
9a3748aa8e
commit
4828353fc7
@ -1,20 +0,0 @@
|
||||
jQuery(document).ready(function($) {
|
||||
jQuery( '#select404page' ).change(function() {
|
||||
jQuery( '#edit_404_page, #test_404_page' ).prop( 'disabled', !( jQuery( '#select404page' ).val() == jQuery( '#404page_current_value').text() != 0 ) );
|
||||
});
|
||||
jQuery( '#select404page' ).trigger( 'change' );
|
||||
jQuery( '#edit_404_page' ).click(function() {
|
||||
window.location.href = jQuery( '#404page_edit_link' ).text();
|
||||
});
|
||||
jQuery( '#test_404_page' ).click(function() {
|
||||
window.location.href = jQuery( '#404page_test_link' ).text();
|
||||
});
|
||||
jQuery( '#404page_admin_notice .notice-dismiss' ).click( function() {
|
||||
jQuery.ajax({
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: '404page_dismiss_admin_notice'
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
@ -1,641 +1,74 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: 404page - your smart custom 404 error page
|
||||
Plugin URI: http://petersplugins.com/free-wordpress-plugins/404page/
|
||||
Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
|
||||
Version: 2.3
|
||||
Author: Peter's Plugins, smartware.cc
|
||||
Author URI: http://petersplugins.com
|
||||
Text Domain: 404page
|
||||
License: GPL2+
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
/**
|
||||
* The 404page Plugin
|
||||
*
|
||||
* 404page allows creation of 404 error pages in WordPress admin
|
||||
*
|
||||
* @wordpress-plugin
|
||||
* Plugin Name: 404page - your smart custom 404 error page
|
||||
* Plugin URI: https://petersplugins.com/free-wordpress-plugins/404page/
|
||||
* Description: Custom 404 the easy way! Set any page as custom 404 error page. No coding needed. Works with (almost) every Theme.
|
||||
* Version: 3.3
|
||||
* Author: Peter Raschendorfer
|
||||
* Author URI: https://petersplugins.com
|
||||
* Text Domain: 404page
|
||||
* License: GPL2+
|
||||
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||
*/
|
||||
|
||||
|
||||
// If this file is called directly, abort
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
define( 'PP_404', true );
|
||||
|
||||
class Smart404Page {
|
||||
public $plugin_name;
|
||||
public $plugin_slug;
|
||||
public $version;
|
||||
private $wp_url;
|
||||
private $my_url;
|
||||
private $dc_url;
|
||||
public $settings;
|
||||
private $template;
|
||||
private $postid;
|
||||
|
||||
public function __construct() {
|
||||
$this->plugin_name = '404page';
|
||||
$this->plugin_slug = '404page';
|
||||
$this->version = '2.3';
|
||||
$this->get_settings();
|
||||
$this->init();
|
||||
}
|
||||
|
||||
// get all settings
|
||||
private function get_settings() {
|
||||
$this->settings = array();
|
||||
$this->settings['404page_page_id'] = $this->get_404page_id();
|
||||
$this->settings['404page_hide'] = $this->get_404page_hide();
|
||||
$this->settings['404page_fire_error'] = $this->get_404page_fire_error();
|
||||
// $this->settings['404page_method'] = $this->get_404page_method(); --> moved to set_mode in v 2.2 because this may be too early here
|
||||
$this->settings['404page_native'] = false;
|
||||
}
|
||||
|
||||
// do plugin init
|
||||
private function init() {
|
||||
|
||||
// as of v 2.2 always call set_mode
|
||||
add_action( 'init', array( $this, 'set_mode' ) );
|
||||
|
||||
if ( !is_admin() ) {
|
||||
|
||||
add_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) );
|
||||
add_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 );
|
||||
|
||||
} else {
|
||||
|
||||
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
||||
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
||||
add_action( 'admin_head', array( $this, 'admin_css' ) );
|
||||
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_settings_link' ) );
|
||||
|
||||
if ( $this->settings['404page_hide'] and $this->settings['404page_page_id'] > 0 ) {
|
||||
add_action( 'pre_get_posts' ,array ( $this, 'exclude_404page' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// init filters
|
||||
function set_mode() {
|
||||
|
||||
$this->settings['404page_method'] = $this->get_404page_method();
|
||||
|
||||
if ( !is_admin() ) {
|
||||
|
||||
if ( defined( 'CUSTOMIZR_VER' ) ) {
|
||||
|
||||
// Customizr Compatibility Mode
|
||||
|
||||
add_filter( 'tc_404_header_content', array( $this, 'show404title_customizr_mode' ), 999 );
|
||||
add_filter( 'tc_404_content', array( $this, 'show404_customizr_mode' ), 999 );
|
||||
add_filter( 'tc_404_selectors', array( $this, 'show404articleselectors_customizr_mode' ), 999 );
|
||||
|
||||
} elseif ( $this->settings['404page_method'] != 'STD' ) {
|
||||
|
||||
// Compatibility Mode
|
||||
add_filter( 'posts_results', array( $this, 'show404_compatiblity_mode' ), 999 );
|
||||
|
||||
} else {
|
||||
|
||||
// Standard Mode
|
||||
add_filter( '404_template', array( $this, 'show404_standard_mode' ), 999 );
|
||||
if ( $this->settings['404page_fire_error'] ) {
|
||||
add_action( 'template_redirect', array( $this, 'do_404_header_standard_mode' ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// show 404 page - Standard Mode
|
||||
function show404_standard_mode( $template ) {
|
||||
|
||||
global $wp_query;
|
||||
$pageid = $this->settings['404page_page_id'];
|
||||
if ( $pageid > 0 ) {
|
||||
if ( ! $this->settings['404page_native'] ) {
|
||||
$wp_query = null;
|
||||
$wp_query = new WP_Query();
|
||||
$wp_query->query( 'page_id=' . $pageid );
|
||||
$wp_query->the_post();
|
||||
$template = get_page_template();
|
||||
rewind_posts();
|
||||
add_filter( 'body_class', array( $this, 'add_404_body_class' ) );
|
||||
}
|
||||
$this->do_404page_action();
|
||||
}
|
||||
return $template;
|
||||
|
||||
}
|
||||
|
||||
// show 404 page - Compatibility Mode
|
||||
function show404_compatiblity_mode( $posts ) {
|
||||
|
||||
// remove the filter so we handle only the first query - no custom queries
|
||||
remove_filter( 'posts_results', array( $this, 'show404_compatiblity_mode' ), 999 );
|
||||
|
||||
$pageid = $this->settings['404page_page_id'];
|
||||
if ( $pageid > 0 && ! $this->settings['404page_native'] ) {
|
||||
if ( empty( $posts ) && is_main_query() && !is_robots() && !is_home() && !is_feed() && !is_search() && !is_archive() && ( !defined('DOING_AJAX') || !DOING_AJAX ) ) {
|
||||
// we need to get the 404 page
|
||||
|
||||
$pageid = $this->get_page_id( $pageid );
|
||||
|
||||
// as of v2.1 we do not alter the posts argument here because this does not work with SiteOrigin's Page Builder Plugin, template_include filter introduced
|
||||
$this->postid = $pageid;
|
||||
$this->template = get_page_template_slug( $pageid );
|
||||
if ( $this->template == '' ) {
|
||||
$this->template = get_page_template();
|
||||
}
|
||||
add_action( 'wp', array( $this, 'do_404_header' ) );
|
||||
add_filter( 'body_class', array( $this, 'add_404_body_class' ) );
|
||||
add_filter( 'template_include', array( $this, 'change_404_template' ), 999 );
|
||||
|
||||
$posts[] = get_post( $pageid );
|
||||
|
||||
$this->do_404page_action();
|
||||
|
||||
} elseif ( 1 == count( $posts ) && 'page' == $posts[0]->post_type ) {
|
||||
|
||||
// Do a 404 if the 404 page is opened directly
|
||||
if ( $this->settings['404page_fire_error'] ) {
|
||||
$curpageid = $posts[0]->ID;
|
||||
|
||||
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
||||
|
||||
// WPML is active - get the post ID of the default language
|
||||
global $sitepress;
|
||||
$curpageid = apply_filters( 'wpml_object_id', $curpageid, 'page', $sitepress->get_default_language() );
|
||||
$pageid = apply_filters( 'wpml_object_id', $pageid, 'page', $sitepress->get_default_language() );
|
||||
|
||||
} elseif ( defined( 'POLYLANG_VERSION' ) ) {
|
||||
|
||||
// Polylang is active - get the post ID of the default language
|
||||
$curpageid = pll_get_post( $curpageid, pll_default_language() );
|
||||
$pageid = pll_get_post( $pageid, pll_default_language() );
|
||||
|
||||
}
|
||||
|
||||
if ( $pageid == $curpageid ) {
|
||||
add_action( 'wp', array( $this, 'do_404_header' ) );
|
||||
add_filter( 'body_class', array( $this, 'add_404_body_class' ) );
|
||||
$this->do_404page_action();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} elseif ( $pageid > 0 && $this->settings['404page_native'] ) {
|
||||
$this->do_404page_action();
|
||||
}
|
||||
return $posts;
|
||||
}
|
||||
|
||||
// this function overrides the page template in compatibilty mode
|
||||
function change_404_template( $template ) {
|
||||
// we have to check if the template file is there because if the theme was changed maybe a wrong template is stored in the database
|
||||
$new_template = locate_template( array( $this->template ) );
|
||||
if ( '' != $new_template ) {
|
||||
return $new_template ;
|
||||
}
|
||||
return $template;
|
||||
}
|
||||
|
||||
// send a 404 HTTP header - Standard Mode
|
||||
function do_404_header_standard_mode() {
|
||||
if ( is_page() && get_the_ID() == $this->settings['404page_page_id'] && !is_404() ) {
|
||||
status_header( 404 );
|
||||
nocache_headers();
|
||||
$this->do_404page_action();
|
||||
}
|
||||
}
|
||||
|
||||
// send a 404 HTTP header - Compatibility Mode
|
||||
function do_404_header() {
|
||||
// remove the action so we handle only the first query - no custom queries
|
||||
remove_action( 'wp', array( $this, 'do_404_header' ) );
|
||||
status_header( 404 );
|
||||
nocache_headers();
|
||||
}
|
||||
|
||||
// adds the error404 class to the body classes
|
||||
function add_404_body_class( $classes ) {
|
||||
$classes[] = 'error404';
|
||||
return $classes;
|
||||
}
|
||||
|
||||
// show title - Customizr Compatibility Mode
|
||||
function show404title_customizr_mode( $title ) {
|
||||
if ( ! $this->settings['404page_native'] ) {
|
||||
return '<h1 class="entry-title">' . get_the_title( $this->settings['404page_page_id'] ) . '</h1>';
|
||||
} else {
|
||||
return $title;
|
||||
}
|
||||
}
|
||||
|
||||
// show content - Customizr Compatibility Mode
|
||||
function show404_customizr_mode( $content ) {
|
||||
if ( ! $this->settings['404page_native'] ) {
|
||||
return '<div class="entry-content">' . apply_filters( 'the_content', get_post_field( 'post_content', $this->settings['404page_page_id'] ) ) . '</div>';
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
$this->do_404page_action();
|
||||
}
|
||||
|
||||
// change article selectors - Customizr Compatibility Mode
|
||||
function show404articleselectors_customizr_mode( $selectors ) {
|
||||
if ( ! $this->settings['404page_native'] ) {
|
||||
return 'id="post-' . $this->settings['404page_page_id'] . '" ' . 'class="' . join( ' ', get_post_class( 'row-fluid', $this->settings['404page_page_id'] ) ) . '"';
|
||||
} else {
|
||||
return $selectors;
|
||||
}
|
||||
}
|
||||
|
||||
// init the admin section
|
||||
function admin_init() {
|
||||
$this->wp_url = 'https://wordpress.org/plugins/' . $this->plugin_slug;
|
||||
$this->my_url = 'http://petersplugins.com/free-wordpress-plugins/' . $this->plugin_slug;
|
||||
$this->dc_url = 'http://petersplugins.com/docs/' . $this->plugin_slug;
|
||||
load_plugin_textdomain( '404page' );
|
||||
add_settings_section( '404page-settings', null, null, '404page_settings_section' );
|
||||
register_setting( '404page_settings', '404page_page_id' );
|
||||
register_setting( '404page_settings', '404page_hide' );
|
||||
register_setting( '404page_settings', '404page_method' );
|
||||
register_setting( '404page_settings', '404page_fire_error' );
|
||||
add_settings_field( '404page_settings_404page', __( 'Page to be displayed as 404 page', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_select_page"></a>' , array( $this, 'admin_404page' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_page_id' ) );
|
||||
add_settings_field( '404page_settings_hide', __( 'Hide 404 page', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_hide_page"></a>' , array( $this, 'admin_hide' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_hide' ) );
|
||||
add_settings_field( '404page_settings_fire', __( 'Fire 404 error', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_fire_404"></a>' , array( $this, 'admin_fire404' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_fire_error' ) );
|
||||
add_settings_field( '404page_settings_method', __( 'Operating Method', '404page' ) . ' <a class="dashicons dashicons-editor-help" href="' . $this->dc_url . '/#settings_operating_method"></a>' , array( $this, 'admin_method' ), '404page_settings_section', '404page-settings', array( 'label_for' => '404page_method' ) );
|
||||
}
|
||||
|
||||
// add css
|
||||
function admin_css() {
|
||||
echo '<style type="text/css">#select404page {width: 100%; }';
|
||||
if ( $this->settings['404page_page_id'] > 0 ) {
|
||||
echo ' #the-list #post-' . $this->settings['404page_page_id'] . ' .column-title {min-height: 32px; background-position: left top; background-repeat: no-repeat; background-image: url(' . plugins_url( 'pluginicon.png', __FILE__ ) . '); padding-left: 40px;}';
|
||||
}
|
||||
echo '</style>';
|
||||
}
|
||||
|
||||
// handle the settings field page id
|
||||
function admin_404page() {
|
||||
if ( $this->settings['404page_page_id'] < 0 ) {
|
||||
echo '<div class="error form-invalid" style="line-height: 3em">' . __( 'The page you have selected as 404 page does not exist anymore. Please choose another page.', '404page' ) . '</div>';
|
||||
}
|
||||
wp_dropdown_pages( array( 'name' => '404page_page_id', 'id' => 'select404page', 'echo' => 1, 'show_option_none' => __( '— NONE (WP default 404 page) —', '404page'), 'option_none_value' => '0', 'selected' => $this->settings['404page_page_id'] ) );
|
||||
echo '<div id="404page_edit_link" style="display: none">' . get_edit_post_link( $this->get_404page_id() ) . '</div>';
|
||||
echo '<div id="404page_test_link" style="display: none">' . get_site_url() . '/' . md5( rand() ) . '/' . md5( rand() ) . '/' . md5( rand() ) . '</div>';
|
||||
echo '<div id="404page_current_value" style="display: none">' . $this->get_404page_id() . '</div>';
|
||||
echo '<p class="submit"><input type="button" name="edit_404_page" id="edit_404_page" class="button secondary" value="' . __( 'Edit Page', '404page' ) . '" /> <input type="button" name="test_404_page" id="test_404_page" class="button secondary" value="' . __( 'Test 404 error', '404page' ) . '" /></p>';
|
||||
}
|
||||
|
||||
// handle the settings field hide
|
||||
function admin_hide() {
|
||||
echo '<p><input type="checkbox" id="404page_hide" name="404page_hide" value="1"' . checked( true, $this->settings['404page_hide'], false ) . '/>';
|
||||
echo '<label for="404page_hide">' . __( 'Hide the selected page from the Pages list', '404page' ) . '</label></p>';
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'For Administrators the page is always visible.', '404page' ) . '</p>';
|
||||
}
|
||||
|
||||
// handle the settings field fire 404 error
|
||||
function admin_fire404() {
|
||||
echo '<p><input type="checkbox" id="404page_fire_error" name="404page_fire_error" value="1"' . checked( true, $this->settings['404page_fire_error'], false ) . '/>';
|
||||
echo '<label for="404page_fire_error">' . __( 'Send an 404 error if the page is accessed directly by its URL', '404page' ) . '</label></p>';
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'Uncheck this if you want the selected page to be accessible.', '404page' ) . '</p>';
|
||||
if ( function_exists( 'wpsupercache_activate' ) ) {
|
||||
echo '<p><span class="dashicons dashicons-warning"></span> <strong>' . __( 'WP Super Cache Plugin detected', '404page' ) . '</strong>. ' . __ ( 'If the page you selected as 404 error page is in cache, always a HTTP code 200 is sent. To avoid this and send a HTTP code 404 you have to exlcude this page from caching', '404page' ) . ' (<a href="' . admin_url( 'options-general.php?page=wpsupercache&tab=settings#rejecturi' ) . '">' . __( 'Click here', '404page' ) . '</a>).<br />(<a href="' . $this->dc_url . '/#wp_super_cache">' . __( 'Read more', '404page' ) . '</a>)</p>';
|
||||
}
|
||||
}
|
||||
|
||||
// handle the settings field method
|
||||
function admin_method() {
|
||||
|
||||
if ( $this->settings['404page_native'] ) {
|
||||
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'This setting is not available because the Theme you are using natively supports the 404page plugin.', '404page' ) . ' (<a href="' . $this->dc_url . '/#native_mode">' . __( 'Read more', '404page' ) . '</a>)</p>';
|
||||
|
||||
} elseif ( defined( 'CUSTOMIZR_VER' ) ) {
|
||||
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'This setting is not availbe because the 404page Plugin works in Customizr Compatibility Mode.', '404page' ) . ' (<a href="' . $this->dc_url . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)</p>';
|
||||
|
||||
} elseif ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
||||
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'This setting is not availbe because the 404page Plugin works in WPML Mode.', '404page' ) . ' (<a href="' . $this->dc_url . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)</p>';
|
||||
|
||||
} elseif ( defined( 'POLYLANG_VERSION' ) ) {
|
||||
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'This setting is not availbe because the 404page Plugin works in Polylang Mode.', '404page' ) . ' (<a href="' . $this->dc_url . '/#special_modes">' . __( 'Read more', '404page' ) . '</a>)</p>';
|
||||
|
||||
} else {
|
||||
|
||||
echo '<p><input type="radio" id="404page_settings_method_standard" name="404page_method" value="STD"' . checked( 'STD', $this->settings['404page_method'], false ) . ' />';
|
||||
echo '<label for="404page_settings_method_standard">' . __( 'Standard Mode', '404page' ) . '</label></p>';
|
||||
|
||||
echo '<p><input type="radio" id="404page_settings_method_compatibility" name="404page_method" value="CMP"' . checked( 'CMP', $this->settings['404page_method'], false ) . '/>';
|
||||
echo '<label for="404page_settings_method_compatibility">' . __( 'Compatibility Mode', '404page' ) . '</label></p>';
|
||||
|
||||
echo '<p><span class="dashicons dashicons-info"></span> ' . __( 'Standard Mode uses the WordPress Template System and should work in most cases. If the 404page plugin does not work properly, probably you are using a theme or plugin that modifies the WordPress Template System. In this case the Compatibility Mode maybe can fix the problem, although it cannot be guaranteed that every possible configuration can be handled by Compatibility Mode. Standard Mode is the recommended method, only switch to Compatibility Mode if you have any problems.', '404page' ) . '</p>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// this function hides the selected page from the list of pages
|
||||
function exclude_404page( $query ) {
|
||||
if ( $this->settings['404page_page_id'] > 0 ) {
|
||||
global $pagenow;
|
||||
|
||||
$post_type = $query->get( 'post_type' );
|
||||
/**
|
||||
* Load core plugin class and run the plugin
|
||||
*/
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
|
||||
$pp_404page = new PP_404Page( __FILE__ );
|
||||
|
||||
// as of v 2.3 we check the post_type on front end
|
||||
if( ( is_admin() && ( 'edit.php' == $pagenow && !current_user_can( 'create_users' ) ) ) || ( ! is_admin() && ( !empty( $post_type) && ( ('page' === $post_type || 'any' === $post_type) || ( is_array( $post_type ) && in_array( 'page', $post_type ) ) ) )) ) {
|
||||
$pageid = $this->settings['404page_page_id'];
|
||||
|
||||
if ( ! is_admin() ) {
|
||||
$pageid = $this->get_page_id( $pageid );
|
||||
}
|
||||
|
||||
// as of v 2.3 we add the ID of the 404 page to post__not_in
|
||||
// using just $query->set() overrides existing settings but not adds a new setting
|
||||
$query->set( 'post__not_in', array_merge( (array)$query->get( 'post__not_in', array() ), array( $pageid ) ) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this function removes the 404 page from get_pages result array
|
||||
function remove_404page_from_array( $pages, $r ) {
|
||||
if ( $this->settings['404page_page_id'] > 0 ) {
|
||||
$pageid = $this->get_page_id( $this->settings['404page_page_id'] );
|
||||
for ( $i = 0; $i < sizeof( $pages ); $i++ ) {
|
||||
if ( $pages[$i]->ID == $pageid ) {
|
||||
unset( $pages[$i] );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_values( $pages );
|
||||
}
|
||||
|
||||
// adds the options page to admin menu
|
||||
function admin_menu() {
|
||||
$page_handle = add_theme_page ( __( '404 Error Page', "404page" ), __( '404 Error Page', '404page' ), 'manage_options', '404pagesettings', array( $this, 'admin_page' ) );
|
||||
add_action( 'admin_print_scripts', array( $this, 'admin_js' ) );
|
||||
}
|
||||
|
||||
// adds javascript to the 404page settings page
|
||||
function admin_js() {
|
||||
wp_enqueue_script( '404pagejs', plugins_url( '/404page.js', __FILE__ ), 'jquery', $this->version, true );
|
||||
}
|
||||
|
||||
// creates the options page
|
||||
function admin_page() {
|
||||
if ( !current_user_can( 'manage_options' ) ) {
|
||||
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
||||
}
|
||||
?>
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<h2 style="min-height: 32px; line-height: 32px; padding-left: 40px; background-image: url(<?php echo plugins_url( 'pluginicon.png', __FILE__ ); ?>); background-repeat: no-repeat; background-position: left center"><a href="<?php echo $this->my_url; ?>">404page</a> <?php echo __( 'Settings', '404page' ); ?></h2>
|
||||
<?php settings_errors(); ?>
|
||||
<hr />
|
||||
<p>Plugin Version: <?php echo $this->version; ?> <a class="dashicons dashicons-editor-help" href="<?php echo $this->wp_url; ?>/changelog/"></a></p>
|
||||
<div id="poststuff">
|
||||
<div id="post-body" class="metabox-holder columns-2">
|
||||
<div id="post-body-content">
|
||||
<div class="meta-box-sortables ui-sortable">
|
||||
<form method="post" action="options.php">
|
||||
<div class="postbox">
|
||||
<div class="inside">
|
||||
<?php
|
||||
settings_fields( '404page_settings' );
|
||||
do_settings_sections( '404page_settings_section' );
|
||||
submit_button();
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php { $this->show_meta_boxes(); } ?>
|
||||
</div>
|
||||
<br class="clear">
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// returns the id of the 404 page if one is defined, returns 0 if none is defined, returns -1 if the defined page id does not exist
|
||||
private function get_404page_id() {
|
||||
$pageid = get_option( '404page_page_id', 0 );
|
||||
if ( $pageid != 0 ) {
|
||||
$page = get_post( $pageid );
|
||||
if ( !$page || $page->post_status != 'publish' ) {
|
||||
$pageid = -1;
|
||||
}
|
||||
}
|
||||
return $pageid;
|
||||
}
|
||||
|
||||
// returns the selected method
|
||||
private function get_404page_method() {
|
||||
if ( defined( 'ICL_SITEPRESS_VERSION' ) || defined( 'POLYLANG_VERSION' ) ) {
|
||||
// WPML or Polylang is active
|
||||
return 'CMP';
|
||||
} else {
|
||||
return get_option( '404page_method', 'STD' );
|
||||
}
|
||||
}
|
||||
|
||||
// should we hide the selected 404 page from the page list?
|
||||
private function get_404page_hide() {
|
||||
return (bool)get_option( '404page_hide', false );
|
||||
}
|
||||
|
||||
// should we fire an 404 error if the selected page is accessed directly?
|
||||
private function get_404page_fire_error() {
|
||||
return (bool)get_option( '404page_fire_error', true );
|
||||
}
|
||||
|
||||
// this function gets the id of the translated page if WPML or Polylang is active - otherwise the original pageid is returned
|
||||
private function get_page_id( $pageid ) {
|
||||
|
||||
if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
|
||||
|
||||
// WPML is active
|
||||
$pageid = apply_filters( 'wpml_object_id', $pageid, 'page', true );
|
||||
|
||||
} elseif ( defined( 'POLYLANG_VERSION' ) ) {
|
||||
|
||||
// Polylang is active
|
||||
$translatedpageid = pll_get_post( $pageid );
|
||||
if ( !empty( $translatedpageid ) && 'publish' == get_post_status( $translatedpageid ) ) {
|
||||
$pageid = $translatedpageid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $pageid;
|
||||
|
||||
}
|
||||
|
||||
// make plugin expandable
|
||||
function do_404page_action() {
|
||||
do_action( '404page_after_404' );
|
||||
}
|
||||
|
||||
// show meta boxes
|
||||
function show_meta_boxes() {
|
||||
?>
|
||||
<div id="postbox-container-1" class="postbox-container">
|
||||
<div class="meta-box-sortables">
|
||||
<div class="postbox">
|
||||
<h3><span><?php _e( 'Like this Plugin?', '404page' ); ?></span></h3>
|
||||
<div class="inside">
|
||||
<ul>
|
||||
<li><div class="dashicons dashicons-wordpress"></div> <a href="<?php echo $this->wp_url; ?>/"><?php _e( 'Please rate the plugin', '404page' ); ?></a></li>
|
||||
<li><div class="dashicons dashicons-admin-home"></div> <a href="<?php echo $this->my_url; ?>/"><?php _e( 'Plugin homepage', '404page'); ?></a></li>
|
||||
<li><div class="dashicons dashicons-admin-home"></div> <a href="http://petersplugins.com/"><?php _e( 'Author homepage', '404page' );?></a></li>
|
||||
<li><div class="dashicons dashicons-googleplus"></div> <a href="http://g.petersplugins.com/"><?php _e( 'Authors Google+ Page', '404page' ); ?></a></li>
|
||||
<li><div class="dashicons dashicons-facebook-alt"></div> <a href="http://f.petersplugins.com/"><?php _e( 'Authors facebook Page', '404page' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="postbox">
|
||||
<h3><span><?php _e( 'Need help?', '404page' ); ?></span></h3>
|
||||
<div class="inside">
|
||||
<ul>
|
||||
<li><div class="dashicons dashicons-book-alt"></div> <a href="<?php echo $this->dc_url; ?>"><?php _e( 'Take a look at the Plugin Doc', '404page' ); ?></a></li>
|
||||
<li><div class="dashicons dashicons-wordpress"></div> <a href="<?php echo $this->wp_url; ?>/faq/"><?php _e( 'Take a look at the FAQ section', '404page' ); ?></a></li>
|
||||
<li><div class="dashicons dashicons-wordpress"></div> <a href="http://wordpress.org/support/plugin/<?php echo $this->plugin_slug; ?>/"><?php _e( 'Take a look at the Support section', '404page'); ?></a></li>
|
||||
<li><div class="dashicons dashicons-admin-comments"></div> <a href="http://petersplugins.com/contact/"><?php _e( 'Feel free to contact the Author', '404page' ); ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="postbox">
|
||||
<h3><span><?php _e( 'Translate this Plugin', '404page' ); ?></span></h3>
|
||||
<div class="inside">
|
||||
<p><?php _e( 'It would be great if you\'d support the 404page Plugin by adding a new translation or keeping an existing one up to date!', '404page' ); ?></p>
|
||||
<p><a href="https://translate.wordpress.org/projects/wp-plugins/<?php echo $this->plugin_slug; ?>"><?php _e( 'Translate online', '404page' ); ?></a></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// add a link to settings page in plugin list
|
||||
function add_settings_link( $links ) {
|
||||
return array_merge( $links, array( '<a href="' . admin_url( 'themes.php?page=404pagesettings' ) . '">' . __( 'Settings', '404page' ) . '</a>') );
|
||||
}
|
||||
|
||||
// uninstall plugin
|
||||
function uninstall() {
|
||||
if( is_multisite() ) {
|
||||
$this->uninstall_network();
|
||||
} else {
|
||||
$this->uninstall_single();
|
||||
}
|
||||
}
|
||||
|
||||
// uninstall network wide
|
||||
function uninstall_network() {
|
||||
global $wpdb;
|
||||
$activeblog = $wpdb->blogid;
|
||||
$blogids = $wpdb->get_col( esc_sql( 'SELECT blog_id FROM ' . $wpdb->blogs ) );
|
||||
foreach ($blogids as $blogid) {
|
||||
switch_to_blog( $blogid );
|
||||
$this->uninstall_single();
|
||||
}
|
||||
switch_to_blog( $activeblog );
|
||||
}
|
||||
|
||||
// uninstall single blog
|
||||
function uninstall_single() {
|
||||
foreach ( $this->settings as $key => $value) {
|
||||
delete_option( $key );
|
||||
}
|
||||
}
|
||||
|
||||
// *
|
||||
// * functions for theme usage
|
||||
// *
|
||||
|
||||
// check if there's a custom 404 page set
|
||||
function pp_404_is_active() {
|
||||
return ( $this->settings['404page_page_id'] > 0 );
|
||||
}
|
||||
|
||||
// activate the native theme support
|
||||
function pp_404_set_native_support() {
|
||||
$this->settings['404page_native'] = true;
|
||||
}
|
||||
|
||||
// get the title - native theme support
|
||||
function pp_404_get_the_title() {
|
||||
$title = '';
|
||||
if ( $this->settings['404page_page_id'] > 0 && $this->settings['404page_native'] ) {
|
||||
$title = get_the_title( $this->settings['404page_page_id'] );
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
// print title - native theme support
|
||||
function pp_404_the_title() {
|
||||
echo $this->pp_404_get_the_title();
|
||||
}
|
||||
|
||||
// get the content - native theme support
|
||||
function pp_404_get_the_content() {
|
||||
$content = '';
|
||||
if ( $this->settings['404page_page_id'] > 0 && $this->settings['404page_native'] ) {
|
||||
$content = apply_filters( 'the_content', get_post_field( 'post_content', $this->settings['404page_page_id'] ) );
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
// print content - native theme support
|
||||
function pp_404_the_content() {
|
||||
echo $this->pp_404_get_the_content();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$smart404page = new Smart404Page();
|
||||
/**
|
||||
* Theme functions
|
||||
*/
|
||||
|
||||
// this function can be used by a theme to check if there's an active custom 404 page
|
||||
function pp_404_is_active() {
|
||||
global $smart404page;
|
||||
return $smart404page->pp_404_is_active();
|
||||
global $pp_404page;
|
||||
return $pp_404page->pp_404_is_active();
|
||||
}
|
||||
|
||||
// this function can be used by a theme to activate native support
|
||||
function pp_404_set_native_support() {
|
||||
global $smart404page;
|
||||
$smart404page->pp_404_set_native_support();
|
||||
global $pp_404page;
|
||||
$pp_404page->pp_404_set_native_support();
|
||||
}
|
||||
|
||||
// this function can be used by a theme to get the title of the custom 404 page in native support
|
||||
function pp_404_get_the_title() {
|
||||
global $smart404page;
|
||||
return $smart404page->pp_404_get_the_title();
|
||||
global $pp_404page;
|
||||
return $pp_404page->pp_404_get_the_title();
|
||||
}
|
||||
|
||||
// this function can be used by a theme to print out the title of the custom 404 page in native support
|
||||
function pp_404_the_title() {
|
||||
global $smart404page;
|
||||
$smart404page->pp_404_the_title();
|
||||
global $pp_404page;
|
||||
$pp_404page->pp_404_the_title();
|
||||
}
|
||||
|
||||
// this function can be used by a theme to get the content of the custom 404 page in native support
|
||||
function pp_404_get_the_content() {
|
||||
global $smart404page;
|
||||
return $smart404page->pp_404_get_the_content();
|
||||
global $pp_404page;
|
||||
return $pp_404page->pp_404_get_the_content();
|
||||
}
|
||||
|
||||
// this function can be used by a theme to print out the content of the custom 404 page in native support
|
||||
function pp_404_the_content() {
|
||||
global $smart404page;
|
||||
return $smart404page->pp_404_the_content();
|
||||
global $pp_404page;
|
||||
return $pp_404page->pp_404_the_content();
|
||||
}
|
||||
|
||||
?>
|
@ -0,0 +1,126 @@
|
||||
#pp-404page-settings h1 {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
#pp-plugin-info-404page {
|
||||
min-height: 48px;
|
||||
line-height: 48px;
|
||||
vertical-align: middle;
|
||||
padding-left: 60px;
|
||||
background-repeat: no-repeat;
|
||||
background-position: left center;
|
||||
}
|
||||
|
||||
.rtl #pp-plugin-info-404page {
|
||||
padding-left: 0;
|
||||
padding-right: 60px;
|
||||
background-position: right center;
|
||||
}
|
||||
|
||||
#pp-plugin-info-404page span {
|
||||
float: right;
|
||||
padding-left: 50px;
|
||||
}
|
||||
|
||||
.rtl #pp-plugin-info-404page span {
|
||||
float: left;
|
||||
padding-left: 0;
|
||||
padding-right: 50px;
|
||||
}
|
||||
|
||||
#pp-plugin-info-404page .dashicons {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#select404page {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#pp-404page-settings .form-table th, .form-table td {
|
||||
display: block;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
#pp-404page-settings .form-table th {
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#pp-404page-settings .form-table td {
|
||||
padding: 0;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#pp-404page-settings .form-table td p {
|
||||
padding: 0;
|
||||
line-height: 1.2;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#pp-seetings-advanced .form-table th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pp-404page-settings input[type="checkbox"] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#pp-404page-settings input[type="checkbox"] + label.check {
|
||||
cursor: pointer;
|
||||
text-indent: -9999px;
|
||||
width: 80px;
|
||||
height: 40px;
|
||||
background: grey;
|
||||
display: block;
|
||||
border-radius: 40px;
|
||||
position: relative;
|
||||
float: left;
|
||||
margin-right: 40px;
|
||||
}
|
||||
|
||||
.rtl #pp-404page-settings input[type="checkbox"] + label.check {
|
||||
float: right;
|
||||
margin-left: 40px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
#pp-404page-settings input[type="checkbox"]:disabled + label.check {
|
||||
background-color: #DDD;
|
||||
}
|
||||
|
||||
#pp-404page-settings input[type="checkbox"] + label.check:after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 5px;
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
background: #fff;
|
||||
border-radius: 30px;
|
||||
transition: 0.3s;
|
||||
}
|
||||
|
||||
body:not(.rtl) #pp-404page-settings input[type="checkbox"] + label.check:after, .rtl #pp-404page-settings input[type="checkbox"]:enabled:checked + label.check:after {
|
||||
left: 5px;
|
||||
transform: none;
|
||||
}
|
||||
|
||||
#pp-404page-settings input[type="checkbox"]:enabled:checked + label.check {
|
||||
background: #104060;
|
||||
}
|
||||
|
||||
body:not(.rtl) #pp-404page-settings input[type="checkbox"]:enabled:checked + label.check:after, .rtl #pp-404page-settings input[type="checkbox"] + label.check:after {
|
||||
left: calc(100% - 5px);
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
|
||||
#pp-404page-settings select {
|
||||
border: 1px solid #104060;
|
||||
border-radius:5px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
#pp-404page-settings .dashicons-warning, #pp-404page-settings input[type="checkbox"] + label.check.warning:before {
|
||||
color: #d54e21;
|
||||
}
|
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
@ -0,0 +1,12 @@
|
||||
jQuery(document).ready(function($) {
|
||||
$( '#select404page' ).change(function() {
|
||||
$( '#edit_404_page, #test_404_page' ).prop( 'disabled', !( $( '#select404page' ).val() == $( '#404page_current_value').text() != 0 ) );
|
||||
});
|
||||
$( '#select404page' ).trigger( 'change' );
|
||||
$( '#edit_404_page' ).click(function() {
|
||||
window.location.href = $( '#404page_edit_link' ).text();
|
||||
});
|
||||
$( '#test_404_page' ).click(function() {
|
||||
window.location.href = $( '#404page_test_link' ).text();
|
||||
});
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
$( '.pp-404page-admin-notice' ).on( 'click', '.notice-dismiss', function ( event ) {
|
||||
event.preventDefault();
|
||||
data = {
|
||||
action: 'pp_404page_dismiss_admin_notice',
|
||||
pp_404page_dismiss_admin_notice: $( this ).parent().attr( 'id' )
|
||||
};
|
||||
$.post( ajaxurl, data );
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
After Width: | Height: | Size: 1.5 KiB |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
@ -0,0 +1 @@
|
||||
<?php // Silence is golden
|
Before Width: | Height: | Size: 934 B |
@ -1,12 +1,27 @@
|
||||
<?php
|
||||
// 404page uninstall
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN || dirname( WP_UNINSTALL_PLUGIN ) != dirname( plugin_basename( __FILE__ ) ) ) {
|
||||
status_header( 404 );
|
||||
exit;
|
||||
}
|
||||
|
||||
include_once plugin_dir_path( __FILE__ ) . '404page.php';
|
||||
/**
|
||||
* The 404page Plugin Uninstall
|
||||
*/
|
||||
|
||||
|
||||
$smart404page->uninstall();
|
||||
// If this file is called directly, abort
|
||||
if ( ! defined( 'WPINC' ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
// If this is somehow accessed withou plugin uninstall is requested, abort
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) || ! WP_UNINSTALL_PLUGIN || dirname( WP_UNINSTALL_PLUGIN ) != dirname( plugin_basename( __FILE__ ) ) ) {
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load core plugin class and run uninstall
|
||||
*/
|
||||
require_once( plugin_dir_path( __FILE__ ) . '/inc/class-404page.php' );
|
||||
$pp_404page = new PP_404Page( __FILE__ );
|
||||
$pp_404page->uninstall();
|
||||
|
||||
?>
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
class Akismet_REST_API {
|
||||
/**
|
||||
* Register the REST API routes.
|
||||
*/
|
||||
public static function init() {
|
||||
if ( ! function_exists( 'register_rest_route' ) ) {
|
||||
// The REST API wasn't integrated into core until 4.4, and we support 4.0+ (for now).
|
||||
return false;
|
||||
}
|
||||
|
||||
register_rest_route( 'akismet/v1', '/key', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_key' ),
|
||||
), array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'set_key' ),
|
||||
'args' => array(
|
||||
'key' => array(
|
||||
'required' => true,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_key' ),
|
||||
'description' => __( 'A 12-character Akismet API key. Available at akismet.com/get/', 'akismet' ),
|
||||
),
|
||||
),
|
||||
), array(
|
||||
'methods' => WP_REST_Server::DELETABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'delete_key' ),
|
||||
)
|
||||
) );
|
||||
|
||||
register_rest_route( 'akismet/v1', '/settings/', array(
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_settings' ),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'set_boolean_settings' ),
|
||||
'args' => array(
|
||||
'akismet_strictness' => array(
|
||||
'required' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'If true, Akismet will automatically discard the worst spam automatically rather than putting it in the spam folder.', 'akismet' ),
|
||||
),
|
||||
'akismet_show_user_comments_approved' => array(
|
||||
'required' => false,
|
||||
'type' => 'boolean',
|
||||
'description' => __( 'If true, show the number of approved comments beside each comment author in the comments list page.', 'akismet' ),
|
||||
),
|
||||
),
|
||||
)
|
||||
) );
|
||||
|
||||
register_rest_route( 'akismet/v1', '/stats', array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
|
||||
'args' => array(
|
||||
'interval' => array(
|
||||
'required' => false,
|
||||
'type' => 'string',
|
||||
'sanitize_callback' => array( 'Akismet_REST_API', 'sanitize_interval' ),
|
||||
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
|
||||
'default' => 'all',
|
||||
),
|
||||
),
|
||||
) );
|
||||
|
||||
register_rest_route( 'akismet/v1', '/stats/(?P<interval>[\w+])', array(
|
||||
'args' => array(
|
||||
'interval' => array(
|
||||
'description' => __( 'The time period for which to retrieve stats. Options: 60-days, 6-months, all', 'akismet' ),
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'permission_callback' => array( 'Akismet_REST_API', 'privileged_permission_callback' ),
|
||||
'callback' => array( 'Akismet_REST_API', 'get_stats' ),
|
||||
)
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current Akismet API key.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_key( $request = null ) {
|
||||
return rest_ensure_response( Akismet::get_api_key() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API key, if possible.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function set_key( $request ) {
|
||||
if ( defined( 'WPCOM_API_KEY' ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be changed via the API.', 'akismet' ), array( 'status'=> 409 ) ) );
|
||||
}
|
||||
|
||||
$new_api_key = $request->get_param( 'key' );
|
||||
|
||||
if ( ! self::key_is_valid( $new_api_key ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'invalid_key', __( 'The value provided is not a valid and registered API key.', 'akismet' ), array( 'status' => 400 ) ) );
|
||||
}
|
||||
|
||||
update_option( 'wordpress_api_key', $new_api_key );
|
||||
|
||||
return self::get_key();
|
||||
}
|
||||
|
||||
/**
|
||||
* Unset the API key, if possible.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function delete_key( $request ) {
|
||||
if ( defined( 'WPCOM_API_KEY' ) ) {
|
||||
return rest_ensure_response( new WP_Error( 'hardcoded_key', __( 'This site\'s API key is hardcoded and cannot be deleted.', 'akismet' ), array( 'status'=> 409 ) ) );
|
||||
}
|
||||
|
||||
delete_option( 'wordpress_api_key' );
|
||||
|
||||
return rest_ensure_response( true );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Akismet settings.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_settings( $request = null ) {
|
||||
return rest_ensure_response( array(
|
||||
'akismet_strictness' => ( get_option( 'akismet_strictness', '1' ) === '1' ),
|
||||
'akismet_show_user_comments_approved' => ( get_option( 'akismet_show_user_comments_approved', '1' ) === '1' ),
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the Akismet settings.
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function set_boolean_settings( $request ) {
|
||||
foreach ( array(
|
||||
'akismet_strictness',
|
||||
'akismet_show_user_comments_approved',
|
||||
) as $setting_key ) {
|
||||
|
||||
$setting_value = $request->get_param( $setting_key );
|
||||
if ( is_null( $setting_value ) ) {
|
||||
// This setting was not specified.
|
||||
continue;
|
||||
}
|
||||
|
||||
// From 4.7+, WP core will ensure that these are always boolean
|
||||
// values because they are registered with 'type' => 'boolean',
|
||||
// but we need to do this ourselves for prior versions.
|
||||
$setting_value = Akismet_REST_API::parse_boolean( $setting_value );
|
||||
|
||||
update_option( $setting_key, $setting_value ? '1' : '0' );
|
||||
}
|
||||
|
||||
return self::get_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a numeric or string boolean value into a boolean.
|
||||
*
|
||||
* @param mixed $value The value to convert into a boolean.
|
||||
* @return bool The converted value.
|
||||
*/
|
||||
public static function parse_boolean( $value ) {
|
||||
switch ( $value ) {
|
||||
case true:
|
||||
case 'true':
|
||||
case '1':
|
||||
case 1:
|
||||
return true;
|
||||
|
||||
case false:
|
||||
case 'false':
|
||||
case '0':
|
||||
case 0:
|
||||
return false;
|
||||
|
||||
default:
|
||||
return (bool) $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Akismet stats for a given time period.
|
||||
*
|
||||
* Possible `interval` values:
|
||||
* - all
|
||||
* - 60-days
|
||||
* - 6-months
|
||||
*
|
||||
* @param WP_REST_Request $request
|
||||
* @return WP_Error|WP_REST_Response
|
||||
*/
|
||||
public static function get_stats( $request ) {
|
||||
$api_key = Akismet::get_api_key();
|
||||
|
||||
$interval = $request->get_param( 'interval' );
|
||||
|
||||
$stat_totals = array();
|
||||
|
||||
$response = Akismet::http_post( Akismet::build_query( array( 'blog' => get_option( 'home' ), 'key' => $api_key, 'from' => $interval ) ), 'get-stats' );
|
||||
|
||||
if ( ! empty( $response[1] ) ) {
|
||||
$stat_totals[$interval] = json_decode( $response[1] );
|
||||
}
|
||||
|
||||
return rest_ensure_response( $stat_totals );
|
||||
}
|
||||
|
||||
private static function key_is_valid( $key ) {
|
||||
$response = Akismet::http_post(
|
||||
Akismet::build_query(
|
||||
array(
|
||||
'key' => $key,
|
||||
'blog' => get_option( 'home' )
|
||||
)
|
||||
),
|
||||
'verify-key'
|
||||
);
|
||||
|
||||
if ( $response[1] == 'valid' ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function privileged_permission_callback() {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
|
||||
public static function sanitize_interval( $interval, $request, $param ) {
|
||||
$interval = trim( $interval );
|
||||
|
||||
$valid_intervals = array( '60-days', '6-months', 'all', );
|
||||
|
||||
if ( ! in_array( $interval, $valid_intervals ) ) {
|
||||
$interval = 'all';
|
||||
}
|
||||
|
||||
return $interval;
|
||||
}
|
||||
|
||||
public static function sanitize_key( $key, $request, $param ) {
|
||||
return trim( $key );
|
||||
}
|
||||
}
|
@ -1,216 +1,231 @@
|
||||
<div class="wrap">
|
||||
|
||||
<h2><?php esc_html_e( 'Akismet' , 'akismet');?></h2>
|
||||
|
||||
<div class="have-key">
|
||||
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<div class="akismet-masthead__logo-container">
|
||||
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="akismet-lower">
|
||||
<?php if ( Akismet::get_api_key() ) { ?>
|
||||
<?php Akismet_Admin::display_status(); ?>
|
||||
<?php } ?>
|
||||
<?php if ( ! empty( $notices ) ) { ?>
|
||||
<?php foreach ( $notices as $notice ) { ?>
|
||||
<?php Akismet::view( 'notice', $notice ); ?>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ( $stat_totals && isset( $stat_totals['all'] ) && (int) $stat_totals['all']->spam > 0 ) : ?>
|
||||
|
||||
<div class="new-snapshot stats">
|
||||
|
||||
<span style="float:right;margin:10px 15px -5px 0px">
|
||||
<a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>" class=""><?php esc_html_e( 'Summaries' , 'akismet');?></a>
|
||||
</span>
|
||||
|
||||
<iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 215px; overflow: hidden;" src="<?php printf( '//akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=180&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() );?>"></iframe>
|
||||
<ul>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'Past six months' , 'akismet');?></h3>
|
||||
<span><?php echo number_format( $stat_totals['6-months']->spam );?></span>
|
||||
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'All time' , 'akismet');?></h3>
|
||||
<span><?php echo number_format( $stat_totals['all']->spam );?></span>
|
||||
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3>
|
||||
<span><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span>
|
||||
<?php printf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?>
|
||||
|
|
||||
<?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="clearfix"></div>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<div class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Statistics' , 'akismet'); ?></span>
|
||||
</div>
|
||||
<div class="akismet-section-header__actions">
|
||||
<a href="<?php echo esc_url( Akismet_Admin::get_page_url( 'stats' ) ); ?>">
|
||||
<?php esc_html_e( 'Detailed Stats' , 'akismet');?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="akismet-new-snapshot">
|
||||
<iframe allowtransparency="true" scrolling="no" frameborder="0" style="width: 100%; height: 220px; overflow: hidden;" src="<?php printf( '//akismet.com/web/1.0/snapshot.php?blog=%s&api_key=%s&height=200&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() );?>"></iframe>
|
||||
<ul>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'Past six months' , 'akismet');?></h3>
|
||||
<span><?php echo number_format( $stat_totals['6-months']->spam );?></span>
|
||||
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['6-months']->spam, 'akismet' ) ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'All time' , 'akismet');?></h3>
|
||||
<span><?php echo number_format( $stat_totals['all']->spam );?></span>
|
||||
<?php echo esc_html( _n( 'Spam blocked', 'Spam blocked', $stat_totals['all']->spam, 'akismet' ) ); ?>
|
||||
</li>
|
||||
<li>
|
||||
<h3><?php esc_html_e( 'Accuracy' , 'akismet');?></h3>
|
||||
<span><?php echo floatval( $stat_totals['all']->accuracy ); ?>%</span>
|
||||
<?php printf( _n( '%s missed spam', '%s missed spam', $stat_totals['all']->missed_spam, 'akismet' ), number_format( $stat_totals['all']->missed_spam ) ); ?>
|
||||
|
|
||||
<?php printf( _n( '%s false positive', '%s false positives', $stat_totals['all']->false_positives, 'akismet' ), number_format( $stat_totals['all']->false_positives ) ); ?>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
|
||||
<?php if ( $akismet_user ):?>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<div class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Settings' , 'akismet'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="wpcom-stats-meta-box-container" class="metabox-holder"><?php
|
||||
wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false );
|
||||
wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false );
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready( function($) {
|
||||
jQuery('.if-js-closed').removeClass('if-js-closed').addClass('closed');
|
||||
if(typeof postboxes !== 'undefined')
|
||||
postboxes.add_postbox_toggles( 'plugins_page_akismet-key-config' );
|
||||
});
|
||||
</script>
|
||||
<div class="postbox-container" style="width: 55%;margin-right: 10px;">
|
||||
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
||||
<div id="referrers" class="postbox ">
|
||||
<div class="handlediv" title="Click to toggle"><br></div>
|
||||
<h3 class="hndle"><span><?php esc_html_e( 'Settings' , 'akismet');?></span></h3>
|
||||
<form name="akismet_conf" id="akismet-conf" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
|
||||
<div class="inside">
|
||||
<table cellspacing="0" class="akismet-settings">
|
||||
<tbody>
|
||||
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
||||
<tr>
|
||||
<th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php if ( isset( $_GET['ssl_status'] ) ) { ?>
|
||||
<tr>
|
||||
<th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<p>
|
||||
<?php
|
||||
<div class="inside">
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="POST">
|
||||
<table cellspacing="0" class="akismet-settings">
|
||||
<tbody>
|
||||
<?php if ( ! Akismet::predefined_api_key() ) { ?>
|
||||
<tr>
|
||||
<th class="akismet-api-key" width="10%" align="left" scope="row"><?php esc_html_e('API Key', 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<span class="api-key"><input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( get_option('wordpress_api_key') ); ?>" class="<?php echo esc_attr( 'regular-text code ' . $akismet_user->status ); ?>"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php if ( isset( $_GET['ssl_status'] ) ) { ?>
|
||||
<tr>
|
||||
<th align="left" scope="row"><?php esc_html_e( 'SSL Status', 'akismet' ); ?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<p>
|
||||
<?php
|
||||
|
||||
if ( ! function_exists( 'wp_http_supports' ) ) {
|
||||
?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php printf( esc_html( 'Your WordPress installation does not include the function %s; upgrade to the latest version of WordPress.', 'akismet' ), '<code>wp_http_supports</code>' ); ?><?php
|
||||
}
|
||||
else if ( ! wp_http_supports( array( 'ssl' ) ) ) {
|
||||
?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?><?php
|
||||
}
|
||||
else {
|
||||
$ssl_disabled = get_option( 'akismet_ssl_disabled' );
|
||||
if ( ! wp_http_supports( array( 'ssl' ) ) ) {
|
||||
?><b><?php esc_html_e( 'Disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Your Web server cannot make SSL requests; contact your Web host and ask them to add support for SSL requests.', 'akismet' ); ?><?php
|
||||
}
|
||||
else {
|
||||
$ssl_disabled = get_option( 'akismet_ssl_disabled' );
|
||||
|
||||
if ( $ssl_disabled ) {
|
||||
?><b><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?><?php
|
||||
}
|
||||
else {
|
||||
?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php
|
||||
}
|
||||
}
|
||||
if ( $ssl_disabled ) {
|
||||
?><b><?php esc_html_e( 'Temporarily disabled.', 'akismet' ); ?></b> <?php esc_html_e( 'Akismet encountered a problem with a previous SSL request and disabled it temporarily. It will begin using SSL for requests again shortly.', 'akismet' ); ?><?php
|
||||
}
|
||||
else {
|
||||
?><b><?php esc_html_e( 'Enabled.', 'akismet' ); ?></b> <?php esc_html_e( 'All systems functional.', 'akismet' ); ?><?php
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<p>
|
||||
<label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' , 'akismet'); ?>"><input name="akismet_show_user_comments_approved" id="akismet_show_user_comments_approved" value="1" type="checkbox" <?php checked('1', get_option('akismet_show_user_comments_approved')); ?>> <?php esc_html_e('Show the number of approved comments beside each comment author', 'akismet'); ?></label>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
|
||||
<p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
|
||||
<p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
|
||||
</fieldset>
|
||||
<span class="note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<tr>
|
||||
<th align="left" scope="row"><?php esc_html_e('Comments', 'akismet');?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<p>
|
||||
<label for="akismet_show_user_comments_approved" title="<?php esc_attr_e( 'Show approved comments' , 'akismet'); ?>">
|
||||
<input
|
||||
name="akismet_show_user_comments_approved"
|
||||
id="akismet_show_user_comments_approved"
|
||||
value="1"
|
||||
type="checkbox"
|
||||
<?php
|
||||
|
||||
$delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
|
||||
|
||||
printf(
|
||||
_n(
|
||||
'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.',
|
||||
'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
|
||||
$delete_interval,
|
||||
'akismet'
|
||||
),
|
||||
admin_url( 'edit-comments.php?comment_status=spam' ),
|
||||
$delete_interval
|
||||
);
|
||||
// If the option isn't set, or if it's enabled ('1'), or if it was enabled a long time ago ('true'), check the checkbox.
|
||||
checked( true, ( in_array( get_option( 'akismet_show_user_comments_approved' ), array( false, '1', 'true' ), true ) ) );
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="major-publishing-actions">
|
||||
<?php if ( !defined( 'WPCOM_API_KEY' ) ):?>
|
||||
<div id="delete-action">
|
||||
<a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e('Disconnect this account', 'akismet'); ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php wp_nonce_field(Akismet_Admin::NONCE) ?>
|
||||
<div id="publishing-action">
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<input type="submit" name="submit" id="submit" class="button button-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
|
||||
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</form>
|
||||
/>
|
||||
<?php esc_html_e( 'Show the number of approved comments beside each comment author', 'akismet' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="strictness" align="left" scope="row"><?php esc_html_e('Strictness', 'akismet'); ?></th>
|
||||
<td></td>
|
||||
<td align="left">
|
||||
<fieldset><legend class="screen-reader-text"><span><?php esc_html_e('Akismet anti-spam strictness', 'akismet'); ?></span></legend>
|
||||
<p><label for="akismet_strictness_1"><input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked('1', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Silently discard the worst and most pervasive spam so I never see it.', 'akismet'); ?></label></p>
|
||||
<p><label for="akismet_strictness_0"><input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked('0', get_option('akismet_strictness')); ?> /> <?php esc_html_e('Always put spam in the Spam folder for review.', 'akismet'); ?></label></p>
|
||||
</fieldset>
|
||||
<span class="akismet-note"><strong><?php esc_html_e('Note:', 'akismet');?></strong>
|
||||
<?php
|
||||
|
||||
$delete_interval = max( 1, intval( apply_filters( 'akismet_delete_comment_interval', 15 ) ) );
|
||||
|
||||
printf(
|
||||
_n(
|
||||
'Spam in the <a href="%1$s">spam folder</a> older than 1 day is deleted automatically.',
|
||||
'Spam in the <a href="%1$s">spam folder</a> older than %2$d days is deleted automatically.',
|
||||
$delete_interval,
|
||||
'akismet'
|
||||
),
|
||||
admin_url( 'edit-comments.php?comment_status=spam' ),
|
||||
$delete_interval
|
||||
);
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="akismet-card-actions">
|
||||
<?php if ( ! Akismet::predefined_api_key() ) { ?>
|
||||
<div id="delete-action">
|
||||
<a class="submitdelete deletion" href="<?php echo esc_url( Akismet_Admin::get_page_url( 'delete_key' ) ); ?>"><?php esc_html_e('Disconnect this account', 'akismet'); ?></a>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php wp_nonce_field(Akismet_Admin::NONCE) ?>
|
||||
<div id="publishing-action">
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<input type="submit" name="submit" id="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e('Save Changes', 'akismet');?>">
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="postbox-container" style="width:44%;">
|
||||
<div id="normal-sortables" class="meta-box-sortables ui-sortable">
|
||||
<div id="referrers" class="postbox ">
|
||||
<div class="handlediv" title="Click to toggle"><br></div>
|
||||
<h3 class="hndle"><span><?php esc_html_e( 'Account' , 'akismet');?></span></h3>
|
||||
<div class="inside">
|
||||
<table cellspacing="0">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<span><?php echo esc_html( $akismet_user->account_name ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<span><?php
|
||||
if ( 'cancelled' == $akismet_user->status ) :
|
||||
esc_html_e( 'Cancelled', 'akismet' );
|
||||
elseif ( 'suspended' == $akismet_user->status ) :
|
||||
esc_html_e( 'Suspended', 'akismet' );
|
||||
elseif ( 'missing' == $akismet_user->status ) :
|
||||
esc_html_e( 'Missing', 'akismet' );
|
||||
elseif ( 'no-sub' == $akismet_user->status ) :
|
||||
esc_html_e( 'No Subscription Found', 'akismet' );
|
||||
else :
|
||||
esc_html_e( 'Active', 'akismet' );
|
||||
endif; ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $akismet_user->next_billing_date ) : ?>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<span><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="major-publishing-actions">
|
||||
<div id="publishing-action">
|
||||
<?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
|
||||
<?php if ( ! Akismet::predefined_api_key() ) { ?>
|
||||
<div class="akismet-card">
|
||||
<div class="akismet-section-header">
|
||||
<div class="akismet-section-header__label">
|
||||
<span><?php esc_html_e( 'Account' , 'akismet'); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="inside">
|
||||
<table cellspacing="0" border="0" class="akismet-settings">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Subscription Type' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<p><?php echo esc_html( $akismet_user->account_name ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Status' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<p><?php
|
||||
if ( 'cancelled' == $akismet_user->status ) :
|
||||
esc_html_e( 'Cancelled', 'akismet' );
|
||||
elseif ( 'suspended' == $akismet_user->status ) :
|
||||
esc_html_e( 'Suspended', 'akismet' );
|
||||
elseif ( 'missing' == $akismet_user->status ) :
|
||||
esc_html_e( 'Missing', 'akismet' );
|
||||
elseif ( 'no-sub' == $akismet_user->status ) :
|
||||
esc_html_e( 'No Subscription Found', 'akismet' );
|
||||
else :
|
||||
esc_html_e( 'Active', 'akismet' );
|
||||
endif; ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ( $akismet_user->next_billing_date ) : ?>
|
||||
<tr>
|
||||
<th scope="row" align="left"><?php esc_html_e( 'Next Billing Date' , 'akismet');?></th>
|
||||
<td width="5%"/>
|
||||
<td align="left">
|
||||
<p><?php echo date( 'F j, Y', $akismet_user->next_billing_date ); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="akismet-card-actions">
|
||||
<div id="publishing-action">
|
||||
<?php Akismet::view( 'get', array( 'text' => ( $akismet_user->account_type == 'free-api-key' && $akismet_user->status == 'active' ? __( 'Upgrade' , 'akismet') : __( 'Change' , 'akismet') ), 'redirect' => 'upgrade' ) ); ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
<?php endif;?>
|
||||
|
||||
</div>
|
||||
</div>
|
@ -1,97 +1,102 @@
|
||||
<div class="no-key config-wrap"><?php
|
||||
if ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) :
|
||||
if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) :?>
|
||||
<p><?php esc_html_e('Akismet eliminates spam from your site. Register below to get started.', 'akismet'); ?></p>
|
||||
<div class="activate-highlight activate-option">
|
||||
<div class="option-description">
|
||||
<strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
|
||||
<?php echo esc_html( $akismet_user->user_email ); ?>
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<div class="akismet-masthead__logo-container">
|
||||
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="right" target="_blank">
|
||||
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
|
||||
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
|
||||
<input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
|
||||
<input type="hidden" name="redirect" value="plugin-signup"/>
|
||||
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Register for Akismet' , 'akismet'); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
<?php elseif ( $akismet_user->status == 'cancelled' ) :?>
|
||||
<p><?php esc_html_e('Akismet eliminates spam from your site.', 'akismet'); ?></p>
|
||||
<div class="activate-highlight activate-option">
|
||||
<div class="option-description" style="width:75%;">
|
||||
<strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
|
||||
<?php echo esc_html( sprintf( __( 'Your subscription for %s is cancelled' , 'akismet'), $akismet_user->user_email ) ); ?>
|
||||
<div class="akismet-lower">
|
||||
<?php Akismet_Admin::display_status(); ?>
|
||||
|
||||
<div class="akismet-box">
|
||||
<h2><?php esc_html_e( 'Eliminate spam from your site', 'akismet' ); ?></h2>
|
||||
<p><?php esc_html_e( 'Select one of the options below to get started.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
<div class="akismet-boxes">
|
||||
<?php if ( ! Akismet::predefined_api_key() ) { ?>
|
||||
<?php if ( $akismet_user && in_array( $akismet_user->status, array( 'active', 'active-dunning', 'no-sub', 'missing', 'cancelled', 'suspended' ) ) ) { ?>
|
||||
<?php if ( in_array( $akismet_user->status, array( 'no-sub', 'missing' ) ) ) { ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
|
||||
<p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
|
||||
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
|
||||
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
|
||||
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
|
||||
<input type="hidden" name="auto-connect" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
|
||||
<input type="hidden" name="redirect" value="plugin-signup"/>
|
||||
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
|
||||
</form>
|
||||
<?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
|
||||
<p><?php echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
|
||||
</div>
|
||||
<?php } elseif ( $akismet_user->status == 'cancelled' ) { ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
|
||||
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="akismet-right" target="_blank">
|
||||
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
|
||||
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
|
||||
<input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
|
||||
<input type="hidden" name="redirect" value="upgrade"/>
|
||||
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Reactivate Akismet' , 'akismet' ); ?>"/>
|
||||
</form>
|
||||
<p><?php echo esc_html( sprintf( __( 'Your subscription for %s is cancelled.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
|
||||
</div>
|
||||
<?php } elseif ( $akismet_user->status == 'suspended' ) { ?>
|
||||
<div class="centered akismet-box">
|
||||
<h3><?php esc_html_e( 'Connected via Jetpack' , 'akismet' ); ?></h3>
|
||||
<p class="akismet-alert-text"><?php echo esc_html( sprintf( __( 'Your subscription for %s is suspended.' , 'akismet' ), $akismet_user->user_email ) ); ?></p>
|
||||
<p><?php esc_html_e( 'No worries! Get in touch and we’ll sort this out.', 'akismet' ); ?></p>
|
||||
<p><a href="https://akismet.com/contact" class="akismet-button akismet-is-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet' ); ?></a></p>
|
||||
</div>
|
||||
<?php } else { // ask do they want to use akismet account found using jetpack wpcom connection ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Connect via Jetpack', 'akismet' ); ?></h3>
|
||||
<p><?php esc_html_e( 'Use your Jetpack connection to activate Akismet.', 'akismet' ); ?></p>
|
||||
<form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="akismet-right">
|
||||
<input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
||||
<input type="submit" class="akismet-button akismet-is-primary" value="<?php esc_attr_e( 'Connect with Jetpack' , 'akismet' ); ?>"/>
|
||||
</form>
|
||||
<?php echo get_avatar( $akismet_user->user_email, null, null, null, array( 'class' => 'akismet-jetpack-gravatar' ) ); ?>
|
||||
<p><?php echo sprintf( esc_html( __( 'You are connected as %s.', 'akismet' ) ), '<b>' . esc_html( $akismet_user->user_login ) . '</b>' ); ?><br /><span class="akismet-jetpack-email"><?php echo esc_html( $akismet_user->user_email ); ?></span></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Or sign up with a different email address', 'akismet' ); ?></h3>
|
||||
<div class="akismet-right">
|
||||
<?php Akismet::view( 'get', array( 'text' => __( 'Sign up with a different email address' , 'akismet' ), 'classes' => array( 'akismet-button' ) ) ); ?>
|
||||
</div>
|
||||
<p><?php esc_html_e( 'Choose this option to use Akismet independently of your Jetpack connection.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Activate Akismet' , 'akismet' );?></h3>
|
||||
<div class="akismet-right">
|
||||
<?php Akismet::view( 'get', array( 'text' => __( 'Get your API key' , 'akismet' ), 'classes' => array( 'akismet-button', 'akismet-is-primary' ) ) ); ?>
|
||||
</div>
|
||||
<p><?php esc_html_e( 'Log in or sign up now.', 'akismet' ); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<div class="akismet-box">
|
||||
<h3><?php esc_html_e( 'Or enter an API key', 'akismet' ); ?></h3>
|
||||
<p><?php esc_html_e( 'Already have your key? Enter it here.', 'akismet' ); ?> <a href="https://docs.akismet.com/getting-started/api-key/" target="_blank"><?php esc_html_e( '(What is an API key?)', 'akismet' ); ?></a></p>
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<p style="width: 100%; display: flex; flex-wrap: nowrap; box-sizing: border-box;">
|
||||
<input id="key" name="key" type="text" size="15" value="" class="regular-text code" style="flex-grow: 1; margin-right: 1rem;">
|
||||
<input type="submit" name="submit" id="submit" class="akismet-button" value="<?php esc_attr_e( 'Connect with API key', 'akismet' );?>">
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="akismet-box">
|
||||
<h2><?php esc_html_e( 'Manual Configuration', 'akismet' ); ?></h2>
|
||||
<p><?php echo sprintf( esc_html__( 'An Akismet API key has been defined in the %s file for this site.', 'akismet' ), '<code>wp-config.php</code>' ); ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<form name="akismet_activate" id="akismet_activate" action="https://akismet.com/get/" method="post" class="right" target="_blank">
|
||||
<input type="hidden" name="passback_url" value="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>"/>
|
||||
<input type="hidden" name="blog" value="<?php echo esc_url( get_option( 'home' ) ); ?>"/>
|
||||
<input type="hidden" name="user_id" value="<?php echo esc_attr( $akismet_user->ID ); ?>"/>
|
||||
<input type="hidden" name="redirect" value="upgrade"/>
|
||||
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Reactivate Akismet' , 'akismet'); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
<?php elseif ( $akismet_user->status == 'suspended' ) : ?>
|
||||
<p><?php esc_html_e('Akismet eliminates spam from your site.', 'akismet'); ?></p>
|
||||
<div class="activate-highlight centered activate-option">
|
||||
<strong class="small-heading"><?php esc_html_e( 'Connected via Jetpack' , 'akismet'); ?></strong>
|
||||
<h3 class="alert-text"><?php echo esc_html( sprintf( __( 'Your subscription for %s is suspended' , 'akismet'), $akismet_user->user_email ) ); ?></h3>
|
||||
<p><?php esc_html_e('No worries! Get in touch and we’ll sort this out.', 'akismet'); ?></p>
|
||||
<a href="https://akismet.com/contact" class="button button-primary"><?php esc_html_e( 'Contact Akismet support' , 'akismet'); ?></a>
|
||||
</div>
|
||||
<?php else : // ask do they want to use akismet account found using jetpack wpcom connection ?>
|
||||
<p style="margin-right:10px"><?php esc_html_e('Akismet eliminates spam from your site. To set up Akismet, select one of the options below.', 'akismet'); ?></p>
|
||||
<div class="activate-highlight activate-option">
|
||||
<div class="option-description">
|
||||
<strong class="small-heading"><?php esc_html_e('Connected via Jetpack', 'akismet'); ?></strong>
|
||||
<?php echo esc_html( $akismet_user->user_email ); ?>
|
||||
</div>
|
||||
<form name="akismet_use_wpcom_key" action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-activate" class="right">
|
||||
<input type="hidden" name="key" value="<?php echo esc_attr( $akismet_user->api_key );?>"/>
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
||||
<input type="submit" class="button button-primary" value="<?php esc_attr_e( 'Use this account' , 'akismet'); ?>"/>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<div class="activate-highlight secondary activate-option">
|
||||
<div class="option-description">
|
||||
<strong><?php esc_html_e('Sign up for a plan with a different email address', 'akismet'); ?></strong>
|
||||
<p><?php esc_html_e('Use this option to use Akismet independently of your Jetpack connection.', 'akismet'); ?></p>
|
||||
</div>
|
||||
<?php Akismet::view( 'get', array( 'text' => __( 'Sign up with a different email address' , 'akismet'), 'classes' => array( 'right', 'button', 'button-secondary' ) ) ); ?>
|
||||
</div>
|
||||
<div class="activate-highlight secondary activate-option">
|
||||
<div class="option-description">
|
||||
<strong><?php esc_html_e('Enter an API key', 'akismet'); ?></strong>
|
||||
<p><?php esc_html_e('Already have your key? Enter it here.', 'akismet'); ?></p>
|
||||
</div>
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
|
||||
<input id="key" name="key" type="text" size="15" value="" class="regular-text code">
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ) ?>
|
||||
<input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
|
||||
</form>
|
||||
</div>
|
||||
<?php else :?>
|
||||
<p><?php esc_html_e('Akismet eliminates spam from your site. To set up Akismet, select one of the options below.', 'akismet'); ?></p>
|
||||
<div class="activate-highlight activate-option">
|
||||
<div class="option-description">
|
||||
<strong><?php esc_html_e( 'Activate Akismet' , 'akismet');?></strong>
|
||||
<p><?php esc_html_e('Log in or sign up now.', 'akismet'); ?></p>
|
||||
</div>
|
||||
<?php Akismet::view( 'get', array( 'text' => __( 'Get your API key' , 'akismet'), 'classes' => array( 'right', 'button', 'button-primary' ) ) ); ?>
|
||||
</div>
|
||||
<div class="activate-highlight secondary activate-option">
|
||||
<div class="option-description">
|
||||
<strong><?php esc_html_e('Manually enter an API key', 'akismet'); ?></strong>
|
||||
<p><?php esc_html_e('If you already know your API key.', 'akismet'); ?></p>
|
||||
</div>
|
||||
<form action="<?php echo esc_url( Akismet_Admin::get_page_url() ); ?>" method="post" id="akismet-enter-api-key" class="right">
|
||||
<input id="key" name="key" type="text" size="15" value="<?php echo esc_attr( Akismet::get_api_key() ); ?>" class="regular-text code">
|
||||
<input type="hidden" name="action" value="enter-key">
|
||||
<?php wp_nonce_field( Akismet_Admin::NONCE ); ?>
|
||||
<input type="submit" name="submit" id="submit" class="button button-secondary" value="<?php esc_attr_e('Use this key', 'akismet');?>">
|
||||
</form>
|
||||
</div><?php
|
||||
endif;?>
|
||||
</div>
|
@ -1,4 +1,11 @@
|
||||
<div class="wrap">
|
||||
<h2><?php esc_html_e( 'Akismet Stats' , 'akismet');?><?php if ( !isset( $hide_settings_link ) ): ?> <a href="<?php echo esc_url( Akismet_Admin::get_page_url() );?>" class="add-new-h2"><?php esc_html_e( 'Settings' , 'akismet');?></a><?php endif;?></h2>
|
||||
<iframe src="<?php echo esc_url( sprintf( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0" id="akismet-stats-frame"></iframe>
|
||||
<div id="akismet-plugin-container">
|
||||
<div class="akismet-masthead">
|
||||
<div class="akismet-masthead__inside-container">
|
||||
<a href="<?php echo esc_url( Akismet_Admin::get_page_url() );?>" class="akismet-right"><?php esc_html_e( 'Akismet Settings' , 'akismet' ); ?></a>
|
||||
<div class="akismet-masthead__logo-container">
|
||||
<img class="akismet-masthead__logo" src="<?php echo esc_url( plugins_url( '../_inc/img/logo-full-2x.png', __FILE__ ) ); ?>" alt="Akismet" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<iframe src="<?php echo esc_url( sprintf( '//akismet.com/web/1.0/user-stats.php?blog=%s&api_key=%s&locale=%s', urlencode( get_option( 'home' ) ), Akismet::get_api_key(), get_locale() ) ); ?>" width="100%" height="2500px" frameborder="0"></iframe>
|
||||
</div>
|
@ -1,17 +0,0 @@
|
||||
<fieldset>
|
||||
<legend class="screen-reader-text">
|
||||
<span><?php esc_html_e( 'Akismet anti-spam strictness', 'akismet' ); ?></span>
|
||||
</legend>
|
||||
<p>
|
||||
<label for="akismet_strictness_1">
|
||||
<input type="radio" name="akismet_strictness" id="akismet_strictness_1" value="1" <?php checked( '1', get_option( 'akismet_strictness' ) ); ?> />
|
||||
<?php esc_html_e( 'Strict: silently discard the worst and most pervasive spam.', 'akismet' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
<p>
|
||||
<label for="akismet_strictness_0">
|
||||
<input type="radio" name="akismet_strictness" id="akismet_strictness_0" value="0" <?php checked( '0', get_option( 'akismet_strictness' ) ); ?> />
|
||||
<?php esc_html_e( 'Safe: always put spam in the Spam folder for review.', 'akismet' ); ?>
|
||||
</label>
|
||||
</p>
|
||||
</fieldset>
|
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class AIOSEOPAdminMenus
|
||||
*
|
||||
* @since 2.3.11.5
|
||||
*/
|
||||
class AIOSEOPAdminMenus {
|
||||
|
||||
/**
|
||||
* Constructor to add the actions.
|
||||
*/
|
||||
function __construct() {
|
||||
if( current_user_can( 'manage_options' ) || current_user_can( 'aiosp_manage_seo') ){
|
||||
add_action( 'admin_menu', array( $this, 'add_pro_submenu' ), 11 );
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds Upgrade link to our menu.
|
||||
*
|
||||
* @since 2.3.11.5
|
||||
*/
|
||||
function add_pro_submenu() {
|
||||
global $submenu;
|
||||
$url = 'https://semperplugins.com/all-in-one-seo-pack-pro-version/?loc=aio_menu';
|
||||
$upgrade_text = __('Upgrade to Pro', 'all-in-one-seo-pack');
|
||||
$submenu['all-in-one-seo-pack/aioseop_class.php'][] = array(
|
||||
"<span class='upgrade_menu_link'>$upgrade_text</span>",
|
||||
'manage_options',
|
||||
$url,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
new AIOSEOPAdminMenus();
|
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
if ( ! class_exists( 'All_in_One_SEO_Pack_Compatible' ) ) {
|
||||
/**
|
||||
* Abstract class to be used to create compatibility with 3rd party wordpress plugins.
|
||||
*
|
||||
* @package All-in-One-SEO-Pack
|
||||
* @author Alejandro Mostajo
|
||||
* @copyright Semperfi Web Design <https://semperplugins.com/>
|
||||
* @version 2.3.13
|
||||
* @since 2.3.12.3
|
||||
*/
|
||||
abstract class All_in_One_SEO_Pack_Compatible {
|
||||
/**
|
||||
* Returns flag indicating if compatible plugin exists in current instalation or not.
|
||||
* This function should be overwritten on child class.
|
||||
* @since 2.3.12.3
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method executed by compatibility handler to declare hooks and/or any other compatibility code needed.
|
||||
* @since 2.3.12.3
|
||||
*/
|
||||
public function hooks() {
|
||||
// TODO per compatible plugin.
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
if ( ! class_exists( 'All_in_One_SEO_Pack_Wpml' ) ) {
|
||||
/**
|
||||
* Compatibility with WPML - Wordpress Multilingual Plugin
|
||||
*
|
||||
* @link https://wpml.org/
|
||||
* @package All-in-One-SEO-Pack
|
||||
* @author Alejandro Mostajo
|
||||
* @copyright Semperfi Web Design <https://semperplugins.com/>
|
||||
* @version 2.3.13
|
||||
*/
|
||||
class All_in_One_SEO_Pack_Wpml extends All_in_One_SEO_Pack_Compatible {
|
||||
/**
|
||||
* Returns flag indicating if WPML is present.
|
||||
*
|
||||
* @since 2.3.12.3
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function exists() {
|
||||
return function_exists( 'icl_object_id' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares compatibility hooks.
|
||||
*
|
||||
* @since 2.3.12.3
|
||||
*/
|
||||
public function hooks() {
|
||||
add_filter( 'aioseop_home_url', array( &$this, 'aioseop_home_url' ) );
|
||||
add_filter( 'aioseop_sitemap_xsl_url', array( &$this, 'aioseop_sitemap_xsl_url' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns specified url filtered by wpml.
|
||||
* This is needed to obtain the correct domain in which wordpress is running on.
|
||||
* AIOSEOP would have ran first expecting the return of home_url().
|
||||
*
|
||||
* @since 2.3.12.3
|
||||
*
|
||||
* @param string $path Relative path or url.
|
||||
*
|
||||
* @param string filtered url.
|
||||
*/
|
||||
public function aioseop_home_url( $path ) {
|
||||
$url = apply_filters( 'wpml_home_url', home_url( '/' ) );
|
||||
// Remove query string
|
||||
preg_match_all( '/\?[\s\S]+/', $url, $matches );
|
||||
// Get base
|
||||
$url = preg_replace( '/\?[\s\S]+/', '', $url);
|
||||
$url = trailingslashit( $url );
|
||||
$url .= preg_replace( '/\//', '', $path, 1);
|
||||
// Add query string
|
||||
if ( count( $matches ) > 0 && count( $matches[0] ) > 0 )
|
||||
$url .= $matches[0][0];
|
||||
return $url;
|
||||
}
|
||||
/**
|
||||
* Returns XSL url without query string.
|
||||
*
|
||||
* @since 2.3.12.3
|
||||
*
|
||||
* @param string $url XSL url.
|
||||
*
|
||||
* @param string filtered url.
|
||||
*/
|
||||
public function aioseop_sitemap_xsl_url( $url )
|
||||
{
|
||||
return preg_replace( '/\?[\s\S]+/', '', $url);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue