| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPAdminify\Inc\Admin\Options; |
| 4 |
|
| 5 |
use WPAdminify\Inc\Utils; |
| 6 |
use WPAdminify\Inc\Admin\AdminSettingsModel; |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
die; |
| 10 |
} // Cannot access directly. |
| 11 |
|
| 12 |
class Tweaks_Archives extends AdminSettingsModel |
| 13 |
{ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
$this->tweaks_archives_settings(); |
| 17 |
} |
| 18 |
|
| 19 |
public function get_defaults() |
| 20 |
{ |
| 21 |
return [ |
| 22 |
'display_last_modified_date' => false, |
| 23 |
'remove_capital_p_dangit' => false, |
| 24 |
'remove_archives_date' => false, |
| 25 |
'remove_archives_author' => false, |
| 26 |
'remove_archives_tag' => false, |
| 27 |
'remove_archives_category' => false, |
| 28 |
'remove_archives_postformat' => false, |
| 29 |
'remove_archives_search' => false, |
| 30 |
]; |
| 31 |
} |
| 32 |
|
| 33 |
|
| 34 |
public function tweaks_archive_fields(&$archive_fields) |
| 35 |
{ |
| 36 |
$archive_fields[] = array( |
| 37 |
'type' => 'subheading', |
| 38 |
'content' => Utils::adminfiy_help_urls( |
| 39 |
__('Redirect unused archives to the homepage to avoid indexing these pages and content duplication.', WP_ADMINIFY_TD), |
| 40 |
'https://wpadminify.com/kb/wp-adminify-tweaks/', |
| 41 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 42 |
'https://www.facebook.com/groups/jeweltheme', |
| 43 |
'https://wpadminify.com/support/' |
| 44 |
) |
| 45 |
); |
| 46 |
|
| 47 |
$archive_fields[] = array( |
| 48 |
'id' => 'display_last_modified_date', |
| 49 |
'type' => 'switcher', |
| 50 |
'title' => __('Display Last Modified Date', WP_ADMINIFY_TD), |
| 51 |
'subtitle' => __('Enable/Disable Last Modified date of Posts', WP_ADMINIFY_TD), |
| 52 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 53 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 54 |
'text_width' => 80, |
| 55 |
'default' => $this->get_default_field('display_last_modified_date'), |
| 56 |
); |
| 57 |
|
| 58 |
$archive_fields[] = array( |
| 59 |
'id' => 'remove_capital_p_dangit', |
| 60 |
'type' => 'switcher', |
| 61 |
'title' => __('Remove Capital "P" Dangit', WP_ADMINIFY_TD), |
| 62 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 63 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 64 |
'text_width' => 80, |
| 65 |
'default' => $this->get_default_field('remove_capital_p_dangit'), |
| 66 |
); |
| 67 |
|
| 68 |
$archive_fields[] = array( |
| 69 |
'id' => 'remove_archives_date', |
| 70 |
'type' => 'switcher', |
| 71 |
'title' => __('Disable Date Archives', WP_ADMINIFY_TD), |
| 72 |
'subtitle' => __('Redirect date archives to the homepage', WP_ADMINIFY_TD), |
| 73 |
'label' => __('If you are not using date archives on your site you can disable them.', WP_ADMINIFY_TD), |
| 74 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 75 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 76 |
'text_width' => 80, |
| 77 |
'default' => $this->get_default_field('remove_archives_date'), |
| 78 |
); |
| 79 |
|
| 80 |
$archive_fields[] = array( |
| 81 |
'id' => 'remove_archives_author', |
| 82 |
'type' => 'switcher', |
| 83 |
'title' => __('Disable Author Archives', WP_ADMINIFY_TD), |
| 84 |
'subtitle' => __('Redirect author archives to the homepage', WP_ADMINIFY_TD), |
| 85 |
'label' => __('If you have only 1 author on your site or you are not planning to use this archives you can disable them.', WP_ADMINIFY_TD), |
| 86 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 87 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 88 |
'text_width' => 80, |
| 89 |
'default' => $this->get_default_field('remove_archives_author'), |
| 90 |
); |
| 91 |
|
| 92 |
$archive_fields[] = array( |
| 93 |
'id' => 'remove_archives_tag', |
| 94 |
'type' => 'switcher', |
| 95 |
'title' => __('Disable Tag Archives', WP_ADMINIFY_TD), |
| 96 |
'subtitle' => __('Redirect tag archives to the homepage', WP_ADMINIFY_TD), |
| 97 |
'label' => __('If you are not using tags on your site you can disable these archives.', WP_ADMINIFY_TD), |
| 98 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 99 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 100 |
'text_width' => 80, |
| 101 |
'default' => $this->get_default_field('remove_archives_tag'), |
| 102 |
); |
| 103 |
|
| 104 |
$archive_fields[] = array( |
| 105 |
'id' => 'remove_archives_category', |
| 106 |
'type' => 'switcher', |
| 107 |
'title' => __('Disable Category Archives', WP_ADMINIFY_TD), |
| 108 |
'subtitle' => __('Redirect category archives to the homepage', WP_ADMINIFY_TD), |
| 109 |
'label' => __('If you are not using categories on your site you can disable these archives.', WP_ADMINIFY_TD), |
| 110 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 111 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 112 |
'text_width' => 80, |
| 113 |
'default' => $this->get_default_field('remove_archives_category'), |
| 114 |
); |
| 115 |
|
| 116 |
$archive_fields[] = array( |
| 117 |
'id' => 'remove_archives_postformat', |
| 118 |
'type' => 'switcher', |
| 119 |
'title' => __('Disable Post Format Archives', WP_ADMINIFY_TD), |
| 120 |
'subtitle' => __('Redirect post format archives to the homepage', WP_ADMINIFY_TD), |
| 121 |
'label' => __('If you are not using post formats on your site you can disable these archives.', WP_ADMINIFY_TD), |
| 122 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 123 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 124 |
'text_width' => 80, |
| 125 |
'default' => $this->get_default_field('remove_archives_postformat'), |
| 126 |
); |
| 127 |
|
| 128 |
$archive_fields[] = array( |
| 129 |
'id' => 'remove_archives_search', |
| 130 |
'type' => 'switcher', |
| 131 |
'title' => __('Disable Search', WP_ADMINIFY_TD), |
| 132 |
'subtitle' => __('Redirect search listing to the homepage', WP_ADMINIFY_TD), |
| 133 |
'label' => __('If you do not use search on your site you can disable search results page.', WP_ADMINIFY_TD), |
| 134 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 135 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 136 |
'text_width' => 80, |
| 137 |
'default' => $this->get_default_field('remove_archives_search'), |
| 138 |
); |
| 139 |
} |
| 140 |
|
| 141 |
public function tweaks_archives_settings() |
| 142 |
{ |
| 143 |
|
| 144 |
if (!class_exists('ADMINIFY')) { |
| 145 |
return; |
| 146 |
} |
| 147 |
|
| 148 |
$archive_fields = []; |
| 149 |
$this->tweaks_archive_fields($archive_fields); |
| 150 |
|
| 151 |
\ADMINIFY::createSection( |
| 152 |
$this->prefix, |
| 153 |
array( |
| 154 |
'title' => __('Post/Archives', WP_ADMINIFY_TD), |
| 155 |
'parent' => 'tweaks_performance', |
| 156 |
'icon' => 'fas fa-edit', |
| 157 |
'fields' => $archive_fields |
| 158 |
) |
| 159 |
); |
| 160 |
} |
| 161 |
} |
| 162 |
|