/** * Delete plugin database footprint on unsinstall */ public static function uninstall() { ApmTreeData::delete_database_data(); ApmAddons::delete_database_data(); }
public static function handle_actions() { //Check nonce: if (!empty($_REQUEST['apm_options_action']) && !wp_verify_nonce($_REQUEST['_wpnonce'], self::save_options_nonce)) { wp_die(__("Could not save plugin settings : security check failed.", ApmConfig::i18n_domain)); exit; } $redirect_url = self::get_base_url(true); if (!empty($_GET['apm_options_action'])) { //Bugfix "Headers already sent" on action in Pages > Settings > Plugin data management for some configs. //TODO : see if we can identify more precisely what is causing this to find a more targeted fix. $buffer = ob_get_clean(); switch ($_GET['apm_options_action']) { case 'delete_all_data': ApmTreeData::delete_database_data(false); wp_redirect(add_query_arg(array('apm_options_msg' => 2), $redirect_url)); exit; break; case 'delete_options': ApmOptions::delete_database_data(); wp_redirect(add_query_arg(array('apm_options_msg' => 3), $redirect_url)); exit; break; case 'delete_folding_infos': ApmTreeState::delete_all(); wp_redirect(add_query_arg(array('apm_options_msg' => 4), $redirect_url)); exit; break; case 'restore_page': if (!empty($_GET['wp_id'])) { //Check if the page is still lost : $lost_pages = self::get_lost_pages(); if (array_key_exists($_GET['wp_id'], $lost_pages)) { $tree = new ApmTreeData(); $tree->load_last_tree(); $apm_id = $tree->add_new_node('insert_child', ApmTreeData::root_id, 'page', $_GET['wp_id']); self::$feedback['msg'] = sprintf(__('The page "%s" has been successful restored to the end of the tree', ApmConfig::i18n_domain), $lost_pages[$_GET['wp_id']]->post_title); if (!empty($_GET['redirect_to_page_in_tree'])) { wp_redirect(ApmBoContext::get_reach_node_url($apm_id)); exit; } } else { self::$feedback['type'] = 'error'; self::$feedback['msg'] = sprintf(__('The page to restore (wp_id = %s) is not in lost pages.', ApmConfig::i18n_domain), $_GET['wp_id']); } } break; case 'reset_tree_from_wp_pages': //Restore apm tree from WP pages tree $tree = new ApmTreeData(); $tree->reset_tree_and_data(); wp_redirect(add_query_arg(array('apm_options_msg' => 5), $redirect_url)); exit; break; case 'apm_tree_to_wp_pages_tree': $tree = new ApmTreeData(); $tree->load_last_tree(); $tree->synchronize_tree_with_wp_entities(); wp_redirect(add_query_arg(array('apm_options_msg' => 6), $redirect_url)); exit; break; } //Bugfix "Headers already sent" on action in Pages > Settings > Plugin data management for some configs. //TODO : see if we can identify more precisely what is causing this to find a more targeted fix. echo $buffer; do_action('apm_options_handle_get_action', $_GET['apm_options_action'], $redirect_url); } elseif (!empty($_POST['apm_options_action'])) { switch ($_POST['apm_options_action']) { case 'save_admin_options': self::save_options($_POST); self::$feedback['msg'] = __('Admin options saved successfuly', ApmConfig::i18n_domain); break; } do_action('apm_options_handle_post_action', $_POST['apm_options_action'], $redirect_url); } }