Skip to content

Instantly share code, notes, and snippets.

@moxdev
moxdev / map.js
Last active November 2, 2016 15:47
Google Maps Initializer with Dynamic loading
document.addEventListener('DOMContentLoaded', function () {
if (document.querySelectorAll('#map-canvas').length > 0) {
if (document.querySelector('html').lang)
lang = document.querySelector('html').lang;
else
lang = 'en';
var js_file = document.createElement('script');
js_file.type = 'text/javascript';
js_file.src = 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCpyM0WKh2D56hXCJvays0YYDlXaG1A8u8&callback=initialize&language=' + lang;
@moxdev
moxdev / switch-to-ssh-git.md
Created November 29, 2016 18:10
How to easily switch from http to ssh remote origin (if you have 2-form Auth active)

git remote -v git remote remove origin git remote add origin git@github.com:user/repo.git

@moxdev
moxdev / single.php
Created December 23, 2016 16:04
Code needed to make acf show up on post pages.
$blogPage = get_option( 'page_for_posts' );
// Example:
// $blogPage = get_option( 'page_for_posts' );
// $sideWYSIWYG = get_field('acf_field_name', $blogPage);
@moxdev
moxdev / _mq.scss
Created January 12, 2017 20:11 — forked from jwebcat/_mq.scss
handy sass mixin for media queries
$break-small: 320px;
$break-large: 1024px;
@mixin respond-to($media) {
@if $media == handhelds {
@media only screen and (max-width: $break-small) { @content; }
}
@else if $media == medium-screens {
@media only screen and (min-width: $break-small + 1) and (max-width: $break-large - 1) { @content; }
}
@moxdev
moxdev / _masthead.scss
Last active January 16, 2017 17:07
Basic masthead sass layout
// masthead.scss
#masthead {
width: 100%;
height: 80px;
display: flex;
justify-content: space-between;
.site-branding {
max-width: 100px;
@moxdev
moxdev / functions.php
Created January 19, 2017 15:02
Add font sizes to WordPress wysiwyg
function wp_editor_fontsize_filter( $buttons ) {
array_shift( $buttons );
array_unshift( $buttons, 'fontsizeselect');
array_unshift( $buttons, 'formatselect');
return $buttons;
}
add_filter('mce_buttons_2', 'wp_editor_fontsize_filter');
@moxdev
moxdev / content-page.php
Last active March 21, 2017 19:28
For showing the on page title function in WordPress if it exists.
<header class="entry-header">
<?php if ( get_field( 'on_page_title' )){
echo '<h1 class="entry-title">' . get_field( 'on_page_title' ) . '</h1>';
} else {
the_title( '<h1 class="entry-title">', '</h1>' );
} ?>
</header><!-- .entry-header -->
@moxdev
moxdev / down-caret.scss
Last active March 22, 2017 19:18
Round css down-caret button
a.btn {
background: #fff;
border-radius: 4px;
box-shadow: 0 2px 0px 0 rgba(0,0,0,0.25);
color: #fff;
display: inline-block;
padding: 6px 30px 8px;
position: relative;
text-decoration: none;
transition: all 0.1s 0s ease-out;
@moxdev
moxdev / box-shadow.css
Created March 22, 2017 20:37
Nice starter box shadow code
box-shadow: 2px 2px 2px 2px rgba(0,0,0,0.25);
@moxdev
moxdev / mce_buttons.php
Created March 24, 2017 17:33
Create custom MCE wysiwyg functions. Below example gives user the ability to create custom buttons and text color in wysiwyg.
/**
* ADD STYLES TO WYSIWYG
*/
// Insert 'styleselect' into the $buttons array
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
// Use 'mce_buttons' for button row #1, mce_buttons_3' for button row #3
add_filter('mce_buttons_2', 'my_mce_buttons_2');