0.2 cleanup
This commit is contained in:
parent
456b48c112
commit
50e58d78aa
3 changed files with 49 additions and 45 deletions
|
@ -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": [
|
||||
|
|
11
readme.txt
11
readme.txt
|
@ -1,17 +1,14 @@
|
|||
=== 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 ==
|
||||
|
||||
*WARNING*
|
||||
|
@ -25,7 +22,7 @@ Content will be exported to wp-content/flat/{post_slug}/ folder ( one folder per
|
|||
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 ==
|
||||
|
|
|
@ -28,7 +28,7 @@ Required minimum PHP version: 5.4
|
|||
|
||||
namespace WP_FLATEXPORTS;
|
||||
|
||||
define ( 'force', true );
|
||||
define ( 'force', false );
|
||||
define ( 'basedir', 'flat' );
|
||||
define ( 'basefile', 'item.md' );
|
||||
define ( 'maxattachments', 100 );
|
||||
|
@ -230,6 +230,13 @@ function plain_text_post ( $postid = false ) {
|
|||
$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 @@ function post_content ( &$post ) {
|
|||
|
||||
// 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 @@ function raw_post_data ( &$post = null ) {
|
|||
// 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,48 +472,13 @@ function raw_post_data ( &$post = null ) {
|
|||
'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
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue