| 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 |
$this->tweaks_attachments_settings(); |
| 16 |
} |
| 17 |
|
| 18 |
|
| 19 |
public function get_defaults() { |
| 20 |
return [ |
| 21 |
'thumbnails_rss_feed' => false, |
| 22 |
'remove_image_link' => false, |
| 23 |
'remove_attachment' => false, |
| 24 |
'disable_pdf_thumbnail' => false, |
| 25 |
]; |
| 26 |
} |
| 27 |
|
| 28 |
|
| 29 |
public function tweaks_attachment_fields( &$attachment_fields ) { |
| 30 |
$attachment_fields[] = [ |
| 31 |
'type' => 'subheading', |
| 32 |
'content' => Utils::adminfiy_help_urls( |
| 33 |
__( 'Redirect attachment single page URLs to parent post URL to avoid indexing these pages.', 'adminify' ), |
| 34 |
'https://wpadminify.com/kb/wp-adminify-tweaks/', |
| 35 |
'https://www.youtube.com/playlist?list=PLqpMw0NsHXV-EKj9Xm1DMGa6FGniHHly8', |
| 36 |
'https://www.facebook.com/groups/jeweltheme', |
| 37 |
'https://wpadminify.com/support/' |
| 38 |
), |
| 39 |
]; |
| 40 |
|
| 41 |
$attachment_fields[] = [ |
| 42 |
'id' => 'thumbnails_rss_feed', |
| 43 |
'type' => 'switcher', |
| 44 |
'title' => __( 'Show Thumbnails on RSS Feed', 'adminify' ), |
| 45 |
'subtitle' => __( 'Show Post Thumbnails on RSS excerpt and Content Feed', 'adminify' ), |
| 46 |
'text_on' => __( 'Yes', 'adminify' ), |
| 47 |
'text_off' => __( 'No', 'adminify' ), |
| 48 |
'text_width' => 80, |
| 49 |
'default' => $this->get_default_field( 'thumbnails_rss_feed' ), |
| 50 |
]; |
| 51 |
|
| 52 |
$attachment_fields[] = [ |
| 53 |
'id' => 'remove_image_link', |
| 54 |
'type' => 'switcher', |
| 55 |
'title' => __( 'Remove Image Link', 'adminify' ), |
| 56 |
'subtitle' => __( 'Remove Default Image Link', 'adminify' ), |
| 57 |
'text_on' => __( 'Yes', 'adminify' ), |
| 58 |
'text_off' => __( 'No', 'adminify' ), |
| 59 |
'text_width' => 80, |
| 60 |
'default' => $this->get_default_field( 'remove_image_link' ), |
| 61 |
]; |
| 62 |
|
| 63 |
$attachment_fields[] = [ |
| 64 |
'id' => 'remove_attachment', |
| 65 |
'type' => 'switcher', |
| 66 |
'title' => __( 'Disable Attachments', 'adminify' ), |
| 67 |
'subtitle' => __( 'Redirect attachment pages archives to parent post URL', 'adminify' ), |
| 68 |
'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.', 'adminify' ), |
| 69 |
'text_on' => __( 'Yes', 'adminify' ), |
| 70 |
'text_off' => __( 'No', 'adminify' ), |
| 71 |
'text_width' => 80, |
| 72 |
'default' => $this->get_default_field( 'remove_attachment' ), |
| 73 |
]; |
| 74 |
|
| 75 |
$attachment_fields[] = [ |
| 76 |
'id' => 'disable_pdf_thumbnail', |
| 77 |
'type' => 'switcher', |
| 78 |
'title' => __( 'Disable PDF Thumbnails Preview', 'adminify' ), |
| 79 |
'text_on' => __( 'Yes', 'adminify' ), |
| 80 |
'text_off' => __( 'No', 'adminify' ), |
| 81 |
'text_width' => 80, |
| 82 |
'default' => $this->get_default_field( 'disable_pdf_thumbnail' ), |
| 83 |
]; |
| 84 |
} |
| 85 |
|
| 86 |
|
| 87 |
public function tweaks_attachments_settings() { |
| 88 |
if ( ! class_exists( 'ADMINIFY' ) ) { |
| 89 |
return; |
| 90 |
} |
| 91 |
|
| 92 |
$attachment_fields = []; |
| 93 |
$this->tweaks_attachment_fields( $attachment_fields ); |
| 94 |
|
| 95 |
\ADMINIFY::createSection( |
| 96 |
$this->prefix, |
| 97 |
[ |
| 98 |
'title' => __( 'Attachments', 'adminify' ), |
| 99 |
'parent' => 'tweaks_performance', |
| 100 |
'icon' => 'far fa-file-alt', |
| 101 |
'fields' => $attachment_fields, |
| 102 |
] |
| 103 |
); |
| 104 |
} |
| 105 |
} |
| 106 |
|