PluginProbe ʕ •ᴥ•ʔ
Permalink Manager Lite / 2.0.3
Permalink Manager Lite v2.0.3
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-tools.php
permalink-manager / includes / views Last commit date
permalink-manager-debug.php 8 years ago permalink-manager-permastructs.php 8 years ago permalink-manager-settings.php 8 years ago permalink-manager-tools.php 8 years ago permalink-manager-upgrade.php 8 years ago permalink-manager-uri-editor-post.php 8 years ago permalink-manager-uri-editor.php 8 years ago
permalink-manager-tools.php
261 lines
1 <?php
2
3 /**
4 * Display the page where the slugs could be regenerated or replaced
5 */
6 class Permalink_Manager_Tools extends Permalink_Manager_Class {
7
8 public function __construct() {
9 add_filter( 'permalink-manager-sections', array($this, 'add_admin_section'), 1 );
10 }
11
12 public function add_admin_section($admin_sections) {
13
14 $admin_sections['tools'] = array(
15 'name' => __('Tools', 'permalink-manager'),
16 'subsections' => array(
17 'duplicates' => array(
18 'name' => __('Permalink Duplicates', 'permalink-manager'),
19 'function' => array('class' => 'Permalink_Manager_Tools', 'method' => 'duplicates_output')
20 ),
21 'find_and_replace' => array(
22 'name' => __('Find & Replace', 'permalink-manager'),
23 'function' => array('class' => 'Permalink_Manager_Tools', 'method' => 'find_and_replace_output')
24 ),
25 'regenerate_slugs' => array(
26 'name' => __('Regenerate/Reset', 'permalink-manager'),
27 'function' => array('class' => 'Permalink_Manager_Tools', 'method' => 'regenerate_slugs_output')
28 ),
29 'stop_words' => array(
30 'name' => __('Stop Words', 'permalink-manager'),
31 'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
32 ),
33 'import' => array(
34 'name' => __('Custom Permalinks', 'permalink-manager'),
35 'function' => array('class' => 'Permalink_Manager_Admin_Functions', 'method' => 'pro_text')
36 )
37 )
38 );
39
40 return $admin_sections;
41 }
42
43 public function display_instructions() {
44 return wpautop(__('<strong>A MySQL backup is highly recommended before using "<em>Native slugs</em>" mode!</strong>', 'permalink-manager'));
45 }
46
47 public function duplicates_output() {
48 global $permalink_manager_uris, $permalink_manager_redirects;
49
50 // Get the duplicates & another variables
51 $all_duplicates = Permalink_Manager_Core_Functions::detect_duplicates();
52 $home_url = trim(get_option('home'), "/");
53
54 $html = sprintf("<h3>%s</h3>", __("List of duplicated permalinks", "permalink-manager"));
55
56 if(!empty($all_duplicates)) {
57 foreach($all_duplicates as $uri => $duplicates) {
58 $html .= "<div class=\"permalink-manager postbox permalink-manager-duplicate-box\">";
59 $html .= "<h4 class=\"heading\"><a href=\"{$home_url}/{$uri}\" target=\"_blank\">{$home_url}/{$uri} <span class=\"dashicons dashicons-external\"></span></a></h4>";
60 $html .= "<table>";
61
62 foreach($duplicates as $item_id) {
63 $html .= "<tr>";
64
65 // Detect duplicate type
66 preg_match("/(redirect-([\d]+)_)?(?:(tax-)?([\d]*))/", $item_id, $parts);
67
68 $redirect_type = (!empty($parts[1])) ? __('Extra Redirect', 'permalink-manager') : __('Custom URI', 'permalink-manager');
69 $detected_id = $parts[4];
70 $detected_index = $parts[2];
71 $detected_term = (!empty($parts[3])) ? true : false;
72
73 // Get term
74 if($detected_term && !empty($detected_id)) {
75 $term = get_term($detected_id);
76 $title = $term->name;
77 $edit_label = __("Edit term", "permalink-manager");
78 $edit_link = get_edit_tag_link($term->term_id, $term->taxonomy);
79 } else if(!empty($detected_id)) {
80 $post = get_post($detected_id);
81 $title = $post->post_title;
82 $edit_label = __("Edit post", "permalink-manager");
83 $edit_link = get_edit_post_link($post->ID);
84 } else {
85 continue;
86 }
87
88 $html .= sprintf(
89 //'<td><a href="%1$s" target="_blank">%2$s</a>%3$s</td><td>%4$s</td><td class="actions"><a href="%1$s" target="_blank"><span class="dashicons dashicons-edit"></span> %5$s</a> | <a class="remove-duplicate-link" href="%6$s"><span class="dashicons dashicons-trash"></span> %7$s</a></td>',
90 '<td><a href="%1$s" target="_blank">%2$s</a>%3$s</td><td>%4$s</td><td class="actions"><a href="%1$s" target="_blank"><span class="dashicons dashicons-edit"></span> %5$s</a></td>',
91 $edit_link,
92 $title,
93 " <small>#{$detected_id}</small>",
94 $redirect_type,
95 $edit_label
96 );
97 $html .= "</tr>";
98 }
99 $html .= "</table>";
100 $html .= "</div>";
101 }
102 } else {
103 $html .= sprintf("<p class=\"alert notice-success notice\">%s</p>", __('Congratulations! No duplicated URIs or Redirects found!', 'permalink-manager'));
104 }
105
106 return $html;
107 }
108
109 public function find_and_replace_output() {
110 // Get all registered post types array & statuses
111 $all_post_statuses_array = get_post_statuses();
112 $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
113 $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
114
115 $fields = apply_filters('permalink-manager-tools-fields', array(
116 'old_string' => array(
117 'label' => __( 'Find ...', 'permalink-manager' ),
118 'type' => 'text',
119 'container' => 'row',
120 'input_class' => 'widefat'
121 ),
122 'new_string' => array(
123 'label' => __( 'Replace with ...', 'permalink-manager' ),
124 'type' => 'text',
125 'container' => 'row',
126 'input_class' => 'widefat'
127 ),
128 'mode' => array(
129 'label' => __( 'Mode', 'permalink-manager' ),
130 'type' => 'select',
131 'container' => 'row',
132 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Native slugs', 'permalink-manager')),
133 ),
134 'content_type' => array(
135 'label' => __( 'Select content type', 'permalink-manager' ),
136 'type' => 'select',
137 'disabled' => true,
138 'pro' => true,
139 'container' => 'row',
140 'default' => 'post_types',
141 'choices' => array('post_types' => __('Post types', 'permalink-manager'), 'taxonomies' => __('Taxonomies', 'permalink-manager')),
142 ),
143 'post_types' => array(
144 'label' => __( 'Select post types', 'permalink-manager' ),
145 'type' => 'checkbox',
146 'container' => 'row',
147 'default' => array('post', 'page'),
148 'choices' => $all_post_types,
149 'select_all' => '',
150 'unselect_all' => '',
151 ),
152 'taxonomies' => array(
153 'label' => __( 'Select taxonomies', 'permalink-manager' ),
154 'type' => 'checkbox',
155 'container' => 'row',
156 'container_class' => 'hidden',
157 'default' => array('category', 'post_tag'),
158 'choices' => $all_taxonomies,
159 'pro' => true,
160 'select_all' => '',
161 'unselect_all' => '',
162 ),
163 'post_statuses' => array(
164 'label' => __( 'Select post statuses', 'permalink-manager' ),
165 'type' => 'checkbox',
166 'container' => 'row',
167 'default' => array('publish'),
168 'choices' => $all_post_statuses_array,
169 'select_all' => '',
170 'unselect_all' => '',
171 ),
172 'ids' => array(
173 'label' => __( 'Select IDs', 'permalink-manager' ),
174 'type' => 'text',
175 'container' => 'row',
176 //'disabled' => true,
177 'description' => __('To narrow the above filters you can type the post IDs (or ranges) here. Eg. <strong>1-8, 10, 25</strong>.', 'permalink-manager'),
178 //'pro' => true,
179 'input_class' => 'widefat'
180 )
181 ), 'find_and_replace');
182
183 $sidebar = '<h3>' . __('Important notices', 'permalink-manager') . '</h3>';
184 $sidebar .= self::display_instructions();
185
186 $output = Permalink_Manager_Admin_Functions::get_the_form($fields, 'columns-3', array('text' => __('Find and replace', 'permalink-manager'), 'class' => 'primary margin-top'), $sidebar, array('action' => 'permalink-manager', 'name' => 'find_and_replace'), true);
187
188 return $output;
189 }
190
191 public function regenerate_slugs_output() {
192 // Get all registered post types array & statuses
193 $all_post_statuses_array = get_post_statuses();
194 $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array();
195 $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array();
196
197 $fields = apply_filters('permalink-manager-tools-fields', array(
198 'mode' => array(
199 'label' => __( 'Mode', 'permalink-manager' ),
200 'type' => 'select',
201 'container' => 'row',
202 'choices' => array('custom_uris' => __('Custom URIs', 'permalink-manager'), 'slugs' => __('Restore native slugs', 'permalink-manager'), 'native' => __('Restore native permalinks', 'permalink-manager')),
203 ),
204 'content_type' => array(
205 'label' => __( 'Select content type', 'permalink-manager' ),
206 'type' => 'select',
207 'disabled' => true,
208 'pro' => true,
209 'container' => 'row',
210 'default' => 'post_types',
211 'choices' => array('post_types' => __('Post types', 'permalink-manager'), 'taxonomies' => __('Taxonomies', 'permalink-manager')),
212 ),
213 'post_types' => array(
214 'label' => __( 'Select post types', 'permalink-manager' ),
215 'type' => 'checkbox',
216 'container' => 'row',
217 'default' => array('post', 'page'),
218 'choices' => $all_post_types,
219 'select_all' => '',
220 'unselect_all' => '',
221 ),
222 'taxonomies' => array(
223 'label' => __( 'Select taxonomies', 'permalink-manager' ),
224 'type' => 'checkbox',
225 'container' => 'row',
226 'container_class' => 'hidden',
227 'default' => array('category', 'post_tag'),
228 'choices' => $all_taxonomies,
229 'pro' => true,
230 'select_all' => '',
231 'unselect_all' => '',
232 ),
233 'post_statuses' => array(
234 'label' => __( 'Select post statuses', 'permalink-manager' ),
235 'type' => 'checkbox',
236 'container' => 'row',
237 'default' => array('publish'),
238 'choices' => $all_post_statuses_array,
239 'select_all' => '',
240 'unselect_all' => '',
241 ),
242 'ids' => array(
243 'label' => __( 'Select IDs', 'permalink-manager' ),
244 'type' => 'text',
245 'container' => 'row',
246 //'disabled' => true,
247 'description' => __('To narrow the above filters you can type the post IDs (or ranges) here. Eg. <strong>1-8, 10, 25</strong>.', 'permalink-manager'),
248 //'pro' => true,
249 'input_class' => 'widefat'
250 )
251 ), 'regenerate');
252
253 $sidebar = '<h3>' . __('Important notices', 'permalink-manager') . '</h3>';
254 $sidebar .= self::display_instructions();
255
256 $output = Permalink_Manager_Admin_Functions::get_the_form($fields, 'columns-3', array('text' => __( 'Regenerate', 'permalink-manager' ), 'class' => 'primary margin-top'), $sidebar, array('action' => 'permalink-manager', 'name' => 'regenerate'), true);
257
258 return $output;
259 }
260 }
261