Skip to content

Instantly share code, notes, and snippets.

@marcbacon
marcbacon / hamburger.html
Last active September 7, 2017 16:05
[Hamburger Menu Animation] Animate a hamburger menu into an "X" using css animations.
<div id="menu-btn">
<div class="bar bar-1"></div>
<div class="bar bar-2"></div>
<div class="bar bar-3"></div>
</div>
@marcbacon
marcbacon / Replace All.js
Created January 20, 2016 23:20
Replace all iterations of a string (within a string) with other content.
/*
* Function to replace all iterations of one string with another
*/
function replaceAll(str, find, replace) {
return str.replace(new RegExp(find, 'g'), replace);
}
@marcbacon
marcbacon / Error_Log.php
Created November 16, 2015 19:28
Create an error log in your theme directory and save data to it.
error_log($args, 3, get_template_directory().'/test.log');
@marcbacon
marcbacon / PHPtoICS.php
Created October 23, 2015 21:58 — forked from jakebellacera/ICS.php
A convenient script to generate iCalendar (.ics) files on the fly in PHP.
<?php
// Variables used in this script:
// $summary - text title of the event
// $datestart - the starting date (in seconds since unix epoch)
// $dateend - the ending date (in seconds since unix epoch)
// $address - the event's address
// $uri - the URL of the event (add http://)
// $description - text description of the event
// $filename - the name of this file for saving (e.g. my-event-name.ics)
//
@marcbacon
marcbacon / God Mode.php
Created October 22, 2015 21:27
Enable GOD MODE in WordPress - all settings saved in the database in one place
/**
* Enable GOD MODE - all settings saved in the database in one place
*/
function god_mode() {
add_options_page(__('All Settings'), __('All Settings'), 'administrator', 'options.php');
}
add_action('admin_menu', 'god_mode');
@marcbacon
marcbacon / Hide Author ID.php
Created October 21, 2015 16:19
Hide author pages. Redirect anyone trying to view author info by appending ?author=1 to url to the home page. This secures the site by hiding user id's from possible hackers.
/**
* Hide author pages. Redirect anyone trying to view author info
* by appending ?author=1 to url to the home page.
* This secures the site by hiding user id's from possible hackers.
*/
function author_redirect() {
if ( is_author() ) {
wp_redirect( home_url() ); exit;
}
} // author_redirect()
@marcbacon
marcbacon / Rounded Corners for Outlook.html
Created October 20, 2015 19:45
VML based button. Rounded corners will work in Outlook.
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<div>
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://example.com" style="height:36px;v-text-anchor:middle;width:150px;" arcsize="5%" strokecolor="#EB7035" fillcolor="#EB7035">
<w:anchorlock/>
<center style="color:#ffffff;font-family:Helvetica, Arial,sans-serif;font-size:16px;">I am a button &rarr;</center>
</v:roundrect>
<![endif]-->
@marcbacon
marcbacon / 12 Column Grid.css
Last active September 7, 2017 16:07
[Basic 12 Column Grid]
.col {
float: left;
box-sizing: border-box;
padding: 0 10px;
}
.col-1 {
width: 8.3333%;
}
.col-2 {
width: 16.6666%;
@marcbacon
marcbacon / Edit Admin Bar.php
Last active August 29, 2015 14:26
Code to edit the admin bar/toolbar in WordPress
// Remove links from the admin bar/toolbar
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('updates');
$wp_admin_bar->remove_menu('search');
$wp_admin_bar->remove_menu('comments');
// Remove site name and new only if user is not administrator
@marcbacon
marcbacon / Hide Admin Bar.php
Created July 31, 2015 14:30
Hide the admin bar on the front end of a WordPress website.
// Place in functions.php or in a plugin
add_filter('show_admin_bar', '__return_false');