Skip to content

Instantly share code, notes, and snippets.

View deardorffdev's full-sized avatar

Deardorff Associates Web deardorffdev

View GitHub Profile
@deardorffdev
deardorffdev / _mixins.scss
Created May 28, 2017 11:11
Useful SASS Mixins 1
/* * */
/*----------------[IMPORT VARIABLES]---------------*/
/* * */
/*
Push auto
To quickly centre a block element without having to worry about if there is any top or bottom margin already applied.
*/
@deardorffdev
deardorffdev / wordpress-functions.php
Last active November 1, 2024 14:17
Useful Wordpress Functions 1
<!-- What is Functions File in WordPress? -->
<!-- Functions file commonly known as functions.php file is a WordPress theme file.
It comes with all free and premium WordPress themes.
The purpose of this file is to allow theme developers to define theme features and functions. This file acts just like a WordPress plugin and can be used to add your own custom code snippets in WordPress.
You would find many of these code snippets on websites like https://deardorffassociatesweb.wordpress.com/ with instructions telling you to add this code in your theme’s functions.php file or a site-specific WordPress plugin.
Now you may be thinking what’s the difference between a site-specific WordPress plugin and functions.php file? Which one is better?
//JS Snippets
// Gets the browser prefix
var browserPrefix;
navigator.sayswho= (function(){
var N = navigator.appName, ua = navigator.userAgent, tem;
var M = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if(M && (tem = ua.match(/version\/([\.\d]+)/i))!= null) M[2] = tem[1];
M = M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
M = M[0];
@deardorffdev
deardorffdev / wp-snippets.php
Created May 10, 2017 18:31 — forked from matiskay/wp-snippets.php
Wordpress Snippets
<?php
// http://johnford.is/programmatically-pull-attachments-from-wordpress-posts/
// http://www.wprecipes.com/how-to-show-wordpress-post-attachments
// get all of the images attached to the current post
function _get_images($size = 'thumbnail') {
global $post;
$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
@deardorffdev
deardorffdev / wp-snippets.php
Created May 10, 2017 18:31 — forked from j-mccarthy/wp-snippets.php
Useful Wordpress Snippets
<?php
// Get the_content by post id
echo apply_filters('the_content', get_post_field('post_content', $post_id));
// Featured Image display
$attr = array(
'src' => $src,
'class' => "attachment-$size",
'alt' => trim(strip_tags( $wp_postmeta->_wp_attachment_image_alt )),
@deardorffdev
deardorffdev / admin.php
Created May 10, 2017 18:30 — forked from baptistebriel/admin.php
[WordPress] - Collection of WordPress Snippets
<?php
// Show something only if the user is logged / admin.
// To be used in the current theme files - front.
if (current_user_can('manage_options')){ ?>
<div class="work">
<div class="work_layer">
<div class="device-content row">
<div class="work_content right">
<span class="f_13 uppercase sub_title">Web</span>