Skip to content

Instantly share code, notes, and snippets.

View brianpurkiss's full-sized avatar

Brian Purkiss brianpurkiss

View GitHub Profile
@brianpurkiss
brianpurkiss / seo-optimized-title.php
Last active August 29, 2015 14:10
A dynamic <title> tag for WordPress that is SEO optimized.
<title><?php if ( is_category() ) {
echo 'Category Archive for &quot;'; single_cat_title(); echo '&quot; | '; bloginfo( 'name' );
} elseif ( is_tag() ) {
echo 'Tag Archive for &quot;'; single_tag_title(); echo '&quot; | '; bloginfo( 'name' );
} elseif ( is_archive() ) {
wp_title(''); echo ' Archive | '; bloginfo( 'name' );
} elseif ( is_search() ) {
echo 'Search for &quot;'.wp_specialchars($s).'&quot; | '; bloginfo( 'name' );
} elseif ( is_home() || is_front_page() ) {
bloginfo( 'name' ); echo ' | '; bloginfo( 'description' );
@brianpurkiss
brianpurkiss / .gitignore
Last active October 3, 2016 21:43 — forked from octocat/.gitignore
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@brianpurkiss
brianpurkiss / sample-sass-gulpfule.js
Created July 6, 2016 16:27
This gulp file's primary purpose is SASS compiling. It includes an auto compressor, prefixer, and watcher.
'use strict';
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
// primary gulp build
gulp.task('sass', function () {
@brianpurkiss
brianpurkiss / shortcode.php
Created October 11, 2017 16:01
Bootstrap 4 Card WordPress Shortcode
<?php
function bootstrap_card( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => '300px',
'img' => '',
'title' => '',
'alt' => ''
), $atts )
);
@brianpurkiss
brianpurkiss / Gravity Forms + Bootstrap 4
Last active April 7, 2022 13:21 — forked from kirandash/Gravity Forms + Bootstrap
Helpful function for adding Bootstrap 4 classes to Gravity Forms fields.
<?php
/**
* Gravity Forms Bootstrap Styles
*
* Applies bootstrap classes to various common field types.
* Requires Bootstrap to be in use by the theme.
*
* Using this function allows use of Gravity Forms default CSS
* in conjuction with Bootstrap (benefit for fields types such as Address).
*
@brianpurkiss
brianpurkiss / bs_wp_pagination.php
Created August 9, 2018 13:43
Plugin free numbered pagination for WordPress, uses Bootstrap styles
function numbered_pagination($pages = '', $range = 2) {
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
@brianpurkiss
brianpurkiss / favicon.php
Created December 27, 2018 19:03
Adding a favicon to WordPress through functions
<?php
// Setup favicon call
function add_favicon() {
$favicon_url = get_stylesheet_directory_uri() . '/library/images/favicon.png';
echo '<link rel="shortcut icon" href="' . $favicon_url . '" />';
}
// Adds favicon to WP Frontend and WP Dashboard
@brianpurkiss
brianpurkiss / google-fonts.php
Created December 27, 2018 19:33
Adding Google Fonts to WordPress functions
<?php
//
// Add and optimize Google Fonts
//
// Add Google Fonts
// Enqueue google api webfont
function mod_fonts_enqueue() {
@brianpurkiss
brianpurkiss / gutenberg-sample-content.html
Last active January 20, 2023 05:04 — forked from mailenkno/gutenberg-sample-content.html
WordPress Gutenberg Sample Content
<!-- wp:heading {"level":1} -->
<h1>This is a heading (H1)</h1>
<!-- /wp:heading -->
<!-- wp:heading -->
<h2>This is a heading (H2)</h2>
<!-- /wp:heading -->
<!-- wp:heading {"level":3} -->
<h3>This is a heading (H3)</h3>
@brianpurkiss
brianpurkiss / remove_woocommerce_actions
Created January 31, 2019 23:23
Remove a WooCommerce Action
// Add the action
add_action('init','sample_remove_product_meta');
// Declare the function
function sample_remove_product_meta() {
remove_action('woocommerce_single_product_summary','woocommerce_template_single_meta',40);
}
// First item in remove_action is the hook
// Second item in remove_action is what was hooked