Skip to content

Instantly share code, notes, and snippets.

View mauriciogofas's full-sized avatar

Mauricio Gofas mauriciogofas

View GitHub Profile
@mauriciogofas
mauriciogofas / my_init_email_as_username.php
Last active August 29, 2015 14:16 — forked from strangerstudios/my_init_email_as_username.php
Use the email address as username with PMPro checkout. You'll also have to hide the username fields at checkout using CSS or a custom checkout page template.
<?php
function my_init_email_as_username()
{
//check for level as well to make sure we're on checkout page
if(empty($_REQUEST['level']))
return;
if(!empty($_REQUEST['bemail']))
$_REQUEST['username'] = $_REQUEST['bemail'];
@mauriciogofas
mauriciogofas / add-capability.php
Last active August 29, 2015 14:16 — forked from jgalea/add-capability.php
Adds a capability to an existing role
<?php
function add_capability() {
// gets the author role
$role = get_role( 'author' );
// This only works, because it accesses the class instance.
$role->add_cap( 'edit_others_posts' );
}
add_action( 'admin_init', 'add_capability');
@mauriciogofas
mauriciogofas / rrwd_upload_dir.php
Last active August 29, 2015 14:15 — forked from rianrietveld/rrwd_upload_dir.php
Add custom post type name to upload directory WordPress
<?php
/**
* Change Upload Directory for one Custom Post-Type
* Author: https://gist.github.com/RRWD/8705908
* This will change the upload directory for a custom post-type. Attachments for this custom post type will
* now be uploaded to a seperate "uploads" directory. Make
* sure you swap out "post-type" and the "my-dir" with the appropriate values...
* credits to: http://wordpress.stackexchange.com/users/4044/jhdenham
* and http://yoast.com/smarter-upload-handling-wp-plugins/
*/
@mauriciogofas
mauriciogofas / test.php
Last active August 29, 2015 14:15 — forked from raewrites/test.php
Display Post and Page IDs in the WordPress Admin
// fonte: http://premium.wpmudev.org/blog/display-wordpress-post-page-ids/
add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_content', 5, 2 );
function revealid_add_id_column( $columns ) {
$columns['revealid_id'] = 'ID';
return $columns;
}
<?php
function auto_send_invoice_after_creation( $invoice_id ) {
$invoice = SI_Invoice::get_instance( $invoice_id );
$client = $invoice->get_client();
$client_users = $client->get_associated_users();
if ( !empty( $client_users ) ) {
do_action( 'send_invoice', $invoice, $client_users );
}
}
@mauriciogofas
mauriciogofas / gw-gravity-forms-map-fields-to-field.php
Last active August 29, 2015 14:14 — forked from spivurno/gw-gravity-forms-map-fields-to-field.php
Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
<?php
/**
* Gravity Wiz // Gravity Forms // Map Submitted Field Values to Another Field
*
* Preview your Gravity forms on the frontend of your website. Adds a "Live Preview" link to the Gravity Forms toolbar.
*
* Usage
*
* 1 - Enable "Allow field to be populated dynamically" option on field which should be populated.
* 2 - In the "Parameter Name" input, enter the merge tag (or merge tags) of the field whose value whould be populated into this field.
@mauriciogofas
mauriciogofas / revoke-profile-access.php
Last active August 29, 2015 14:14 — forked from gmazzap/revoke-profile-access.php
Revoke WP Profile Access
<?php
/**
* Plugin Name: Revoke Profile Access
* Description: Allow administrators to revoke access to profile to some users
* Plugin URI: http://wordpress.stackexchange.com/q/141743/
* Author: G. M.
* Author URI: http://wordpress.stackexchange.com/users/35541/g-m
* License: GPLv2
*
*/
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Modify client dashboard date format in Sprout Invoices
<?php
function change_client_dash_date_format() {
return 'd/m/Y';
}
add_filter( 'si_client_dash_date_format', 'change_client_dash_date_format' );
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Default Money Formatting for the BR in Sprout Invoices
<?php
// Brazilian money simbol in Sprout Invoices
function set_br_reais_localeconv( $locale = array() ) {
$locale = array(
'decimal_point' => '.',
'thousands_sep' => '',
'int_curr_symbol' => 'BRL',
'currency_symbol' => 'R$',
'mon_decimal_point' => ',',
'mon_thousands_sep' => '.',
@mauriciogofas
mauriciogofas / functions.php
Last active August 29, 2015 14:14 — forked from dancameron/functions.php
Custom States and Countries for Sprout Invoices
<?php
/**
* This function file is loaded after the parent theme's function file. It's a great way to override functions, e.g. add_image_size sizes.
*
*
*/
function custom_states() {
return array(