Skip to content

Instantly share code, notes, and snippets.

@roscabgdn
roscabgdn / category-to-body-class.php
Created January 27, 2016 11:50
WordPress - add category class to body class
add_filter( 'body_class', 'body_class_example' );
function body_class_example( $classes ) {
if( is_single() ) {
foreach( get_the_category( get_the_ID() ) as $category )
$classes[] = 'cat-' . $category->category_nicename;
}
return $classes;
}
@roscabgdn
roscabgdn / htaccess-file.txt
Last active January 27, 2016 15:08
WordPress .htaccess
# WP Security
# PROTECTING DIRECTORIES
Options -Indexes
#IndexIgnore *.php
# WHITELISTING IP ADDRESSES
<Files wp-login.php>
#Order Deny,Allow
#Deny from all
# Allow access via this IP address
/*
* @seen on https://css-tricks.com/snippets/sass/centering-mixin/
*/
@mixin center($horizontal: true, $vertical: true) {
position: absolute;
@if ($horizontal and $vertical) {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
// Title Border
// Apply a short border beneath a title
// Usage @mixin title-border(color);
@mixin title-border($color, $height, $width, $position) {
@if $position == center {
$position: 0 auto;
} @else {
$position: 0;
// ------------------------------------------------------------
// Font Stacks
// ------------------------------------------------------------
// Example Font Stack Usage
// @include font(light);
// @include font(body);
// @include font(medium);
// @include font(semibold);
// @include font(bold);
/*
About: CSS (SCSS) Tooltips
Author: https://twitter.com/_uloga
*/
$success: #2AA583 !default;
$info: #15a3ff !default;
$warning: #F3AB44 !default;
$danger: #EE4D3B !default;
@roscabgdn
roscabgdn / gist:768535bad068c21ce8f6
Created March 8, 2016 09:55
Change the "Proceed to PayPal" button text in the WooCommerce checkout screen
/*
* Change the "Proceed to PayPal" button text in the WooCommerce checkout screen
*/
add_filter( 'gettext', 'rb_custom_paypal_button', 20, 3 );
function rb_custom_paypal_button( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Proceed to PayPal' :
$translated_text = __( 'Your new Paypal button text here', 'woocommerce' );
break;
}
@roscabgdn
roscabgdn / woocommerce_product_tabs
Created March 11, 2016 08:36
Removing Tabs WooCommerce
add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs['description'] ); // Remove the description tab
unset( $tabs['reviews'] ); // Remove the reviews tab
unset( $tabs['additional_information'] ); // Remove the additional information tab
return $tabs;
@roscabgdn
roscabgdn / woo_rename_tabs
Created March 11, 2016 08:37
Renaming Tabs WooCommerce
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab
return $tabs;
}