diff --git a/includes/shortcodes.php b/includes/shortcodes.php index e64dea3..a91dd68 100755 --- a/includes/shortcodes.php +++ b/includes/shortcodes.php @@ -540,15 +540,23 @@ function getLatestSeriesImageId( $series = 0 ) { } return null; - }/** @noinspection PhpUnusedParameterInspection */ - /** @noinspection PhpUnusedParameterInspection */ + } /** * Renders sorting HTML. * - * @param array $atts Shortcode parameters. There are 0 parameters for this shortcode. + * @param array $atts Shortcode parameters. + * + * @type string $series Force specific series to show. Slug only + * @type string $preachers Force specific preacher to show. Slug only + * @type string $topics Force specific topic to show. Slug only + * @type string $books Force specific book to show. Slug only + * @type string $visibility 'none' to hide the forced fields, 'disable' to show them as disabled and 'suggest' to + * just set the default value while allowing user to change it. Default 'suggest' * * @return string Sorting HTML + * + * @since 2.5.0 added shortcode parameters */ public function displaySermonSorting( $atts = array() ) { // enqueue scripts and styles @@ -556,7 +564,19 @@ public function displaySermonSorting( $atts = array() ) { define( 'SM_ENQUEUE_SCRIPTS_STYLES', true ); } - return render_wpfc_sorting(); + // default shortcode options + $args = array( + 'series' => '', + 'preachers' => '', + 'topics' => '', + 'books' => '', + 'visibility' => 'suggest', + ); + + // merge default and user options + $args = shortcode_atts( $args, $atts, 'sermon_sort_fields' ); + + return render_wpfc_sorting( $args ); } /** diff --git a/includes/template-tags.php b/includes/template-tags.php index bf43b28..920edd5 100755 --- a/includes/template-tags.php +++ b/includes/template-tags.php @@ -133,67 +133,92 @@ function render_wpfc_sermon_archive() { displaySermonSorting() + * + * @return string the HTML + * + * @since 2.5.0 added $args + */ +function render_wpfc_sorting( $args = array() ) { + // reset values + $hidden = ''; + + // handle current page. We don't need "page" var in URL + if ( is_archive() && get_post_type() === 'wpfc_sermon' ) { + $action = get_site_url() . '/' . generate_wpfc_slug()['slug']; + } else { + $action = ''; + } + + // we need it for taxonomy name conversion function + $shortcodes = new WPFC_Shortcodes(); + + // add other filtering fields + foreach ( array( 'wpfc_preacher', 'wpfc_sermon_series', 'wpfc_sermon_topics', 'wpfc_bible_book' ) as $filter ) { + // Force shortcode defined argument if set + if ( ! empty( $args[ $shortcodes->convertTaxonomyName( $filter, false ) ] ) && + $value = $args[ $shortcodes->convertTaxonomyName( $filter, false ) ] ) { + $hidden .= "" . PHP_EOL; + + continue; + } + + if ( ! empty( get_query_var( $filter ) ) && $value = get_query_var( $filter ) ) { + $hidden .= "" . PHP_EOL; + } + } + + // Filters HTML fields data + $filters = array( + array( + 'className' => 'sortPreacher', + 'taxonomy' => 'wpfc_preacher', + 'title' => 'Sort by ' . \SermonManager::getOption( 'preacher_label' ) ?: 'Preacher', + ), + array( + 'className' => 'sortSeries', + 'taxonomy' => 'wpfc_sermon_series', + 'title' => 'Sort by Series' + ), + array( + 'className' => 'sortTopics', + 'taxonomy' => 'wpfc_sermon_topics', + 'title' => 'Sort by Topic' + ), + array( + 'className' => 'sortBooks', + 'taxonomy' => 'wpfc_bible_book', + 'title' => 'Sort by Book' + ), + ); + ob_start(); ?>
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
+ + + +
+ + + +
+
+ +
'; - $html .= '

' . __( 'Download Files', 'sermon-manager' ) . ''; + $html = '

'; + $html .= '

' . __( 'Download Files', 'sermon-manager' ) . ''; if ( get_wpfc_sermon_meta( 'sermon_audio' ) ) { $html .= '' . __( 'MP3', 'sermon-manager' ) . ''; } diff --git a/includes/types-taxonomies.php b/includes/types-taxonomies.php index 62031fd..c664b47 100755 --- a/includes/types-taxonomies.php +++ b/includes/types-taxonomies.php @@ -296,7 +296,7 @@ function wpfc_sermon_metaboxes() { 'desc' => __( 'Type a brief description about this sermon, an outline, or a full manuscript', 'sermon-manager' ), 'id' => 'sermon_description', 'type' => 'wysiwyg', - 'options' => array( 'textarea_rows' => 7, 'media_buttons' => false, ), + 'options' => array( 'textarea_rows' => 7, 'media_buttons' => true, ), ) ); $cmb2 = new_cmb2_box( array( @@ -320,7 +320,7 @@ function wpfc_sermon_metaboxes() { ) ); $cmb2->add_field( array( 'name' => __( 'MP3 Duration', 'sermon-manager' ), - 'desc' => __( 'Length in minutes (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager' ), + 'desc' => __( 'Length in hh:mm:ss format (if left blank, will attempt to calculate automatically when you save)', 'sermon-manager' ), 'id' => '_wpfc_sermon_duration', 'type' => 'text', ) ); @@ -358,22 +358,22 @@ function wpfc_sermon_metaboxes() { } -// Custom taxonomy terms dropdown function -function wpfc_get_term_dropdown( $taxonomy ) { - $terms = get_terms( $taxonomy ); - $current_preacher = get_query_var( 'wpfc_preacher' ); - $current_series = get_query_var( 'wpfc_sermon_series' ); - $current_topic = get_query_var( 'wpfc_sermon_topics' ); - $current_book = get_query_var( 'wpfc_bible_book' ); - $html = ''; - foreach ( $terms as $term ) { - $term_slug = $term->slug; - $term_name = $term->name; - if ( $term_slug == $current_preacher || $term_slug == $current_series || $term_slug == $current_topic || $term_slug == $current_book ) { - $html .= ''; - } else { - $html .= ''; - } +/** + * Build