Skip to content

Instantly share code, notes, and snippets.

View danmaby's full-sized avatar

Dan Maby danmaby

View GitHub Profile
@danmaby
danmaby / .htaccess
Last active February 16, 2018 15:17
Site Security All Sites
#
<IfModule mod_headers.c>
# HSTS - force redirect to HTTPS at the browser level.
# Submit for Chrome preload list at https://hstspreload.appspot.com/
Header set Strict-Transport-Security: "max-age=31536000; includeSubDomains; preload"
# X-Xss-Protection
Header always set X-Xss-Protection "1; mode=block"
# Stop clickjacking by only allowing us to frame our own site
@danmaby
danmaby / .htaccess
Last active June 27, 2017 20:17
Site Optimisation All Sites
## ENABLE GZIP COMPRESSION ##
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
@danmaby
danmaby / functions.php
Created November 12, 2017 18:12
prevent https:// for cron job when using Local by Flywheel
/**
* ============== REMOVE FROM LIVE ===================
prevent https:// for cron job
**/
add_filter( 'cron_request', function( $args ) {
$args['url'] = set_url_scheme( $args['url'], 'http' );
return $args;
} );
@danmaby
danmaby / functions.php
Created February 16, 2018 07:42
Amazon Polly for WordPress - Custom Post Types
/**
* Amazon Polly "Events" CPT
**/
function my_amazon_polly_post_types( $post_types ) {
$post_types[] = 'events';
return $post_types;
}
add_filter( 'amazon_polly_post_types', 'my_amazon_polly_post_types' );
@danmaby
danmaby / functions.php
Last active February 19, 2018 11:56
Add custom post types to WordPress loop
<?php
/**
* Add 'Events' CTP to WP Loop
**/
function add_custom_post_type_to_query( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'post_type', array('post', 'events') );
}
}
@danmaby
danmaby / functions.php
Last active March 30, 2018 16:44
Remove "Archives:" from WP Astra Advanced Header Add-on
<?php
// Filter out "archive" from archive page title
function wpldn_remove_archive_text( $value, $original_value, $params ) {
$value = str_replace( $params->'Archives: ', ' ', $value );
return $value;
}
add_filter( 'ast-advanced-headers-title', 'wpldn_remove_archive_text', 10, 3 );
@danmaby
danmaby / functions.php
Created April 4, 2018 09:37
Replace og:image on custom post type archive
<?php
// CPT Talks - replace og:image
add_action( 'wp_head', 'prefix_add_og_image', 10, 1 );
function prefix_add_og_image( $img ) {
if( is_post_type_archive( 'post-type-archive-wpldn_talk' ) ) {
echo '<meta property="og:image" content="https://www.wpldn.uk/wp-content/uploads/2018/03/2018-02-22-WPLDN_Primary-Image-2.jpg" />';
}
}
@danmaby
danmaby / keybase.md
Created May 23, 2018 18:11
keybase.md

Keybase proof

I hereby claim:

  • I am danmaby on github.
  • I am danmaby (https://keybase.io/danmaby) on keybase.
  • I have a public key ASB3Cx53jUDppwLxpkgEu4wlmRg7rQstfeTSe8SabKk_iwo

To claim this, I am signing this object:

@danmaby
danmaby / functions.php
Created June 9, 2018 08:21
default editor label for my_custom_post_type
<?php
// default editor label for my_custom_post_type
add_action('admin_footer', 'add_title_to_editor');
function add_title_to_editor() {
global $post;
if (get_post_type($post) == 'my_custom_post_type') : ?>
<script> jQuery('<h3>Optional Additional Information</h3>').insertBefore('#postdivrich'); </script>
<? endif;
@danmaby
danmaby / decorative-wrap.css
Created August 1, 2018 08:06
Polished Mobile Nails Decorative Wrap CSS
/* Decorative wrap -----*/
.wrap-default, .decorative-wrap-1, .decorative-wrap-2, .decorative-wrap-3, .decorative-wrap-4 {
position: relative;
z-index: 1;
display: inline-block;
}
@media (min-width: 992px) {
.wrap-default, .decorative-wrap-1, .decorative-wrap-2, .decorative-wrap-3, .decorative-wrap-4 {
display: block;
}