Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Redirect to Latest Post
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
ETH Redirect to Latest Post
Commits
f555c2d0
Verified
Commit
f555c2d0
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
v0.2.2, handling sites with slug-only permalinks
parent
60650137
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
eth-redirect-to-latest.php
+12
-1
12 additions, 1 deletion
eth-redirect-to-latest.php
readme.txt
+5
-2
5 additions, 2 deletions
readme.txt
with
17 additions
and
3 deletions
eth-redirect-to-latest.php
+
12
−
1
View file @
f555c2d0
...
...
@@ -4,7 +4,7 @@ Plugin Name: ETH Redirect to Latest Post
Plugin URI: https://ethitter.com/plugins/
Description: Redirect a chosen slug to the whatever is currently the latest post
Author: Erick Hitter
Version: 0.2.
1
Version: 0.2.
2
Author URI: https://ethitter.com/
Text Domain: eth_redirect_to_latest_post
Domain Path: /languages/
...
...
@@ -90,7 +90,18 @@ class ETH_Redirect_To_Latest_Post {
* Redirect to the latest post any requests made to plugin's slug
*/
public
function
action_parse_request
(
$r
)
{
$should_intercept
=
false
;
// Check if request is for our slug
// The first condition catches permastructs that are more than just post slug, whereas the second catches for slug-only permalinks
if
(
isset
(
$r
->
query_vars
[
'pagename'
]
)
&&
$this
->
slug
===
$r
->
query_vars
[
'pagename'
]
)
{
$should_intercept
=
true
;
}
elseif
(
isset
(
$r
->
query_vars
[
'name'
]
)
&&
$this
->
slug
===
$r
->
query_vars
[
'name'
]
)
{
$should_intercept
=
true
;
}
// Handle redirection
if
(
$should_intercept
)
{
$latest
=
get_posts
(
array
(
'posts_per_page'
=>
1
,
'post_type'
=>
'post'
,
...
...
This diff is collapsed.
Click to expand it.
readme.txt
+
5
−
2
View file @
f555c2d0
...
...
@@ -3,8 +3,8 @@ Contributors: ethitter
Donate link: https://ethitter.com/donate/
Tags: latest, latest post, redirect, redirect latest, redirect post
Requires at least: 4.5
Tested up to: 4.
6
Stable tag: 0.2.
1
Tested up to: 4.
7
Stable tag: 0.2.
2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
...
...
@@ -22,6 +22,9 @@ Once activated, a given slug will redirect to whatever is the most recently-publ
== Changelog ==
= 0.2.2 =
* Handle sites using slug-only permalinks
= 0.2.1 =
* Correct Composer path error
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment