Skip to content

Instantly share code, notes, and snippets.

View oneblackcrayon's full-sized avatar

Frederick Polk oneblackcrayon

View GitHub Profile
@oneblackcrayon
oneblackcrayon / addtogcal.php
Created July 30, 2017 02:22 — forked from petertwise/addtogcal.php
Function to create Add to Google Calendar link
<?php
function squarecandy_add_to_gcal(
$name,
$startdate,
$enddate = false,
$description = false,
$location = false,
$allday = false,
$linktext = 'Add to gCal',
$classes = array('gcal-button, button')
<?php the_terms($post->ID, 'group') ?>
<?php echo get_the_term_list( $post->ID, 'styles', '<ul class="styles"><li>', ',</li><li>', '</li></ul>' ); ?>
<?php $terms = wp_get_post_terms( $post->ID, 'fragorna', array('fields' => 'all') );
print_r($terms[0]->description);
?>
@oneblackcrayon
oneblackcrayon / functions.php
Created May 12, 2017 04:42 — forked from galengidman/functions.php
Adding Static Menu Items to wp_nav_menu()
<?php
function my_nav_wrap() {
// default value of 'items_wrap' is <ul id="%1$s" class="%2$s">%3$s</ul>'
// open the <ul>, set 'menu_class' and 'menu_id' values
$wrap = '<ul id="%1$s" class="%2$s">';
// get nav items as configured in /wp-admin/
$wrap .= '%3$s';
@oneblackcrayon
oneblackcrayon / functions.php
Created May 7, 2017 03:35 — forked from proweb/functions.php
Wordpress. Function for remove archive prefix from archive title. Remove “Category:”, “Tag:”, “Author:” from the_archive_title.
function remove_category_prefix_from_archive_title( $title ) {
if ( is_category() ) {
$title = single_cat_title( '', false );
} elseif ( is_tag() ) {
$title = single_tag_title( '', false );
} elseif ( is_author() ) {
$title = '<span class="vcard">' . get_the_author() . '</span>' ;
}
<?php
/**
* Remove archive title prefixes.
*
* @param string $title The archive title from get_the_archive_title();
* @return string The cleaned title.
*/
function grd_custom_archive_title( $title ) {
// Remove any HTML, words, digits, and spaces before the title.
// @link: https://premium.wpmudev.org/blog/maintenance-mode/
// Activate WordPress Maintenance Mode
function wp_maintenance_mode(){
if(!current_user_can('edit_themes') || !is_user_logged_in()){
wp_die('<h1 style="color:red">Website under Maintenance</h1><br />We are performing scheduled maintenance. We will be back online shortly!');
}
}
add_action('get_header', 'wp_maintenance_mode');
A little explanation for those who have no idea what NOBLOGREDIRECT is.
The define(‘NOBLOGREDIRECT’, ‘%siteurl%’); inside of the wp-config.php makes it so that when someone enters a subdomain that does not exist on your site to redirect to whatever url you wish it to. You can use this to have it either go to a specific FAQ page or directly back to the main root installation, anywhere you want to direct it. the %siteurl% can be replaced for example define(‘NOBLOGREDIRECT’, ‘http://frumph.net/FAQ/site-create’);
When someone in their browser tries to go to (for example) http://badsubdomain.frumph.net/ a subomain which doesn’t exist, it will go to what is defined in NOBLOGREDIRECT.
Without using NOBLOGREDIRECT the (for example) http://badsubdomain.frumph.net/ – which is a subdomain that doesn’t exist would direct to the signup page asking which reports whether or not the user can create the bad subdomain in question. This is fine, there’s nothing wrong with it redirecting to the signup page if someone put
@oneblackcrayon
oneblackcrayon / custom-fonts.php
Created January 3, 2017 23:09 — forked from jamesdixon/custom-fonts.php
Wordpress Allow Custom Font Upload
<?php
// add to your theme's functions.php file
add_filter('upload_mimes', 'add_custom_upload_mimes');
function add_custom_upload_mimes($existing_mimes) {
$existing_mimes['otf'] = 'application/x-font-otf';
$existing_mimes['woff'] = 'application/x-font-woff';
$existing_mimes['ttf'] = 'application/x-font-ttf';
$existing_mimes['svg'] = 'image/svg+xml';
$existing_mimes['eot'] = 'application/vnd.ms-fontobject';
return $existing_mimes;
@oneblackcrayon
oneblackcrayon / admin.php
Created January 3, 2017 22:42 — forked from Phoenix2k/admin.php
WordPress Gists
<?php
/**
* Adds support for `admin.css` (with child-theme support)
*
* You can use this to style anything from edit buttons on the frontend
* to customizing your admin screen for logged in users
*
* @link http://codex.wordpress.org/Function_Reference/wp_enqueue_script
*/
add_action( 'admin_enqueue_scripts', 'theme_admin_styles' );
@oneblackcrayon
oneblackcrayon / osx-setup.sh
Created January 1, 2017 06:24 — forked from somebox/osx-setup.sh
Set up an OSX machine from zero to awesome. Uses Homebrew (and cask, fonts, etc). Focused on Ruby/Rails development, includes rvm, xquartz, editor fonts, sublime text, and many tools.
#!/bin/bash
# A script to set up a new mac. Uses bash, homebrew, etc.
# Focused for ruby/rails development. Includes many utilities and apps:
# - homebrew, rvm, node
# - quicklook plugins, terminal fonts
# - browsers: chrome, firefox
# - dev: iterm2, sublime text, postgres, chrome devtools, etc.
# - team: slack, dropbox, google drive, skype, etc