Skip to content

Commit

Permalink
authMgrPlus integration
Browse files Browse the repository at this point in the history
  • Loading branch information
joshp23 committed Mar 13, 2021
1 parent dc9daf6 commit e03e2c1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ https://eg.com/yourls-api.php?refetch=true&action=shorturl&url=https://some.real
- `target=title-force` skips the malformed url check and just looks for an updated title. Requires `shorturl=EX`.
- `target=all` which will run a check on the entire database and requires a valid log in (eg. signature or user/pass)
3. There is an action button in the admin section to force-update single links at a a time.
Note: This button is filtered by [AuthMgrPlus](https://github.com/joshp23/YOURLS-AuthMgrPlus) with the `EditURL` capability, if installed.

#### The catch
While this doesn't cause the developers of third party applications to give attetnion to their code, it does make integration more flexible and provides an immediate working solution on YOURLS's end, akin to the [api-concurrence-fix](https://bitbucket.org/laceous/yourls-concurrency-fix) plugin.
Expand Down
41 changes: 31 additions & 10 deletions title-refetch/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Title Refetch
Plugin URI: https://github.com/joshp23/YOURLS-title-refetch
Description: Refetch poorly defined titles
Version: 1.3.0
Version: 1.4.0
Author: Josh Panter
Author URI: https://unfettered.net
*/
Expand All @@ -12,18 +12,39 @@
if( !defined( 'YOURLS_ABSPATH' ) ) die();

// Add a Refetch Button to the Admin interface
yourls_add_filter( 'action_links', 'title_refetch_admin_button' );
function title_refetch_admin_button( $action_links, $keyword, $url, $ip, $clicks, $timestamp ) {
yourls_add_filter( 'table_add_row_action_array', 'title_refetch_admin_button' );
function title_refetch_admin_button ( $actions, $keyword ) {

$id = yourls_string2htmlid( $keyword ); // used as HTML #id
$id = yourls_string2htmlid( $keyword );
$sig = yourls_auth_signature();
$home = YOURLS_SITE;
$jslink = "'$keyword','$sig','$id'";

// Add the Refetch button to the action links list
$action_links .= '<a href="javascript:void(0);" onclick="titleRefetch('. $jslink .');" id="trlink-'.$id.'" title="Title Refetch" class="button button_refetch">JS Refetch</a>';

return $action_links;
$refetch = array (
'refetch' => array(
'href' => "javascript:void(0);",
'id' => "trlink-$id",
'title' => yourls_esc_attr__( 'Title Refetch' ),
'anchor' => yourls__( 'JS Refetch' ),
'onclick' => "titleRefetch( $jslink );",
)
);
$result = array_merge( $actions, $refetch ); ;
return $result;
}
// Is authMgrPlus active?
yourls_add_action( 'plugins_loaded', 'title_refetch_amp_check' );
function title_refetch_amp_check() {
if( yourls_is_active_plugin( 'authMgrPlus/plugin.php' ) ) {
yourls_add_filter( 'amp_button_capability_map', 'title_refetch_button_cap' );
yourls_add_filter( 'amp_restricted_buttons', 'title_refetch_restricted' );
}
}
function title_refetch_button_cap ( $var ) {
$var += ['refetch' => ampCap::EditURL];
return $var;
}
function title_refetch_restricted ( $var ) {
$var += ['refetch'];
return $var;
}

// Add the js/CSS to <head>
Expand Down

0 comments on commit e03e2c1

Please sign in to comment.