Skip to content

Instantly share code, notes, and snippets.

const functionA = async () => {
try {
// request something that resolves in a promise
} catch (error) {
throw new Error("Function A failed");
}
}
const functionB = async () => {
try {
@devinsays
devinsays / example-ajax-enqueue.php
Last active July 21, 2024 08:53
Simple WordPress Ajax Example
<?php
function example_ajax_enqueue() {
// Enqueue javascript on the frontend.
wp_enqueue_script(
'example-ajax-script',
get_template_directory_uri() . '/js/simple-ajax-example.js',
array( 'jquery' )
);
@jasperf
jasperf / .htaccess
Last active March 25, 2019 23:50
.htaccess boilerplate including expire headers, mod pagespeed, cache control headers, Gzip, Deflate #htaccess #seo
# BEGIN Expire headers
AddDefaultCharset UTF-8
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 7200 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/gif "access plus 2592000 seconds"
ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
@leandersikma
leandersikma / facebook_purge.php
Last active September 18, 2016 17:43
Problem with Facebook cache: Page not Found on future posts in Wordpress
<?php
// Issues with sharing posts on Facebook: http://www.passwordincorrect.com/issue-with-sharing-wordpress-posts-to-facebook/
// Add this chunck of code in your functions.php or anywhere else in your theme files.
// Register action for post status transitions
add_action( 'transition_post_status' , 'purge_future_post', 10, 3);
// Check if the new transition is publish, for correctness you could check if $old_status == 'pending', but I want that every post (which is published) is cached again (just to be sure).