Skip to content

Instantly share code, notes, and snippets.

View cameronjonesweb's full-sized avatar
👨‍👦

Cameron Jones cameronjonesweb

👨‍👦
View GitHub Profile
@cameronjonesweb
cameronjonesweb / cameronjonesweb-google-fonts.php
Last active October 7, 2020 23:38
[PHP] Helper function for retrieving Google Fonts stylesheet URLs
<?php
/**
* Generates a URL for getting a Google Font stylesheet URL
*
* @copyright 2017 Cameron Jones
* @license MIT
* @param array $args
* @return string URL of the Google Font family
*/
function cameronjonesweb_google_fonts( $args ) {
@cameronjonesweb
cameronjonesweb / htaccess.txt
Last active February 29, 2020 12:00
Force HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
@cameronjonesweb
cameronjonesweb / cameronjonesweb-facebook-page-slug.php
Last active December 14, 2017 04:42
Get slug from Facebook page
<?php
function cameronjonesweb_facebook_page_slug( $url ) {
$slug = str_replace(
array(
'https://facebook.com/', 'https://www.facebook.com/', 'http://facebook.com/', 'http://www.facebook.com/'
),
'',
rtrim(
@cameronjonesweb
cameronjonesweb / google-map.js
Last active July 17, 2017 05:11
ACF Google Maps Script
(function($) {
function new_map( $el ) {
// var
var $markers = $el.find('.marker');
// vars
var args = {
@cameronjonesweb
cameronjonesweb / cameronjonesweb-fix-author-no-posts.php
Created July 10, 2017 05:27
Fixes an issue with WordPress where the current author is empty on author archives with no posts
<?php
add_action( 'template_redirect', 'cameronjonesweb_fix_author_no_posts' );
function cameronjonesweb_fix_author_no_posts() {
global $authordata;
if( is_author() && empty( $authordata ) ) {
@cameronjonesweb
cameronjonesweb / .htaccess
Created June 26, 2017 07:13
Noindex PDF files
<FilesMatch ".pdf$">
Header set X-Robots-Tag "noindex"
</FilesMatch>
@cameronjonesweb
cameronjonesweb / hosts
Last active September 3, 2018 00:13
Spotify ad block
# Spotify ad block
0.0.0.0 adclick.g.doublecklick.net
0.0.0.0 adeventtracker.spotify.com
0.0.0.0 ads-fa.spotify.com
0.0.0.0 analytics.spotify.com
0.0.0.0 audio2.spotify.com
0.0.0.0 b.scorecardresearch.com
0.0.0.0 bounceexchange.com
0.0.0.0 bs.serving-sys.com
0.0.0.0 content.bitsontherun.com
<!DOCTYPE html>
<head>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php var_dump( have_posts() ); ?>
<?php wp_footer(); ?>
</body>
@cameronjonesweb
cameronjonesweb / cameronjonesweb-button-generator.php
Last active July 12, 2017 04:11
PHP button generator for WordPress
<?php
/**
* Generates a button
* @param string $label The label of the button
* @param string $link The URL to link to
* @param array $classes Additional classes to add to the button element
* @param bool $new_window Whether to open in a new window or now
* @return string The HTML button element
*/
@cameronjonesweb
cameronjonesweb / .htaccess
Created May 30, 2017 04:34
Cache and GZIP
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access plus 1 year"
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/gif "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/pdf "access plus 1 month"
ExpiresByType text/x-javascript "access plus 1 month"
ExpiresByType application/x-shockwave-flash "access plus 1 month"