Skip to content

Instantly share code, notes, and snippets.

View mauriciogofas's full-sized avatar

Mauricio Gofas mauriciogofas

View GitHub Profile
@mauriciogofas
mauriciogofas / copy-files.php
Last active November 18, 2015 01:14
#php - copy all files (recursive) in a directory to another
<?php
// function definition
// copy a directory and its contents
function copyTree($source, $destination) {
if (file_exists($source)) {
// create source pointer
$dp = opendir($source) or die ('ERROR: Cannot open directory');
// if destination directory does not exist
// create it
@mauriciogofas
mauriciogofas / copy-files.php
Last active October 27, 2015 02:20
#PHP - copy all files (not recursive) in a directory to another
<?php
$src = '/home/username/public_html/'; // Caminho absoluto da origem, mas tb pode ser um caminho relativo a pasta onde está sendo executado o script
$dst = 'beta/'; // Caminho relativo a pasta onde está sendo executado o script
$files = glob("/home/username/public_html/*.*"); // Nome global para os arquivos
foreach($files as $file){
$file_to_go = str_replace($src,$dst,$file);
copy($file, $file_to_go);
}
?>
@mauriciogofas
mauriciogofas / header.php
Last active October 23, 2015 18:45
Multiple header images based on page, post type, loop type, category and/or featured image. (Categories Images generated by https://wordpress.org/plugins/categories-images/)
<?php if ( is_front_page() ) : ?>
<?php elseif ( is_post_type_archive( 'videos' )) : ?>
<!-- Imagem do cabeçalho no loop de VÍDEOS -->
<?php if (function_exists('z_taxonomy_image_url')) : ?>
<div style="background: url(<?php echo z_taxonomy_image_url('1'); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php else : ?>
<div style="background: url(<?php echo wp_get_attachment_url(get_post_thumbnail_id()); ?>) no-repeat top left; width:100%; height:300px;background-size: cover;"></div>
<?php endif ?>
@mauriciogofas
mauriciogofas / functions.php
Created October 20, 2015 19:12
Custom post type Loop
<?php $rand_posts = get_posts('numberposts=1&post_type=videos');
foreach ($rand_posts as $post) :?>
<a style="text-decoration:none; position:relative;" href="<?php the_permalink(); ?>">
<h2 class="public-thumb"><?php the_title();?></h2>
<?php echo the_post_thumbnail( 'large' , 'class=home-thumb' ); ?>
</a>
<?php endforeach; ?>
@mauriciogofas
mauriciogofas / 0_reuse_code.js
Created October 2, 2015 15:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mauriciogofas
mauriciogofas / functions.php
Last active October 2, 2015 15:26
Add info/field to woocommerce_email_after_order_table
add_action( 'woocommerce_email_after_order_table', 'wc_add_payment_type_to_emails', 15, 2 );
function wc_add_payment_type_to_emails( $order, $is_admin_email ) {
echo '<p><strong>Forma de pagamento:</strong> ' . $order->payment_method_title . '</p>';
}
@mauriciogofas
mauriciogofas / functions.php
Created October 2, 2015 14:47
//Gravity forms - limit entries
//Gravity forms - limite de entradas
class GWLimitBySum {
private $_args;
function __construct($args) {
$this->_args = wp_parse_args($args, array(
'form_id' => false,
@mauriciogofas
mauriciogofas / wpfcwc.conf
Last active October 1, 2015 00:54 — forked from pelmered/wpfcwc.conf
EasyEngine WooCommerce config with FastCGI Cache
#
set $skip_cache 0;
# POST requests and URL with a query string should always go to php
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
@mauriciogofas
mauriciogofas / gofas-smtp.php
Last active September 29, 2015 19:39
Replace wp_mail() function for your SMTP mail config
<?php
/*
Plugin Name: Gofas Multisite SMTP
Plugin URI: https://www.gofas.com.br
Description: wp_mail() is SMTP Mail
Author: Muricio Gofas
Author URI: https://www.gofas.com.br
Version: 0.1
*/
add_action( 'phpmailer_init', 'my_phpmailer_example' );
@mauriciogofas
mauriciogofas / gist:884566ed02f89af821d6
Created September 29, 2015 17:40 — forked from mikejolley/gist:9b82e46548301c192aa0
ShareDaddy integration code for WooCommerce
function sharedaddy_for_woocommerce() {
?>
<div class="social"><?php echo sharing_display(); ?></div>
<?php
}
add_action( 'woocommerce_share', 'sharedaddy_for_woocommerce' );