예제 #1
0
 public static function get_page_show_in_tree_link($page_id = 0)
 {
     $show_in_tree_link = '';
     if (empty($page_id)) {
         global $post;
         if (!empty($post->post_type) && $post->post_type == 'page') {
             $page_id = $post->ID;
         }
     }
     if (!empty($page_id)) {
         if (!current_user_can('edit_pages', $page_id)) {
             return '';
         }
         $page_apm_id = self::get_page_apm_id($page_id);
         if (!empty($page_apm_id)) {
             $show_in_tree_link = ApmBoContext::get_reach_node_url($page_apm_id);
         }
     }
     return $show_in_tree_link;
 }
예제 #2
0
 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);
     }
 }
			<?php 
            /*
             	//Native edit page panel displays nothing if there's no page templates in current theme. Let's do the same.
            	<p id="apm_page_attributes_template"><span><?php _e('No Page Template found in current theme directory!') ?></span></p> 
            */
            ?>
		<?php 
        }
        ?>
		
		<div id="apm_page_attributes_reach">
			<?php 
        if (!empty($page_apm_id)) {
            ?>
				<a class="button" href="<?php 
            echo ApmBoContext::get_reach_node_url($page_apm_id);
            ?>
"><?php 
            _e("Where is it ?", ApmConfig::i18n_domain);
            ?>
</a>
			<?php 
        }
        ?>
		</div>
		
		<div id="apm_page_attributes_family_nav">
			<?php 
        $link = !empty($page_tree_positions->parent) ? get_edit_post_link($page_tree_positions->parent) : '';
        ?>
			<div class="apm_page_attributes_nav_button_wrapper">