/** * Update an option * * Updates an mdjm setting value in both the db and the global variable. * Warning: Passing in an empty, false or null string value will remove * the key from the mdjm_options array. * * @since 1.3 * @param string $key The Key to update * @param string|bool|int $value The value to set the key to * @return boolean True if updated, false if not. */ function mdjm_update_option($key = '', $value = false) { // If no key, exit if (empty($key)) { return false; } if (empty($value)) { $remove_option = mdjm_delete_option($key); return $remove_option; } // First let's grab the current settings $options = get_option('mdjm_settings'); // Let's let devs alter that value coming in $value = apply_filters('mdjm_update_option', $value, $key); $value = apply_filters("mdjm_update_option_{$key}", $value); // Next let's try to update the value $options[$key] = $value; $did_update = update_option('mdjm_settings', $options); // If it updated, let's update the global variable if ($did_update) { global $mdjm_options; $mdjm_options[$key] = $value; } return $did_update; }
/** * Run the update procedures. * * @version 1.3.8 * @param * @return. */ function mdjm_run_update_138() { $payment_label = __('Pay Now', 'mobile-dj-manager'); $gateway = mdjm_get_option('payment_gateway', false); if (!empty($gateway)) { if ($gateway == 'paypal') { $button_text = mdjm_get_option('mdjm_pg_paypal_button_text'); } if ($gateway == 'payfast') { $button_text = mdjm_get_option('mdjm_pg_payfast_button_text'); } if (!empty($button_text)) { $payment_label = sanitize_text_field($button_text); } } mdjm_delete_option('payment_gateway'); mdjm_update_option('payment_gateway', $gateway); mdjm_update_option('gateways', array($gateway => '1')); mdjm_update_option('payment_button', $payment_label); }
/** * Fires when a playlist category is created or edited. * * Check whether the set as default option is set and update options. * * @since 1.3 * @param int $term_id The term ID * @param int $tt_id The term taxonomy ID * @return str */ function mdjm_save_playlist_category($term_id, $tt_id) { if (!empty($_POST['playlist_default_cat'])) { mdjm_update_option('playlist_default_cat', $term_id); } else { if (mdjm_get_option('playlist_default_cat') == $term_id) { mdjm_delete_option('playlist_default_cat'); } } }