Skip to content

Instantly share code, notes, and snippets.

@indietravel
indietravel / fragment, functions.php
Created August 28, 2015 09:11
Why do we need cookie on the front end?
/* ----------------------------------------------------------------------------------- */
/* Ajax Animation Session / Add class on body for ajax
/* ----------------------------------------------------------------------------------- */
add_action('after_setup_theme', 'myStartSession', 1);
add_action('wp_logout', 'myEndSession');
add_action('wp_login', 'myEndSession');
/* Start session */
if (!function_exists('myStartSession')) {
@indietravel
indietravel / functions.php
Created March 17, 2015 11:10
Add favicons to a WordPress site
/* Favicon
* Generate the images at http://www.favicon-generator.org
* Place images in your (child) theme folder at /favicon
*/
function foundry_favicon() { ?>
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon/apple-icon-114x114.png">
@indietravel
indietravel / style.css
Created January 23, 2015 10:11
Default starting point for a child theme
/*
Theme Name:
Theme URI: http://performancefoundry.com
Version: 1.0
Description: Custom Theme based on
Author: Craig Martin, Performance Foundry
Author URI: http://performancefoundry.com
Template: name
*/
/* Default styles */
@indietravel
indietravel / category.php
Created October 22, 2014 16:38
Rick's approach
<?php
/**
* The template for displaying category pages.
*
* Learn more: http://codex.wordpress.org/Template_Hierarchy
*
* @package DW Focus
* @since DW Focus 1.0
*/
<div class="content-inner">
<?php
if ( is_category() ) {
$cat = get_query_var('cat');
$ourcat = get_category ($cat);
$category_selected = $ourcat->slug;
}
$args = array (
@indietravel
indietravel / gist:49aef8b00a76eba38a31
Created June 30, 2014 01:23
Secure file permissions for WordPress
In Terminal:
find /var/www/user/public_html -exec chown www-data:www-data {} \;
find /var/www/user/public_html -type d -exec chmod 755 {} \;
find /var/www/user/public_html -type f -exec chmod 644 {} \;
cd /var/www/user/public_html;
rm -f readme.html;
touch readme.html;
chown www-data:www-data readme.html;
@indietravel
indietravel / gist:a2c6307b04abccff5d84
Created June 17, 2014 10:43
Redirect media files from a dev environment to the live environment
#Redirect media files from a dev environment to the live environment
RedirectMatch 301 ^/wp-content/uploads/([0-9]{4})/([0-9]{2})/(.*)$ http://example.com/wp-content/uploads/$1/$2/$3
#Core WP files that might change
.htaccess
/index.php
/license.txt
/readme.html
/wp-activate.php
/wp-admin*
/wp-blog-header.php
/wp-comments-post.php
/wp-config.php
@indietravel
indietravel / gist:11239438
Last active August 29, 2015 14:00
WP - Remove unwanted menu items
/*-----------------------------------------------------------------------------------*/
/* Remove Unwanted Admin Menu Items */
/* Source - https://managewp.com/wordpress-admin-sidebar-remove-unwanted-items */
/* Array could include Appearance, Comments, Links, Media, Pages, Plugins, Posts, Settings, Tools, Users */
/*-----------------------------------------------------------------------------------*/
function foundry_remove_admin_menu_items() {
$remove_menu_items = array(__('Comments'),__('Links'),__('Posts'));
global $menu;
end ($menu);