permalink-manager-debug.php
5 years ago
permalink-manager-permastructs.php
5 years ago
permalink-manager-settings.php
5 years ago
permalink-manager-tools.php
5 years ago
permalink-manager-uri-editor-post.php
5 years ago
permalink-manager-uri-editor.php
5 years ago
permalink-manager-debug.php
112 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Display the page where the slugs could be regenerated or replaced |
| 5 | */ |
| 6 | class Permalink_Manager_Debug extends Permalink_Manager_Class { |
| 7 | |
| 8 | public function __construct() { |
| 9 | add_filter( 'permalink_manager_sections', array($this, 'add_debug_section'), 4 ); |
| 10 | } |
| 11 | |
| 12 | public function add_debug_section($admin_sections) { |
| 13 | $admin_sections['debug'] = array( |
| 14 | 'name' => __('Debug', 'permalink-manager'), |
| 15 | 'function' => array('class' => 'Permalink_Manager_Debug', 'method' => 'output') |
| 16 | ); |
| 17 | |
| 18 | return $admin_sections; |
| 19 | } |
| 20 | |
| 21 | public function output() { |
| 22 | global $permalink_manager_options, $permalink_manager_uris, $permalink_manager_permastructs, $permalink_manager_redirects, $permalink_manager_external_redirects, $wp_filter; |
| 23 | |
| 24 | $debug_section_url = Permalink_Manager_Admin_Functions::get_admin_url('§ion=debug'); |
| 25 | |
| 26 | $sections_and_fields = apply_filters('permalink_manager_debug_fields', array( |
| 27 | 'debug-data' => array( |
| 28 | 'section_name' => __('Debug data', 'permalink-manager'), |
| 29 | 'fields' => array( |
| 30 | 'uris' => array( |
| 31 | 'type' => 'textarea', |
| 32 | 'description' => sprintf('%s<br /><strong><a class="pm-confirm-action" href="%s&remove-permalink-manager-settings=uris">%s</a></strong>', |
| 33 | __('List of the URIs generated by this plugin.', 'permalink-manager'), |
| 34 | $debug_section_url, |
| 35 | __('Remove all custom permalinks', 'permalink-manager') |
| 36 | ), |
| 37 | 'label' => __('Array with URIs', 'permalink-manager'), |
| 38 | 'input_class' => 'short-textarea widefat', |
| 39 | 'value' => ($permalink_manager_uris) ? print_r($permalink_manager_uris, true) : '' |
| 40 | ), |
| 41 | 'custom-redirects' => array( |
| 42 | 'type' => 'textarea', |
| 43 | 'description' => sprintf('%s<br /><strong><a class="pm-confirm-action" href="%s&remove-permalink-manager-settings=redirects">%s</a></strong>', |
| 44 | __('List of custom redirects set-up by this plugin.', 'permalink-manager'), |
| 45 | $debug_section_url, |
| 46 | __('Remove all custom redirects', 'permalink-manager') |
| 47 | ), |
| 48 | 'label' => __('Array with redirects', 'permalink-manager'), |
| 49 | 'input_class' => 'short-textarea widefat', |
| 50 | 'value' => ($permalink_manager_redirects) ? print_r($permalink_manager_redirects, true) : '' |
| 51 | ), |
| 52 | 'external-redirects' => array( |
| 53 | 'type' => 'textarea', |
| 54 | 'description' => sprintf('%s<br /><strong><a class="pm-confirm-action" href="%s&remove-permalink-manager-settings=external-redirects">%s</a></strong>', |
| 55 | __('List of external redirects set-up by this plugin.', 'permalink-manager'), |
| 56 | $debug_section_url, __('Remove all external redirects', 'permalink-manager') |
| 57 | ), |
| 58 | 'label' => __('Array with external redirects', 'permalink-manager'), |
| 59 | 'input_class' => 'short-textarea widefat', |
| 60 | 'value' => ($permalink_manager_external_redirects) ? print_r(array_filter($permalink_manager_external_redirects), true) : '' |
| 61 | ), |
| 62 | 'permastructs' => array( |
| 63 | 'type' => 'textarea', |
| 64 | 'description' => sprintf('%s<br /><strong><a class="pm-confirm-action" href="%s&remove-permalink-manager-settings=permastructs">%s</a></strong>', |
| 65 | __('List of permastructures set-up by this plugin.', 'permalink-manager'), |
| 66 | $debug_section_url, |
| 67 | __('Remove all permastructures settings', 'permalink-manager') |
| 68 | ), |
| 69 | 'label' => __('Array with permastructures', 'permalink-manager'), |
| 70 | 'input_class' => 'short-textarea widefat', |
| 71 | 'value' => ($permalink_manager_permastructs) ? print_r($permalink_manager_permastructs, true) : '' |
| 72 | ), |
| 73 | 'settings' => array( |
| 74 | 'type' => 'textarea', |
| 75 | 'description' => sprintf('%s<br /><strong><a class="pm-confirm-action" href="%s&remove-permalink-manager-settings=settings">%s</a></strong>', |
| 76 | __('List of plugin settings.', 'permalink-manager'), |
| 77 | $debug_section_url, |
| 78 | __('Remove all plugin settings', 'permalink-manager') |
| 79 | ), |
| 80 | 'label' => __('Array with settings used in this plugin.', 'permalink-manager'), |
| 81 | 'input_class' => 'short-textarea widefat', |
| 82 | 'value' => print_r($permalink_manager_options, true) |
| 83 | ) |
| 84 | ) |
| 85 | ) |
| 86 | )); |
| 87 | |
| 88 | // Now get the HTML output |
| 89 | $output = ''; |
| 90 | foreach($sections_and_fields as $section_id => $section) { |
| 91 | $output .= (isset($section['section_name'])) ? "<h3>{$section['section_name']}</h3>" : ""; |
| 92 | $output .= (isset($section['description'])) ? "<p class=\"description\">{$section['description']}</p>" : ""; |
| 93 | $output .= "<table class=\"form-table fixed-table\">"; |
| 94 | |
| 95 | // Loop through all fields assigned to this section |
| 96 | foreach($section['fields'] as $field_id => $field) { |
| 97 | $field_name = "{$section_id}[$field_id]"; |
| 98 | $field['container'] = 'row'; |
| 99 | |
| 100 | $output .= Permalink_Manager_Admin_Functions::generate_option_field($field_name, $field); |
| 101 | } |
| 102 | |
| 103 | // End the section |
| 104 | $output .= "</table>"; |
| 105 | |
| 106 | } |
| 107 | |
| 108 | return $output; |
| 109 | } |
| 110 | |
| 111 | } |
| 112 |