Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍👦
My son is my everything

Cameron Jones cameronjonesweb

👨‍👦
My son is my everything
View GitHub Profile
@cameronjonesweb
cameronjonesweb / cameronjonesweb-image-generator.php
Last active Jul 3, 2017
[WordPress] A helper class to generate a HTML image string from a supplied image class, array or ID. Useful for dealing with images stored in custom fields.
View cameronjonesweb-image-generator.php
<?php
// Helper class to generate responsive image HTML from an id or array
class cameronjonesweb_generate_image {
public $output;
function __construct( $image, $size = 'full' ) {
if( is_array( $image ) ) {
// It's an array
@cameronjonesweb
cameronjonesweb / add_control.php
Last active Jun 3, 2016
Never Fear, The Customizer Is Here! [WordCamp Sunshine Coast] demo code
View add_control.php
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'wordcampsc_link_colour', array(
'label' => __( 'Link Colour', 'wordcampsc' ),
'section' => 'colors',
) ) );
View useful-bash-commands.sh
# Change file permissions on a sever
## Change owner
$ chown -R owner filename
## Change group
$ chgrp -R group filename
## Change mode
$ chmod 755 filename
# Git
## Add all of file extension
@cameronjonesweb
cameronjonesweb / scrolltoanchor.js
Last active Jun 4, 2020
jQuery Scroll To Anchor
View scrolltoanchor.js
jQuery( document ).ready(function(){
jQuery( 'a[href^="#"]' ).each(function(){
if ( jQuery( this ).attr( 'href' ).length > 1 ) {
if ( jQuery( 'body' ).find( jQuery( this ).attr( 'href' ) ) ) {
jQuery( this ).click( function(e){
e.preventDefault();
jQuery( 'html, body' ).animate({
scrollTop: jQuery( jQuery( this ).attr( 'href' ) ).offset().top
}, 'slow' );
});
@cameronjonesweb
cameronjonesweb / clone_meta_environment
Last active Nov 6, 2016
Setting up the WordPress Meta Environment on VVV
View clone_meta_environment
$ git clone https://github.com/WordPress/meta-environment.git www/WordPress-meta-environment
@cameronjonesweb
cameronjonesweb / create_htaccess.sh
Last active Jan 15, 2017
www or non-www redirects with .htaccess
@cameronjonesweb
cameronjonesweb / brokenthumbnails.sql
Created Feb 1, 2017
Retrieve posts with a broken thumbnail (thumbnail set to an attachment that does not exist)
View brokenthumbnails.sql
SELECT `wp_posts`.`ID`, `wp_posts`.`post_title`, `b`.`ID` as 'thumbnail'
FROM `wp_posts`
INNER JOIN (
SELECT *
FROM `wp_postmeta`
WHERE `meta_key` = '_thumbnail_id'
) AS a ON `wp_posts`.`ID` = `a`.`post_id`
LEFT JOIN (
SELECT *
FROM `wp_posts`
@cameronjonesweb
cameronjonesweb / prevent_admin_usename.php
Created Feb 8, 2017
I Don't Know Why Anyone Would Want To Hack My Site
View prevent_admin_usename.php
<?php
add_filter( 'illegal_user_logins', 'cameronjonesweb_illegal_user_logins' );
function cameronjonesweb_illegal_user_logins( $usernames ) {
$usernames[] = 'admin';
return $usernames;
@cameronjonesweb
cameronjonesweb / Contract Killer 3.md
Created Apr 20, 2017 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers
View Contract Killer 3.md

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

View 404-tag-archives.php
<?php
add_action( 'pre_get_posts', 'cameronjonesweb_404_tag_archives' );
function cameronjonesweb_404_tag_archives( $query ) {
if( $query->is_main_query() && $query->is_tag() ) {
$query->set_404();
status_header( 404 );
}
}
You can’t perform that action at this time.