Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
ETH Simple Shortlinks
Commits
ae511d2e
Commit
ae511d2e
authored
Mar 20, 2016
by
Erick Hitter
Browse files
Improve how shortlink popup is added for row actions, allowing it to work for non-JS too.
parent
b03129d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
eth-simple-shortlinks.php
View file @
ae511d2e
...
...
@@ -71,6 +71,7 @@ class ETH_Simple_Shortlinks {
// Shortlink
add_filter
(
'get_shortlink'
,
array
(
$this
,
'filter_get_shortlink'
),
10
,
2
);
add_action
(
'admin_head-edit.php'
,
array
(
$this
,
'add_admin_header_assets'
)
);
add_filter
(
'post_row_actions'
,
array
(
$this
,
'filter_row_actions'
),
10
,
2
);
add_filter
(
'page_row_actions'
,
array
(
$this
,
'filter_row_actions'
),
10
,
2
);
}
...
...
@@ -144,6 +145,29 @@ class ETH_Simple_Shortlinks {
return
$this
->
get_shortlink
(
$id
);
}
/**
* Header assets for shortlink in row actions
*/
public
function
add_admin_header_assets
()
{
global
$typenow
;
if
(
!
in_array
(
$typenow
,
$this
->
supported_post_types
)
)
{
return
;
}
?>
<script
type=
"text/javascript"
>
jQuery
(
document
)
.
ready
(
function
(
$
)
{
$
(
'
.row-actions .shortlink a
'
).
click
(
function
(
e
)
{
e
.
preventDefault
();
prompt
(
'
URL:
'
,
$
(
this
).
attr
(
'
href
'
)
);
}
);
}
);
</script>
<?php
}
/**
* Provide the shortlink in row actions for easy access
*/
...
...
@@ -152,7 +176,7 @@ class ETH_Simple_Shortlinks {
return
$actions
;
}
$actions
[
'shortlink'
]
=
'<a
style="cursor: pointer;" onclick="prompt( \'URL:\', \'
'
.
esc_js
(
$this
->
get_shortlink
(
$post
->
ID
)
)
.
'
\' );return false;
">Shortlink</a>'
;
$actions
[
'shortlink'
]
=
'<a
href="
'
.
esc_js
(
$this
->
get_shortlink
(
$post
->
ID
)
)
.
'">Shortlink</a>'
;
return
$actions
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment