Skip to content

Commit 84033ae

Browse files
author
Nikola Miljković
authored
Merge pull request #111 from WP-for-Church/dev
Release 2.7.1
2 parents 50d7068 + 538fc09 commit 84033ae

6 files changed

Lines changed: 557 additions & 548 deletions

File tree

includes/admin-functions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,17 +424,17 @@ function wpfc_taxonomy_short_description_shorten( $string, $max_length = 23, $ap
424424
if ( $length > $max_length ) {
425425

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

429429
/*
430430
* A word has been cut in half during shortening.
431431
* If the shortened string contains more than one word
432432
* the last word in the string will be removed.
433433
*/
434-
if ( 0 !== mb_strpos( $string, $short . ' ', 0, $encoding ) ) {
435-
$pos = mb_strrpos( $short, ' ', $encoding );
434+
if ( 0 !== strpos( $string, $short . ' ', 0 ) ) {
435+
$pos = strpos( $short, ' ' );
436436
if ( false !== $pos ) {
437-
$short = mb_substr( $short, 0, $pos, $encoding );
437+
$short = strpos( $short, 0, $pos );
438438
}
439439
}
440440

includes/class-sm-error-recovery.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,10 @@ public static function upgrade_check() {
273273
update_option( '_sm_recovery_do_not_catch', 0 );
274274
update_option( '_sm_recovery_disable', 0 );
275275
update_option( 'sm_version', SERMON_MANAGER_VERSION );
276+
277+
// Flush rewrite rules after update
278+
add_action( 'sm_after_register_post_type', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
279+
add_action( 'sm_after_register_taxonomy', array( 'SM_Post_Types', 'flush_rewrite_rules_hard' ) );
276280
}
277281
}
278282

includes/class-sm-post-types.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public static function register_taxonomies() {
4141
apply_filters( 'sm_taxonomy_args_wpfc_preacher', array(
4242
'hierarchical' => false,
4343
/* Translators: %s: Preachers label (sentence case; plural) */
44-
'label' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's'),
44+
'label' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ),
4545
'labels' => array(
4646
/* Translators: %s: Preachers label (sentence case; plural) */
4747
'name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) . 's' ),
4848
/* Translators: %s: Preacher label (sentence case; singular) */
4949
'singular_name' => sprintf( __( '%s', 'sermon-manager-for-wordpress' ), ucwords( $preacher_label ) ),
5050
/* Translators: %s: Preachers label (sentence case; plural) */
51-
'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager' ), ucwords( $preacher_label ). 's' ),
51+
'menu_name' => sprintf( _x( '%s', 'Admin menu name', 'sermon-manager' ), ucwords( $preacher_label ) . 's' ),
5252
/* Translators: %s: Preachers label (lowercase; plural) */
5353
'search_items' => sprintf( __( 'Search %s', 'sermon-manager-for-wordpress' ), $preacher_label . 's' ),
5454
/* Translators: %s: Preachers label (lowercase; plural) */
@@ -269,6 +269,15 @@ public static function rest_api_allowed_post_types( $post_types ) {
269269

270270
return $post_types;
271271
}
272+
273+
/**
274+
* Shorthand function for flush_rewrite_rules(true)
275+
*
276+
* @since 2.7.1
277+
*/
278+
public static function flush_rewrite_rules_hard() {
279+
\flush_rewrite_rules( true );
280+
}
272281
}
273282

274283
SM_Post_Types::init();

includes/shortcodes.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -772,17 +772,8 @@ function displaySermons( $atts = array() ) {
772772
unset( $query_args['tax_query']['custom'] );
773773
}
774774

775-
776-
if ( $query_args['orderby'] === 'date' ) {
777-
add_filter( 'posts_orderby', array( $this, 'orderby' ) );
778-
}
779-
780775
$listing = new WP_Query( $query_args );
781776

782-
if ( $query_args['orderby'] === 'date' ) {
783-
remove_filter( 'posts_orderby', array( $this, 'orderby' ) );
784-
}
785-
786777
if ( $listing->have_posts() ) {
787778
ob_start(); ?>
788779
<div id="wpfc_sermon">
@@ -826,10 +817,6 @@ function displaySermons( $atts = array() ) {
826817
return 'No sermons found.';
827818
}
828819
}
829-
830-
public function orderby( $var ) {
831-
return 'GREATEST(UNIX_TIMESTAMP(wp_posts.post_date), wp_postmeta.meta_value+0) DESC';
832-
}
833820
}
834821

835822
$WPFC_Shortcodes = new WPFC_Shortcodes;

0 commit comments

Comments
 (0)