permalink-manager-advanced.php
9 years ago
permalink-manager-permastructs.php
9 years ago
permalink-manager-settings.php
9 years ago
permalink-manager-tools.php
9 years ago
permalink-manager-uri-editor-post.php
9 years ago
permalink-manager-uri-editor.php
9 years ago
permalink-manager-advanced.php
92 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Display the page where the slugs could be regenerated or replaced |
| 5 | */ |
| 6 | class Permalink_Manager_Advanced extends Permalink_Manager_Class { |
| 7 | |
| 8 | public function __construct() { |
| 9 | add_filter( 'permalink-manager-sections', array($this, 'add_advanced_section'), 1 ); |
| 10 | } |
| 11 | |
| 12 | public function add_advanced_section($admin_sections) { |
| 13 | $admin_sections['debug'] = array( |
| 14 | 'name' => __('Debug', 'permalink-manager'), |
| 15 | 'function' => array('class' => 'Permalink_Manager_Advanced', '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, $wp_filter; |
| 23 | |
| 24 | // Append PHP & plugin version |
| 25 | $permalink_manager_info = array_merge($permalink_manager_options, array('php_version' => phpversion(), 'plugin_version' => PERMALINK_MANAGER_VERSION)); |
| 26 | |
| 27 | // Get permalink hooks |
| 28 | foreach(array('_get_page_link', 'post_link', 'page_link', 'post_type_link') as $hook) { |
| 29 | $permalink_hooks[$hook] = $wp_filter[$hook]; |
| 30 | } |
| 31 | |
| 32 | $sections_and_fields = apply_filters('permalink-manager-advanced-fields', array( |
| 33 | 'debug-data' => array( |
| 34 | 'section_name' => __('Debug data', 'permalink-manager'), |
| 35 | 'fields' => array( |
| 36 | 'uris' => array( |
| 37 | 'type' => 'textarea', |
| 38 | 'description' => __('List of the URIs generated by this plugin.', 'permalink-manager'), |
| 39 | 'label' => __('Array with URIs', 'permalink-manager'), |
| 40 | 'input_class' => 'short-textarea widefat', |
| 41 | 'value' => ($permalink_manager_uris) ? json_encode($permalink_manager_uris, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : '' |
| 42 | ), |
| 43 | 'permastructs' => array( |
| 44 | 'type' => 'textarea', |
| 45 | 'description' => __('List of the permastructures.', 'permalink-manager'), |
| 46 | 'label' => __('Array with permastructures', 'permalink-manager'), |
| 47 | 'input_class' => 'short-textarea widefat', |
| 48 | 'value' => ($permalink_manager_permastructs) ? json_encode($permalink_manager_permastructs, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) : '' |
| 49 | ), |
| 50 | 'settings' => array( |
| 51 | 'type' => 'textarea', |
| 52 | 'description' => __('Plugin data.', 'permalink-manager'), |
| 53 | 'label' => __('Array with settings used in this plugin & some additional information.', 'permalink-manager'), |
| 54 | 'input_class' => 'short-textarea widefat', |
| 55 | 'value' => json_encode($permalink_manager_info, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) |
| 56 | ), |
| 57 | 'hooks' => array( |
| 58 | 'type' => 'textarea', |
| 59 | 'description' => __('Permalink hooks.', 'permalink-manager'), |
| 60 | 'label' => __('Array with list of permalink hooks used on this website.', 'permalink-manager'), |
| 61 | 'input_class' => 'short-textarea widefat', |
| 62 | 'value' => json_encode($permalink_hooks, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) |
| 63 | ) |
| 64 | ) |
| 65 | ) |
| 66 | )); |
| 67 | |
| 68 | // Now get the HTML output |
| 69 | $output = ''; |
| 70 | foreach($sections_and_fields as $section_id => $section) { |
| 71 | $output .= (isset($section['section_name'])) ? "<h3>{$section['section_name']}</h3>" : ""; |
| 72 | $output .= (isset($section['description'])) ? "<p class=\"description\">{$section['description']}</p>" : ""; |
| 73 | $output .= "<table class=\"form-table fixed-table\">"; |
| 74 | |
| 75 | // Loop through all fields assigned to this section |
| 76 | foreach($section['fields'] as $field_id => $field) { |
| 77 | $field_name = "{$section_id}[$field_id]"; |
| 78 | $field['container'] = 'row'; |
| 79 | |
| 80 | $output .= Permalink_Manager_Admin_Functions::generate_option_field($field_name, $field); |
| 81 | } |
| 82 | |
| 83 | // End the section |
| 84 | $output .= "</table>"; |
| 85 | |
| 86 | } |
| 87 | |
| 88 | return $output; |
| 89 | } |
| 90 | |
| 91 | } |
| 92 |