├── languages ├── 404-to-301.mo ├── index.php ├── 404-to-301-pt_PT.mo ├── 404-to-301.pot └── 404-to-301-pt_PT.po ├── index.php ├── includes ├── index.php ├── admin │ ├── index.php │ ├── views │ │ ├── index.php │ │ ├── admin.php │ │ ├── custom-redirect.php │ │ └── settings.php │ ├── class-jj4t3-admin.php │ └── class-jj4t3-log-listing.php ├── public │ ├── index.php │ ├── class-jj4t3-404-logging.php │ ├── class-jj4t3-404-data.php │ ├── class-jj4t3-404-email.php │ └── class-jj4t3-404-actions.php ├── functions │ ├── index.php │ └── jj4t3-general-functions.php ├── class-jj4t3-i18n.php ├── class-jj-404-to-301.php └── class-jj4t3-activator-deactivator-uninstaller.php ├── .svn-assets ├── screenshot-1.png ├── screenshot-2.png └── screenshot-3.png ├── wpml-config.xml ├── .github └── workflows │ └── wpcs.yml ├── composer.json ├── assets └── src │ ├── css │ └── admin.scss │ └── js │ └── admin.js ├── uninstall.php ├── .gitignore ├── package.json ├── webpack.config.js ├── README.md ├── 404-to-301.php ├── Gruntfile.js ├── readme.txt └── LICENSE /languages/404-to-301.mo: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.github/workflows/wpcs.yml: -------------------------------------------------------------------------------- 1 | name: WPCS Check 2 | 3 | on: pull_request 4 | 5 | jobs: 6 | phpcs: 7 | name: WPCS 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: WPCS Check 12 | uses: 10up/wpcs-action@stable 13 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "joel-james/404-to-301", 3 | "version" : "3.1.1", 4 | "description": "Automatically redirect all 404 errors to any page using 301 redirect for SEO. You can redirect and log every 404 errors. No more 404 errors in Webmaster tool.", 5 | "homepage" : "https://duckdev.com/products/404-to-301/", 6 | "license" : "GPL-2.0+", 7 | "type" : "wordpress-plugin", 8 | "require" : { 9 | "composer/installers": "~1.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /assets/src/css/admin.scss: -------------------------------------------------------------------------------- 1 | .jj4t3-url-p { 2 | color: #e53531 !important; 3 | } 4 | 5 | .jj4t3-fixed-height { 6 | height: 120px; 7 | margin-bottom: 20px; 8 | overflow: auto; 9 | padding: 0 20px 0 0; 10 | } 11 | 12 | .jj4t3-notice { 13 | padding: 10px; 14 | } 15 | 16 | .jj4t3-p-desc { 17 | font-size: 13px !important; 18 | } 19 | 20 | .jj4t3-h2 { 21 | font-size: 23px; 22 | line-height: 29px; 23 | font-weight: bold !important; 24 | } 25 | 26 | h2 .subtitle a { 27 | text-decoration: none; 28 | } 29 | 30 | .jj4t3-hide { 31 | display: none; 32 | } 33 | 34 | .jj4t3-handle { 35 | cursor: default !important; 36 | } 37 | -------------------------------------------------------------------------------- /uninstall.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://www.gnu.org/licenses/ GNU General Public License 12 | * @link https://duckdev.com/products/404-to-301/ 13 | */ 14 | 15 | // If uninstall not called from WordPress exit. 16 | defined( 'WP_UNINSTALL_PLUGIN' ) || exit(); 17 | 18 | // Plugin option names. 19 | $options = array( 20 | 'i4t3_gnrl_options', 21 | 'i4t3_activated_time', 22 | 'i4t3_db_version', 23 | 'i4t3_version_no', 24 | 'i4t3_review_notice', 25 | ); 26 | 27 | // Loop through each options. 28 | foreach ( $options as $option ) { 29 | delete_option( $option ); 30 | } 31 | 32 | global $wpdb; 33 | 34 | // Drop our custom table. 35 | $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "404_to_301" ); 36 | -------------------------------------------------------------------------------- /includes/class-jj4t3-i18n.php: -------------------------------------------------------------------------------- 1 | 16 | * @license http://www.gnu.org/licenses/ GNU General Public License 17 | * @link https://duckdev.com/products/404-to-301/ 18 | */ 19 | class JJ4T3_i18n { 20 | 21 | /** 22 | * Initialize the class. 23 | * 24 | * @since 3.0.0 25 | * @access private 26 | */ 27 | public function __construct() { 28 | 29 | add_action( 'plugins_loaded', array( $this, 'textdomain' ) ); 30 | } 31 | 32 | /** 33 | * Load the plugin text domain for translation. 34 | * 35 | * @since 3.0.0 36 | * @access public 37 | */ 38 | public function textdomain() { 39 | 40 | load_plugin_textdomain( '404-to-301', false, JJ4T3_DIR . '/languages/' ); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /includes/admin/views/admin.php: -------------------------------------------------------------------------------- 1 | 15 | * @license http://www.gnu.org/licenses/ GNU General Public License 16 | * @link https://duckdev.com/products/404-to-301 17 | */ 18 | ?> 19 |
20 | 21 |

Joel James', '404-to-301' ), 'https://duckdev.com' ); ?> ( v )


22 | 23 | 24 | 25 | 26 | 30 | 31 | 32 | 33 |
-------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Recommended from: https://gist.github.com/octocat/9257657 2 | 3 | # Compiled source # 4 | ################### 5 | *.com 6 | *.class 7 | *.dll 8 | *.exe 9 | *.o 10 | *.so 11 | 12 | # Development Libraries # 13 | ######################### 14 | node_modules/ 15 | config.json 16 | package-lock.json 17 | 18 | # Packages # 19 | ############ 20 | # it's better to unpack these files and commit the raw source 21 | # git has its own built in compression methods 22 | *.7z 23 | *.dmg 24 | *.gz 25 | *.iso 26 | *.jar 27 | *.rar 28 | *.tar 29 | *.zip 30 | 31 | # Logs and databases # 32 | ###################### 33 | *.log 34 | *.sql 35 | *.sqlite 36 | 37 | # OS generated files # 38 | ###################### 39 | .DS_Store 40 | .DS_Store? 41 | ._* 42 | .Spotlight-V100 43 | .Trashes 44 | ehthumbs.db 45 | Thumbs.db 46 | 47 | # --------------------------------------------- 48 | 49 | # IDE's # 50 | ######### 51 | 52 | # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm 53 | *.iml 54 | ## Directory-based project format: 55 | .idea/ 56 | 57 | # Netbeans # 58 | nbproject/private/ 59 | build/ 60 | nbbuild/ 61 | dist/ 62 | nbdist/ 63 | nbactions.xml 64 | nb-configuration.xml 65 | 66 | 67 | # Releases folder # 68 | releases/ 69 | 70 | # Generated assets # 71 | assets/js 72 | assets/css -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "404-to-301", 3 | "version": "3.1.1", 4 | "private": true, 5 | "description": "Automatically redirect all 404 errors to any page using 301 redirect for SEO. You can redirect and log every 404 errors. No more 404 errors in Webmaster tool", 6 | "keywords": [ 7 | "404", 8 | "301", 9 | "302", 10 | "307", 11 | "not found", 12 | "404 redirect", 13 | "404 to 301", 14 | "301 redirect", 15 | "seo redirect", 16 | "error redirect", 17 | "404 seo", 18 | "custom 404 page" 19 | ], 20 | "homepage": "https://duckdev.com/products/404-to-301/", 21 | "license": "GPL-2.0", 22 | "author": { 23 | "name": "Joel James", 24 | "url": "https://duckdev.com" 25 | }, 26 | "main": "404-to-301.php", 27 | "repository": "git+https://github.com/Joel-James/404-to-301.git", 28 | "scripts": { 29 | "compile": "clear && grunt clean && webpack -p --progress", 30 | "translate": "clear && grunt translate", 31 | "build": "npm run compile && grunt prepare && grunt build" 32 | }, 33 | "devDependencies": { 34 | "grunt": "^1.0.3", 35 | "grunt-checktextdomain": "^1.0.1", 36 | "grunt-contrib-clean": "^1.1.0", 37 | "grunt-contrib-compress": "^1.4.3", 38 | "grunt-contrib-copy": "^1.0.0", 39 | "grunt-wp-i18n": "^1.0.2", 40 | "load-grunt-tasks": "^4.0.0", 41 | "grunt-po2mo": "^0.1.2", 42 | "ajv": "6.5.2", 43 | "ajv-keywords": "^3.2.0", 44 | "babel-core": "^6.26.3", 45 | "babel-loader": "^7.1.4", 46 | "babel-preset-env": "^1.7.0", 47 | "babel-preset-react": "^6.24.1", 48 | "css-loader": "^0.28.11", 49 | "to-string-loader": "^1.1.4", 50 | "file-loader": "^1.1.11", 51 | "mini-css-extract-plugin": "^0.4.1", 52 | "node-sass": "^4.9.2", 53 | "postcss-loader": "^2.1.5", 54 | "resolve-url-loader": "^2.3.0", 55 | "sass-loader": "^7.0.3", 56 | "style-loader": "^0.21.0", 57 | "url-loader": "^1.0.1", 58 | "webpack": "^4.16.2", 59 | "webpack-command": "^0.3.1" 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /includes/public/class-jj4t3-404-logging.php: -------------------------------------------------------------------------------- 1 | 15 | * @license http://www.gnu.org/licenses/ GNU General Public License 16 | * @link https://duckdev.com/products/404-to-301/ 17 | */ 18 | class JJ4T3_404_Logging { 19 | 20 | /** 21 | * Error data class object. 22 | * 23 | * @var object 24 | * @access public 25 | * @since 3.0.0 26 | */ 27 | public $data; 28 | 29 | /** 30 | * Initialize the class and set properties. 31 | * 32 | * @param object $error_data Error log data class. 33 | * 34 | * @since 3.0.0 35 | * @access public 36 | */ 37 | public function __construct( $error_data ) { 38 | 39 | $this->data = $error_data; 40 | } 41 | 42 | /** 43 | * Log details of error to the database. 44 | * 45 | * Registered new action hook "jj4t3_before_logging". 46 | * 47 | * @since 3.0.0 48 | * @access public 49 | * @global object $wpdb WordPress database. 50 | */ 51 | public function log_error() { 52 | 53 | global $wpdb; 54 | 55 | $data = $this->get_data(); 56 | 57 | /** 58 | * Action hook before logging. 59 | * 60 | * To perform actions before logging errors to db. 61 | * 62 | * @since 3.0.0 63 | * 64 | * @param array $data Error log data. 65 | */ 66 | do_action( 'jj4t3_before_logging', $data ); 67 | 68 | // Insert data to db. 69 | $wpdb->insert( JJ4T3_TABLE, $data ); 70 | } 71 | 72 | /** 73 | * Get error log data in proper format. 74 | * 75 | * @since 3.0.0 76 | * @access public 77 | * 78 | * @return array $data Array of error log data. 79 | */ 80 | private function get_data() { 81 | 82 | // Set error data fields. 83 | $data = array( 84 | 'date' => $this->data->time, 85 | 'ip' => $this->data->ip, 86 | 'url' => $this->data->url, 87 | 'ref' => $this->data->ref, 88 | 'ua' => $this->data->ua, 89 | ); 90 | 91 | // If a custom redirect is set. 92 | if ( $this->data->custom_redirect_url ) { 93 | $data['redirect'] = $this->data->custom_redirect_url; 94 | } 95 | 96 | return $data; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const _ = require( 'lodash' ), 2 | path = require( 'path' ), 3 | webpack = require( 'webpack' ), 4 | ATP = require( 'autoprefixer' ), 5 | CSSExtract = require( "mini-css-extract-plugin" ); 6 | 7 | // The path where the Shared UI fonts & images should be sent. 8 | const config = { 9 | output: { 10 | imagesDirectory: '../images', 11 | fontsDirectory: '../fonts' 12 | } 13 | }; 14 | 15 | const sharedConfig = { 16 | mode: 'production', 17 | 18 | stats: { 19 | colors: true, 20 | entrypoints: true 21 | }, 22 | 23 | watchOptions: { 24 | ignored: /node_modules/, 25 | poll: 1000 26 | } 27 | }; 28 | 29 | const scssConfig = _.assign( _.cloneDeep( sharedConfig ), { 30 | entry: { 31 | 'admin': './assets/src/css/admin.scss' 32 | }, 33 | 34 | output: { 35 | filename: '[name].min.css', 36 | path: path.resolve( __dirname, 'assets/css' ) 37 | }, 38 | 39 | module: { 40 | rules: [ 41 | { 42 | test: /\.scss$/, 43 | exclude: /node_modules/, 44 | use: [CSSExtract.loader, 45 | { 46 | loader: 'css-loader' 47 | }, 48 | { 49 | loader: 'postcss-loader', 50 | options: { 51 | plugins: [ 52 | ATP( { 53 | browsers: ['ie > 9', '> 1%'] 54 | } ) 55 | ], 56 | sourceMap: true 57 | } 58 | }, 59 | { 60 | loader: 'resolve-url-loader' 61 | }, 62 | { 63 | loader: 'sass-loader', 64 | options: { 65 | sourceMap: true 66 | } 67 | } 68 | ] 69 | }, 70 | { 71 | test: /\.(png|jpg|gif)$/, 72 | use: { 73 | loader: 'file-loader', // Instructs webpack to emit the required object as file and to return its public URL. 74 | options: { 75 | name: '[name].[ext]', 76 | outputPath: config.output.imagesDirectory 77 | } 78 | } 79 | }, 80 | { 81 | test: /\.(woff|woff2|eot|ttf|otf|svg)$/, 82 | use: { 83 | loader: 'file-loader', // Instructs webpack to emit the required object as file and to return its public URL. 84 | options: { 85 | name: '[name].[ext]', 86 | outputPath: config.output.fontsDirectory 87 | } 88 | } 89 | } 90 | ] 91 | }, 92 | 93 | plugins: [ 94 | new CSSExtract( { 95 | filename: '../css/[name].min.css' 96 | } ) 97 | ] 98 | } ); 99 | 100 | const jsConfig = _.assign( _.cloneDeep( sharedConfig ), { 101 | entry: { 102 | 'admin': './assets/src/js/admin.js' 103 | }, 104 | 105 | output: { 106 | filename: '[name].min.js', 107 | path: path.resolve( __dirname, 'assets/js' ) 108 | }, 109 | 110 | module: { 111 | rules: [ 112 | { 113 | test: /\.js$/, 114 | exclude: /node_modules/, 115 | use: { 116 | loader: 'babel-loader', 117 | options: { 118 | presets: ['env', 'react'] 119 | } 120 | } 121 | } 122 | ] 123 | } 124 | } ); 125 | 126 | module.exports = [scssConfig, jsConfig]; 127 | -------------------------------------------------------------------------------- /assets/src/js/admin.js: -------------------------------------------------------------------------------- 1 | (function ( $ ) { 2 | 'use strict'; 3 | 4 | /** 5 | * All of the code for our admin-specific JavaScript source 6 | * should reside in this file. 7 | * 8 | * Note that this assume you're going to use jQuery, so it prepares 9 | * the $ function reference to be used within the scope of this 10 | * function. 11 | * 12 | * From here, we are able to define handlers for when the DOM is 13 | * ready: 14 | * 15 | * $(function() { 16 | * 17 | * }); 18 | * 19 | * Or when the window is loaded: 20 | * 21 | * $( window ).load(function() { 22 | * 23 | * }); 24 | * 25 | * ...and so on. 26 | */ 27 | $( function () { 28 | 29 | // Hide/Show fields when redirect to value changes. 30 | $( '#jj4t3_redirect_to' ).change( function () { 31 | 32 | switch ( $( this ).val() ) { 33 | 34 | case 'page': 35 | $( '#custom_page' ).show(); 36 | $( '#custom_url' ).hide(); 37 | break; 38 | 39 | case 'link': 40 | $( '#custom_url' ).show(); 41 | $( '#custom_page' ).hide(); 42 | break; 43 | 44 | default: 45 | $( '#custom_page' ).hide(); 46 | $( '#custom_url' ).hide(); 47 | break; 48 | } 49 | } ); 50 | 51 | // open custom redirect form modal. 52 | $( '.jj4t3_redirect_thickbox' ).on( 'click', function () { 53 | 54 | var data = { 55 | 'action': 'jj4t3_redirect_thickbox', 56 | 'url_404': $( this ).attr( 'url_404' ), 57 | 'nonce': $( this ).attr( 'wpnonce' ) 58 | }; 59 | 60 | /** global: ajaxurl */ 61 | $.post( ajaxurl, data, function ( response ) { 62 | 63 | /** global: jj4t3strings (available from localization) */ 64 | tb_show( jj4t3strings.redirect, '#TB_inline?width=700&height=370&inlineId=jj4t3-redirect-modal' ); 65 | 66 | $( '#jj4t3_redirect_404' ).val( response.url_404 ); 67 | $( '#jj4t3_redirect_404_text' ).html( response.url_404 ); 68 | $( '#jj4t3_redirect_url' ).val( response.url ); 69 | $( '#jj4t3_custom_redirect_type' ).val( response.type ); 70 | 71 | jj4t3Check( 'jj4t3_custom_redirect_redirect', response.redirect ); 72 | jj4t3Check( 'jj4t3_custom_redirect_log', response.log ); 73 | jj4t3Check( 'jj4t3_custom_redirect_alert', response.alert ); 74 | } ); 75 | } ); 76 | 77 | // Save custom redirect value. 78 | $( '#jj4t3_custom_redirect_submit' ).on( 'click', function () { 79 | 80 | $( this ).addClass( 'disabled' ); 81 | 82 | $( '.jj4t3-spinner' ).css( 'visibility', 'visible' ); 83 | 84 | // Form data. 85 | var data = $( '#jj4t3_custom_redirect_form' ).serialize(); 86 | 87 | /** global: ajaxurl */ 88 | $.post( ajaxurl, data, function ( response ) { 89 | 90 | // Close the modal. 91 | tb_remove(); 92 | $( '#jj4t3_custom_redirect_submit' ).removeClass( 'disabled' ); 93 | $( '.j4t3-spinner' ).css( "visibility", 'hidden' ); 94 | 95 | // Redirect after update. 96 | location.reload(); 97 | } ); 98 | } ); 99 | 100 | /** 101 | * Set checkbox checked/not checked. 102 | * 103 | * @param object selecter Current selector element. 104 | * @param mixed val Value. 105 | */ 106 | var jj4t3Check = function ( name, val ) { 107 | 108 | $( 'input[name=' + name + '][value=' + val + ']' ).prop( 'checked', true ); 109 | } 110 | } ); 111 | 112 | })( jQuery ); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > ####WARNING: This latest version is not live yet. Use with caution! 2 | 3 | # [404 to 301](https://wordpress.org/plugins/404-to-301) - No more 404 errors! 4 | 5 | Automatically redirect all 404 errors to any page using 301 redirect to boost your SEO in WordPress. This plugin also can log all 404 erros and list it to you. Also you can optionally get email alerts on 404 errors! 6 | 7 |
8 | 9 | ##### Contributors: Joel James 10 | ##### Requires at least: WordPress 3.5 11 | ##### Tested up to: WordPress 5.8 12 | ##### Stable tag: 3.1.1 13 | 14 | Before starting development make sure you read and understand everything in this README. 15 | 16 | Also, don't forget to document your code properly. 17 | 18 | ## Working with Git 19 | 20 | Clone the plugin repo and checkout the `dev` branch 21 | 22 | ``` 23 | # git clone git@github.com:Joel-James/404-to-301.git 24 | # git fetch && git checkout dev 25 | ``` 26 | 27 | ## Installing dependencies and initial configuration 28 | 29 | Install Node 30 | ``` 31 | # curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - 32 | # sudo apt-get install -y nodejs build-essential 33 | ``` 34 | 35 | Install the necessary npm modules and packages 36 | ``` 37 | # npm install 38 | ``` 39 | 40 | After that for the first time, run below command to create updated assets. 41 | ``` 42 | # npm run compile 43 | ``` 44 | 45 | Set up username and email for Git commits 46 | ``` 47 | # git config user.email "" 48 | # git config user.name "" 49 | ``` 50 | 51 | ## Build tasks (npm) 52 | 53 | Everything (except unit tests) should be handled by npm. Note that you don't need to interact with Grunt in a direct way. 54 | 55 | Command | Action 56 | ------- | ------ 57 | `npm run translate` | Build pot and mo file inside /languages/ folder 58 | `npm run compile` | Compile assets 59 | `npm run build` | Build release version, useful to provide for testing 60 | 61 | ## Versioning 62 | 63 | Follow semantic versioning [http://semver.org/](http://semver.org/) as `package.json` won't work otherwise. That's it: 64 | 65 | - `X.X.0` for mayor versions 66 | - `X.X.X` for minor versions 67 | - `X.X[.X||.0]-rc.1` for release candidates 68 | - `X.X[.X||.0]-beta.1` for betas 69 | 70 | ## Workflow 71 | 72 | Do not commit on `master` branch (if you are on a forked repo, no need to worry). `dev` is the code 73 | that accumulates all the code for the next version. 74 | 75 | - Create a new branch from `dev` branch: `git checkout -b branch-name origin/dev`. Try to give it a descriptive name. For example: 76 | * `release/X.X.X` for next releases 77 | * `new/some-feature` for new features 78 | * `enhance/some-enhancement` for enhancements 79 | * `fix/some-bug` for bug fixing 80 | - Make your commits and push the new branch: `git push -u origin branch-name` 81 | - File the new Pull Request against `dev` branch 82 | - Once the PR is approved it will be merged to the `dev` branch. 83 | 84 | If you are sending pull requests from your forked repo, follow the same steps. 85 | 86 | ## Important Links and Documentation 87 | 88 | - Plugin Website 89 | - WordPress Page 90 | - Plugin Support Forum 91 | - Documentation 92 | -------------------------------------------------------------------------------- /includes/class-jj-404-to-301.php: -------------------------------------------------------------------------------- 1 | 17 | * @license http://www.gnu.org/licenses/ GNU General Public License 18 | * @link https://duckdev.com/products/404-to-301/ 19 | */ 20 | final class JJ_404_to_301 { 21 | 22 | /** 23 | * Main 404 to 301 class instance. 24 | * 25 | * @var JJ_404_to_301 26 | * @since 3.0.0 27 | * @access private 28 | */ 29 | private static $instance; 30 | 31 | /** 32 | * Main JJ_404_to_301 Instance. 33 | * 34 | * Insures that only one instance of JJ_404_to_301 exists in memory 35 | * at any one time. 36 | * Also prevents needing to define globals all over the place. 37 | * 38 | * @since 3.0.0 39 | * @access public 40 | * @staticvar array $instance 41 | * 42 | * @return JJ_404_to_301|object 43 | */ 44 | public static function instance() { 45 | 46 | if ( ! isset( self::$instance ) && ! ( self::$instance instanceof JJ_404_to_301 ) ) { 47 | 48 | // Main plugin class. 49 | self::$instance = new JJ_404_to_301(); 50 | 51 | // Include required files. 52 | self::$instance->includes(); 53 | // Load translation support. 54 | self::$instance->locale(); 55 | 56 | // Required only when admin. 57 | if ( is_admin() ) { 58 | // Init admin class.. 59 | self::$instance->admin = new JJ4T3_Admin(); 60 | } 61 | 62 | // Required only when not admin. 63 | if ( ! is_admin() ) { 64 | // Init 404 class. 65 | self::$instance->actions = new JJ4T3_404_Actions(); 66 | } 67 | } 68 | 69 | return self::$instance; 70 | } 71 | 72 | /** 73 | * Include plugin's required files. 74 | * 75 | * Load all required files for this plugin's 76 | * perfect functionality. 77 | * We will handle the conditional checks inside 78 | * these files. 79 | * 80 | * @since 3.0.0 81 | * @access private 82 | * 83 | * @return void 84 | */ 85 | private function includes() { 86 | 87 | include_once JJ4T3_DIR . 'includes/functions/jj4t3-general-functions.php'; 88 | include_once JJ4T3_DIR . 'includes/class-jj4t3-i18n.php'; 89 | 90 | // Required only when not admin. 91 | if ( ! is_admin() ) { 92 | include_once JJ4T3_DIR . 'includes/public/class-jj4t3-404-data.php'; 93 | include_once JJ4T3_DIR . 'includes/public/class-jj4t3-404-email.php'; 94 | include_once JJ4T3_DIR . 'includes/public/class-jj4t3-404-logging.php'; 95 | include_once JJ4T3_DIR . 'includes/public/class-jj4t3-404-actions.php'; 96 | } 97 | 98 | // Required only when backend. 99 | if ( is_admin() ) { 100 | include_once JJ4T3_DIR . 'includes/admin/class-jj4t3-admin.php'; 101 | include_once JJ4T3_DIR . 'includes/admin/class-jj4t3-log-listing.php'; 102 | } 103 | } 104 | 105 | /** 106 | * Initialize internationalization class. 107 | * 108 | * Load text domain for the internationalization functionality. 109 | * 110 | * @since 3.0.0 111 | * @access private 112 | * 113 | * @return object Locale class object. 114 | */ 115 | private function locale() { 116 | 117 | return new JJ4T3_I18n(); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /404-to-301.php: -------------------------------------------------------------------------------- 1 | 404 errors to any page using 301 redirect for SEO. You can redirect and log every 404 errors. No more 404 errors in Webmaster tool. 6 | * Version: 3.1.3 7 | * Author: Joel James 8 | * Author URI: https://duckdev.com/ 9 | * Donate link: https://paypal.me/JoelCJ 10 | * License: GPL-2.0+ 11 | * License URI: http://www.gnu.org/licenses/gpl-3.0.txt 12 | * Text Domain: 404-to-301 13 | * Domain Path: /languages 14 | * 15 | * 404 to 301 is free software: you can redistribute it and/or modify 16 | * it under the terms of the GNU General Public License as published by 17 | * the Free Software Foundation, either version 2 of the License, or 18 | * any later version. 19 | * 20 | * 404 to 301 is distributed in the hope that it will be useful, 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 | * GNU General Public License for more details. 24 | * 25 | * You should have received a copy of the GNU General Public License 26 | * along with 404 to 301. If not, see . 27 | * 28 | * @author Joel James 29 | * @license http://www.gnu.org/licenses/ GNU General Public License 30 | * @category Core 31 | * @link https://duckdev.com/products/404-to-301/ 32 | * @package JJ4T3 33 | */ 34 | 35 | // If this file is called directly, abort. 36 | defined( 'ABSPATH' ) || exit; 37 | 38 | // Define plugin slug name. 39 | define( 'JJ4T3_NAME', '404-to-301' ); 40 | // Define plugin directory. 41 | define( 'JJ4T3_DIR', plugin_dir_path( __FILE__ ) ); 42 | // Define plugin base url. 43 | define( 'JJ4T3_URL', plugin_dir_url( __FILE__ ) ); 44 | // Define plugin base file. 45 | define( 'JJ4T3_BASE_FILE', __FILE__ ); 46 | // Define plugin version. 47 | define( 'JJ4T3_VERSION', '3.1.3' ); 48 | // Define plugin version. 49 | define( 'JJ4T3_DB_VERSION', '11.0' ); 50 | // Define plugin log table. 51 | define( 'JJ4T3_TABLE', $GLOBALS['wpdb']->prefix . '404_to_301' ); 52 | 53 | // Set who all can access plugin settings. 54 | // You can change this if you want to give others access. 55 | if ( ! defined( 'JJ4T3_ACCESS' ) ) { 56 | define( 'JJ4T3_ACCESS', 'manage_options' ); 57 | } 58 | 59 | // File that contains main plugin class. 60 | require_once JJ4T3_DIR . 'includes/class-jj-404-to-301.php'; 61 | require_once JJ4T3_DIR . 'includes/class-jj4t3-activator-deactivator-uninstaller.php'; 62 | 63 | /** 64 | * The main function for that returns JJ_404_to_301 65 | * 66 | * The main function responsible for returning the one true JJ_404_to_301 67 | * instance to functions everywhere. 68 | * 69 | * Use this function like you would a global variable, except without needing 70 | * to declare the global. 71 | * 72 | * Example: 73 | * 74 | * @since 3.0.0 75 | * 76 | * @return JJ_404_to_301|object 77 | */ 78 | function jj_404_to_301() { 79 | return JJ_404_to_301::instance(); 80 | } 81 | 82 | /** 83 | * Plugin activation actions. 84 | * 85 | * Actions to perform during plugin activation. 86 | * We will be registering default options in this function. 87 | * 88 | * @uses register_activation_hook() To register activation hook. 89 | */ 90 | register_activation_hook( 91 | JJ4T3_BASE_FILE, 92 | array( 'JJ4T3_Activator_Deactivator_Uninstaller', 'activate' ) 93 | ); 94 | 95 | // Check the minimum required PHP version (5.6) and run the plugin. 96 | if ( version_compare( PHP_VERSION, '5.6', '>=' ) ) { 97 | // Run the plugin. 98 | add_action( 'plugins_loaded', 'jj_404_to_301' ); 99 | } 100 | -------------------------------------------------------------------------------- /includes/admin/views/custom-redirect.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | 73 | -------------------------------------------------------------------------------- /includes/class-jj4t3-activator-deactivator-uninstaller.php: -------------------------------------------------------------------------------- 1 | 16 | * @license http://www.gnu.org/licenses/ GNU General Public License 17 | * @link https://duckdev.com/products/404-to-301/ 18 | */ 19 | class JJ4T3_Activator_Deactivator_Uninstaller { 20 | 21 | /** 22 | * Function to run during activation 23 | * 24 | * We register default options to the WordPress if not exists already. 25 | * We will keep the old values if already exist. 26 | * 27 | * @since 3.0.0 28 | * @access public 29 | * 30 | * @return void 31 | */ 32 | public static function activate() { 33 | // Default settings for our plugin. 34 | $options = array( 35 | 'redirect_type' => '301', 36 | 'redirect_link' => home_url(), 37 | 'redirect_log' => 1, 38 | 'redirect_to' => 'link', 39 | 'redirect_page' => '', 40 | 'email_notify' => 0, 41 | 'disable_guessing' => 0, 42 | 'email_notify_address' => get_option( 'admin_email' ), 43 | 'exclude_paths' => '/wp-content', 44 | ); 45 | 46 | // Get existing options if exists. 47 | $existing = get_option( 'i4t3_gnrl_options' ); 48 | // Check if valid dcl settings exist. 49 | if ( $existing && is_array( $existing ) ) { 50 | foreach ( $options as $key => $value ) { 51 | if ( array_key_exists( $key, $existing ) ) { 52 | $options[ $key ] = $existing[ $key ]; 53 | } 54 | } 55 | } 56 | 57 | // Update/create our settings. 58 | // We are using older prefix for our option names. 59 | update_option( 'i4t3_gnrl_options', $options ); 60 | 61 | // Set review notice time for 1 week. 62 | add_option( 'i4t3_review_notice', time() + 604800 ); 63 | 64 | // Manage error log table. 65 | self::log_table(); 66 | } 67 | 68 | /** 69 | * Create or update error logs table in database. 70 | * 71 | * Define our custom table schema and create the table if not exists. 72 | * If already exists and changes found, update the table. 73 | * dbDelta() will properly take care of these tasks safely. 74 | * 75 | * @global object $wpdb WordPress database helper object. 76 | * @uses dbDelta() For safe db upgrades. 77 | * 78 | * @return void 79 | */ 80 | private static function log_table() { 81 | 82 | // Get db version number. 83 | $db = get_option( 'i4t3_db_version' ); 84 | 85 | // If table is upto date, do nothing. 86 | if ( defined( JJ4T3_DB_VERSION ) && $db === JJ4T3_DB_VERSION ) { 87 | return; 88 | } 89 | 90 | global $wpdb; 91 | // Out custom table name. 92 | $table = $wpdb->prefix . "404_to_301"; 93 | 94 | // Define the table schema query. 95 | $query = "CREATE TABLE $table ( 96 | id BIGINT NOT NULL AUTO_INCREMENT, 97 | date DATETIME NOT NULL, 98 | url VARCHAR(512) NOT NULL, 99 | ref VARCHAR(512) NOT NULL default '', 100 | ip VARCHAR(40) NOT NULL default '', 101 | ua VARCHAR(512) NOT NULL default '', 102 | redirect VARCHAR(512) NULL default '', 103 | options LONGTEXT, 104 | status BIGINT NOT NULL default 1, 105 | PRIMARY KEY (id) 106 | );"; 107 | 108 | // Handle DB upgrades in proper WordPress way. 109 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 110 | 111 | // Update or create table in database. 112 | dbDelta( $query ); 113 | 114 | // Update the db version number. 115 | update_option( 'i4t3_db_version', JJ4T3_DB_VERSION ); 116 | } 117 | 118 | /** 119 | * Fired during plugin uninstall. 120 | * 121 | * We need to clear database by deleting all custom options 122 | * and our custom logs table. 123 | * 124 | * @since 3.0.0 125 | * 126 | * @return void 127 | */ 128 | public static function uninstall() { 129 | 130 | // Plugin option names. 131 | $options = array( 132 | 'i4t3_gnrl_options', 133 | 'i4t3_activated_time', 134 | 'i4t3_db_version', 135 | 'i4t3_version_no', 136 | 'i4t3_review_notice', 137 | ); 138 | 139 | // Loop through each options. 140 | foreach ( $options as $option ) { 141 | delete_option( $option ); 142 | } 143 | 144 | global $wpdb; 145 | 146 | // Drop our custom table. 147 | $wpdb->query( "DROP TABLE IF EXISTS " . $wpdb->prefix . "404_to_301" ); 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | require("load-grunt-tasks")(grunt); 3 | 4 | var conf = { 5 | plugin_branches: { 6 | include_files: [ 7 | "includes/**", 8 | "assets/**", 9 | "vendor/**", 10 | "!vendor/freemius/.codeclimate.yml", 11 | "!vendor/freemius/.gitignore", 12 | "!vendor/freemius/gulpfile.js", 13 | "!vendor/freemius/package.json", 14 | "!vendor/freemius/composer.json", 15 | "!vendor/freemius/languages/**", 16 | "!vendor/freemius/README.md", 17 | "vendor/freemius/languages/freemius.pot", 18 | "vendor/freemius/languages/index.php", 19 | "404-to-301.php", 20 | "index.php", 21 | "LICENSE", 22 | "readme.txt", 23 | "wpml-config.xml", 24 | ], 25 | }, 26 | 27 | plugin_dir: "404-to-301/", 28 | plugin_file: "404-to-301.php", 29 | }; 30 | 31 | // Project configuration. 32 | grunt.initConfig({ 33 | pkg: grunt.file.readJSON("package.json"), 34 | 35 | // Make .pot file for translation. 36 | makepot: { 37 | options: { 38 | domainPath: "languages", 39 | exclude: ["vendor/.*"], 40 | mainFile: "404-to-301.php", 41 | potFilename: "404-to-301.pot", 42 | potHeaders: { 43 | poedit: true, 44 | "language-team": "Joel James ", 45 | "report-msgid-bugs-to": "https://duckdev.com/products/404-to-301/", 46 | "last-translator": "Joel James ", 47 | "x-generator": "grunt-wp-i18n", 48 | }, 49 | type: "wp-plugin", 50 | updateTimestamp: false, // Update POT-Creation-Date header if no other changes are detected. 51 | cwd: "", 52 | }, 53 | // Make .pot file for the plugin. 54 | main: { 55 | options: { 56 | cwd: "", 57 | }, 58 | }, 59 | // Make .pot file for the release. 60 | release: { 61 | options: { 62 | cwd: "releases/404-to-301", 63 | }, 64 | }, 65 | }, 66 | 67 | // Make .mo file from .pot file for translation. 68 | po2mo: { 69 | // Make .mo file for the plugin. 70 | main: { 71 | src: "languages/404-to-301.pot", 72 | dest: "languages/404-to-301.mo", 73 | }, 74 | // Make .mo file for the release. 75 | release: { 76 | src: "releases/404-to-301/languages/404-to-301.pot", 77 | dest: "releases/404-to-301/languages/404-to-301.mo", 78 | }, 79 | }, 80 | 81 | // Clean temp folders and release copies. 82 | clean: { 83 | temp: { 84 | src: ["**/*.tmp", "**/.afpDeleted*", "**/.DS_Store"], 85 | dot: true, 86 | filter: "isFile", 87 | }, 88 | folder_v2: ["releases/**"], 89 | }, 90 | 91 | // Verify in text domain is used properly. 92 | checktextdomain: { 93 | options: { 94 | text_domain: "404-to-301", 95 | keywords: [ 96 | "__:1,2d", 97 | "_e:1,2d", 98 | "_x:1,2c,3d", 99 | "esc_html__:1,2d", 100 | "esc_html_e:1,2d", 101 | "esc_html_x:1,2c,3d", 102 | "esc_attr__:1,2d", 103 | "esc_attr_e:1,2d", 104 | "esc_attr_x:1,2c,3d", 105 | "_ex:1,2c,3d", 106 | "_n:1,2,4d", 107 | "_nx:1,2,4c,5d", 108 | "_n_noop:1,2,3d", 109 | "_nx_noop:1,2,3c,4d", 110 | ], 111 | }, 112 | files: { 113 | src: ["includes/**/*.php", "404-to-301.php"], 114 | expand: true, 115 | }, 116 | }, 117 | 118 | // Copy selected folder and files for release. 119 | copy: { 120 | files: { 121 | src: conf.plugin_branches.include_files, 122 | dest: "releases/<%= pkg.name %>/", 123 | }, 124 | freemius: { 125 | expand: true, 126 | flatten: true, 127 | src: ".freemius_assets/**", 128 | dest: "releases/<%= pkg.name %>/vendor/freemius/assets/img/", 129 | filter: "isFile", 130 | }, 131 | }, 132 | 133 | // Compress release folder with version number. 134 | compress: { 135 | files: { 136 | options: { 137 | mode: "zip", 138 | archive: "./releases/<%= pkg.name %>-<%= pkg.version %>.zip", 139 | }, 140 | expand: true, 141 | cwd: "releases/<%= pkg.name %>/", 142 | src: ["**/*"], 143 | dest: conf.plugin_dir, 144 | }, 145 | }, 146 | }); 147 | 148 | // Check if text domain is used properly. 149 | grunt.registerTask("prepare", ["checktextdomain"]); 150 | 151 | // Make pot file from files. 152 | grunt.registerTask("translate", ["makepot:main"]); 153 | 154 | // Run build task to create release copy. 155 | grunt.registerTask("build", "Run all tasks.", function () { 156 | grunt.task.run("clean"); 157 | grunt.task.run("translate"); 158 | grunt.task.run("copy:files"); 159 | grunt.task.run("copy:freemius"); 160 | grunt.task.run("makepot:release"); 161 | //grunt.task.run("po2mo:release"); 162 | grunt.task.run("compress"); 163 | }); 164 | }; 165 | -------------------------------------------------------------------------------- /includes/public/class-jj4t3-404-data.php: -------------------------------------------------------------------------------- 1 | 15 | * @license http://www.gnu.org/licenses/ GNU General Public License 16 | * @category Core 17 | * @package JJ4T3 18 | * @subpackage 404Data 19 | */ 20 | class JJ4T3_404_Data { 21 | 22 | /** 23 | * Visitor IP address. 24 | * 25 | * @var string 26 | * @access public 27 | */ 28 | public $ip = ''; 29 | 30 | /** 31 | * Visitor user agent. 32 | * 33 | * @var string 34 | * @access public 35 | */ 36 | public $ua = ''; 37 | 38 | /** 39 | * Referring link. 40 | * 41 | * @var string 42 | * @access public 43 | */ 44 | public $ref = 'n/a'; 45 | 46 | /** 47 | * Current requested path. 48 | * 49 | * @var array 50 | * @access public 51 | */ 52 | public $url = ''; 53 | 54 | /** 55 | * Current date and time. 56 | * 57 | * @var array 58 | * @access public 59 | */ 60 | public $time = ''; 61 | 62 | /** 63 | * Initialize the class. 64 | * 65 | * @since 3.0.0 66 | * @access private 67 | */ 68 | public function init() { 69 | $this->set_ip(); 70 | $this->set_ref(); 71 | $this->set_ua(); 72 | $this->set_url(); 73 | $this->set_time(); 74 | } 75 | 76 | /** 77 | * Set visitors IP address. 78 | * 79 | * Get real IP address of the user. 80 | * http://stackoverflow.com/a/55790/3845839 81 | * 82 | * @since 2.2.6 83 | * @access private 84 | * 85 | * @param string $ip Default value for IP Address. 86 | * 87 | * @return void 88 | */ 89 | private function set_ip( $ip = '' ) { 90 | // IP variables in priority oder. 91 | $headers = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'REMOTE_ADDR' ); 92 | foreach ( $headers as $header ) { 93 | if ( isset( $_SERVER[ $header ] ) ) { 94 | $ip = $_SERVER[ $header ]; // phpcs:ignore 95 | } 96 | } 97 | 98 | /** 99 | * Filter to alter visitors IP address. 100 | * 101 | * @since 3.0.0 102 | */ 103 | $ip = apply_filters( 'jj4t3_404_ip', $ip ); 104 | 105 | $this->ip = sanitize_text_field( $ip ); 106 | } 107 | 108 | /** 109 | * Set visitors user agent/browser. 110 | * 111 | * @since 3.0.0 112 | * @access private 113 | * 114 | * @param string $ua Default value for User Agent. 115 | * 116 | * @return void 117 | */ 118 | private function set_ua( $ua = '' ) { 119 | if ( isset( $_SERVER['HTTP_USER_AGENT'] ) ) { 120 | $ua = $_SERVER['HTTP_USER_AGENT']; // phpcs:ignore 121 | } 122 | 123 | /** 124 | * Filter to alter User Agent. 125 | * 126 | * @since 3.0.0 127 | */ 128 | $ua = apply_filters( 'jj4t3_404_ua', $ua ); 129 | 130 | $this->ua = sanitize_text_field( $ua ); 131 | } 132 | 133 | /** 134 | * Set visitors referring link. 135 | * 136 | * @since 3.0.0 137 | * @access private 138 | * 139 | * @param string $ref Default value for Ref. 140 | * 141 | * @return void 142 | */ 143 | private function set_ref( $ref = '' ) { 144 | if ( isset( $_SERVER['HTTP_REFERER'] ) ) { 145 | $ref = $_SERVER['HTTP_REFERER']; // phpcs:ignore 146 | } 147 | 148 | /** 149 | * Filter to alter referrer url. 150 | * 151 | * To alter the url where the visitor comes from. 152 | * 153 | * @since 3.0.0 154 | */ 155 | $ref = apply_filters( 'jj4t3_404_ref', $ref ); 156 | 157 | $this->ref = esc_url_raw( $ref ); 158 | } 159 | 160 | /** 161 | * Set visitors referring link. 162 | * 163 | * @since 3.0.0 164 | * @access private 165 | * 166 | * @param string $url Default value for 404 URL. 167 | * 168 | * @return void 169 | */ 170 | private function set_url( $url = '' ) { 171 | if ( isset( $_SERVER['REQUEST_URI'] ) ) { 172 | $url = $_SERVER['REQUEST_URI']; // phpcs:ignore 173 | } 174 | 175 | /** 176 | * Filter to alter current 404 path. 177 | * 178 | * It is not recommended to change this value. 179 | * 180 | * @since 3.0.0 181 | */ 182 | $url = apply_filters( 'jj4t3_404_url', $url ); 183 | 184 | $this->url = untrailingslashit( esc_url_raw( $url ) ); 185 | } 186 | 187 | /** 188 | * Set current time. 189 | * 190 | * @since 3.0.0 191 | * @access private 192 | * 193 | * @return void 194 | */ 195 | private function set_time() { 196 | /** 197 | * Filter to alter current time. 198 | * 199 | * @note If you using this filter, remember to 200 | * return proper MySQL time format. 201 | * 202 | * @since 3.0.0 203 | */ 204 | $this->time = apply_filters( 'jj4t3_404_time', current_time( 'mysql' ) ); 205 | } 206 | 207 | /** 208 | * Exclude specified paths from 404. 209 | * 210 | * If paths entered in exclude paths option is 211 | * found in current 404 page, skip this from 212 | * 404 actions. 213 | * 214 | * @since 2.0.8 215 | * @access private 216 | * 217 | * @return boolean 218 | */ 219 | public function is_excluded() { 220 | $excluded = jj4t3_get_option( 'exclude_paths', '' ); 221 | 222 | $paths = array(); 223 | 224 | // If no exclude path set, return false early. 225 | if ( ! empty( $excluded ) ) { 226 | // Split by line break. 227 | $paths = explode( "\n", $excluded ); 228 | } 229 | 230 | /** 231 | * Filter to alter exclude path values. 232 | * 233 | * @note You should return array if strings . 234 | * 235 | * @since 3.0.0 236 | */ 237 | $paths = apply_filters( 'jj4t3_404_excluded_paths', $paths ); 238 | 239 | // If split failed, return false. 240 | if ( empty( $paths ) ) { 241 | return false; 242 | } 243 | 244 | // Verify that the excluded path is not matching current page. 245 | foreach ( $paths as $path ) { 246 | if ( strpos( $this->url, trim( $path ) ) !== false ) { 247 | return true; 248 | } 249 | } 250 | 251 | return false; 252 | } 253 | } 254 | -------------------------------------------------------------------------------- /includes/public/class-jj4t3-404-email.php: -------------------------------------------------------------------------------- 1 | 16 | * @license http://www.gnu.org/licenses/ GNU General Public License 17 | * @link https://duckdev.com/products/404-to-301/ 18 | */ 19 | class JJ4T3_404_Email { 20 | 21 | /** 22 | * Error data class object. 23 | * 24 | * @var object 25 | * @access private 26 | * @since 3.0.0 27 | */ 28 | private $error_data; 29 | 30 | /** 31 | * Recipient email addresses. 32 | * 33 | * @var string|array 34 | * @access public 35 | */ 36 | public $recipient; 37 | 38 | /** 39 | * Email subject. 40 | * 41 | * @var string 42 | * @access public 43 | */ 44 | public $subject; 45 | 46 | /** 47 | * Email headers. 48 | * 49 | * @var array 50 | * @access public 51 | */ 52 | public $headers; 53 | 54 | /** 55 | * Email content body. 56 | * 57 | * @var string 58 | * @access public 59 | */ 60 | public $body; 61 | 62 | /** 63 | * Initialize the class and set properties. 64 | * 65 | * @param object $error_data Error logs data class. 66 | * 67 | * @since 3.0.0 68 | * @access public 69 | */ 70 | public function __construct( $error_data ) { 71 | 72 | $this->error_data = $error_data; 73 | 74 | // Set required properties. 75 | $this->set_recipient(); 76 | $this->set_subject(); 77 | $this->set_headers(); 78 | $this->set_body(); 79 | } 80 | 81 | /** 82 | * Send email alert about the error. 83 | * 84 | * Registering new action hook "jj4t3_before_email". 85 | * 86 | * @since 3.0.0 87 | * @access public 88 | */ 89 | public function send_email() { 90 | 91 | /** 92 | * Action hook to perform before email alert. 93 | * 94 | * Sending email using wp_mail() function. 95 | * 96 | * @since 3.0.0 97 | * 98 | * @param string $this ->recipient Email recipient. 99 | * @param string $this ->subject Email subject. 100 | * @param string $this ->body Email body. 101 | */ 102 | do_action( 'jj4t3_before_email', $this->recipient, $this->subject, $this->body ); 103 | 104 | //var_dump($this->recipient); exit; 105 | // Send email using wp_mail(). 106 | wp_mail( $this->recipient, $this->subject, $this->body, $this->headers ); 107 | } 108 | 109 | /** 110 | * Set email recipients. 111 | * 112 | * Registering filter - "jj4t3_email_recipient". 113 | * 114 | * @since 3.0.0 115 | * @access private 116 | */ 117 | private function set_recipient() { 118 | 119 | // Get email recipient if set. 120 | $recipient = jj4t3_get_option( 'email_notify_address', get_option( 'admin_email' ) ); 121 | 122 | /** 123 | * Filter to alter email recipient. 124 | * 125 | * @since 3.0.0 126 | */ 127 | $this->recipient = apply_filters( 'jj4t3_email_recipient', $recipient ); 128 | } 129 | 130 | /** 131 | * Set subject for the 404 email alert. 132 | * 133 | * Registering filter - "jj4t3_email_subject". 134 | * 135 | * @since 3.0.0 136 | * @access private 137 | */ 138 | private function set_subject() { 139 | 140 | // Include site title. 141 | $message = __( 'Snap! One more 404 on ', '404-to-301' ) . get_bloginfo( 'name' ); 142 | 143 | /** 144 | * Filter to alter email subject text. 145 | * 146 | * @since 3.0.0 147 | */ 148 | $this->subject = apply_filters( 'jj4t3_email_subject', $message ); 149 | } 150 | 151 | /** 152 | * Set email headers. 153 | * 154 | * Registering filter - "jj4t3_email_headers". 155 | * 156 | * @since 3.0.0 157 | * @access private 158 | */ 159 | private function set_headers() { 160 | 161 | /** 162 | * Filter to alter From name of email alert. 163 | * 164 | * @since 3.0.0 165 | */ 166 | $from_name = apply_filters( 'jj4t3_email_header_name', get_bloginfo( 'name' ) ); 167 | 168 | /** 169 | * Filter to alter From email address of email alert. 170 | * 171 | * @since 3.0.0 172 | */ 173 | $from_email = apply_filters( 'jj4t3_email_header_email', get_option( 'admin_email' ) ); 174 | 175 | $this->headers[] = "From: " . $from_name . " <" . $from_email . ">" . "\r\n"; 176 | $this->headers[] = "Content-Type: text/html; charset=UTF-8"; 177 | } 178 | 179 | /** 180 | * Set content for the email alert. 181 | * 182 | * Registering filter - "jj4t3_email_body". 183 | * 184 | * @since 3.0.0 185 | * @access private 186 | */ 187 | private function set_body() { 188 | 189 | $message = "

" . __( 'Bummer! You have one more 404', '404-to-301' ) . "

"; 190 | $message .= ''; 191 | // 404 path. 192 | $message .= ''; 193 | $message .= ''; 194 | $message .= ''; 195 | $message .= ''; 196 | // IP Address. 197 | $message .= ''; 198 | $message .= ''; 199 | $message .= ''; 200 | $message .= ''; 201 | // Date and time. 202 | $message .= ''; 203 | $message .= ''; 204 | $message .= ''; 205 | $message .= ''; 206 | // Referral url. 207 | $message .= ''; 208 | $message .= ''; 209 | $message .= ''; 210 | $message .= ''; 211 | $message .= '
' . __( '404 Path', '404-to-301' ) . '' . $this->error_data->url . '
' . __( 'IP Address', '404-to-301' ) . '' . $this->error_data->ip . '
' . __( 'Time', '404-to-301' ) . '' . $this->error_data->time . '
' . __( 'Referral Page', '404-to-301' ) . '' . $this->error_data->ref . '
'; 212 | // Who sent me this alert? 213 | $message .= '

' . sprintf( __( 'Alert sent by the %s404 to 301%s plugin for WordPress.', '404-to-301' ), '', '' ) . '

'; 214 | 215 | /** 216 | * Filter to alter email content. 217 | * 218 | * @since 3.0.0 219 | */ 220 | $this->body = apply_filters( 'jj4t3_email_body', $message ); 221 | } 222 | 223 | } 224 | -------------------------------------------------------------------------------- /includes/admin/views/settings.php: -------------------------------------------------------------------------------- 1 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 28 | 29 | 30 | 31 | 32 | 43 | 44 | 45 | 46 | 51 | 52 | 53 | 54 | 58 | 59 | 60 | 61 | 65 | 66 | 67 | 68 | 72 | 73 | 74 | 75 | 79 | 80 | 81 | 82 | 87 | 88 | 89 | 90 | 94 | 95 | 96 |
20 | 25 |

26 |

27 |
33 | 38 |

: .

39 |

: .

40 |

: .

41 |

42 |
47 | 'i4t3_gnrl_options[redirect_page]', 'selected' => $options['redirect_page'] ) ); ?> 48 |

49 |

create a custom 404 page and assign that page here.', '404-to-301' ), admin_url( 'post-new.php?post_type=page' ) ); ?>

50 |
55 | 56 |

57 |
62 | /> 63 |

64 |
69 | /> 70 |

71 |
76 | /> 77 |

', '' ); ?>

78 |
83 | 84 | 85 |

86 |
91 | 92 |

93 |
97 | 98 |
99 | -------------------------------------------------------------------------------- /includes/functions/jj4t3-general-functions.php: -------------------------------------------------------------------------------- 1 | __( '301 Redirect (SEO)', '404-to-301' ), 284 | 302 => __( '302 Redirect', '404-to-301' ), 285 | 307 => __( '307 Redirect', '404-to-301' ), 286 | ); 287 | 288 | /** 289 | * Filter for allowed status codes. 290 | * 291 | * If you want to add additional HTTP status codes 292 | * for redirect, please use this filter and add to 293 | * the statuses array. 294 | * DO NOT remove default values (301, 302 and 307) from 295 | * the array. 296 | * 297 | * @since 3.0.0 298 | */ 299 | return (array) apply_filters( 'jj4t3_redirect_statuses', $statuses ); 300 | } 301 | 302 | /** 303 | * Available columns in error logs table. 304 | * 305 | * This columns are being used few times. Use this to avoid 306 | * unwanted names. 307 | * Registering filter - "jj4t3_redirect_statuses". 308 | * 309 | * @since 3.0.0 310 | * @access private 311 | * 312 | * @return array Allowed HTTP status codes. 313 | */ 314 | function jj4t3_log_columns() { 315 | 316 | $columns = array( 317 | 'date' => __( 'Date', '404-to-301' ), 318 | 'url' => __( '404 Path', '404-to-301' ), 319 | 'ref' => __( 'From', '404-to-301' ), 320 | 'ip' => __( 'IP Address', '404-to-301' ), 321 | 'ua' => __( 'User Agent', '404-to-301' ), 322 | 'redirect' => __( 'Redirect', '404-to-301' ), 323 | ); 324 | 325 | /** 326 | * Filter for available columns. 327 | * 328 | * These are the availble column names in 404 329 | * error logs. 330 | * Registering filter - "jj4t3_log_columns". 331 | * 332 | * @param array columns name and slug. 333 | * 334 | * @since 3.0.0 335 | */ 336 | return (array) apply_filters( 'jj4t3_log_columns', $columns ); 337 | } 338 | 339 | /** 340 | * Retrive value from $_REQUEST. 341 | * 342 | * Helper function to retrive data from $_REQUEST 343 | * We can use this function to get values from request 344 | * and get a default value if the current key does not exist 345 | * or empty. 346 | * Output will be trimmed. 347 | * 348 | * @param string $key Key to get from request. 349 | * @param mixed $default Default value. 350 | * 351 | * @since 3.0.0 352 | * @access public 353 | * 354 | * @return array|string 355 | */ 356 | function jj4t3_from_request( $key = '', $default = '' ) { 357 | 358 | // Return default value if key is not given. 359 | if ( empty( $key ) || ! is_string( $key ) ) { 360 | return $default; 361 | } 362 | 363 | // Return default value if key not set. 364 | if ( ! isset( $_REQUEST[ $key ] ) ) { // phpcs:ignore 365 | return $default; 366 | } 367 | 368 | // Trim output. 369 | if ( is_string( $_REQUEST[ $key ] ) ) { // phpcs:ignore 370 | return sanitize_text_field( $_REQUEST[ $key ] ); // phpcs:ignore 371 | } elseif ( is_array( $_REQUEST[ $key ] ) ) { // phpcs:ignore 372 | return array_map( 'sanitize_text_field', $_REQUEST[ $key ] ); // phpcs:ignore 373 | } 374 | 375 | return $default; 376 | } 377 | -------------------------------------------------------------------------------- /includes/public/class-jj4t3-404-actions.php: -------------------------------------------------------------------------------- 1 | 16 | * @license http://www.gnu.org/licenses/ GNU General Public License 17 | * @link https://duckdev.com/products/404-to-301/ 18 | */ 19 | class JJ4T3_404_Actions extends JJ4T3_404_Data { 20 | 21 | /** 22 | * Redirect url for current 404. 23 | * 24 | * @var string 25 | * @access public 26 | * 27 | */ 28 | public $redirect_url = ''; 29 | 30 | /** 31 | * Custom redirect url for current 404. 32 | * 33 | * @var string 34 | * @access public 35 | * 36 | */ 37 | public $custom_redirect_url = ''; 38 | 39 | /** 40 | * Redirect status code for currenr 404. 41 | * 42 | * @var string 43 | * @access public 44 | * @since 3.0.0 45 | */ 46 | public $redirect_type = 301; 47 | 48 | /** 49 | * Is redirect enabled for current 404. 50 | * 51 | * @var boolean 52 | * @access public 53 | * @since 3.0.0 54 | */ 55 | public $redirect_enabled = false; 56 | 57 | /** 58 | * Is logging enabled for current 404. 59 | * 60 | * @var boolean 61 | * @access public 62 | * @since 3.0.0 63 | */ 64 | public $log_enabled = false; 65 | 66 | /** 67 | * Is email alert enabled for current 404. 68 | * 69 | * @var boolean 70 | * @access public 71 | * @since 3.0.0 72 | */ 73 | public $alert_enabled = false; 74 | 75 | /** 76 | * Is common check passed for current 404. 77 | * 78 | * @var boolean 79 | * @access public 80 | * @since 3.0.0 81 | */ 82 | public $common_check_passed = false; 83 | 84 | /** 85 | * Initialize the class and parent class. 86 | * 87 | * @since 3.0.0 88 | * @access public 89 | */ 90 | public function __construct() { 91 | 92 | // Main filter that handles 404. 93 | add_action( 'template_redirect', array( $this, 'handle_404' ) ); 94 | add_filter( 'redirect_canonical', array( $this, 'url_guessing' ) ); 95 | } 96 | 97 | /** 98 | * Perform 404 actions. 99 | * 100 | * Perform required actions on each 404 pages being visited. 101 | * Log error details, Alert via email, Redirect. 102 | * 103 | * @since 3.0.0 104 | * @access public 105 | * 106 | * @return void 107 | */ 108 | public function handle_404() { 109 | 110 | // Only if we can. 111 | if ( ! is_404() || is_admin() ) { 112 | return; 113 | } 114 | 115 | // Let's try folks. 116 | try { 117 | 118 | // Initialize. 119 | $this->init(); 120 | 121 | // Set options for current 404. 122 | $this->set_options(); 123 | 124 | // Log error details to database. 125 | $this->log_error(); 126 | 127 | // Send email alert about the error. 128 | $this->email_alert(); 129 | 130 | // Redirect the user. 131 | $this->redirect(); 132 | 133 | } catch ( Exception $ex ) { 134 | // Who cares? 135 | } 136 | } 137 | 138 | /** 139 | * Send email about the error. 140 | * 141 | * @since 3.0.0 142 | * @access public 143 | * 144 | * @return void 145 | */ 146 | public function email_alert() { 147 | 148 | /** 149 | * Filter to completely disable email alerts. 150 | * 151 | * @since 3.0.0 152 | */ 153 | if ( ! apply_filters( 'jj4t3_can_email_alert', $this->alert_enabled ) ) { 154 | return; 155 | } 156 | 157 | 158 | // Email alert class. 159 | $email = new JJ4T3_404_Email( $this ); 160 | $email->send_email(); 161 | } 162 | 163 | /** 164 | * Log details of error to the database. 165 | * 166 | * @since 3.0.0 167 | * @access public 168 | * 169 | * @return void 170 | */ 171 | public function log_error() { 172 | 173 | // Only if we can. 174 | if ( ! $this->log_enabled ) { 175 | return; 176 | } 177 | 178 | // Error logging class. 179 | $logging = new JJ4T3_404_Logging( $this ); 180 | $logging->log_error(); 181 | } 182 | 183 | /** 184 | * Redirect 404 requests. 185 | * 186 | * If a 404 page is requested, take visitors to a proper existing page. 187 | * Registering new action hook "jj4t3_before_redirect". 188 | * 189 | * @since 3.0.0 190 | * @access private 191 | * 192 | * @global object $wpdb WordPress DB object. 193 | * 194 | * @return void 195 | */ 196 | public function redirect() { 197 | 198 | // Only if we can. 199 | if ( ! $this->redirect_enabled ) { 200 | return; 201 | } 202 | 203 | if ( ! empty( $this->redirect_url ) ) { 204 | 205 | /** 206 | * Action hook to perform before redirect. 207 | * 208 | * @since 3.0.0 209 | * 210 | * @param string $url Link to redirect. 211 | */ 212 | do_action( 'jj4t3_before_redirect', $this->redirect_url ); 213 | 214 | // Perform redirect using WordPres. 215 | wp_redirect( $this->redirect_url, $this->redirect_type ); 216 | // Exit, because WordPress will not exit automatically. 217 | exit; 218 | } 219 | } 220 | 221 | /** 222 | * Set custom redirect url if set 223 | * 224 | * If custom redirect url is set for give 404 path, 225 | * set that link. 226 | * Registering filter "jj4t3_custom_redirect_url". 227 | * 228 | * @global object $wpdb WP DB object 229 | * @since 2.2.0 230 | * @access private 231 | * 232 | * @return void 233 | */ 234 | private function set_options() { 235 | 236 | if ( empty( $this->url ) ) { 237 | return; 238 | } 239 | 240 | global $wpdb; 241 | // Make sure that the errors are hidden. 242 | $wpdb->hide_errors(); 243 | 244 | // Get custom redirect if set. 245 | $result = $result = $wpdb->get_row( "SELECT redirect, options FROM " . JJ4T3_TABLE . " WHERE url = '" . $this->url . "' AND redirect IS NOT NULL LIMIT 0,1", "OBJECT" ); 246 | 247 | $options = empty( $result->options ) ? array() : maybe_unserialize( $result->options ); 248 | 249 | // Set all properties. 250 | $this->set_common_check(); 251 | $this->set_redirect_url( $result ); 252 | $this->set_redirect_type( $options ); 253 | $this->set_redirect_status( $options ); 254 | $this->set_logging_status( $options ); 255 | $this->set_alert_status( $options ); 256 | } 257 | 258 | /** 259 | * Get url to redirect to. 260 | * 261 | * This function is used to get the url 262 | * for redirecting to. 263 | * If a custom redirect is set through admin dashboard or even through 264 | * the filter "jj4t3_custom_redirect_url" for the current 404 page, it will be prioratised. 265 | * Otherwise global redirect link. 266 | * Registering filter - jj4t3_redirect_url. 267 | * 268 | * @param object $options Current 404 options. 269 | * 270 | * @since 3.0.0 271 | * @access private 272 | * 273 | * @return void 274 | */ 275 | private function set_redirect_url( $options ) { 276 | 277 | $url = false; 278 | 279 | $custom_redirect = empty( $options->redirect ) ? '' : $options->redirect; 280 | 281 | /** 282 | * Filter for modify/set current 404's custom redirect. 283 | * 284 | * Using this filter you can modify or set custom redirect 285 | * for any 404 path. 286 | * @note : If you want to remove custom redirect for a path, you can 287 | * use this filter and return an empty/false value. 288 | * If you have set a value here, this will get priority over global redirect. 289 | * 290 | * @since 3.0.0 291 | */ 292 | $custom_redirect = apply_filters( 'jj4t3_custom_redirect_url', $custom_redirect, $this->url ); 293 | 294 | if ( ! empty( $custom_redirect ) ) { 295 | $url = esc_url( $custom_redirect ); 296 | $this->custom_redirect_url = esc_url( $custom_redirect ); 297 | } else { 298 | // Get redirect to. 299 | $to = jj4t3_get_option( 'redirect_to' ); 300 | if ( 'page' === $to ) { 301 | // If an existing page is selected, get permalink. 302 | $url = get_permalink( jj4t3_get_option( 'redirect_page' ) ); 303 | } elseif ( 'link' === $to ) { 304 | // If a link. 305 | $url = jj4t3_get_option( 'redirect_link' ); 306 | } 307 | } 308 | 309 | /** 310 | * Filter hook to change redirect url. 311 | * 312 | * To alter redirect link. Return full absolute 313 | * path to redirect. 314 | * 315 | * @since 3.0.0 316 | */ 317 | $this->redirect_url = esc_url( apply_filters( 'jj4t3_redirect_url', $url ) ); 318 | } 319 | 320 | /** 321 | * Set redirect type for the current 404. 322 | * 323 | * This function is used to set the redirect type code 324 | * for the current 404. 325 | * Custom config for the 404 is considered first. 326 | * 327 | * @param object $options Current 404 options. 328 | * 329 | * @since 3.0.0 330 | * @access public 331 | * 332 | * @return void 333 | */ 334 | private function set_redirect_type( $options ) { 335 | 336 | if ( isset( $options['type'] ) && is_numeric( $options['type'] ) ) { 337 | $this->redirect_type = intval( $options[ 'type' ] ); 338 | } else { 339 | $this->redirect_type = jj4t3_redirect_type(); 340 | } 341 | } 342 | 343 | /** 344 | * Set if we can log 404 errors to database. 345 | * 346 | * This function is used to check and verify 347 | * if the error logging is set to enabled. 348 | * Checking custom config for the 404 first. 349 | * 350 | * @param object $options Current 404 options. 351 | * 352 | * @since 3.0.0 353 | * @access public 354 | * 355 | * @return void 356 | */ 357 | private function set_logging_status( $options ) { 358 | 359 | if ( isset( $options['log'] ) && in_array( $options['log'], array( 0, 1 ) ) ) { 360 | $enabled = boolval( $options[ 'log' ] ); 361 | } else { 362 | $enabled = jj4t3_log_enabled(); 363 | } 364 | 365 | if ( $enabled && jj4t3_is_human() && $this->common_check_passed ) { 366 | $this->log_enabled = true; 367 | } 368 | } 369 | 370 | /** 371 | * Set if we can email notify on errors. 372 | * 373 | * This function is used to check and verify 374 | * if the email notification is enabled. 375 | * Checking custom config for the 404 first. 376 | * 377 | * @param object $options Current 404 options. 378 | * 379 | * @since 3.0.0 380 | * @access public 381 | * 382 | * @return void 383 | */ 384 | private function set_alert_status( $options ) { 385 | 386 | if ( isset( $options['alert'] ) && in_array( $options['alert'], array( 0, 1 ) ) ) { 387 | $enabled = boolval( $options[ 'alert' ] ); 388 | } else { 389 | $enabled = jj4t3_email_notify_enabled(); 390 | } 391 | 392 | if ( $enabled && jj4t3_is_human() && $this->common_check_passed ) { 393 | $this->alert_enabled = true; 394 | } 395 | } 396 | 397 | /** 398 | * Set if we can perform redirect related actions. 399 | * 400 | * Verify that the common check passed. 401 | * Verify that redirect is enabled by user (custom if any). 402 | * 403 | * @param object $options Current 404 options. 404 | * 405 | * @since 2.2.0 406 | * @access public 407 | * 408 | * @return void 409 | */ 410 | private function set_redirect_status( $options ) { 411 | 412 | if ( isset( $options['redirect'] ) && in_array( $options['redirect'], array( 0, 1 ) ) ) { 413 | $enabled = boolval( $options['redirect'] ); 414 | } else { 415 | $enabled = jj4t3_redirect_enabled(); 416 | } 417 | 418 | if ( $enabled && $this->common_check_passed ) { 419 | $this->redirect_enabled = true; 420 | } 421 | } 422 | 423 | /** 424 | * Set if the common checks are passed. 425 | * 426 | * Verify that the current page is not excluded. 427 | * Verify that the current page is not an BuddyPress page 428 | * only if BuddyPress is active. 429 | * 430 | * @since 2.2.0 431 | * @access public 432 | * 433 | * @return void 434 | */ 435 | private function set_common_check() { 436 | 437 | // Do not redirect if excluded by user. 438 | if ( $this->is_excluded() ) { 439 | $this->common_check_passed = false; 440 | } elseif ( function_exists( 'bp_current_component' ) ) { 441 | $this->common_check_passed = ( ! bp_current_component() ); 442 | } else { 443 | $this->common_check_passed = true; 444 | } 445 | } 446 | 447 | /** 448 | * Disable URL guessing if enabled. 449 | * 450 | * @param bool $guess Current status. 451 | * 452 | * @since 3.0.4 453 | * 454 | * @return bool 455 | */ 456 | public function url_guessing( $guess ) { 457 | // Check if guessing is disabled. 458 | $disable_guessing = jj4t3_get_option( 'disable_guessing' ); 459 | // Disable only on 404. 460 | if ( $disable_guessing && is_404() && ! isset( $_GET['p'] ) ) { 461 | $guess = false; 462 | } 463 | 464 | return $guess; 465 | } 466 | } 467 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === 404 to 301 - Redirect, Log and Notify 404 Errors === 2 | Contributors: joelcj91,duckdev 3 | Tags: 404, 301, 302, 307, not found, 404 redirect, 404 to 301, 301 redirect, seo redirect, error redirect, 404 seo, custom 404 page 4 | Donate link: https://www.paypal.me/JoelCJ 5 | Requires at least: 3.5 6 | Tested up to: 5.8 7 | Stable tag: 3.1.1 8 | Requires PHP: 5.6 9 | License: GPLv2 or later 10 | License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 | 12 | Automatically redirect, log and notify all 404 page errors to any page using 301 redirect for SEO. No more 404 Errors in WebMaster tool. 13 | 14 | == Description == 15 | 16 | If you care about your website, you should take steps to avoid 404 errors as it affects your SEO badly. 404 ( Page not found ) errors are common and we all hate it, even Search engines do the same! Install this plugin then sit back and relax. It will take care of 404 errors! 17 | 18 | = What is 404 to 301? = 19 | 20 | *Handling 404 errors in your site should be easy. With this plugin, it finally is.* 21 | 22 | > #### 404 to 301 Log Manager - Add-on is now available! 23 | > 24 | > - Instead of instant email alerts, get **hourly, twice daily, daily, twice weekly, weekly** alerts.
25 | > - Limit the amount of emails sent out based on error logs count.
26 | > - **PDF file** attachment of error logs will be delivered through the email.
27 | > - **Automatically clear** old error logs based on time period.
28 | > - Get email alerts to multiple email recipients.
29 | > 30 | > [Get this add-on now](https://duckdev.com/products/404-to-301-log-manager/) | [See Docs](https://duckdev.com/support/docs/404-to-301-log-manager/) 31 | 32 | 404 to 301 is a simple but amazing plugin which handles all 404 errors for you. It will redirect all 404 errors to any page that you set, using 301 (or any other) status. That means no more 404 errors! Even in Google webmaster tool you are safe! 33 | You will not see any 404 error reports in your webmaster tool dashboard. 34 | 35 | 36 | > #### 404 to 301 - Features 37 | > 38 | > - You can redirect errors to any existing page or custom link (globally).
39 | > - **You can set custom redirect for each 404 path!**
40 | > - No more 404 errors in your website. Seriously!
41 | > - **Translation ready!**
42 | > - You can optionally monitor/log all errors.
43 | > - Exclude paths from errors.
44 | > - You can optionally enable email notification on all 404 errors.
45 | > - You can choose which redirect method to be used (301,302,307).
46 | > - Will not irritate your visitors if they land on a non-existing page/url.
47 | > - Increase your SEO by telling Google that all 404 pages are moved to some other page.
48 | > - Completely free to use with lifetime updates.
49 | > - Developer friendly.
50 | > - Follows best WordPress coding standards.
51 | > - Of course, available in [GitHub](https://github.com/joel-james/404-to-301)
52 | > 53 | > [Installation](https://wordpress.org/plugins/404-to-301/installation/) | [Docs](https://duckdev.com/support/docs/404-to-301/) | [Screenshots](https://wordpress.org/plugins/404-to-301/screenshots/) 54 | 55 | 56 | **Bug Reports** 57 | 58 | Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com/support/). 59 | 60 | **More information** 61 | 62 | - [404 to 301 - Plugin Homepage](https://duckdev.com/products/404-to-301), containing more details and docs. 63 | - Follow the developer [@Twitter](https://twitter.com/Joel_James) 64 | - Other [WordPress plugins](https://profiles.wordpress.org/joelcj91/#content-plugins) by Joel James for [Duck Dev](https://duckdev.com) 65 | 66 | **404 Errors and Redirect - More Details** 67 | 68 | If you are confused with these terms 404,301, redirect etc, [refer this page](https://moz.com/learn/seo/redirection/) to know more about the redirect and SEO. 69 | 70 | 71 | == Installation == 72 | 73 | 74 | = Installing the plugin - Simple = 75 | 1. In your WordPress admin panel, go to *Plugins > New Plugin*, search for **404 to 301** and click "*Install now*" 76 | 2. Alternatively, download the plugin and upload the contents of `404-to-301.zip` to your plugins directory, which usually is `/wp-content/plugins/`. 77 | 3. Activate the plugin 78 | 4. Go to 404 to 301 tab on your admin menus. 79 | 5. Configure the plugin options with available settings. 80 | 81 | 82 | = Need more help? = 83 | Please take a look at the [plugin documentation](https://duckdev.com/support/docs/404-to-301/) or [open a support request](http://wordpress.org/support/plugin/404-to-301/). 84 | 85 | = Missing something? = 86 | If you would like to have an additional feature for this plugin, [let me know](https://duckdev.com/support/) 87 | 88 | == Frequently Asked Questions == 89 | 90 | = What is the use of 404 to 301? = 91 | 92 | It will increase your SEO by redirecting all 404 errors using SEO redirects. 93 | 94 | = Can I monitor 404 errors? = 95 | 96 | Yes. You can. If you enable logs from settings, it will list all the errors. 97 | 98 | = How can I clear logs? = 99 | 100 | Select 'clear logs' from bulk actions and submit. It will delete all log data from your db. 101 | 102 | = Can I get email notifications? = 103 | 104 | Yes. You can enable email notifications on each 404 errors (optional). 105 | 106 | = Can I set custom redirects for each errors? = 107 | 108 | Yes. You can set that from error logs table. 109 | 110 | = I need more details = 111 | 112 | Please take a look at the [plugin documentation](https://duckdev.com/support/docs/404-to-301/) or [open a support request](http://wordpress.org/support/plugin/404-to-301/). 113 | 114 | 115 | == Other Notes == 116 | 117 | = Bug Reports = 118 | 119 | Bug reports for 404 to 301 are always welcome. [Report here](https://duckdev.com/support/). 120 | 121 | 122 | == Screenshots == 123 | 124 | 1. **Settings** - Settings page of 404 to 301. 125 | 2. **Error Logs** - Logged 404 Errors. 126 | 3. **Custom Redirect** - Setting custom redirect for each 404 paths. 127 | 128 | 129 | == Changelog == 130 | 131 | = 3.1.1 (15/11/2021) = 132 | **👌 Improvements** 133 | 134 | * Security checks and improvements. 135 | 136 | = 3.1.0 (18/10/2021) = 137 | **👌 Improvements** 138 | 139 | * Tested with WP 5.8. 140 | * Added sanitization. 141 | 142 | = 3.0.9 (06/10/2021) = 143 | **👌 Improvements** 144 | 145 | * Added nonce verification for bulk actions. 146 | 147 | = 3.0.8 (12/06/2021) = 148 | **👌 Improvements** 149 | 150 | * Tested with WP 5.7. 151 | * Add capability checks for ajax actions - Thanks [Jerome](https://secure.nintechnet.com/). 152 | * Improve query preparations - Thanks [Jerome](https://secure.nintechnet.com/). 153 | 154 | = 3.0.7 (28/01/2021) = 155 | **🐛 Bug Fixes** 156 | 157 | * Activation hook was not being executed. 158 | * Table creation failed in new installations. 159 | 160 | = 3.0.6 (18/12/2020) = 161 | **👌 Improvements** 162 | 163 | * Tested with WP 5.6. 164 | * Small improvements. 165 | * Temporarily disabled Freemius SDK. 166 | 167 | = 3.0.5 (02/07/2019) = 168 | **👌 Improvements** 169 | 170 | * Updated Freemius SDK. 171 | * Tested with WP 5.2. 172 | 173 | = 3.0.4 (16/03/2019) = 174 | **📦 New** 175 | 176 | * Added option to disable URL guessing. 177 | * Added review notice. 178 | 179 | = 3.0.3 (15/03/2019) = 180 | **🐛 Bug Fixes** 181 | 182 | * Opt-in is disabled temporarily to debug the issues. 183 | 184 | = 3.0.2 (26/02/2019) = 185 | **🐛 Bug Fixes** 186 | 187 | * Security fix. 188 | 189 | **👌 Improvements** 190 | 191 | * Minor performance improvements. 192 | 193 | = 3.0.1 (24/08/2018) = 194 | **👌 Improvements** 195 | 196 | * Make release automated. 197 | 198 | **🐛 Bug Fixes** 199 | 200 | * Do not include exclude path items. 201 | 202 | = 3.0.0.1 (25/06/2018) = 203 | **Bug Fixes** 204 | 205 | - Using template_redirect hook for redirect instead of wp hook. 206 | - Fixed an issue with do_action in Freemius SDK. 207 | 208 | = 3.0.0 (20/06/2018) = 209 | **New Features** 210 | 211 | - Individual optional settings for each error log item (Individual redirec, log, email alert can be set). 212 | - Clear error logs without removing custom redirects. 213 | - Added error logs grouping with count. 214 | - [WPML compatible](https://wpml.org/plugin/404-to-301/). 215 | - Integrated Freemius for addon, support and analytics (optional). 216 | 217 | **Improvements** 218 | 219 | - Complete code revamp. More improved structure. 220 | - Set custom options from previous logs if same item exists. 221 | - Made 3rd party integration easier. 222 | 223 | = 2.3.3 (31/08/2016) = 224 | **Bug Fixes** 225 | 226 | - Using esc_url() for Ref and Url fields. 227 | - Fixed Cross Site Scripting vulnerability in "From" column - Thanks to [Plugin Vulnerabilities](https://www.pluginvulnerabilities.com/). 228 | 229 | = 2.3.1 (27/08/2016) = 230 | **Bug Fixes** 231 | 232 | - Fixed Cross Site Scripting vulnerability - Thanks to [Summer of Pwnage](https://www.sumofpwn.nl/) & Louis Dion-Marcil. 233 | - Fixed sorting issue in error log (Changed default order to Date Descending order). 234 | - Fixed issues when trailing slash found at the end of custom redirect. 235 | 236 | **Improvements** 237 | 238 | - Tested with WordPress 4.6. 239 | 240 | = 2.3.0 (17/08/2016) = 241 | **Bug Fixes** 242 | 243 | - Removed unused UAN button from help page. 244 | - Completely safe to use. 245 | - Tracking completely removed from the plugin since it was detected as spam. Read more [here](https://duckdev.com/blog/404-to-301-plugin-detected-by-wordfence-here-is-what-actually-happened/). 246 | 247 | = 2.2.9 (16/08/2016) = 248 | **Bug Fixes** 249 | 250 | - Serious issue fixed - Usage tracking script was being detected as spam. 251 | - Removed tracking completely. 252 | 253 | = 2.2.8 (12/07/2016) = 254 | **Bug Fixes** 255 | 256 | - Fixed a minor bug on TOC button. 257 | 258 | = 2.2.7 (07/07/2016) = 259 | **Bug Fixes** 260 | 261 | - Fixed issue with PHP 5.4 - Empty error log data. 262 | 263 | **Improvements** 264 | 265 | - Improved condition checking. 266 | - Speed improvements. 267 | - Made error log link to new tab. 268 | 269 | = 2.2.6 (30/06/2016) = 270 | **Bug Fixes** 271 | 272 | - Fixed issue - Undefined index when accessed directly. 273 | 274 | **Improvements** 275 | 276 | - Improved condition checking. 277 | 278 | = 2.2.5 (05/06/2016) = 279 | **Bug Fixes** 280 | 281 | - Fixed issue - Front end was slow. 282 | 283 | = 2.2.4 (02/06/2016) = 284 | **Bug Fixes** 285 | 286 | - Fixed custom redirect issue. 287 | - Fixed issues when activating. 288 | 289 | = 2.2.2 (01/06/2016) = 290 | **New Feature** 291 | 292 | - Now you can set **custom redirects** for reach error path. 293 | - Goto error logs list and set custom redirect. 294 | - Fixed issues with BuddyPress. 295 | 296 | **Improvements** 297 | 298 | - Improved code. 299 | 300 | = 2.1.7 (20/04/2016) = 301 | **New Add-on** 302 | 303 | - New [Log Manager](https://duckdev.com/products/404-to-301-log-manager/) add-on available now. 304 | - Get periodic email alerts instead of instant email alerts for every errors (add-on). 305 | - Automatically clear error logs (add-on). 306 | 307 | **Improvements** 308 | 309 | - Removed inactive filter - i4t3_before_404_redirect 310 | 311 | = 2.1.6 (06/04/2016) = 312 | **Improvements** 313 | 314 | - Fixed broken plugin website links. 315 | - Tested with WordPress 4.5. 316 | 317 | = 2.1.5 (22/03/2016) = 318 | **Improvements** 319 | 320 | - Fixed issues with deprecated functions - Thanks to [Pedro Mendonça](https://github.com/pedro-mendonca). 321 | - Translated missing strings. 322 | - Tested with WordPress 4.4.2. 323 | 324 | = 2.1.4 (22/01/2016) = 325 | **Bug Fixes** 326 | 327 | - Fixed issues when clearing logs (header already sent..). 328 | - Tested with WordPress 4.4.1. 329 | 330 | = 2.1.3 (20/12/2015) = 331 | **Bug Fixes** 332 | 333 | - Fixed issues with older version of WordPress. 334 | - Fixed issues with older version of PHP. 335 | 336 | = 2.1.0 (20/12/2015) = 337 | **New Feature** 338 | 339 | - New option to set items per page from error log listing page. 340 | - New option to show or hide items from listing table (Screen option). 341 | 342 | **Improvements** 343 | 344 | - Improved error listing page table structure. 345 | 346 | **Bug Fixes** 347 | 348 | - Fixed issue - Null value issue when no Referrer or User Agent found. 349 | - Fixed issue - Clearing errors and redirecting. 350 | 351 | = 2.0.9 (2/11/2015) = 352 | **Bug Fixes** 353 | 354 | - Fixed issue - Empty needle issue after 2.0.8 update. 355 | 356 | = 2.0.8 (28/10/2015) = 357 | **New Feature** 358 | 359 | - New option to exclude paths from error logs and redirect. 360 | 361 | **Bug Fixes** 362 | 363 | - Fixed issue - Email notifications are being sent even after disabling it. 364 | - Fixed issue - Settings reset after reactivation of plugin. 365 | 366 | = 2.0.7 (25/09/2015) = 367 | **New Feature** 368 | 369 | - New option to change error notification email address. 370 | - Now **100% Translation ready**. 371 | 372 | **Improvements** 373 | 374 | - Minor code improvements. 375 | 376 | = 2.0.6 (13/09/2015) = 377 | **Improvements** 378 | 379 | - Introduced new website for the plugin. 380 | - Fixed few dead link issues 381 | 382 | = 2.0.5 (03/09/2015) = 383 | **Improvements** 384 | 385 | - Added option to avoid search engine crawlers/bots from logging errors. 386 | 387 | **Bug Fixes** 388 | 389 | - Fixed error log per page issue. 390 | 391 | = 2.0.4 (26/08/2015) = 392 | 393 | **Bug Fixes** 394 | 395 | - Fixed an issue where error log table is not being created. 396 | 397 | = 2.0.3 (21/08/2015) = 398 | 399 | **Bug Fixes** 400 | 401 | - Fixed a serious issue which may cause SQL injection attack. 402 | 403 | = 2.0.2 (16/08/2015) = 404 | **Bug Fixes** 405 | 406 | - Fixed an issue with https redirect. 407 | - Fixed an issue with url preg_match. 408 | 409 | = 2.0.1 (29/07/2015) = 410 | **New Feature** 411 | 412 | - Now you can log/monitor all 404 errors (optional). 413 | - You can get email notifications on 404 errors (optional). 414 | - You can select existing pages from dropdown to set as redirect page. 415 | - New plugin home page. 416 | 417 | **Improvements** 418 | 419 | - Upgraded to WordPress plugin coding standard. 420 | - Documented all functions. 421 | 422 | = 1.0.8 = 423 | * Very minor bug fix 424 | * Tested for WP 4.2 425 | 426 | = 1.0.7 = 427 | * Fixed options saving issue in admin page. 428 | * Improved performance. 429 | 430 | = 1.0.6 = 431 | * Tested with latest version. 432 | * Improved structure. 433 | 434 | = 1.0.5 = 435 | * Bug fix. 436 | * Fixed permission issue on redirect link on plugin activation. 437 | 438 | = 1.0.4 = 439 | * Bug fix. 440 | * Fixed permission issue on activating along with some security plugins like WordFence. 441 | 442 | = 1.0.3 = 443 | * Added official support forum. 444 | 445 | = 1.0.1 = 446 | * Added official website details. 447 | 448 | = 1.0.0 = 449 | * Added first version with basic options. 450 | 451 | == Upgrade Notice == 452 | 453 | = 3.1.1 (15/11/2021) = 454 | **👌 Improvements** 455 | 456 | * Security checks and improvements. -------------------------------------------------------------------------------- /includes/admin/class-jj4t3-admin.php: -------------------------------------------------------------------------------- 1 | 12 | * @license http://www.gnu.org/licenses/ GNU General Public License 13 | * @category Core 14 | * @link https://duckdev.com/products/404-to-301/ 15 | * @package JJ4T3 16 | * @subpackage Admin 17 | */ 18 | class JJ4T3_Admin { 19 | 20 | /** 21 | * Error listing table. 22 | * 23 | * @var object 24 | */ 25 | public $list_table; 26 | 27 | /** 28 | * Initialize the class. 29 | * 30 | * Register all hooks in this class. 31 | * All admin facing functionality. 32 | * 33 | * @since 3.0.0 34 | * @access public 35 | */ 36 | public function __construct() { 37 | 38 | add_filter( 'admin_init', array( $this, 'add_buffer' ) ); 39 | add_action( 'admin_enqueue_scripts', array( $this, 'styles' ) ); 40 | add_action( 'admin_enqueue_scripts', array( $this, 'scripts' ) ); 41 | add_action( 'admin_menu', array( $this, 'admin_menu' ) ); 42 | add_action( 'admin_menu', array( $this, 'rename_menu' ) ); 43 | add_action( 'admin_init', array( $this, 'register_settings' ) ); 44 | add_filter( 'set-screen-option', array( 'JJ4T3_Log_Listing', 'set_screen' ), 10, 3 ); 45 | add_action( 'admin_footer', array( $this, 'add_thickbox' ), 100 ); 46 | add_action( 'wp_ajax_jj4t3_redirect_thickbox', array( 'JJ4T3_Log_Listing', 'open_redirect' ), 100 ); 47 | add_action( 'wp_ajax_jj4t3_redirect_form', array( 'JJ4T3_Log_Listing', 'save_redirect' ) ); 48 | add_action( 'admin_footer', array( 'JJ4T3_Log_Listing', 'get_redirect_content' ), 100 ); 49 | add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 5 ); 50 | add_action( 'plugins_loaded', array( $this, 'upgrade' ) ); 51 | 52 | // Show review request. 53 | add_action( 'admin_notices', array( $this, 'review_notice' ) ); 54 | add_action( 'admin_init', array( $this, 'review_action' ) ); 55 | } 56 | 57 | /** 58 | * Output buffer function. 59 | * 60 | * To avoid header already sent issues. 61 | * 62 | * @link https://tommcfarlin.com/wp_redirect-headers-already-sent/ 63 | * @since 2.1.4 64 | * @access public 65 | * 66 | * @uses ob_start() To load buffer. 67 | * 68 | * @return void 69 | */ 70 | public function add_buffer() { 71 | 72 | ob_start(); 73 | } 74 | 75 | /** 76 | * Register the stylesheet for the Dashboard. 77 | * 78 | * This function is used to register all the required stylesheets for 79 | * dashboard. 80 | * Styles will be registered only for our plugin pages for performance. 81 | * 82 | * @since 2.0.0 83 | * @access public 84 | * @global string $pagenow Current page. 85 | * @uses wp_enqueue_style To register styles. 86 | * 87 | * @return void 88 | */ 89 | public function styles() { 90 | global $pagenow; 91 | 92 | if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && in_array( 93 | $_GET['page'], 94 | array( 95 | 'jj4t3-settings', 96 | 'jj4t3-logs', 97 | ), 98 | true 99 | ) 100 | ) { 101 | wp_enqueue_style( 102 | JJ4T3_NAME, 103 | JJ4T3_URL . 'assets/css/admin.min.css', 104 | array(), 105 | JJ4T3_VERSION, 106 | 'all' 107 | ); 108 | } 109 | } 110 | 111 | /** 112 | * Register the scripts for the Dashboard. 113 | * 114 | * This function is used to register all the required scripts for 115 | * dashboard. 116 | * Scripts will be registered only for our plugin pages for performance. 117 | * 118 | * @since 2.0.0 119 | * @access public 120 | * 121 | * @global string $pagenow Current page. 122 | * 123 | * @uses wp_localize_script To translate strings in js. 124 | * 125 | * @uses wp_enqueue_script To register script. 126 | * @return void 127 | */ 128 | public function scripts() { 129 | global $pagenow; 130 | 131 | if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && in_array( 132 | $_GET['page'], 133 | array( 134 | 'jj4t3-settings', 135 | 'jj4t3-logs', 136 | ), 137 | true 138 | ) 139 | ) { 140 | wp_enqueue_script( 141 | JJ4T3_NAME, 142 | JJ4T3_URL . 'assets/js/admin.min.js', 143 | array( 'jquery' ), 144 | JJ4T3_VERSION, 145 | false 146 | ); 147 | 148 | // Strings to translate in js. 149 | $strings = array( 'redirect' => esc_html__( 'Custom Redirect', '404-to-301' ) ); 150 | 151 | wp_localize_script( JJ4T3_NAME, 'jj4t3strings', $strings ); 152 | } 153 | } 154 | 155 | /** 156 | * Creating admin menus for 404 to 301. 157 | * 158 | * Creates one main menu and few sub menu items. 159 | * Menu menu will be linked to 404 error logs by default. 160 | * Set menu access permissions using JJ4T3_ACCESS constant. 161 | * Regitsering action hook - "jj4t3_admin_page". 162 | * 163 | * @since 2.0.0 164 | * @access public 165 | * 166 | * @uses add_submenu_page() Action hook to add new admin menu sub page. 167 | * 168 | * @return void 169 | */ 170 | public function admin_menu() { 171 | 172 | // Main menu for error logs list. 173 | $hook = add_menu_page( 174 | __( '404 Error Logs', '404-to-301' ), 175 | __( '404 Errors', '404-to-301' ), 176 | JJ4T3_ACCESS, 177 | 'jj4t3-logs', 178 | array( 179 | $this, 180 | 'error_list', 181 | ), 182 | 'dashicons-redo', 183 | 90 184 | ); 185 | 186 | // Render screen options on listing table. 187 | add_action( "load-$hook", array( $this, 'screen_option' ) ); 188 | 189 | // 404 to 301 settings menu. 190 | add_submenu_page( 191 | 'jj4t3-logs', 192 | __( '404 to 301 Settings', '404-to-301' ), 193 | __( '404 Settings', '404-to-301' ), 194 | JJ4T3_ACCESS, 195 | 'jj4t3-settings', 196 | array( 197 | $this, 198 | 'admin_page', 199 | ) 200 | ); 201 | 202 | /** 203 | * Action hook to register new submenu item. 204 | * 205 | * You can user this action hook to register any custom 206 | * submenu items to 404 to 301 menu. 207 | * This can be used by add-ons of our plugins. 208 | * 209 | * @since 2.0.0 210 | */ 211 | do_action( 'i4t3_admin_page' ); 212 | } 213 | 214 | /** 215 | * To make screen options for error listing. 216 | * 217 | * This function is used to show screen options like entries per page, 218 | * show/hide columns etc. 219 | * This feature is extended from WP_List_Table class. 220 | * 221 | * @since 2.1.0 222 | * @access public 223 | * 224 | * @return void 225 | */ 226 | public function screen_option() { 227 | 228 | $args = array( 229 | 'label' => __( 'Error Logs', '404-to-301' ), 230 | 'default' => 20, 231 | 'option' => 'logs_per_page', 232 | ); 233 | 234 | add_screen_option( 'per_page', $args ); 235 | 236 | // Error log listing table. 237 | $this->list_table = new JJ4T3_Log_Listing(); 238 | } 239 | 240 | /** 241 | * Show error listing table view. 242 | * 243 | * This method displays the listing table HTML to the page. 244 | * Registering action hook - "jj4t3_log_list_above_form". 245 | * Registering action hook - "jj4t3_log_list_below_form". 246 | * 247 | * @since 2.1.0 248 | * @access public 249 | * 250 | * @return void 251 | */ 252 | public function error_list() { 253 | ?> 254 |
255 |

256 |
257 |
258 |
259 |
260 | list_table->prepare_items(); 262 | /** 263 | * Action hook to add something above listing page. 264 | * 265 | * Use this action hook to add custom filters and search 266 | * boxes to the listing table top section. 267 | * 268 | * @param object $this Listing page class object. 269 | * 270 | * @since 3.0.0 271 | */ 272 | do_action( 'jj4t3_log_list_above_form', $this->list_table ); 273 | ?> 274 |
275 | 276 | list_table->display(); ?> 277 |
278 | list_table ); 290 | ?> 291 |
292 |
293 |
294 |
295 |
296 |
297 | ' . __( 'Settings', '404-to-301' ) . ''; 384 | $settings_link .= ' | ' . __( 'Logs', '404-to-301' ) . ''; 385 | 386 | // Add quick links to plugins listing page. 387 | array_unshift( $links, $settings_link ); 388 | } 389 | 390 | return $links; 391 | } 392 | 393 | /** 394 | * Upgrade plugin on updates. 395 | * 396 | * If there are structural changes to make after new version release, 397 | * make required changes. 398 | * 399 | * @since 3.0.0 400 | * @access public 401 | * 402 | * @return void 403 | */ 404 | public function upgrade() { 405 | 406 | $current_version = get_option( 'i4t3_version_no', false ); 407 | 408 | if ( ! $current_version || ( $current_version < JJ4T3_VERSION ) ) { 409 | if ( ! class_exists( 'JJ4T3_Activator_Deactivator_Uninstaller' ) ) { 410 | include_once JJ4T3_DIR . 'includes/class-jj4t3-activator-deactivator-uninstaller.php'; 411 | } 412 | 413 | // Run upgrade actions. 414 | JJ4T3_Activator_Deactivator_Uninstaller::activate(); 415 | 416 | // Update the plugin version number. 417 | update_option( 'i4t3_version_no', JJ4T3_VERSION ); 418 | } 419 | } 420 | 421 | /** 422 | * Show admin to ask for review in wp.org. 423 | * 424 | * Show admin notice only inside our plugin's settings page. 425 | * Hide the notice permanently if user dismissed it. 426 | * 427 | * @since 3.0.4 428 | * 429 | * @return void|bool 430 | */ 431 | public function review_notice() { 432 | global $pagenow; 433 | 434 | // Only on our page. 435 | if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && in_array( 436 | $_GET['page'], 437 | array( 438 | 'jj4t3-settings', 439 | 'jj4t3-logs', 440 | 'jj4t3-logs-addons', 441 | ) 442 | ) 443 | ) { 444 | // Only for admins. 445 | if ( ! current_user_can( 'manage_options' ) ) { 446 | return false; 447 | } 448 | // Get the notice time. 449 | $notice_time = get_option( 'i4t3_review_notice' ); 450 | // If not set, set now and bail. 451 | if ( ! $notice_time ) { 452 | // Set to next week. 453 | return add_option( 'i4t3_review_notice', time() + 604800 ); 454 | } 455 | 456 | // Current logged in user. 457 | $current_user = wp_get_current_user(); 458 | // Did the current user already dismiss?. 459 | $dismissed = get_user_meta( $current_user->ID, 'i4t3_review_notice_dismissed', true ); 460 | // Continue only when allowed. 461 | if ( (int) $notice_time <= time() && ! $dismissed ) { 462 | ?> 463 |
464 |

465 | display_name ) ? esc_html__( 'there', '404-to-301' ) : esc_html( ucwords( $current_user->display_name ) ), 469 | '', 470 | '' 471 | ); 472 | ?> 473 |

474 |

475 | 476 |

477 |

478 | 479 |

480 |

481 | 482 |

483 |
484 | \n" 13 | "Language-Team: Joel James \n" 14 | "Language: en\n" 15 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 16 | "X-Poedit-Country: United States\n" 17 | "X-Poedit-SourceCharset: UTF-8\n" 18 | "X-Poedit-KeywordsList: " 19 | "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" 20 | "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" 21 | "X-Poedit-Basepath: ../\n" 22 | "X-Poedit-SearchPath-0: .\n" 23 | "X-Poedit-Bookmarks: \n" 24 | "X-Textdomain-Support: yes\n" 25 | "X-Generator: grunt-wp-i18n 1.0.3\n" 26 | 27 | #: includes/admin/class-jj4t3-admin.php:139 28 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:139 29 | msgid "Custom Redirect" 30 | msgstr "" 31 | 32 | #: includes/admin/class-jj4t3-admin.php:163 33 | #: includes/admin/class-jj4t3-admin.php:230 34 | #: includes/admin/class-jj4t3-log-listing.php:47 35 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:163 36 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:230 37 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:47 38 | msgid "404 Error Logs" 39 | msgstr "" 40 | 41 | #: includes/admin/class-jj4t3-admin.php:163 42 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:163 43 | msgid "404 Errors" 44 | msgstr "" 45 | 46 | #: includes/admin/class-jj4t3-admin.php:172 47 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:172 48 | msgid "404 to 301 Settings" 49 | msgstr "" 50 | 51 | #: includes/admin/class-jj4t3-admin.php:172 52 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:172 53 | msgid "404 Settings" 54 | msgstr "" 55 | 56 | #: includes/admin/class-jj4t3-admin.php:204 57 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:204 58 | msgid "Error Logs" 59 | msgstr "" 60 | 61 | #: includes/admin/class-jj4t3-admin.php:288 includes/admin/views/admin.php:21 62 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:288 63 | #: releases/404-to-301/includes/admin/views/admin.php:21 64 | msgid "404 to 301" 65 | msgstr "" 66 | 67 | #: includes/admin/class-jj4t3-admin.php:357 includes/admin/views/admin.php:27 68 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:357 69 | #: releases/404-to-301/includes/admin/views/admin.php:27 70 | msgid "Settings" 71 | msgstr "" 72 | 73 | #: includes/admin/class-jj4t3-admin.php:358 74 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:358 75 | msgid "Logs" 76 | msgstr "" 77 | 78 | #: includes/admin/class-jj4t3-admin.php:435 79 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:435 80 | msgid "" 81 | "Hey %1$s, I noticed you've been using %2$s404 to 301%3$s for more than 1 " 82 | "week – that’s awesome! Could you please do me a BIG favor and give it a " 83 | "5-star rating on WordPress? Just to help us spread the word and boost our " 84 | "motivation." 85 | msgstr "" 86 | 87 | #: includes/admin/class-jj4t3-admin.php:436 88 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:436 89 | msgid "there" 90 | msgstr "" 91 | 92 | #: includes/admin/class-jj4t3-admin.php:442 93 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:442 94 | msgid "Ok, you deserve it" 95 | msgstr "" 96 | 97 | #: includes/admin/class-jj4t3-admin.php:445 98 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:445 99 | msgid "Nope, maybe later" 100 | msgstr "" 101 | 102 | #: includes/admin/class-jj4t3-admin.php:448 103 | #: releases/404-to-301/includes/admin/class-jj4t3-admin.php:448 104 | msgid "I already did" 105 | msgstr "" 106 | 107 | #: includes/admin/class-jj4t3-log-listing.php:46 108 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:46 109 | msgid "404 Error Log" 110 | msgstr "" 111 | 112 | #: includes/admin/class-jj4t3-log-listing.php:328 113 | #: includes/functions/jj4t3-general-functions.php:317 114 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:328 115 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:317 116 | msgid "Date" 117 | msgstr "" 118 | 119 | #: includes/admin/class-jj4t3-log-listing.php:329 120 | #: includes/functions/jj4t3-general-functions.php:318 121 | #: includes/public/class-jj4t3-404-email.php:193 122 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:329 123 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:318 124 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:193 125 | msgid "404 Path" 126 | msgstr "" 127 | 128 | #: includes/admin/class-jj4t3-log-listing.php:330 129 | #: includes/functions/jj4t3-general-functions.php:319 130 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:330 131 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:319 132 | msgid "From" 133 | msgstr "" 134 | 135 | #: includes/admin/class-jj4t3-log-listing.php:331 136 | #: includes/functions/jj4t3-general-functions.php:320 137 | #: includes/public/class-jj4t3-404-email.php:198 138 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:331 139 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:320 140 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:198 141 | msgid "IP Address" 142 | msgstr "" 143 | 144 | #: includes/admin/class-jj4t3-log-listing.php:332 145 | #: includes/functions/jj4t3-general-functions.php:321 146 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:332 147 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:321 148 | msgid "User Agent" 149 | msgstr "" 150 | 151 | #: includes/admin/class-jj4t3-log-listing.php:333 152 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:333 153 | msgid "Customization" 154 | msgstr "" 155 | 156 | #: includes/admin/class-jj4t3-log-listing.php:475 157 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:475 158 | msgid "Are you sure you want to delete this item?" 159 | msgstr "" 160 | 161 | #: includes/admin/class-jj4t3-log-listing.php:477 162 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:477 163 | msgid "Delete" 164 | msgstr "" 165 | 166 | #: includes/admin/class-jj4t3-log-listing.php:624 167 | #: includes/admin/views/custom-redirect.php:17 168 | #: includes/admin/views/custom-redirect.php:25 169 | #: includes/admin/views/custom-redirect.php:33 170 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:624 171 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:17 172 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:25 173 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:33 174 | msgid "Default" 175 | msgstr "" 176 | 177 | #: includes/admin/class-jj4t3-log-listing.php:626 178 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:626 179 | msgid "Customize" 180 | msgstr "" 181 | 182 | #: includes/admin/class-jj4t3-log-listing.php:696 183 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:696 184 | msgid "Delete Selected" 185 | msgstr "" 186 | 187 | #: includes/admin/class-jj4t3-log-listing.php:697 188 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:697 189 | msgid "Delete All" 190 | msgstr "" 191 | 192 | #: includes/admin/class-jj4t3-log-listing.php:698 193 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:698 194 | msgid "Delete All (Keep redirects)" 195 | msgstr "" 196 | 197 | #: includes/admin/class-jj4t3-log-listing.php:735 198 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:735 199 | msgid "Group by" 200 | msgstr "" 201 | 202 | #: includes/admin/class-jj4t3-log-listing.php:740 203 | #: releases/404-to-301/includes/admin/class-jj4t3-log-listing.php:740 204 | msgid "Apply" 205 | msgstr "" 206 | 207 | #: includes/admin/views/admin.php:21 208 | #: releases/404-to-301/includes/admin/views/admin.php:21 209 | msgid "by Joel James" 210 | msgstr "" 211 | 212 | #: includes/admin/views/custom-redirect.php:11 213 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:11 214 | msgid "Redirecting from" 215 | msgstr "" 216 | 217 | #: includes/admin/views/custom-redirect.php:15 218 | #: includes/functions/jj4t3-general-functions.php:322 219 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:15 220 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:322 221 | msgid "Redirect" 222 | msgstr "" 223 | 224 | #: includes/admin/views/custom-redirect.php:18 225 | #: includes/admin/views/custom-redirect.php:26 226 | #: includes/admin/views/custom-redirect.php:34 227 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:18 228 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:26 229 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:34 230 | msgid "Enable" 231 | msgstr "" 232 | 233 | #: includes/admin/views/custom-redirect.php:19 234 | #: includes/admin/views/custom-redirect.php:27 235 | #: includes/admin/views/custom-redirect.php:35 236 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:19 237 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:27 238 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:35 239 | msgid "Disable" 240 | msgstr "" 241 | 242 | #: includes/admin/views/custom-redirect.php:23 243 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:23 244 | msgid "Error logging" 245 | msgstr "" 246 | 247 | #: includes/admin/views/custom-redirect.php:31 248 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:31 249 | msgid "Email alert" 250 | msgstr "" 251 | 252 | #: includes/admin/views/custom-redirect.php:39 253 | #: includes/admin/views/settings.php:30 254 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:39 255 | #: releases/404-to-301/includes/admin/views/settings.php:30 256 | msgid "Redirect to" 257 | msgstr "" 258 | 259 | #: includes/admin/views/custom-redirect.php:42 260 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:42 261 | msgid "" 262 | "Enter the url if you want to set custom redirect for above 404 path. Enter " 263 | "the full url including http://. Leave empty if you want to follow default " 264 | "settings." 265 | msgstr "" 266 | 267 | #: includes/admin/views/custom-redirect.php:51 268 | #: includes/admin/views/settings.php:17 269 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:51 270 | #: releases/404-to-301/includes/admin/views/settings.php:17 271 | msgid "Redirect type" 272 | msgstr "" 273 | 274 | #: includes/admin/views/custom-redirect.php:58 275 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:58 276 | msgid "Select redirect type to override default one." 277 | msgstr "" 278 | 279 | #: includes/admin/views/custom-redirect.php:65 280 | #: releases/404-to-301/includes/admin/views/custom-redirect.php:65 281 | msgid "Save Redirect" 282 | msgstr "" 283 | 284 | #: includes/admin/views/settings.php:24 285 | #: releases/404-to-301/includes/admin/views/settings.php:24 286 | msgid "Learn more" 287 | msgstr "" 288 | 289 | #: includes/admin/views/settings.php:24 290 | #: releases/404-to-301/includes/admin/views/settings.php:24 291 | msgid "about these redirect types" 292 | msgstr "" 293 | 294 | #: includes/admin/views/settings.php:33 includes/admin/views/settings.php:37 295 | #: releases/404-to-301/includes/admin/views/settings.php:33 296 | #: releases/404-to-301/includes/admin/views/settings.php:37 297 | msgid "Existing Page" 298 | msgstr "" 299 | 300 | #: includes/admin/views/settings.php:34 includes/admin/views/settings.php:38 301 | #: includes/admin/views/settings.php:52 302 | #: releases/404-to-301/includes/admin/views/settings.php:34 303 | #: releases/404-to-301/includes/admin/views/settings.php:38 304 | #: releases/404-to-301/includes/admin/views/settings.php:52 305 | msgid "Custom URL" 306 | msgstr "" 307 | 308 | #: includes/admin/views/settings.php:35 includes/admin/views/settings.php:39 309 | #: releases/404-to-301/includes/admin/views/settings.php:35 310 | #: releases/404-to-301/includes/admin/views/settings.php:39 311 | msgid "No Redirect" 312 | msgstr "" 313 | 314 | #: includes/admin/views/settings.php:37 315 | #: releases/404-to-301/includes/admin/views/settings.php:37 316 | msgid "Select any WordPress page as a 404 page" 317 | msgstr "" 318 | 319 | #: includes/admin/views/settings.php:38 320 | #: releases/404-to-301/includes/admin/views/settings.php:38 321 | msgid "Redirect 404 requests to a specific URL" 322 | msgstr "" 323 | 324 | #: includes/admin/views/settings.php:39 325 | #: releases/404-to-301/includes/admin/views/settings.php:39 326 | msgid "To disable redirect" 327 | msgstr "" 328 | 329 | #: includes/admin/views/settings.php:40 330 | #: releases/404-to-301/includes/admin/views/settings.php:40 331 | msgid "" 332 | "You can override this by setting individual custom redirects from error " 333 | "logs list." 334 | msgstr "" 335 | 336 | #: includes/admin/views/settings.php:44 337 | #: releases/404-to-301/includes/admin/views/settings.php:44 338 | msgid "Select the page" 339 | msgstr "" 340 | 341 | #: includes/admin/views/settings.php:47 342 | #: releases/404-to-301/includes/admin/views/settings.php:47 343 | msgid "The default 404 page will be replaced by the page you choose in this list." 344 | msgstr "" 345 | 346 | #: includes/admin/views/settings.php:48 347 | #: releases/404-to-301/includes/admin/views/settings.php:48 348 | msgid "" 349 | "You can create a custom 404 page and " 350 | "assign that page here." 351 | msgstr "" 352 | 353 | #: includes/admin/views/settings.php:55 354 | #: releases/404-to-301/includes/admin/views/settings.php:55 355 | msgid "Enter any url (including http://)" 356 | msgstr "" 357 | 358 | #: includes/admin/views/settings.php:59 359 | #: releases/404-to-301/includes/admin/views/settings.php:59 360 | msgid "Log 404 Errors" 361 | msgstr "" 362 | 363 | #: includes/admin/views/settings.php:62 364 | #: releases/404-to-301/includes/admin/views/settings.php:62 365 | msgid "Enable/Disable Logging" 366 | msgstr "" 367 | 368 | #: includes/admin/views/settings.php:66 369 | #: releases/404-to-301/includes/admin/views/settings.php:66 370 | msgid "Email notifications" 371 | msgstr "" 372 | 373 | #: includes/admin/views/settings.php:69 374 | #: releases/404-to-301/includes/admin/views/settings.php:69 375 | msgid "" 376 | "If you check this, an email will be sent on every 404 log on the admin " 377 | "email account." 378 | msgstr "" 379 | 380 | #: includes/admin/views/settings.php:73 381 | #: releases/404-to-301/includes/admin/views/settings.php:73 382 | msgid "Disable URL guessing" 383 | msgstr "" 384 | 385 | #: includes/admin/views/settings.php:76 386 | #: releases/404-to-301/includes/admin/views/settings.php:76 387 | msgid "" 388 | "If you disable URL guessing, it will stop WordPress from autocorrecting " 389 | "incorrect URLs. %1$sLearn more%2$s about canonical redirect." 390 | msgstr "" 391 | 392 | #: includes/admin/views/settings.php:80 393 | #: releases/404-to-301/includes/admin/views/settings.php:80 394 | msgid "Email address" 395 | msgstr "" 396 | 397 | #: includes/admin/views/settings.php:84 398 | #: releases/404-to-301/includes/admin/views/settings.php:84 399 | msgid "Change the recipient email address for error log notifications." 400 | msgstr "" 401 | 402 | #: includes/admin/views/settings.php:88 403 | #: releases/404-to-301/includes/admin/views/settings.php:88 404 | msgid "Exclude paths" 405 | msgstr "" 406 | 407 | #: includes/admin/views/settings.php:91 408 | #: releases/404-to-301/includes/admin/views/settings.php:91 409 | msgid "If you want to exclude few paths from error logs, enter here. One per line." 410 | msgstr "" 411 | 412 | #: includes/admin/views/settings.php:96 413 | #: releases/404-to-301/includes/admin/views/settings.php:96 414 | msgid "Save settings" 415 | msgstr "" 416 | 417 | #: includes/functions/jj4t3-general-functions.php:283 418 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:283 419 | msgid "301 Redirect (SEO)" 420 | msgstr "" 421 | 422 | #: includes/functions/jj4t3-general-functions.php:284 423 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:284 424 | msgid "302 Redirect" 425 | msgstr "" 426 | 427 | #: includes/functions/jj4t3-general-functions.php:285 428 | #: releases/404-to-301/includes/functions/jj4t3-general-functions.php:285 429 | msgid "307 Redirect" 430 | msgstr "" 431 | 432 | #: includes/public/class-jj4t3-404-email.php:141 433 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:141 434 | msgid "Snap! One more 404 on " 435 | msgstr "" 436 | 437 | #: includes/public/class-jj4t3-404-email.php:189 438 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:189 439 | msgid "Bummer! You have one more 404" 440 | msgstr "" 441 | 442 | #: includes/public/class-jj4t3-404-email.php:203 443 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:203 444 | msgid "Time" 445 | msgstr "" 446 | 447 | #: includes/public/class-jj4t3-404-email.php:208 448 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:208 449 | msgid "Referral Page" 450 | msgstr "" 451 | 452 | #: includes/public/class-jj4t3-404-email.php:213 453 | #: releases/404-to-301/includes/public/class-jj4t3-404-email.php:213 454 | msgid "Alert sent by the %s404 to 301%s plugin for WordPress." 455 | msgstr "" 456 | 457 | #. Plugin Name of the plugin/theme 458 | msgid "404 to 301 - Redirect, Log and Notify 404 Errors" 459 | msgstr "" 460 | 461 | #. Plugin URI of the plugin/theme 462 | msgid "https://duckdev.com/products/404-to-301/" 463 | msgstr "" 464 | 465 | #. Description of the plugin/theme 466 | msgid "" 467 | "Automatically redirect all 404 errors to any page using " 468 | "301 redirect for SEO. You can redirect and " 469 | "log every 404 errors. No more 404 errors in Webmaster tool." 470 | msgstr "" 471 | 472 | #. Author of the plugin/theme 473 | msgid "Joel James" 474 | msgstr "" 475 | 476 | #. Author URI of the plugin/theme 477 | msgid "https://duckdev.com/" 478 | msgstr "" -------------------------------------------------------------------------------- /languages/404-to-301-pt_PT.po: -------------------------------------------------------------------------------- 1 | # Translation of Stable (latest release) in Portuguese (Portugal) 2 | # This file is distributed under the same license as the Stable (latest release) package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: 404 to 301\n" 6 | "POT-Creation-Date: 2018-06-20 00:50+0530\n" 7 | "PO-Revision-Date: 2018-06-20 00:50+0530\n" 8 | "Last-Translator: Pedro Mendonça \n" 9 | "Language-Team: Pedro Mendonça \n" 10 | "Language: pt_PT\n" 11 | "MIME-Version: 1.0\n" 12 | "Content-Type: text/plain; charset=UTF-8\n" 13 | "Content-Transfer-Encoding: 8bit\n" 14 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 15 | "X-Generator: Poedit 1.8.7.1\n" 16 | "X-Poedit-SourceCharset: UTF-8\n" 17 | "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;" 18 | "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;" 19 | "esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" 20 | "X-Poedit-Basepath: ..\n" 21 | "X-Poedit-WPHeader: 404-to-301.php\n" 22 | "X-Poedit-SearchPath-0: .\n" 23 | 24 | #: includes/admin/class-jj4t3-admin.php:127 25 | msgid "Custom Redirect" 26 | msgstr "Redireccionamento personalizado" 27 | 28 | #: includes/admin/class-jj4t3-admin.php:151 29 | #: includes/admin/class-jj4t3-admin.php:212 30 | #: includes/admin/class-jj4t3-log-listing.php:47 31 | msgid "404 Error Logs" 32 | msgstr "Registos de erros 404" 33 | 34 | #: includes/admin/class-jj4t3-admin.php:151 35 | msgid "404 Errors" 36 | msgstr "" 37 | 38 | #: includes/admin/class-jj4t3-admin.php:157 39 | msgid "404 to 301 Settings" 40 | msgstr "Definições de 404 to 301" 41 | 42 | #: includes/admin/class-jj4t3-admin.php:157 43 | msgid "404 Settings" 44 | msgstr "Definições de 404" 45 | 46 | #: includes/admin/class-jj4t3-admin.php:186 47 | msgid "Error Logs" 48 | msgstr "Registos de erros" 49 | 50 | #: includes/admin/class-jj4t3-admin.php:270 includes/admin/views/admin.php:21 51 | msgid "404 to 301" 52 | msgstr "404 to 301" 53 | 54 | #: includes/admin/class-jj4t3-admin.php:339 includes/admin/views/admin.php:27 55 | msgid "Settings" 56 | msgstr "Definições" 57 | 58 | #: includes/admin/class-jj4t3-admin.php:340 59 | msgid "Logs" 60 | msgstr "Registos" 61 | 62 | #: includes/admin/class-jj4t3-log-listing.php:46 63 | msgid "404 Error Log" 64 | msgstr "Registo de erro 404" 65 | 66 | #: includes/admin/class-jj4t3-log-listing.php:328 67 | #: includes/functions/jj4t3-general-functions.php:317 68 | msgid "Date" 69 | msgstr "Data" 70 | 71 | #: includes/admin/class-jj4t3-log-listing.php:329 72 | #: includes/functions/jj4t3-general-functions.php:318 73 | #: includes/public/class-jj4t3-404-email.php:193 74 | msgid "404 Path" 75 | msgstr "Caminho de 404" 76 | 77 | #: includes/admin/class-jj4t3-log-listing.php:330 78 | #: includes/functions/jj4t3-general-functions.php:319 79 | msgid "From" 80 | msgstr "De" 81 | 82 | #: includes/admin/class-jj4t3-log-listing.php:331 83 | #: includes/functions/jj4t3-general-functions.php:320 84 | #: includes/public/class-jj4t3-404-email.php:198 85 | msgid "IP Address" 86 | msgstr "Endereço IP" 87 | 88 | #: includes/admin/class-jj4t3-log-listing.php:332 89 | #: includes/functions/jj4t3-general-functions.php:321 90 | msgid "User Agent" 91 | msgstr "Agente do utilizador" 92 | 93 | #: includes/admin/class-jj4t3-log-listing.php:333 94 | msgid "Customization" 95 | msgstr "" 96 | 97 | #: includes/admin/class-jj4t3-log-listing.php:397 98 | msgid "Ah! You are so clean that you still got ZERO errors." 99 | msgstr "" 100 | 101 | #: includes/admin/class-jj4t3-log-listing.php:475 102 | msgid "Are you sure you want to delete this item?" 103 | msgstr "Tem a certeza que quer eliminar este item?" 104 | 105 | #: includes/admin/class-jj4t3-log-listing.php:477 106 | msgid "Delete" 107 | msgstr "Eliminar" 108 | 109 | #: includes/admin/class-jj4t3-log-listing.php:624 110 | #: includes/admin/views/custom-redirect.php:17 111 | #: includes/admin/views/custom-redirect.php:25 112 | #: includes/admin/views/custom-redirect.php:33 113 | msgid "Default" 114 | msgstr "Por omissão" 115 | 116 | #: includes/admin/class-jj4t3-log-listing.php:626 117 | msgid "Customize" 118 | msgstr "Personalizar" 119 | 120 | #: includes/admin/class-jj4t3-log-listing.php:696 121 | msgid "Delete Selected" 122 | msgstr "Eliminar seleccionados" 123 | 124 | #: includes/admin/class-jj4t3-log-listing.php:697 125 | msgid "Delete All" 126 | msgstr "Eliminar tudo" 127 | 128 | #: includes/admin/class-jj4t3-log-listing.php:698 129 | msgid "Delete All (Keep redirects)" 130 | msgstr "" 131 | 132 | #: includes/admin/class-jj4t3-log-listing.php:735 133 | msgid "Group by" 134 | msgstr "" 135 | 136 | #: includes/admin/class-jj4t3-log-listing.php:740 137 | msgid "Apply" 138 | msgstr "Aplicar" 139 | 140 | #: includes/admin/views/admin.php:21 141 | #, php-format 142 | msgid "by Joel James" 143 | msgstr "" 144 | 145 | #: includes/admin/views/custom-redirect.php:11 146 | msgid "Redirecting from" 147 | msgstr "Redireccionar de" 148 | 149 | #: includes/admin/views/custom-redirect.php:15 150 | #: includes/functions/jj4t3-general-functions.php:322 151 | msgid "Redirect" 152 | msgstr "Redireccionamento" 153 | 154 | #: includes/admin/views/custom-redirect.php:18 155 | #: includes/admin/views/custom-redirect.php:26 156 | #: includes/admin/views/custom-redirect.php:34 157 | msgid "Enable" 158 | msgstr "" 159 | 160 | #: includes/admin/views/custom-redirect.php:19 161 | #: includes/admin/views/custom-redirect.php:27 162 | #: includes/admin/views/custom-redirect.php:35 163 | msgid "Disable" 164 | msgstr "" 165 | 166 | #: includes/admin/views/custom-redirect.php:23 167 | msgid "Error logging" 168 | msgstr "" 169 | 170 | #: includes/admin/views/custom-redirect.php:31 171 | msgid "Email alert" 172 | msgstr "" 173 | 174 | #: includes/admin/views/custom-redirect.php:39 175 | #: includes/admin/views/settings.php:30 176 | msgid "Redirect to" 177 | msgstr "Redireccionar para" 178 | 179 | #: includes/admin/views/custom-redirect.php:42 180 | msgid "" 181 | "Enter the url if you want to set custom redirect for above 404 path. Enter " 182 | "the full url including http://. Leave empty if you want to follow deafult " 183 | "settings." 184 | msgstr "" 185 | 186 | #: includes/admin/views/custom-redirect.php:51 187 | #: includes/admin/views/settings.php:17 188 | msgid "Redirect type" 189 | msgstr "Tipo de redireccionamento" 190 | 191 | #: includes/admin/views/custom-redirect.php:58 192 | msgid "Select redirect type to override default one." 193 | msgstr "" 194 | 195 | #: includes/admin/views/custom-redirect.php:65 196 | msgid "Save Redirect" 197 | msgstr "Guardar redireccionamento" 198 | 199 | #: includes/admin/views/settings.php:24 200 | msgid "Learn more" 201 | msgstr "Saiba mais" 202 | 203 | #: includes/admin/views/settings.php:24 204 | msgid "about these redirect types" 205 | msgstr "sobre estes tipos de redireccionamento" 206 | 207 | #: includes/admin/views/settings.php:33 includes/admin/views/settings.php:37 208 | msgid "Existing Page" 209 | msgstr "Página existente" 210 | 211 | #: includes/admin/views/settings.php:34 includes/admin/views/settings.php:38 212 | #: includes/admin/views/settings.php:52 213 | msgid "Custom URL" 214 | msgstr "URL personalizado" 215 | 216 | #: includes/admin/views/settings.php:35 includes/admin/views/settings.php:39 217 | msgid "No Redirect" 218 | msgstr "Sem redireccionamento" 219 | 220 | #: includes/admin/views/settings.php:37 221 | msgid "Select any WordPress page as a 404 page" 222 | msgstr "Seleccione qualquer página do WordPress como página 404" 223 | 224 | #: includes/admin/views/settings.php:38 225 | msgid "Redirect 404 requests to a specific URL" 226 | msgstr "Redireccione pedidos 404 para um URL específico" 227 | 228 | #: includes/admin/views/settings.php:39 229 | msgid "To disable redirect" 230 | msgstr "Para desactivar o redireccionamento" 231 | 232 | #: includes/admin/views/settings.php:40 233 | msgid "" 234 | "You can override this by setting individual custom redirects from error logs " 235 | "list." 236 | msgstr "" 237 | "Esta definição pode ser sobreposta por redireccionamentos personalizados " 238 | "individuais a partir da lista de registos de erros." 239 | 240 | #: includes/admin/views/settings.php:44 241 | msgid "Select the page" 242 | msgstr "Seleccione a página" 243 | 244 | #: includes/admin/views/settings.php:47 245 | msgid "" 246 | "The default 404 page will be replaced by the page you choose in this list." 247 | msgstr "" 248 | 249 | #: includes/admin/views/settings.php:48 250 | #, php-format 251 | msgid "" 252 | "You can create a custom 404 page and " 253 | "assign that page here." 254 | msgstr "" 255 | 256 | #: includes/admin/views/settings.php:55 257 | msgid "Enter any url (including http://)" 258 | msgstr "" 259 | 260 | #: includes/admin/views/settings.php:59 261 | msgid "Log 404 Errors" 262 | msgstr "Registar erros 404" 263 | 264 | #: includes/admin/views/settings.php:62 265 | msgid "Enable/Disable Logging" 266 | msgstr "Activar/Desactivar registo" 267 | 268 | #: includes/admin/views/settings.php:66 269 | msgid "Email notifications" 270 | msgstr "Notificações por email" 271 | 272 | #: includes/admin/views/settings.php:69 273 | msgid "" 274 | "If you check this, an email will be sent on every 404 log on the admin email " 275 | "account." 276 | msgstr "" 277 | 278 | #: includes/admin/views/settings.php:73 279 | msgid "Email address" 280 | msgstr "Endereço de email" 281 | 282 | #: includes/admin/views/settings.php:77 283 | msgid "Change the recipient email address for error log notifications." 284 | msgstr "" 285 | 286 | #: includes/admin/views/settings.php:81 287 | msgid "Exclude paths" 288 | msgstr "Excluir caminhos" 289 | 290 | #: includes/admin/views/settings.php:84 291 | msgid "" 292 | "If you want to exclude few paths from error logs, enter here. One per line." 293 | msgstr "" 294 | "Se quiser excluir alguns caminhos dos registos de erros, insira aqui, um por " 295 | "linha." 296 | 297 | #: includes/admin/views/settings.php:89 298 | msgid "Save settings" 299 | msgstr "" 300 | 301 | #: includes/functions/jj4t3-general-functions.php:283 302 | msgid "301 Redirect (SEO)" 303 | msgstr "" 304 | 305 | #: includes/functions/jj4t3-general-functions.php:284 306 | msgid "302 Redirect" 307 | msgstr "" 308 | 309 | #: includes/functions/jj4t3-general-functions.php:285 310 | msgid "307 Redirect" 311 | msgstr "" 312 | 313 | #: includes/public/class-jj4t3-404-email.php:141 314 | msgid "Snap! One more 404 on " 315 | msgstr "Ups! Tem mais um 404 em " 316 | 317 | #: includes/public/class-jj4t3-404-email.php:189 318 | msgid "Bummer! You have one more 404" 319 | msgstr "Ups! Tem mais um 404." 320 | 321 | #: includes/public/class-jj4t3-404-email.php:203 322 | msgid "Time" 323 | msgstr "" 324 | 325 | #: includes/public/class-jj4t3-404-email.php:208 326 | msgid "Referral Page" 327 | msgstr "" 328 | 329 | #~ msgid "Thank you for choosing 404 to 301 to improve your website" 330 | #~ msgstr "Obrigado por escolher o 404 to 301 para optimizar o seu site" 331 | 332 | #~ msgid "Kindly give this plugin a %srating%s" 333 | #~ msgstr "Por favor, atribua a este plugin uma %sclassificação%s" 334 | 335 | #~ msgid "Settings Data" 336 | #~ msgstr "Dados das definições" 337 | 338 | #~ msgid "Basic Details" 339 | #~ msgstr "Detalhes básicos" 340 | 341 | #~ msgid "WordPress Version" 342 | #~ msgstr "Versão do WordPress" 343 | 344 | #~ msgid "PHP Version" 345 | #~ msgstr "Versão do PHP" 346 | 347 | #~ msgid "Plugin Version" 348 | #~ msgstr "Versão do plugin" 349 | 350 | #~ msgid "Home Page" 351 | #~ msgstr "Página inicial" 352 | 353 | #~ msgid "Active Theme Details" 354 | #~ msgstr "Detalhes do tema activo" 355 | 356 | #~ msgid "Name" 357 | #~ msgstr "Nome" 358 | 359 | #~ msgid "Version" 360 | #~ msgstr "Versão" 361 | 362 | #~ msgid "Theme URI" 363 | #~ msgstr "URI do tema" 364 | 365 | #~ msgid "Active Plugins" 366 | #~ msgstr "Plugins activos" 367 | 368 | #~ msgid "Ulta pulta..! Seems like you had no errors to log." 369 | #~ msgstr "Ena! Parece que não ocorreu nenhum erro para registar." 370 | 371 | #~ msgid "N/A" 372 | #~ msgstr "Não disponível" 373 | 374 | #~ msgid "List View" 375 | #~ msgstr "Vista de lista" 376 | 377 | #~ msgid "Excerpt View" 378 | #~ msgstr "Vista de excerto" 379 | 380 | #~ msgid "No items found." 381 | #~ msgstr "Nenhum item encontrado." 382 | 383 | #~ msgid "Select bulk action" 384 | #~ msgstr "Seleccionar acção por lotes" 385 | 386 | #~ msgid "Bulk Actions" 387 | #~ msgstr "Acções por lotes" 388 | 389 | #~ msgid "Show more details" 390 | #~ msgstr "Ver mais detalhes" 391 | 392 | #~ msgid "Filter by date" 393 | #~ msgstr "Filtrar por data" 394 | 395 | #~ msgid "All dates" 396 | #~ msgstr "Todas as datas" 397 | 398 | #~ msgid "%1$s %2$d" 399 | #~ msgstr "%1$s de %2$d" 400 | 401 | #~ msgid "%s comment" 402 | #~ msgid_plural "%s comments" 403 | #~ msgstr[0] "%s comentário" 404 | #~ msgstr[1] "%s comentários" 405 | 406 | #~ msgid "%s approved comment" 407 | #~ msgid_plural "%s approved comments" 408 | #~ msgstr[0] "%s comentário aprovado" 409 | #~ msgstr[1] "%s comentários aprovados" 410 | 411 | #~ msgid "%s pending comment" 412 | #~ msgid_plural "%s pending comments" 413 | #~ msgstr[0] "%s comentário pendente" 414 | #~ msgstr[1] "%s comentários pendentes" 415 | 416 | #~ msgid "No comments" 417 | #~ msgstr "Sem comentários" 418 | 419 | #~ msgid "No approved comments" 420 | #~ msgstr "Sem comentários aprovados" 421 | 422 | #~ msgid "No pending comments" 423 | #~ msgstr "Não há comentários pendentes" 424 | 425 | #~ msgid "%s item" 426 | #~ msgid_plural "%s items" 427 | #~ msgstr[0] "%s item" 428 | #~ msgstr[1] "%s itens" 429 | 430 | #~ msgid "First page" 431 | #~ msgstr "Primeira página" 432 | 433 | #~ msgid "Previous page" 434 | #~ msgstr "Página anterior" 435 | 436 | #~ msgid "Current Page" 437 | #~ msgstr "Página actual" 438 | 439 | #~ msgctxt "paging" 440 | #~ msgid "%1$s of %2$s" 441 | #~ msgstr "%1$s de %2$s" 442 | 443 | #~ msgid "Next page" 444 | #~ msgstr "Página seguinte" 445 | 446 | #~ msgid "Last page" 447 | #~ msgstr "Última página" 448 | 449 | #~ msgid "Select All" 450 | #~ msgstr "Seleccionar tudo" 451 | 452 | #~ msgid "%s pending" 453 | #~ msgstr "%s pendente(s)" 454 | 455 | #~ msgid "1 item" 456 | #~ msgid_plural "%s items" 457 | #~ msgstr[0] "1 item" 458 | #~ msgstr[1] "%s itens" 459 | 460 | #~ msgid "Go to the first page" 461 | #~ msgstr "Ir para a primeira página" 462 | 463 | #~ msgid "Go to the previous page" 464 | #~ msgstr "Ir para a página anterior" 465 | 466 | #~ msgid "Select Page" 467 | #~ msgstr "Seleccionar página" 468 | 469 | #~ msgid "Go to the next page" 470 | #~ msgstr "Ir para a página seguinte" 471 | 472 | #~ msgid "Go to the last page" 473 | #~ msgstr "Ir para a última página" 474 | 475 | #~ msgid "I accept" 476 | #~ msgstr "Aceito" 477 | 478 | #~ msgid "I do not accept" 479 | #~ msgstr "Não aceito" 480 | 481 | #~ msgid "About the plugin & developer" 482 | #~ msgstr "Sobre o plugin e o programador" 483 | 484 | #~ msgid "Yo %s!" 485 | #~ msgstr "Olá %s!" 486 | 487 | #~ msgid "Thank you for using 404 to 301" 488 | #~ msgstr "Obrigado por utilizar o 404 to 301." 489 | 490 | #~ msgid "This plugin is brought to you by" 491 | #~ msgstr "Este plugin é desenvolvido por" 492 | 493 | #~ msgid "Visit author website" 494 | #~ msgstr "Visite o website do autor" 495 | 496 | #~ msgid "a web store developed and managed by Joel James." 497 | #~ msgstr "uma loja online desenvolvida e gerida por Joel James." 498 | 499 | #~ msgid "So you installed this plugin and how is it doing? Feel free to" 500 | #~ msgstr "" 501 | #~ "Então, instalou este plugin, que tal está a correr? Sinta-se à vontade " 502 | #~ "para" 503 | 504 | #~ msgid "Contact the developer" 505 | #~ msgstr "Contacte o programador" 506 | 507 | #~ msgid "get in touch with me" 508 | #~ msgstr "entrar em contacto comigo" 509 | 510 | #~ msgid "anytime for help. I am always happy to help." 511 | #~ msgstr "a qualquer momento para ajuda. Tenho o maior prazer em ajudar." 512 | 513 | #~ msgid "Debugging Data" 514 | #~ msgstr "Dados de depuração" 515 | 516 | #~ msgid "Plugin Information" 517 | #~ msgstr "Informações do plugin" 518 | 519 | #~ msgid "Author" 520 | #~ msgstr "Autor" 521 | 522 | #~ msgid "Visit plugin website" 523 | #~ msgstr "Visite o site do plugin" 524 | 525 | #~ msgid "Plugin documentation" 526 | #~ msgstr "Documentação do plugin" 527 | 528 | #~ msgid "More details about the plugin" 529 | #~ msgstr "Mais detalhes sobre o plugin" 530 | 531 | #~ msgid "Need help?" 532 | #~ msgstr "Precisa de ajuda?" 533 | 534 | #~ msgid "Contact support" 535 | #~ msgstr "Contacte o suporte" 536 | 537 | #~ msgid "Disable UAN" 538 | #~ msgstr "Desactivar UAN" 539 | 540 | #~ msgid "Enable UAN" 541 | #~ msgstr "Activar UAN" 542 | 543 | #~ msgid "Log Manager Addon" 544 | #~ msgstr "Addon Log Manager" 545 | 546 | #~ msgid "" 547 | #~ "Error Log Manager addon is available for 404 to 301 now. Make 404 error " 548 | #~ "management more easy." 549 | #~ msgstr "" 550 | #~ "O addon Log Manager está agora disponível para o 404 to 301. Torne a " 551 | #~ "gestão de erros 404 mais fácil." 552 | 553 | #~ msgid "" 554 | #~ "Instead of email alerts on every error, get Hourly, Daily, Twice a day, " 555 | #~ "Weekly, Twice a week email alerts." 556 | #~ msgstr "" 557 | #~ "Em vez de emails de alerta por cada erro, receba emails de alerta a cada " 558 | #~ "hora, uma a duas vezes por dia, ou uma a duas vezes por semana." 559 | 560 | #~ msgid "Automatically clear old error logs after few days to reduce db load." 561 | #~ msgstr "" 562 | #~ "Limpeza automática de registos de erros antigos após alguns dias, para " 563 | #~ "reduzir o peso da base de dados." 564 | 565 | #~ msgid "See More Details" 566 | #~ msgstr "Ver mais detalhes" 567 | 568 | #~ msgid "Like the plugin" 569 | #~ msgstr "Gosta do plugin" 570 | 571 | #~ msgid "Rate now" 572 | #~ msgstr "Classificar agora" 573 | 574 | #~ msgid "Rate this on WordPress" 575 | #~ msgstr "Dê uma classificação no WordPress" 576 | 577 | #~ msgid "Donate now" 578 | #~ msgstr "Fazer donativo agora" 579 | 580 | #~ msgid "Make a small donation" 581 | #~ msgstr "Faça um pequeno donativo" 582 | 583 | #~ msgid "Contribute now" 584 | #~ msgstr "Contribuir agora" 585 | 586 | #~ msgid "Contribute to the Plugin" 587 | #~ msgstr "Contribua para o plugin" 588 | 589 | #~ msgid "Tweet now" 590 | #~ msgstr "Publicar no Twitter agora" 591 | 592 | #~ msgid "Tweet about the Plugin" 593 | #~ msgstr "Publique no Twitter sobre o plugin" 594 | 595 | #~ msgid "" 596 | #~ "Enter the url if you want to set custom redirect for above 404 path. " 597 | #~ "Enter the full url including http://. Leave empty if you want to follow " 598 | #~ "deafult settings" 599 | #~ msgstr "" 600 | #~ "Insira o URL pretendido para o redireccionamento personalizado do caminho " 601 | #~ "404 acima. Insira o caminho completo do URL incluindo http://. Deixe em " 602 | #~ "branco para utilizar as definições por omissão." 603 | 604 | #~ msgid "settings updated successfully" 605 | #~ msgstr "definições actualizadas com sucesso" 606 | 607 | #~ msgid "General" 608 | #~ msgstr "Geral" 609 | 610 | #~ msgid "Help & Info" 611 | #~ msgstr "Ajuda e informações" 612 | 613 | #~ msgid "Redirect (SEO)" 614 | #~ msgstr "Redireccionamento (SEO)" 615 | 616 | #~ msgid "" 617 | #~ "The default 404 page will be replaced by the page you choose in this list" 618 | #~ msgstr "" 619 | #~ "A página 404 por omissão será substituída por uma página à escolha desta " 620 | #~ "lista" 621 | 622 | #~ msgid "Enter any url" 623 | #~ msgstr "Insira qualquer URL" 624 | 625 | #~ msgid "including" 626 | #~ msgstr "incluindo" 627 | 628 | #~ msgid "Enable Error Logs" 629 | #~ msgstr "Activar registos de erros" 630 | 631 | #~ msgid "Disable Error Logs" 632 | #~ msgstr "Desactivar registos de erros" 633 | 634 | #~ msgid "" 635 | #~ "If you check this, an email will be sent on every 404 log on the admin " 636 | #~ "email account" 637 | #~ msgstr "" 638 | #~ "Se activar esta opção, será enviado um email a cada registo de 404 para o " 639 | #~ "email do administrador" 640 | 641 | #~ msgid "Change the recipient email address for error log notifications" 642 | #~ msgstr "" 643 | #~ "Modifique o endereço de email do destinatário para as notificações de " 644 | #~ "registo de erro" 645 | 646 | #~ msgid "Save All Changes" 647 | #~ msgstr "Guardar todas as alterações" 648 | 649 | #~ msgid "https://thefoxe.com/products/404-to-301/" 650 | #~ msgstr "https://thefoxe.com/products/404-to-301/" 651 | 652 | #~ msgid "" 653 | #~ "Automatically redirect all 404 errors to any page using " 654 | #~ "301 redirect for SEO. You can redirect and log every 404 errors. No more 404 errors in Webmaster tool." 656 | #~ msgstr "" 657 | #~ "Redireccione automaticamente todos os erros 404 para " 658 | #~ "qualquer página através de redireccionamento 301 para SEO. Pode redireccionar e registar todos os erros " 660 | #~ "404. Ponha fim aos erros 404 na sua ferramenta de Webmaster." 661 | 662 | #~ msgid "Joel James" 663 | #~ msgstr "Joel James" 664 | 665 | #~ msgid "https://thefoxe.com/" 666 | #~ msgstr "https://thefoxe.com/" 667 | -------------------------------------------------------------------------------- /includes/admin/class-jj4t3-log-listing.php: -------------------------------------------------------------------------------- 1 | 19 | * @license http://www.gnu.org/licenses/ GNU General Public License 20 | * @category Core 21 | * @link https://duckdev.com/products/404-to-301/ 22 | * @package JJ4T3 23 | * @subpackage ErrorLogListing 24 | */ 25 | class JJ4T3_Log_Listing extends WP_List_Table { 26 | 27 | /** 28 | * Group by column name. 29 | * 30 | * @var string 31 | * @since 3.0.0 32 | * @access private 33 | */ 34 | private $group_by = ''; 35 | 36 | /** 37 | * Initialize the class and set properties. 38 | * 39 | * @since 3.0.0 40 | * @access public 41 | */ 42 | public function __construct() { 43 | parent::__construct( 44 | array( 45 | 'singular' => __( '404 Error Log', '404-to-301' ), 46 | 'plural' => __( '404 Error Logs', '404-to-301' ), 47 | 'ajax' => false, 48 | ) 49 | ); 50 | } 51 | 52 | /** 53 | * Prepare listing table using WP_List_Table class. 54 | * 55 | * As name says, this function is used to prepare the lsting table based 56 | * on the custom rules and filters that we have given. 57 | * This function extends the lsiting table class and uses our custom data 58 | * to list in the table. 59 | * Here we set pagination, columns, sorting etc. 60 | * $this->items - Push our custom log data to the listing table. 61 | * Registering filter - "jj4t3_logs_list_per_page". 62 | * 63 | * @since 2.0.0 64 | * @access public 65 | * @global object $wpdb WP DB object 66 | */ 67 | public function prepare_items() { 68 | $this->_column_headers = $this->get_column_info(); 69 | 70 | // Execute bulk actions. 71 | $actions = $this->process_actions(); 72 | 73 | // Redirect after actions, or after securoty check. 74 | $this->safe_redirect( $actions ); 75 | 76 | // Set group by column. 77 | $this->set_groupby(); 78 | 79 | /** 80 | * Filter to alter no. of items per page. 81 | * 82 | * Change no. of items listed on a page. This value can be changed from 83 | * error listing page screen options. 84 | * 85 | * @since 2.0.0 86 | */ 87 | $per_page = apply_filters( 'jj4t3_logs_list_per_page', $this->get_items_per_page( 'logs_per_page', 20 ) ); 88 | 89 | // Current page number. 90 | $page_number = $this->get_pagenum(); 91 | 92 | // Total error logs. 93 | $total_items = $this->total_logs(); 94 | 95 | // Set pagination. 96 | $this->set_pagination_args( 97 | array( 98 | 'total_items' => $total_items, 99 | 'per_page' => $per_page, 100 | ) 101 | ); 102 | 103 | // Set error logs data for the current page. 104 | $this->items = $this->get_error_logs( $per_page, $page_number ); 105 | } 106 | 107 | /** 108 | * Get error logs data. 109 | * 110 | * Get error logs data from our custom database table. 111 | * Apply all filtering, sorting and paginations. 112 | * Registering filter - "jj4t3_logs_list_result". 113 | * 114 | * @param int $per_page Logs per page. 115 | * @param int $page_number Current page number. 116 | * 117 | * @since 3.0.0 118 | * @access public 119 | * 120 | * @global object $wpdb WP DB object 121 | * @return array 122 | */ 123 | private function get_error_logs( $per_page = 20, $page_number = 1 ) { 124 | global $wpdb; 125 | 126 | // Current offset. 127 | $offset = ( $page_number - 1 ) * $per_page; 128 | 129 | // Sort by column. 130 | $orderby = $this->get_order_by(); 131 | 132 | // Set group b query, if set. 133 | $groupby_query = empty( $this->group_by ) ? '' : ' GROUP BY ' . $this->group_by; 134 | // Get count of grouped items. 135 | $count = empty( $this->group_by ) ? '' : ', COUNT(id) as count '; 136 | 137 | // Sort order. 138 | $order = $this->get_order(); 139 | 140 | // Get error logs. 141 | $result = $wpdb->get_results( 142 | $wpdb->prepare( 143 | "SELECT *{$count} FROM " . JJ4T3_TABLE . " WHERE status != 0 $groupby_query ORDER BY $orderby $order LIMIT %d OFFSET %d", 144 | array( $per_page, $offset ) ), 145 | 'ARRAY_A' 146 | ); 147 | 148 | /** 149 | * Filter to alter the error logs listing data result. 150 | * 151 | * BE CAREFUL when you use this filter. If you alter the structure 152 | * the entire listing table may get affected. 153 | * 154 | * @since 2.0.0 155 | */ 156 | return apply_filters( 'jj4t3_logs_list_result', $result ); 157 | } 158 | 159 | /** 160 | * Get sort by column name. 161 | * 162 | * This is used to filter the sorting parameters in order 163 | * to prevent SQL injection atacks. We will accept only our 164 | * required values. Else we will assign a default value. 165 | * Registering filter - "jj4t3_log_list_orderby". 166 | * 167 | * @since 2.0.3 168 | * @access public 169 | * @uses esc_sql() To escape string for SQL. 170 | * 171 | * @return string Filtered column name. 172 | */ 173 | private function get_order_by() { 174 | /** 175 | * Filter to alter the log listing orderby param. 176 | * 177 | * Only accepted, valid column name will be accepted. 178 | * 179 | * @since 2.0.0 180 | */ 181 | $orderby = apply_filters( 'jj4t3_log_list_orderby', jj4t3_from_request( 'orderby', 'date' ) ); 182 | 183 | /** 184 | * Filter to alter the allowed order by values. 185 | * 186 | * Only these columns will be allowed. It is a security 187 | * measure too. 188 | * 189 | * @param array array of allowed column names. 190 | * 191 | * @since 2.0.0 192 | */ 193 | $allowed_columns = apply_filters( 'jj4t3_log_list_orderby_allowed', array( 'date', 'url', 'ref', 'ip' ) ); 194 | 195 | // Make sure only valid columns are considered. 196 | $allowed_columns = array_intersect( $allowed_columns, array_keys( jj4t3_log_columns() ) ); 197 | 198 | // Check if given column is allowed. 199 | if ( in_array( $orderby, $allowed_columns, true ) ) { 200 | return sanitize_sql_orderby( $orderby ); 201 | } 202 | 203 | return 'date'; 204 | } 205 | 206 | /** 207 | * Filter the sorting parameters. 208 | * 209 | * This is used to filter the sorting parameters in order 210 | * to prevent SQL injection atacks. We will accept only our 211 | * required values. Else we will assign a default value. 212 | * Registering filter - "jj4t3_log_list_order". 213 | * 214 | * @since 2.0.3 215 | * @access private 216 | * 217 | * @return string Filtered column name. 218 | */ 219 | private function get_order() { 220 | // Get order column name from request. 221 | $order = jj4t3_from_request( 'order', 'DESC' ) === 'asc' ? 'ASC' : 'DESC'; 222 | 223 | /** 224 | * Filter to alter the log listing order param. 225 | * 226 | * Only ASC and DESC will be accepted. 227 | * 228 | * @since 2.0.0 229 | */ 230 | return apply_filters( 'jj4t3_log_list_order', $order ); 231 | } 232 | 233 | /** 234 | * Set gropuby value for grouping results. 235 | * 236 | * Groupby filter to avoid duplicate values in error log 237 | * listing table. If a groupby column is set, it will show 238 | * the count along with the logs. 239 | * Registering filter - "jj4t3_log_list_groupby_allowed". 240 | * Registering filter - "jj4t3_log_list_groupby". 241 | * 242 | * @since 3.0.0 243 | * @access private 244 | */ 245 | private function set_groupby() { 246 | /** 247 | * Filter to alter the allowed group by values. 248 | * 249 | * Only these columns will be allowed. It is a security 250 | * measure too. 251 | * 252 | * @param array array of allowed column names. 253 | * 254 | * @since 2.0.0 255 | */ 256 | $allowed_values = apply_filters( 'jj4t3_log_list_groupby_allowed', array( 'url', 'ref', 'ip', 'ua' ) ); 257 | 258 | // Make sure only valid columns are considered. 259 | $allowed_values = array_intersect( $allowed_values, array_keys( jj4t3_log_columns() ) ); 260 | 261 | // Get group by value from request. 262 | $group_by = jj4t3_from_request( 'group_by_top', '' ); 263 | 264 | /** 265 | * Filter to alter the log listing groupby param. 266 | * 267 | * Only allowed column names are accepted. 268 | * 269 | * @since 2.0.0 270 | */ 271 | $group_by = apply_filters( 'jj4t3_log_list_groupby', $group_by ); 272 | 273 | // Verify if the group by value is allowed. 274 | if ( ! in_array( $group_by, $allowed_values, true ) ) { 275 | return; 276 | } 277 | 278 | $this->group_by = $group_by; 279 | } 280 | 281 | /** 282 | * Get the count of total logs in table. 283 | * 284 | * Since we are using a custom table for data in 285 | * listing, we need to get count of total items for proper pagination. 286 | * Registering filter - "jj4t3_log_list_count". 287 | * 288 | * @since 2.0.3 289 | * @access private 290 | * 291 | * @global object $wpdb WP DB object 292 | * @return int Total count. 293 | */ 294 | private function total_logs() { 295 | global $wpdb; 296 | 297 | if ( empty( $this->group_by ) ) { 298 | $total = $wpdb->get_var( "SELECT COUNT(id) FROM " . JJ4T3_TABLE ); 299 | } else { 300 | $total = $wpdb->get_var( "SELECT COUNT(DISTINCT " . $this->group_by . ") FROM " . JJ4T3_TABLE ); 301 | } 302 | 303 | /** 304 | * Filter to alter total logs count. 305 | * 306 | * You MAY NOT have to use this filter. 307 | * 308 | * @since 2.0.0 309 | */ 310 | return apply_filters( 'jj4t3_log_list_count', $total ); 311 | } 312 | 313 | /** 314 | * Listing table column titles. 315 | * 316 | * Custom column titles to be displayed in listing table. 317 | * Registering filter - "jj4t3_log_list_column_names". 318 | * 319 | * @since 2.0.0 320 | * @access public 321 | * 322 | * @return array $columns Array of column titles. 323 | */ 324 | public function get_columns() { 325 | $columns = array( 326 | 'cb' => '', 327 | 'date' => __( 'Date', '404-to-301' ), 328 | 'url' => __( '404 Path', '404-to-301' ), 329 | 'ref' => __( 'From', '404-to-301' ), 330 | 'ip' => __( 'IP Address', '404-to-301' ), 331 | 'ua' => __( 'User Agent', '404-to-301' ), 332 | 'redirect' => __( 'Customization', '404-to-301' ), 333 | ); 334 | 335 | /** 336 | * Filter hook to change column titles. 337 | * 338 | * If you are adding custom columns, remember to add 339 | * those to "jj4t3_log_list_column_default" filter too. 340 | * 341 | * @since 3.0.0 342 | */ 343 | return apply_filters( 'jj4t3_log_list_column_names', $columns ); 344 | } 345 | 346 | /** 347 | * Make columns sortable. 348 | * 349 | * To make our custom columns in list table sortable. 350 | * Do not enable sorting for redirect and ua columns. 351 | * Registering filter - "jj4t3_log_list_sortable_columns". 352 | * 353 | * @since 2.0.0 354 | * @access protected 355 | * 356 | * @return array Array of columns to enable sorting. 357 | */ 358 | protected function get_sortable_columns() { 359 | $columns = array( 360 | 'date' => array( 'date', true ), 361 | 'url' => array( 'url', false ), 362 | 'ref' => array( 'ref', false ), 363 | 'ip' => array( 'ip', false ), 364 | ); 365 | 366 | /** 367 | * Filter hook to change column titles. 368 | * 369 | * @note DO NOT add extra columns. 370 | * 371 | * @since 3.0.0 372 | */ 373 | return apply_filters( 'jj4t3_log_list_sortable_columns', $columns ); 374 | } 375 | 376 | /** 377 | * Message to be displayed when there are no items. 378 | * 379 | * If there are no errors logged yet, show custom error message 380 | * instead of default one. 381 | * Registering filter - "jj4t3_log_list_no_items_message". 382 | * 383 | * @since 2.0.0 384 | * @access public 385 | * 386 | * @return void 387 | */ 388 | public function no_items() { 389 | $message = __( 'Ah! You are so clean that you still got ZERO errors.', '404-to-301' ); 390 | 391 | $message = apply_filters( 'jj4t3_log_list_no_items_message', $message ); 392 | 393 | /** 394 | * Filter hook to change no items message. 395 | * 396 | * @since 3.0.0 397 | */ 398 | echo esc_html( $message ); 399 | } 400 | 401 | /** 402 | * Default columns in list table. 403 | * 404 | * To show columns in error log list table. If there is nothing 405 | * for switch, printing the whole array. 406 | * Registering filter - "jj4t3_log_list_column_default". 407 | * 408 | * @param array $item Column data. 409 | * @param string $column_name Column name. 410 | * 411 | * @since 2.0.0 412 | * @access protected 413 | * 414 | * @return string 415 | */ 416 | protected function column_default( $item, $column_name ) { 417 | $columns = array_keys( jj4t3_log_columns() ); 418 | 419 | /** 420 | * Filter hook to change column names. 421 | * 422 | * @note DO NOT add extra columns. 423 | * 424 | * @since 3.0.0 425 | */ 426 | $columns = apply_filters( 'jj4t3_log_list_column_default', $columns ); 427 | 428 | // If current column is allowed. 429 | if ( in_array( $column_name, $columns, true ) ) { 430 | return $item[ $column_name ]; 431 | } 432 | 433 | return ''; 434 | } 435 | 436 | /** 437 | * To output checkbox for bulk actions. 438 | * 439 | * This function is used to add new checkbox for all entries in 440 | * the listing table. We use this checkbox to perform bulk actions. 441 | * 442 | * @param array $item Column data. 443 | * 444 | * @since 2.1.0 445 | * @access public 446 | * 447 | * @return string 448 | */ 449 | public function column_cb( $item ) { 450 | return sprintf( '', $item['id'] ); 451 | } 452 | 453 | /** 454 | * Date column content. 455 | * 456 | * This function is used to modify the column data for date in listing table. 457 | * We can change styles, texts etc. using this function. 458 | * Registering filter - "jj4t3_log_list_date_column". 459 | * 460 | * @param array $item Column data. 461 | * 462 | * @since 2.0.0 463 | * @access public 464 | * 465 | * @return string 466 | */ 467 | public function column_date( $item ) { 468 | $delete_nonce = wp_create_nonce( 'bulk-' . $this->_args['plural'] ); 469 | 470 | $title = mysql2date( 'j M Y, g:i a', $item['date'] ); 471 | 472 | $confirm = __( 'Are you sure you want to delete this item?', '404-to-301' ); 473 | 474 | $actions = array( 'delete' => sprintf( '' . __( 'Delete', '404-to-301' ) . '', 'delete', absint( $item['id'] ), $delete_nonce, $confirm ) ); 475 | 476 | /** 477 | * Filter to change date colum html content. 478 | * 479 | * @since 3.0.0 480 | */ 481 | return apply_filters( 'jj4t3_log_list_date_column', $title . $this->row_actions( $actions ) ); 482 | } 483 | 484 | /** 485 | * URL column content. 486 | * 487 | * This function is used to modify the column data for url in listing table. 488 | * We can change styles, texts etc. using this function. 489 | * Registering filter - "jj4t3_log_list_url_column". 490 | * 491 | * @param array $item Column data. 492 | * 493 | * @since 2.0.0 494 | * @access public 495 | * 496 | * @return string URL column html content 497 | */ 498 | public function column_url( $item ) { 499 | // Get default text if empty value. 500 | $url = $this->get_empty_content( $item['url'] ); 501 | if ( ! $url ) { 502 | $url = '' . esc_url( $item['url'] ) . ''; 503 | } 504 | 505 | /** 506 | * Filter to change url colum content. 507 | * 508 | * Remember this filter value is a partial url field. 509 | * 510 | * @since 3.0.0 511 | */ 512 | return apply_filters( 'jj4t3_log_list_url_column', $this->get_group_content( $url, 'url', $item ) ); 513 | } 514 | 515 | /** 516 | * Referer column content. 517 | * 518 | * This function is used to modify the column data for ref in listing table. 519 | * We can change styles, texts etc. using this function. 520 | * Registering filter - "jj4t3_log_list_ref_column". 521 | * 522 | * @param array $item Column data. 523 | * 524 | * @since 2.0.0 525 | * @access public 526 | * 527 | * @return string Ref column html content. 528 | */ 529 | public function column_ref( $item ) { 530 | // Get default text if empty value. 531 | $ref = $this->get_empty_content( $item['ref'] ); 532 | if ( ! $ref ) { 533 | $ref = '' . esc_url( $item['ref'] ) . ''; 534 | } 535 | 536 | /** 537 | * Filter to change referer url colum content. 538 | * 539 | * @since 3.0.0 540 | */ 541 | return apply_filters( 'jj4t3_log_list_ref_column', $this->get_group_content( $ref, 'ref', $item ) ); 542 | } 543 | 544 | /** 545 | * User agent column content. 546 | * 547 | * This function is used to modify the column data for user agent in listing table. 548 | * We can change styles, texts etc. using this function. 549 | * Registering filter - "jj4t3_log_list_ua_column". 550 | * 551 | * @param array $item Column data. 552 | * 553 | * @since 2.0.9 554 | * @access public 555 | * 556 | * @return string User Agent column html content 557 | */ 558 | public function column_ua( $item ) { 559 | // Sanitize text content. 560 | $ua = sanitize_text_field( $item['ua'] ); 561 | 562 | /** 563 | * Filter to change user agent colum content. 564 | * 565 | * @since 3.0.0 566 | */ 567 | return apply_filters( 'jj4t3_log_list_ua_column', $this->get_group_content( $ua, 'ua', $item ) ); 568 | } 569 | 570 | /** 571 | * IP column content. 572 | * 573 | * This function is used to modify the column data for ip in listing table. 574 | * We can change styles, texts etc. using this function. 575 | * Registering filter - "jj4t3_log_list_ip_column". 576 | * 577 | * @param array $item Column data. 578 | * 579 | * @since 2.0.9 580 | * @access public 581 | * 582 | * @return string IP column html content. 583 | */ 584 | public function column_ip( $item ) { 585 | // Get default text if empty value. 586 | $ip = $this->get_empty_content( $item['ip'] ); 587 | if ( ! $ip ) { 588 | $ip = sanitize_text_field( $item['ip'] ); 589 | } 590 | 591 | /** 592 | * Filter to change IP colum content. 593 | * 594 | * @since 3.0.0 595 | */ 596 | return apply_filters( 'jj4t3_log_list_ip_column', $this->get_group_content( $ip, 'ip', $item ) ); 597 | } 598 | 599 | /** 600 | * Custom redirect column content. 601 | * 602 | * This function is used to modify the column data for custom redirect in listing table. 603 | * 604 | * @param array $item Column data. 605 | * 606 | * @since 2.0.9 607 | * @access public 608 | * 609 | * @return string HTML content for redirect column. 610 | */ 611 | public function column_redirect( $item ) { 612 | // Link for redirect. 613 | $link = esc_url( $item['redirect'] ); 614 | 615 | // Get default text if empty value. 616 | $title = empty( $link ) ? __( 'Default', '404-to-301' ) : $link; 617 | 618 | $redirect = '' . $title . ''; 619 | 620 | return $redirect; 621 | } 622 | 623 | /** 624 | * Get default text if empty. 625 | * 626 | * Get an error text with custom class to show if the 627 | * current column value is empty or n/a. 628 | * 629 | * @param string $content Content to display. 630 | * @param string $column Column name. 631 | * @param array $item Items array. 632 | * 633 | * @since 3.0.0 634 | * @access private 635 | * 636 | * @return string 637 | */ 638 | private function get_group_content( $content, $column, $item ) { 639 | $count_text = ''; 640 | // Check if current column name is grouped. 641 | // Add count text then. 642 | if ( ! empty( $item['count'] ) && $item['count'] > 1 && $column === $this->group_by ) { 643 | $count_text = " (" . $item['count'] . ")"; 644 | } 645 | 646 | return '

' . $content . $count_text . '

'; 647 | } 648 | 649 | /** 650 | * Get default text if empty. 651 | * 652 | * Get an error text with custom class to show if the 653 | * current column value is empty or n/a. 654 | * 655 | * @param string $value Field value. 656 | * 657 | * @since 3.0.0 658 | * @access private 659 | * 660 | * @return string|boolean 661 | */ 662 | private function get_empty_content( $value ) { 663 | // Get default error text. 664 | if ( strtolower( $value ) === 'n/a' || empty( $value ) ) { 665 | return 'n/a'; 666 | } 667 | 668 | return false; 669 | } 670 | 671 | /** 672 | * Bulk actions drop down. 673 | * 674 | * Options to be added to the bulk actions drop down for users 675 | * to select. We have added 'Delete' actions. 676 | * Registering filter - "jj4t3_log_list_bulk_actions". 677 | * 678 | * @since 2.0.0 679 | * @access public 680 | * 681 | * @return array $actions Options to be added to the action select box. 682 | */ 683 | public function get_bulk_actions() { 684 | $actions = array( 685 | 'bulk_delete' => __( 'Delete Selected', '404-to-301' ), 686 | 'bulk_clean' => __( 'Delete All', '404-to-301' ), 687 | 'bulk_delete_all' => __( 'Delete All (Keep redirects)', '404-to-301' ), 688 | ); 689 | 690 | /** 691 | * Filter hook to change actions. 692 | * 693 | * @note If you are adding extra actions 694 | * Make sure it's actions are properly added. 695 | * 696 | * @since 3.0.0 697 | */ 698 | return apply_filters( 'jj4t3_log_list_bulk_actions', $actions ); 699 | } 700 | 701 | /** 702 | * Add extra action dropdown for grouping the error logs. 703 | * 704 | * @param string $which Top or Bottom. 705 | * 706 | * @access protected 707 | * @since 3.0.0 708 | * 709 | * @return void 710 | */ 711 | public function extra_tablenav( $which ) { 712 | if ( $this->has_items() && 'top' === $which ) { 713 | 714 | // This filter is already documented above. 715 | $allowed_values = apply_filters( 'jj4t3_log_list_groupby_allowed', array( 'url', 'ref', 'ip', 'ua' ) ); 716 | // Allowed/available columns. 717 | $available_columns = jj4t3_log_columns(); 718 | // Consider only available columns. 719 | $column_names = array_intersect( $allowed_values, array_keys( $available_columns ) ); 720 | // Add dropdown. 721 | echo '
'; 722 | echo ''; 728 | submit_button( __( 'Apply', '404-to-301' ), 'button', 'filter_action', false, array( 'id' => 'post-query' ) ); 729 | echo '
'; 730 | 731 | /** 732 | * Action hook to add extra items in actions area. 733 | * 734 | * @param object $this Class instance. 735 | * @param string $which Current location (top or bottom). 736 | */ 737 | do_action( 'jj4t3_log_list_extra_tablenav', $this, $which ); 738 | } 739 | } 740 | 741 | /** 742 | * To perform bulk actions. 743 | * 744 | * After security check, perform bulk actions selected by 745 | * the user. Only allowed actions will be performed. 746 | * 747 | * @since 2.1.0 748 | * @access private 749 | * @uses check_admin_referer() For security check. 750 | * 751 | * @return bool 752 | */ 753 | private function process_actions() { 754 | // Get current action. 755 | $action = $this->current_action(); 756 | 757 | // Get allowed actions array. 758 | $allowed_actions = array_keys( $this->get_bulk_actions() ); 759 | 760 | // Verify only allowed actions are passed. 761 | if ( ! in_array( $action, $allowed_actions, true ) && 'delete' !== $action ) { 762 | return false; 763 | } 764 | 765 | $nonce = jj4t3_from_request( '_wpnonce' ); 766 | 767 | // Nonce verification. 768 | if ( empty( $nonce ) || ! wp_verify_nonce( $nonce, 'bulk-' . $this->_args['plural'] ) ) { 769 | return false; 770 | } 771 | 772 | // IDs of log entries to process. 773 | $ids = jj4t3_from_request( 'bulk-delete', true ); 774 | 775 | // Run custom bulk actions. 776 | // Add other custom actions in switch.. 777 | switch ( $action ) { 778 | // Normal selected deletes. 779 | case 'delete': 780 | case 'bulk_delete': 781 | case 'bulk_clean': 782 | case 'bulk_delete_all': 783 | $this->delete_logs( $ids, $action ); 784 | break; 785 | // Add custom actions here. 786 | } 787 | 788 | return true; 789 | } 790 | 791 | /** 792 | * Remove sensitive values from the URL. 793 | * 794 | * If WordPress nonce or admin referrer is found in url 795 | * remove that and redirect to same page. 796 | * 797 | * @param boolean $action_performed If any actions performed. 798 | * 799 | * @access private 800 | * @since 3.0.0 801 | * 802 | * @return void 803 | */ 804 | private function safe_redirect( $action_performed = false ) { 805 | // If sensitive data found, remove those and redirect. 806 | if ( ! empty( $_GET['_wp_http_referer'] ) || ! empty( $_GET['_wpnonce'] ) || $action_performed ) { 807 | $strings = array( '_wp_http_referer', '_wpnonce' ); 808 | // Remove processed actions. 809 | if ( $action_performed ) { 810 | $strings[] = 'action'; 811 | $strings[] = 'action2'; 812 | } 813 | // Remove params. 814 | $url = remove_query_arg( $strings ); 815 | wp_redirect( $url ); 816 | exit(); 817 | } 818 | } 819 | 820 | /** 821 | * Delete error logs. 822 | * 823 | * Bulk action processor to delete error logs according to 824 | * the user selection. We are using IF ELSE loop instead of 825 | * switch to easily handle conditions. 826 | * 827 | * @param mixed $ids ID(s) of the log(s). 828 | * @param string $action Current bulk action. 829 | * 830 | * @since 2.0.0 831 | * @access private 832 | * 833 | * @return void 834 | */ 835 | private function delete_logs( $ids, $action ) { 836 | global $wpdb; 837 | 838 | if ( is_numeric( $ids ) && 'delete' === $action ) { 839 | // If a single log is being deleted. 840 | $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id = " . absint( $ids ); 841 | } elseif ( is_array( $ids ) && 'bulk_delete' === $action ) { 842 | // If multiple selected logs are being deleted. 843 | $ids = implode( ',', array_map( 'absint', $ids ) ); 844 | $query = "DELETE FROM " . JJ4T3_TABLE . " WHERE id IN($ids)"; 845 | } elseif ( 'bulk_delete_all' === $action ) { 846 | // If deleting all logs except custom redirected ones. 847 | // Delete the duplicate entries from custom redirects. 848 | $query = "DELETE t1 FROM " . JJ4T3_TABLE . " t1, " . JJ4T3_TABLE . " t2 WHERE (t1.id < t2.id AND t1.url = t2.url) OR t1.redirect IS NULL OR t1.redirect = ''"; 849 | } elseif ( 'bulk_clean' === $action ) { 850 | // If deleting all logs. 851 | $query = "DELETE FROM " . JJ4T3_TABLE; 852 | } else { 853 | // Incase if invalid log ids. 854 | return; 855 | } 856 | 857 | // Run query to delete logs. 858 | $wpdb->query( $query ); 859 | } 860 | 861 | /** 862 | * Set screen options of error log listing. 863 | * 864 | * @param string $status Status. 865 | * @param string $option Option name. 866 | * @param mixed $value Value of the option. 867 | * 868 | * @since 2.1.0 869 | * @access public 870 | * 871 | * @return string 872 | */ 873 | public static function set_screen( $status, $option, $value ) { 874 | return $value; 875 | } 876 | 877 | /** 878 | * Get custom redirect modal content 879 | * 880 | * @since 2.2.0 881 | * @access public 882 | * 883 | * @global object $wpdb WP DB object 884 | * @return void 885 | */ 886 | public static function open_redirect() { 887 | // Yes, security check is a must when you alter something. 888 | check_ajax_referer( 'jj4t3_redirect_nonce', 'nonce' ); 889 | 890 | // The user should have the capability. 891 | if ( ! current_user_can( JJ4T3_ACCESS ) ) { 892 | wp_die(); 893 | } 894 | 895 | // Verify if the 404 value is found. 896 | if ( empty( $_POST['url_404'] ) ) { 897 | wp_die(); 898 | } 899 | 900 | $url_404 = esc_url_raw( $_POST['url_404'] ); 901 | 902 | global $wpdb; 903 | 904 | // Get custom redirect value from db, if exist. 905 | $result = $wpdb->get_row( $wpdb->prepare( "SELECT redirect, options FROM " . JJ4T3_TABLE . " WHERE url = %s AND redirect IS NOT NULL LIMIT 0,1", $url_404 ), 'OBJECT' ); 906 | 907 | // Get custom redirect type and url. 908 | $url = empty( $result->redirect ) ? '' : esc_url_raw( $result->redirect ); 909 | 910 | // Get custom options. 911 | $options = empty( $result->options ) ? array() : maybe_unserialize( $result->options ); 912 | 913 | // Get result in an array. 914 | $data = array( 915 | 'url_404' => $url_404, 916 | 'url' => $url, 917 | ); 918 | 919 | // Set the custom options for the 404. 920 | $data['type'] = empty( $options['type'] ) ? jj4t3_get_option( 'redirect_type' ) : intval( $options['type'] ); 921 | $data['redirect'] = isset( $options['redirect'] ) ? intval( $options['redirect'] ) : - 1; 922 | $data['log'] = isset( $options['log'] ) ? intval( $options['log'] ) : - 1; 923 | $data['alert'] = isset( $options['alert'] ) ? intval( $options['alert'] ) : - 1; 924 | 925 | /** 926 | * Filter to alter custom redirect modal response array. 927 | * 928 | * You should return response in array. 929 | * 930 | * @since 3.0.0 931 | */ 932 | wp_send_json( apply_filters( 'jj4t3_log_list_custom_redirect_open', $data ) ); 933 | } 934 | 935 | /** 936 | * Save custom redirect value. 937 | * 938 | * When user set a custom redirect url for a 404 link, save the data 939 | * from modal by updating all error logs of the current 404 links. 940 | * 941 | * @since 2.2.0 942 | * @access public 943 | * 944 | * @note Always die() for wp_ajax 945 | * 946 | * @global object $wpdb WP DB object 947 | * @return void 948 | */ 949 | public static function save_redirect() { 950 | // Yes, security check is a must when you alter something. 951 | check_ajax_referer( 'jj4t3_redirect_nonce', 'jj4t3_redirect_nonce' ); 952 | 953 | // The user should have the capability. 954 | if ( ! current_user_can( JJ4T3_ACCESS ) ) { 955 | wp_die(); 956 | } 957 | 958 | // Custom options for the 404 path. 959 | $options = maybe_serialize( 960 | array( 961 | 'redirect' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_redirect' ) ), 962 | 'log' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_log' ) ), 963 | 'alert' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_alert' ) ), 964 | 'type' => intval( jj4t3_from_request( 'jj4t3_custom_redirect_type' ) ), 965 | ) 966 | ); 967 | 968 | // Get 404 url. 969 | $url = jj4t3_from_request( 'jj4t3_custom_redirect', false ) ? esc_url_raw( jj4t3_from_request( 'jj4t3_custom_redirect' ) ) : ''; 970 | 971 | global $wpdb; 972 | 973 | // Get custom redirect url. 974 | $url_404 = jj4t3_from_request( 'jj4t3_redirect_404', false ) ? esc_url_raw( jj4t3_from_request( 'jj4t3_redirect_404' ) ) : ''; 975 | 976 | /** 977 | * Action hook to run before updating a custom redirect. 978 | * 979 | * If you want to change the query or stop the update query, just wp_die() 980 | * after your custom function. 981 | * 982 | * @param string $url_404 404 link. 983 | * @param string $url Link to redirect. 984 | * 985 | * @since 3.0.0 986 | */ 987 | do_action( 'jj4t3_log_list_custom_redirect_save', $url_404, $url ); 988 | 989 | // Run update query and set custom redirect. 990 | $wpdb->query( $wpdb->prepare( "UPDATE " . JJ4T3_TABLE . " SET redirect = %s, options = %s WHERE url = %s", $url, $options, $url_404 ) ); 991 | 992 | // Die ajax request. 993 | wp_die(); 994 | } 995 | 996 | /** 997 | * This function displays the custom redirect modal html content 998 | * 999 | * @since 2.2.0 1000 | * @acess public 1001 | * 1002 | * @return void 1003 | */ 1004 | public static function get_redirect_content() { 1005 | if ( current_user_can( JJ4T3_ACCESS ) ) { 1006 | include_once JJ4T3_DIR . 'includes/admin/views/custom-redirect.php'; 1007 | } 1008 | } 1009 | } 1010 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------