Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Simple Shortlinks
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
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 Simple Shortlinks
Commits
e40bfd71
Commit
e40bfd71
authored
9 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Introduce utility methods to reduce repetition
parent
35ddcd25
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Utility methods for supported post types and statuses
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
eth-simple-shortlinks.php
+18
-4
18 additions, 4 deletions
eth-simple-shortlinks.php
with
18 additions
and
4 deletions
eth-simple-shortlinks.php
+
18
−
4
View file @
e40bfd71
...
@@ -134,11 +134,11 @@ class ETH_Simple_Shortlinks {
...
@@ -134,11 +134,11 @@ class ETH_Simple_Shortlinks {
return
$shortlink
;
return
$shortlink
;
}
}
if
(
!
in_array
(
get_post_status
(
$id
),
$this
->
supported
_post_status
es
)
)
{
if
(
!
$this
->
is_supported_post_status
(
get
_post_status
(
$id
)
)
)
{
return
$shortlink
;
return
$shortlink
;
}
}
if
(
!
in_array
(
get_post_type
(
$id
),
$this
->
supported_post_type
s
)
)
{
if
(
!
$this
->
is_
supported_post_type
(
get_post_type
(
$id
)
)
)
{
return
$shortlink
;
return
$shortlink
;
}
}
...
@@ -150,7 +150,7 @@ class ETH_Simple_Shortlinks {
...
@@ -150,7 +150,7 @@ class ETH_Simple_Shortlinks {
*/
*/
public
function
add_admin_header_assets
()
{
public
function
add_admin_header_assets
()
{
global
$typenow
;
global
$typenow
;
if
(
!
in_array
(
$typenow
,
$this
->
supported_post_type
s
)
)
{
if
(
!
$this
->
is_
supported_post_type
(
$typenow
)
)
{
return
;
return
;
}
}
...
@@ -172,7 +172,7 @@ class ETH_Simple_Shortlinks {
...
@@ -172,7 +172,7 @@ class ETH_Simple_Shortlinks {
* Provide the shortlink in row actions for easy access
* Provide the shortlink in row actions for easy access
*/
*/
public
function
filter_row_actions
(
$actions
,
$post
)
{
public
function
filter_row_actions
(
$actions
,
$post
)
{
if
(
!
in_array
(
get_post_type
(
$post
)
,
$this
->
supported_post_
types
)
||
!
in_array
(
get_post_status
(
$post
)
,
$this
->
supported_post_statuses
)
)
{
if
(
!
$this
->
is_supported_post_type
(
get_post_type
(
$post
)
)
||
!
$this
->
is_
supported_post_
status
(
get_post_status
(
$post
)
)
)
{
return
$actions
;
return
$actions
;
}
}
...
@@ -181,6 +181,20 @@ class ETH_Simple_Shortlinks {
...
@@ -181,6 +181,20 @@ class ETH_Simple_Shortlinks {
return
$actions
;
return
$actions
;
}
}
/**
* Check if given post type is supported
*/
private
function
is_supported_post_type
(
$type
)
{
return
in_array
(
$type
,
$this
->
supported_post_types
);
}
/**
* Check if given post status is supported
*/
private
function
is_supported_post_status
(
$status
)
{
return
in_array
(
$status
,
$this
->
supported_post_statuses
);
}
/**
/**
* Utility method for building permlink
* Utility method for building permlink
*/
*/
...
...
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