Skip to content

Instantly share code, notes, and snippets.

View kenmasters's full-sized avatar

Ken John Siosan kenmasters

View GitHub Profile
@kenmasters
kenmasters / CSS: Disabled buttons
Last active March 16, 2018 16:25
Disabled Button html/css
# Style rule for disabling any button
# added class and attribute `disabled`
input[type="submit"].disabled,
input[type="submit"].disabled:hover {
background-color: #eaeaea;
cursor: no-drop;
}
function clean($string) {
$string = str_replace(' ', '_', $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9_]/', '', $string); // Removes special chars.
return preg_replace('/_+/', '_', $string); // Replaces multiple hyphens with single one.
}
echo clean("HAnn-a Jane##ll f. e"); // HAnna_Janell_f_e
@kenmasters
kenmasters / Genesis - Footer Widgets
Last active December 19, 2017 06:01
Moving Footer widgets + Header and Footer outside Site Container in Executive Pro (Genesis)
@kenmasters
kenmasters / GFORM: Change Currency
Last active June 30, 2019 21:03
Gravity Forms PayPal Standard Add-On
/**
* Change payment currency base from another field, when specific form is submitted.
*/
add_action( 'gform_pre_submission_2', 'change_currency_' );
function change_currency_( $form ) {
add_filter( 'gform_currency', function() { return rgpost('input_4'); } );
}
@kenmasters
kenmasters / GFORM: Product Order Summary
Last active December 7, 2017 02:03
Option to remove or show product order summary when using {all_fields} merge tag
# Docs: https://docs.gravityforms.com/gform_display_product_summary/
# Disable for all forms
add_filter( 'gform_display_product_summary', '__return_false' );
# Disable for a specific form
add_filter( 'gform_display_product_summary', function( $display_product_summary, $field, $form, $entry ) {
return $form['id'] == 10 ? false : $display_product_summary;
}, 10, 4 );
@kenmasters
kenmasters / Common-Currency.json
Created December 8, 2017 03:55 — forked from ksafranski/Common-Currency.json
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
@kenmasters
kenmasters / GFORM: GFAPI::get_entries + pagination
Created March 16, 2018 16:19
List gravityform entries using GFAPI class + pagination
# http://inlinedocs.gravityhelp.com/class-GFAPI.html
# https://docs.gravityforms.com/getting-started-with-the-gravity-forms-api-gfapi/
# working code
# notes: we are to going to lists submitted entries of the current loggedin user.
$form_ids = [19, 20, 21, 22, 23, 24, 25, 26]; // accepts single or array of form id's.
$search_criteria = array(
'field_filters' => array(
'mode' => 'any',
#
add_action( 'init', 'gta_rewrite_add_rewrites' );
function gta_rewrite_add_rewrites()
{
add_rewrite_rule('agent/?([^/]*)', 'index.php?pagename=agent&agentID=$matches[1]', 'top');
}
add_filter('query_vars', 'gta_query_vars');
# References:
# https://docs.gravityforms.com/dynamically-populating-drop-down-fields/
# https://docs.gravityforms.com/gf_field_select/
add_filter( 'gform_pre_render_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_pre_validation_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_pre_submission_filter_45', 'disable_ADA_ACA_transactions' );
add_filter( 'gform_admin_pre_render_45', 'disable_ADA_ACA_transactions' );
function disable_ADA_ACA_transactions( $form ) {
add_filter( 'edit_profile_url', 'custom_profile_url', 10, 3 );
function custom_profile_url( $url, $user_id, $scheme ) {
if ( !current_user_can('subscriber') ) return;
return '';
}
# IMPORTANT NOTES: What the function does above is removing the link on the Edit Profile if the current loggedin user role is `subscriber`.