0.2.1, see readme.txt
This commit is contained in:
parent
2521b8dfca
commit
172504813f
2 changed files with 50 additions and 12 deletions
|
@ -4,7 +4,7 @@ Donate link: https://paypal.me/petermolnar/3
|
||||||
Tags: linkrot, archive, hyperlink, url
|
Tags: linkrot, archive, hyperlink, url
|
||||||
Requires at least: 3.0
|
Requires at least: 3.0
|
||||||
Tested up to: 4.4.1
|
Tested up to: 4.4.1
|
||||||
Stable tag: 0.2
|
Stable tag: 0.2.1
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
||||||
Required minimum PHP version: 5.3
|
Required minimum PHP version: 5.3
|
||||||
|
@ -36,6 +36,11 @@ Version numbering logic:
|
||||||
* every .B version indicates new features.
|
* every .B version indicates new features.
|
||||||
* every ..C indicates bugfixes for A.B version.
|
* every ..C indicates bugfixes for A.B version.
|
||||||
|
|
||||||
|
= 0.2.1 =
|
||||||
|
* 2016-03-01*
|
||||||
|
|
||||||
|
* better logging, added filter for urls
|
||||||
|
|
||||||
= 0.2 =
|
= 0.2 =
|
||||||
*2016-01-07*
|
*2016-01-07*
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
Plugin Name: wp-url2snapshot
|
Plugin Name: wp-url2snapshot
|
||||||
Plugin URI: https://github.com/petermolnar/wp-url2snapshot
|
Plugin URI: https://github.com/petermolnar/wp-url2snapshot
|
||||||
Description: reversible automatic short slug based on post pubdate epoch for WordPress
|
Description: reversible automatic short slug based on post pubdate epoch for WordPress
|
||||||
Version: 0.2
|
Version: 0.2.1
|
||||||
Author: Peter Molnar <hello@petermolnar.eu>
|
Author: Peter Molnar <hello@petermolnar.eu>
|
||||||
Author URI: http://petermolnar.eu/
|
Author URI: http://petermolnar.eu/
|
||||||
License: GPLv3
|
License: GPLv3
|
||||||
|
@ -119,6 +119,8 @@ class WP_URL2SNAPSHOT {
|
||||||
static::debug(" processing post #{$post->ID}");
|
static::debug(" processing post #{$post->ID}");
|
||||||
$content = static::get_the_content($post);
|
$content = static::get_the_content($post);
|
||||||
$urls = static::extract_urls($content);
|
$urls = static::extract_urls($content);
|
||||||
|
$urls = apply_filters ( 'wp_url2snapshot_urls', $urls, $post );
|
||||||
|
$urls = array_unique ( $urls );
|
||||||
foreach ($urls as $url) {
|
foreach ($urls as $url) {
|
||||||
$url = esc_url_raw($url);
|
$url = esc_url_raw($url);
|
||||||
|
|
||||||
|
@ -427,23 +429,54 @@ class WP_URL2SNAPSHOT {
|
||||||
*
|
*
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param int $level
|
* @param int $level
|
||||||
|
*
|
||||||
|
* @output log to syslog | wp_die on high level
|
||||||
|
* @return false on not taking action, true on log sent
|
||||||
*/
|
*/
|
||||||
public static function debug( $message, $level = LOG_NOTICE ) {
|
public static function debug( $message, $level = LOG_NOTICE ) {
|
||||||
|
if ( empty( $message ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( @is_array( $message ) || @is_object ( $message ) )
|
if ( @is_array( $message ) || @is_object ( $message ) )
|
||||||
$message = json_encode($message);
|
$message = json_encode($message);
|
||||||
|
|
||||||
|
$levels = array (
|
||||||
|
LOG_EMERG => 0, // system is unusable
|
||||||
|
LOG_ALERT => 1, // Alert action must be taken immediately
|
||||||
|
LOG_CRIT => 2, // Critical critical conditions
|
||||||
|
LOG_ERR => 3, // Error error conditions
|
||||||
|
LOG_WARNING => 4, // Warning warning conditions
|
||||||
|
LOG_NOTICE => 5, // Notice normal but significant condition
|
||||||
|
LOG_INFO => 6, // Informational informational messages
|
||||||
|
LOG_DEBUG => 7, // Debug debug-level messages
|
||||||
|
);
|
||||||
|
|
||||||
switch ( $level ) {
|
// number for number based comparison
|
||||||
case LOG_ERR :
|
// should work with the defines only, this is just a make-it-sure step
|
||||||
wp_die( '<h1>Error:</h1>' . '<p>' . $message . '</p>' );
|
$level_ = $levels [ $level ];
|
||||||
exit;
|
|
||||||
default:
|
// in case WordPress debug log has a minimum level
|
||||||
if ( !defined( 'WP_DEBUG' ) || WP_DEBUG != true )
|
if ( defined ( 'WP_DEBUG_LEVEL' ) ) {
|
||||||
return;
|
$wp_level = $levels [ WP_DEBUG_LEVEL ];
|
||||||
break;
|
if ( $level_ < $wp_level ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error_log( __CLASS__ . ": " . $message );
|
// ERR, CRIT, ALERT and EMERG
|
||||||
|
if ( 3 >= $level_ ) {
|
||||||
|
wp_die( '<h1>Error:</h1>' . '<p>' . $message . '</p>' );
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$trace = debug_backtrace();
|
||||||
|
$caller = $trace[1];
|
||||||
|
$parent = $caller['function'];
|
||||||
|
|
||||||
|
if (isset($caller['class']))
|
||||||
|
$parent = $caller['class'] . '::' . $parent;
|
||||||
|
|
||||||
|
return error_log( "{$parent}: {$message}" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue