Skip to content

Commit

Permalink
Merge pull request #68 from dartiss/develop
Browse files Browse the repository at this point in the history
Version 2.5.2
  • Loading branch information
dartiss authored Jan 31, 2023
2 parents 57cbfea + b558c11 commit ef927b2
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 39 deletions.
Binary file removed images/scheduled.png
Binary file not shown.
24 changes: 12 additions & 12 deletions inc/class-draftlistwidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,27 @@ public function form( $instance ) {
// Title field.
$field_id = $this->get_field_id( 'title' );
$field_name = $this->get_field_name( 'title' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Widget Title', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['title'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Widget Title', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['title'] ) . '" /></p>';

// Template field.
$field_id = $this->get_field_id( 'template' );
$field_name = $this->get_field_name( 'template' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Template', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['template'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Template', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['template'] ) . '" /></p>';

// Limit field.
$field_id = $this->get_field_id( 'limit' );
$field_name = $this->get_field_name( 'limit' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Maximum number of drafts (0=unlimited)', 'simple-draft-list' ) . ': </label><input type="text" size="2" maxlength="2" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['limit'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Maximum number of drafts (0=unlimited)', 'simple-draft-list' ) . ': </label><input type="text" size="2" maxlength="2" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['limit'] ) . '" /></p>';

// Minimum number of words.
$field_id = $this->get_field_id( 'words' );
$field_name = $this->get_field_name( 'words' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Minimum number of words', 'simple-draft-list' ) . ': </label><input type="text" size="3" maxlength="3" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['words'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Minimum number of words', 'simple-draft-list' ) . ': </label><input type="text" size="3" maxlength="3" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['words'] ) . '" /></p>';

// Draft types field.
$field_id = $this->get_field_id( 'type' );
$field_name = $this->get_field_name( 'type' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Draft Type', 'simple-draft-list' ) . ': </label><select name="' . esc_html( $field_name ) . '" class="widefat" id="' . esc_html( $field_id ) . '"><option value=""';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Draft Type', 'simple-draft-list' ) . ': </label><select name="' . esc_attr( $field_name ) . '" class="widefat" id="' . esc_attr( $field_id ) . '"><option value=""';
if ( esc_html( $instance['type'] ) == '' ) {
echo " selected='selected'";
}
Expand All @@ -164,7 +164,7 @@ public function form( $instance ) {
// Order field.
$field_id = $this->get_field_id( 'order' );
$field_name = $this->get_field_name( 'order' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Order', 'simple-draft-list' ) . ': </label><select name="' . esc_html( $field_name ) . '" class="widefat" id="' . esc_html( $field_id ) . '"><option value=""';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Order', 'simple-draft-list' ) . ': </label><select name="' . esc_attr( $field_name ) . '" class="widefat" id="' . esc_attr( $field_id ) . '"><option value=""';
if ( esc_html( $instance['order'] ) == '' ) {
echo " selected='selected'";
}
Expand Down Expand Up @@ -193,7 +193,7 @@ public function form( $instance ) {
// Scheduled field.
$field_id = $this->get_field_id( 'scheduled' );
$field_name = $this->get_field_name( 'scheduled' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Hide Scheduled Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_html( $field_name ) . '" id="' . esc_html( $field_id ) . '" value="no"';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Hide Scheduled Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="no"';
if ( 'no' == esc_html( $instance['scheduled'] ) ) {
echo " checked='checked'";
}
Expand All @@ -202,7 +202,7 @@ public function form( $instance ) {
// Show pending posts.
$field_id = $this->get_field_id( 'pending' );
$field_name = $this->get_field_name( 'pending' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Show Pending Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_html( $field_name ) . '" id="' . esc_html( $field_id ) . '" value="yes"';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Show Pending Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="yes"';
if ( 'yes' == esc_attr( $instance['pending'] ) ) {
echo " checked='checked'";
}
Expand All @@ -211,22 +211,22 @@ public function form( $instance ) {
// Folder field.
$field_id = $this->get_field_id( 'folder' );
$field_name = $this->get_field_name( 'folder' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Icon Folder', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['folder'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Icon Folder', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['folder'] ) . '" /></p>';

// Date format field.
$field_id = $this->get_field_id( 'date' );
$field_name = $this->get_field_name( 'date' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Date Output Format', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['date'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Date Output Format', 'simple-draft-list' ) . ': </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['date'] ) . '" /></p>';

// Created field.
$field_id = $this->get_field_id( 'created' );
$field_name = $this->get_field_name( 'created' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Must have been created in the last', 'simple-draft-list' ) . '*: </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['created'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Must have been created in the last', 'simple-draft-list' ) . '*: </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['created'] ) . '" /></p>';

// Modified field.
$field_id = $this->get_field_id( 'modified' );
$field_name = $this->get_field_name( 'modified' );
echo "\r\n" . '<p><label for="' . esc_html( $field_id ) . '">' . esc_html__( 'Must have been modified in the last', 'simple-draft-list' ) . '*: </label><input type="text" class="widefat" id="' . esc_html( $field_id ) . '" name="' . esc_html( $field_name ) . '" value="' . esc_html( $instance['modified'] ) . '" /></p>';
echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Must have been modified in the last', 'simple-draft-list' ) . '*: </label><input type="text" class="widefat" id="' . esc_attr( $field_id ) . '" name="' . esc_attr( $field_name ) . '" value="' . esc_attr( $instance['modified'] ) . '" /></p>';

echo '<p>* ' . esc_html__( 'leave blank to show posts across all time periods', 'simple-draft-list' ) . '</p>';
}
Expand Down
24 changes: 12 additions & 12 deletions inc/create-lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
}

$plugin_name = 'Draft List';
$code = '';

// Convert appropriate parameters.
$list_type = strtolower( $list_type );
Expand Down Expand Up @@ -167,7 +168,7 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
$code .= adl_report_error( __( 'The created parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
$error = true;
}
$created = date( 'Y-m-d H:i:s', $created );
$created = gmdate( 'Y-m-d H:i:s', $created );

if ( '' != $modified ) {
$modified = '-' . $modified;
Expand All @@ -179,7 +180,7 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
$code .= adl_report_error( __( 'The modified parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
$error = true;
}
$modified = date( 'Y-m-d H:i:s', $modified );
$modified = gmdate( 'Y-m-d H:i:s', $modified );

if ( ! $error ) {

Expand All @@ -198,13 +199,6 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
array_push( $status, 'pending' );
}

// Define icon folder.
if ( '' == $icon_folder ) {
$icon_folder = plugins_url( 'images/', dirname( __FILE__ ) );
} else {
$icon_folder = get_bloginfo( 'template_url' ) . '/' . $icon_folder . '/';
}

// Has a word or character count been requested?
if ( ( $words > 0 ) || ( strpos( $template, '%words%' ) != false ) || ( strpos( $template, '{{words}}' ) != false ) || ( strpos( $template, '%chars%' ) != false ) || ( strpos( $template, '%chars+space%' ) != false ) || ( strpos( $template, '{{chars+space}}' ) != false ) ) {
$sql_content = ', post_content';
Expand Down Expand Up @@ -316,10 +310,16 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
// Replace the icon tag.
$alt_title = __( 'Scheduled', 'simple-draft-list' );
if ( 'future' == $post_status ) {
$icon_url = '<img src="' . $icon_folder . 'scheduled.png" alt="' . $alt_title . '" title="' . $alt_title . '">';
if ( '' != $icon_folder ) {
$icon_folder = get_bloginfo( 'template_url' ) . '/' . $icon_folder . '/';
$icon_url = '<img src="' . $icon_folder . 'scheduled.png" alt="' . $alt_title . '" title="' . $alt_title . '">';
} else {
$icon_url = '<span class="dashicons dashicons-clock"></span>';
}
} else {
$icon_url = '';
}

$this_line = str_replace( '{{icon}}', $icon_url, $this_line );

// Replace the author tag.
Expand All @@ -344,11 +344,11 @@ function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '',
$this_line = str_replace( '{{draft}}', $draft, $this_line );

// Replace the created date.
$created_date = date( $date_format, strtotime( $post_created ) );
$created_date = gmdate( $date_format, strtotime( $post_created ) );
$this_line = str_replace( '{{created}}', $created_date, $this_line );

// Replace the modified date.
$modified_date = date( $date_format, strtotime( $post_modified ) );
$modified_date = gmdate( $date_format, strtotime( $post_modified ) );
$this_line = str_replace( '{{modified}}', $modified_date, $this_line );

// Replace the word and character counts.
Expand Down
11 changes: 11 additions & 0 deletions inc/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ function adl_set_plugin_meta( $links, $file ) {
}

add_filter( 'plugin_row_meta', 'adl_set_plugin_meta', 10, 2 );

/**
* Add Dashicons to front-end
*
* Will enqueue Dashicons for front-end use.
*/
function adl_load_dashicons_front_end() {
wp_enqueue_style( 'dashicons' );
}

add_action( 'wp_enqueue_scripts', 'adl_load_dashicons_front_end' );
23 changes: 9 additions & 14 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Tags: draft, list, scheduled, SEO, widget
Requires at least: 4.6
Tested up to: 6.1
Requires PHP: 7.4
Stable tag: 2.5.1
Stable tag: 2.5.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

📝 WordPress plugin to manage and promote your unpublished content.

== Description ==

**If you're upgrading from a previous release of Draft List (i.e. pre version 2.5) please check out the FAQ - a number of changes have been made in this release that you need to be aware of. Also, there's big news for version 3.**
**If you're upgrading from a previous release of Draft List (i.e. pre version 2.5) please check out the FAQ - a number of changes have been made in this release that you need to be aware of**

Draft List allows you to both manage your draft and scheduled posts more easily but also to promote them by showing them on your site via shortcode or widget - use it to show your visitors what's "coming soon" or as a great SEO tool.

Expand Down Expand Up @@ -113,16 +113,6 @@ From version 2.5, 2 features have been removed...

1. Caching has gone. This release has had some massive performance improvements which means it was no longer needed. It, more often than not, caused issues and many people have native caching on their site anyway.
2. The draft menus options have been removed. I've moved that functionality off to another plugin named [Draft Links](https://wordpress.org/plugins/draft-links/). If you want the menu links back, please install that. Why have they been removed? For a start, some people were installing this plugin JUST for that functionality, so it made sense for me to separate it. Additionally, the next FAQ answer is part of this too...

= What do I need to know about version 3? =

Version 3 of this plugin is coming soon and it will be a breaking release. In other words, your existing shortcode will stop working, if you're upgrading from an earlier version - you'll need to make changes to it for it to work again.

When this plugin first started it was all about drafts. However, that's changed as it's become obvious that what this plugin should be about is any unpublished content - not just drafts. It could be pending or scheduled posts, for example. Basically, it should be so much more. So, version 3 will be.

It will be renamed and the draft element de-emphasised. This will include renaming the shortcode and various parameters too (hence the breaking element of it). If you have automatic updates switched on for this plugin, I'd recommend turning them off.

The good news, however, is that the plugin will include a raft of new and powerful features, including the ability to limit unpublished post output to specific categories, amongst other things.

== Screenshots ==

Expand All @@ -132,6 +122,11 @@ The good news, however, is that the plugin will include a raft of new and powerf

I use semantic versioning, with the first release being 1.0.

= 2.5.2 =
* Bug: I wasn't setting an initial value for $code. My bad. Now resolved. Thanks to Wiktor Jędrzejczak for spotting that.
* Enhancement: I've made a number of changes to ensure the plugin abides by PHPCS standards for both WordPress and WordPress VIP. Secure and Performant are my middle names. They're not really. I don't actually have so, theoretically, I could use these.
* Enhancement: For the default clock icon, I'm now using a built-in Dashicon SVG. However, you can override for your own image in the usual way.

= 2.5.1 =
* Bug: Fixed a bug (an extra comma) that impacts users on a particular version of PHP

Expand Down Expand Up @@ -261,5 +256,5 @@ I use semantic versioning, with the first release being 1.0.

== Upgrade Notice ==

= 2.5.1 =
* Bug fix that impacts users on one particular version of PHP
= 2.5.2 =
* A bug fix, some code quality improvements and a switch to an SVG for the default clock icon.
2 changes: 1 addition & 1 deletion simple-draft-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Plugin Name: Draft List
* Plugin URI: https://wordpress.org/plugins/simple-draft-list/
* Description: 📝 WordPress plugin to manage and promote your unpublished content.
* Version: 2.5.1
* Version: 2.5.2
* Requires at least: 4.6
* Requires PHP: 5.3
* Author: David Artiss
Expand Down

0 comments on commit ef927b2

Please sign in to comment.