PluginProbe ʕ •ᴥ•ʔ
Permalink Manager Lite / 2.5.4
Permalink Manager Lite v2.5.4
2.5.4 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 days ago permalink-manager-permastructures.php 3 days ago permalink-manager-settings.php 3 days ago permalink-manager-tools.php 3 days ago permalink-manager-ui-elements.php 3 days ago permalink-manager-uri-editor-post.php 3 days ago permalink-manager-uri-editor.php 3 days ago
permalink-manager-debug.php
134 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Display the page where the slugs could be regenerated or replaced
9 */
10 class Permalink_Manager_Debug {
11
12 public function __construct() {
13 add_filter( 'permalink_manager_sections', array( $this, 'add_debug_section' ), 4 );
14 }
15
16 /**
17 * Add a new section to the Permalink Manager UI
18 *
19 * @param array $admin_sections
20 *
21 * @return array
22 */
23 public function add_debug_section( $admin_sections ) {
24 $admin_sections['debug'] = array(
25 'name' => __( 'Debug', 'permalink-manager' ),
26 'function' => array( 'class' => 'Permalink_Manager_Debug', 'method' => 'output' )
27 );
28
29 return $admin_sections;
30 }
31
32 /**
33 * Get a URL pointing to the "Debug" tab in Permalink Manager UI
34 *
35 * @param string $field
36 *
37 * @return string
38 */
39 public function get_remove_settings_url( $field = '' ) {
40 return add_query_arg( array(
41 'section' => 'debug',
42 'remove-permalink-manager-settings' => $field,
43 'permalink-manager-nonce' => wp_create_nonce( 'permalink-manager' )
44 ), Permalink_Manager_Admin_Functions::get_admin_url() );
45 }
46
47 /**
48 * Define and display HTML output of a new section with the "Debug" data
49 *
50 * @return string
51 */
52 public function output() {
53 global $permalink_manager_options, $permalink_manager_permastructs, $permalink_manager_redirects, $permalink_manager_external_redirects;
54
55 // Get the permalinks array & count permalinks and calculate the size of array
56 $custom_permalinks = Permalink_Manager_URI_Functions::get_all_uris();
57 list ( $custom_permalinks_size, $custom_permalinks_count ) = Permalink_Manager_URI_Functions::get_all_uris( true );
58
59 if ( $custom_permalinks_count >= 1 ) {
60 $custom_permalinks_size = ( is_numeric( ( $custom_permalinks_size ) ) ) ? round( $custom_permalinks_size / 1024, 2 ) . __( 'kb', 'permalink-manager' ) : '-';
61 /* translators: 1: Custom permalinks count, 2: Custom permalinks array size */
62 $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 ) );
63 } else {
64 $custom_permalinks_stats = __( 'The custom permalinks array has not been stored in the database yet.', 'permalink-manager' );
65 }
66
67 $sections_and_fields = apply_filters( 'permalink_manager_debug_fields', array(
68 'debug-data' => array(
69 'section_name' => __( 'Debug data', 'permalink-manager' ),
70 'fields' => array(
71 'uris' => array(
72 'type' => 'textarea',
73 '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' ) ),
74 'label' => __( 'Array with custom permalinks', 'permalink-manager' ),
75 'input_class' => 'short-textarea widefat',
76 'value' => ( $custom_permalinks ) ? Permalink_Manager_Debug_Functions::prepare_debug_data( $custom_permalinks ) : ''
77 ),
78 'custom-redirects' => array(
79 'type' => 'textarea',
80 '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' ) ),
81 'label' => __( 'Array with redirects', 'permalink-manager' ),
82 'input_class' => 'short-textarea widefat',
83 'value' => ( $permalink_manager_redirects ) ? Permalink_Manager_Debug_Functions::prepare_debug_data( $permalink_manager_redirects ) : ''
84 ),
85 'external-redirects' => array(
86 'type' => 'textarea',
87 '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' ) ),
88 'label' => __( 'Array with external redirects', 'permalink-manager' ),
89 'input_class' => 'short-textarea widefat',
90 'value' => ( $permalink_manager_external_redirects ) ? Permalink_Manager_Debug_Functions::prepare_debug_data( array_filter( $permalink_manager_external_redirects ) ) : ''
91 ),
92 'permastructs' => array(
93 'type' => 'textarea',
94 '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' ) ),
95 'label' => __( 'Array with permastructures', 'permalink-manager' ),
96 'input_class' => 'short-textarea widefat',
97 'value' => ( $permalink_manager_permastructs ) ? Permalink_Manager_Debug_Functions::prepare_debug_data( $permalink_manager_permastructs) : ''
98 ),
99 'settings' => array(
100 'type' => 'textarea',
101 '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' ) ),
102 'label' => __( 'Array with settings used in this plugin.', 'permalink-manager' ),
103 'input_class' => 'short-textarea widefat',
104 'value' => Permalink_Manager_Debug_Functions::prepare_debug_data( $permalink_manager_options )
105 )
106 )
107 )
108 ) );
109
110 // Now get the HTML output
111 $output = '';
112 foreach ( $sections_and_fields as $section_id => $section ) {
113 $output .= ( isset( $section['section_name'] ) ) ? "<h3>{$section['section_name']}</h3>" : "";
114 $output .= ( isset( $section['description'] ) ) ? "<p class=\"description\">{$section['description']}</p>" : "";
115 $output .= "<table class=\"form-table fixed-table\">";
116
117 // Loop through all fields assigned to this section
118 foreach ( $section['fields'] as $field_id => $field ) {
119 $field_name = "{$section_id}[$field_id]";
120 $field['container'] = 'row';
121
122 $output .= Permalink_Manager_UI_Elements::generate_option_field( $field_name, $field );
123 }
124
125 // End the section
126 $output .= "</table>";
127
128 }
129
130 return $output;
131 }
132
133 }
134