gde_get_options
Get the current options, upgrading or resetting them as needed.
Description
(array) gde_get_options();
Returns (array)
Current value of gde_options
Usage
if ( !function_exists( 'gde_get_options' ) ) { require_once ABSPATH . PLUGINDIR . 'google-doc-embedder/libs/lib-setup.php'; } // NOTICE! Understand what this does before running. $result = gde_get_options();
Defined (1)
The function is defined in the following location(s).
- /libs/lib-setup.php
- function gde_get_options() {
- $defopts = gde_defaults('options');
- if ( ! $gdeoptions = get_option('gde_options') ) {
- // options don't exist
- gde_dx_log("Writing default options");
- update_option('gde_options', $defopts);
- } else {
- // check if upgrading from < 2.5
- if ( isset( $gdeoptions['default_width'] ) ) {
- gde_dx_log("Old options found - resetting");
- $defopts['upgraded'] = "yes";
- update_option('gde_options', $defopts);
- } else {
- gde_dx_log("Options already exist");
- // check or upgrade options
- $updated = false;
- foreach ( $defopts as $k => $v ) {
- if ( ! array_key_exists( $k, $gdeoptions ) ) {
- $gdeoptions[$k] = $v;
- //gde_dx_log("New option $k added");
- $updated = true;
- }
- }
- if ( $updated ) {
- gde_dx_log('Options were updated');
- update_option('gde_options', $defopts);
- }
- // set API key if empty (ie., failed on earlier attempt or first upgrade)
- if ( empty( $gdeoptions['api_key'] ) && ! empty( $apikey ) ) {
- $gdeoptions['api_key'] = $apikey;
- gde_dx_log("Updated API Key");
- update_option( 'gde_options', $gdeoptions );
- }
- }
- }
- return $gdeoptions;
- }