tools
6 years ago
views
6 years ago
options.class.php
6 years ago
options.php
6 years ago
plugins.php
6 years ago
settings.php
6 years ago
settings.php
399 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')) |
| 4 | exit; |
| 5 | |
| 6 | add_action('admin_menu', 'acfe_admin_settings_menu'); |
| 7 | function acfe_admin_settings_menu(){ |
| 8 | |
| 9 | if(!acf_get_setting('show_admin')) |
| 10 | return; |
| 11 | |
| 12 | $submenu_page = add_submenu_page('edit.php?post_type=acf-field-group', __('Settings'), __('Settings'), acf_get_setting('capability'), 'acfe-settings', 'acfe_admin_settings_html'); |
| 13 | |
| 14 | add_action('admin_print_scripts-' . $submenu_page, function(){ |
| 15 | acf_enqueue_scripts(); |
| 16 | }); |
| 17 | |
| 18 | } |
| 19 | |
| 20 | function acfe_admin_settings_html(){ |
| 21 | ?> |
| 22 | <div class="wrap" id="acfe-admin-settings"> |
| 23 | |
| 24 | <h1><?php _e('Settings'); ?></h1> |
| 25 | |
| 26 | <div id="poststuff"> |
| 27 | |
| 28 | <div class="postbox acf-postbox"> |
| 29 | <h2 class="hndle ui-sortable-handle"><span><?php _e('Settings'); ?></span></h2> |
| 30 | <div class="inside acf-fields -left"> |
| 31 | |
| 32 | <?php |
| 33 | acf_render_field_wrap(array( |
| 34 | 'type' => 'tab', |
| 35 | 'label' => 'ACF', |
| 36 | )); |
| 37 | ?> |
| 38 | |
| 39 | <?php |
| 40 | |
| 41 | $load_json = acf_get_setting('load_json'); |
| 42 | $load_json_text = ''; |
| 43 | |
| 44 | if(!empty($load_json)) |
| 45 | $load_json_text = implode("<br />", $load_json); |
| 46 | |
| 47 | $settings = array( |
| 48 | array( |
| 49 | 'name' => 'path', |
| 50 | 'label' => 'Path', |
| 51 | 'value' => '<code>' . acf_get_setting('path') . '</code>', |
| 52 | 'description' => 'Absolute path to ACF plugin folder including trailing slash.<br />Defaults to plugin_dir_path' |
| 53 | ), |
| 54 | array( |
| 55 | 'name' => 'dir', |
| 56 | 'label' => 'Directory', |
| 57 | 'value' => '<code>' . acf_get_setting('dir') . '</code>', |
| 58 | 'description' => 'URL to ACF plugin folder including trailing slash. Defaults to plugin_dir_url' |
| 59 | ), |
| 60 | array( |
| 61 | 'name' => 'show_admin', |
| 62 | 'label' => 'Show menu', |
| 63 | 'value' => '<code>' . (acf_get_setting('show_admin') ? __('True'): __('False')) . '</code>', |
| 64 | 'description' => 'Show/hide ACF menu item. Defaults to true' |
| 65 | ), |
| 66 | array( |
| 67 | 'name' => 'stripslashes', |
| 68 | 'label' => 'Strip slashes', |
| 69 | 'value' => '<code>' . (acf_get_setting('stripslashes') ? __('True'): __('False')) . '</code>', |
| 70 | 'description' => 'Runs the function stripslashes on all $_POST data. Some servers / WP instals may require this extra functioanlity. Defaults to false' |
| 71 | ), |
| 72 | array( |
| 73 | 'name' => 'local', |
| 74 | 'label' => 'PHP/Json', |
| 75 | 'value' => '<code>' . (acf_get_setting('local') ? __('True'): __('False')) . '</code>', |
| 76 | 'description' => 'Enable/Disable local (PHP/json) fields. Defaults to true' |
| 77 | ), |
| 78 | array( |
| 79 | 'name' => 'json', |
| 80 | 'label' => 'Json', |
| 81 | 'value' => '<code>' . (acf_get_setting('json') ? __('True'): __('False')) . '</code>', |
| 82 | 'description' => 'Enable/Disable json fields. Defaults to true' |
| 83 | ), |
| 84 | array( |
| 85 | 'name' => 'save_json', |
| 86 | 'label' => 'Json folder (save)', |
| 87 | 'value' => '<code>' . acf_get_setting('save_json') . '</code>', |
| 88 | 'description' => 'Absolute path to folder where json files will be created when field groups are saved.<br />Defaults to ‘acf-json’ folder within current theme' |
| 89 | ), |
| 90 | array( |
| 91 | 'name' => 'load_json', |
| 92 | 'label' => 'Json folder (load)', |
| 93 | 'value' => '<code>' . $load_json_text . '</code>', |
| 94 | 'description' => 'Array of absolutes paths to folders where field group json files can be read.<br />Defaults to an array containing at index 0, the ‘acf-json’ folder within current theme' |
| 95 | ), |
| 96 | array( |
| 97 | 'name' => 'default_language', |
| 98 | 'label' => 'Default language', |
| 99 | 'value' => '<code>' . acf_get_setting('default_language') . '</code>', |
| 100 | 'description' => 'Language code of the default language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML default language setting' |
| 101 | ), |
| 102 | array( |
| 103 | 'name' => 'current_language', |
| 104 | 'label' => 'Current language', |
| 105 | 'value' => '<code>' . acf_get_setting('current_language') . '</code>', |
| 106 | 'description' => 'Language code of the current post’s language. Defaults to ”.<br />If WPML is active, ACF will default this to the WPML current language' |
| 107 | ), |
| 108 | array( |
| 109 | 'name' => 'capability', |
| 110 | 'label' => 'Capability', |
| 111 | 'value' => '<code>' . acf_get_setting('capability') . '</code>', |
| 112 | 'description' => 'Capability used for ACF post types and if the current user can see the ACF menu item.<br />Defaults to ‘manage_options’.' |
| 113 | ), |
| 114 | array( |
| 115 | 'name' => 'show_updates', |
| 116 | 'label' => 'Show updates', |
| 117 | 'value' => '<code>' . (acf_get_setting('show_updates') ? __('True'): __('False')) . '</code>', |
| 118 | 'description' => 'Enable/Disable updates to appear in plugin list and show/hide the ACF updates admin page.<br />Defaults to true.' |
| 119 | ), |
| 120 | array( |
| 121 | 'name' => 'export_textdomain', |
| 122 | 'label' => 'Export textdomain', |
| 123 | 'value' => '<code>' . (acf_get_setting('export_textdomain') ? __('True'): __('False')) . '</code>', |
| 124 | 'description' => 'Array of keys used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Defaults to array(’title’, ’label’, ’instructions’). Depreciated in v5.3.4 – please see l10n_field and l10n_field_group' |
| 125 | ), |
| 126 | array( |
| 127 | 'name' => 'export_translate', |
| 128 | 'label' => 'Export translate', |
| 129 | 'value' => '<code>' . print_r(acf_get_setting('export_translate'), true) . '</code>', |
| 130 | 'description' => 'Used during the ‘Export to PHP’ feature to wrap strings within the __() function.<br />Depreciated in v5.4.4 – please see l10n_textdomain' |
| 131 | ), |
| 132 | array( |
| 133 | 'name' => 'autoload', |
| 134 | 'label' => 'Auto load', |
| 135 | 'value' => '<code>' . (acf_get_setting('autoload') ? __('True'): __('False')) . '</code>', |
| 136 | 'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty' |
| 137 | ), |
| 138 | array( |
| 139 | 'name' => 'l10n', |
| 140 | 'label' => 'l10n', |
| 141 | 'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>', |
| 142 | 'description' => 'Allows ACF to translate field and field group settings using the __() function.<br />Defaults to true. Useful to override translation without modifying the textdomain' |
| 143 | ), |
| 144 | array( |
| 145 | 'name' => 'l10n_textdomain', |
| 146 | 'label' => 'l10n Textdomain', |
| 147 | 'value' => '<code>' . (acf_get_setting('l10n') ? __('True'): __('False')) . '</code>', |
| 148 | 'description' => 'Sets the text domain used when translating field and field group settings.<br />Defaults to ”. Strings will not be translated if this setting is empty' |
| 149 | ), |
| 150 | array( |
| 151 | 'name' => 'l10n_field', |
| 152 | 'label' => 'l10n Field', |
| 153 | 'value' => '<code>' . print_r(acf_get_setting('l10n_field'), true) . '</code>', |
| 154 | 'description' => 'An array of settings to translate when loading and exporting a field.<br />Defaults to array(’label’, ’instructions’). Depreciated in v5.3.6 – please see acf/translate_field filter' |
| 155 | ), |
| 156 | array( |
| 157 | 'name' => 'l10n_field_group', |
| 158 | 'label' => 'l10n Field group', |
| 159 | 'value' => '<code>' . print_r(acf_get_setting('l10n_field_group'), true) . '</code>', |
| 160 | 'description' => 'An array of settings to translate when loading and exporting a field group.<br />Defaults to array(’title’). Depreciated in v5.3.6 – please see acf/translate_field_group filter' |
| 161 | ), |
| 162 | array( |
| 163 | 'name' => 'google_api_key', |
| 164 | 'label' => 'Google API Key', |
| 165 | 'value' => '<code>' . acf_get_setting('google_api_key') . '</code>', |
| 166 | 'description' => 'Specify a Google Maps API authentication key to prevent usage limits.<br />Defaults to ”' |
| 167 | ), |
| 168 | array( |
| 169 | 'name' => 'google_api_client', |
| 170 | 'label' => 'Google API Key', |
| 171 | 'value' => '<code>' . acf_get_setting('google_api_client') . '</code>', |
| 172 | 'description' => 'Specify a Google Maps API Client ID to prevent usage limits.<br />Not needed if using google_api_key. Defaults to ”' |
| 173 | ), |
| 174 | array( |
| 175 | 'name' => 'enqueue_google_maps', |
| 176 | 'label' => 'Enqueue Google Maps', |
| 177 | 'value' => '<code>' . (acf_get_setting('enqueue_google_maps') ? __('True'): __('False')) . '</code>', |
| 178 | 'description' => 'Allows ACF to enqueue and load the Google Maps API JS library.<br />Defaults to true' |
| 179 | ), |
| 180 | array( |
| 181 | 'name' => 'enqueue_select2', |
| 182 | 'label' => 'Enqueue Select2', |
| 183 | 'value' => '<code>' . (acf_get_setting('enqueue_select2') ? __('True'): __('False')) . '</code>', |
| 184 | 'description' => 'Allows ACF to enqueue and load the Select2 JS/CSS library.<br />Defaults to true' |
| 185 | ), |
| 186 | array( |
| 187 | 'name' => 'select2_version', |
| 188 | 'label' => 'Select2 version', |
| 189 | 'value' => '<code>' . acf_get_setting('select2_version') . '</code>', |
| 190 | 'description' => 'Defines which version of Select2 library to enqueue. Either 3 or 4.<br />Defaults to 4 since ACF 5.6.0' |
| 191 | ), |
| 192 | array( |
| 193 | 'name' => 'enqueue_datepicker', |
| 194 | 'label' => 'Enqueue Datepicker', |
| 195 | 'value' => '<code>' . (acf_get_setting('enqueue_datepicker') ? __('True'): __('False')) . '</code>', |
| 196 | 'description' => 'Allows ACF to enqueue and load the WP datepicker JS/CSS library.<br />Defaults to true' |
| 197 | ), |
| 198 | array( |
| 199 | 'name' => 'enqueue_datetimepicker', |
| 200 | 'label' => 'Enqueue Date/timepicker', |
| 201 | 'value' => '<code>' . (acf_get_setting('enqueue_datetimepicker') ? __('True'): __('False')) . '</code>', |
| 202 | 'description' => 'Allows ACF to enqueue and load the datetimepicker JS/CSS library.<br />Defaults to true' |
| 203 | ), |
| 204 | array( |
| 205 | 'name' => 'row_index_offset', |
| 206 | 'label' => 'Row index offset', |
| 207 | 'value' => '<code>' . acf_get_setting('row_index_offset') . '</code>', |
| 208 | 'description' => 'Defines the starting index used in all ‘loop’ and ‘row’ functions.<br />Defaults to 1 (1 is the first row), can be changed to 0 (0 is the first row)' |
| 209 | ), |
| 210 | array( |
| 211 | 'name' => 'remove_wp_meta_box', |
| 212 | 'label' => 'Remove WP meta box', |
| 213 | 'value' => '<code>' . (acf_get_setting('remove_wp_meta_box') ? __('True'): __('False')) . '</code>', |
| 214 | 'description' => 'Allows ACF to remove the default WP custom fields metabox. Defaults to true' |
| 215 | ), |
| 216 | ); |
| 217 | |
| 218 | ?> |
| 219 | |
| 220 | <?php foreach($settings as $setting){ ?> |
| 221 | <div class="acf-field"> |
| 222 | <div class="acf-label"> |
| 223 | <label><span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="<?php echo $setting['description']; ?>"></span><?php echo $setting['label']; ?></label> |
| 224 | <p class="description"><code><?php echo $setting['name']; ?></code></p> |
| 225 | </div> |
| 226 | <div class="acf-input"> |
| 227 | <?php echo $setting['value']; ?> |
| 228 | </div> |
| 229 | </div> |
| 230 | <?php } ?> |
| 231 | |
| 232 | <?php |
| 233 | acf_render_field_wrap(array( |
| 234 | 'type' => 'tab', |
| 235 | 'label' => 'ACF: Extended', |
| 236 | )); |
| 237 | ?> |
| 238 | |
| 239 | <?php |
| 240 | |
| 241 | $load_php = acf_get_setting('acfe/php_load'); |
| 242 | $load_php_text = ''; |
| 243 | |
| 244 | if(!empty($load_php)) |
| 245 | $load_php_text = implode("<br />", $load_php); |
| 246 | |
| 247 | $settings = array( |
| 248 | array( |
| 249 | 'name' => 'acfe/modules/author', |
| 250 | 'label' => 'Module: Author', |
| 251 | 'value' => '<code>' . (acf_get_setting('acfe/modules/author', true) ? __('True'): __('False')) . '</code>', |
| 252 | 'description' => 'Show/hide the Author module. Defaults to true' |
| 253 | ), |
| 254 | array( |
| 255 | 'name' => 'acfe/modules/dynamic_block_types', |
| 256 | 'label' => 'Module: Dynamic Block Types', |
| 257 | 'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_block_types', true) ? __('True'): __('False')) . '</code>', |
| 258 | 'description' => 'Show/hide the Block Types module. Defaults to true' |
| 259 | ), |
| 260 | array( |
| 261 | 'name' => 'acfe/modules/dynamic_forms', |
| 262 | 'label' => 'Module: Dynamic Forms', |
| 263 | 'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_forms', true) ? __('True'): __('False')) . '</code>', |
| 264 | 'description' => 'Show/hide the Forms module. Defaults to true' |
| 265 | ), |
| 266 | array( |
| 267 | 'name' => 'acfe/modules/dynamic_post_types', |
| 268 | 'label' => 'Module: Dynamic Post Types', |
| 269 | 'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_post_types', true) ? __('True'): __('False')) . '</code>', |
| 270 | 'description' => 'Show/hide the Post Types module. Defaults to true' |
| 271 | ), |
| 272 | array( |
| 273 | 'name' => 'acfe/modules/dynamic_taxonomies', |
| 274 | 'label' => 'Module: Dynamic Taxonomies', |
| 275 | 'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_taxonomies', true) ? __('True'): __('False')) . '</code>', |
| 276 | 'description' => 'Show/hide the Taxonomies module. Defaults to true' |
| 277 | ), |
| 278 | array( |
| 279 | 'name' => 'acfe/modules/dynamic_options_pages', |
| 280 | 'label' => 'Module: Dynamic Options Pages', |
| 281 | 'value' => '<code>' . (acf_get_setting('acfe/modules/dynamic_options_pages', true) ? __('True'): __('False')) . '</code>', |
| 282 | 'description' => 'Show/hide the Options Pages module. Defaults to true' |
| 283 | ), |
| 284 | array( |
| 285 | 'name' => 'acfe/modules/options', |
| 286 | 'label' => 'Module: Options', |
| 287 | 'value' => '<code>' . (acf_get_setting('acfe/modules/options', true) ? __('True'): __('False')) . '</code>', |
| 288 | 'description' => 'Show/hide the Options module. Defaults to true' |
| 289 | ), |
| 290 | array( |
| 291 | 'name' => 'acfe/modules/taxonomies', |
| 292 | 'label' => 'Module: Taxonomies Enhancements', |
| 293 | 'value' => '<code>' . (acf_get_setting('acfe/modules/taxonomies', true) ? __('True'): __('False')) . '</code>', |
| 294 | 'description' => 'Show/hide the Taxonomies enhancements module. Defaults to true' |
| 295 | ), |
| 296 | array( |
| 297 | 'name' => 'acfe/field/recaptcha/site_key', |
| 298 | 'label' => 'Field: reCaptcha site key', |
| 299 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/site_key') . '</code>', |
| 300 | 'description' => 'The default reCaptcha site key' |
| 301 | ), |
| 302 | array( |
| 303 | 'name' => 'acfe/field/recaptcha/secret_key', |
| 304 | 'label' => 'Field: reCaptcha secret key', |
| 305 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/secret_key') . '</code>', |
| 306 | 'description' => 'The default reCaptcha secret key' |
| 307 | ), |
| 308 | array( |
| 309 | 'name' => 'acfe/field/recaptcha/version', |
| 310 | 'label' => 'Field: reCaptcha version', |
| 311 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/version', 'v2') . '</code>', |
| 312 | 'description' => 'The default reCaptcha version' |
| 313 | ), |
| 314 | array( |
| 315 | 'name' => 'acfe/field/recaptcha/v2/theme', |
| 316 | 'label' => 'Field: reCaptcha v2 theme', |
| 317 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/theme', 'light') . '</code>', |
| 318 | 'description' => 'The default reCaptcha v2 theme' |
| 319 | ), |
| 320 | array( |
| 321 | 'name' => 'acfe/field/recaptcha/v2/size', |
| 322 | 'label' => 'Field: reCaptcha v2 size', |
| 323 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v2/size', 'normal') . '</code>', |
| 324 | 'description' => 'The default reCaptcha v2 size' |
| 325 | ), |
| 326 | array( |
| 327 | 'name' => 'acfe/field/recaptcha/v3/hide_logo', |
| 328 | 'label' => 'Field: reCaptcha v3 hide logo', |
| 329 | 'value' => '<code>' . acf_get_setting('acfe/field/recaptcha/v3/hide_logo') . '</code>', |
| 330 | 'description' => 'Show/hide reCaptcha v3 logo' |
| 331 | ), |
| 332 | array( |
| 333 | 'name' => 'acfe/dev', |
| 334 | 'label' => 'Dev mode', |
| 335 | 'value' => '<code>' . (acf_get_setting('acfe/dev') ? __('True'): __('False')) . '</code>', |
| 336 | 'description' => 'Show/hide the advanced WP post meta box. Defaults to false' |
| 337 | ), |
| 338 | array( |
| 339 | 'name' => 'acfe/php', |
| 340 | 'label' => 'PHP', |
| 341 | 'value' => '<code>' . (acf_get_setting('acfe/php') ? __('True'): __('False')) . '</code>', |
| 342 | 'description' => 'Allow PHP Sync' |
| 343 | ), |
| 344 | array( |
| 345 | 'name' => 'acfe/php_found', |
| 346 | 'label' => 'PHP: Found', |
| 347 | 'value' => '<code>' . (acf_get_setting('acfe/php_found') ? __('True'): __('False')) . '</code>', |
| 348 | 'description' => 'Found PHP Sync load folder' |
| 349 | ), |
| 350 | array( |
| 351 | 'name' => 'acfe/php_save', |
| 352 | 'label' => 'PHP: Save', |
| 353 | 'value' => '<code>' . acf_get_setting('acfe/php_save') . '</code>', |
| 354 | 'description' => 'Found PHP Sync save folder' |
| 355 | ), |
| 356 | array( |
| 357 | 'name' => 'acfe/php_load', |
| 358 | 'label' => 'PHP: Load', |
| 359 | 'value' => '<code>' . $load_php_text . '</code>', |
| 360 | 'description' => 'PHP Sync Load path' |
| 361 | ), |
| 362 | array( |
| 363 | 'name' => 'acfe/json_found', |
| 364 | 'label' => 'Json: Found', |
| 365 | 'value' => '<code>' . (acf_get_setting('acfe/json_found') ? __('True'): __('False')) . '</code>', |
| 366 | 'description' => 'Found Json Sync load folder' |
| 367 | ), |
| 368 | ); |
| 369 | ?> |
| 370 | |
| 371 | <?php foreach($settings as $setting){ ?> |
| 372 | <div class="acf-field"> |
| 373 | <div class="acf-label"> |
| 374 | <label><span class="acf-js-tooltip dashicons dashicons-info" style="float:right; font-size:16px; color:#ccc;" title="<?php echo $setting['description']; ?>"></span><?php echo $setting['label']; ?></label> |
| 375 | <p class="description"><code><?php echo $setting['name']; ?></code></p> |
| 376 | </div> |
| 377 | <div class="acf-input"> |
| 378 | <?php echo $setting['value']; ?> |
| 379 | </div> |
| 380 | </div> |
| 381 | <?php } ?> |
| 382 | |
| 383 | <script type="text/javascript"> |
| 384 | if( typeof acf !== 'undefined' ) { |
| 385 | |
| 386 | acf.newPostbox({ |
| 387 | 'id': 'acfe-settings', |
| 388 | 'label': 'left' |
| 389 | }); |
| 390 | |
| 391 | } |
| 392 | </script> |
| 393 | </div> |
| 394 | </div> |
| 395 | </div> |
| 396 | |
| 397 | </div> |
| 398 | <?php |
| 399 | } |