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_Admin_Page_Settings extends Quform_Admin_Page
  7: {
  8:     /**
  9:      * @var Quform_Options
 10:      */
 11:     protected $options;
 12: 
 13:     /**
 14:      * @var Quform_License
 15:      */
 16:     protected $license;
 17: 
 18:     /**
 19:      * @var Quform_Permissions
 20:      */
 21:     protected $permissions;
 22: 
 23:     /**
 24:      * @var Quform_ScriptLoader
 25:      */
 26:     protected $scriptLoader;
 27: 
 28:     /**
 29:      * @param  Quform_ViewFactory   $viewFactory
 30:      * @param  Quform_Options       $options
 31:      * @param  Quform_License       $license
 32:      * @param  Quform_Repository    $repository
 33:      * @param  Quform_Permissions   $permissions
 34:      * @param  Quform_ScriptLoader  $scriptLoader
 35:      */
 36:     public function __construct(Quform_ViewFactory $viewFactory, Quform_Repository $repository,
 37:                                 Quform_Options $options, Quform_License $license,
 38:                                 Quform_Permissions $permissions, Quform_ScriptLoader $scriptLoader)
 39:     {
 40:         parent::__construct($viewFactory, $repository);
 41: 
 42:         $this->options = $options;
 43:         $this->license = $license;
 44:         $this->permissions = $permissions;
 45:         $this->viewFactory = $viewFactory;
 46:         $this->scriptLoader = $scriptLoader;
 47:     }
 48: 
 49:     public function init()
 50:     {
 51:         $this->template = QUFORM_TEMPLATE_PATH .  '/admin/settings.php';
 52:     }
 53: 
 54:     /**
 55:      * Enqueue the page styles
 56:      */
 57:     protected function enqueueStyles()
 58:     {
 59:         wp_enqueue_style('qtip2', Quform::url('css/jquery.qtip.min.css'), array(), '3.0.4');
 60:         wp_enqueue_style('quform-select2', Quform::url('css/select2.min.css'), array(), '4.0.13');
 61: 
 62:         parent::enqueueStyles();
 63:     }
 64: 
 65:     /**
 66:      * Enqueue the page scripts
 67:      */
 68:     protected function enqueueScripts()
 69:     {
 70:         parent::enqueueScripts();
 71: 
 72:         wp_enqueue_script('qtip2', Quform::url('js/jquery.qtip.min.js'), array('jquery'), '3.0.4', true);
 73:         wp_enqueue_script('quform-select2', Quform::url('js/select2.min.js'), array('jquery'), '4.0.13', true);
 74:         wp_enqueue_script('themecatcher-tabs', Quform::adminUrl('js/tc.tabs.min.js'), array('jquery'), '1.0.0', true);
 75:         wp_enqueue_script('quform-settings', Quform::adminUrl('js/settings.min.js'), array('jquery'), QUFORM_VERSION, true);
 76: 
 77:         wp_localize_script('quform-settings', 'quformSettingsL10n', array(
 78:             'verifyNonce' => wp_create_nonce('quform_verify_purchase_code'),
 79:             /* translators: %1$s: open link tag, %2$s: close link tag */
 80:             'errorVerifying' => sprintf(__('An error occurred verifying the license key, please try again. If this problem persists, see %1$sthis page%2$s.', 'quform'), '<a href="https://support.themecatcher.net/quform-wordpress-v2/troubleshooting/common-problems/an-error-occurred-verifying-the-license-key" target="_blank">', '</a>'),
 81:             'waitVerifying' => __('Please wait, verification in progress', 'quform'),
 82:             'valid' => __('Valid', 'quform'),
 83:             'bundled' => __('Valid (bundled)', 'quform'),
 84:             'unlicensed' => __('Unlicensed', 'quform'),
 85:             'updateCheckNonce' => wp_create_nonce('quform_manual_update_check'),
 86:             'errorCheckingForUpdate' => __('An error occurred checking for an update.', 'quform'),
 87:             'waitUpdating' => __('Please wait, checking for an update', 'quform'),
 88:             'saveSettingsNonce' => wp_create_nonce('quform_save_settings'),
 89:             'settingsSaved' => __('Settings saved', 'quform'),
 90:             'errorSavingSettings' => __('An error occurred saving the settings.', 'quform'),
 91:             'rebuildScriptCacheNonce' => wp_create_nonce('quform_rebuild_script_cache'),
 92:             'errorRebuildingScriptCache' => __('An error occurred rebuilding the script cache.', 'quform'),
 93:             'scriptCacheRebuilt' => __('Script cache rebuilt', 'quform'),
 94:             'searchPostsNonce' => wp_create_nonce('quform_settings_search_posts')
 95:         ));
 96:     }
 97: 
 98:     /**
 99:      * Get the HTML for the admin navigation menu
100:      *
101:      * @param   array|null  $currentForm  The data for the current form (if any)
102:      * @param   array       $extra        Extra HTML to add to the nav, the array key is the hook position
103:      * @return  string
104:      */
105:     public function getNavHtml(array $currentForm = null, array $extra = array())
106:     {
107:         ob_start();
108:         ?>
109:         <div class="qfb-nav-item qfb-nav-page-info"><i class="qfb-nav-page-icon qfb-mdi qfb-mdi-settings"></i><span class="qfb-nav-page-title"><?php esc_html_e('Settings', 'quform'); ?></span></div>
110:         <?php
111: 
112:         return parent::getNavHtml($currentForm, array(40 => ob_get_clean()));
113:     }
114: 
115:     /**
116:      * Process this page and send data to the view
117:      */
118:     public function process()
119:     {
120:         if ( ! current_user_can('quform_settings')) {
121:             wp_die(__( 'You do not have sufficient permissions to access this page.', 'quform'), 403);
122:         }
123: 
124:         global $wp_roles;
125: 
126:         $this->view->with(array(
127:             'options' => $this->options,
128:             'license' => $this->license,
129:             'requirements' => $this->getServerCompatibility(),
130:             'roles' => $wp_roles->roles,
131:             'caps' => $this->permissions->getAllCapabilitiesWithDescriptions(),
132:             'disableableStyles' => $this->getDisableableStyles(),
133:             'disableableScripts' => $this->getDisableableScripts()
134:         ));
135:     }
136: 
137:     /**
138:      * Get the server compatibility information
139:      *
140:      * @return array
141:      */
142:     protected function getServerCompatibility()
143:     {
144:         $server = array(
145:             'phpVersion' => phpversion(),
146:             'mysqlVersion' => $this->repository->getDbVersion(),
147:             'wordpressVersion' => get_bloginfo('version'),
148:             'gdEnabled' => function_exists('imagecreate'),
149:             'ftEnabled' => function_exists('imagettftext'),
150:             'zipEnabled' => extension_loaded('zip'),
151:             'tmpDir' => Quform::getTempDir('quform'),
152:             'cacheDir' => $this->scriptLoader->getCachePath(),
153:             'uploadsDir' => Quform::getUploadsDir()
154:         );
155: 
156:         $compatibility = array(
157:             'php' => array(
158:                 'name' => __('PHP Version', 'quform'),
159:                 'info' => $server['phpVersion']
160:             ),
161:             'mysql' => array(
162:                 'name' => __('MySQL Version', 'quform'),
163:                 'info' => $server['mysqlVersion']
164:             ),
165:             'wordpress' => array(
166:                 'name' => __('WordPress Version', 'quform'),
167:                 'info' => $server['wordpressVersion']
168:             ),
169:             'gd' => array(
170:                 'name' => __('GD Image Library', 'quform'),
171:                 'info' => $server['gdEnabled'] ? __('Available', 'quform') : __('Unavailable', 'quform')
172:             ),
173:             'ft' => array(
174:                 'name' => __('FreeType Library', 'quform'),
175:                 'info' => $server['ftEnabled'] ? __('Available', 'quform') : __('Unavailable', 'quform')
176:             ),
177:             'zip' => array(
178:                 'name' => __('Zip Extension', 'quform'),
179:                 'info' => $server['zipEnabled'] ? __('Available', 'quform') : __('Unavailable', 'quform')
180:             ),
181:             'tmp' => array(
182:                 'name' => __('Temporary Directory', 'quform'),
183:                 'info' => $server['tmpDir'],
184:             ),
185:             'cache' => array(
186:                 'name' => __('Cache Directory', 'quform'),
187:                 'info' => $server['cacheDir'],
188:             ),
189:             'uploads' => array(
190:                 'name' => __('Uploads Directory', 'quform'),
191:                 'info' => $server['uploadsDir'],
192:             )
193:         );
194: 
195:         if (version_compare($server['phpVersion'], '5.2', '<')) {
196:             $compatibility['php']['error'] = __('The plugin requires PHP version 5.2 or later.', 'quform');
197:         }
198: 
199:         if (version_compare($server['mysqlVersion'], '5.0.0', '<')) {
200:             $compatibility['mysql']['error'] = __('The plugin requires MySQL version 5 or later.', 'quform');
201:         }
202: 
203:         if (version_compare($server['wordpressVersion'], '4.5', '<')) {
204:             $compatibility['wordpress']['error'] = __('The plugin requires WordPress version 4.5 or later.', 'quform');
205:         }
206: 
207:         if ( ! $server['gdEnabled']) {
208:             $compatibility['gd']['error'] = __('The plugin requires the GD image library for the CAPTCHA element.', 'quform');
209:         }
210: 
211:         if ( ! $server['ftEnabled']) {
212:             $compatibility['ft']['error'] = __('The plugin requires the FreeType library for the CAPTCHA element.', 'quform');
213:         }
214: 
215:         if ( ! $server['zipEnabled']) {
216:             $compatibility['zip']['error'] = __('The plugin requires the Zip PHP extension to export entries.', 'quform');
217:         }
218: 
219:         if ( ! is_dir($server['tmpDir'])) {
220:             $compatibility['tmp']['error'] = __('The temporary directory does not exist, please create the directory and make it writable.', 'quform');
221:         } else if ( ! wp_is_writable($server['tmpDir'])) {
222:             $compatibility['tmp']['error'] = __('The temporary directory is not writable.', 'quform');
223:         }
224: 
225:         if ( ! is_dir($server['cacheDir'])) {
226:             $compatibility['cache']['error'] = __('The plugin cache directory does not exist, please create the directory and make it writable.', 'quform');
227:         } else if ( ! wp_is_writable($server['cacheDir'])) {
228:             $compatibility['cache']['error'] = __('The plugin cache directory is not writable.', 'quform');
229:         }
230: 
231:         if ( ! is_dir($server['uploadsDir'])) {
232:             $compatibility['uploads']['error'] = __('The WordPress uploads directory does not exist, please create the directory and make it writable.', 'quform');
233:         } else if ( ! wp_is_writable($server['uploadsDir'])) {
234:             $compatibility['uploads']['error'] = __('The WordPress uploads directory is not writable.', 'quform');
235:         }
236: 
237:         return $compatibility;
238:     }
239: 
240:     /**
241:      * Get the array of stylesheets that can be disabled
242:      *
243:      * @return array
244:      */
245:     protected function getDisableableStyles()
246:     {
247:         return array(
248:             'font_awesome' => array(
249:                 'disabled' => $this->options->get('disabledStyles.fontAwesome'),
250:                 'name' => 'Font Awesome',
251:                 'version' => 'v4.7.0',
252:                 'tooltip' => __('Used for displaying icons in various parts of the form.', 'quform')
253:             ),
254:             'select2' => array(
255:                 'disabled' => $this->options->get('disabledStyles.select2'),
256:                 'name' => 'Select2',
257:                 'version' => 'v4.0.13',
258:                 'tooltip' => __('Used as a select menu replacement.', 'quform')
259:             ),
260:             'qtip' => array(
261:                 'disabled' => $this->options->get('disabledStyles.qtip'),
262:                 'name' => 'qTip',
263:                 'version' => 'v3.0.3',
264:                 'tooltip' => __('Used for displaying tooltips in the form.', 'quform')
265:             ),
266:             'fancybox' => array(
267:                 'disabled' => $this->options->get('disabledStyles.fancybox'),
268:                 'name' => 'Fancybox',
269:                 'version' => 'v1.3.9',
270:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
271:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-1'
272:             ),
273:             'fancybox2' => array(
274:                 'disabled' => $this->options->get('disabledStyles.fancybox2'),
275:                 'name' => 'Fancybox',
276:                 'version' => 'v2.1.9',
277:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
278:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-2'
279:             ),
280:             'fancybox3' => array(
281:                 'disabled' => $this->options->get('disabledStyles.fancybox3'),
282:                 'name' => 'Fancybox',
283:                 'version' => 'v3.5.7',
284:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
285:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-3'
286:             ),
287:             'magnific_popup' => array(
288:                 'disabled' => $this->options->get('disabledStyles.magnificPopup'),
289:                 'name' => 'Magnific Popup',
290:                 'version' => 'v1.1.0',
291:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
292:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'magnific-popup'
293:             )
294:         );
295:     }
296: 
297:     /**
298:      * Get the array of scripts that can be disabled
299:      *
300:      * @return array
301:      */
302:     protected function getDisableableScripts()
303:     {
304:         return array(
305:             'file_upload' => array(
306:                 'disabled' => $this->options->get('disabledScripts.fileUpload'),
307:                 'name' => 'jQuery File Upload',
308:                 'version' => 'v9.21.0',
309:                 'tooltip' => __('Used for adding upload progress to File Upload elements.', 'quform')
310:             ),
311:             'scroll_to' => array(
312:                 'disabled' => $this->options->get('disabledScripts.scrollTo'),
313:                 'name' => 'jQuery.scrollTo',
314:                 'version' => 'v2.1.2',
315:                 'tooltip' => __('Used for animated scrolling to success and error messages.', 'quform')
316:             ),
317:             'select2' => array(
318:                 'disabled' => $this->options->get('disabledScripts.select2'),
319:                 'name' => 'Select2',
320:                 'version' => 'v4.0.13',
321:                 'tooltip' => __('Used as a select menu replacement.', 'quform')
322:             ),
323:             'qtip' => array(
324:                 'disabled' => $this->options->get('disabledScripts.qtip'),
325:                 'name' => 'qTip',
326:                 'version' => 'v3.0.3',
327:                 'tooltip' => __('Used for displaying tooltips in the form.', 'quform')
328:             ),
329:             'fancybox' => array(
330:                 'disabled' => $this->options->get('disabledScripts.fancybox'),
331:                 'name' => 'Fancybox',
332:                 'version' => 'v1.3.9',
333:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
334:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-1'
335:             ),
336:             'fancybox2' => array(
337:                 'disabled' => $this->options->get('disabledScripts.fancybox2'),
338:                 'name' => 'Fancybox',
339:                 'version' => 'v2.1.9',
340:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
341:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-2'
342:             ),
343:             'fancybox3' => array(
344:                 'disabled' => $this->options->get('disabledScripts.fancybox3'),
345:                 'name' => 'Fancybox',
346:                 'version' => 'v3.5.7',
347:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
348:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'fancybox-3'
349:             ),
350:             'magnific_popup' => array(
351:                 'disabled' => $this->options->get('disabledScripts.magnificPopup'),
352:                 'name' => 'Magnific Popup',
353:                 'version' => 'v1.1.0',
354:                 'tooltip' => __('Used for displaying the form in a popup.', 'quform'),
355:                 'hidden' => ! $this->options->get('popupEnabled') || $this->options->get('popupScript') != 'magnific-popup'
356:             ),
357:             'infield_labels' => array(
358:                 'disabled' => $this->options->get('disabledScripts.infieldLabels'),
359:                 'name' => 'Infield Labels',
360:                 'version' => 'v0.1.5',
361:                 'tooltip' => __('Used for displaying labels inside fields.', 'quform')
362:             ),
363:             'datepicker' => array(
364:                 'disabled' => $this->options->get('disabledScripts.datepicker'),
365:                 'name' => 'Datepicker',
366:                 'version' => 'v2020.2.617',
367:                 'tooltip' => __('Used for displaying a datepicker calendar on the Date element.', 'quform')
368:             ),
369:             'timepicker' => array(
370:                 'disabled' => $this->options->get('disabledScripts.timepicker'),
371:                 'name' => 'Timepicker',
372:                 'version' => 'v2020.2.617',
373:                 'tooltip' => __('Used for displaying a timepicker list on the Time element.', 'quform')
374:             )
375:         );
376:     }
377: }
378: 
API documentation generated by ApiGen