| 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_Attachments extends AdminSettingsModel |
| 13 |
{ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
$this->tweaks_attachments_settings(); |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
public function get_defaults() |
| 21 |
{ |
| 22 |
return [ |
| 23 |
'thumbnails_rss_feed' => false, |
| 24 |
'remove_image_link' => false, |
| 25 |
'remove_attachment' => false, |
| 26 |
'disable_pdf_thumbnail' => false |
| 27 |
]; |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
public function tweaks_attachment_fields(&$attachment_fields) |
| 32 |
{ |
| 33 |
$attachment_fields[] = array( |
| 34 |
'type' => 'subheading', |
| 35 |
'content' => Utils::adminfiy_help_urls( |
| 36 |
__('Redirect attachment single page URLs to parent post URL to avoid indexing these pages.', WP_ADMINIFY_TD), |
| 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 |
$attachment_fields[] = array( |
| 45 |
'id' => 'thumbnails_rss_feed', |
| 46 |
'type' => 'switcher', |
| 47 |
'title' => __('Show Thumbnails on RSS Feed', WP_ADMINIFY_TD), |
| 48 |
'subtitle' => __('Show Post Thumbnails on RSS excerpt and Content Feed', WP_ADMINIFY_TD), |
| 49 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 50 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 51 |
'text_width' => 80, |
| 52 |
'default' => $this->get_default_field('thumbnails_rss_feed'), |
| 53 |
); |
| 54 |
|
| 55 |
$attachment_fields[] = array( |
| 56 |
'id' => 'remove_image_link', |
| 57 |
'type' => 'switcher', |
| 58 |
'title' => __('Remove Image Link', WP_ADMINIFY_TD), |
| 59 |
'subtitle' => __('Remove Default Image Link', WP_ADMINIFY_TD), |
| 60 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 61 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 62 |
'text_width' => 80, |
| 63 |
'default' => $this->get_default_field('remove_image_link'), |
| 64 |
); |
| 65 |
|
| 66 |
$attachment_fields[] = array( |
| 67 |
'id' => 'remove_attachment', |
| 68 |
'type' => 'switcher', |
| 69 |
'title' => __('Disable Attachments', WP_ADMINIFY_TD), |
| 70 |
'subtitle' => __('Redirect attachment pages archives to parent post URL', WP_ADMINIFY_TD), |
| 71 |
'label' => __('Every image or other file attached to post has it\'s own URL and sometimes it can hurt your SEO if these URLs will be indexed by search engines.', WP_ADMINIFY_TD), |
| 72 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 73 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 74 |
'text_width' => 80, |
| 75 |
'default' => $this->get_default_field('remove_attachment'), |
| 76 |
); |
| 77 |
|
| 78 |
$attachment_fields[] = array( |
| 79 |
'id' => 'disable_pdf_thumbnail', |
| 80 |
'type' => 'switcher', |
| 81 |
'title' => __('Disable PDF Thumbnails Preview', WP_ADMINIFY_TD), |
| 82 |
'text_on' => __('Yes', WP_ADMINIFY_TD), |
| 83 |
'text_off' => __('No', WP_ADMINIFY_TD), |
| 84 |
'text_width' => 80, |
| 85 |
'default' => $this->get_default_field('disable_pdf_thumbnail'), |
| 86 |
); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
public function tweaks_attachments_settings() |
| 91 |
{ |
| 92 |
|
| 93 |
if (!class_exists('ADMINIFY')) { |
| 94 |
return; |
| 95 |
} |
| 96 |
|
| 97 |
$attachment_fields = []; |
| 98 |
$this->tweaks_attachment_fields($attachment_fields); |
| 99 |
|
| 100 |
\ADMINIFY::createSection( |
| 101 |
$this->prefix, |
| 102 |
array( |
| 103 |
'title' => __('Attachments', WP_ADMINIFY_TD), |
| 104 |
'parent' => 'tweaks_performance', |
| 105 |
'icon' => 'far fa-file-alt', |
| 106 |
'fields' => $attachment_fields |
| 107 |
) |
| 108 |
); |
| 109 |
} |
| 110 |
} |
| 111 |
|