Skip to content

Instantly share code, notes, and snippets.

East Side Code EastSideCode

Block or report user

Report or block EastSideCode

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EastSideCode
EastSideCode / functions.php
Created Feb 22, 2017
WordPress Child theme functions.php
View functions.php
<?php
function add_parent_styles() {
wp_enqueue_style('parent-style', get_template_directory_uri().'/style.css');
}
add_action('wp_enqueue_scripts', 'add_parent_styles');
@EastSideCode
EastSideCode / .htaccess
Last active Mar 13, 2019
Force HTTS and www
View .htaccess
# force HTTPS and www.
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://www.%1%{REQUEST_URI} [L,NE,R=301]
@EastSideCode
EastSideCode / script.js
Created Jan 16, 2019
Phone call tracking without jQuery
View script.js
<script type="text/javascript">
document.addEventListener( 'wpcf7mailsent', function( event ) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Submit', {
'event_category': 'Contact Form',
'event_label': 'Main Contact Form',
'event_callback': function() {
console.log("contact form tracking sent successfully");
}
@EastSideCode
EastSideCode / index.php
Created Nov 26, 2018
Measuring PHP execution time
View index.php
$start = microtime(true);
// code here
$time_elapsed_secs = microtime(true) - $start;
@EastSideCode
EastSideCode / .htaccess
Created Nov 16, 2018
Redirect http to https
View .htaccess
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
@EastSideCode
EastSideCode / function.php
Created Oct 13, 2018
Split a string in 2 and add a span tag to the first word
View function.php
$originalString = "Test String";
$stringInParts = explode(' ', $originalString);
$originalString = '<span>' . $stringInParts[0] . '</span>' . Implode(" ", array_slice($stringInParts,1));
@EastSideCode
EastSideCode / functions.php
Created Feb 20, 2018
Track phone clicks and Contact form 7 submissions
View functions.php
// 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 / customizer.php
Created Sep 15, 2018
Add a setting to WordPress customizer
View customizer.php
// This example is for a section called theme options, with a setting for copyright text
$wp_customize->add_section( 'theme_options_section' , array(
'title' => __('Theme Options','themename'),
'priority' => 30,
) );
$wp_customize->add_setting( 'copyright_text' , array(
'default' => 'Default text here'
) );
@EastSideCode
EastSideCode / .htaccess
Created Aug 7, 2018
Redirect WordPress site traffic once SSL is installed
View .htaccess
# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
View Media Queries
/* Smaller than standard 960 (devices and browsers) */
@media (max-width: 959px) {}
/* Tablet Portrait size to standard 960 (devices and browsers) */
@media (min-width: 768px) and (max-width: 959px) {}
/* All Mobile Sizes (devices and browser) */
@media (max-width: 767px) {}
/* Mobile Landscape Size to Tablet Portrait (devices and browsers) */
You can’t perform that action at this time.