admin
3 years ago
field-groups
3 years ago
fields
3 years ago
fields-settings
3 years ago
locations
3 years ago
modules
2 years ago
screens
3 years ago
acfe-deprecated-functions.php
2 years ago
acfe-field-functions.php
3 years ago
acfe-field-group-functions.php
3 years ago
acfe-file-functions.php
3 years ago
acfe-form-functions.php
3 years ago
acfe-helper-functions.php
3 years ago
acfe-meta-functions.php
3 years ago
acfe-post-functions.php
3 years ago
acfe-screen-functions.php
3 years ago
acfe-template-functions.php
3 years ago
acfe-term-functions.php
3 years ago
acfe-user-functions.php
3 years ago
acfe-wp-functions.php
3 years ago
assets.php
3 years ago
compatibility-6.0.php
2 years ago
compatibility.php
3 years ago
field-extend.php
3 years ago
field.php
3 years ago
hooks.php
3 years ago
init.php
3 years ago
local-meta.php
3 years ago
module-acf.php
3 years ago
module-db.php
3 years ago
module-l10n.php
3 years ago
module-legacy.php
3 years ago
module-manager.php
3 years ago
module-post.php
2 years ago
module-posts.php
3 years ago
module-upgrades.php
3 years ago
module.php
3 years ago
multilang.php
3 years ago
settings.php
3 years ago
third-party.php
3 years ago
upgrades.php
3 years ago
upgrades.php
68 lines
| 1 | <?php |
| 2 | |
| 3 | if(!defined('ABSPATH')){ |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | if(!class_exists('acfe_upgrades')): |
| 8 | |
| 9 | class acfe_upgrades{ |
| 10 | |
| 11 | /** |
| 12 | * construct |
| 13 | */ |
| 14 | function __construct(){ |
| 15 | |
| 16 | // get db version |
| 17 | $db_version = acfe_get_settings('version'); |
| 18 | |
| 19 | // bail early if superior |
| 20 | if(acf_version_compare($db_version, '>=', ACFE_VERSION)){ |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | // do upgrade |
| 25 | if($db_version){ |
| 26 | |
| 27 | add_action('acf/init', function() use($db_version){ |
| 28 | do_action('acfe/do_upgrade', $db_version); |
| 29 | }, 999); |
| 30 | |
| 31 | // do reset |
| 32 | }else{ |
| 33 | |
| 34 | // hook on init to load all WP components |
| 35 | // post types, post statuses 'acf-disabled' etc... |
| 36 | add_action('init', function(){ |
| 37 | do_action('acfe/do_reset'); |
| 38 | }); |
| 39 | |
| 40 | } |
| 41 | |
| 42 | // get db settings |
| 43 | $settings = acf_get_array(acfe_get_settings()); |
| 44 | |
| 45 | // model |
| 46 | $model = acfe_parse_args_r($settings, array( |
| 47 | 'version' => '', |
| 48 | 'modules' => array( |
| 49 | 'block_types' => array(), |
| 50 | 'options_pages' => array(), |
| 51 | 'post_types' => array(), |
| 52 | 'taxonomies' => array(), |
| 53 | ) |
| 54 | )); |
| 55 | |
| 56 | // assign version |
| 57 | $model['version'] = ACFE_VERSION; |
| 58 | |
| 59 | // update db |
| 60 | acfe_update_settings($model); |
| 61 | |
| 62 | } |
| 63 | |
| 64 | } |
| 65 | |
| 66 | acf_new_instance('acfe_upgrades'); |
| 67 | |
| 68 | endif; |