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 | |
add_action( 'init', function() { | |
$role = get_role('editor'); | |
$role->add_cap('edit_theme_options'); | |
} ); |
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 | |
/** | |
* Order Has Product | |
* | |
* Checks a WooCommerce order to see if it contains | |
* a given product ID | |
* | |
* @param object $order | |
* @param int $product_id |
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
/** | |
* Written by Philip Walton | |
* @see https://philipwalton.com/articles/responsive-components-a-solution-to-the-container-queries-problem/ | |
*/ | |
if ('ResizeObserver' in self) { | |
// Create a single ResizeObserver instance to handle all | |
// container elements. The instance is created with a callback, | |
// which is invoked as soon as an element is observed as well |
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 | |
/** | |
* Add Fields to Order | |
* | |
* @param $fields (array) WooCommerce Checkout Fields | |
*/ | |
add_action( 'woocommerce_checkout_before_customer_details', function( $fields ) { | |
// Define new Field |
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
/** | |
* Get Post with Fields | |
* | |
* Returns a post with it's ACF fields | |
* attached to it | |
* | |
* @NOTE We don't use $post as a variable | |
* inside here so we don't mess with the | |
* WordPress global variable | |
* |
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 | |
/* | |
* Manage Vacancies Columns | |
*/ | |
add_filter( 'manage_vacancies_posts_columns', function ( $columns ) { | |
// Checkbox column | |
$cb = $columns['cb']; |
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 | |
/** | |
* Get Date Range | |
* | |
* @param string $start Start date in unix timestamp format | |
* @param string $end End date in unix timestamp format | |
* @return array Range of dates in an array | |
*/ | |
function get_date_range( $start, $end ) { |
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
var picker = new Pikaday({ | |
field: document.getElementById('datpicker'), | |
minDate: moment().toDate(), // Today | |
disableDayFn: function(date) { | |
var currentDate, today, yearFromNow, dateFormat; | |
// Set Date Format | |
dateFormat = 'YYYY-MM-DD'; | |
// Create Moment Objects |
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 | |
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyz'; | |
// Output: 54esmdr0qf | |
echo substr(str_shuffle($permitted_chars), 0, 10); | |
$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
// Output: video-g6swmAP8X5VG4jCi.mp4 | |
echo 'video-'.substr(str_shuffle($permitted_chars), 0, 16).'.mp4'; | |
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 | |
/** | |
* Get Posts by Year | |
* | |
* Returns an array of posts | |
* sorted by year and month. | |
* | |
* @param string $post_type Post Type | |
* @param array $options Options array for get_posts() |