ConfigPress.php
8 years ago
Content.php
8 years ago
Core.php
8 years ago
Manager.php
8 years ago
Tools.php
8 years ago
Tools.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * ====================================================================== |
| 5 | * LICENSE: This file is subject to the terms and conditions defined in * |
| 6 | * file 'license.txt', which is part of this source code package. * |
| 7 | * ====================================================================== |
| 8 | */ |
| 9 | |
| 10 | /** |
| 11 | * Backend tools settings |
| 12 | * |
| 13 | * @package AAM |
| 14 | * @author Vasyl Martyniuk <vasyl@vasyltech.com> |
| 15 | */ |
| 16 | class AAM_Backend_Feature_Settings_Tools extends AAM_Backend_Feature_Abstract { |
| 17 | |
| 18 | /** |
| 19 | * @inheritdoc |
| 20 | */ |
| 21 | public static function getTemplate() { |
| 22 | return 'settings/tools.phtml'; |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * |
| 27 | * @return type |
| 28 | */ |
| 29 | public function export() { |
| 30 | $exporter = new AAM_Core_Exporter(AAM_Core_Config::get( |
| 31 | 'export', array('system' => 'roles,utilities,configpress') |
| 32 | )); |
| 33 | |
| 34 | return json_encode(array( |
| 35 | 'status' => 'success', |
| 36 | 'content' => base64_encode(json_encode($exporter->run())) |
| 37 | )); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * |
| 42 | * @return type |
| 43 | */ |
| 44 | public function import() { |
| 45 | $importer = new AAM_Core_Importer(filter_input(INPUT_POST, 'json')); |
| 46 | |
| 47 | return json_encode(array('status' => $importer->run())); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Clear all AAM settings |
| 52 | * |
| 53 | * @global wpdb $wpdb |
| 54 | * |
| 55 | * @return string |
| 56 | * |
| 57 | * @access public |
| 58 | */ |
| 59 | public function clear() { |
| 60 | global $wpdb; |
| 61 | |
| 62 | //clear wp_options |
| 63 | $oquery = "DELETE FROM {$wpdb->options} WHERE (`option_name` LIKE %s) AND "; |
| 64 | $oquery .= "(`option_name` NOT IN ('aam-extensions', 'aam-uid'))"; |
| 65 | $wpdb->query($wpdb->prepare($oquery, 'aam%')); |
| 66 | |
| 67 | //clear wp_postmeta |
| 68 | $pquery = "DELETE FROM {$wpdb->postmeta} WHERE `meta_key` LIKE %s"; |
| 69 | $wpdb->query($wpdb->prepare($pquery, 'aam-post-access-%')); |
| 70 | |
| 71 | //clear wp_usermeta |
| 72 | $uquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s"; |
| 73 | $wpdb->query($wpdb->prepare($uquery, 'aam%')); |
| 74 | |
| 75 | $mquery = "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` LIKE %s"; |
| 76 | $wpdb->query($wpdb->prepare($mquery, $wpdb->prefix . 'aam%')); |
| 77 | |
| 78 | $this->clearCache(); |
| 79 | |
| 80 | return json_encode(array('status' => 'success')); |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * |
| 85 | * @return type |
| 86 | */ |
| 87 | public function clearCache() { |
| 88 | AAM_Core_API::clearCache(); |
| 89 | |
| 90 | return json_encode(array('status' => 'success')); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Register Contact/Hire feature |
| 95 | * |
| 96 | * @return void |
| 97 | * |
| 98 | * @access public |
| 99 | */ |
| 100 | public static function register() { |
| 101 | AAM_Backend_Feature::registerFeature((object) array( |
| 102 | 'uid' => 'settings-tools', |
| 103 | 'position' => 10, |
| 104 | 'title' => __('Tools', AAM_KEY), |
| 105 | 'capability' => 'aam_manage_settings', |
| 106 | 'type' => 'settings', |
| 107 | 'view' => __CLASS__ |
| 108 | )); |
| 109 | } |
| 110 | |
| 111 | } |
| 112 |