diff --git a/composer.json b/composer.json index 3d507c1..3931d21 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "petermolnar/wp-flatbackups", "description": "WordPress plugin to auto-export WordPress content to flat YAML + HTML files", "require": { - "php": ">=5.3.0", + "php": ">=5.3.0", "ext-yaml": "^1.2" }, "license": "GPLv3", @@ -10,7 +10,7 @@ { "name": "Peter Molnar", "email": "hello@petermolnar.eu", - "homepage": "https://petermolnar.eu" + "homepage": "https://petermolnar.eu" } ] } diff --git a/readme.txt b/readme.txt index 662edb6..b3d0c2e 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ === wp-flatbackups === Contributors: cadeyrn -Donate link: +Donate link: https://paypal.me/petermolnar/3 Tags: backup, YAML, flat files Requires at least: 3.0 Tested up to: 4.4 diff --git a/wp-flatbackups.php b/wp-flatbackups.php index c613b71..fe21e3d 100644 --- a/wp-flatbackups.php +++ b/wp-flatbackups.php @@ -31,12 +31,21 @@ if (!class_exists('WP_FLATBACKUPS')): class WP_FLATBACKUPS { public function __construct () { - if (!function_exists('yaml_emit')) { - static::debug('`yaml_emit` function missing. Please install the YAML extension; otherwise this plugin will not work'); + register_activation_hook( __FILE__ , array( &$this, 'plugin_activate' ) ); + add_action( 'wp_footer', array( &$this, 'export_yaml')); + } + + /** + * activate hook + */ + public static function plugin_activate() { + if ( version_compare( phpversion(), 5.3, '<' ) ) { + die( 'The minimum PHP version required for this plugin is 5.3' ); } - add_action( 'wp_footer', array( &$this, 'export_yaml')); - + if (!function_exists('yaml_emit')) { + die('`yaml_emit` function missing. Please install the YAML extension; otherwise this plugin will not work'); + } } /** @@ -99,7 +108,7 @@ class WP_FLATBACKUPS { $attachment_path = get_attached_file( $aid ); $attachment_file = basename( $attachment_path); $target_file = $flatdir . DIRECTORY_SEPARATOR . $attachment_file; - static::debug ('should ' . $post->post_name . ' have this attachment?: ' . $attachment_file ); + //static::debug ('should ' . $post->post_name . ' have this attachment?: ' . $attachment_file ); if ( !is_file($target_file)) { if (!link( $attachment_path, $target_file )) { static::debug("could not hardlink '$attachment_path' to '$target_file'; trying to copy"); @@ -152,7 +161,7 @@ class WP_FLATBACKUPS { $cout = yaml_emit($c, YAML_UTF8_ENCODING ); $cout .= "---\n" . $comment->comment_content; - static::debug ('Exporting comment #' . $comment->comment_ID. ' to ' . $cfile ); + //static::debug ('Exporting comment #' . $comment->comment_ID. ' to ' . $cfile ); file_put_contents ($cfile, $cout); touch ( $cfile, $c_timestamp ); } @@ -165,7 +174,7 @@ class WP_FLATBACKUPS { $out = static::yaml(); // write log - static::debug ('Exporting #' . $post->ID . ', ' . $post->post_name . ' to ' . $flatfile ); + //static::debug ('Exporting #' . $post->ID . ', ' . $post->post_name . ' to ' . $flatfile ); file_put_contents ($flatfile, $out); touch ( $flatfile, $post_timestamp ); return true; @@ -392,18 +401,6 @@ class WP_FLATBACKUPS { error_log( __CLASS__ . " => " . $message ); } - /** - * debug log messages, if needed - * - public static function debug( $message) { - if (is_object($message) || is_array($message)) - $message = json_encode($message); - - if ( defined('WP_DEBUG') && WP_DEBUG == true ) - error_log ( __CLASS__ . ' => ' . $message); - } - */ - /** * */