Skip to content

Commit

Permalink
v1.6 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
vaakash committed Nov 24, 2022
1 parent 229b6fa commit fb5b1e4
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 6 deletions.
4 changes: 2 additions & 2 deletions git-it-write.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
Description: Publish markdown files present in a Github repository as posts to WordPress automatically
Author: Aakash Chakravarthy
Author URI: https://www.aakashweb.com/
Version: 1.5
Version: 1.6
*/

define( 'GIW_VERSION', '1.5' );
define( 'GIW_VERSION', '1.6' );
define( 'GIW_PATH', plugin_dir_path( __FILE__ ) ); // All have trailing slash
define( 'GIW_ADMIN_URL', trailingslashit( plugin_dir_url( __FILE__ ) . 'admin' ) );

Expand Down
6 changes: 5 additions & 1 deletion includes/parsedown.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class GIW_Parsedown extends ParsedownExtra{
'post_status' => 'publish',
'post_excerpt' => '',
'post_date' => '',
'comment_status' => '',
'page_template' => '',
'taxonomy' => array(),
'custom_fields' => array()
'custom_fields' => array(),
'stick_post' => '',
'skip_file' => ''
);

public $uploaded_images = array();
Expand Down
27 changes: 26 additions & 1 deletion includes/publisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){
$post_status = empty( $front_matter[ 'post_status' ] ) ? 'publish' : $front_matter[ 'post_status' ];
$post_excerpt = empty( $front_matter[ 'post_excerpt' ] ) ? '' : $front_matter[ 'post_excerpt' ];
$menu_order = empty( $front_matter[ 'menu_order' ] ) ? 0 : $front_matter[ 'menu_order' ];
$page_template = empty( $front_matter[ 'page_template' ] ) ? '' : $front_matter[ 'page_template' ];
$comment_status = empty( $front_matter[ 'comment_status' ] ) ? '' : $front_matter[ 'comment_status' ];
$stick_post = empty( $front_matter[ 'stick_post' ] ) ? '' : $front_matter[ 'stick_post' ];
$skip_file = empty( $front_matter[ 'skip_file' ] ) ? '' : $front_matter[ 'skip_file' ];
$taxonomy = $front_matter[ 'taxonomy' ];
$custom_fields = $front_matter[ 'custom_fields' ];

Expand All @@ -151,6 +155,10 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){
$post_excerpt = '';
$post_date = '';
$menu_order = 0;
$page_template = '';
$comment_status = '';
$stick_post = '';
$skip_file = '';
$taxonomy = array();
$custom_fields = array();

Expand All @@ -159,6 +167,11 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){
$github_url = '';
}

if( $skip_file == 'yes' ){
GIW_Utils::log( 'Skipping file [' . $item_props[ 'github_url' ] . '], skip_file option is set' );
return false;
}

$meta_input = array_merge( $custom_fields, array(
'sha' => $sha,
'github_url' => $github_url
Expand All @@ -175,6 +188,8 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){
'post_excerpt' => $post_excerpt,
'post_parent' => $parent,
'post_date' => $post_date,
'page_template' => $page_template,
'comment_status' => $comment_status,
'menu_order' => $menu_order,
'meta_input' => $meta_input
);
Expand All @@ -199,11 +214,21 @@ public function create_post( $post_id, $item_slug, $item_props, $parent ){

$set_tax = wp_set_object_terms( $new_post_id, $terms, $tax_name );
if( is_wp_error( $set_tax ) ){
GIW_Utils::log( 'Failed to set taxonomy [' . $set_tax->get_error_message() . ']' );
GIW_Utils::log( 'Failed to set taxonomy [' . $set_tax->get_error_message() . ']' );
}
}
}

if( $stick_post == 'yes' ){
GIW_Utils::log( 'Marking post [' . $new_post_id . '] as sticky' );
stick_post( $new_post_id );
}

if( $stick_post == 'no' ){
GIW_Utils::log( 'Removing post [' . $new_post_id . '] as sticky' );
unstick_post( $new_post_id );
}

$stat_key = $new_post_id == $post_id ? 'updated' : 'new';
$this->stats[ 'posts' ][ $stat_key ][ $new_post_id ] = get_post_permalink( $new_post_id );

Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Donate link: https://www.paypal.me/vaakash/
License: GPLv2 or later
Requires PHP: 5.3
Requires at least: 4.4
Tested up to: 6.0.2
Stable tag: 1.5
Tested up to: 6.1.1
Stable tag: 1.6

Publish markdown files present in a Github repository as posts to WordPress automatically

Expand Down Expand Up @@ -140,6 +140,10 @@ Yes, if you want to pull posts from a folder in a repository then you can specif

## Changelog

### 1.6
* New: Options like comment status, page template, sticky post can now be set.
* New: New option to skip file from being published.

### 1.5
* New: Post date can now be set.
* Fix: Enhancements to data escaping in the admin page.
Expand Down

0 comments on commit fb5b1e4

Please sign in to comment.