Skip to content

Instantly share code, notes, and snippets.

Avatar

César Ribeiro chrdesigner

View GitHub Profile
@chrdesigner
chrdesigner / functions.php
Last active Aug 29, 2015
allow AED for WooCommerce
View functions.php
<?php
// allow AED for WooCommerce
add_filter( 'woocommerce_paypal_supported_currencies', 'paypal_aed_current' );
function paypal_aed_current($currency_array) {
$currency_array[] = 'AED';
return $currency_array;
}
@chrdesigner
chrdesigner / functions.php
Created Jun 17, 2015
Custom single post format template
View functions.php
<?php
/**
* Custom single post format template
* Reference: https://codex.wordpress.org/Function_Reference/get_post_format
*/
function chr_custom_single_post_format( $template ) {
if ( is_single() && has_post_format() ) {
$post_format_template = locate_template( 'single-' . get_post_format() . '.php' );
if ( $post_format_template ) {
$template = $post_format_template;
@chrdesigner
chrdesigner / main.js
Created Jul 20, 2015
Vertical Align with jQuery
View main.js
$(function() {
$('.classVerticalAlign').css({
'position' : 'absolute',
'left' : '50%',
'top' : '50%',
'margin-left' : -$('.classVerticalAlign').outerWidth()/2,
'margin-top' : -$('.classVerticalAlign').outerHeight()/2
});
});
@chrdesigner
chrdesigner / functions.php
Last active Aug 29, 2015
Function Remove Special Characters and Convert Text in Lowercase
View functions.php
<?php
/*
* Function Remove Special Characters and Convert Text in Lowercase
*/
function chrConvertText($text) {
$transliterationTable = array('á' => 'a', 'Á' => 'A', 'à' => 'a', 'À' => 'A', 'ă' => 'a', 'Ă' => 'A', 'â' => 'a', 'Â' => 'A', 'å' => 'a', 'Å' => 'A', 'ã' => 'a', 'Ã' => 'A', 'ą' => 'a', 'Ą' => 'A', 'ā' => 'a', 'Ā' => 'A', 'ä' => 'ae', 'Ä' => 'AE', 'æ' => 'ae', 'Æ' => 'AE', 'ḃ' => 'b', 'Ḃ' => 'B', 'ć' => 'c', 'Ć' => 'C', 'ĉ' => 'c', 'Ĉ' => 'C', 'č' => 'c', 'Č' => 'C', 'ċ' => 'c', 'Ċ' => 'C', 'ç' => 'c', 'Ç' => 'C', 'ď' => 'd', 'Ď' => 'D', 'ḋ' => 'd', 'Ḋ' => 'D', 'đ' => 'd', 'Đ' => 'D', 'ð' => 'dh', 'Ð' => 'Dh', 'é' => 'e', 'É' => 'E', 'è' => 'e', 'È' => 'E', 'ĕ' => 'e', 'Ĕ' => 'E', 'ê' => 'e', 'Ê' => 'E', 'ě' => 'e', 'Ě' => 'E', 'ë' => 'e', 'Ë' => 'E', 'ė' => 'e', 'Ė' => 'E', 'ę' => 'e', 'Ę' => 'E', 'ē' => 'e', 'Ē' => 'E', 'ḟ' => 'f', 'Ḟ' => 'F', 'ƒ' => 'f', 'Ƒ' => 'F', 'ğ' => 'g', 'Ğ' => 'G', 'ĝ' => 'g', 'Ĝ' => 'G', 'ġ' => 'g', 'Ġ' => 'G', 'ģ' => 'g', 'Ģ' => 'G', 'ĥ' => 'h', 'Ĥ' => 'H', 'ħ' =
View functions.php
<?php
/**
* Remove Widget Product Gallery - WooCommerce
*/
add_action( 'add_meta_boxes' , 'chr_remove_meta_boxe', 40 );
function chr_remove_meta_boxe(){
remove_meta_box( 'woocommerce-product-images', 'product', 'side');
}
@chrdesigner
chrdesigner / functions.php
Created Aug 11, 2015
Add wysija shortcode after the_content
View functions.php
<?php
/*
* Add wysija shortcode after the_content
*/
add_filter( 'the_content', 'chr_add_after_content' );
function chr_add_after_content( $content ) {
if( is_single() ) :
$custom_content .= $content;
$custom_content .= '<h2 class="widgettitle">Newsletter</h2>';
View functions.php
<?php
/*
* Add Stock Quantity in Catalog Loop
*/
function odin_stock_catalog() {
global $product;
if ( $product->is_in_stock() ) {
echo '<div class="stock" >' . $product->get_stock_quantity() . __( 'EM ESTOQUE', 'odin' ) . '</div>';
} else {
echo '<div class="out-of-stock" >' . __('SEM ESTOQUE', 'odin' ) . '</div>';
@chrdesigner
chrdesigner / functions.php
Created Aug 21, 2015
WordPress - Search in Specific Post Type
View functions.php
<?php
/*
* Search in Specific Post Type
*/
function search_specific_post_type($query) {
if ($query->is_search) {
$query->set('post_type', array('post'));
};
return $query;
};
@chrdesigner
chrdesigner / functions.php
Last active Sep 4, 2015
Function - Disable Checkout for some Countries and States
View functions.php
<?php
/*
* Function - Disable Checkout for some Countries and States
*/
function wc_checkout_validation() {
$shipping_country = ! empty( $_POST['shipping_country'] ) ? $_POST['shipping_country'] : $_POST['billing_country'];
$shipping_state = ! empty( $_POST['shipping_state'] ) ? $_POST['shipping_state'] : $_POST['billing_state'];
// Add here States : More example look here -> wp-content/plugins/woocommerce/i18n/states/
@chrdesigner
chrdesigner / main.js
Created Oct 11, 2015
jQuery: addClass in <html> if size bellow 415
View main.js
var $window = $(window), $html = $('html');
$window.resize(function resize(){
if ($window.width() < 415) {
return $html.addClass('mobile');
}
$html.removeClass('mobile');
}).trigger('resize');
You can’t perform that action at this time.