Skip to content

Commit

Permalink
Update to 1.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
terrylinooo committed Jan 15, 2019
1 parent e7adc31 commit 794d9fa
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 65 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -38,9 +38,9 @@ https://youtu.be/it1noNCTXa4

## Requirement

* PHP version > 5.3
* PHP version > 5.3.6
* WordPress version > 4.0
* Tested up to 5.0.2
* Tested up to 5.0.3

## Download

Expand Down
11 changes: 8 additions & 3 deletions README.txt
Expand Up @@ -2,9 +2,9 @@
Contributors: terrylin
Tags: markdown, markdown editor, katex, mermaid, flow chart, github
Requires at least: 4.0
Tested up to: 5.0.2
Stable tag: 1.4.2
Requires PHP: 5.3
Tested up to: 5.0.3
Stable tag: 1.4.3
Requires PHP: 5.3.6
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl.html

Expand Down Expand Up @@ -161,6 +161,11 @@ GNU General Public License for more details.

* Fix bug: HTML-to-Markdown helper.

= 1.4.3

* Bug fix - issue #3 - Thank to wojciehm@github for reporting this issue.
* Display a notice if user's PHP version does not meet the minimum requirement.

== Known Issues ==

* #1 - Sequence Diagram: this feature is only available in WordPress version > 4.5, because it uses underscore.js, and it has confict issues with WordPress' plupload uploader in early version. You can use Mermaid instead of it. We have already hidden this option in setting while an user uses that version < 4.5
Expand Down
26 changes: 19 additions & 7 deletions githuber-md.php
Expand Up @@ -7,14 +7,14 @@
*
* @package Githuber
* @since 1.0.0
* @version 1.4.2
* @version 1.4.3
*/

/**
* Plugin Name: WP Githuber MD
* Plugin URI: https://github.com/terrylinooo/githuber-md
* Description: An all-in-one Markdown plugin for your WordPress sites.
* Version: 1.4.2
* Version: 1.4.3
* Author: Terry Lin
* Author URI: https://terryl.in/
* License: GPL 3.0
Expand Down Expand Up @@ -64,7 +64,7 @@
define( 'GITHUBER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'GITHUBER_PLUGIN_PATH', __FILE__ );
define( 'GITHUBER_PLUGIN_LANGUAGE_PACK', dirname( plugin_basename( __FILE__ ) ) . '/languages' );
define( 'GITHUBER_PLUGIN_VERSION', '1.4.2' );
define( 'GITHUBER_PLUGIN_VERSION', '1.4.3' );
define( 'GITHUBER_PLUGIN_TEXT_DOMAIN', 'wp-githuber-md' );

/**
Expand All @@ -80,8 +80,20 @@
// Composer autoloader.
require_once GITHUBER_PLUGIN_DIR . 'vendor/autoload.php';

// Load main launcher class of WP Githuber MD plugin.
$gitbuber = new Githuber();
if ( version_compare( phpversion(), '5.3.6', '>=' ) ) {

// Let's go!
$gitbuber->init();
// Load main launcher class of WP Githuber MD plugin.
$gitbuber = new Githuber();
// Let's go!
$gitbuber->init();

} else {
/**
* Prompt a warning message while PHP version does not meet the minimum requirement.
* And, nothing to do.
*/
function githuber_md_warning() {
echo githuber_load_view( 'message/php-version-warning' );
}
add_action( 'admin_notices', 'githuber_md_warning' );
}
2 changes: 1 addition & 1 deletion src/Models/Markdown.php
Expand Up @@ -7,7 +7,7 @@
*
* @package Githuber
* @since 1.0.0
* @version 1.0.0
* @version 1.4.3
*/

namespace Githuber\Model;
Expand Down
77 changes: 25 additions & 52 deletions src/Modules/MarkdownParser.php
Expand Up @@ -8,65 +8,38 @@
*
* @package Githuber
* @since 1.0.0
* @version 1.4.3
* @version 1.0.0
*/

namespace Githuber\Module;
use ParsedownExtra;

if ( version_compare( phpversion(), '5.3.6', '>=' ) ) {
class MarkdownParser extends ParsedownExtra {

class MarkdownParser extends \ParsedownExtra {
/**
* Constructer.
*/
public function __construct() {
parent::__construct();
}

/**
* Remove bare <p> elements. <p>s with attributes will be preserved.
*
* @param string $text HTML content.
* @return string <p>-less content.
*/
public function remove_bare_p_tags( $text ) {
return preg_replace( "#<p>(.*?)</p>(\n|$)#ums", '$1$2', $text );
}

/**
* Teansform Markdown to HTML.
*
* @param string $text Markdown content.
*/
public function transform( $text ) {
$parsed_content = $this->text( $text );
return $parsed_content;
}
/**
* Constructer.
*/
public function __construct() {
parent::__construct();
}

} else {

class MarkdownParser extends \Parsedown {
/**
* Remove bare <p> elements. <p>s with attributes will be preserved.
*
* @param string $text HTML content.
* @return string <p>-less content.
*/
public function remove_bare_p_tags( $text ) {
return preg_replace( "#<p>(.*?)</p>(\n|$)#ums", '$1$2', $text );
}

/**
* Remove bare <p> elements. <p>s with attributes will be preserved.
*
* @param string $text HTML content.
* @return string <p>-less content.
*/
public function remove_bare_p_tags( $text ) {
return preg_replace( "#<p>(.*?)</p>(\n|$)#ums", '$1$2', $text );
}

/**
* Teansform Markdown to HTML.
*
* @param string $text Markdown content.
*/
public function transform( $text ) {
$parsed_content = $this->text( $text );
return $parsed_content;
}
/**
* Teansform Markdown to HTML.
*
* @param string $text Markdown content.
*/
public function transform( $text ) {
$parsed_content = $this->text( $text );
return $parsed_content;
}
}

21 changes: 21 additions & 0 deletions src/Views/message/php-version-warning.php
@@ -0,0 +1,21 @@
<?php
if ( ! defined('GITHUBER_PLUGIN_NAME') ) die;
/**
* Show PHP version notice.
*
* @author Terry Lin
* @link https://terryl.in/
*
* @package Githuber
* @since 1.4.3
* @version 1.4.3
*/
$php_version = phpversion();
?>

<div class="notice notice-error is-dismissible">
<p>
<?php printf( __( 'The minimum required PHP version for WP Githuber MD is PHP <strong>5.3.6</strong>, and yours is <strong>%1s</strong>.', 'wp-githuber-md' ), $php_version ) ?> <br>
<?php echo __( 'Please remove WP Githuber MD or upgrade your PHP version.', 'wp-githuber-md' ); ?>
</p>
</div>

0 comments on commit 794d9fa

Please sign in to comment.