Skip to content
Snippets Groups Projects

Row actions and utility functions

Merged Erick Hitter requested to merge develop into master
1 file
+ 25
1
Compare changes
  • Side-by-side
  • Inline
+ 25
1
@@ -71,6 +71,7 @@ class ETH_Simple_Shortlinks {
@@ -71,6 +71,7 @@ class ETH_Simple_Shortlinks {
// Shortlink
// Shortlink
add_filter( 'get_shortlink', array( $this, 'filter_get_shortlink' ), 10, 2 );
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( 'post_row_actions', array( $this, 'filter_row_actions' ), 10, 2 );
add_filter( 'page_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 {
@@ -144,6 +145,29 @@ class ETH_Simple_Shortlinks {
return $this->get_shortlink( $id );
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
* Provide the shortlink in row actions for easy access
*/
*/
@@ -152,7 +176,7 @@ class ETH_Simple_Shortlinks {
@@ -152,7 +176,7 @@ class ETH_Simple_Shortlinks {
return $actions;
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;
return $actions;
}
}
Loading