/** * Builds HTML from tree or list $nodes * @param array $nodes Must be the result of a "get_ready_to_display_[tree|list]" method. * @param boolean $return_array Whether to return an array or a string of html nodes. */ protected static function get_html_tree($nodes, $return_array = false) { $html = $return_array ? array() : ''; if (!is_array($nodes)) { $nodes = array($nodes); } $template_name = !empty($_POST['tree_template']) ? $_POST['tree_template'] : 'tree_display'; $tree_template_file = dirname(__FILE__) . '/../templates/' . ApmOptions::get_option('panel_page_template_name') . '/' . $template_name . '.php'; if (file_exists($tree_template_file)) { require_once dirname(__FILE__) . '/../lib/custom_columns.php'; if ($return_array) { $nodes_list = $nodes; foreach ($nodes_list as $node) { $nodes = array($node); ob_start(); require $tree_template_file; $node_html = ob_get_contents(); ob_end_clean(); $html[$node->apm_id] = trim($node_html); } } else { ob_start(); require $tree_template_file; $html = trim(ob_get_contents()); ob_end_clean(); } } else { self::add_error(__("Template not found", ApmConfig::i18n_domain) . ' : [' . $tree_template_file . ']'); } return $html; }
* * We arrive here via the "template_redirect" hook in the main advanced_page_manager class. * * @package APM */ header('Content-Type: text/html; charset=UTF-8'); require_once dirname(__FILE__) . "/api_ajax.php"; ApmApiAjax::check_admin_user_connected(); //Check the AJAX nonce check_ajax_referer('apm_ajax_request'); if (isset($_POST['apm_action'])) { $action = $_POST['apm_action']; require_once dirname(__FILE__) . "/tree_ajax.php"; require_once dirname(__FILE__) . "/list_ajax.php"; require_once dirname(__FILE__) . "/nodes_ajax.php"; if (ApmOptions::get_option('queries_watcher_on') == true) { $queries_watcher_file = dirname(__FILE__) . "/../lib/queries_watcher.php"; if (file_exists($queries_watcher_file)) { require_once $queries_watcher_file; ApmQueriesWatcher::start(); } } if (method_exists('ApmTreeAjax', $action)) { ApmTreeAjax::$action(); } else { if (method_exists('ApmListAjax', $action)) { ApmListAjax::$action(); } else { if (method_exists('ApmNodesAjax', $action)) { ApmNodesAjax::$action(); }
/** * Loads the template for the plugin options panel */ public static function bo_options_panel_template() { ApmOptions::handle_actions(); ApmAddons::handle_actions(); require_once dirname(__FILE__) . "/templates/core/bo_options_panel.php"; }
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); } }
public static function delete_database_data($including_plugin_options = true) { if ($including_plugin_options) { ApmOptions::delete_database_data(); } ApmTreeDb::delete_database_data(); ApmTreeState::delete_all(); if (ApmAddons::addon_is_on('flagged_pages')) { ApmMarkedNodes::delete_all_users_marked_nodes(); } }
<?php } else { ?> <?php foreach ($lost_pages as $page) { ?> <tr> <td><a href="<?php echo get_edit_post_link($page->ID); ?> "><?php echo $page->post_title; ?> </a></td> <td><a href="<?php echo ApmOptions::get_restore_page_url($page->ID, false); ?> "><?php _e("Restore at the end of the page tree", ApmConfig::i18n_domain); ?> </a></td> </tr> <?php } ?> <?php } ?> </table> </div> </div>
</div> </div> <?php } else { //The page is not in APM tree : $allowed_post_status = ApmConfig::$allowed_post_status; $allowed_post_status = apply_filters('apm_allowed_post_status', $allowed_post_status, 'page_attributes_meta_box'); $message = __('This page is not in the Advanced Page Manager tree.', ApmConfig::i18n_domain); $message = apply_filters('apm_page_attributes_metabox_not_in_tree_message', $message); ?> <div id="apm_page_not_in_apm_tree"> <?php echo $message; ?> <?php if (in_array($post->post_status, $allowed_post_status)) { ?> <br/><br/><a class="button" href="<?php echo ApmOptions::get_restore_page_url($post->ID); ?> "><?php _e('Insert this page as last page of the tree', ApmConfig::i18n_domain); ?> </a> <?php } ?> </div> <?php } }
public static function handle_actions() { //Note : security nonce on APM options actions is checked in ApmOptions::handle_actions() if (!empty($_POST['apm_options_action'])) { //Addons activations/deactivations : if ($_POST['apm_options_action'] == self::$posted_options_action) { $current_addons = self::get_addons_from_db(); $addons = self::check_addons($_POST); self::save_addons($addons); foreach ($addons as $addon_file => $activated) { require_once self::get_addons_directory() . '/' . $addon_file . '.php'; if ($activated) { if (isset($current_addons[$addon_file])) { //Addon existed if ($current_addons[$addon_file] === false) { //Only launch activation hook if it was deactivated do_action('apm_activate_addon_' . $addon_file . '.php'); } } else { //Addon didn't exist : launch activation hook: do_action('apm_activate_addon_' . $addon_file . '.php'); } } else { if (isset($current_addons[$addon_file])) { //Addon existed if ($current_addons[$addon_file] === true) { //Only launch deactivation hook if it was activated do_action('apm_deactivate_addon_' . $addon_file . '.php'); } } else { //Addon didn't exist and we deactivate it (a bit strange I must say...) //Still, it can't hurt to launch the deactivation hook: do_action('apm_deactivate_addon_' . $addon_file . '.php'); } } } //Reload page in case the addon changes the BO menu : wp_redirect(add_query_arg(array('apm_options_msg' => 1), ApmOptions::get_base_url(true))); exit; } } }
?> hors arborescence :</h3> <table> <?php foreach ($lost_pages as $page) { ?> <tr> <td><a href="<?php echo get_edit_post_link($page->ID); ?> "><?php echo $page->post_title; ?> </a></td> <td><a href="<?php echo add_query_arg(array('apm_options_action' => 'restore_page', 'wp_id' => $page->ID, 'redirect_to_page_in_tree' => true), ApmOptions::get_base_url()); ?> ">Repositionner en fin d'arborescence</a></td> </tr> <?php } ?> </table> </div> <?php } ?> <!-- left panel --> <!-- todo : Remove the 250 px hack --> <div class="column-panel" id="left-panels-wrapper" style="width:250px;">