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
// this disables users clicking the submit button multiple times for forms without submit event handlers. | |
window.onbeforeunload = function () { | |
Array.from(document.querySelectorAll('[type=submit],[type=image],[type=reset]')).forEach(function (el) { | |
if (el.form) { | |
el.disabled = true; | |
} | |
}) | |
} |
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_filter('acf/pre_load_post_id', | |
/** | |
* Fix all ACF option pages. acf-pro translates the default "options" page, but not option pages with a custom post_id | |
* | |
* @param string|null $return | |
* @param string|int $post_id | |
* | |
* @return null|string |
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 | |
// Template Name: Advanced Custom Fields Export | |
$groups = acf_get_local_field_groups(); | |
$json = []; | |
foreach ($groups as $group) { | |
// Fetch the fields for the given group key | |
$fields = acf_get_local_fields($group['key']); | |
// Remove unecessary key value pair with key "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
<?php | |
// at the top of wp-config.php | |
if ( isset( $_SERVER, $_SERVER['HTTP_USER_AGENT'] ) | |
&& false !== stripos( $_SERVER['HTTP_USER_AGENT'], 'some-ua' ) | |
) { | |
define( 'DISABLE_SUPERCACHE', true ); | |
define( 'DONOTMINIFY', true ); | |
define( 'NO_JQUERY', true ); | |
} else { | |
define( 'NO_JQUERY', false ); |
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
{% if js is not defined or not js %} | |
<script> | |
document.cookie = "js=1"; | |
location.reload(true); //Refreshes the page | |
</script> | |
{% endif %} | |
{% if js is not defined or js %} | |
<noscript> | |
<meta http-equiv="Set-Cookie" content="js=0"> | |
<meta http-equiv="Refresh" content="0"> |
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
/** | |
* @param {int} y year | |
* @param {int} w ISO week (1-52) | |
* @param {int} d ISO weekday (1-7) | |
* @returns {Date} | |
*/ | |
function getDateByISOYearWeek(y, w, d) { | |
d = d || 1; | |
var simple = new Date(Date.UTC(y, 0, 1 + (w - 1) * 7)); | |
var dow = simple.getDay(); |
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
/* | |
year - weeknr - day of week (1-7) | |
*/ | |
SELECT | |
CONCAT_WS("-", | |
LEFT(YEARWEEK(FROM_UNIXTIME(`daystamp`), 1), 4), | |
RIGHT(YEARWEEK(FROM_UNIXTIME(`daystamp`), 1), 2), | |
WEEKDAY(FROM_UNIXTIME(`daystamp`)) + 1 | |
) as iso_day, | |
DATE(FROM_UNIXTIME(`daystamp`)) as date, |
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
if (typeof assert !== 'function') { | |
function assert(expr, message) { | |
if (!Boolean(expr)) { | |
throw new Error(message || 'unknown assertion error'); | |
} | |
} | |
} | |
function elementScreenQuadrant(element) { |
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_filter( 'template_redirect', function () { | |
global $wp_query; | |
if ( $wp_query instanceof WP_Query && | |
isset( $wp_query->query['pagename'] ) && | |
$wp_query->is_404() | |
) { | |
$uploads_dir = wp_get_upload_dir(); |
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 | |
class HttpCache { | |
/** | |
* @param int $lastModifiedTimestamp | |
* @param int $maxAge | |
* | |
* @return void | |
*/ | |
public static function Init( $lastModifiedTimestamp, $maxAge = null ) { |
NewerOlder