Skip to content

Instantly share code, notes, and snippets.

View priscillamc's full-sized avatar

Priscilla Chapman priscillamc

View GitHub Profile
@priscillamc
priscillamc / wp-attachment-links
Created July 17, 2014 22:55
WordPress snippet. Link images and documents to the file instead of the attachment page. This also changes the 'View' link in the Media Library admin screen. Add to a new plugin file or to the functions.php in your theme.
@priscillamc
priscillamc / list category post page attachments
Created March 4, 2015 17:19
Shortcode to list page attachments using the WordPress List Category Posts plugin https://wordpress.org/plugins/list-category-posts/
<!-- Replace CURRENT_PAGE_ID for the post_parent to only display attachments of a certain page -->
[catlist post_type="attachment" post_parent="CURRENT_PAGE_ID" numberposts=-1 post_status="publish,inherit" orderby="title" order="ASC" no_posts_text="No files found"]
// Use custom template pages in a WordPress plugin
function my_cpt_templates( $template_path ){
// Change template for CPT single pages
if( is_singular('my_cpt') ){
$template_path = plugin_dir_path( __FILE__ ) . 'templates/single-cpt.php';
}
// Change template for CPT archive pages for a certain taxonomy
<?php
/*
Plugin Name: Auto Update
Description: Enables automatic background updates for core, plugins, and themes. See <a href="https://codex.wordpress.org/Configuring_Automatic_Background_Updates" target="_blank">Configuring Automatic Background Updates</a> for more details.
Version: 1.0.0
*/
// Enable automatic updates for core major releases
add_filter( 'allow_major_auto_core_updates', '__return_true' );
<!-- Simple Calendar 3.0.4 - UF Template -->
<div class="event item">
<div class="eventdate event-date">
<div class="month">[start-date format="M"]</div>
<div class="day">[start-date format="j"]</div>
</div>
<div class="eventtitle">
<h4>[link][title][/link]</h4>
[if-whole-day]<div class="time">All Day</div>[/if-whole-day]
[if-not-whole-day]<div class="time">[start-date format="g:i A"] - [end-date format="g:i A"]</div>[/if-not-whole-day]
# Bootstrap
* http://bootswatch.com/
* https://wrapbootstrap.com/
# WordPress
* https://github.com/zamoose/themehookalliance
* https://wordpress.org/plugins/tha-hooks-interface/
/**
* Add styles and scripts to a WordPress site
*
* See https://codex.wordpress.org/Class_Reference/WP_Styles#Conditional_Styles
*/
function my_scripts_styles(){
global $wp_styles;
// Load IE version-specific stylesheets
wp_enqueue_style( 'html5shiv', 'https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js', array(), '3.7.2', 'screen' );

Add menus to a WordPress Theme

In functions.php, register menus:

function theme_setup() {
    register_nav_menus( array(
		'main_menu' => esc_html__( 'Main Menu', 'theme' ),
	) );
}
@priscillamc
priscillamc / wp-debug.md
Last active July 18, 2016 05:34
Enable WordPress debugging mode

How to Enable Debug Mode in WordPress

  1. Open wp-config.php and comment out line: define('WP_DEBUG', false);

  2. Paste in the lines below to enable WP_DEBUG mode. This will create a debug.log file in the wp-content folder. Rememeber to turn off debugging when you've finished.

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

SVG Notes

To create the CSS from a Photoshop template file:

  • For any non-shape layers (including text layers), make a copy. Right-click the copied layer and click 'Convert to Shape'
  • The converted Department Name shape layer should be renamed to "Unit Text"
  • If a shape should have a default color, set the color.
  • Rename layers if needed. The layer name becomes the path id in the svg.
  • Hide layers that don't need to be exported as paths.
  • Select the layers that should be exported. (Bar, Logo, Parent Unit Text, Unit Text)