Skip to content

Instantly share code, notes, and snippets.

View EastSideCode's full-sized avatar

East Side Code EastSideCode

View GitHub Profile
@EastSideCode
EastSideCode / functions.php
Created February 20, 2018 18:55
Track phone clicks and Contact form 7 submissions
// add tracking for phone call clicks
function google_phone_clicks_and_contact_form() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event){
if (typeof ga !== 'undefined') {
ga('send', 'event', 'Contact', 'Phone', 'Click');
@EastSideCode
EastSideCode / functions.php
Last active February 17, 2018 15:08
Add phone call tracking for Google Analytics
// add tracking for phone call clicks
function google_phone_clicks() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event){
if (typeof __gaTracker !== 'undefined') {
__gaTracker('send', 'event', 'Contact', 'Phone', 'Click');
}
@EastSideCode
EastSideCode / functions.php
Created January 22, 2018 05:12
Add a WordPress user via FTP
function ectuts_admin_account(){
$user = 'Username';
$pass = 'Password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
} }
@EastSideCode
EastSideCode / functions.php
Created January 16, 2018 17:24
Add analytics to wordpress
// Include the Google Analytics Tracking Code (ga.js)
// @ https://developers.google.com/analytics/devguides/collection/gajs/
function google_analytics_tracking_code() { ?>
<!-- analytics script goes here -->
<script type="text/javascript">
</script>
<!-- analytics script ends here -->
@EastSideCode
EastSideCode / style.css
Created December 14, 2017 14:44
Sample table of contents
/*
# Table of contents
# Normalize / reset
# Header
# Footer
# Menu
# Home
# Page and Post
# Page Specific Content
@EastSideCode
EastSideCode / functions.php
Created December 14, 2017 14:41
Add layer slider CSS into HTML Body
// remove the default css
add_action( 'wp_enqueue_scripts', 'remove_layer_slider_stylesheet');
function remove_layer_slider_stylesheet() {
wp_dequeue_style( 'layerslider' );
}
// load layer slider styles on the page
@EastSideCode
EastSideCode / functions.php
Created December 14, 2017 14:24
Adding google fonts
function wpb_add_google_fonts() {
wp_enqueue_style( 'wpb-google-fonts', 'http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,700,300', false );
}
add_action( 'wp_enqueue_scripts', 'wpb_add_google_fonts' );
@EastSideCode
EastSideCode / functions.php
Created December 5, 2017 13:30
Put WordPress site into maintenance mode
// Put site into maintenance mode
function eastsideCode_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:purple">Website under Maintenance</h1><br />We are performing scheduled maintenance, and will be back online shortly. If you think you've received this notice in error, please contact your website administrator. Thanks!');
}
}
add_action('get_header', 'eastsideCode_maintenance_mode');
@EastSideCode
EastSideCode / .htaccess
Last active February 5, 2018 21:47
Leverage browser caching with .htaccess
## EXPIRES CACHING ##
# In apache, be sure to enable mod_headers and mod_expires
# sudo a2enmod headers
# sudo a2enmod expires
#
# Then restart apache
# service apache2 restart
@EastSideCode
EastSideCode / js
Created November 13, 2017 20:38
Generic, reusable, AJAX Mailer
jQuery(document).ready(function($) {
// load form elements in vars for ease of use
var frm = $('#contact-form');
var formMessages = $('#form-messages');
var loadingAnimation = $('#loading-container');
frm.submit(function (e) {