Skip to content

Instantly share code, notes, and snippets.

View j-mccarthy's full-sized avatar
💭
passing by

John McCarthy j-mccarthy

💭
passing by
  • flowethic
  • United Kingdom
View GitHub Profile
@j-mccarthy
j-mccarthy / wp-snippets.php
Last active May 10, 2017 18:31
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 )),
@j-mccarthy
j-mccarthy / Woocommerce-snippets.php
Last active December 11, 2022 08:16
Woo commerce Snippets
<?php
// Change the add to cart text on product archives
add_filter( 'add_to_cart_text', 'woo_custom_cart_button_text' ); // < 2.1
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_cart_button_text' ); // 2.1 +
function woo_custom_cart_button_text() {
return __( 'My Button Text', 'woocommerce' );
}
@j-mccarthy
j-mccarthy / CSSSnippets.css
Last active August 29, 2015 13:57
CSS Snippets
.centerimgindiv {
margin-left: auto;
margin-right: auto;
display:block;
}
/*No Wrap Floats!!!*/
p {
overflow:hidden;
}
<!-- Open New window onclick Javasript method -->
<a href="http://chriscoyier.net" onclick="window.open(this.href); return false;" onkeypress="window.open(this.href); return false;">This link will open in new window/tab</a>
<!-- Open New window onclick HTML5 method -->
<a href="http://chriscoyier.net" target="_blank">This link will open in new window/tab</a>
@j-mccarthy
j-mccarthy / wp-functionssnippets.php
Last active August 29, 2015 13:58
Wordpress Functions Snippets
<?php
// re-order child style
function src_reorder_child_style() {
wp_dequeue_style( 'responsive-style-css' );
wp_deregister_style( 'responsive-style-css');
wp_enqueue_style( 'child-style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'src_reorder_child_style', 20 );
{
"name": "MyProject",
"version": "1.0.0",
"dependencies": {
"gulp": "*",
"gulp-ruby-sass": "*",
"gulp-util": "*",
"gulp-rename": "*",
"map-stream": "*",
"gulp-livereload": "*",
@j-mccarthy
j-mccarthy / gulpfile.js
Last active August 29, 2015 14:08 — forked from franksmule/gulpfile.js
Gulp Files
//*********** IMPORTS *****************
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var gutil = require('gulp-util');
var rename = require("gulp-rename");
var map = require("map-stream");
var livereload = require("gulp-livereload");
var concat = require("gulp-concat");
var uglify = require('gulp-uglify');
var watch = require('gulp-watch');
<?php
/**
* Adding Html Blocks in Genesis Hooks
*
* @package Genese Gists
* @since 0.0.1
* @link
* @author John McCarthy <john@studio-momentum.co.uk>
* @copyright Copyright (c) 2014, John McCarthy
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
<?php
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
<?php // <- Remove <?php if your using this snippet
// Register New Layout
function jm_custom_layout() {
genesis_register_layout( 'layout-name', array(
'label' => __('custom/layout/name', 'genesis'),
'img' => get_bloginfo('stylesheet_directory') . '/images/yourlayout.gif'
) );
}
add_action( 'init', 'jm_custom_layout' );