Skip to content

Commit

Permalink
Merge pull request #111 from WP-for-Church/dev
Browse files Browse the repository at this point in the history
Release 2.7.1
  • Loading branch information
Nikola Miljković authored Sep 28, 2017
2 parents 50d7068 + 538fc09 commit 84033ae
Show file tree
Hide file tree
Showing 6 changed files with 557 additions and 548 deletions.
8 changes: 4 additions & 4 deletions includes/admin-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -424,17 +424,17 @@ function wpfc_taxonomy_short_description_shorten( $string, $max_length = 23, $ap
if ( $length > $max_length ) {

/* Shorten the string to max-length */
$short = mb_substr( $string, 0, $max_length, $encoding );
$short = substr( $string, 0, $max_length );

/*
* A word has been cut in half during shortening.
* If the shortened string contains more than one word
* the last word in the string will be removed.
*/
if ( 0 !== mb_strpos( $string, $short . ' ', 0, $encoding ) ) {
$pos = mb_strrpos( $short, ' ', $encoding );
if ( 0 !== strpos( $string, $short . ' ', 0 ) ) {
$pos = strpos( $short, ' ' );
if ( false !== $pos ) {
$short = mb_substr( $short, 0, $pos, $encoding );
$short = strpos( $short, 0, $pos );
}
}

Expand Down
4 changes: 4 additions & 0 deletions includes/class-sm-error-recovery.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,10 @@ public static function upgrade_check() {
update_option( '_sm_recovery_do_not_catch', 0 );
update_option( '_sm_recovery_disable', 0 );
update_option( 'sm_version', SERMON_MANAGER_VERSION );

// Flush rewrite rules after update
add_action( 'sm_after_register_post_type', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
add_action( 'sm_after_register_taxonomy', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
}
}

Expand Down
13 changes: 11 additions & 2 deletions includes/class-sm-post-types.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ public static function register_taxonomies() {
apply_filters( 'sm_taxonomy_args_wpfc_preacher', array(
'hierarchical' => false,
/* Translators: %s: Preachers label (sentence case; plural) */
'label' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's'),
'label' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ),
'labels' => array(
/* Translators: %s: Preachers label (sentence case; plural) */
'name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ),
/* Translators: %s: Preacher label (sentence case; singular) */
'singular_name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) ),
/* Translators: %s: Preachers label (sentence case; plural) */
'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager' ), ucwords( $preacher_label ). 's' ),
'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager' ), ucwords( $preacher_label ) . 's' ),
/* Translators: %s: Preachers label (lowercase; plural) */
'search_items' => sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ),
/* Translators: %s: Preachers label (lowercase; plural) */
Expand Down Expand Up @@ -269,6 +269,15 @@ public static function rest_api_allowed_post_types( $post_types ) {

return $post_types;
}

/**
* Shorthand function for flush_rewrite_rules(true)
*
* @since 2.7.1
*/
public static function flush_rewrite_rules_hard() {
\flush_rewrite_rules( true );
}
}

SM_Post_Types::init();
13 changes: 0 additions & 13 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -772,17 +772,8 @@ function displaySermons( $atts = array() ) {
unset( $query_args['tax_query']['custom'] );
}


if ( $query_args['orderby'] === 'date' ) {
add_filter( 'posts_orderby', array( $this, 'orderby' ) );
}

$listing = new WP_Query( $query_args );

if ( $query_args['orderby'] === 'date' ) {
remove_filter( 'posts_orderby', array( $this, 'orderby' ) );
}

if ( $listing->have_posts() ) {
ob_start(); ?>
<div id="wpfc_sermon">
Expand Down Expand Up @@ -826,10 +817,6 @@ function displaySermons( $atts = array() ) {
return 'No sermons found.';
}
}

public function orderby( $var ) {
return 'GREATEST(UNIX_TIMESTAMP(wp_posts.post_date), wp_postmeta.meta_value+0) DESC';
}
}

$WPFC_Shortcodes = new WPFC_Shortcodes;
Expand Down
Loading

0 comments on commit 84033ae

Please sign in to comment.