Skip to content

Instantly share code, notes, and snippets.

View priscillamc's full-sized avatar

Priscilla Chapman priscillamc

View GitHub Profile
# 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' );

Display Featured Image, if exists (in loop)

if ( has_post_thumbnail() ){
    the_post_thumbnail();
}

Display theme image

<img src="<?php echo get_styleshet_directory_uri(); ?>/images/logo.png" class="" alt="" />
@priscillamc
priscillamc / wp-add-inline-scripts.md
Last active October 4, 2019 14:53
Adding inline javascript in WordPress 4.5+ using wp_add_inline_script()

Adding Inline Scripts in WordPress

Since WordPress 4.5, you can add the inline JavaScript using the wp_add_inline_script() function. This can be used instead of echoing inline scripts using wp_footer. The first argument is the handle of a registered script, in this case 'pretty-photo'.

function add_styles_scripts(){
	// Add script in the footer
	wp_enqueue_script('pretty-photo', get_stylesheet_directory_uri() . '/.../jquery.prettyPhoto.js', 
		array('jquery'), NULL, true);
	

WP-CLI Commands

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' ),
	) );
}

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)
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "."
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "js"
# To enable sourcemap output, set this to true
@priscillamc
priscillamc / bs-config.json
Created March 17, 2017 16:41
Open Angular project in Chrome instead of default browser.
{
"browser" : "chrome"
}