Overview

Namespaces

  • None
  • Quform
    • Traduttore_Registry

Classes

  • Quform
  • Quform_Admin_InsertForm
  • Quform_Admin_Page
  • Quform_Admin_Page_Controller
  • Quform_Admin_Page_Dashboard
  • Quform_Admin_Page_Entries
  • Quform_Admin_Page_Entries_Edit
  • Quform_Admin_Page_Entries_List
  • Quform_Admin_Page_Entries_View
  • Quform_Admin_Page_Factory
  • Quform_Admin_Page_Forms_Add
  • Quform_Admin_Page_Forms_Edit
  • Quform_Admin_Page_Forms_List
  • Quform_Admin_Page_Help
  • Quform_Admin_Page_Preview
  • Quform_Admin_Page_Settings
  • Quform_Admin_Page_Tools
  • Quform_Admin_Page_Tools_ExportEntries
  • Quform_Admin_Page_Tools_ExportForm
  • Quform_Admin_Page_Tools_Home
  • Quform_Admin_Page_Tools_ImportForm
  • Quform_Admin_Page_Tools_Migrate
  • Quform_Admin_Page_Tools_Uninstall
  • Quform_Api
  • Quform_Block
  • Quform_Builder
  • Quform_Captcha
  • Quform_ClassLoader
  • Quform_Confirmation
  • Quform_Container
  • Quform_Dashboard_Widget
  • Quform_Dispatcher
  • Quform_Element
  • Quform_Element_Captcha
  • Quform_Element_Checkbox
  • Quform_Element_Column
  • Quform_Element_Container
  • Quform_Element_Container_Iterator
  • Quform_Element_Date
  • Quform_Element_Email
  • Quform_Element_Factory
  • Quform_Element_Field
  • Quform_Element_File
  • Quform_Element_Group
  • Quform_Element_Hidden
  • Quform_Element_Honeypot
  • Quform_Element_Html
  • Quform_Element_Multi
  • Quform_Element_Multiselect
  • Quform_Element_Name
  • Quform_Element_Page
  • Quform_Element_Password
  • Quform_Element_Radio
  • Quform_Element_Recaptcha
  • Quform_Element_Row
  • Quform_Element_Select
  • Quform_Element_Submit
  • Quform_Element_Text
  • Quform_Element_Textarea
  • Quform_Element_Time
  • Quform_Entry_Controller
  • Quform_Entry_Exporter
  • Quform_Entry_List_Settings
  • Quform_Entry_List_Table
  • Quform_Entry_Processor
  • Quform_Entry_UserSearcher
  • Quform_Filter_Abstract
  • Quform_Filter_Alpha
  • Quform_Filter_AlphaNumeric
  • Quform_Filter_Digits
  • Quform_Filter_Regex
  • Quform_Filter_Static
  • Quform_Filter_StripTags
  • Quform_Filter_Trim
  • Quform_Form
  • Quform_Form_Controller
  • Quform_Form_Exporter
  • Quform_Form_Factory
  • Quform_Form_Importer
  • Quform_Form_Iterator
  • Quform_Form_List_Settings
  • Quform_Form_List_Table
  • Quform_Form_Processor
  • Quform_License
  • Quform_Migrator
  • Quform_NonceRefresher
  • Quform_Notification
  • Quform_Notification_Resender
  • Quform_Options
  • Quform_Permissions
  • Quform_Repository
  • Quform_ScriptLoader
  • Quform_Session
  • Quform_Settings
  • Quform_Shortcode
  • Quform_Themes
  • Quform_TokenReplacer
  • Quform_Toolbar
  • Quform_Translations
  • Quform_Updater
  • Quform_Upgrader
  • Quform_Uploader
  • Quform_Validator_Abstract
  • Quform_Validator_Alpha
  • Quform_Validator_AlphaNumeric
  • Quform_Validator_Array
  • Quform_Validator_Captcha
  • Quform_Validator_Date
  • Quform_Validator_Digits
  • Quform_Validator_Duplicate
  • Quform_Validator_Email
  • Quform_Validator_FileUpload
  • Quform_Validator_GreaterThan
  • Quform_Validator_Honeypot
  • Quform_Validator_Identical
  • Quform_Validator_InArray
  • Quform_Validator_Length
  • Quform_Validator_LessThan
  • Quform_Validator_Recaptcha
  • Quform_Validator_Regex
  • Quform_Validator_Required
  • Quform_Validator_Static
  • Quform_Validator_Time
  • Quform_View
  • Quform_ViewFactory
  • Quform_Widget_Form
  • Quform_Widget_Popup

Interfaces

  • Quform_Attachable
  • Quform_Element_Editable
  • Quform_Filter_Interface
  • Quform_Validator_Interface

Constants

  • Quform\Traduttore_Registry\TRANSIENT_KEY_PLUGIN
  • Quform\Traduttore_Registry\TRANSIENT_KEY_THEME

Functions

  • Quform\Traduttore_Registry\add_project
  • Quform\Traduttore_Registry\clean_translations_cache
  • Quform\Traduttore_Registry\get_available_locales
  • Quform\Traduttore_Registry\get_installed_translations
  • Quform\Traduttore_Registry\get_translations
  • Quform\Traduttore_Registry\register_clean_translations_cache
  • Quform\Traduttore_Registry\sanitize_date
  • Overview
  • Namespace
  • Class
  1: <?php
  2: 
  3: /**
  4:  * @copyright Copyright (c) 2009-2022 ThemeCatcher (https://www.themecatcher.net)
  5:  */
  6: class Quform_Options
  7: {
  8:     /**
  9:      * The key within the wp_options table
 10:      *
 11:      * @var string
 12:      */
 13:     protected $key;
 14: 
 15:     /**
 16:      * The options
 17:      *
 18:      * @var array
 19:      */
 20:     protected $options = array();
 21: 
 22:     public function __construct($key)
 23:     {
 24:         $this->key = $key;
 25: 
 26:         $options = get_option($this->key);
 27: 
 28:         if ( ! is_array($options)) {
 29:             $options = $this->getDefaults();
 30:         }
 31: 
 32:         $this->options = $options;
 33:     }
 34: 
 35:     /**
 36:      * Get the default options
 37:      *
 38:      * @return array
 39:      */
 40:     protected function getDefaults()
 41:     {
 42:         return array(
 43:             'defaultEmailAddress' => get_bloginfo('admin_email'),
 44:             'defaultEmailName' => '',
 45:             'defaultFromEmailAddress' => 'wordpress@' . preg_replace('/^www./', '', Quform::get($_SERVER, 'SERVER_NAME')),
 46:             'defaultFromEmailName' => get_bloginfo('name'),
 47:             'licenseKey' => '',
 48:             'locale' => 'en-US',
 49:             'dateFormatJs' => '',
 50:             'timeFormatJs' => '',
 51:             'dateTimeFormatJs' => '',
 52:             'dateFormat' => '',
 53:             'timeFormat' => '',
 54:             'dateTimeFormat' => '',
 55:             'rtl' => '',
 56:             'recaptchaSiteKey' => '',
 57:             'recaptchaSecretKey' => '',
 58:             'hcaptchaSiteKey' => '',
 59:             'hcaptchaSecretKey' => '',
 60:             'turnstileSiteKey' => '',
 61:             'turnstileSecretKey' => '',
 62:             'customCss' => '',
 63:             'customCssTablet' => '',
 64:             'customCssPhone' => '',
 65:             'customJs' => '',
 66:             'loadScripts' => 'always',
 67:             'loadScriptsCustom' => array(),
 68:             'disabledStyles' => array(
 69:                 'fontAwesome' => false,
 70:                 'select2' => false,
 71:                 'qtip' => false,
 72:                 'fancybox' => false,
 73:                 'fancybox2' => false,
 74:                 'fancybox3' => false,
 75:                 'magnificPopup' => false
 76:             ),
 77:             'disabledScripts' => array(
 78:                 'fileUpload' => false,
 79:                 'scrollTo' => false,
 80:                 'select2' => false,
 81:                 'qtip' => false,
 82:                 'fancybox' => false,
 83:                 'fancybox2' => false,
 84:                 'fancybox3' => false,
 85:                 'magnificPopup' => false,
 86:                 'infieldLabels' => false,
 87:                 'datepicker' => false,
 88:                 'timepicker' => false
 89:             ),
 90:             'combineCss' => true,
 91:             'combineJs' => true,
 92:             'popupEnabled' => false,
 93:             'popupScript' => 'fancybox-2',
 94:             'rawFix' => false,
 95:             'scrollOffset' => '50',
 96:             'scrollSpeed' => '800',
 97:             'allowAllFileTypes' => false,
 98:             'showEditLink' => true,
 99:             'csrfProtection' => true,
100:             'supportPageCaching' => true,
101:             'toolbarMenu' => true,
102:             'dashboardWidget' => true,
103:             'insertFormButton' => true,
104:             'preventFouc' => false,
105:             'secureApiRequests' => true,
106:             'saveEntries' => true,
107:             'saveIpAddresses' => true,
108:             'alwaysShowFullDates' => false,
109:             'referralEnabled' => false,
110:             'referralText' => __('Powered by Quform', 'quform'),
111:             'referralLink' => '',
112:             'activeThemes' => array(),
113:             'activeLocales' => array(),
114:             'activeDatepickers' => array(),
115:             'activeTimepickers' => array(),
116:             'activeEnhancedUploaders' => array(),
117:             'activeEnhancedSelects' => array(),
118:             'activeCustomCss' => array(),
119:             'inactiveCustomCss' => array(),
120:             'cacheBuster' => time()
121:         );
122:     }
123: 
124:     /**
125:      * Save the options
126:      */
127:     protected function update()
128:     {
129:         update_option($this->key, $this->options);
130:     }
131: 
132:     /**
133:      * Get the value opf the option with the given key
134:      *
135:      * If it does not exist the given default will be returned
136:      * If the given default is null it will get the default value for the option
137:      *
138:      * @param   string      $key      The option key
139:      * @param   mixed|null  $default  The default to return if the key does not exist
140:      * @return  mixed
141:      */
142:     public function get($key, $default = null)
143:     {
144:         $value = Quform::get($this->options, $key, $default);
145: 
146:         if ($value === null) {
147:             $value = Quform::get($this->getDefaults(), $key, $default);
148:         }
149: 
150:         return apply_filters("quform_get_option_$key", $value, $default);
151:     }
152: 
153:     /**
154:      * Set the value of the option with the given key and save the options
155:      *
156:      * @param  string|array  $key
157:      * @param  null|mixed    $value
158:      */
159:     public function set($key, $value = null)
160:     {
161:         if (is_array($key)) {
162:             foreach ($key as $k => $v) {
163:                 $this->options[$k] = $v;
164:             }
165:         } else {
166:             $this->options[$key] = $value;
167:         }
168: 
169:         $this->update();
170:     }
171: 
172:     /**
173:      * Get the locale configured in the plugin settings
174:      *
175:      * @return string
176:      */
177:     public function getLocale() {
178:         return apply_filters('quform_locale', $this->get('locale'));
179:     }
180: 
181:     /**
182:      * Formats a date to local time and translates
183:      *
184:      * @param   string        $datetime           A date/time string able to be parsed by DateTime, in the UTC timezone
185:      * @param   boolean       $hideDateIfSameDay  Hides the date and only shows the time if the date is today
186:      * @param   string        $customDateFormat   Specify a custom date format
187:      * @return  string|false                      The formatted date or false if there was an error
188:      */
189:     public function formatDate($datetime, $hideDateIfSameDay = false, $customDateFormat = '')
190:     {
191:         if ( ! Quform::isNonEmptyString($datetime)) {
192:             return '';
193:         }
194: 
195:         try {
196:             $date = new DateTime($datetime, new DateTimeZone('UTC'));
197: 
198:             if (Quform::isNonEmptyString($customDateFormat)) {
199:                 return Quform::date($customDateFormat, $date);
200:             }
201: 
202:             if ($this->get('alwaysShowFullDates')) {
203:                 $hideDateIfSameDay = false;
204:             }
205: 
206:             $today = new DateTime('now', new DateTimeZone('UTC'));
207: 
208:             if ($hideDateIfSameDay && $date->format('Y-m-d') == $today->format('Y-m-d')) {
209:                 $key = 'timeFormat';
210:             } else {
211:                 $key = 'dateTimeFormat';
212:             }
213: 
214:             $format = $this->get($key);
215: 
216:             if ( ! Quform::isNonEmptyString($format)) {
217:                 $locale = Quform::getLocale($this->getLocale());
218:                 $format = $locale[$key];
219:             }
220: 
221:             return Quform::date($format, $date);
222:         } catch (Exception $e) {
223:             return '';
224:         }
225:     }
226: 
227:     /**
228:      * Called when the plugin is uninstalled, delete all options
229:      */
230:     public function uninstall()
231:     {
232:         // Delete options
233:         delete_option($this->key);
234:     }
235: }
236: 
API documentation generated by ApiGen