Skip to content

Instantly share code, notes, and snippets.

View scarstens's full-sized avatar
🌟
Automating workflows.

Seth Carstens scarstens

🌟
Automating workflows.
View GitHub Profile
@scarstens
scarstens / class-an-injected-network-site-option.php
Created January 11, 2017 17:24
Site option example of injecting new section and fields into existing sm_options_page or sm_options_container from the fansided-vip plugin
<?php
/**
* Plugin Name: an-injected-network-site-option
* Description: Site option example of injecting new section and fields into existing sm_options_page or sm_options_container from the fansided-vip plugin
* Plugin URI: https://github.com/fansided
* Author: sethcarstens
* Author URI: https://fansided.com
* Version: 0.0.1
* Text Domain: fs
* License: GPLv2 or later
@scarstens
scarstens / sunrise.php
Created April 18, 2016 23:50
Custom sunrise for TLD wordpress multisite in 1 file
<?php
if ( !empty( $_SERVER['HTTP_HOST'] ) ) {
$site = get_site_by_path( strtolower( $_SERVER['HTTP_HOST'] ), '/');
define( 'COOKIE_DOMAIN', '.' . $site->domain );
}
@scarstens
scarstens / wordpress.text_widget_enable_shortcodes.php
Created December 5, 2013 23:35
Enable shortcodes in the default text widget, making custom widgets obsolete. Save hours of programming time by allowing shortcodes in the sidebars.
<?php
add_filter('widget_text', 'do_shortcode');
?>
@scarstens
scarstens / wordpress.add-admin-javascript.php
Created September 29, 2013 16:53
Script that adds or enqueues javascript to a wp-admin page (a specified page, not all of them)
function my_enqueue($hook) {
if( 'users.php' != $hook && 'user-meta-manager' != $_GET['page'])
return;
wp_enqueue_script( 'jquery-ui-sortable');
}
add_action( 'admin_enqueue_scripts', 'my_enqueue' );
@scarstens
scarstens / wordpress.require.login.php
Created September 23, 2013 02:39
Force user to login before accessing the site (on WordPress)
//force user login, regardless of post type
//UNLESS public is in the URL
add_action('parse_request', 'rr_login_redirect');
function rr_login_redirect() {
global $wp;
if(stristr($wp->request,'public/') || stristr($wp->request,'/public')){}
elseif (!is_user_logged_in()) {
auth_redirect();
}
}
@scarstens
scarstens / functions.admin_private_parent.inc.php
Last active December 22, 2015 00:58
Function / Action to enable choosing private pages as parent pages
<?php
/*
* Function / Action to enable choosing private pages as parent pages
*/
function admin_private_parent_metabox($output)
{
global $post;
$args = array(
'post_type' => $post->post_type,
@scarstens
scarstens / sort-array-of-objects.js
Created July 15, 2013 20:45
Sort array of objects by a property in each object
function sortObjectBy(property) {
var sortOrder = 1;
if(property[0] === "-") {
sortOrder = -1;
property = property.substr(1, property.length - 1);
}
return function (a,b) {
var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0;
return result * sortOrder;
}
@scarstens
scarstens / get-base-website-url.js
Created July 15, 2013 20:20
javascript function that return the main URL
function get_base_website_url() {
if (!window.location.origin)
return window.location.origin = window.location.protocol+"//"+window.location.host;
else
return window.location.origin;
}
@scarstens
scarstens / gmail.sig.sidebyside.html
Created June 12, 2013 22:42
Google Mail Side by Side Signature and Logo
<table border="0" cellpadding="0" cellspacing="0" width="400">
<tbody>
<tr height="10">
<td height="10" colspan="2"><hr style="height: 1px; border: 0; border-bottom: 1px dashed #ccc; padding: 0; margin: 12px 0 5px 0;" /></td>
</tr>
<tr style="vertical-align: middle;" height="100">
<td height="100" width="250" style="border-right: 1px dashed #ccc;"><strong>Seth Carstens</strong><br>
Rapid Recovery<br>
<a href="tel:8773727732">877-372-7732</a> office<br>
<a href="tel:4802033753">480-203-3753</a> cell<br>
<apex:page standardStylesheets="false" showHeader="false" sidebar="false">
<apex:stylesheet value="{!URLFOR($Resource.WorkBookStyles, 'styles.css')}" />