Skip to content

Instantly share code, notes, and snippets.

View macariojames's full-sized avatar
💭
Making things. All the things. Ahh!

Macario James macariojames

💭
Making things. All the things. Ahh!
View GitHub Profile
@macariojames
macariojames / functions.php
Last active August 1, 2019 19:07
Wordpress: register and enqueue of scripts, use wp_localize_script to get current theme images
// for the JS file that needs theme images
// append rest of directory
// could add multiple variables if wanted inside array
// ~mj
wp_localize_script(
'main', // $handle
'WPURLS',
array(
'siteurl' => print_dir('images') // instead of custom function print_dir(), you can put the path of your images directory
@macariojames
macariojames / instagram-feed.js
Created August 31, 2018 20:47
Sorta vanilla javascript instagram feed
// thank you https://ariasthompson.com/2018/02/08/adding-instagram-feed-website-without-plugin/
// for the basis of this feed grab
var getInstagramFeed = function () {
var request = new XMLHttpRequest();
var token = 'ACCESS_TOKEN';
var count = 3;
request.open('GET', 'https://api.instagram.com/v1/users/self/media/recent/?access_token='+token+'&count='+count, true);
request.onload = function(container) {
@macariojames
macariojames / functions.php
Last active August 4, 2021 13:30
Change wp-login.php page title // Remove "WordPress" from login page
<?php
// Put this in your functions.php file
// Changes wp-login.php page title
// Here I'm removing the default "WordPress" at the end of it ~mj
function custom_login_title( $login_title ) {
return str_replace(array( ' &lsaquo;', ' &#8212; WordPress'), array( ' &lsaquo;', ''),$login_title );
}
add_filter( 'login_title', 'custom_login_title' );
@macariojames
macariojames / mobile-map-clicker-jquery.js
Last active October 29, 2018 18:40
Link opens Google Maps, iOS Maps on mobile device; normal browser link otherwise (jQuery)
// Checks if on mobile device
// Changes link to go to Google Maps
// Which should open automatically in Apple or Google Maps on Android/iOS device ~mj
function mobileMapClicker() {
console.log(navigator.userAgent);
// Checks userAgent if mobile device
if (/Mobi/.test(navigator.userAgent)) {
console.log('Mobile Device Detected!');
/* if we're on iOS, open in Apple Maps */
@macariojames
macariojames / display-active-functions.php
Last active October 29, 2018 19:50
WordPress/PHP: display active functions
echo "<pre>"; print_r( get_defined_functions() );
@macariojames
macariojames / .htaccess
Last active January 26, 2019 16:06
Leverage Browser Caching - Apache - Add this to .htaccess file
# Thank you to this gist for some edits (check history! lol) https://gist.github.com/Zodiac1978/3145830
# Leverage Browser Caching
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
@macariojames
macariojames / .htaccess
Created January 26, 2019 15:51
Enable Gzip Compression - Apache - Add this to the .htaccess file
# Enable Compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
@macariojames
macariojames / apache2.conf
Created January 27, 2019 20:16
For gzip compression - Add to Apache conf file
<Directory /var/www/html/>
<IfModule mod_mime.c>
AddType application/x-javascript .js
AddType text/css .css
</IfModule>
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/plain text/xml application/javascript
<IfModule mod_setenvif.c>
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
@macariojames
macariojames / local-mc-validate.js
Created January 28, 2019 16:04
Minified mc-validate.js
!function(e,t){"use strict";function n(e){var t=e.length,n=K.type(e);return!K.isWindow(e)&&(!(1!==e.nodeType||!t)||("array"===n||"function"!==n&&(0===t||"number"==typeof t&&t>0&&t-1 in e)))}function r(e,n,r,i){if(K.acceptData(e)){var a,o,s=K.expando,u="string"==typeof n,l=e.nodeType,c=l?K.cache:e,d=l?e[s]:e[s]&&s;if(d&&c[d]&&(i||c[d].data)||!u||r!==t)return d||(l?e[s]=d=$.pop()||K.guid++:d=s),c[d]||(c[d]={},l||(c[d].toJSON=K.noop)),("object"==typeof n||"function"==typeof n)&&(i?c[d]=K.extend(c[d],n):c[d].data=K.extend(c[d].data,n)),a=c[d],i||(a.data||(a.data={}),a=a.data),r!==t&&(a[K.camelCase(n)]=r),u?(o=a[n],null==o&&(o=a[K.camelCase(n)])):o=a,o}}function i(e,t,n){if(K.acceptData(e)){var r,i,a,s=e.nodeType,u=s?K.cache:e,l=s?e[K.expando]:K.expando;if(u[l]){if(t&&(r=n?u[l]:u[l].data)){K.isArray(t)?t=t.concat(K.map(t,K.camelCase)):t in r?t=[t]:t=(t=K.camelCase(t))in r?[t]:t.split(" ");for(i=0,a=t.length;a>i;i++)delete r[t[i]];if(!(n?o:K.isEmptyObject)(r))return}(n||(delete u[l].data,o(u[l])))&&(s?K.cleanData([
@macariojames
macariojames / local-horizontal-slim-10_7.css
Created January 29, 2019 15:05
Minified Mailchimp CSS file
#mc_embed_signup form{text-align:center;padding:10px 0}.mc-field-group{display:inline-block}#mc_embed_signup input.email{font-family:"Open Sans","Helvetica Neue",Arial,Helvetica,Verdana,sans-serif;font-size:15px;border:1px solid #ABB0B2;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;color:#343434;background-color:#fff;box-sizing:border-box;height:32px;padding:0 .4em;display:inline-block;margin:0;width:350px;vertical-align:top}#mc_embed_signup label{display:block;font-size:16px;padding-bottom:10px;font-weight:700}#mc_embed_signup .clear{display:inline-block}#mc_embed_signup .button{font-size:13px;border:none;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;letter-spacing:.03em;color:#fff;background-color:#aaa;box-sizing:border-box;height:32px;line-height:32px;padding:0 18px;display:inline-block;margin:0;transition:all .23s ease-in-out 0s}#mc_embed_signup .button:hover{background-color:#777;cursor:pointer}#mc_embed_signup div#mce-responses{float:left;top:-1.4em;padding:0 .5