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-settings.php
117 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Display the settings page |
| 5 | */ |
| 6 | class Permalink_Manager_Settings 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 | $admin_sections['settings'] = array( |
| 14 | 'name' => __('Settings', 'permalink-manager'), |
| 15 | 'function' => array('class' => 'Permalink_Manager_Settings', 'method' => 'output') |
| 16 | ); |
| 17 | |
| 18 | return $admin_sections; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Get the array with settings and render the HTML output |
| 23 | */ |
| 24 | public function output() { |
| 25 | // Get all registered post types array & statuses |
| 26 | $all_post_statuses_array = get_post_statuses(); |
| 27 | $all_post_types = Permalink_Manager_Helper_Functions::get_post_types_array(null, null, true); |
| 28 | $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, false, true); |
| 29 | $content_types = (defined('PERMALINK_MANAGER_PRO')) ? array('post_types' => $all_post_types, 'taxonomies' => $all_taxonomies) : array('post_types' => $all_post_types); |
| 30 | |
| 31 | $sections_and_fields = apply_filters('permalink-manager-settings-fields', array( |
| 32 | 'general' => array( |
| 33 | 'section_name' => __('General settings', 'permalink-manager'), |
| 34 | 'container' => 'row', |
| 35 | 'name' => 'general', |
| 36 | 'fields' => array( |
| 37 | 'auto_update_uris' => array( |
| 38 | 'type' => 'single_checkbox', |
| 39 | 'label' => __('Auto-update permalinks', 'permalink-manager'), |
| 40 | 'input_class' => '', |
| 41 | 'description' => __('If enabled, the custom permalinks will be automatically updated every time the post is saved or updated.', 'permalink-manager') |
| 42 | ), |
| 43 | 'case_insensitive_permalinks' => array( |
| 44 | 'type' => 'single_checkbox', |
| 45 | 'label' => __('Case insensitive permalinks', 'permalink-manager'), |
| 46 | 'input_class' => '', |
| 47 | 'description' => __('Make all the permalinks case-insensitive.', 'permalink-manager') |
| 48 | ) |
| 49 | ) |
| 50 | ), |
| 51 | 'seo' => array( |
| 52 | 'section_name' => __('SEO functions', 'permalink-manager'), |
| 53 | 'container' => 'row', |
| 54 | 'name' => 'general', |
| 55 | 'fields' => array( |
| 56 | 'canonical_redirect' => array( |
| 57 | 'type' => 'single_checkbox', |
| 58 | 'label' => __('Canonical redirect', 'permalink-manager'), |
| 59 | 'input_class' => '', |
| 60 | 'description' => __('This function allows Wordpress to correct the URLs used by the visitors.', 'permalink-manager') |
| 61 | ), |
| 62 | 'setup_redirects' => array( |
| 63 | 'type' => 'single_checkbox', |
| 64 | 'label' => __('Auto-create "Extra Redirects" for old permalinks', 'permalink-manager'), |
| 65 | 'input_class' => '', |
| 66 | 'pro' => true, |
| 67 | 'disabled' => true, |
| 68 | 'description' => __('If enabled, the redirects will be automatially created for old custom permalinks, after posts or terms are updated.', 'permalink-manager') |
| 69 | ), |
| 70 | 'redirect' => array( |
| 71 | 'type' => 'select', |
| 72 | 'label' => __('Redirect', 'permalink-manager'), |
| 73 | 'input_class' => 'settings-select', |
| 74 | 'choices' => array(0 => __('Disable', 'permalink-manager'), "301" => __('Enable "301 redirect"', 'permalink-manager'), "302" => __('Enable "302 redirect"', 'permalink-manager')), |
| 75 | 'description' => __('If enabled - the visitors will be redirected from native permalinks to your custom permalinks.<br /><strong>Only native permalinks & extra redirects will be redirected to new custom permalinks</strong>.', 'permalink-manager') |
| 76 | ), |
| 77 | 'trailing_slashes' => array( |
| 78 | 'type' => 'select', |
| 79 | 'label' => __('Trailing slashes', 'permalink-manager'), |
| 80 | 'input_class' => 'settings-select', |
| 81 | 'choices' => array(0 => __('Use default settings', 'permalink-manager'), 1 => __('Add trailing slashes', 'permalink-manager'), 10 => __('Add trailing slashes (+ auto-redirect links without them)', 'permalink-manager'), 2 => __('Remove trailing slashes', 'permalink-manager'), 20 => __('Remove trailing slashes (+ auto-redirect links with them)', 'permalink-manager'),), |
| 82 | 'description' => __('This option can be used to alter the native settings and control if trailing slash should be added or removed from the end of posts & terms permalinks.', 'permalink-manager') |
| 83 | ) |
| 84 | ) |
| 85 | ), |
| 86 | 'advanced' => array( |
| 87 | 'section_name' => __('Advanced settings', 'permalink-manager'), |
| 88 | 'container' => 'row', |
| 89 | 'name' => 'general', |
| 90 | 'fields' => array( |
| 91 | 'auto_remove_duplicates' => array( |
| 92 | 'type' => 'single_checkbox', |
| 93 | 'label' => __('Automatically remove duplicates', 'permalink-manager'), |
| 94 | 'input_class' => '', |
| 95 | 'description' => sprintf(__('If enabled, the duplicated redirects & custom permalinks will be automatically removed if they were previously assigned to removed posts or terms.<br />To manually remove the duplicates please go <a href="%s">to this page</a>.', 'permalink-manager'), admin_url('tools.php?page=permalink-manager§ion=tools&subsection=duplicates')) |
| 96 | ), |
| 97 | 'force_custom_slugs' => array( |
| 98 | 'type' => 'single_checkbox', |
| 99 | 'label' => __('Force custom slugs', 'permalink-manager'), |
| 100 | 'input_class' => '', |
| 101 | 'description' => __('If enabled, the slugs in the default custom permalinks will be recreated from the post titles.<br />This may cause permalinks duplicates when the post or term title is used more than once.', 'permalink-manager') |
| 102 | ), |
| 103 | 'partial_disable' => array( |
| 104 | 'type' => 'checkbox', |
| 105 | 'label' => __('Disable Permalink Manager functionalities', 'permalink-manager'), |
| 106 | 'choices' => $content_types, |
| 107 | 'description' => __('Select the post types & taxonomies where the functionalities of Permalink Manager should be completely disabled.', 'permalink-manager') |
| 108 | ), |
| 109 | ) |
| 110 | ) |
| 111 | )); |
| 112 | |
| 113 | $output = Permalink_Manager_Admin_Functions::get_the_form($sections_and_fields, '', array('text' => __( 'Save settings', 'permalink-manager' ), 'class' => 'primary margin-top'), '', array('action' => 'permalink-manager', 'name' => 'permalink_manager_options')); |
| 114 | return $output; |
| 115 | } |
| 116 | } |
| 117 |