This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Fetch posts in chunks. | |
* | |
* This function fetches posts in chunks of a specified size, which can be useful for large datasets. | |
* | |
* @param string $post_type The type of post to fetch. Default is 'post'. | |
* @param int $posts_per_page The number of posts to fetch per page. Default is 100. | |
* @param array $custom_args Custom arguments to pass to WP_Query. Default is an empty array. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set from https://www.npmjs.com/package/@wordpress/scripts | |
// Add package.json with the @wordpress/scripts dependency. | |
// Add a root file called webpack.config.js | |
// Import the original config from the @wordpress/scripts package. | |
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' ); | |
// Import the helper to find and generate the entry points in the src directory | |
const { getWebpackEntryPoints } = require( '@wordpress/scripts/utils/config' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Is motion ok? | |
* | |
* Prevent animations from running if the user has enabled 'reduce motion' on their machines. | |
* | |
* Use as a conditional. if ( isMotionOk ) { runAnimation(); } | |
*/ | |
function checkMQ( mediaQuery ) { | |
return ! mediaQuery.matches; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Removes empty paragraph tags from shortcodes in WordPress. | |
* | |
* https://thomasgriffin.com/how-to-remove-empty-paragraph-tags-from-shortcodes-in-wordpress/ | |
*/ | |
function remove_empty_paragraph_tags_from_shortcodes_wordpress( $content ) { | |
$to_fix = array( | |
'<p>[' => '[', | |
']</p>' => ']', | |
']<br />' => ']' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Mixin for What-Input | |
* https://github.com/ten1seven/what-input | |
* | |
* Example use: | |
* .element { | |
* @include what-input(keyboard) { | |
* outline: 1px dotted black; | |
* } | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Load a template part & pass in variables declared in caller scope. Optionally return as a string. | |
* @param string $path path to template file, minus .php (eg. `content-page`, `partial/folder/template-name`) | |
* @param array $args map of variables to load into scope | |
* @param bool $echo echo or return rendered template | |
* @return null or rendered template string | |
*/ | |
function rb_get_template_part($path, $args = [], $echo = true) { | |
if (!empty($args)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Filter taxonomy terms by term_order if term_order is specified | |
* | |
* @param string $orderby Method to order terms by | |
* @param array $query_vars The query | |
* @param array $taxonomies Array of taxonomies | |
*/ | |
function filter_terms_order( $orderby, $query_vars, $taxonomies ) { | |
return 'term_order' === $query_vars['orderby'] ? 'term_order' : $orderby; | |
} |