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