permalink-manager-actions.php
9 years ago
permalink-manager-admin-functions.php
9 years ago
permalink-manager-helper-functions.php
9 years ago
permalink-manager-uri-functions-post.php
9 years ago
permalink-manager-admin-functions.php
469 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Additional back-end functions related to Wordpress Dashboard UI |
| 5 | */ |
| 6 | class Permalink_Manager_Admin_Functions extends Permalink_Manager_Class { |
| 7 | |
| 8 | public $menu_name, $sections, $active_section, $active_subsection; |
| 9 | public $plugin_slug = PERMALINK_MANAGER_PLUGIN_SLUG; |
| 10 | public $plugin_basename = PERMALINK_MANAGER_BASENAME; |
| 11 | |
| 12 | public function __construct() { |
| 13 | add_action( 'admin_menu', array($this, 'add_menu_page') ); |
| 14 | add_action( 'admin_init', array($this, 'init') ); |
| 15 | add_action( 'admin_notices', array($this, 'custom_admin_notices') ); |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Hooks that should be triggered with "admin_init" |
| 20 | */ |
| 21 | public function init() { |
| 22 | // Additional link in "Plugins" page |
| 23 | add_filter( "plugin_action_links_{$this->plugin_basename}", array($this, "plugins_page_links") ); |
| 24 | |
| 25 | // Detect current section |
| 26 | $this->sections = apply_filters('permalink-manager-sections', array()); |
| 27 | $this->get_current_section(); |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * Get current section (only in plugin sections) |
| 32 | */ |
| 33 | public function get_current_section() { |
| 34 | global $active_section, $active_subsection, $current_admin_tax; |
| 35 | |
| 36 | // 1. Get current section |
| 37 | if(isset($_GET['page']) && $_GET['page'] == $this->plugin_slug) { |
| 38 | if(isset($_POST['section'])) { |
| 39 | $this->active_section = $_POST['section']; |
| 40 | } else if(isset($_GET['section'])) { |
| 41 | $this->active_section = $_GET['section']; |
| 42 | } else { |
| 43 | $sections_names = array_keys($this->sections); |
| 44 | $this->active_section = $sections_names[0]; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | // 2. Get current subsection |
| 49 | if($this->active_section && isset($this->sections[$this->active_section]['subsections'])) { |
| 50 | if(isset($_POST['subsection'])) { |
| 51 | $this->active_subsection = $_POST['subsection']; |
| 52 | } else if(isset($_GET['subsection'])) { |
| 53 | $this->active_subsection = $_GET['subsection']; |
| 54 | } else { |
| 55 | $subsections_names = array_keys($this->sections[$this->active_section]['subsections']); |
| 56 | $this->active_subsection = $subsections_names[0]; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | // Check if current admin page is related to taxonomies |
| 61 | if(substr($this->active_subsection, 0, 4) == 'tax_') { |
| 62 | $current_admin_tax = substr($this->active_subsection, 4, strlen($this->active_subsection)); |
| 63 | } else { |
| 64 | $current_admin_tax = false; |
| 65 | } |
| 66 | |
| 67 | // Set globals |
| 68 | $active_section = $this->active_section; |
| 69 | $active_subsection = $this->active_subsection; |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Add menu page. |
| 74 | */ |
| 75 | public function add_menu_page() { |
| 76 | $this->menu_name = add_management_page( __('Permalink Manager', 'permalink-manager'), __('Permalink Manager', 'permalink-manager'), 'manage_options', $this->plugin_slug, array($this, 'display_section') ); |
| 77 | |
| 78 | add_action( 'admin_init', array($this, 'enqueue_styles' ) ); |
| 79 | add_action( 'admin_init', array($this, 'enqueue_scripts' ) ); |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Register the CSS file for the dashboard. |
| 84 | */ |
| 85 | public function enqueue_styles() { |
| 86 | wp_enqueue_style( $this->plugin_slug, PERMALINK_MANAGER_URL . '/out/permalink-manager-admin.css', array(), PERMALINK_MANAGER_VERSION, 'all' ); |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * Register the JavaScript file for the dashboard. |
| 91 | */ |
| 92 | public function enqueue_scripts() { |
| 93 | wp_enqueue_script( $this->plugin_slug, PERMALINK_MANAGER_URL . '/out/permalink-manager-admin.js', array( 'jquery' ), PERMALINK_MANAGER_VERSION, false ); |
| 94 | } |
| 95 | |
| 96 | /** |
| 97 | * Get admin url for the plugin |
| 98 | */ |
| 99 | function get_admin_url($append = '') { |
| 100 | return menu_page_url( "{$this->plugin_slug}", false ) . $append; |
| 101 | } |
| 102 | |
| 103 | /** |
| 104 | * Additional links on "Plugins" page |
| 105 | */ |
| 106 | public function plugins_page_links($links) { |
| 107 | $links[] = '<a href="' . $this->get_admin_url() .'">' . __( 'Go To Permalink Manager', 'permalink-manager' ) . '</a>'; |
| 108 | return $links; |
| 109 | } |
| 110 | |
| 111 | /** |
| 112 | * Generate the fields |
| 113 | */ |
| 114 | static public function generate_option_field($input_name, $args) { |
| 115 | global $permalink_manager_options; |
| 116 | |
| 117 | // Reset $fields variables |
| 118 | $fields = $section_name = $field_name = ''; |
| 119 | |
| 120 | // Allow to filter the $args |
| 121 | $args = apply_filters('permalink-manager-field-args', $args, $input_name); |
| 122 | |
| 123 | $default = (isset($args['default'])) ? $args['default'] : ''; |
| 124 | $label = (isset($args['label'])) ? $args['label'] : ''; |
| 125 | $placeholder = (isset($args['placeholder'])) ? "placeholder=\"{$args['placeholder']}\"" : ''; |
| 126 | $readonly = (isset($args['readonly'])) ? "readonly=\"readonly\"" : ''; |
| 127 | $rows = (isset($args['rows'])) ? "rows=\"{$rows}\"" : "rows=\"5\""; |
| 128 | $input_class = (isset($args['input_class'])) ? "class=\"{$args['input_class']}\"" : ''; |
| 129 | $container_class = (isset($args['container_class'])) ? " class=\"{$args['container_class']} field-container\"" : " class=\"field-container\""; |
| 130 | $description = (isset($args['description'])) ? "<p class=\"field-description description\">{$args['description']}</p>" : ""; |
| 131 | $append_content = (isset($args['append_content'])) ? "{$args['append_content']}" : ""; |
| 132 | |
| 133 | // Get the field value (if it is not set in $args) |
| 134 | if(isset($args['value']) && empty($args['value']) == false) { |
| 135 | $value = $args['value']; |
| 136 | } else { |
| 137 | // Extract the section and field name from $input_name |
| 138 | preg_match("/(.*)\[(.*)\]/", $input_name, $field_section_and_name); |
| 139 | |
| 140 | if($field_section_and_name) { |
| 141 | $section_name = $field_section_and_name[1]; |
| 142 | $field_name = $field_section_and_name[2]; |
| 143 | $value = (isset($permalink_manager_options[$section_name][$field_name])) ? $permalink_manager_options[$section_name][$field_name] : $default; |
| 144 | } else { |
| 145 | $value = (isset($permalink_manager_options[$input_name])) ? $permalink_manager_options[$input_name] : $default; |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | switch($args['type']) { |
| 150 | case 'checkbox' : |
| 151 | $fields .= '<div class="checkboxes">'; |
| 152 | foreach($args['choices'] as $choice_value => $checkbox_label) { |
| 153 | $checked = (is_array($value) && in_array($choice_value, $value)) ? "checked='checked'" : ""; |
| 154 | $fields .= "<label for='{$input_name}[]'><input type='checkbox' {$input_class} value='{$choice_value}' name='{$input_name}[]' {$checked} /> {$checkbox_label}</label>"; |
| 155 | } |
| 156 | $fields .= '</div>'; |
| 157 | |
| 158 | // Add helper checkboxes for bulk actions |
| 159 | if(isset($args['select_all']) || isset($args['unselect_all'])) { |
| 160 | $select_all_label = (!empty($args['select_all'])) ? $args['select_all'] : __('Select all', 'permalink-manager'); |
| 161 | $unselect_all_label = (!empty($args['unselect_all'])) ? $args['unselect_all'] : __('Unselect all', 'permalink-manager'); |
| 162 | |
| 163 | $fields .= "<p class=\"checkbox_actions extra-links\">"; |
| 164 | $fields .= (isset($args['select_all'])) ? "<a href=\"#\" class=\"select_all\">{$select_all_label}</a> " : ""; |
| 165 | $fields .= (isset($args['unselect_all'])) ? "<a href=\"#\" class=\"unselect_all\">{$unselect_all_label}</a>" : ""; |
| 166 | $fields .= "</p>"; |
| 167 | } |
| 168 | break; |
| 169 | |
| 170 | case 'single_checkbox' : |
| 171 | $fields .= '<div class="checkboxes">'; |
| 172 | $checked = ($value == 1) ? "checked='checked'" : ""; |
| 173 | $checkbox_label = (isset($args['checkbox_label'])) ? $args['checkbox_label'] : ''; |
| 174 | |
| 175 | $fields .= "<label for='{$input_name}'><input type='checkbox' {$input_class} value='1' name='{$input_name}' {$checked} /> {$checkbox_label}</label>"; |
| 176 | $fields .= '</div>'; |
| 177 | break; |
| 178 | |
| 179 | case 'radio' : |
| 180 | $fields .= '<div class="radios">'; |
| 181 | foreach($args['choices'] as $choice_value => $checkbox_label) { |
| 182 | $checked = ($choice_value == $value) ? "checked='checked'" : ""; |
| 183 | $fields .= "<label for='{$input_name}[]'><input type='radio' {$input_class} value='{$choice_value}' name='{$input_name}[]' {$checked} /> {$checkbox_label}</label>"; |
| 184 | } |
| 185 | $fields .= '</div>'; |
| 186 | break; |
| 187 | |
| 188 | case 'select' : |
| 189 | $fields .= '<div class="select">'; |
| 190 | $fields .= "<select name='{$input_name}' {$input_class}>"; |
| 191 | foreach($args['choices'] as $choice_value => $checkbox_label) { |
| 192 | $selected = ($choice_value == $value) ? "selected='selected'" : ""; |
| 193 | $fields .= "<option value='{$choice_value}' {$selected} />{$checkbox_label}</option>"; |
| 194 | } |
| 195 | $fields .= '</select>'; |
| 196 | $fields .= '</div>'; |
| 197 | break; |
| 198 | |
| 199 | case 'number' : |
| 200 | $fields .= "<input type='number' {$input_class} value='{$value}' name='{$input_name}' />"; |
| 201 | break; |
| 202 | |
| 203 | case 'hidden' : |
| 204 | $fields .= "<input type='hidden' {$input_class} value='{$value}' name='{$input_name}' />"; |
| 205 | break; |
| 206 | |
| 207 | case 'textarea' : |
| 208 | $fields .= "<textarea {$input_class} name='{$input_name}' {$placeholder} {$readonly} {$rows}>{$value}</textarea>"; |
| 209 | break; |
| 210 | |
| 211 | case 'pre' : |
| 212 | $fields .= "<pre {$input_class}>{$value}</pre>"; |
| 213 | break; |
| 214 | |
| 215 | case 'clearfix' : |
| 216 | return "<div class=\"clearfix\"></div>"; |
| 217 | |
| 218 | case 'permastruct' : |
| 219 | $siteurl = get_option('home'); |
| 220 | $fields .= "<code>{$siteurl}/</code><input type='text' {$input_class} value='{$value}' name='{$input_name}' {$placeholder} {$readonly}/>"; |
| 221 | break; |
| 222 | |
| 223 | default : |
| 224 | $fields .= "<input type='text' {$input_class} value='{$value}' name='{$input_name}' {$placeholder} {$readonly}/>"; |
| 225 | } |
| 226 | |
| 227 | // Get the final HTML output |
| 228 | if(isset($args['container']) && $args['container'] == 'tools') { |
| 229 | $output = "<div{$container_class}>"; |
| 230 | $output .= "<h4>{$label}</h4>"; |
| 231 | $output .= "<div class='{$input_name}-container'>{$fields}</div>"; |
| 232 | $output .= $description; |
| 233 | $output .= $append_content; |
| 234 | $output .= "</div>"; |
| 235 | } else if(isset($args['container']) && $args['container'] == 'row') { |
| 236 | $output = "<tr><th><label for='{$input_name}'>{$args['label']}</label></th>"; |
| 237 | $output .= "<td>{$fields}{$description}</td></tr>"; |
| 238 | $output .= ($append_content) ? "<tr class=\"appended-row\"><td colspan=\"2\">{$append_content}</td></tr>" : ""; |
| 239 | } else { |
| 240 | $output = $fields . $append_content; |
| 241 | } |
| 242 | |
| 243 | return apply_filters('permalink-manager-field-output', $output); |
| 244 | } |
| 245 | |
| 246 | /** |
| 247 | * Display hidden field to indicate posts or taxonomies admin sections |
| 248 | */ |
| 249 | static public function section_type_field($type = 'post') { |
| 250 | return self::generate_option_field('section_type', array('value' => $type, 'type' => 'hidden')); |
| 251 | } |
| 252 | |
| 253 | /** |
| 254 | * Display the form |
| 255 | */ |
| 256 | static public function get_the_form($fields = array(), $container = '', $button = array(), $sidebar = '', $nonce = array()) { |
| 257 | // 1. Check if the content will be displayed in columns and button details |
| 258 | switch($container) { |
| 259 | case 'columns-3' : |
| 260 | $wrapper_class = 'columns-container'; |
| 261 | $form_column_class = 'column column-2_3'; |
| 262 | $sidebar_class = 'column column-1_3'; |
| 263 | break; |
| 264 | // there will be more cases in future ... |
| 265 | default : |
| 266 | $form_column_class = 'form'; |
| 267 | $sidebar_class = 'sidebar'; |
| 268 | $wrapper_class = $form_column_class = ''; |
| 269 | } |
| 270 | |
| 271 | // 2. Process the array with button and nonce field settings |
| 272 | $button_text = (!empty($button['text'])) ? $button['text'] : ''; |
| 273 | $button_class = (!empty($button['class'])) ? $button['class'] : ''; |
| 274 | $nonce_action = (!empty($nonce['action'])) ? $nonce['action'] : ''; |
| 275 | $nonce_name = (!empty($nonce['name'])) ? $nonce['name'] : ''; |
| 276 | |
| 277 | // 2. Now get the HTML output (start section row container) |
| 278 | $output = ($wrapper_class) ? "<div class=\"{$wrapper_class}\">" : ''; |
| 279 | |
| 280 | // 3. Display some notes |
| 281 | if($sidebar_class && $sidebar) { |
| 282 | $output .= "<div class=\"{$sidebar_class}\">"; |
| 283 | $output .= "<div class=\"section-notes\">"; |
| 284 | $output .= $sidebar; |
| 285 | $output .= "</div>"; |
| 286 | $output .= "</div>"; |
| 287 | } |
| 288 | |
| 289 | // 4. Start fields' section |
| 290 | $output .= ($form_column_class) ? "<div class=\"{$form_column_class}\">" : ""; |
| 291 | $output .= "<form method=\"POST\">"; |
| 292 | |
| 293 | // Loop through all fields assigned to this section |
| 294 | foreach($fields as $field_name => $field) { |
| 295 | $field_name = (!empty($field['name'])) ? $field['name'] : $field_name; |
| 296 | |
| 297 | // A. Display table row |
| 298 | if(isset($field['container']) && $field['container'] == 'row') { |
| 299 | $output .= (isset($field['section_name'])) ? "<h3>{$field['section_name']}</h3>" : ""; |
| 300 | $output .= (isset($field['description'])) ? "<p class=\"description\">{$field['description']}</p>" : ""; |
| 301 | $output .= (isset($field['append_content'])) ? $field['append_content'] : ""; |
| 302 | $output .= "<table class=\"form-table\">"; |
| 303 | |
| 304 | // Loop through all fields assigned to this section |
| 305 | if(isset($field['fields'])) { |
| 306 | foreach($field['fields'] as $section_field_id => $section_field) { |
| 307 | $section_field_name = (!empty($section_field['name'])) ? $section_field['name'] : "{$field_name}[$section_field_id]"; |
| 308 | $section_field['container'] = 'row'; |
| 309 | |
| 310 | $output .= self::generate_option_field($section_field_name, $section_field); |
| 311 | } |
| 312 | } else { |
| 313 | $output .= self::generate_option_field($field_name, $field); |
| 314 | } |
| 315 | |
| 316 | $output .= "</table>"; |
| 317 | } |
| 318 | // B. Display single field |
| 319 | else { |
| 320 | $output .= self::generate_option_field($field_name, $field); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | // End the fields' section + add button & nonce fields |
| 325 | $output .= ($nonce_action && $nonce_name) ? wp_nonce_field($nonce_action, $nonce_name, true, true) : ""; |
| 326 | $output .= ($button_text) ? get_submit_button($button_text, $button_class, '', false) : ""; |
| 327 | $output .= '</form>'; |
| 328 | $output .= ($form_column_class) ? "</div>" : ""; |
| 329 | |
| 330 | // 5. End the section row container |
| 331 | $output .= ($wrapper_class) ? "</div>" : ""; |
| 332 | |
| 333 | return $output; |
| 334 | } |
| 335 | |
| 336 | /** |
| 337 | * Display the plugin sections. |
| 338 | */ |
| 339 | public function display_section() { |
| 340 | global $wpdb, $permalink_manager_before_sections_html, $permalink_manager_after_sections_html; |
| 341 | |
| 342 | $output = "<div id=\"permalink-manager\" class=\"wrap\">"; |
| 343 | |
| 344 | // Display alerts [moved to custom_admin_notices() function] and another content if needed and the plugin header |
| 345 | // $output .= $permalink_manager_before_sections_html; |
| 346 | $output .= "<h2 id=\"plugin-name-heading\">" . PERMALINK_MANAGER_PLUGIN_NAME . " <a href=\"" . PERMALINK_MANAGER_WEBSITE ."\" target=\"_blank\">" . __('by Maciej Bis', 'permalink-manager') . "</a></h2>"; |
| 347 | |
| 348 | // Display the tab navigation |
| 349 | $output .= "<div id=\"permalink-manager-tab-nav\" class=\"nav-tab-wrapper\">"; |
| 350 | foreach($this->sections as $section_name => $section_properties) { |
| 351 | $active_class = ($this->active_section === $section_name) ? 'nav-tab-active nav-tab' : 'nav-tab'; |
| 352 | $section_url = $this->get_admin_url("§ion={$section_name}"); |
| 353 | |
| 354 | $output .= "<a href=\"{$section_url}\" class=\"{$active_class}\">{$section_properties['name']}</a>"; |
| 355 | } |
| 356 | $output .= "</div>"; |
| 357 | |
| 358 | // Now display the active section |
| 359 | $output .= "<div id=\"permalink-manager-sections\">"; |
| 360 | $active_section_array = (isset($this->sections[$this->active_section])) ? $this->sections[$this->active_section] : ""; |
| 361 | |
| 362 | // Display addidional navigation for subsections |
| 363 | if(isset($this->sections[$this->active_section]['subsections'])) { |
| 364 | $output .= "<ul class=\"subsubsub\">"; |
| 365 | foreach ($this->sections[$this->active_section]['subsections'] as $subsection_name => $subsection) { |
| 366 | $active_class = ($this->active_subsection === $subsection_name) ? 'current' : ''; |
| 367 | $subsection_url = $this->get_admin_url("§ion={$this->active_section}&subsection={$subsection_name}"); |
| 368 | |
| 369 | $output .= "<li><a href=\"{$subsection_url}\" class=\"{$active_class}\">{$subsection['name']}</a></li>"; |
| 370 | } |
| 371 | $output .= "</ul>"; |
| 372 | } |
| 373 | |
| 374 | // A. Execute the function assigned to the subsection |
| 375 | if(isset($active_section_array['subsections'][$this->active_subsection]['function'])) { |
| 376 | $class_name = $active_section_array['subsections'][$this->active_subsection]['function']['class']; |
| 377 | $section_object = new $class_name(); |
| 378 | |
| 379 | $section_content = call_user_func(array($section_object, $active_section_array['subsections'][$this->active_subsection]['function']['method'])); |
| 380 | } |
| 381 | // B. Execute the function assigned to the section |
| 382 | else if(isset($active_section_array['function'])) { |
| 383 | $class_name = $active_section_array['function']['class']; |
| 384 | $section_object = new $class_name(); |
| 385 | |
| 386 | $section_content = call_user_func(array($section_object, $active_section_array['function']['method'])); |
| 387 | } |
| 388 | // C. Display the raw HTMl output of subsection |
| 389 | else if(isset($active_section_array['subsections'][$this->active_subsection]['html'])) { |
| 390 | $section_content = (isset($active_section_array['subsections'][$this->active_subsection]['html'])) ? $active_section_array['subsections'][$this->active_subsection]['html'] : ""; |
| 391 | } |
| 392 | // D. Try to display the raw HTMl output of section |
| 393 | else { |
| 394 | $section_content = (isset($active_section_array['html'])) ? $active_section_array['html'] : ""; |
| 395 | } |
| 396 | |
| 397 | $output .= "<div data-section=\"{$this->active_section}\" id=\"{$this->active_section}\">{$section_content}</div>"; |
| 398 | $output .= "</div>"; |
| 399 | |
| 400 | // Display alerts and another content if needed and close .wrap container |
| 401 | $output .= $permalink_manager_after_sections_html; |
| 402 | $output .= "</div>"; |
| 403 | |
| 404 | echo $output; |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Display error/info message |
| 409 | */ |
| 410 | public static function get_alert_message($alert_content, $alert_type, $dismissable = true) { |
| 411 | $class = ($dismissable) ? "is-dismissible" : ""; |
| 412 | $output = sprintf( "<div class=\"{$alert_type} notice {$class}\"> %s</div>", wpautop($alert_content) ); |
| 413 | |
| 414 | return $output; |
| 415 | } |
| 416 | |
| 417 | static function pro_text() { |
| 418 | $output = sprintf( "<div class=\"alert info\"> %s</div>", wpautop(__('This functionality is available only in "Permalink Manager Pro".'), 'alert', false) ); |
| 419 | return $output; |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * Display the table with updated slugs after one of the actions is triggered |
| 424 | */ |
| 425 | static function display_updated_slugs($updated_array, $uri_type = 'post') { |
| 426 | // Check if slugs should be displayed |
| 427 | $first_slug = reset($updated_array); |
| 428 | |
| 429 | $header_footer = '<tr>'; |
| 430 | $header_footer .= '<th class="column-primary">' . __('Title', 'permalink-manager') . '</th>'; |
| 431 | $header_footer .= '<th>' . __('Old URI', 'permalink-manager') . '</th>'; |
| 432 | $header_footer .= '<th>' . __('New URI', 'permalink-manager') . '</th>'; |
| 433 | $header_footer .= (isset($first_slug['old_slug'])) ? '<th>' . __('Old Slug', 'permalink-manager') . '</th>' : ""; |
| 434 | $header_footer .= (isset($first_slug['new_slug'])) ? '<th>' . __('New Slug', 'permalink-manager') . '</th>' : ""; |
| 435 | $header_footer .= '</tr>'; |
| 436 | |
| 437 | $updated_slugs_count = 0; |
| 438 | $main_content = ""; |
| 439 | foreach($updated_array as $row) { |
| 440 | // Odd/even class |
| 441 | $updated_slugs_count++; |
| 442 | $alternate_class = ($updated_slugs_count % 2 == 1) ? ' class="alternate"' : ''; |
| 443 | $permalink = get_permalink($row['ID']); |
| 444 | |
| 445 | $main_content .= "<tr{$alternate_class}>"; |
| 446 | $main_content .= '<td class="row-title column-primary" data-colname="' . __('Title', 'permalink-manager') . '">' . $row['post_title'] . "<a target=\"_blank\" href=\"{$permalink}\"><span class=\"small\">{$permalink}</span></a>" . '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __('Show more details', 'permalink-manager') . '</span></button></td>'; |
| 447 | $main_content .= '<td data-colname="' . __('Old URI', 'permalink-manager') . '">' . $row['old_uri'] . '</td>'; |
| 448 | $main_content .= '<td data-colname="' . __('New URI', 'permalink-manager') . '">' . $row['new_uri'] . '</td>'; |
| 449 | $main_content .= (isset($row['old_slug'])) ? '<td data-colname="' . __('Old Slug', 'permalink-manager') . '">' . $row['old_slug'] . '</td>' : ""; |
| 450 | $main_content .= (isset($row['new_slug'])) ? '<td data-colname="' . __('New Slug', 'permalink-manager') . '">' . $row['new_slug'] . '</td>' : ""; |
| 451 | $main_content .= '</tr>'; |
| 452 | } |
| 453 | |
| 454 | // Merge header, footer and content |
| 455 | $output = '<h3 id="updated-list">' . __('List of updated items', 'permalink-manager') . '</h3>'; |
| 456 | $output .= '<table class="widefat wp-list-table updated-slugs-table">'; |
| 457 | $output .= "<thead>{$header_footer}</thead><tbody>{$main_content}</tbody><tfoot>{$header_footer}</tfoot>"; |
| 458 | $output .= '</table>'; |
| 459 | |
| 460 | return $output; |
| 461 | } |
| 462 | |
| 463 | function custom_admin_notices() { |
| 464 | global $permalink_manager_before_sections_html; |
| 465 | echo $permalink_manager_before_sections_html; |
| 466 | } |
| 467 | |
| 468 | } |
| 469 |