all repos — wp-flatexport @ 50e58d78aafa5d7f3085b5defbc8b1473d6ccc34

0.2 cleanup
Peter Molnar hello@petermolnar.eu
Sat, 09 Jul 2016 20:25:43 +0000
commit

50e58d78aafa5d7f3085b5defbc8b1473d6ccc34

parent

456b48c1124421ad05fc0e1c9340123185e26437

3 files changed, 49 insertions(+), 45 deletions(-)

jump to
M composer.jsoncomposer.json

@@ -2,7 +2,7 @@ {

"name": "petermolnar/wp-flatexport", "description": "auto-export WordPress contents to folders and plain text + markdown files for longetivity and portability", "require": { - "php": ">=5.3.0", + "php": ">=5.4.0", }, "license": "GPLv3", "authors": [
M readme.txtreadme.txt

@@ -1,16 +1,13 @@

=== wp-flatexport === Contributors: cadeyrn -Donate link: https://paypal.me/petermolnar/3 -Tags: plain text, export, longnow -Requires at least: 3.0 -Tested up to: 4.4.2 +Tags: plain text, export, backup +Requires at least: 4.2 +Tested up to: 4.5.3 Stable tag: 0.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html -Required minimum PHP version: 5.3 Auto-export all published content on visit to flat, folder + files based structure. - == Description ==

@@ -25,7 +22,7 @@

The content will be placed into in item.md file. This is a markdown file, with some plain test headers. Comments are exported into the same folder, named comment-{comment_id}.md; the format is similar for those as well. -This is not a backup! +**This is not a backup!** The goal of the plugin is to have a portable, plain text, easy to read, easy to copy version of you content on WordPress. Since not all data is exported, your site cannot be reconstructed from these exports. == Requirements ==
M wp-flatexport.phpwp-flatexport.php

@@ -28,7 +28,7 @@ */

namespace WP_FLATEXPORTS; -define ( 'force', true ); +define ( 'force', false ); define ( 'basedir', 'flat' ); define ( 'basefile', 'item.md' ); define ( 'maxattachments', 100 );

@@ -230,6 +230,13 @@ $out .= "------\n";

$out .= "{$postdata['author']}\n\n"; } + if ( isset( $postdata['geo'] ) && ! empty( $postdata['geo'] ) ) { + $out .= "Location\n"; + $out .= "--------\n"; + $out .= "{$postdata['geo']}\n\n"; + } + + if ( ! empty( $postdata['tags'] ) ) { $tags = array(); foreach ( $postdata['tags'] as $k => $tag ) {

@@ -356,6 +363,29 @@ }

// find images and replace them with footnote versions ? + // word-wrap magic + /* + $fenced_o = array(); + preg_match_all( "/^```(.*?)[\n\r](.*?)```/mis", $content, $fenced_o ); + + file_put_contents('/tmp/fenced.out', var_export($fenced_o, true) ); + + $content = wordwrap( $content, 72 ); + + $fenced_n = array(); + preg_match_all( "/^```(.*?)[\n\r](.*?)```/mis", $content, $fenced_n ); + + file_put_contents('/tmp/fenced_.out', var_export($fenced_n, true) ); + + //debug ( $fenced_n ); + + foreach ( array_keys( $fenced_o[0] ) as $k ) { + if ( $fenced_o[0][$k] != $fenced_n[0][$k] ) { + $content = str_replace ( $fenced_n[0][$k], $fenced_o[0][$k], $content ); + } + } + */ + return $content; }

@@ -420,6 +450,18 @@

// read tags $tags = \wp_get_post_terms( $post->ID, 'post_tag' ); + // geo + $geo = ''; + $lat = \get_post_meta ( $post->ID, 'geo_latitude' , true ); + $lon = \get_post_meta ( $post->ID, 'geo_longitude' , true ); + $alt = \get_post_meta ( $post->ID, 'geo_altitude' , true ); + + if ( !empty( $lat ) && !empty( $lon ) ) + $geo = "{$lat},{$lon}"; + + if ( !empty( $alt ) ) + $geo .= "@{$alt}"; + // assemble the data $out = array ( 'title' => trim( \get_the_title( $post->ID ) ),

@@ -430,47 +472,12 @@ 'tags' => $tags,

'author' => $author, 'content' => $content, 'excerpt' => trim( $excerpt ), + 'geo' => $geo, //'reactions' => meta_reaction( $post ), ); return $out; } - - -/** - * - * -function meta_reaction ( &$post ) { - - $url = trim ( get_post_meta( $post->ID, 'webmention_url', true ) ); - $type = trim ( get_post_meta( $post->ID, 'webmention_type', true ) ); - $rsvp = trim ( get_post_meta( $post->ID, 'webmention_data', true ) ); - - if ( empty( $url ) ) - return false; - - switch ($type) { - case 'from': - case 'repost': - $prefix = '**FROM:** '; - break; - case 're': - case 'reply': - case 'rsvp': - $prefix = '**RE:** '; - break; - default: - $prefix = '**URL:** '; - break; - } - - $r = "{$prefix}${url}"; - if ( !empty ($rsvp) ) - $r .= "\n{$rsvp}"; - - return $r; -} -*/ /** * do everything to get the Post object