Skip to content

Commit

Permalink
Merge pull request #26 from thenewinquiry/1.2.4
Browse files Browse the repository at this point in the history
1.2.4 - Fix permalink for `future` posts
  • Loading branch information
misfist authored May 18, 2017
2 parents 1f2f830 + 810afd0 commit 5533b24
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 30 deletions.
47 changes: 47 additions & 0 deletions includes/content-filters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
/**
* Tni Core Content Filters
*
* @package Tni_Core
* @subpackage Tni_Core\Includes
* @since 1.2.4
* @license GPL-2.0+
*/

/**
* Get Pretty Permalink for Future Posts
* When posts are scheduled (`post_status` = `future`), "pretty" permalinks aren't returned by `get_permalink()`
*
* @since 1.2.4
*
* @link https://github.com/thenewinquiry/tni-theme/issues/66
* @link https://core.trac.wordpress.org/ticket/30910
*
* @param string $permalink
* @param obj $post
* @param string $leavename
* @param boolean $sample
*
* @return string $permalink
*/
function tni_core_future_permalink( $permalink, $post, $leavename, $sample = false ) {
static $recursing = false;

/* If there is no post id or you're in the admin area */
if ( empty( $post->ID ) || is_admin() ) {
return $permalink;
}

if ( !$recursing ) {
if ( isset( $post->post_status ) && ( 'future' === $post->post_status ) ) {
$post->post_status = 'publish';
$recursing = true;
return get_permalink( $post, $leavename ) ;
}
}

$recursing = false;
return $permalink;
}
add_filter( 'post_link', 'tni_core_future_permalink', 10, 3 );
add_filter( 'post_type_link', 'tni_core_future_permalink', 10, 4 );
26 changes: 1 addition & 25 deletions includes/utilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,10 @@
* @license GPL-2.0+
*/

/**
* Run Once
* Runs function once
* *
* @since 1.0.0
*/
if ( isset( $_GET['run_tni_copy_custom_fields'] ) && ! get_option( 'tni_copy_custom_fields_complete' ) ) {
add_action( 'init', 'tni_copy_custom_fields', 10 );
add_action( 'init', 'tni_copy_custom_fields_finished', 20 );
} elseif ( isset( $_GET['run_tni_copy_custom_fields'] ) && get_option( 'tni_copy_custom_fields_complete' ) ) {
die( "Script already run." );
}

/**
* Copy Custom Fields
* Copies meta field data from `_additional_content_*` fields to new custom fields
* @usage http://yourdomain.com/?run_tni_copy_custom_fields
* @usage run using WP-CLI `wp eval 'tni_copy_custom_fields();'`
*
* @since 1.0.0
*
Expand Down Expand Up @@ -58,7 +45,6 @@ function tni_copy_custom_fields() {
}

}
add_action( 'init', 'tni_copy_custom_fields', 10 );

/**
* Set Guest Account Roles
Expand Down Expand Up @@ -107,13 +93,3 @@ function tni_core_assign_guest_author_roles() {
echo "DONE";

}

/**
* Add `tni_copy_custom_fields_complete` Once Function is Run
*
* @since 1.0.0
*/
function tni_copy_custom_fields_finished() {
add_option( 'tni_copy_custom_fields_complete', 1 );
die( "Script finished." );
}
7 changes: 5 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Contributors: misfist
Tags: custom
Requires at least: 4.7
Tested up to: 4.7.4
Version: 1.2.3
Tested up to: 4.7.5
Version: 1.2.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -22,6 +22,9 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 1.2.4 May 18, 2017 =
* #66 {https://github.com/thenewinquiry/tni-theme/issues/66} - Fix permalink for `future` posts

= 1.2.3 May 10, 2017 =
* #23 - Added hide featured image checkbox field to blogs.

Expand Down
6 changes: 3 additions & 3 deletions tni-core-functionality.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Text Domain: tni-core
* Domain Path: /languages
*
* Version: 1.2.3
* Version: 1.2.4
*
* @package Tni_Core_Functionality
*/
Expand All @@ -26,6 +26,7 @@
define( 'TNI_CORE_DIR_URL', plugin_dir_url( __FILE__ ) );

require_once( 'includes/helpers.php' );
require_once( 'includes/content-filters.php' );
require_once( 'includes/template-tags.php' );

// Load plugin class files
Expand All @@ -42,7 +43,6 @@

// Load admin files
require_once( 'admin/class-tni-core-admin.php' );

require_once( 'includes/utilities.php' );

/**
Expand All @@ -52,7 +52,7 @@
* @return object Tni_Core
*/
function Tni_Core() {
$instance = Tni_Core::instance( __FILE__, '1.2.3' );
$instance = Tni_Core::instance( __FILE__, '1.2.4' );

return $instance;
}
Expand Down

0 comments on commit 5533b24

Please sign in to comment.