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
135 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(); |
| 28 | $all_taxonomies = Permalink_Manager_Helper_Functions::get_taxonomies_array(false, false, true); |
| 29 | $content_types = (defined('PERMALINK_MANAGER_PRO')) ? array_merge($all_post_types, $all_taxonomies) : $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 URIs', 'permalink-manager'), |
| 40 | 'input_class' => '', |
| 41 | 'description' => __('If enabled, the custom URIs 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 URIs', 'permalink-manager'), |
| 46 | 'input_class' => '', |
| 47 | 'description' => __('Make the permalinks case-insensitive.', 'permalink-manager') |
| 48 | ) |
| 49 | ) |
| 50 | ), |
| 51 | 'miscellaneous' => array( |
| 52 | 'section_name' => __('SEO functions', 'permalink-manager'), |
| 53 | 'container' => 'row', |
| 54 | 'name' => 'general', |
| 55 | 'fields' => array( |
| 56 | 'yoast_primary_term' => array( |
| 57 | 'type' => 'single_checkbox', |
| 58 | 'label' => __('Primay term/category support', 'permalink-manager'), |
| 59 | 'input_class' => '', |
| 60 | 'description' => __('Used to generate default permalinks in pages, posts & custom post types. Works only when "Yoast SEO" plugin is enabled.', 'permalink-manager') |
| 61 | ), |
| 62 | 'yoast_attachment_redirect' => array( |
| 63 | 'type' => 'single_checkbox', |
| 64 | 'label' => __('Attachment redirect support', 'permalink-manager'), |
| 65 | 'input_class' => '', |
| 66 | 'description' => __('Support for redirect attachment URLs to parent post URL. Works only when "Yoast SEO Premium" plugin is enabled.', 'permalink-manager') |
| 67 | ), |
| 68 | 'canonical_redirect' => array( |
| 69 | 'type' => 'single_checkbox', |
| 70 | 'label' => __('Canonical redirect', 'permalink-manager'), |
| 71 | 'input_class' => '', |
| 72 | 'description' => __('This function allows Wordpress to correct the URLs used by the visitors.', 'permalink-manager') |
| 73 | ), |
| 74 | 'redirect' => array( |
| 75 | 'type' => 'select', |
| 76 | 'label' => __('Redirect', 'permalink-manager'), |
| 77 | 'input_class' => 'settings-select', |
| 78 | 'choices' => array(0 => __('Disable', 'permalink-manager'), "301" => __('Enable "301 redirect"', 'permalink-manager'), "302" => __('Enable "302 redirect"', 'permalink-manager')), |
| 79 | '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 URIs</strong>.', 'permalink-manager') |
| 80 | ) |
| 81 | ) |
| 82 | ), |
| 83 | 'advanced' => array( |
| 84 | 'section_name' => __('Advanced settings', 'permalink-manager'), |
| 85 | 'container' => 'row', |
| 86 | 'name' => 'general', |
| 87 | 'fields' => array( |
| 88 | 'setup_redirects' => array( |
| 89 | 'type' => 'single_checkbox', |
| 90 | 'label' => __('Add redirects for old URIs', 'permalink-manager'), |
| 91 | 'input_class' => '', |
| 92 | 'pro' => true, |
| 93 | 'disabled' => true, |
| 94 | 'description' => __('If enabled, the redirects will be automatially created for old custom permalinks.', 'permalink-manager') |
| 95 | ), |
| 96 | 'auto_remove_duplicates' => array( |
| 97 | 'type' => 'single_checkbox', |
| 98 | 'label' => __('Automatically remove duplicates', 'permalink-manager'), |
| 99 | 'input_class' => '', |
| 100 | 'description' => __('If enabled, the duplicated redirects & custom URIs will be automatically removed.', 'permalink-manager') |
| 101 | ), |
| 102 | 'force_custom_slugs' => array( |
| 103 | 'type' => 'single_checkbox', |
| 104 | 'label' => __('Force custom slugs', 'permalink-manager'), |
| 105 | 'input_class' => '', |
| 106 | 'description' => __('If enabled, the native slugs in the defult URIs will be recreated from the post title.<br />This may cause URI duplicates when the post title is used more than once.', 'permalink-manager') |
| 107 | ), |
| 108 | 'disable_slug_appendix' => array( |
| 109 | 'type' => 'checkbox', |
| 110 | 'label' => __('Disable slug appendix', 'permalink-manager'), |
| 111 | 'choices' => $content_types, |
| 112 | 'description' => __('The slugs will not be automatically apended to the end of permastructure in the default permalinks for selected post types & taxonomies.<br />Works correctly only if <strong>"Force custom slugs" is disabled!</strong>', 'permalink-manager') |
| 113 | ), |
| 114 | 'decode_uris' => array( |
| 115 | 'type' => 'single_checkbox', |
| 116 | 'label' => __('Decode URIs', 'permalink-manager'), |
| 117 | 'input_class' => '', |
| 118 | 'description' => __('If enabled, the permalinks with non-ASCII characters may not be recognized in older browsers versions (advanced users only).', 'permalink-manager') |
| 119 | ), |
| 120 | 'trailing_slashes' => array( |
| 121 | 'type' => 'select', |
| 122 | 'label' => __('Trailing slashes', 'permalink-manager'), |
| 123 | 'input_class' => 'settings-select', |
| 124 | 'choices' => array(0 => __('Use default settings', 'permalink-manager'), 1 => __('Always add trailing slashes', 'permalink-manager'), 2 => __('Always remove trailing slashes', 'permalink-manager')), |
| 125 | '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') |
| 126 | ) |
| 127 | ) |
| 128 | ) |
| 129 | )); |
| 130 | |
| 131 | $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')); |
| 132 | return $output; |
| 133 | } |
| 134 | } |
| 135 |