Contributors: TheWebist
Tags: comments, spam
Requires at least: 4.5
Tested up to: 5.8
Stable tag: 2.1.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Displays a listing of posts sortable by ShuffleJS using the shortcode [postfilter] with the following options:
/**
* Displays a ShuffleJS powered listing of posts.
*
* RELATED COURSES META QUERY
* When this function is running on a WooCommerce Product Single, we run
* a meta query using the Product's `_yoast_wpseo_primary_sub_category`.
* This allows us to display a listing of Related Courses which have the
* same Primary Sub Category.
*
* In order for this Related Courses query to work, the current Product
* must be assigned a Primary Sub Category, and there must be other
* Products (i.e. Courses) assigned the same Primary Sub Category.
*
* @param array $atts {
* @type string $category When querying `posts`, filter the posts by category. Accepts a comma separated list of category slugs.
* @type string $category_not_in When querying `posts`, exclude the posts by category. Accepts a comma separated list of category slugs.
* @type int $default_thumbnail Default thumbnail ID.
* @type string $exclude List of terms to exclude from the ShuffleJS filter list.
* @type string $filter_class_name Filter class name.
* @type int $gridId Will be used as the HTML id attribute. Must be unique on the output page.
* @type int $limit Set the number of initial results as well as the size of each page of results. Defaults to `30`, set to
* `-1` for "Endless Scroll".
* @type int $mobile_break_point Minimum width in pixels for mobile adjustments. For example, we are removing the Newsletter Sign Up form
* in the Knowledge Center feed when viewing on mobile. (Default 500)
* @type string $order Either ASC or DESC.
* @type string $orderby The column we're sorting by.
* @type string $post__in Comma separated list of Post IDs.
* @type string $post_type The post_type.
* @type int $posts_per_page The number of posts to return. Default -1.
* @type string $primary_role The slug of the `role` you want to highlight when displaying "Roles/Professional Levels"
* as a filter. For example, if you want to use "Agile Coaching" as the filter under
* "Professional Levels", you set the $primary_role to `agile-coaching`, and your
* "Professional Levels" filters will show as "Advanced", "Awareness", "Core", and
* "Supporting" for "Agile Coaching".
* @type bool $include_all Used with `post__in`, includes all other posts after initial set listed in `post__in`.
* @type bool $show_all_filters Set this to TRUE when using the `primary_role` attribute to also show the `primary_role` as a filter.
* @type bool $show_filters Show the filters?
* @type string $tag The tag. (?)
* @type string $taxonomies_display Comma separated list of taxonomy slugs we want to display filters for.
* @type string $taxonomy The taxonomy we're displaying as buttons.
* @type string $terms The terms. (?)
* }
*
* @return string HTML for displaying our ShuffleJS filter and list of posts.
*/
On Knowledge Center pages, I've setup shufflejs-post-filter.js to display the "Newsletter Signup Template". In order for that form to display properly, you must ensure the following setup inside WordPress and Elementor:
- The form must be saved as an Elementor Template with the title "Newsletter Signup Template". The plugin uses that title to query the proper template from Elementor's template library.
- You must add
newslettersignupas the Form ID for the form. Find this under "Content > Additional Options" when you're editing the form widget.
- If you need to initialize Google reCAPTCHA on the Newsletter Sign Up form, you must add
pardot_recaptchaas the reCAPTCHA field's ID value:
- Run
grunt makepotto generatelanguages/shufflejs-post-filter.pot. - Copy
languages/shufflejs-post-filter.potwith your desired language extension (e.g.languages/shufflejs-post-filter-es_ES.po). - Update the translations in the file you copied in #2 (use PoEdit if you prefer a GUI).
- Run
grunt po2moto build.mofiles inlanguages/.
Note: The first time I ran grunt po2mo, I got the error Can not create sync-exec directory. To fix, I had to edit node_modules\grunt-po2mo\tasks\po2mo.js as follows:
- Line 11 Original:
var exec = require('sync-exec'); - Line 11 Revised:
var exec = require('child_process').execSync;
The JavaScript which powers this plugin is found in the following compiled file:
lib/js/dist/bundle.js
The bundle.js file is compiled from the following source files:
lib/js/src/main.js- This is the "master" JS file which importslib/js/src/shufflejs-init.jswith the following dependencies:
lib/js/src/shufflejs-init.js
↳ lib/js/src/utilities.js
↳ node_modules/shufflejs
In order to compile lib/js/src/main.js to lib/js/dist/bundle.js, you must run npm run build. That runs the necessary compilation scripts as defined in package.json.
- Removing
uber_log().
- Accomodating a Google reCAPTCHA field on the Newsletter Sign Up Form.
- Correctly removing the CSS
backgroundproperty fromul.shuffle .list-content.post .overlay(i.e. Knowledge Center articles, see 2.0.3 below) by removing it inlib/scss/postfilter.scssand recompiling the CSS usingnpm run buildto generate the compiledlib/css/postfilter.cssfile.
- Updating npm
caniuselibraries. - Documenting
bundle.jscompile process.
- Disable background knowledge-center article. Some funds do not appear in Spanish.
- Renaming localized variable from
wpvarstopostFilterVarsto prevent naming collisions.
- Bugfix: Checking if
this.posts.lengthis defined.
- Adding
filter_${taxonomy}class names to filters to allow for addressing via CSS (e.g.filter_resource-type).
- Updating NPM packages.
- Adding icon for "Transformation Sketch" Knowledge Center posts.
- Adding CSS class for "Interview" Knowledge Center posts.
- Recompiling
lib/js/dist/bundle.jsdue to update to parent Shuffle JS library.
- Additional documentation for "Related Posts" meta query in
post_filter()function. - Updating NPM packages.
- Removing Newsletter Sign Up form in posts feed when browser width is less than the mobile break point.
- Adding
mobile_break_pointattribute to the[postfilter]shortcode.
- Adding "Deep Linking" for News Categories (e.g.
?news-category=netminder-interviews).
- Adding
[postfilter] $query_argslogging viaNETMIND_DEBUGconstant.
- Adding Spanish translation for "Face-to-Face" (i.e. "Presencial").
- Updating NPM packages.
- Adding Spanish translation for "All" (i.e. "Todos").
- Removing
ucwords()from filter headings.
- Updating text domain string to match the name of the lanugage file (changed "underscores" to "dashes").
- Running
load_plugin_textdomain()duringinithook.
- Adding Spanish translation.
- Adding dynamic insertion of the Newsletter Sign Up form.
- Initial translation setup.
- Restoring
$postinside[postfilter]to global query$postobject.
- Adding logic for "Related Courses" query when using
[postfilter post_type=product posts_per_page=3 show_filters=false]on a Course (i.e. WooCommerce product single) page. - Adding
posts_per_pageattribute to[postfilter]to allow limiting of returned results.
- You can now "page" results and show a "Load More" button at the bottom. To do so, use the
limitattribute to set the size of the page of results.
- Handling
categoryattribute of[postfilter]shortcode. Previously we weren't doing anything will a passed category. Now we are filtering by any category slugs passed via thecategory="..."attribute. - Adding
category_not_inattribute to[postfilter].
- Adding blue border to Course card design.
- Updating NPM modules
- Fixing documentation formating.
- Adding
primary_roleattribute for filtering out roles when displaying the "Professional Level" filters.
- Adding
taxonomies_displayoption for[postfilter]shortcode. - Adding
[postfilter]documentation to the README.
- Adding "Deep Link" smooth scroll.
- BUGFIX: Checking for
nullvariable when attempting to "Deep Link" to specific Sub Categories and Certifications.
- Adding "Deep Linking" to "Sub Categories" and "Certifications".
- BUGFIX: Checking for existence of array before running
implode().
- Adding "Best Practice" taxonomy.
- Updating Knowledge Center posts to allow for three lines of text for titles.
- Setting initial state of filter buttons with "All" selected.
- Restoring "All" to selected state when no filters are selected.
- Adjusting filter buttons styling (i.e. more "pill shaped", Netmind Blue for selected buttons).
- BUGFIX: Correctly assigning file version to
postfilter.cssby usingfilemtime().
- Removing title's ellipsis from the front of the flip cards.
- BUGFIX: Respecting order of
post__inattribute for[postfilter post__in="..." /].
- Adding
include_allattribute to[postfilter/]for including all other posts when usingpost__in.
- Flip Card back styling for 2nd line ellipsis on heading, and 8th line ellipsis on the excerpt.
- Styling adjustments to [postfilter /] filter buttons.
- Adding
post__inattribute to specify the complete set and order of posts displayed by[postfilter /].
- Initializing variable and checking for varilable in
lib/fns/shortcodes.php.
- Adding "Virtual" to label for "OpenClass" classes.
- Removing borders around flip cards.
- Adding
show_filtersattribute to[postfilter]shortcode.
- Bug Fix: Using single quotes for product dataGroup attribute.
- Refactoring post meta data.
- Updating Course meta color to Netmind blue.
- Adding Course meta to course products.
- Adding "New" tag to courses <= 90 days old.
- Adding "flip card" animation to course products.
- Updating
excludeattribute to only remove the filter buttons from the ShuffleJS filter rather than removing the items from the query.
- Initial release.


