Skip to content

Instantly share code, notes, and snippets.

View r0bsc0tt's full-sized avatar

Rob Scott r0bsc0tt

View GitHub Profile
@r0bsc0tt
r0bsc0tt / .htaccess
Created June 25, 2018 15:08 — forked from jdevalk/.htaccess
These three files together form an affiliate link redirect script.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteRule (.*) ./index.php?id=$1 [L]
</IfModule>
@r0bsc0tt
r0bsc0tt / eazy-google-analytics.php
Created December 29, 2016 23:52
Add Google Analytics as a WordPress Plugin
<?php
/*
* Plugin Name: Eazy Add Analytics
* Plugin URI: http://robjscott.com/wordpress/eazy-add-analytics
* Description: easily add analytics to footer
* Version: 1.0
* Author: Rob Scott, LLC
* Author URI: http://robjscott.com
* Text Domain: eazy-photography
* License: GPL-2.0+
@r0bsc0tt
r0bsc0tt / gist:66382e23b9b6a104e222644e9a6c0ea0
Created December 26, 2016 16:00
Alter wordpress main loop with pre get posts
add_filter('pre_get_posts', 'product_line_posts');
function product_line_posts( $query ) {
if( is_tax( 'product-line' ) ) {
//you can pass query params like this
$query->set('posts_per_page', -1);
$query->set('orderby', 'title');
$query->set('order', 'ASC');
}
return $query;
}
<?php
// add the admin options page
add_action('admin_menu', 'plugin_admin_add_page');
function plugin_admin_add_page() {
add_options_page('Custom Plugin Page', 'Custom Plugin Menu', 'manage_options', 'plugin', 'plugin_options_page');
}
// display the admin options page
function plugin_options_page() {
@r0bsc0tt
r0bsc0tt / add_drop_caps.php
Last active November 2, 2016 16:39 — forked from strangerstudios/add_drop_caps.php
Filter to add drop caps to first letter of blog posts in WordPress. Add to your active theme's functions.php.
/*
Drop cap first letter of each post.
*/
add_filter('the_content', 'add_drop_caps', 30);
function add_drop_caps($content) {
global $post;
//only on these included post types
$included_post_types = array("eazy-photo", "post" );
@r0bsc0tt
r0bsc0tt / WordPress - Register & Enqueue Scripts from CDNJS
Last active October 31, 2016 20:05
WordPress - Register & Enqueue Scripts from CDNJS
add_action( 'wp_enqueue_scripts', 'r0bsc0tt_styles_and_scripts', 999 );
function r0bsc0tt_styles_and_scripts() {
if (!is_admin()) {
// Deregister jQuery, then register it from CDNJS (version will need to be updated) and enqueue it
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js', array(), '1.12.4', true);
wp_enqueue_script('jquery');
// Deregister jQuery Migrate, then register it from CDNJS (version will need to be updated) and enqueue it
wp_deregister_script( 'jquery-migrate' );
wp_register_script( 'jquery-migrate', 'https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.0.0/jquery-migrate.min.js', array( 'jquery' ), '3.0.0', true );
<= message arrival
=> normal message delivery
-> additional address in same delivery
*> delivery suppressed by -N
** delivery failed; address bounced
== delivery deferred; temporary problem
A authenticator name (and optional id)
C SMTP confirmation on delivery
@r0bsc0tt
r0bsc0tt / Remove WP Emoji from WordPress
Created October 11, 2016 22:31
Removes WP Emoji from WordPress Head & disable functionality.
<?php
/*
Plugin Name: Eazy Remove WP Emoji
Plugin URI:
Description: Remove WP emoji from header
Version: 1.0.0
Author: Rob Scott, LLC
Author URI: http://robjscott.com
License: GPL2 or any later version
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@r0bsc0tt
r0bsc0tt / JavaScriptwithMediaQueries.js
Created September 21, 2016 00:22
Using JavaScript with Media Queries
function switchHeaderContent() {
//checks if .header-nav display is set to none (changes in media query @ 768px width)
if ($(".header-nav").css("display") == "none" ){
//execute some code here
}
// else if .header-nav is inline-block (set in default stylesheet)
else if ($(".header-nav").css("display") == "inline-block" ){
//execute some other code here
}
}
// replace jQuery with version hosted on CDN
add_action( 'wp_enqueue_scripts', 'register_jquery' );
function register_jquery() {
if (!is_admin() && $GLOBALS['pagenow'] != 'wp-login.php') {
// comment out the next two lines to load the local copy of jQuery
wp_deregister_script('jquery');
wp_register_script('jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js', false, '1.12.4');
wp_enqueue_script('jquery');
}
}