PluginProbe ʕ •ᴥ•ʔ
Permalink Manager Lite / trunk
Permalink Manager Lite vtrunk
2.5.3.4 2.2.18 2.2.19.2 2.2.19.3 2.2.19.3.1 2.2.2 2.2.20 2.2.20.1 2.2.20.3 2.2.4 2.2.5 2.2.6 2.2.7.2 2.2.7.3 2.2.7.5 2.2.7.6 2.2.8.4 2.2.8.5 2.2.8.6 2.2.8.7 2.2.8.9 2.2.9.1 2.2.9.2 2.2.9.2.1 2.2.9.3 2.2.9.4 2.2.9.6 2.2.9.7 2.2.9.9 2.3.0 2.3.1.1 2.4.0 2.4.1 2.4.1.2 2.4.1.3 2.4.1.4 2.4.1.5 2.4.1.6 2.4.2 2.4.2.1 2.4.3 2.4.3.1 2.4.3.2 2.4.3.3 2.4.3.4 2.4.4 2.4.4.1 2.4.4.2 2.4.4.3 2.5.0 2.5.1 2.5.1.1 2.5.1.2 2.5.1.3 2.5.1.4 2.5.2 2.5.2.1 2.5.2.2 2.5.2.3 2.5.2.4 2.5.3 2.5.3.1 2.5.3.2 2.5.3.3 trunk 0.2 0.3 0.3.1 0.3.2 0.3.3 0.3.4 0.4 0.4.1 0.4.2 0.4.3 0.4.4 0.4.6 0.4.7 0.4.8 0.4.9 0.5.3 0.5.4 1.0.0 1.0.1 1.0.4 1.1.0 1.1.1 1.1.2 1.11.6.3 2.0.0 2.0.3 2.0.4 2.0.4.3 2.0.5.1 2.0.5.2 2.0.5.3 2.0.5.3.1 2.0.5.4 2.0.5.4a 2.0.5.5 2.0.5.6 2.0.5.6.1 2.0.5.7 2.0.5.9a 2.0.6.2.1 2.0.6.2a 2.0.6.3 2.1.0 2.1.1 2.1.2.4 2.2.0 2.2.1.1 2.2.1.2 2.2.11 2.2.12 2.2.13.1 2.2.14 2.2.15.1 2.2.16 2.2.17
permalink-manager / includes / views / permalink-manager-debug.php
permalink-manager / includes / views Last commit date
permalink-manager-debug.php 3 months ago permalink-manager-permastructures.php 1 month ago permalink-manager-settings.php 3 months ago permalink-manager-tools.php 3 months ago permalink-manager-ui-elements.php 3 months ago permalink-manager-uri-editor-post.php 1 month ago permalink-manager-uri-editor.php 3 months ago
permalink-manager-debug.php
132 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 /**
6 * Display the page where the slugs could be regenerated or replaced
7 */
8 class Permalink_Manager_Debug {
9
10 public function __construct() {
11 add_filter( 'permalink_manager_sections', array( $this, 'add_debug_section' ), 4 );
12 }
13
14 /**
15 * Add a new section to the Permalink Manager UI
16 *
17 * @param array $admin_sections
18 *
19 * @return array
20 */
21 public function add_debug_section( $admin_sections ) {
22 $admin_sections['debug'] = array(
23 'name' => __( 'Debug', 'permalink-manager' ),
24 'function' => array( 'class' => 'Permalink_Manager_Debug', 'method' => 'output' )
25 );
26
27 return $admin_sections;
28 }
29
30 /**
31 * Get a URL pointing to the "Debug" tab in Permalink Manager UI
32 *
33 * @param string $field
34 *
35 * @return string
36 */
37 public function get_remove_settings_url( $field = '' ) {
38 return add_query_arg( array(
39 'section' => 'debug',
40 'remove-permalink-manager-settings' => $field,
41 'permalink-manager-nonce' => wp_create_nonce( 'permalink-manager' )
42 ), Permalink_Manager_Admin_Functions::get_admin_url() );
43 }
44
45 /**
46 * Define and display HTML output of a new section with the "Debug" data
47 *
48 * @return string
49 */
50 public function output() {
51 global $permalink_manager_options, $permalink_manager_permastructs, $permalink_manager_redirects, $permalink_manager_external_redirects;
52
53 // Get the permalinks array & count permalinks and calculate the size of array
54 $custom_permalinks = Permalink_Manager_URI_Functions::get_all_uris();
55 list ( $custom_permalinks_size, $custom_permalinks_count ) = Permalink_Manager_URI_Functions::get_all_uris( true );
56
57 if ( $custom_permalinks_count >= 1 ) {
58 $custom_permalinks_size = ( is_numeric( ( $custom_permalinks_size ) ) ) ? round( $custom_permalinks_size / 1024, 2 ) . __( 'kb', 'permalink-manager' ) : '-';
59 /* translators: 1: Custom permalinks count, 2: Custom permalinks array size */
60 $custom_permalinks_stats = sprintf( __( 'Custom permalinks count: <strong>%1$s</strong> | Custom permalinks array size in DB: <strong>%2$s</strong>', 'permalink-manager' ), esc_html( $custom_permalinks_count ), esc_html( $custom_permalinks_size ) );
61 } else {
62 $custom_permalinks_stats = __( 'The custom permalinks array has not been stored in the database yet.', 'permalink-manager' );
63 }
64
65 $sections_and_fields = apply_filters( 'permalink_manager_debug_fields', array(
66 'debug-data' => array(
67 'section_name' => __( 'Debug data', 'permalink-manager' ),
68 'fields' => array(
69 'uris' => array(
70 'type' => 'textarea',
71 'description' => sprintf( '%s<br />%s<br /><strong><a class="pm-confirm-action" href="%s">%s</a></strong>', __( 'List of the URIs generated by this plugin.', 'permalink-manager' ), $custom_permalinks_stats, $this->get_remove_settings_url( 'uris' ), __( 'Remove all custom permalinks', 'permalink-manager' ) ),
72 'label' => __( 'Array with custom permalinks', 'permalink-manager' ),
73 'input_class' => 'short-textarea widefat',
74 'value' => ( $custom_permalinks ) ? print_r( $custom_permalinks, true ) : ''
75 ),
76 'custom-redirects' => array(
77 'type' => 'textarea',
78 'description' => sprintf( '%s<br /><strong><a class="pm-confirm-action" href="%s">%s</a></strong>', __( 'List of custom redirects set-up by this plugin.', 'permalink-manager' ), $this->get_remove_settings_url( 'redirects' ), __( 'Remove all custom redirects', 'permalink-manager' ) ),
79 'label' => __( 'Array with redirects', 'permalink-manager' ),
80 'input_class' => 'short-textarea widefat',
81 'value' => ( $permalink_manager_redirects ) ? print_r( $permalink_manager_redirects, true ) : ''
82 ),
83 'external-redirects' => array(
84 'type' => 'textarea',
85 'description' => sprintf( '%s<br /><strong><a class="pm-confirm-action" href="%s">%s</a></strong>', __( 'List of external redirects set-up by this plugin.', 'permalink-manager' ), $this->get_remove_settings_url( 'external-redirects' ), __( 'Remove all external redirects', 'permalink-manager' ) ),
86 'label' => __( 'Array with external redirects', 'permalink-manager' ),
87 'input_class' => 'short-textarea widefat',
88 'value' => ( $permalink_manager_external_redirects ) ? print_r( array_filter( $permalink_manager_external_redirects ), true ) : ''
89 ),
90 'permastructs' => array(
91 'type' => 'textarea',
92 'description' => sprintf( '%s<br /><strong><a class="pm-confirm-action" href="%s">%s</a></strong>', __( 'List of permastructures set-up by this plugin.', 'permalink-manager' ), $this->get_remove_settings_url( 'permastructs' ), __( 'Remove all permastructures settings', 'permalink-manager' ) ),
93 'label' => __( 'Array with permastructures', 'permalink-manager' ),
94 'input_class' => 'short-textarea widefat',
95 'value' => ( $permalink_manager_permastructs ) ? print_r( $permalink_manager_permastructs, true ) : ''
96 ),
97 'settings' => array(
98 'type' => 'textarea',
99 'description' => sprintf( '%s<br /><strong><a class="pm-confirm-action" href="%s">%s</a></strong>', __( 'List of plugin settings.', 'permalink-manager' ), $this->get_remove_settings_url( 'settings' ), __( 'Remove all plugin settings', 'permalink-manager' ) ),
100 'label' => __( 'Array with settings used in this plugin.', 'permalink-manager' ),
101 'input_class' => 'short-textarea widefat',
102 'value' => print_r( $permalink_manager_options, true )
103 )
104 )
105 )
106 ) );
107
108 // Now get the HTML output
109 $output = '';
110 foreach ( $sections_and_fields as $section_id => $section ) {
111 $output .= ( isset( $section['section_name'] ) ) ? "<h3>{$section['section_name']}</h3>" : "";
112 $output .= ( isset( $section['description'] ) ) ? "<p class=\"description\">{$section['description']}</p>" : "";
113 $output .= "<table class=\"form-table fixed-table\">";
114
115 // Loop through all fields assigned to this section
116 foreach ( $section['fields'] as $field_id => $field ) {
117 $field_name = "{$section_id}[$field_id]";
118 $field['container'] = 'row';
119
120 $output .= Permalink_Manager_UI_Elements::generate_option_field( $field_name, $field );
121 }
122
123 // End the section
124 $output .= "</table>";
125
126 }
127
128 return $output;
129 }
130
131 }
132