Created
September 1, 2017 17:54
-
-
Save ozh/a0090f46569b50835520d95f9481d9fd to your computer and use it in GitHub Desktop.
YOURLS Plugin: delete all URLs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: RESET URLS | |
Plugin URI: http://yourls.org/ | |
Description: OMG | |
Version: 1.0 | |
Author: Ozh | |
Author URI: http://ozh.org/ | |
*/ | |
// Register our plugin admin page | |
yourls_add_action( 'plugins_loaded', 'ozh_yourls_resetall_add_page' ); | |
function ozh_yourls_resetall_add_page() { | |
yourls_register_plugin_page( 'reset', 'RESET!!', 'ozh_yourls_resetall_do_page' ); | |
// parameters: page slug, page title, and function that will display the page itself | |
} | |
// Display admin page | |
function ozh_yourls_resetall_do_page() { | |
// Check if a form was submitted | |
if( isset( $_POST['reset'] ) && $_POST['reset'] == 'yes' ) { | |
ozh_yourls_resetall_urls(); | |
} else { | |
echo <<<HTML | |
<h2>RESET DB</h2> | |
<p>DELETE ALL URLS??</p> | |
<form method="post"> | |
<input type="hidden" name="reset" value="yes" /> | |
<p><input type="submit" value="YES" /></p> | |
</form> | |
HTML; | |
} | |
} | |
// Update option in database | |
function ozh_yourls_resetall_urls() { | |
$sql = "TRUNCATE TABLE ". YOURLS_DB_TABLE_URL.";"; | |
global $ydb; | |
$ydb->query( $sql ); | |
echo "<p class='error'>ALL GONE OMG!!</p>"; | |
} |
I receive the following error when I try to activate this plugin:
'No plugin specified, or not a valid plugin'
Another plugins (like: Random Backgrounds, Random Keywords, ...) are activated successfully.
YOURLS Version: 1.7.2
I just removed the white spaces from directory name and the plugin is working now. Thanks.
Does this plugin works for 1.8.2 version? - thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Useful! Thanks.