Skip to content

Instantly share code, notes, and snippets.

View duplaja's full-sized avatar

Dan D. duplaja

  • Central US
View GitHub Profile
@duplaja
duplaja / Encrypt_Decrypt_WP_Options.php
Last active May 22, 2019 02:43
Encrypt / Decrypt WP Options on Save (API keys, etc)
<?php
//Registers the pre_update_option filter for elements to encrypt. Format pre_update_option_(option name)
//Only do this for ones you want encrypted... in this case, first and third options.
function yourplugin_init() {
add_filter( 'pre_update_option_your_first_option', 'yourplugin_update_option', 10, 2 );
add_filter( 'pre_update_option_your_third_option', 'yourplugin_update_option', 10, 2 );
}
add_action( 'init', 'yourplugin_init' );
@duplaja
duplaja / get-field-value-last-entry.php
Last active May 22, 2019 02:50
Get last Gravity Forms Entry Value
<?php
//Form ID
$form_id = 1;
//Field ID
$field_id = 1;
//Pulls only the most recent entry
$paging = array( 'offset' => 0, 'page_size' => 1 );
@duplaja
duplaja / convert-guest-to-logged-in.php
Last active May 22, 2019 02:56
Convert Guest Orders to Logged In
<?php
//Runs on User Registration
add_action( 'user_register', 'wc_map_guest_initial_match_past_orders', 10, 1 );
function wc_map_guestinitial_match_past_orders( $user_id ) {
//Get current users's e-mail from ID
$current_user = get_user_by( 'ID', $user_id );
$email = $current_user->user_email;
@duplaja
duplaja / wp-privacy.php
Created January 12, 2017 17:57 — forked from mattyrob/wp-privacy.php
Stop WordPress auto-updates and control information shared with api.wordpress.org
<?php
// you'll have to put a plugin header here
// Stop auto updated in WordPress 3.7+
add_filter( 'auto_update_core', '__return_false' );
add_filter( 'auto_update_plugin', '__return_false' );
add_filter( 'auto_update_theme', '__return_false' );
add_filter( 'auto_update_translation', '__return_false' );
// stop translation updates when updating plugins or themes