| 1 |
<?php |
| 2 |
namespace WPEXtra; |
| 3 |
|
| 4 |
if (!defined('ABSPATH')) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
use WPEXtra\WPSettings\SMTP; |
| 9 |
use WPEXtra\WPSettings\EmailLogsPage; |
| 10 |
use WPEXtra\WPSettings\ProtectHtaccess; |
| 11 |
|
| 12 |
class Settings |
| 13 |
{ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
add_filter('wp_settings_option_type_map', function ($options) { |
| 17 |
$options['smtp'] = SMTP::class; |
| 18 |
$options['protect'] = ProtectHtaccess::class; |
| 19 |
return $options; |
| 20 |
}); |
| 21 |
new EmailLogsPage(); |
| 22 |
add_action('admin_menu', [$this, 'register'], 10); |
| 23 |
add_action('admin_init', [$this, 'register'], 10); |
| 24 |
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_assets']); |
| 25 |
} |
| 26 |
|
| 27 |
public function register() |
| 28 |
{ |
| 29 |
$settings = new \WPVNTeam\WPSettings\WPSettings('WP EXtra'); |
| 30 |
$settings->set_capability('manage_options'); |
| 31 |
$settings->set_menu_icon('dashicons-superhero-alt'); |
| 32 |
$settings->set_menu_position(80); |
| 33 |
$settings->set_version(WPEX_VERSION); |
| 34 |
$settings->set_plugin_data(WPEX_FILE); |
| 35 |
|
| 36 |
$add_days = (new \DateTime())->diff(new \DateTime('2019-01-18'))->days; |
| 37 |
$notice_message = sprintf( |
| 38 |
/* translators: 1. days; 2. link to donate; 3. link to review */ |
| 39 |
__('The plugin developer has dedicated <strong>%1$s</strong> days to this project. If you like it, you can support the author with <a href="%2$s" target="_blank">a beer 🍻 / coffee ☕️</a> ! Please <a href="%3$s" target="_blank">rate us on WordPress.org</a>', 'wp-extra'), |
| 40 |
number_format_i18n($add_days), |
| 41 |
'https://wpvnteam.com/donate/', |
| 42 |
'https://wordpress.org/support/plugin/wp-extra/reviews/?filter=5#new-post' |
| 43 |
); |
| 44 |
$plugin_message = "<p>" . esc_html__('Like this plugin? Check out our other WordPress products:', 'wp-extra') . "</p><a class='thickbox open-plugin-details-modal' href='" . esc_url(admin_url('plugin-install.php?tab=plugin-information&plugin=ux-flat&from=import&TB_iframe=true&width=800&height=550')) . "'>UX Flat</a> - " . esc_html__('Create new elements for Flatsome', 'wp-extra'); |
| 45 |
|
| 46 |
$sidebar_items = [ |
| 47 |
__('Write a review for WP EXtra', 'wp-extra') . ' 📝' => $notice_message, |
| 48 |
__('Our WordPress Products', 'wp-extra') . ' ⭐' => $plugin_message, |
| 49 |
]; |
| 50 |
$settings->set_sidebar($sidebar_items); |
| 51 |
|
| 52 |
// Tab 0: Modules Overview |
| 53 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M10.5 4v4h3V4H15v4h1.5a1 1 0 011 1v4l-3 4v2a1 1 0 01-1 1h-3a1 1 0 01-1-1v-2l-3-4V9a1 1 0 011-1H9V4h1.5zm.5 12.5v2h2v-2l3-4v-3H8v3l3 4z"></path></svg>' . __('Modules')); |
| 54 |
$section = $tab->add_section(__('Modules'), ['description' => __('The module operates independently. Please enable it as needed.', 'wp-extra')]); |
| 55 |
$module_options = [ |
| 56 |
'dashboard' => [ |
| 57 |
'title' => __('Dashboard', 'wp-extra'), |
| 58 |
'desc' => __('Widgets cleanup, system info cards & custom notice', 'wp-extra'), |
| 59 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"></path></svg>' |
| 60 |
], |
| 61 |
'posts' => [ |
| 62 |
'title' => __('Posts & Writing', 'wp-extra'), |
| 63 |
'desc' => __('Classic Editor, featured image column & cleanup', 'wp-extra'), |
| 64 |
'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" focusable="false"><path d="M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z"></path></svg>' |
| 65 |
], |
| 66 |
'toc' => [ |
| 67 |
'title' => __('Table of Contents', 'wp-extra'), |
| 68 |
'desc' => __('Auto Table of Contents, headings numbering & sticky badge', 'wp-extra'), |
| 69 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z"></path></svg>' |
| 70 |
], |
| 71 |
'duplicate' => [ |
| 72 |
'title' => __('Clone Content', 'wp-extra'), |
| 73 |
'desc' => __('1-click duplicate posts, pages & taxonomies', 'wp-extra'), |
| 74 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"></path></svg>' |
| 75 |
], |
| 76 |
'media' => [ |
| 77 |
'title' => __('Media & SVG', 'wp-extra'), |
| 78 |
'desc' => __('SVG uploads, auto WebP/JPG conversion & SEO rename', 'wp-extra'), |
| 79 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="m7 6.5 4 2.5-4 2.5z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z"></path></svg>' |
| 80 |
], |
| 81 |
'comments' => [ |
| 82 |
'title' => __('Comments & Spam', 'wp-extra'), |
| 83 |
'desc' => __('Disable comments globally & anti-spam link filter', 'wp-extra'), |
| 84 |
'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.68822 16.625L5.5 17.8145L5.5 5.5L18.5 5.5L18.5 16.625L6.68822 16.625ZM7.31 18.125L19 18.125C19.5523 18.125 20 17.6773 20 17.125L20 5C20 4.44772 19.5523 4 19 4H5C4.44772 4 4 4.44772 4 5V19.5247C4 19.8173 4.16123 20.086 4.41935 20.2237C4.72711 20.3878 5.10601 20.3313 5.35252 20.0845L7.31 18.125ZM16 9.99997H8V8.49997H16V9.99997ZM8 14H13V12.5H8V14Z"></path></svg>' |
| 85 |
], |
| 86 |
'logins' => [ |
| 87 |
'title' => __('Branding & Login', 'wp-extra'), |
| 88 |
'desc' => __('Custom login URL, themes, Turnstile captcha & security', 'wp-extra'), |
| 89 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z"></path></svg>' |
| 90 |
], |
| 91 |
'admins' => [ |
| 92 |
'title' => __('Permission & Roles', 'wp-extra'), |
| 93 |
'desc' => __('Hide admin bar, menu restrictions & hide plugins', 'wp-extra'), |
| 94 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z" fill-rule="evenodd"></path></svg>' |
| 95 |
], |
| 96 |
'security' => [ |
| 97 |
'title' => __('Security & Hardening', 'wp-extra'), |
| 98 |
'desc' => __('Disable XML-RPC, REST API, file editors & update locks', 'wp-extra'), |
| 99 |
'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" focusable="false"><path d="M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zM9.8 7c0-1.2 1-2.2 2.2-2.2 1.2 0 2.2 1 2.2 2.2v3H9.8V7zm6.7 11.5h-9v-7h9v7z"></path></svg>' |
| 100 |
], |
| 101 |
'optimize' => [ |
| 102 |
'title' => __('Speed & Optimize', 'wp-extra'), |
| 103 |
'desc' => __('Disable emojis, block styles & strip query strings', 'wp-extra'), |
| 104 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M3.445 16.505a.75.75 0 001.06.05l5.005-4.55 4.024 3.521 4.716-4.715V14h1.5V8.25H14v1.5h3.19l-3.724 3.723L9.49 9.995l-5.995 5.45a.75.75 0 00-.05 1.06z"></path></svg>' |
| 105 |
], |
| 106 |
'permalinks' => [ |
| 107 |
'title' => __('Permalinks & SEO', 'wp-extra'), |
| 108 |
'desc' => __('Remove category slugs, external links SEO & robots.txt', 'wp-extra'), |
| 109 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="M12.5 14.5h-1V16h1c2.2 0 4-1.8 4-4s-1.8-4-4-4h-1v1.5h1c1.4 0 2.5 1.1 2.5 2.5s-1.1 2.5-2.5 2.5zm-4 1.5v-1.5h-1C6.1 14.5 5 13.4 5 12s1.1-2.5 2.5-2.5h1V8h-1c-2.2 0-4 1.8-4 4s1.8 4 4 4h1zm-1-3.2h5v-1.5h-5v1.5zM18 4H9c-1.1 0-2 .9-2 2v.5h1.5V6c0-.3.2-.5.5-.5h9c.3 0 .5.2.5.5v12c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5v-.5H7v.5c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2z"></path></svg>' |
| 110 |
], |
| 111 |
'code' => [ |
| 112 |
'title' => __('Custom Code & CSS', 'wp-extra'), |
| 113 |
'desc' => __('Header/body/footer scripts & responsive custom CSS', 'wp-extra'), |
| 114 |
'icon' => '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4.8 11.4H2.1V9H1v6h1.1v-2.6h2.7V15h1.1V9H4.8v2.4zm1.9-1.3h1.7V15h1.1v-4.9h1.7V9H6.7v1.1zM16.2 9l-1.5 2.7L13.3 9h-.9l-.8 6h1.1l.5-4 1.5 2.8 1.5-2.8.5 4h1.1L17 9h-.8zm3.8 5V9h-1.1v6h3.6v-1H20z"></path></svg>' |
| 115 |
], |
| 116 |
'cookie' => [ |
| 117 |
'title' => __('Cookie Consent', 'wp-extra'), |
| 118 |
'desc' => __('GDPR/CCPA cookie banner with modern presets', 'wp-extra'), |
| 119 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="20" height="20" aria-hidden="true" focusable="false"><path d="M497.1 286.7c-3.4-4.6-8.5-7.6-14.1-8.3-73.7-9.1-129.2-71.4-129.2-145.1 0-24.7 6.4-49.2 18.5-70.8 2.8-4.9 3.3-10.8 1.6-16.2s-5.7-9.8-10.8-12.2C330 18.8 294.7 11 258.1 11c-136.2 0-247 109.9-247 245s110.8 245 247.1 245c118.2 0 220.2-83.5 242.6-198.5 1-5.5-.3-11.2-3.7-15.8m-239 173.5c-113.5 0-205.9-91.6-205.9-204.2S144.6 51.8 258.1 51.8c23.5 0 46.4 3.9 68.2 11.5-9 22.2-13.7 46-13.7 70 0 86.5 59.9 160.8 142.7 181.4-25.7 85.4-105.6 145.5-197.2 145.5"/><ellipse cx="194.5" cy="150.8" rx="20.4" ry="20.3"/><ellipse cx="264.4" cy="230.7" rx="20.4" ry="20.3"/><ellipse cx="293.8" cy="340.2" rx="20.4" ry="20.3"/><ellipse cx="146.7" cy="304.3" rx="20.4" ry="20.3"/></svg>' |
| 120 |
], |
| 121 |
'smtp' => [ |
| 122 |
'title' => __('SMTP Mailer', 'wp-extra'), |
| 123 |
'desc' => __('Multi-account rotation, provider presets & email logs', 'wp-extra'), |
| 124 |
'icon' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.5 4.5" width="20" height="20" aria-hidden="true" focusable="false"><path d="M4 0.75H0.5a0.25 0.25 0 0 0 -0.25 0.25v2.5a0.25 0.25 0 0 0 0.25 0.25h3.5a0.25 0.25 0 0 0 0.25 -0.25V1a0.25 0.25 0 0 0 -0.25 -0.25m-0.193 2.75H0.708l0.875 -0.905 -0.18 -0.174L0.5 3.355V1.19l1.554 1.546a0.25 0.25 0 0 0 0.352 0L4 1.151v2.188l-0.92 -0.92 -0.176 0.176ZM0.664 1h3.134L2.23 2.559Z"/></svg>' |
| 125 |
], |
| 126 |
]; |
| 127 |
|
| 128 |
$section->add_option('module', [ |
| 129 |
'name' => 'modules', |
| 130 |
'options' => $module_options, |
| 131 |
'label' => __('List Module', 'wp-extra') |
| 132 |
]); |
| 133 |
|
| 134 |
// 1. Dashboard Tab |
| 135 |
if (self::get_option('modules') && in_array('dashboard', (array) self::get_option('modules'))) { |
| 136 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"></path></svg>' . __('Dashboard', 'wp-extra')); |
| 137 |
|
| 138 |
// Roles helper |
| 139 |
$all_roles = wp_roles()->get_names(); |
| 140 |
|
| 141 |
// Section 1: Dashboard Widgets & Cleanup |
| 142 |
$section = $tab->add_section(__('Dashboard Widgets & Cleanup', 'wp-extra')); |
| 143 |
$section->add_option('checkbox', [ |
| 144 |
'name' => 'dashboard', |
| 145 |
'label' => __('Clean All Default Widgets & Welcome Panel', 'wp-extra'), |
| 146 |
'description' => __('Hide all standard WordPress and plugin dashboard widgets including the Welcome Panel at once.', 'wp-extra') |
| 147 |
]); |
| 148 |
$section->add_option('checkbox', [ |
| 149 |
'name' => 'dashboard_sysinfo', |
| 150 |
'label' => __('Enable System Info Widget', 'wp-extra'), |
| 151 |
'description' => __('Display a dashboard widget with live PHP, Memory, Upload Size, and Server stats (Visible to Administrators only).', 'wp-extra') |
| 152 |
]); |
| 153 |
$section->add_option('checkbox', [ |
| 154 |
'name' => 'tab_help', |
| 155 |
'label' => __('Hide Help Tabs', 'wp-extra'), |
| 156 |
'description' => __('Remove the Help dropdown tab from the top right of admin screens.', 'wp-extra') |
| 157 |
]); |
| 158 |
$section->add_option('checkbox', [ |
| 159 |
'name' => 'tab_screen', |
| 160 |
'label' => __('Hide Screen Options', 'wp-extra'), |
| 161 |
'description' => __('Remove the Screen Options dropdown tab from the top right of admin screens.', 'wp-extra') |
| 162 |
]); |
| 163 |
|
| 164 |
// Section 2: Custom Notice Widgets (Repeater) |
| 165 |
$role_options = array_merge(['all' => __('All User Roles', 'wp-extra')], $all_roles); |
| 166 |
|
| 167 |
$section = $tab->add_section(__('Custom Notice Widgets', 'wp-extra')); |
| 168 |
$section->add_option('repeater', [ |
| 169 |
'name' => 'dashboard_custom_widgets', |
| 170 |
'label' => __('Custom Widgets List', 'wp-extra'), |
| 171 |
'description' => __('Add custom notice widgets to the dashboard screen.', 'wp-extra'), |
| 172 |
'button_text' => __('Add New Widget', 'wp-extra'), |
| 173 |
'fields' => [ |
| 174 |
[ |
| 175 |
'name' => 'title', |
| 176 |
'label' => __('Widget Title', 'wp-extra'), |
| 177 |
'type' => 'text', |
| 178 |
'placeholder' => __('e.g. Admin Guidelines / System Notice', 'wp-extra'), |
| 179 |
], |
| 180 |
[ |
| 181 |
'name' => 'role', |
| 182 |
'label' => __('Display For', 'wp-extra'), |
| 183 |
'type' => 'select', |
| 184 |
'options' => $role_options, |
| 185 |
'default' => 'all', |
| 186 |
], |
| 187 |
[ |
| 188 |
'name' => 'content', |
| 189 |
'label' => __('Content', 'wp-extra'), |
| 190 |
'type' => 'editor', |
| 191 |
'rows' => 6, |
| 192 |
'full_width' => true, |
| 193 |
'placeholder' => __('Enter text, HTML, or shortcodes...', 'wp-extra'), |
| 194 |
], |
| 195 |
] |
| 196 |
]); |
| 197 |
} |
| 198 |
|
| 199 |
// 2. Posts Tab |
| 200 |
if (self::get_option('modules') && in_array('posts', self::get_option('modules'))) { |
| 201 |
$tab = $settings->add_tab('<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path d="M18 5.5H6a.5.5 0 0 0-.5.5v12a.5.5 0 0 0 .5.5h12a.5.5 0 0 0 .5-.5V6a.5.5 0 0 0-.5-.5ZM6 4h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2Zm1 5h1.5v1.5H7V9Zm1.5 4.5H7V15h1.5v-1.5ZM10 9h7v1.5h-7V9Zm7 4.5h-7V15h7v-1.5Z"></path></svg>' . __('Posts')); |
| 202 |
|
| 203 |
$section = $tab->add_section(__('Editor & Writing', 'wp-extra')); |
| 204 |
$section->add_option('checkbox', [ |
| 205 |
'name' => 'mce_classic', |
| 206 |
'label' => __('Classic Editor'), |
| 207 |
'description' => __('Use the classic WordPress editor instead of block editor.', 'wp-extra') |
| 208 |
]); |
| 209 |
$section->add_option('checkbox', [ |
| 210 |
'name' => 'mce_plugins', |
| 211 |
'label' => __('TinyMCE Power Tools', 'wp-extra'), |
| 212 |
'description' => __('Enable full toolbar tools: justify, unlinks, letter spacing, tables, visual blocks, search & replace, rel=nofollow & sponsored.', 'wp-extra'), |
| 213 |
'show_if' => ['mce_classic' => true] |
| 214 |
]); |
| 215 |
$section->add_option('checkbox', [ |
| 216 |
'name' => 'signature', |
| 217 |
'label' => __('Post Signature', 'wp-extra'), |
| 218 |
'description' => sprintf(__('Insert signature into single posts using shortcode %1$s or automatically.', 'wp-extra'), '<code>[signature]</code>') |
| 219 |
]); |
| 220 |
$section->add_option('wp-editor', [ |
| 221 |
'name' => 'signature_content', |
| 222 |
'teeny' => true, |
| 223 |
'show_if' => ['signature' => true], |
| 224 |
'label' => __('Signature Content', 'wp-extra') |
| 225 |
]); |
| 226 |
$section->add_option('choices', [ |
| 227 |
'name' => 'signature_pos', |
| 228 |
'options' => [ |
| 229 |
'' => __('No'), |
| 230 |
'top' => __('Top'), |
| 231 |
'bottom' => __('Bottom') |
| 232 |
], |
| 233 |
'label' => __('Auto Insert Position', 'wp-extra'), |
| 234 |
'show_if' => ['signature' => true] |
| 235 |
]); |
| 236 |
if (wp_get_theme()->template !== 'flatsome') { |
| 237 |
$section->add_option('checkbox', [ |
| 238 |
'name' => 'classic_widget', |
| 239 |
'label' => __('Classic Widgets', 'wp-extra'), |
| 240 |
'description' => __('Restore classic widget management screens.', 'wp-extra') |
| 241 |
]); |
| 242 |
$section->add_option('widget', [ |
| 243 |
'name' => 'disable_widget', |
| 244 |
'label' => __('Disable Sidebar Widgets', 'wp-extra'), |
| 245 |
]); |
| 246 |
} |
| 247 |
|
| 248 |
$section = $tab->add_section(__('Publishing & List Views', 'wp-extra')); |
| 249 |
$section->add_option('checkbox', [ |
| 250 |
'name' => 'publish_btn', |
| 251 |
'label' => __('Sticky Publish Button', 'wp-extra'), |
| 252 |
'default' => 1, |
| 253 |
'description' => __('Stick the Publish/Save button to the bottom of the screen when scrolling long posts.', 'wp-extra') |
| 254 |
]); |
| 255 |
$section->add_option('checkbox', [ |
| 256 |
'name' => 'delete_attached', |
| 257 |
'label' => __('Delete Attached Media', 'wp-extra'), |
| 258 |
'description' => __('Automatically remove images attached to a post when the post is permanently deleted.', 'wp-extra') |
| 259 |
]); |
| 260 |
$section->add_option('text', [ |
| 261 |
'type' => 'number', |
| 262 |
'name' => 'post_revisions', |
| 263 |
'css' => ['input_class' => 'small-text'], |
| 264 |
'label' => __('Post Revisions Limit', 'wp-extra'), |
| 265 |
'description' => __('Maximum revisions to keep per post. Enter 0 to disable revisions completely, or leave empty to use WordPress default.', 'wp-extra') |
| 266 |
]); |
| 267 |
$section->add_option('checkbox', [ |
| 268 |
'name' => 'img_column', |
| 269 |
'label' => __('Featured Image Column', 'wp-extra'), |
| 270 |
'description' => __('Show a thumbnail preview column in post admin list tables.', 'wp-extra') |
| 271 |
]); |
| 272 |
$section->add_option('checkbox', [ |
| 273 |
'name' => 'show_modified', |
| 274 |
'label' => __('Show Modified Date', 'wp-extra'), |
| 275 |
'description' => __('Display a sortable last modified date column in admin post lists.', 'wp-extra') |
| 276 |
]); |
| 277 |
$section->add_option('checkbox', [ |
| 278 |
'name' => 'lock_modified', |
| 279 |
'label' => __('Lock Modified Date', 'wp-extra'), |
| 280 |
'description' => __('Prevent updating the modified date when editing existing posts.', 'wp-extra') |
| 281 |
]); |
| 282 |
$section->add_option('select', [ |
| 283 |
'name' => 'disable_tags', |
| 284 |
'label' => __('Global Post Tags', 'wp-extra'), |
| 285 |
'description' => __('Manage post tags across the system: Default, disable tag links on frontend, or completely disable post tags.', 'wp-extra'), |
| 286 |
'options' => [ |
| 287 |
'' => __('Default', 'wp-extra'), |
| 288 |
'disable_link' => __('Disable Tag Links', 'wp-extra'), |
| 289 |
'disable_tag' => __('Disable Post Tags', 'wp-extra'), |
| 290 |
], |
| 291 |
'default' => '' |
| 292 |
]); |
| 293 |
} |
| 294 |
|
| 295 |
// Tab Table of Contents |
| 296 |
if (self::get_option('modules') && in_array('toc', (array) self::get_option('modules'), true)) { |
| 297 |
$tab = $settings->add_tab('<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path d="M4 6h16v2H4V6zm0 5h16v2H4v-2zm0 5h16v2H4v-2z"></path></svg>' . __('Table of Contents', 'wp-extra')); |
| 298 |
|
| 299 |
// SECTION 1: Auto Insert & Positioning |
| 300 |
$section = $tab->add_section(__('Auto Insert & Positioning', 'wp-extra')); |
| 301 |
|
| 302 |
$post_types = get_post_types(['public' => true], 'objects'); |
| 303 |
$post_type_options = []; |
| 304 |
foreach ($post_types as $pt) { |
| 305 |
if ($pt->name !== 'attachment') { |
| 306 |
$post_type_options[$pt->name] = esc_html($pt->labels->name); |
| 307 |
} |
| 308 |
} |
| 309 |
|
| 310 |
$section->add_option('checkbox-multiple', [ |
| 311 |
'name' => 'enabled_post_types', |
| 312 |
'label' => __('Enable Support', 'wp-extra'), |
| 313 |
'description' => __('Enable table of contents support for these post types.', 'wp-extra'), |
| 314 |
'options' => $post_type_options, |
| 315 |
'default' => ['post'] |
| 316 |
]); |
| 317 |
$section->add_option('checkbox-multiple', [ |
| 318 |
'name' => 'auto_insert_post_types', |
| 319 |
'label' => __('Auto Insert', 'wp-extra'), |
| 320 |
'description' => __('Automatically insert table of contents without manual shortcode.', 'wp-extra'), |
| 321 |
'options' => $post_type_options, |
| 322 |
'default' => ['post'] |
| 323 |
]); |
| 324 |
$section->add_option('select', [ |
| 325 |
'name' => 'position', |
| 326 |
'label' => __('Position', 'wp-extra'), |
| 327 |
'options' => [ |
| 328 |
'before' => __('Before first heading (Recommended)', 'wp-extra'), |
| 329 |
'after' => __('After first heading', 'wp-extra'), |
| 330 |
'top' => __('Top of content', 'wp-extra'), |
| 331 |
'bottom' => __('Bottom of content', 'wp-extra'), |
| 332 |
'afterpara' => __('After first paragraph', 'wp-extra'), |
| 333 |
'afterimg' => __('After first image', 'wp-extra'), |
| 334 |
], |
| 335 |
'default' => 'before' |
| 336 |
]); |
| 337 |
$section->add_option('text', [ |
| 338 |
'type' => 'number', |
| 339 |
'name' => 'start', |
| 340 |
'css' => ['input_class' => 'small-text'], |
| 341 |
'label' => __('Show When', 'wp-extra'), |
| 342 |
'default' => 4, |
| 343 |
'description' => __('headings or more are present.', 'wp-extra') |
| 344 |
]); |
| 345 |
$section->add_option('text', [ |
| 346 |
'name' => 'heading_text', |
| 347 |
'label' => __('Header Label', 'wp-extra'), |
| 348 |
'default' => __('Table of Contents', 'wp-extra'), |
| 349 |
'description' => __('Header text displayed at the top of the table of contents.', 'wp-extra') |
| 350 |
]); |
| 351 |
$section->add_option('checkbox', [ |
| 352 |
'name' => 'visibility', |
| 353 |
'label' => __('Toggle Visibility', 'wp-extra'), |
| 354 |
'description' => __('Allow readers to toggle table of contents visibility.', 'wp-extra'), |
| 355 |
'default' => true |
| 356 |
]); |
| 357 |
$section->add_option('checkbox', [ |
| 358 |
'name' => 'visibility_hide_by_default', |
| 359 |
'label' => __('Initially Hide', 'wp-extra'), |
| 360 |
'description' => __('Initially collapse the table of contents on page load.', 'wp-extra'), |
| 361 |
'default' => false, |
| 362 |
'show_if' => ['visibility' => true] |
| 363 |
]); |
| 364 |
$section->add_option('choices', [ |
| 365 |
'name' => 'counter', |
| 366 |
'label' => __('Counter Style', 'wp-extra'), |
| 367 |
'options' => [ |
| 368 |
'none' => [ |
| 369 |
'label' => __('None', 'wp-extra'), |
| 370 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="18" y="20" width="60" height="8" rx="3" fill="#334155"/><rect x="26" y="34" width="50" height="7" rx="3" fill="#64748B"/><rect x="26" y="47" width="44" height="7" rx="3" fill="#64748B"/><rect x="18" y="60" width="56" height="8" rx="3" fill="#334155"/></svg>', |
| 371 |
'description' => __('Minimal pure text (Default)', 'wp-extra'), |
| 372 |
], |
| 373 |
'decimal' => [ |
| 374 |
'label' => __('Decimal', 'wp-extra'), |
| 375 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="14" y="18" width="3.5" height="12" rx="1.75" fill="#2271B1"/><rect x="23" y="20" width="55" height="8" rx="3" fill="#334155"/><rect x="23" y="37" width="2.5" height="9" rx="1.25" fill="#64748B"/><rect x="30" y="38" width="45" height="7" rx="3" fill="#64748B"/><rect x="23" y="51" width="2.5" height="9" rx="1.25" fill="#64748B"/><rect x="30" y="52" width="50" height="7" rx="3" fill="#64748B"/></svg>', |
| 376 |
'description' => __('Numbered 1, 1.1, 1.2...', 'wp-extra'), |
| 377 |
], |
| 378 |
'decimal-circle' => [ |
| 379 |
'label' => __('Decimal Circle', 'wp-extra'), |
| 380 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="20" cy="24" r="6.5" fill="#0284C7"/><text x="20" y="27" fill="#FFFFFF" font-size="8" font-weight="bold" font-family="sans-serif" text-anchor="middle">1</text><rect x="31" y="20" width="55" height="8" rx="3" fill="#334155"/><rect x="17" y="37" width="17" height="10" rx="5" fill="#F1F5F9" stroke="#E2E8F0" stroke-width="1"/><text x="25.5" y="44.5" fill="#475569" font-size="7" font-weight="bold" font-family="sans-serif" text-anchor="middle">1.1</text><rect x="38" y="38" width="42" height="7" rx="3" fill="#64748B"/><rect x="17" y="51" width="17" height="10" rx="5" fill="#F1F5F9" stroke="#E2E8F0" stroke-width="1"/><text x="25.5" y="58.5" fill="#475569" font-size="7" font-weight="bold" font-family="sans-serif" text-anchor="middle">1.2</text><rect x="38" y="52" width="48" height="7" rx="3" fill="#64748B"/></svg>', |
| 381 |
'description' => __('Numbers in rounded badge', 'wp-extra'), |
| 382 |
], |
| 383 |
'disc' => [ |
| 384 |
'label' => __('Disc', 'wp-extra'), |
| 385 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><line x1="20" y1="26" x2="20" y2="55" stroke="#CBD5E1" stroke-width="1.5"/><line x1="20" y1="41" x2="27" y2="41" stroke="#CBD5E1" stroke-width="1.5"/><line x1="20" y1="55" x2="27" y2="55" stroke="#CBD5E1" stroke-width="1.5"/><circle cx="20" cy="24" r="3.5" fill="#2271B1"/><rect x="30" y="20" width="55" height="8" rx="3" fill="#334155"/><circle cx="30" cy="41" r="2.5" fill="#94A3B8"/><rect x="37" y="38" width="42" height="7" rx="3" fill="#64748B"/><circle cx="30" cy="55" r="2.5" fill="#94A3B8"/><rect x="37" y="52" width="48" height="7" rx="3" fill="#64748B"/></svg>', |
| 386 |
'description' => __('Bullet dot • with guide line', 'wp-extra'), |
| 387 |
], |
| 388 |
'checkmark' => [ |
| 389 |
'label' => __('Checkmark', 'wp-extra'), |
| 390 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="20" cy="24" r="5.5" fill="#D1FAE5"/><path d="M17.5 24L19.5 26L22.5 22" stroke="#059669" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><rect x="31" y="20" width="55" height="8" rx="3" fill="#334155"/><circle cx="25" cy="41" r="4.5" fill="#ECFDF5"/><path d="M23 41L24.5 42.5L27 39.5" stroke="#10B981" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/><rect x="35" y="38" width="45" height="7" rx="3" fill="#64748B"/><circle cx="25" cy="55" r="4.5" fill="#ECFDF5"/><path d="M23 55L24.5 56.5L27 53.5" stroke="#10B981" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round"/><rect x="35" y="52" width="48" height="7" rx="3" fill="#64748B"/></svg>', |
| 391 |
'description' => __('Circle checkmark ✔ badge', 'wp-extra'), |
| 392 |
], |
| 393 |
], |
| 394 |
'default' => 'none', |
| 395 |
]); |
| 396 |
|
| 397 |
// SECTION 2: Appearance & Customization |
| 398 |
$section = $tab->add_section(__('Appearance & Customization', 'wp-extra')); |
| 399 |
$section->add_option('choices', [ |
| 400 |
'name' => 'title_icon_style', |
| 401 |
'label' => __('Title Icon Type', 'wp-extra'), |
| 402 |
'options' => [ |
| 403 |
'none' => [ |
| 404 |
'label' => __('None', 'wp-extra'), |
| 405 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="60" cy="40" r="14" stroke="#94A3B8" stroke-width="2"/><line x1="50" y1="50" x2="70" y2="30" stroke="#94A3B8" stroke-width="2"/></svg>', |
| 406 |
'description' => __('No icon before title (Default)', 'wp-extra'), |
| 407 |
], |
| 408 |
'toc_tree' => [ |
| 409 |
'label' => __('TOC Tree', 'wp-extra'), |
| 410 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="36" cy="26" r="3.5" fill="#2271B1"/><rect x="45" y="23" width="40" height="6" rx="3" fill="#334155"/><circle cx="44" cy="38" r="3" fill="#64748B"/><rect x="52" y="35.5" width="30" height="5" rx="2.5" fill="#64748B"/><circle cx="36" cy="50" r="3.5" fill="#2271B1"/><rect x="45" y="47" width="40" height="6" rx="3" fill="#334155"/><circle cx="44" cy="61" r="3" fill="#64748B"/><rect x="52" y="58.5" width="28" height="5" rx="2.5" fill="#64748B"/></svg>', |
| 411 |
'description' => __('Hierarchical nested list tree', 'wp-extra'), |
| 412 |
], |
| 413 |
'list' => [ |
| 414 |
'label' => __('Index List', 'wp-extra'), |
| 415 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="36" cy="27" r="3" fill="#2271B1"/><line x1="46" y1="27" x2="84" y2="27" stroke="#2271B1" stroke-width="3" stroke-linecap="round"/><circle cx="36" cy="40" r="3" fill="#334155"/><line x1="46" y1="40" x2="84" y2="40" stroke="#334155" stroke-width="3" stroke-linecap="round"/><circle cx="36" cy="53" r="3" fill="#334155"/><line x1="46" y1="53" x2="84" y2="53" stroke="#334155" stroke-width="3" stroke-linecap="round"/></svg>', |
| 416 |
'description' => __('Classic index ☰ list icon', 'wp-extra'), |
| 417 |
], |
| 418 |
'bookmark' => [ |
| 419 |
'label' => __('Bookmark', 'wp-extra'), |
| 420 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><path d="M68 56L60 50L52 56V24H68V56Z" fill="#2271B1" stroke="#2271B1" stroke-width="2" stroke-linejoin="round"/></svg>', |
| 421 |
'description' => __('Reading bookmark 🔖 ribbon', 'wp-extra'), |
| 422 |
], |
| 423 |
'book' => [ |
| 424 |
'label' => __('Open Book', 'wp-extra'), |
| 425 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><path d="M42 53C47 50 55 50 60 54C65 50 73 50 78 53V29C73 26 65 26 60 30C55 26 47 26 42 29V53Z" stroke="#2271B1" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/><line x1="60" y1="30" x2="60" y2="54" stroke="#2271B1" stroke-width="3"/></svg>', |
| 426 |
'description' => __('Open book 📖 pages', 'wp-extra'), |
| 427 |
], |
| 428 |
'layers' => [ |
| 429 |
'label' => __('Layers', 'wp-extra'), |
| 430 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><path d="M60 22L36 33L60 44L84 33L60 22Z" fill="#2271B1"/><path d="M36 43L60 54L84 43" stroke="#334155" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M36 53L60 64L84 53" stroke="#64748B" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>', |
| 431 |
'description' => __('Layer stack ☷', 'wp-extra'), |
| 432 |
], |
| 433 |
'sparkle' => [ |
| 434 |
'label' => __('Sparkle', 'wp-extra'), |
| 435 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><path d="M60 20L63.5 35L78 38.5L63.5 42L60 57L56.5 42L42 38.5L56.5 35L60 20Z" fill="#0284C7"/><circle cx="76" cy="24" r="3" fill="#38BDF8"/><circle cx="44" cy="54" r="2" fill="#38BDF8"/></svg>', |
| 436 |
'description' => __('Modern star sparkle ✦', 'wp-extra'), |
| 437 |
], |
| 438 |
'settings' => [ |
| 439 |
'label' => __('Settings', 'wp-extra'), |
| 440 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="60" cy="40" r="9" stroke="#2271B1" stroke-width="4"/><circle cx="60" cy="40" r="4" fill="#334155"/></svg>', |
| 441 |
'description' => __('Gear cog ⚙', 'wp-extra'), |
| 442 |
], |
| 443 |
'bullet' => [ |
| 444 |
'label' => __('Bullet', 'wp-extra'), |
| 445 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><circle cx="60" cy="40" r="10" fill="#2271B1"/></svg>', |
| 446 |
'description' => __('Solid circle dot ●', 'wp-extra'), |
| 447 |
], |
| 448 |
], |
| 449 |
'default' => 'none' |
| 450 |
]); |
| 451 |
$section->add_option('choices', [ |
| 452 |
'name' => 'toggle_icon_style', |
| 453 |
'label' => __('Toggle Button Icon', 'wp-extra'), |
| 454 |
'options' => [ |
| 455 |
'chevron' => [ |
| 456 |
'label' => __('Chevron (⌄ / ⌃)', 'wp-extra'), |
| 457 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="24" y="36" width="48" height="8" rx="3" fill="#334155"/><polyline points="84 36 90 42 96 36" stroke="#2271B1" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"/></svg>', |
| 458 |
'description' => __('Modern folding chevron (Default)', 'wp-extra'), |
| 459 |
], |
| 460 |
'list' => [ |
| 461 |
'label' => __('List Menu (☰)', 'wp-extra'), |
| 462 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="24" y="36" width="48" height="8" rx="3" fill="#334155"/><line x1="84" y1="34" x2="96" y2="34" stroke="#2271B1" stroke-width="2" stroke-linecap="round"/><line x1="84" y1="40" x2="96" y2="40" stroke="#2271B1" stroke-width="2" stroke-linecap="round"/><line x1="84" y1="46" x2="96" y2="46" stroke="#2271B1" stroke-width="2" stroke-linecap="round"/></svg>', |
| 463 |
'description' => __('Classic hamburger menu icon', 'wp-extra'), |
| 464 |
], |
| 465 |
'caret' => [ |
| 466 |
'label' => __('Caret (▼ / ▲)', 'wp-extra'), |
| 467 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="24" y="36" width="48" height="8" rx="3" fill="#334155"/><path d="M85 36L90 44L95 36Z" fill="#2271B1"/></svg>', |
| 468 |
'description' => __('Solid arrow caret', 'wp-extra'), |
| 469 |
], |
| 470 |
'plus_minus' => [ |
| 471 |
'label' => __('Plus / Minus (+ / −)', 'wp-extra'), |
| 472 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="24" y="36" width="48" height="8" rx="3" fill="#334155"/><line x1="84" y1="40" x2="96" y2="40" stroke="#2271B1" stroke-width="2.5" stroke-linecap="round"/><line x1="90" y1="34" x2="90" y2="46" stroke="#2271B1" stroke-width="2.5" stroke-linecap="round"/></svg>', |
| 473 |
'description' => __('Accordion expandable + / −', 'wp-extra'), |
| 474 |
], |
| 475 |
'grid' => [ |
| 476 |
'label' => __('Grid Dots (☷)', 'wp-extra'), |
| 477 |
'svg' => '<svg viewBox="0 0 120 80" width="120" height="80" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="120" height="80" rx="8" fill="#F8FAFC" stroke="#E2E8F0" stroke-width="1.5"/><rect x="24" y="36" width="48" height="8" rx="3" fill="#334155"/><circle cx="86" cy="36" r="2" fill="#2271B1"/><circle cx="94" cy="36" r="2" fill="#2271B1"/><circle cx="86" cy="44" r="2" fill="#2271B1"/><circle cx="94" cy="44" r="2" fill="#2271B1"/></svg>', |
| 478 |
'description' => __('Four dot matrix pattern', 'wp-extra'), |
| 479 |
], |
| 480 |
], |
| 481 |
'default' => 'chevron', |
| 482 |
'show_if' => ['visibility' => true] |
| 483 |
]); |
| 484 |
$section->add_option('text', [ |
| 485 |
'type' => 'number', |
| 486 |
'name' => 'font_size', |
| 487 |
'css' => ['input_class' => 'small-text'], |
| 488 |
'label' => __('Font Size', 'wp-extra'), |
| 489 |
'default' => 14, |
| 490 |
'description' => 'px' |
| 491 |
]); |
| 492 |
$section->add_option('text', [ |
| 493 |
'type' => 'number', |
| 494 |
'name' => 'title_font_size', |
| 495 |
'css' => ['input_class' => 'small-text'], |
| 496 |
'label' => __('Title Font Size', 'wp-extra'), |
| 497 |
'default' => 16, |
| 498 |
'description' => 'px' |
| 499 |
]); |
| 500 |
$section->add_option('text', [ |
| 501 |
'type' => 'number', |
| 502 |
'name' => 'child_font_size', |
| 503 |
'css' => ['input_class' => 'small-text'], |
| 504 |
'label' => __('Sub-heading Font Size', 'wp-extra'), |
| 505 |
'default' => 13, |
| 506 |
'description' => 'px' |
| 507 |
]); |
| 508 |
$section->add_option('text', [ |
| 509 |
'type' => 'number', |
| 510 |
'name' => 'child_indent', |
| 511 |
'css' => ['input_class' => 'small-text'], |
| 512 |
'label' => __('Sub-heading Indent', 'wp-extra'), |
| 513 |
'default' => 40, |
| 514 |
'placeholder' => '40', |
| 515 |
'description' => __('px (indentation distance for nested headings H3, H4, H5... Set 0 for flat list).', 'wp-extra') |
| 516 |
]); |
| 517 |
$section->add_option('select', [ |
| 518 |
'name' => 'subheading_collapse_mode', |
| 519 |
'label' => __('Default Heading State', 'wp-extra'), |
| 520 |
'options' => [ |
| 521 |
'open_first' => __('1. Open First Item Only (Default)', 'wp-extra'), |
| 522 |
'open_all' => __('2. Open All', 'wp-extra'), |
| 523 |
'collapse_all' => __('3. Collapse All', 'wp-extra'), |
| 524 |
], |
| 525 |
'default' => 'open_first', |
| 526 |
'description' => __('Initial display state of nested sub-headings on page load.', 'wp-extra') |
| 527 |
]); |
| 528 |
$section->add_option('text', [ |
| 529 |
'type' => 'number', |
| 530 |
'name' => 'width_custom', |
| 531 |
'css' => ['input_class' => 'small-text'], |
| 532 |
'label' => __('Custom Width', 'wp-extra'), |
| 533 |
'placeholder' => '320', |
| 534 |
'description' => __('px (leave blank for auto 100%)', 'wp-extra') |
| 535 |
]); |
| 536 |
$section->add_option('text', [ |
| 537 |
'name' => 'container_padding', |
| 538 |
'css' => ['input_class' => 'regular-text'], |
| 539 |
'label' => __('Container Padding', 'wp-extra'), |
| 540 |
'placeholder' => '16px', |
| 541 |
'description' => __('Padding for outer container (#wptoc-container). Enter CSS values like 16px or 14px 18px.', 'wp-extra') |
| 542 |
]); |
| 543 |
$section->add_option('text', [ |
| 544 |
'name' => 'nav_padding', |
| 545 |
'css' => ['input_class' => 'regular-text'], |
| 546 |
'label' => __('Nav Padding', 'wp-extra'), |
| 547 |
'placeholder' => '12px 16px', |
| 548 |
'description' => __('Padding for list wrapper (#wptoc-container nav). Enter CSS values like 12px 16px.', 'wp-extra') |
| 549 |
]); |
| 550 |
$section->add_option('color', [ |
| 551 |
'name' => 'custom_background_colour', |
| 552 |
'label' => __('Container Background', 'wp-extra'), |
| 553 |
'default' => '', |
| 554 |
'description' => __('Background color of the entire container (leave blank for default).', 'wp-extra') |
| 555 |
]); |
| 556 |
$section->add_option('color', [ |
| 557 |
'name' => 'custom_header_background_colour', |
| 558 |
'label' => __('Header Background', 'wp-extra'), |
| 559 |
'default' => '', |
| 560 |
'description' => __('Background color of the header bar (leave blank for default).', 'wp-extra') |
| 561 |
]); |
| 562 |
$section->add_option('color', [ |
| 563 |
'name' => 'custom_border_colour', |
| 564 |
'label' => __('Border Color', 'wp-extra'), |
| 565 |
'default' => '', |
| 566 |
'description' => __('Border color of the container (leave blank for default).', 'wp-extra') |
| 567 |
]); |
| 568 |
$section->add_option('text', [ |
| 569 |
'type' => 'number', |
| 570 |
'name' => 'custom_border_width', |
| 571 |
'css' => ['input_class' => 'small-text'], |
| 572 |
'label' => __('Border Width', 'wp-extra'), |
| 573 |
'placeholder' => '1', |
| 574 |
'description' => __('px (border thickness, leave blank for default)', 'wp-extra') |
| 575 |
]); |
| 576 |
$section->add_option('select', [ |
| 577 |
'name' => 'custom_border_style', |
| 578 |
'label' => __('Border Style', 'wp-extra'), |
| 579 |
'options' => [ |
| 580 |
'solid' => __('Solid', 'wp-extra'), |
| 581 |
'dashed' => __('Dashed', 'wp-extra'), |
| 582 |
'dotted' => __('Dotted', 'wp-extra'), |
| 583 |
'none' => __('None', 'wp-extra'), |
| 584 |
], |
| 585 |
'default' => 'solid' |
| 586 |
]); |
| 587 |
$section->add_option('text', [ |
| 588 |
'type' => 'number', |
| 589 |
'name' => 'custom_border_radius', |
| 590 |
'css' => ['input_class' => 'small-text'], |
| 591 |
'label' => __('Border Radius', 'wp-extra'), |
| 592 |
'placeholder' => '12', |
| 593 |
'description' => __('px (rounded corners radius, leave blank for default)', 'wp-extra') |
| 594 |
]); |
| 595 |
$section->add_option('color', [ |
| 596 |
'name' => 'custom_title_colour', |
| 597 |
'label' => __('Title Color', 'wp-extra'), |
| 598 |
'default' => '', |
| 599 |
'description' => __('Leave blank to use layout default.', 'wp-extra') |
| 600 |
]); |
| 601 |
$section->add_option('color', [ |
| 602 |
'name' => 'custom_title_icon_colour', |
| 603 |
'label' => __('Title Prefix Icon Color', 'wp-extra'), |
| 604 |
'default' => '', |
| 605 |
'description' => __('Color of the icon before table of contents title.', 'wp-extra') |
| 606 |
]); |
| 607 |
$section->add_option('color', [ |
| 608 |
'name' => 'custom_link_colour', |
| 609 |
'label' => __('Link Color', 'wp-extra'), |
| 610 |
'default' => '', |
| 611 |
'description' => __('Leave blank to use layout default.', 'wp-extra') |
| 612 |
]); |
| 613 |
$section->add_option('color', [ |
| 614 |
'name' => 'custom_link_hover_colour', |
| 615 |
'label' => __('Hover & Active Accent Color', 'wp-extra'), |
| 616 |
'default' => '', |
| 617 |
'description' => __('Accent color when hovering or active scrollspy heading.', 'wp-extra') |
| 618 |
]); |
| 619 |
$section->add_option('color', [ |
| 620 |
'name' => 'custom_counter_colour', |
| 621 |
'label' => __('Counter & Bullet Color', 'wp-extra'), |
| 622 |
'default' => '', |
| 623 |
'description' => __('Default color of counter numbers, bullet dots or checkmarks.', 'wp-extra') |
| 624 |
]); |
| 625 |
$section->add_option('color', [ |
| 626 |
'name' => 'custom_button_background_colour', |
| 627 |
'label' => __('Button Background', 'wp-extra'), |
| 628 |
'default' => '', |
| 629 |
'description' => __('Background color for toggle buttons (transparent by default).', 'wp-extra') |
| 630 |
]); |
| 631 |
$section->add_option('color', [ |
| 632 |
'name' => 'custom_button_hover_background_colour', |
| 633 |
'label' => __('Button Hover Background', 'wp-extra'), |
| 634 |
'default' => '', |
| 635 |
'description' => __('Background color when hovering over buttons.', 'wp-extra') |
| 636 |
]); |
| 637 |
$section->add_option('color', [ |
| 638 |
'name' => 'custom_button_colour', |
| 639 |
'label' => __('Button Icon Color', 'wp-extra'), |
| 640 |
'default' => '', |
| 641 |
'description' => __('Icon color of toggle buttons.', 'wp-extra') |
| 642 |
]); |
| 643 |
|
| 644 |
// SECTION 3: Headings & Rules |
| 645 |
$section = $tab->add_section(__('Headings & Rules', 'wp-extra')); |
| 646 |
$section->add_option('checkbox-multiple', [ |
| 647 |
'name' => 'heading_levels', |
| 648 |
'label' => __('Heading Levels', 'wp-extra'), |
| 649 |
'options' => [ |
| 650 |
'1' => __('Heading 1 (h1)', 'wp-extra'), |
| 651 |
'2' => __('Heading 2 (h2)', 'wp-extra'), |
| 652 |
'3' => __('Heading 3 (h3)', 'wp-extra'), |
| 653 |
'4' => __('Heading 4 (h4)', 'wp-extra'), |
| 654 |
'5' => __('Heading 5 (h5)', 'wp-extra'), |
| 655 |
'6' => __('Heading 6 (h6)', 'wp-extra'), |
| 656 |
], |
| 657 |
'default' => ['1', '2', '3', '4', '5', '6'], |
| 658 |
'description' => __('Select heading levels to include in the table of contents.', 'wp-extra') |
| 659 |
]); |
| 660 |
$section->add_option('text', [ |
| 661 |
'name' => 'exclude', |
| 662 |
'label' => __('Exclude Headings', 'wp-extra'), |
| 663 |
'placeholder' => 'Introduction*|Comments|References', |
| 664 |
'description' => __('Specify headings to exclude separated by pipe | (supports wildcard *).', 'wp-extra') |
| 665 |
]); |
| 666 |
$section->add_option('text', [ |
| 667 |
'name' => 'exclude_by_class', |
| 668 |
'label' => __('Exclude by CSS Class', 'wp-extra'), |
| 669 |
'placeholder' => 'no-toc, ignore-heading', |
| 670 |
'description' => __('Enter CSS classes of headings to exclude, separated by comma.', 'wp-extra') |
| 671 |
]); |
| 672 |
$section->add_option('text', [ |
| 673 |
'name' => 'exclude_post_ids', |
| 674 |
'label' => __('Exclude Posts by ID', 'wp-extra'), |
| 675 |
'placeholder' => '12, 45, 108', |
| 676 |
'description' => __('Enter post/page IDs to exclude from table of contents, separated by comma (,).', 'wp-extra') |
| 677 |
]); |
| 678 |
$section->add_option('text', [ |
| 679 |
'name' => 'exclude_category_ids', |
| 680 |
'label' => __('Exclude Categories by ID', 'wp-extra'), |
| 681 |
'placeholder' => '3, 8, 21', |
| 682 |
'description' => __('Enter category IDs to exclude from table of contents, separated by comma (,).', 'wp-extra') |
| 683 |
]); |
| 684 |
$section->add_option('checkbox', [ |
| 685 |
'name' => 'include_homepage', |
| 686 |
'label' => __('Show on Homepage', 'wp-extra'), |
| 687 |
'description' => __('Show table of contents on homepage if eligible headings exist.', 'wp-extra'), |
| 688 |
'default' => false |
| 689 |
]); |
| 690 |
$section->add_option('checkbox', [ |
| 691 |
'name' => 'include_category', |
| 692 |
'label' => __('Show on Category Pages', 'wp-extra'), |
| 693 |
'default' => false |
| 694 |
]); |
| 695 |
$section->add_option('checkbox', [ |
| 696 |
'name' => 'include_product_category', |
| 697 |
'label' => __('Show in WooCommerce Product Categories', 'wp-extra'), |
| 698 |
'default' => false |
| 699 |
]); |
| 700 |
|
| 701 |
// SECTION 4: Sticky TOC |
| 702 |
$section = $tab->add_section(__('Sticky TOC', 'wp-extra')); |
| 703 |
$section->add_option('checkbox', [ |
| 704 |
'name' => 'sticky-toggle', |
| 705 |
'label' => __('Enable Sticky Floating Button (FAB)', 'wp-extra'), |
| 706 |
'description' => __('Display floating circular button when scrolling down, clicking opens table of contents drawer panel.', 'wp-extra'), |
| 707 |
'default' => true |
| 708 |
]); |
| 709 |
$section->add_option('select', [ |
| 710 |
'name' => 'sticky-toggle-position', |
| 711 |
'label' => __('Floating Button Position', 'wp-extra'), |
| 712 |
'options' => [ |
| 713 |
'bottom-left' => __('Bottom Left (Default)', 'wp-extra'), |
| 714 |
'bottom-right' => __('Bottom Right', 'wp-extra'), |
| 715 |
'bottom-center' => __('Bottom Center Badge (Edge attached)', 'wp-extra'), |
| 716 |
'middle-left' => __('Vertical Left Badge (Edge attached)', 'wp-extra'), |
| 717 |
'middle-right' => __('Vertical Right Badge (Edge attached)', 'wp-extra'), |
| 718 |
], |
| 719 |
'default' => 'bottom-left', |
| 720 |
'description' => __('Floating button position (horizontal pill badge or vertical edge badge).', 'wp-extra'), |
| 721 |
'show_if' => ['sticky-toggle' => true] |
| 722 |
]); |
| 723 |
$section->add_option('text', [ |
| 724 |
'name' => 'sticky_button_text', |
| 725 |
'label' => __('Floating Button Text', 'wp-extra'), |
| 726 |
'default' => 'Contents', |
| 727 |
'placeholder' => 'Contents', |
| 728 |
'description' => __('Text label displayed on the floating sticky badge (e.g. "Contents"). Leave empty to display icon only.', 'wp-extra'), |
| 729 |
'show_if' => ['sticky-toggle' => true] |
| 730 |
]); |
| 731 |
$section->add_option('color', [ |
| 732 |
'name' => 'sticky_highlight_bg_colour', |
| 733 |
'label' => __('Active Background Color', 'wp-extra'), |
| 734 |
'default' => '#f0f6fc', |
| 735 |
'show_if' => ['sticky-toggle' => true] |
| 736 |
]); |
| 737 |
$section->add_option('color', [ |
| 738 |
'name' => 'sticky_highlight_title_colour', |
| 739 |
'label' => __('Active Text Color', 'wp-extra'), |
| 740 |
'default' => '#2271b1', |
| 741 |
'show_if' => ['sticky-toggle' => true] |
| 742 |
]); |
| 743 |
$section->add_option('text', [ |
| 744 |
'type' => 'number', |
| 745 |
'name' => 'sticky_width', |
| 746 |
'css' => ['input_class' => 'small-text'], |
| 747 |
'label' => __('Sticky Width', 'wp-extra'), |
| 748 |
'placeholder' => '270', |
| 749 |
'description' => __('px (leave blank for default 270px)', 'wp-extra'), |
| 750 |
'show_if' => ['sticky-toggle' => true] |
| 751 |
]); |
| 752 |
$section->add_option('text', [ |
| 753 |
'type' => 'number', |
| 754 |
'name' => 'sticky_height', |
| 755 |
'css' => ['input_class' => 'small-text'], |
| 756 |
'label' => __('Sticky Max Height', 'wp-extra'), |
| 757 |
'placeholder' => '500', |
| 758 |
'description' => __('px (leave blank for default auto)', 'wp-extra'), |
| 759 |
'show_if' => ['sticky-toggle' => true] |
| 760 |
]); |
| 761 |
$section->add_option('text', [ |
| 762 |
'type' => 'number', |
| 763 |
'name' => 'sticky_scale', |
| 764 |
'css' => ['input_class' => 'small-text'], |
| 765 |
'label' => __('Sticky Scale', 'wp-extra'), |
| 766 |
'default' => '90', |
| 767 |
'placeholder' => '90', |
| 768 |
'description' => __('% (e.g. 90 for 90%, leave blank for 100%)', 'wp-extra'), |
| 769 |
'show_if' => ['sticky-toggle' => true] |
| 770 |
]); |
| 771 |
$section->add_option('text', [ |
| 772 |
'type' => 'number', |
| 773 |
'name' => 'sticky_mobile_width', |
| 774 |
'css' => ['input_class' => 'small-text'], |
| 775 |
'label' => __('Sticky Mobile Width', 'wp-extra'), |
| 776 |
'placeholder' => '280', |
| 777 |
'description' => __('px (leave blank for default auto responsive)', 'wp-extra'), |
| 778 |
'show_if' => ['sticky-toggle' => true] |
| 779 |
]); |
| 780 |
$section->add_option('text', [ |
| 781 |
'type' => 'number', |
| 782 |
'name' => 'sticky_mobile_height', |
| 783 |
'css' => ['input_class' => 'small-text'], |
| 784 |
'label' => __('Sticky Mobile Max Height', 'wp-extra'), |
| 785 |
'placeholder' => '400', |
| 786 |
'description' => __('px (leave blank for default auto responsive)', 'wp-extra'), |
| 787 |
'show_if' => ['sticky-toggle' => true] |
| 788 |
]); |
| 789 |
|
| 790 |
// SECTION 5: Advanced & Performance |
| 791 |
$section = $tab->add_section(__('Advanced & Performance', 'wp-extra')); |
| 792 |
$section->add_option('select', [ |
| 793 |
'name' => 'toc_loading', |
| 794 |
'label' => __('Loading Method', 'wp-extra'), |
| 795 |
'options' => [ |
| 796 |
'js' => __('JavaScript (Default - Full animation & smooth scroll)', 'wp-extra'), |
| 797 |
'css' => __('Pure CSS (Super lightweight, no JS)', 'wp-extra'), |
| 798 |
], |
| 799 |
'default' => 'js' |
| 800 |
]); |
| 801 |
$section->add_option('checkbox', [ |
| 802 |
'name' => 'inline_css', |
| 803 |
'label' => __('Inline CSS', 'wp-extra'), |
| 804 |
'description' => __('Inject CSS inline to reduce HTTP requests.', 'wp-extra'), |
| 805 |
'default' => false |
| 806 |
]); |
| 807 |
$section->add_option('checkbox', [ |
| 808 |
'name' => 'smooth_scroll', |
| 809 |
'label' => __('Smooth Scroll', 'wp-extra'), |
| 810 |
'description' => __('Scroll smoothly to anchor targets when clicking TOC links.', 'wp-extra'), |
| 811 |
'default' => true |
| 812 |
]); |
| 813 |
$section->add_option('text', [ |
| 814 |
'type' => 'number', |
| 815 |
'name' => 'smooth_scroll_offset', |
| 816 |
'css' => ['input_class' => 'small-text'], |
| 817 |
'label' => __('Smooth Scroll Offset', 'wp-extra'), |
| 818 |
'default' => 30, |
| 819 |
'description' => 'px', |
| 820 |
'show_if' => ['smooth_scroll' => true] |
| 821 |
]); |
| 822 |
} |
| 823 |
|
| 824 |
// 3. Clone / Duplicate Tab |
| 825 |
if (self::get_option('modules') && in_array('duplicate', self::get_option('modules'))) { |
| 826 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M5 4.5h11a.5.5 0 0 1 .5.5v11a.5.5 0 0 1-.5.5H5a.5.5 0 0 1-.5-.5V5a.5.5 0 0 1 .5-.5ZM3 5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5Zm17 3v10.75c0 .69-.56 1.25-1.25 1.25H6v1.5h12.75a2.75 2.75 0 0 0 2.75-2.75V8H20Z"></path></svg>' . __('Clone', 'wp-extra')); |
| 827 |
|
| 828 |
$section = $tab->add_section(__('Duplication', 'wp-extra')); |
| 829 |
$section->add_option('checkbox-multiple', [ |
| 830 |
'name' => 'duplicate', |
| 831 |
'options' => fn() => array_combine( |
| 832 |
$ids = array_diff(get_post_types(['public' => true]), ['product', 'attachment']), |
| 833 |
array_map(fn($id) => get_post_type_object($id)->label . " <code>$id</code>", $ids) |
| 834 |
), |
| 835 |
'label' => __('Duplicate Post Types', 'wp-extra'), |
| 836 |
'description' => __('Add a 1-click Clone action to Posts, Pages, and Custom Post Types.', 'wp-extra') |
| 837 |
]); |
| 838 |
$section->add_option('checkbox-multiple', [ |
| 839 |
'name' => 'duplicate_tax', |
| 840 |
'options' => fn() => array_combine( |
| 841 |
$ids = array_diff(get_taxonomies(['public' => true], 'names'), ['post_format']), |
| 842 |
array_map(fn($id) => get_taxonomy($id)->label . " <code>$id</code>", $ids) |
| 843 |
), |
| 844 |
'label' => __('Duplicate Taxonomies', 'wp-extra'), |
| 845 |
'description' => __('Add a Clone action to Categories, Tags, and Custom Taxonomies.', 'wp-extra') |
| 846 |
]); |
| 847 |
} |
| 848 |
|
| 849 |
// 4. Media Tab |
| 850 |
if (self::get_option('modules') && in_array('media', self::get_option('modules'))) { |
| 851 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="m7 6.5 4 2.5-4 2.5z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="m5 3c-1.10457 0-2 .89543-2 2v14c0 1.1046.89543 2 2 2h14c1.1046 0 2-.8954 2-2v-14c0-1.10457-.8954-2-2-2zm14 1.5h-14c-.27614 0-.5.22386-.5.5v10.7072l3.62953-2.6465c.25108-.1831.58905-.1924.84981-.0234l2.92666 1.8969 3.5712-3.4719c.2911-.2831.7545-.2831 1.0456 0l2.9772 2.8945v-9.3568c0-.27614-.2239-.5-.5-.5zm-14.5 14.5v-1.4364l4.09643-2.987 2.99567 1.9417c.2936.1903.6798.1523.9307-.0917l3.4772-3.3806 3.4772 3.3806.0228-.0234v2.5968c0 .2761-.2239.5-.5.5h-14c-.27614 0-.5-.2239-.5-.5z"></path></svg>' . __('Media')); |
| 852 |
|
| 853 |
$section = $tab->add_section(__('Image Optimization & Uploads', 'wp-extra')); |
| 854 |
$section->add_option('checkbox', [ |
| 855 |
'name' => 'allow_filetype', |
| 856 |
'label' => __('Allow SVG Uploads', 'wp-extra'), |
| 857 |
'description' => __('Enable secure SVG file uploads in WordPress Media Library.', 'wp-extra') |
| 858 |
]); |
| 859 |
$section->add_option('checkbox', [ |
| 860 |
'name' => 'autoupload', |
| 861 |
'label' => __('Auto Optimize Uploads', 'wp-extra'), |
| 862 |
'description' => __('Automatically resize and convert uploaded images to modern formats (WebP/JPG).', 'wp-extra') |
| 863 |
]); |
| 864 |
$section->add_option('select', [ |
| 865 |
'name' => 'autoconverter', |
| 866 |
'show_if' => ['autoupload' => true], |
| 867 |
'label' => __('Format Converter', 'wp-extra'), |
| 868 |
'options' => [ |
| 869 |
'' => __('No'), |
| 870 |
'webp' => __('WebP (Recommended)', 'wp-extra'), |
| 871 |
'jpg' => __('JPG') |
| 872 |
] |
| 873 |
]); |
| 874 |
$section->add_option('text', [ |
| 875 |
'type' => 'number', |
| 876 |
'name' => 'image_max_width', |
| 877 |
'css' => ['input_class' => 'small-text'], |
| 878 |
'show_if' => ['autoupload' => true], |
| 879 |
'label' => __('Max Image Width', 'wp-extra'), |
| 880 |
'description' => __('px (E.g: 1920). Larger images are scaled down automatically.', 'wp-extra') |
| 881 |
]); |
| 882 |
$section->add_option('text', [ |
| 883 |
'type' => 'number', |
| 884 |
'name' => 'image_max_height', |
| 885 |
'css' => ['input_class' => 'small-text'], |
| 886 |
'show_if' => ['autoupload' => true], |
| 887 |
'label' => __('Max Image Height', 'wp-extra'), |
| 888 |
'description' => __('px (E.g: 1080). Larger images are scaled down automatically.', 'wp-extra') |
| 889 |
]); |
| 890 |
$section->add_option('text', [ |
| 891 |
'type' => 'number', |
| 892 |
'name' => 'image_limit', |
| 893 |
'css' => ['input_class' => 'small-text'], |
| 894 |
'label' => __('Max File Size Limit', 'wp-extra'), |
| 895 |
'description' => __('KB (E.g: 2048 = 2MB). Prevent uploading overly large files.', 'wp-extra') |
| 896 |
]); |
| 897 |
$section->add_option('text', [ |
| 898 |
'type' => 'number', |
| 899 |
'name' => 'image_quality', |
| 900 |
'css' => ['input_class' => 'small-text'], |
| 901 |
'default' => '90', |
| 902 |
'options' => [ |
| 903 |
'step' => '5', |
| 904 |
'min' => '70', |
| 905 |
'max' => '100' |
| 906 |
], |
| 907 |
'label' => __('Compression Quality', 'wp-extra'), |
| 908 |
'description' => '% ' . __('Default') . ': 90%' |
| 909 |
]); |
| 910 |
|
| 911 |
$section = $tab->add_section(__('Remote Images & Featured Thumbnails', 'wp-extra')); |
| 912 |
$section->add_option('image', [ |
| 913 |
'name' => 'media_default', |
| 914 |
'label' => __('Default Featured Image', 'wp-extra'), |
| 915 |
'description' => __('Fallback featured image used when a post has no thumbnail set.', 'wp-extra') |
| 916 |
]); |
| 917 |
$section->add_option('checkbox', [ |
| 918 |
'name' => 'save_images', |
| 919 |
'label' => __('Auto Save External Images', 'wp-extra'), |
| 920 |
'description' => __('Automatically download remote images in post content to local Media Library upon publishing.', 'wp-extra') |
| 921 |
]); |
| 922 |
$section->add_option('checkbox', [ |
| 923 |
'name' => 'autocrop', |
| 924 |
'show_if' => ['save_images' => true], |
| 925 |
'label' => __('Auto Crop Downloaded Images', 'wp-extra') |
| 926 |
]); |
| 927 |
$section->add_option('text', [ |
| 928 |
'type' => 'number', |
| 929 |
'name' => 'crop_width', |
| 930 |
'css' => ['input_class' => 'small-text'], |
| 931 |
'show_if' => ['autocrop' => true], |
| 932 |
'label' => __('Crop Width', 'wp-extra'), |
| 933 |
'description' => 'px (E.g: 800)' |
| 934 |
]); |
| 935 |
$section->add_option('text', [ |
| 936 |
'type' => 'number', |
| 937 |
'name' => 'crop_height', |
| 938 |
'css' => ['input_class' => 'small-text'], |
| 939 |
'show_if' => ['autocrop' => true], |
| 940 |
'label' => __('Crop Height', 'wp-extra'), |
| 941 |
'description' => 'px (E.g: 600)' |
| 942 |
]); |
| 943 |
$section->add_option('checkbox', [ |
| 944 |
'name' => 'autoflip', |
| 945 |
'show_if' => ['save_images' => true], |
| 946 |
'label' => __('Flip Horizontal', 'wp-extra') |
| 947 |
]); |
| 948 |
$section->add_option('checkbox', [ |
| 949 |
'name' => 'autoset', |
| 950 |
'label' => __('Auto Set Featured Image', 'wp-extra'), |
| 951 |
'description' => __('Automatically set the first post image as the featured image if none is selected.', 'wp-extra') |
| 952 |
]); |
| 953 |
|
| 954 |
$section = $tab->add_section(__('Media SEO & Filenames', 'wp-extra')); |
| 955 |
$section->add_option('select', [ |
| 956 |
'name' => 'rename_images', |
| 957 |
'label' => __('SEO File Renamer', 'wp-extra'), |
| 958 |
'options' => [ |
| 959 |
'' => __('No'), |
| 960 |
'slug' => __('post-slug.jpg'), |
| 961 |
'filename' => __('post-slug-{file-name}.jpg'), |
| 962 |
'date' => __('post-slug-{2026-08-19}.jpg') |
| 963 |
], |
| 964 |
'description' => __('Automatically rename uploaded media files based on post slug for better Google Image SEO.', 'wp-extra') |
| 965 |
]); |
| 966 |
$section->add_option('checkbox', [ |
| 967 |
'name' => 'meta_images', |
| 968 |
'label' => __('Auto Image Alt & Titles', 'wp-extra'), |
| 969 |
'description' => __('Automatically populate Title, Alt-Text, and Caption for images from post title.', 'wp-extra') |
| 970 |
]); |
| 971 |
$section->add_option('checkbox', [ |
| 972 |
'name' => 'meta_images_filename', |
| 973 |
'show_if' => ['meta_images' => true], |
| 974 |
'label' => __('Use Original Filename', 'wp-extra'), |
| 975 |
'description' => __('Generate Alt/Title from cleaned filename instead of post title.', 'wp-extra') |
| 976 |
]); |
| 977 |
$section->add_option('checkbox-multiple', [ |
| 978 |
'name' => 'media_thumbnails', |
| 979 |
'del' => true, |
| 980 |
'options' => fn() => array_combine( |
| 981 |
$sizes = get_intermediate_image_sizes(), |
| 982 |
array_map(fn($size) => ucfirst(str_replace('_', ' ', $size)), $sizes) |
| 983 |
), |
| 984 |
'label' => __('Disable Unnecessary Thumbnails', 'wp-extra'), |
| 985 |
'description' => __('Prevent generating unused image sizes to save disk storage and CDN bandwidth.', 'wp-extra') |
| 986 |
]); |
| 987 |
$section->add_option('checkbox', [ |
| 988 |
'name' => 'big_image_threshold', |
| 989 |
'label' => __('Disable Large Image Threshold (2560px)', 'wp-extra'), |
| 990 |
'description' => __('Disable WordPress default 2560px image threshold auto-scaling.', 'wp-extra') |
| 991 |
]); |
| 992 |
} |
| 993 |
|
| 994 |
// 5. Comments Tab |
| 995 |
if (self::get_option('modules') && in_array('comments', self::get_option('modules'))) { |
| 996 |
$tab = $settings->add_tab('<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path fill-rule="evenodd" clip-rule="evenodd" d="M6.68822 16.625L5.5 17.8145L5.5 5.5L18.5 5.5L18.5 16.625L6.68822 16.625ZM7.31 18.125L19 18.125C19.5523 18.125 20 17.6773 20 17.125L20 5C20 4.44772 19.5523 4 19 4H5C4.44772 4 4 4.44772 4 5V19.5247C4 19.8173 4.16123 20.086 4.41935 20.2237C4.72711 20.3878 5.10601 20.3313 5.35252 20.0845L7.31 18.125ZM16 9.99997H8V8.49997H16V9.99997ZM8 14H13V12.5H8V14Z"></path></svg>' . __('Comments')); |
| 997 |
|
| 998 |
$section = $tab->add_section(__('Comments & Anti-Spam Control', 'wp-extra')); |
| 999 |
$section->add_option('checkbox', [ |
| 1000 |
'name' => 'disable_comments', |
| 1001 |
'label' => __('Disable All Comments', 'wp-extra'), |
| 1002 |
'description' => __('Completely close comments across all posts, pages, and post types.', 'wp-extra') |
| 1003 |
]); |
| 1004 |
$section->add_option('checkbox', [ |
| 1005 |
'name' => 'cm_media', |
| 1006 |
'label' => __('Disable Media Comments', 'wp-extra'), |
| 1007 |
'description' => __('Close comments on media attachment pages.', 'wp-extra') |
| 1008 |
]); |
| 1009 |
$section->add_option('checkbox', [ |
| 1010 |
'name' => 'cm_antispam', |
| 1011 |
'label' => __('Smart Anti-Spam Filter', 'wp-extra'), |
| 1012 |
'description' => __('Automatically filter out spam comments containing malicious keywords or links.', 'wp-extra') |
| 1013 |
]); |
| 1014 |
} |
| 1015 |
|
| 1016 |
// 6. Branding & Logins Tab |
| 1017 |
if (self::get_option('modules') && in_array('logins', self::get_option('modules'))) { |
| 1018 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M4 20h8v-1.5H4V20zM18.9 3.5c-.6-.6-1.5-.6-2.1 0l-7.2 7.2c-.4-.1-.7 0-1.1.1-.5.2-1.5.7-1.9 2.2-.4 1.7-.8 2.2-1.1 2.7-.1.1-.2.3-.3.4l-.6 1.1H6c2 0 3.4-.4 4.7-1.4.8-.6 1.2-1.4 1.3-2.3 0-.3 0-.5-.1-.7L19 5.7c.5-.6.5-1.6-.1-2.2zM9.7 14.7c-.7.5-1.5.8-2.4 1 .2-.5.5-1.2.8-2.3.2-.6.4-1 .8-1.1.5-.1 1 .1 1.3.3.2.2.3.5.2.8 0 .3-.1.9-.7 1.3z"></path></svg>' . __('Branding', 'wp-extra')); |
| 1019 |
|
| 1020 |
$section = $tab->add_section(__('Login Screen Customization', 'wp-extra')); |
| 1021 |
$section->add_option('choices', [ |
| 1022 |
'name' => 'login_preset', |
| 1023 |
'label' => __('Login Design Preset', 'wp-extra'), |
| 1024 |
'default' => 'default', |
| 1025 |
'options' => [ |
| 1026 |
'default' => [ |
| 1027 |
'label' => __('Default', 'wp-extra'), |
| 1028 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#f0f0f1"/><circle cx="60" cy="14" r="5" fill="#2271b1"/><path d="M58 13.5l1.5 4 1-2.5 1 2.5 1.5-4" stroke="#fff" stroke-width="0.8" fill="none" stroke-linecap="round"/><rect x="36" y="22" width="48" height="42" rx="3" fill="#ffffff" stroke="#dcdcde" stroke-width="0.8"/><rect x="42" y="27" width="36" height="4.5" rx="1.5" fill="#f6f7f7" stroke="#c3c4c7" stroke-width="0.6"/><rect x="42" y="34.5" width="36" height="4.5" rx="1.5" fill="#f6f7f7" stroke="#c3c4c7" stroke-width="0.6"/><rect x="42" y="42" width="14" height="2" rx="1" fill="#8c8f94"/><rect x="62" y="41" width="16" height="5" rx="1.5" fill="#2271b1"/><rect x="42" y="51" width="18" height="2" rx="1" fill="#a7aaad"/><rect x="64" y="51" width="14" height="2" rx="1" fill="#a7aaad"/></svg>', |
| 1029 |
], |
| 1030 |
'minimal_white' => [ |
| 1031 |
'label' => __('Minimalist Clean', 'wp-extra'), |
| 1032 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#ffffff" stroke="#e5e7eb" stroke-width="0.8"/><circle cx="60" cy="13" r="4" fill="#18181b"/><rect x="38" y="20" width="44" height="44" rx="5" fill="#ffffff" stroke="#e2e8f0" stroke-width="1"/><rect x="44" y="26" width="32" height="5" rx="2.5" fill="#f8fafc" stroke="#cbd5e1" stroke-width="0.6"/><rect x="44" y="34" width="32" height="5" rx="2.5" fill="#f8fafc" stroke="#cbd5e1" stroke-width="0.6"/><rect x="44" y="43" width="32" height="6" rx="3" fill="#0f172a"/><rect x="48" y="54" width="24" height="2" rx="1" fill="#94a3b8"/></svg>', |
| 1033 |
], |
| 1034 |
'dark_modern' => [ |
| 1035 |
'label' => __('Dark Glass', 'wp-extra'), |
| 1036 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><defs><linearGradient id="dgGrad" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#18181b"/><stop offset="100%" stop-color="#09090b"/></linearGradient></defs><rect width="120" height="70" rx="4" fill="url(#dgGrad)"/><circle cx="60" cy="13" r="4.5" fill="#38bdf8"/><rect x="36" y="21" width="48" height="43" rx="4" fill="#27272a" fill-opacity="0.8" stroke="#3f3f46" stroke-width="0.8"/><rect x="42" y="27" width="36" height="5" rx="2" fill="#18181b" stroke="#52525b" stroke-width="0.6"/><rect x="42" y="35" width="36" height="5" rx="2" fill="#18181b" stroke="#52525b" stroke-width="0.6"/><rect x="42" y="44" width="36" height="6" rx="3" fill="#38bdf8"/><rect x="48" y="55" width="24" height="2" rx="1" fill="#71717a"/></svg>', |
| 1037 |
], |
| 1038 |
'gradient_vibrant' => [ |
| 1039 |
'label' => __('Vibrant Gradient', 'wp-extra'), |
| 1040 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><defs><linearGradient id="gvBg" x1="0" y1="0" x2="1" y2="1"><stop offset="0%" stop-color="#6366f1"/><stop offset="50%" stop-color="#a855f7"/><stop offset="100%" stop-color="#ec4899"/></linearGradient><linearGradient id="gvBtn" x1="0" y1="0" x2="1" y2="0"><stop offset="0%" stop-color="#8b5cf6"/><stop offset="100%" stop-color="#ec4899"/></linearGradient></defs><rect width="120" height="70" rx="4" fill="url(#gvBg)"/><circle cx="60" cy="13" r="4.5" fill="#ffffff"/><rect x="36" y="21" width="48" height="43" rx="5" fill="#ffffff" fill-opacity="0.95" stroke="rgba(255,255,255,0.6)" stroke-width="0.8"/><rect x="42" y="27" width="36" height="5" rx="2" fill="#fdf4ff" stroke="#e879f9" stroke-width="0.6"/><rect x="42" y="35" width="36" height="5" rx="2" fill="#fdf4ff" stroke="#e879f9" stroke-width="0.6"/><rect x="42" y="44" width="36" height="6" rx="3" fill="url(#gvBtn)"/><rect x="48" y="55" width="24" height="2" rx="1" fill="#c084fc"/></svg>', |
| 1041 |
], |
| 1042 |
'custom' => [ |
| 1043 |
'label' => __('Custom', 'wp-extra'), |
| 1044 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#f8fafc" stroke="#e2e8f0" stroke-width="0.8"/><circle cx="42" cy="35" r="16" fill="#e0e7ff"/><path d="M42 22a13 13 0 0 1 13 13c0 2.5-1.5 4.5-3.5 4.5-1 0-1.8-.5-2.2-1.2-.4-.7-.9-1.3-1.8-1.3H44c-4.4 0-8-3.6-8-8 0-3.9 2.7-7 6-7z" fill="#6366f1"/><circle cx="38" cy="29" r="2" fill="#f43f5e"/><circle cx="44" cy="27" r="2" fill="#3b82f6"/><circle cx="48" cy="32" r="2" fill="#10b981"/><circle cx="36" cy="36" r="2" fill="#f59e0b"/><path d="M66 26h28M66 35h28M66 44h28" stroke="#cbd5e1" stroke-width="2.5" stroke-linecap="round"/><circle cx="74" cy="26" r="4" fill="#6366f1"/><circle cx="84" cy="35" r="4" fill="#f43f5e"/><circle cx="71" cy="44" r="4" fill="#10b981"/></svg>', |
| 1045 |
], |
| 1046 |
], |
| 1047 |
'description' => __('Choose a pre-built login style or select "Custom" to reveal custom colors, background, and logo options.', 'wp-extra') |
| 1048 |
]); |
| 1049 |
$section->add_option('text', [ |
| 1050 |
'name' => 'login_title', |
| 1051 |
'css' => ['input_class' => 'regular-text'], |
| 1052 |
'label' => __('Login Page Title', 'wp-extra'), |
| 1053 |
'description' => __('Custom title tag for the login page browser tab.', 'wp-extra') |
| 1054 |
]); |
| 1055 |
$section->add_option('checkbox', [ |
| 1056 |
'name' => 'login_logo_hide', |
| 1057 |
'label' => __('Hide WordPress Logo', 'wp-extra') |
| 1058 |
]); |
| 1059 |
$section->add_option('image', [ |
| 1060 |
'name' => 'login_logo', |
| 1061 |
'show_if' => ['login_logo_hide' => false], |
| 1062 |
'label' => __('Custom Logo'), |
| 1063 |
'description' => __('Replace default WordPress logo. Max recommended width: 320px.', 'wp-extra') |
| 1064 |
]); |
| 1065 |
$section->add_option('text', [ |
| 1066 |
'name' => 'login_logo_url', |
| 1067 |
'show_if' => ['login_logo_hide' => false], |
| 1068 |
'css' => ['input_class' => 'regular-text'], |
| 1069 |
'label' => __('Logo Link URL', 'wp-extra'), |
| 1070 |
'description' => __('Redirect destination when clicking the login logo (default: homepage).', 'wp-extra') |
| 1071 |
]); |
| 1072 |
$section->add_option('color', [ |
| 1073 |
'name' => 'login_color', |
| 1074 |
'show_if' => ['login_preset' => 'custom'], |
| 1075 |
'label' => __('Accent Color', 'wp-extra') |
| 1076 |
]); |
| 1077 |
$section->add_option('image', [ |
| 1078 |
'name' => 'login_bg_image', |
| 1079 |
'show_if' => ['login_preset' => 'custom'], |
| 1080 |
'label' => __('Background Image', 'wp-extra') |
| 1081 |
]); |
| 1082 |
$section->add_option('color', [ |
| 1083 |
'name' => 'login_bg_color', |
| 1084 |
'show_if' => ['login_preset' => 'custom'], |
| 1085 |
'label' => __('Background Color', 'wp-extra') |
| 1086 |
]); |
| 1087 |
$section->add_option('text', [ |
| 1088 |
'type' => 'number', |
| 1089 |
'name' => 'login_form_radius', |
| 1090 |
'show_if' => ['login_preset' => 'custom'], |
| 1091 |
'css' => ['input_class' => 'small-text'], |
| 1092 |
'label' => __('Form Border Radius', 'wp-extra'), |
| 1093 |
'description' => 'px' |
| 1094 |
]); |
| 1095 |
$section->add_option('checkbox', [ |
| 1096 |
'name' => 'login_placeholder', |
| 1097 |
'label' => __('Add Input Placeholders', 'wp-extra'), |
| 1098 |
'description' => __('Show Username and Password inside input fields.', 'wp-extra') |
| 1099 |
]); |
| 1100 |
$section->add_option('checkbox', [ |
| 1101 |
'name' => 'login_remember', |
| 1102 |
'label' => __('Auto-Check Remember Me', 'wp-extra') |
| 1103 |
]); |
| 1104 |
$section->add_option('checkbox-multiple', [ |
| 1105 |
'name' => 'login_link_form', |
| 1106 |
'del' => true, |
| 1107 |
'options' => [ |
| 1108 |
'remember' => __('Remember Me'), |
| 1109 |
'lost' => __('Register') . ' | ' . __('Lost your password?'), |
| 1110 |
'backto' => __('« Back'), |
| 1111 |
'language' => __('Language'), |
| 1112 |
'privacy' => __('Privacy Policy') |
| 1113 |
], |
| 1114 |
'label' => __('Hide Login Footer Links', 'wp-extra') |
| 1115 |
]); |
| 1116 |
|
| 1117 |
$section = $tab->add_section(__('Login Security & Protection', 'wp-extra')); |
| 1118 |
$section->add_option('text', [ |
| 1119 |
'name' => 'login_url', |
| 1120 |
'label' => __('Custom Login URL', 'wp-extra'), |
| 1121 |
'description' => __('Change your login URL slug to block brute-force bots from finding wp-login.php.', 'wp-extra') . '<br>🔐 <a href="' . esc_url(wp_login_url()) . '" target="_blank">' . __('Preview Login URL', 'wp-extra') . '</a>' |
| 1122 |
]); |
| 1123 |
$section->add_option('checkbox', [ |
| 1124 |
'name' => 'turnstile', |
| 1125 |
'label' => __('Cloudflare Turnstile Captcha', 'wp-extra'), |
| 1126 |
'description' => 'Protect login and registration forms with smart zero-friction captcha. <a href="https://developers.cloudflare.com/turnstile/get-started/" target="_blank">' . __('Get Turnstile Keys', 'wp-extra') . '</a>' |
| 1127 |
]); |
| 1128 |
$section->add_option('text', [ |
| 1129 |
'name' => 'turnstile_site_key', |
| 1130 |
'show_if' => ['turnstile' => true], |
| 1131 |
'css' => ['input_class' => 'regular-text'], |
| 1132 |
'label' => __('Turnstile Site Key', 'wp-extra') |
| 1133 |
]); |
| 1134 |
$section->add_option('text', [ |
| 1135 |
'name' => 'turnstile_secret_key', |
| 1136 |
'show_if' => ['turnstile' => true], |
| 1137 |
'css' => ['input_class' => 'regular-text'], |
| 1138 |
'label' => __('Turnstile Secret Key', 'wp-extra') |
| 1139 |
]); |
| 1140 |
if (Helper::is_woo_active()) { |
| 1141 |
$section->add_option('checkbox', [ |
| 1142 |
'name' => 'turnstile_my_account', |
| 1143 |
'show_if' => ['turnstile' => true], |
| 1144 |
'label' => __('WooCommerce My-Account & Flatsome Popup Turnstile', 'wp-extra'), |
| 1145 |
'description' => __('Enable Turnstile captcha on WooCommerce customer login, register forms, and Flatsome theme account popup/modal.', 'wp-extra') |
| 1146 |
]); |
| 1147 |
} |
| 1148 |
$section->add_option('text', [ |
| 1149 |
'type' => 'number', |
| 1150 |
'name' => 'limit_login', |
| 1151 |
'css' => ['input_class' => 'small-text'], |
| 1152 |
'label' => __('Limit Login Attempts', 'wp-extra'), |
| 1153 |
'description' => __('Max allowed failed login attempts before IP temporary lockout.', 'wp-extra') |
| 1154 |
]); |
| 1155 |
|
| 1156 |
$section = $tab->add_section(__('Admin Panel Branding', 'wp-extra')); |
| 1157 |
$section->add_option('checkbox', [ |
| 1158 |
'name' => 'adminfooter_version', |
| 1159 |
'label' => __('Hide WordPress Version', 'wp-extra'), |
| 1160 |
'description' => __('Remove WordPress version number from admin footer.', 'wp-extra') |
| 1161 |
]); |
| 1162 |
$section->add_option('wp-editor', [ |
| 1163 |
'name' => 'adminfooter_custom', |
| 1164 |
'teeny' => true, |
| 1165 |
'label' => __('Custom Admin Footer Text', 'wp-extra') |
| 1166 |
]); |
| 1167 |
|
| 1168 |
$section = $tab->add_section(__('Content Protection', 'wp-extra')); |
| 1169 |
$section->add_option('checkbox', [ |
| 1170 |
'name' => 'donot_copy', |
| 1171 |
'label' => __('Disable Content Copy', 'wp-extra'), |
| 1172 |
'description' => __('Disable right-click and text selection to protect your articles from copying.', 'wp-extra') |
| 1173 |
]); |
| 1174 |
$section->add_option('checkbox', [ |
| 1175 |
'name' => 'donot_content', |
| 1176 |
'show_if' => ['donot_copy' => true], |
| 1177 |
'label' => __('Allow Text Selection', 'wp-extra'), |
| 1178 |
'description' => __('Allow text selection but append copyright notice on copy.', 'wp-extra') |
| 1179 |
]); |
| 1180 |
$section->add_option('text', [ |
| 1181 |
'name' => 'donot_copyright', |
| 1182 |
'css' => ['input_class' => 'regular-text'], |
| 1183 |
'show_if' => ['donot_copy' => true], |
| 1184 |
'label' => __('Copyright Notice Text', 'wp-extra') |
| 1185 |
]); |
| 1186 |
$section->add_option('checkbox', [ |
| 1187 |
'name' => 'donot_back', |
| 1188 |
'label' => __('Disable Back Button', 'wp-extra'), |
| 1189 |
'description' => __('Prevent visitors from navigating back in history.', 'wp-extra') |
| 1190 |
]); |
| 1191 |
} |
| 1192 |
|
| 1193 |
// 7. Admin Menu & Permissions Tab |
| 1194 |
if (self::get_option('modules') && in_array('admins', self::get_option('modules'))) { |
| 1195 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z" fill-rule="evenodd"></path></svg>' . __('Permission', 'wp-extra')); |
| 1196 |
|
| 1197 |
$section = $tab->add_section(__('Top Admin Bar', 'wp-extra')); |
| 1198 |
$section->add_option('checkbox', [ |
| 1199 |
'name' => 'wp_adminbar', |
| 1200 |
'label' => __('Hide Admin Bar', 'wp-extra'), |
| 1201 |
'description' => __('Hide the top admin bar on the frontend.', 'wp-extra') |
| 1202 |
]); |
| 1203 |
$section->add_option('checkbox-multiple', [ |
| 1204 |
'select' => true, |
| 1205 |
'show_if' => ['wp_adminbar' => false], |
| 1206 |
'name' => 'wp_toolbar', |
| 1207 |
'options' => function () { |
| 1208 |
$options = [ |
| 1209 |
'wp-logo' => __('WordPress Logo', 'wp-extra'), |
| 1210 |
'site-name' => __('Site Title', 'wp-extra'), |
| 1211 |
'customize' => __('Customize', 'wp-extra'), |
| 1212 |
'updates' => __('Updates', 'wp-extra'), |
| 1213 |
'comments' => __('Comments', 'wp-extra'), |
| 1214 |
'new-content' => __('New Content Menu (+ New)', 'wp-extra'), |
| 1215 |
'edit' => __('Edit Post/Page', 'wp-extra'), |
| 1216 |
'search' => __('Search', 'wp-extra'), |
| 1217 |
'my-account' => __('Profile / Account', 'wp-extra'), |
| 1218 |
'wp-extra' => __('WP Extra', 'wp-extra'), |
| 1219 |
]; |
| 1220 |
|
| 1221 |
// Detect Active Plugins & Themes |
| 1222 |
if (defined('FLATSOME_VERSION') || get_template() === 'flatsome' || get_stylesheet() === 'flatsome') { |
| 1223 |
$options['flatsome_panel'] = __('Flatsome Theme', 'wp-extra'); |
| 1224 |
} |
| 1225 |
if (defined('WPSEO_VERSION')) { |
| 1226 |
$options['wpseo-menu'] = __('Yoast SEO', 'wp-extra'); |
| 1227 |
} |
| 1228 |
if (defined('RANK_MATH_VERSION')) { |
| 1229 |
$options['rank-math'] = __('Rank Math', 'wp-extra'); |
| 1230 |
} |
| 1231 |
if (defined('WP_ROCKET_VERSION')) { |
| 1232 |
$options['wp-rocket'] = __('WP Rocket', 'wp-extra'); |
| 1233 |
} |
| 1234 |
if (defined('LSCWP_V') || defined('LSCWP_BASENAME')) { |
| 1235 |
$options['litespeed-menu'] = __('LiteSpeed Cache', 'wp-extra'); |
| 1236 |
} |
| 1237 |
if (defined('ELEMENTOR_VERSION')) { |
| 1238 |
$options['elementor_edit_page'] = __('Elementor', 'wp-extra'); |
| 1239 |
} |
| 1240 |
if (class_exists('WooCommerce')) { |
| 1241 |
$options['woocommerce'] = __('WooCommerce', 'wp-extra'); |
| 1242 |
} |
| 1243 |
if (defined('WPFORMS_VERSION')) { |
| 1244 |
$options['wpforms-menu'] = __('WPForms', 'wp-extra'); |
| 1245 |
} |
| 1246 |
if (defined('AUTOPTIMIZE_PLUGIN_VERSION')) { |
| 1247 |
$options['autoptimize'] = __('Autoptimize', 'wp-extra'); |
| 1248 |
} |
| 1249 |
if (class_exists('QueryMonitor') || class_exists('QM_Backtrace')) { |
| 1250 |
$options['query-monitor'] = __('Query Monitor', 'wp-extra'); |
| 1251 |
} |
| 1252 |
|
| 1253 |
return $options; |
| 1254 |
}, |
| 1255 |
'label' => __('Hide Specific Admin Bar Items', 'wp-extra'), |
| 1256 |
'description' => __('Select specific items to remove from the top Admin Bar.', 'wp-extra') |
| 1257 |
]); |
| 1258 |
$section->add_option('checkbox', [ |
| 1259 |
'name' => 'admin_site_link', |
| 1260 |
'label' => __('Redirect Site Title to Admin Dashboard', 'wp-extra'), |
| 1261 |
'description' => __('When enabled, clicking the Site Title on the top Admin Bar opens the Admin Dashboard instead of viewing the website.', 'wp-extra') |
| 1262 |
]); |
| 1263 |
$section->add_option('checkbox', [ |
| 1264 |
'name' => 'wp_adminbar_auto', |
| 1265 |
'show_if' => ['wp_adminbar' => false], |
| 1266 |
'label' => __('Auto-Hide Admin Bar', 'wp-extra'), |
| 1267 |
'description' => __('Automatically slide up admin bar until hovered.', 'wp-extra') |
| 1268 |
]); |
| 1269 |
|
| 1270 |
$section = $tab->add_section(__('Admin Menu & Plugin Management', 'wp-extra')); |
| 1271 |
$section->add_option('checkbox-multiple', [ |
| 1272 |
'name' => 'adminmenu_list', |
| 1273 |
'select' => true, |
| 1274 |
'options' => function () { |
| 1275 |
global $menu; |
| 1276 |
$menu_items = []; |
| 1277 |
if (!empty($menu) && is_array($menu)) { |
| 1278 |
foreach ($menu as $item) { |
| 1279 |
if (!isset($item[0], $item[2])) |
| 1280 |
continue; |
| 1281 |
if (isset($item[4]) && preg_match('/wp-menu-separator/', $item[4])) { |
| 1282 |
$label = '<sub style="color:#616A74;">― Separator</sub>'; |
| 1283 |
} else { |
| 1284 |
$label = $item[0]; |
| 1285 |
} |
| 1286 |
$key = esc_attr($item[2]); |
| 1287 |
$menu_items[$key] = $label; |
| 1288 |
} |
| 1289 |
} |
| 1290 |
return $menu_items; |
| 1291 |
}, |
| 1292 |
'label' => __('Hide Admin Menu Items', 'wp-extra'), |
| 1293 |
'description' => __('Hide selected sidebar navigation items for non-super admins.', 'wp-extra') |
| 1294 |
]); |
| 1295 |
$section->add_option('checkbox', [ |
| 1296 |
'name' => 'menu_chunk_saver', |
| 1297 |
'label' => __('Chunked Nav Menu Saver', 'wp-extra'), |
| 1298 |
'description' => __('Optimize saving WordPress menus by splitting requests into small AJAX chunks to prevent max_input_vars limits on large menus, with group collapse/expand controls.', 'wp-extra') |
| 1299 |
]); |
| 1300 |
$section->add_option('checkbox-multiple', [ |
| 1301 |
'name' => 'adminplugin_list', |
| 1302 |
'select' => true, |
| 1303 |
'options' => function () { |
| 1304 |
if (!function_exists('get_plugins')) { |
| 1305 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 1306 |
} |
| 1307 |
$plugin_items = wp_cache_get('wpex_all_plugins_list'); |
| 1308 |
if (false === $plugin_items) { |
| 1309 |
$all_plugins = get_plugins(); |
| 1310 |
$plugin_items = []; |
| 1311 |
|
| 1312 |
foreach ($all_plugins as $value => $item) { |
| 1313 |
$key = esc_attr($value); |
| 1314 |
$label = wp_strip_all_tags($item['Name']); |
| 1315 |
$plugin_items[$key] = $label; |
| 1316 |
} |
| 1317 |
wp_cache_set('wpex_all_plugins_list', $plugin_items, '', 1800); |
| 1318 |
} |
| 1319 |
|
| 1320 |
return $plugin_items; |
| 1321 |
}, |
| 1322 |
'label' => __('Hide Installed Plugins', 'wp-extra'), |
| 1323 |
'description' => __('Hide specific plugins from appearing in the Plugins list.', 'wp-extra') |
| 1324 |
]); |
| 1325 |
$section->add_option('checkbox', [ |
| 1326 |
'name' => 'disable_widgets', |
| 1327 |
'label' => __('Disable Default Widgets', 'wp-extra'), |
| 1328 |
'description' => __('Remove all default WordPress core widgets (Archives, Calendar, Categories, Meta, Recent Posts/Comments, RSS, Search, Tag Cloud, etc.) from widgets list.', 'wp-extra') |
| 1329 |
]); |
| 1330 |
|
| 1331 |
$section = $tab->add_section(__('User Account Enhancements', 'wp-extra')); |
| 1332 |
$section->add_option('checkbox', [ |
| 1333 |
'name' => 'scrolltotop', |
| 1334 |
'label' => __('Scroll To Top', 'wp-extra'), |
| 1335 |
'description' => __('Floating squircle button to quickly scroll back to the top of any admin page.', 'wp-extra') |
| 1336 |
]); |
| 1337 |
$section->add_option('checkbox', [ |
| 1338 |
'name' => 'registration_date', |
| 1339 |
'label' => __('Show User Registration Date', 'wp-extra'), |
| 1340 |
'description' => __('Display registration date column in the Users list table.', 'wp-extra') |
| 1341 |
]); |
| 1342 |
$section->add_option('checkbox', [ |
| 1343 |
'name' => 'last_login', |
| 1344 |
'label' => __('Show User Last Login', 'wp-extra'), |
| 1345 |
'description' => __('Display last login time column in the Users list table.', 'wp-extra') |
| 1346 |
]); |
| 1347 |
$section->add_option('checkbox', [ |
| 1348 |
'name' => 'application_passwords', |
| 1349 |
'label' => __('Disable Application Passwords', 'wp-extra'), |
| 1350 |
'description' => __('Turn off WordPress Application Passwords feature for security.', 'wp-extra') |
| 1351 |
]); |
| 1352 |
$section->add_option('checkbox', [ |
| 1353 |
'name' => 'profile_pw', |
| 1354 |
'label' => __('Disable Password Change in Profile', 'wp-extra'), |
| 1355 |
'description' => __('Hide password fields in user profile to prevent users from changing passwords.', 'wp-extra') |
| 1356 |
]); |
| 1357 |
$section->add_option('checkbox', [ |
| 1358 |
'name' => 'profile_email', |
| 1359 |
'label' => __('Disable Email Change in Profile', 'wp-extra'), |
| 1360 |
'description' => __('Lock and prevent users from changing their email address on the profile screen.', 'wp-extra') |
| 1361 |
]); |
| 1362 |
|
| 1363 |
$section = $tab->add_section(__('Access & Security Restrictions', 'wp-extra')); |
| 1364 |
$section->add_option('checkbox-multiple', [ |
| 1365 |
'name' => 'no_backend', |
| 1366 |
'select' => true, |
| 1367 |
'options' => function () { |
| 1368 |
$roles = get_editable_roles(); |
| 1369 |
unset($roles['administrator']); |
| 1370 |
$options = []; |
| 1371 |
foreach ($roles as $key => $role) { |
| 1372 |
$options[$key] = translate_user_role($role['name']); |
| 1373 |
} |
| 1374 |
return $options; |
| 1375 |
}, |
| 1376 |
'label' => __('Block Backend Access by Role', 'wp-extra'), |
| 1377 |
'description' => __('Prevent non-admin user roles from accessing /wp-admin and redirect them to homepage.', 'wp-extra') |
| 1378 |
]); |
| 1379 |
$section->add_option('checkbox-multiple', [ |
| 1380 |
'name' => 'adminmenu_extra', |
| 1381 |
'select' => true, |
| 1382 |
'options' => fn() => wp_list_pluck(get_users(['role' => 'administrator']), 'display_name', 'ID'), |
| 1383 |
'label' => __('WP EXtra Super Admins', 'wp-extra'), |
| 1384 |
'description' => __('Only selected administrator accounts can view and edit WP EXtra settings.', 'wp-extra') |
| 1385 |
]); |
| 1386 |
} |
| 1387 |
|
| 1388 |
// 8. Security Tab |
| 1389 |
if (self::get_option('modules') && in_array('security', self::get_option('modules'))) { |
| 1390 |
$tab = $settings->add_tab('<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path d="M17 10h-1.2V7c0-2.1-1.7-3.8-3.8-3.8-2.1 0-3.8 1.7-3.8 3.8v3H7c-.6 0-1 .4-1 1v8c0 .6.4 1 1 1h10c.6 0 1-.4 1-1v-8c0-.6-.4-1-1-1zM9.8 7c0-1.2 1-2.2 2.2-2.2 1.2 0 2.2 1 2.2 2.2v3H9.8V7zm6.7 11.5h-9v-7h9v7z"></path></svg>' . __('Security', 'wp-extra')); |
| 1391 |
|
| 1392 |
$section = $tab->add_section(__('Core Hardening', 'wp-extra')); |
| 1393 |
$section->add_option('checkbox', [ |
| 1394 |
'name' => 'disable_xmlrpc', |
| 1395 |
'label' => __('Disable XML-RPC', 'wp-extra'), |
| 1396 |
'description' => __('Block XML-RPC pingbacks and brute-force attacks.', 'wp-extra') |
| 1397 |
]); |
| 1398 |
$section->add_option('checkbox', [ |
| 1399 |
'name' => 'disable_embeds', |
| 1400 |
'label' => __('Disable WordPress Embeds', 'wp-extra'), |
| 1401 |
'description' => __('Remove WordPress Embed script (wp-embed.min.js) and oEmbed discovery links.', 'wp-extra') |
| 1402 |
]); |
| 1403 |
$section->add_option('checkbox', [ |
| 1404 |
'name' => 'remove_jquery_migrate', |
| 1405 |
'label' => __('Remove jQuery Migrate', 'wp-extra'), |
| 1406 |
'description' => __('Unload legacy jQuery Migrate script on frontend to save HTTP request.', 'wp-extra') |
| 1407 |
]); |
| 1408 |
$section->add_option('checkbox', [ |
| 1409 |
'name' => 'remove_wp_version', |
| 1410 |
'label' => __('Hide WordPress Generator Version', 'wp-extra'), |
| 1411 |
'description' => __('Remove generator meta tag containing WordPress version from HTML source.', 'wp-extra') |
| 1412 |
]); |
| 1413 |
$section->add_option('checkbox', [ |
| 1414 |
'name' => 'clean_head_links', |
| 1415 |
'label' => __('Clean Head & Pingbacks', 'wp-extra'), |
| 1416 |
'description' => __('Remove legacy RSD, WLWmanifest, Shortlink tags and self-pingbacks.', 'wp-extra') |
| 1417 |
]); |
| 1418 |
$section->add_option('checkbox', [ |
| 1419 |
'name' => 'disable_rss_feeds', |
| 1420 |
'label' => __('Disable RSS Feeds & Links', 'wp-extra'), |
| 1421 |
'description' => __('Disable generated RSS feeds, 301 redirect visitors to parent URL, and remove RSS feed link tags from HTML head.', 'wp-extra') |
| 1422 |
]); |
| 1423 |
$section->add_option('checkbox', [ |
| 1424 |
'name' => 'block_user_enumeration', |
| 1425 |
'label' => __('Block User / Author Enumeration', 'wp-extra'), |
| 1426 |
'description' => __('Block URL scanner (?author=N) and REST API user queries to protect admin usernames from bots.', 'wp-extra') |
| 1427 |
]); |
| 1428 |
$section->add_option('checkbox', [ |
| 1429 |
'name' => 'security_headers', |
| 1430 |
'label' => __('Enable HTTP Security Headers', 'wp-extra'), |
| 1431 |
'description' => __('Send modern security headers (X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy).', 'wp-extra') |
| 1432 |
]); |
| 1433 |
$section->add_option('checkbox', [ |
| 1434 |
'name' => 'themeplugin_edits', |
| 1435 |
'label' => __('Disable File Editors', 'wp-extra'), |
| 1436 |
'description' => __('Disable the built-in Theme and Plugin code editors for security.', 'wp-extra') |
| 1437 |
]); |
| 1438 |
$section->add_option('checkbox', [ |
| 1439 |
'name' => 'core_updates', |
| 1440 |
'label' => __('Disable Automatic Core Updates', 'wp-extra'), |
| 1441 |
'description' => __('Prevent WordPress core from automatically applying updates.', 'wp-extra') |
| 1442 |
]); |
| 1443 |
$section->add_option('textarea', [ |
| 1444 |
'name' => 'http_request', |
| 1445 |
'label' => __('Block External HTTP API Calls', 'wp-extra'), |
| 1446 |
'description' => __('Block outgoing remote HTTP requests to specified domains (one per line).', 'wp-extra') |
| 1447 |
]); |
| 1448 |
|
| 1449 |
$section = $tab->add_section(__('REST API & Heartbeat', 'wp-extra')); |
| 1450 |
$section->add_option('choices', [ |
| 1451 |
'name' => 'disable_rest_api', |
| 1452 |
'options' => [ |
| 1453 |
'' => __('Default (Enabled)', 'wp-extra'), |
| 1454 |
'non_admins' => __('Disable for Non-Admins', 'wp-extra'), |
| 1455 |
'logged_out' => __('Disable When Logged Out', 'wp-extra') |
| 1456 |
], |
| 1457 |
'label' => __('REST API Access', 'wp-extra'), |
| 1458 |
'description' => __('Restrict REST API access to authenticated users or administrators.', 'wp-extra') |
| 1459 |
]); |
| 1460 |
$section->add_option('checkbox', [ |
| 1461 |
'name' => 'remove_rest_api_links', |
| 1462 |
'label' => __('Remove REST API Header Links', 'wp-extra'), |
| 1463 |
'description' => __('Remove REST API link tags from HTML head and HTTP response headers.', 'wp-extra') |
| 1464 |
]); |
| 1465 |
$section->add_option('choices', [ |
| 1466 |
'name' => 'disable_heartbeat', |
| 1467 |
'options' => [ |
| 1468 |
'' => __('Default'), |
| 1469 |
'everywhere' => __('Disable Everywhere', 'wp-extra'), |
| 1470 |
'allow_posts' => __('Only Allow When Editing Posts/Pages', 'wp-extra') |
| 1471 |
], |
| 1472 |
'label' => __('Heartbeat API Control', 'wp-extra'), |
| 1473 |
'description' => __('Control WordPress Heartbeat API execution to reduce server CPU load.', 'wp-extra') |
| 1474 |
]); |
| 1475 |
$section->add_option('select', [ |
| 1476 |
'name' => 'heartbeat_frequency', |
| 1477 |
'options' => [ |
| 1478 |
'' => sprintf(__('%s second'), '15') . ' (' . __('Default') . ')', |
| 1479 |
'30' => sprintf(__('%s second'), '30'), |
| 1480 |
'45' => sprintf(__('%s second'), '45'), |
| 1481 |
'60' => sprintf(__('%s second'), '60') |
| 1482 |
], |
| 1483 |
'label' => __('Heartbeat Frequency', 'wp-extra'), |
| 1484 |
'description' => __('Set interval frequency for Heartbeat requests.', 'wp-extra') |
| 1485 |
]); |
| 1486 |
$section->add_option('checkbox', [ |
| 1487 |
'name' => 'remove_blocks', |
| 1488 |
'label' => __('Disable Core Blocks Library', 'wp-extra'), |
| 1489 |
'description' => __('Unregister all standard Gutenberg core block types.', 'wp-extra') |
| 1490 |
]); |
| 1491 |
|
| 1492 |
$section = $tab->add_section(__('Htaccess Rules', 'wp-extra'), ['description' => __('Applies to Apache, LiteSpeed, and OpenLiteSpeed web servers. Please backup your server configuration before editing.', 'wp-extra')]); |
| 1493 |
$section->add_option('import', [ |
| 1494 |
'name' => 'htaccess_root', |
| 1495 |
'label' => __('Root .htaccess', 'wp-extra'), |
| 1496 |
'description' => __('.htaccess') |
| 1497 |
]); |
| 1498 |
$section->add_option('protect', [ |
| 1499 |
'name' => 'htaccess_includes', |
| 1500 |
'target' => 'includes', |
| 1501 |
'label' => __('Protect WP-Includes Folder', 'wp-extra'), |
| 1502 |
'description' => __('Creates .htaccess inside wp-includes to block direct execution of PHP scripts.', 'wp-extra') |
| 1503 |
]); |
| 1504 |
$section->add_option('protect', [ |
| 1505 |
'name' => 'htaccess_content', |
| 1506 |
'target' => 'content', |
| 1507 |
'label' => __('Protect WP-Content Folder', 'wp-extra'), |
| 1508 |
'description' => __('Creates .htaccess inside wp-content to block direct execution of PHP files.', 'wp-extra') |
| 1509 |
]); |
| 1510 |
} |
| 1511 |
|
| 1512 |
// 9. Optimize Tab |
| 1513 |
if (self::get_option('modules') && in_array('optimize', self::get_option('modules'))) { |
| 1514 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M3.445 16.505a.75.75 0 001.06.05l5.005-4.55 4.024 3.521 4.716-4.715V14h1.5V8.25H14v1.5h3.19l-3.724 3.723L9.49 9.995l-5.995 5.45a.75.75 0 00-.05 1.06z"></path></svg>' . __('Optimize', 'wp-extra')); |
| 1515 |
|
| 1516 |
$section = $tab->add_section(__('Frontend Asset Cleanup', 'wp-extra'), ['description' => __('Note: Combine with a caching plugin for best performance.', 'wp-extra')]); |
| 1517 |
$section->add_option('checkbox', [ |
| 1518 |
'name' => 'disable_emojis', |
| 1519 |
'label' => __('Disable WordPress Emojis', 'wp-extra'), |
| 1520 |
'description' => __('Remove WordPress Emoji JavaScript and styles from frontend.', 'wp-extra') |
| 1521 |
]); |
| 1522 |
$section->add_option('checkbox', [ |
| 1523 |
'name' => 'disable_dashicons', |
| 1524 |
'label' => __('Disable Dashicons for Guests', 'wp-extra'), |
| 1525 |
'description' => __('Unload Dashicons CSS for visitors who are not logged in.', 'wp-extra') |
| 1526 |
]); |
| 1527 |
$section->add_option('checkbox', [ |
| 1528 |
'name' => 'gutenberg', |
| 1529 |
'label' => __('Disable Gutenberg Block CSS', 'wp-extra'), |
| 1530 |
'description' => __('Prevent Gutenberg Block Library CSS from loading on the frontend.', 'wp-extra') |
| 1531 |
]); |
| 1532 |
$section->add_option('checkbox', [ |
| 1533 |
'name' => 'remove_global_styles', |
| 1534 |
'label' => __('Remove Global Styles & SVG Filters', 'wp-extra'), |
| 1535 |
'description' => __('Strip global-styles-inline-css and SVG Duotone Filters.', 'wp-extra') |
| 1536 |
]); |
| 1537 |
$section->add_option('checkbox', [ |
| 1538 |
'name' => 'query_strings', |
| 1539 |
'label' => __('Remove Query Strings from Static Resources', 'wp-extra'), |
| 1540 |
'description' => __('Remove version query strings from CSS/JS files to improve CDN cacheability.', 'wp-extra') |
| 1541 |
]); |
| 1542 |
$section->add_option('checkbox', [ |
| 1543 |
'name' => 'font_preconnect', |
| 1544 |
'label' => __('Preconnect Google Fonts & CDNs', 'wp-extra'), |
| 1545 |
'description' => __('Add preconnect link hints for Google Fonts and common CDNs to speed up font loading.', 'wp-extra') |
| 1546 |
]); |
| 1547 |
} |
| 1548 |
|
| 1549 |
// 10. Permalinks Tab |
| 1550 |
if (self::get_option('modules') && in_array('permalinks', self::get_option('modules'))) { |
| 1551 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12.5 14.5h-1V16h1c2.2 0 4-1.8 4-4s-1.8-4-4-4h-1v1.5h1c1.4 0 2.5 1.1 2.5 2.5s-1.1 2.5-2.5 2.5zm-4 1.5v-1.5h-1C6.1 14.5 5 13.4 5 12s1.1-2.5 2.5-2.5h1V8h-1c-2.2 0-4 1.8-4 4s1.8 4 4 4h1zm-1-3.2h5v-1.5h-5v1.5zM18 4H9c-1.1 0-2 .9-2 2v.5h1.5V6c0-.3.2-.5.5-.5h9c.3 0 .5.2.5.5v12c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5v-.5H7v.5c0 1.1.9 2 2 2h9c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2z"></path></svg>' . __('Permalinks')); |
| 1552 |
|
| 1553 |
$section = $tab->add_section(__('URL Structure & Slugs', 'wp-extra')); |
| 1554 |
$section->add_option('checkbox-multiple', [ |
| 1555 |
'name' => 'slug_post_type', |
| 1556 |
'select' => true, |
| 1557 |
'options' => fn() => array_combine( |
| 1558 |
$ids = array_diff(get_post_types(['public' => true]), ['post', 'page', 'attachment', 'blocks', 'product']), |
| 1559 |
array_map(fn($id) => get_post_type_object($id)->label . " <code>$id</code>", $ids) |
| 1560 |
), |
| 1561 |
'label' => __('Remove Post Type Slugs', 'wp-extra'), |
| 1562 |
'description' => __('Remove post type base prefix from URLs for clean single post links.', 'wp-extra') |
| 1563 |
]); |
| 1564 |
$section->add_option('checkbox-multiple', [ |
| 1565 |
'name' => 'slug_taxonomy', |
| 1566 |
'select' => true, |
| 1567 |
'options' => fn() => array_combine( |
| 1568 |
$ids = array_diff(get_taxonomies(['public' => true], 'names'), ['post_tag', 'post_format', 'product_shipping_class', 'product_brand', 'product_cat', 'product_tag']), |
| 1569 |
array_map(fn($id) => get_taxonomy($id)->label . " <code>$id</code>", $ids) |
| 1570 |
), |
| 1571 |
'label' => __('Remove Taxonomy Slugs', 'wp-extra'), |
| 1572 |
'description' => __('Remove category base prefix from archive URLs.', 'wp-extra') |
| 1573 |
]); |
| 1574 |
$section->add_option('checkbox', [ |
| 1575 |
'name' => 'slug_category_post', |
| 1576 |
'label' => __('Category & Post Slug (/category/post/)', 'wp-extra'), |
| 1577 |
'description' => __('Support 2-level URL structure for categories and posts.', 'wp-extra') |
| 1578 |
]); |
| 1579 |
$section->add_option('checkbox', [ |
| 1580 |
'name' => 'slug_hierarchical_page', |
| 1581 |
'label' => __('Hierarchical Page Slug (/parent/child/)', 'wp-extra'), |
| 1582 |
'description' => __('Support 2-level URL structure for parent and child subpages.', 'wp-extra') |
| 1583 |
]); |
| 1584 |
|
| 1585 |
$section = $tab->add_section(__('SEO & Link Redirection', 'wp-extra')); |
| 1586 |
$section->add_option('checkbox', [ |
| 1587 |
'name' => 'external_links', |
| 1588 |
'label' => __('Auto Nofollow & Open External Links in New Tab', 'wp-extra'), |
| 1589 |
'description' => __('Automatically add rel="nofollow noopener noreferrer" and target="_blank" to all external links.', 'wp-extra') |
| 1590 |
]); |
| 1591 |
$section->add_option('checkbox', [ |
| 1592 |
'name' => 'redirect_attachment', |
| 1593 |
'label' => __('Redirect Attachment Pages', 'wp-extra'), |
| 1594 |
'description' => __('Redirect media attachment URLs to the parent post or media file.', 'wp-extra') |
| 1595 |
]); |
| 1596 |
$section->add_option('checkbox', [ |
| 1597 |
'name' => 'redirect_single_post', |
| 1598 |
'label' => __('Auto Redirect Single Search Result', 'wp-extra'), |
| 1599 |
'description' => __('Redirect directly to post if a search query returns exactly one match.', 'wp-extra') |
| 1600 |
]); |
| 1601 |
|
| 1602 |
$section = $tab->add_section(__('Robots.txt Editor', 'wp-extra'), ['description' => __('Manage your search engine crawler directives file.', 'wp-extra')]); |
| 1603 |
$section->add_option('import', [ |
| 1604 |
'name' => 'robots_txt', |
| 1605 |
'label' => __('Robots.txt', 'wp-extra'), |
| 1606 |
'description' => __('robots.txt') |
| 1607 |
]); |
| 1608 |
} |
| 1609 |
|
| 1610 |
// 11. Custom Code Tab |
| 1611 |
if (self::get_option('modules') && in_array('code', self::get_option('modules'))) { |
| 1612 |
$tab = $settings->add_tab('<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" width="24" height="24" aria-hidden="true" focusable="false"><path d="M4.8 11.4H2.1V9H1v6h1.1v-2.6h2.7V15h1.1V9H4.8v2.4zm1.9-1.3h1.7V15h1.1v-4.9h1.7V9H6.7v1.1zM16.2 9l-1.5 2.7L13.3 9h-.9l-.8 6h1.1l.5-4 1.5 2.8 1.5-2.8.5 4h1.1L17 9h-.8zm3.8 5V9h-1.1v6h3.6v-1H20z"></path></svg>' . __('Code')); |
| 1613 |
|
| 1614 |
$section = $tab->add_section(__('Tracking & Custom Scripts', 'wp-extra')); |
| 1615 |
$section->add_option('code-editor', [ |
| 1616 |
'name' => 'code_header', |
| 1617 |
'editor_type' => 'text/html', |
| 1618 |
'label' => __('Header Scripts (<head>)', 'wp-extra'), |
| 1619 |
'description' => __('Add Google Analytics, Tag Manager, or tracking scripts inside the HEAD tag.', 'wp-extra') |
| 1620 |
]); |
| 1621 |
if (function_exists('wp_body_open') && version_compare(get_bloginfo('version'), '5.2', '>=')) { |
| 1622 |
$section->add_option('code-editor', [ |
| 1623 |
'name' => 'code_body', |
| 1624 |
'editor_type' => 'text/html', |
| 1625 |
'label' => __('Body Scripts (<body>)', 'wp-extra'), |
| 1626 |
'description' => __('Add scripts immediately following opening BODY tag.', 'wp-extra') |
| 1627 |
]); |
| 1628 |
} |
| 1629 |
$section->add_option('code-editor', [ |
| 1630 |
'name' => 'code_footer', |
| 1631 |
'editor_type' => 'text/html', |
| 1632 |
'label' => __('Footer Scripts (</body>)', 'wp-extra'), |
| 1633 |
'description' => __('Add tracking pixels or chat widgets loaded at page footer.', 'wp-extra') |
| 1634 |
]); |
| 1635 |
|
| 1636 |
$section = $tab->add_section(__('Custom Responsive CSS', 'wp-extra')); |
| 1637 |
$section->add_option('code-editor', [ |
| 1638 |
'name' => 'css_all', |
| 1639 |
'editor_type' => 'text/css', |
| 1640 |
'label' => __('Global CSS (All Screens)', 'wp-extra') |
| 1641 |
]); |
| 1642 |
$section->add_option('code-editor', [ |
| 1643 |
'name' => 'css_tablet', |
| 1644 |
'editor_type' => 'text/css', |
| 1645 |
'label' => __('Tablet CSS (<= 1024px)', 'wp-extra') |
| 1646 |
]); |
| 1647 |
$section->add_option('code-editor', [ |
| 1648 |
'name' => 'css_mobile', |
| 1649 |
'editor_type' => 'text/css', |
| 1650 |
'label' => __('Mobile CSS (<= 767px)', 'wp-extra') |
| 1651 |
]); |
| 1652 |
} |
| 1653 |
|
| 1654 |
// 12. Cookie Tab |
| 1655 |
if (self::get_option('modules') && in_array('cookie', self::get_option('modules'))) { |
| 1656 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="24" height="24" aria-hidden="true" focusable="false"><path d="M497.1 286.7c-3.4-4.6-8.5-7.6-14.1-8.3-73.7-9.1-129.2-71.4-129.2-145.1 0-24.7 6.4-49.2 18.5-70.8 2.8-4.9 3.3-10.8 1.6-16.2s-5.7-9.8-10.8-12.2C330 18.8 294.7 11 258.1 11c-136.2 0-247 109.9-247 245s110.8 245 247.1 245c118.2 0 220.2-83.5 242.6-198.5 1-5.5-.3-11.2-3.7-15.8m-239 173.5c-113.5 0-205.9-91.6-205.9-204.2S144.6 51.8 258.1 51.8c23.5 0 46.4 3.9 68.2 11.5-9 22.2-13.7 46-13.7 70 0 86.5 59.9 160.8 142.7 181.4-25.7 85.4-105.6 145.5-197.2 145.5"/><ellipse cx="194.5" cy="150.8" rx="20.4" ry="20.3"/><ellipse cx="264.4" cy="230.7" rx="20.4" ry="20.3"/><ellipse cx="293.8" cy="340.2" rx="20.4" ry="20.3"/><ellipse cx="146.7" cy="304.3" rx="20.4" ry="20.3"/></svg>' . __('Cookie', 'wp-extra')); |
| 1657 |
|
| 1658 |
$section = $tab->add_section(__('Cookie Banner', 'wp-extra')); |
| 1659 |
$section->add_option('choices', [ |
| 1660 |
'name' => 'cookie_preset', |
| 1661 |
'label' => __('Design Preset', 'wp-extra'), |
| 1662 |
'default' => 'default', |
| 1663 |
'options' => [ |
| 1664 |
'default' => [ |
| 1665 |
'label' => __('Classic Light', 'wp-extra'), |
| 1666 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#f8fafc" stroke="#e2e8f0" stroke-width="0.8"/><rect x="8" y="8" width="104" height="34" rx="2" fill="#ffffff" stroke="#e2e8f0" stroke-width="0.6"/><circle cx="16" cy="15" r="3" fill="#f1f5f9"/><rect x="22" y="14" width="40" height="2.5" rx="1" fill="#94a3b8"/><rect x="8" y="46" width="104" height="18" rx="2" fill="#ffffff" stroke="#cbd5e1" stroke-width="0.8"/><circle cx="16" cy="55" r="4" fill="#f59e0b"/><circle cx="15" cy="54" r="0.8" fill="#78350f"/><circle cx="17.5" cy="55.5" r="0.8" fill="#78350f"/><rect x="24" y="53" width="50" height="3" rx="1" fill="#475569"/><rect x="24" y="57.5" width="30" height="2" rx="0.8" fill="#94a3b8"/><rect x="84" y="52" width="22" height="7" rx="2" fill="#1e58b1"/></svg>', |
| 1667 |
], |
| 1668 |
'dark_modern' => [ |
| 1669 |
'label' => __('Dark Modern', 'wp-extra'), |
| 1670 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#0f172a"/><rect x="8" y="8" width="104" height="34" rx="2" fill="#1e293b" stroke="#334155" stroke-width="0.6"/><rect x="14" y="14" width="45" height="3" rx="1" fill="#64748b"/><rect x="8" y="46" width="104" height="18" rx="2" fill="#18181b" stroke="#27272a" stroke-width="0.8"/><circle cx="16" cy="55" r="4" fill="#f59e0b"/><circle cx="15" cy="54" r="0.8" fill="#78350f"/><circle cx="17.5" cy="55.5" r="0.8" fill="#78350f"/><rect x="24" y="53" width="50" height="3" rx="1" fill="#f8fafc"/><rect x="24" y="57.5" width="28" height="2" rx="0.8" fill="#94a3b8"/><rect x="84" y="52" width="22" height="7" rx="3.5" fill="#38bdf8"/></svg>', |
| 1671 |
], |
| 1672 |
'soft_warm' => [ |
| 1673 |
'label' => __('Soft Warm', 'wp-extra'), |
| 1674 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#fefce8" stroke="#fef08a" stroke-width="0.8"/><rect x="8" y="8" width="104" height="30" rx="2" fill="#ffffff" stroke="#fef08a" stroke-width="0.6"/><rect x="14" y="14" width="40" height="2.5" rx="1" fill="#ca8a04"/><rect x="16" y="42" width="88" height="22" rx="6" fill="#ffffff" stroke="#fde047" stroke-width="0.8"/><circle cx="27" cy="53" r="4.5" fill="#ea580c"/><circle cx="26" cy="52" r="0.8" fill="#ffffff"/><circle cx="28.5" cy="53.5" r="0.8" fill="#ffffff"/><rect x="36" y="50" width="34" height="3" rx="1" fill="#78350f"/><rect x="36" y="54.5" width="22" height="2" rx="0.8" fill="#a16207"/><rect x="76" y="48" width="22" height="9" rx="4.5" fill="#ea580c"/></svg>', |
| 1675 |
], |
| 1676 |
'custom' => [ |
| 1677 |
'label' => __('Custom', 'wp-extra'), |
| 1678 |
'image' => '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 70" width="100%" height="100%"><rect width="120" height="70" rx="4" fill="#f8fafc" stroke="#e2e8f0" stroke-width="0.8"/><circle cx="36" cy="35" r="15" fill="#fef3c7"/><path d="M36 24a11 11 0 0 1 11 11c0 2-1.2 3.5-2.8 3.5-.8 0-1.4-.4-1.8-1-.3-.5-.7-1-1.4-1h-1.5c-3.5 0-6.5-3-6.5-6.5 0-3.3 2.5-6 6-6z" fill="#f59e0b"/><circle cx="33" cy="30" r="1.5" fill="#ef4444"/><circle cx="38" cy="28" r="1.5" fill="#3b82f6"/><circle cx="41" cy="32" r="1.5" fill="#10b981"/><circle cx="31" cy="35" r="1.5" fill="#8b5cf6"/><path d="M60 26h34M60 35h34M60 44h34" stroke="#cbd5e1" stroke-width="2.5" stroke-linecap="round"/><circle cx="68" cy="26" r="4" fill="#f59e0b"/><circle cx="82" cy="35" r="4" fill="#1e58b1"/><circle cx="65" cy="44" r="4" fill="#ef4444"/></svg>', |
| 1679 |
], |
| 1680 |
], |
| 1681 |
'description' => __('Choose a pre-styled color scheme or select "Custom" to customize colors.', 'wp-extra') |
| 1682 |
]); |
| 1683 |
$section->add_option('wp-editor', [ |
| 1684 |
'name' => 'cookie_message', |
| 1685 |
'label' => __('Notice Message', 'wp-extra'), |
| 1686 |
'default' => __('This site uses cookies to improve your online experience, allow you to share content on social media, measure traffic to this website and display customised ads based on your browsing activity.', 'wp-extra'), |
| 1687 |
'description' => __('Notice message displayed to website visitors.', 'wp-extra'), |
| 1688 |
'editor_settings' => [ |
| 1689 |
'media_buttons' => false, |
| 1690 |
'textarea_rows' => 4, |
| 1691 |
'teeny' => true, |
| 1692 |
'quicktags' => true |
| 1693 |
] |
| 1694 |
]); |
| 1695 |
$section->add_option('text', [ |
| 1696 |
'name' => 'cookie_button', |
| 1697 |
'css' => ['input_class' => 'regular-text'], |
| 1698 |
'default' => __('Accept Cookies', 'wp-extra'), |
| 1699 |
'label' => __('Accept Button Text', 'wp-extra') |
| 1700 |
]); |
| 1701 |
$section->add_option('checkbox', [ |
| 1702 |
'name' => 'cookie_privacy', |
| 1703 |
'label' => __('Display Privacy Policy Link', 'wp-extra'), |
| 1704 |
'description' => '<a href="' . esc_url(get_privacy_policy_url()) . '" target="_blank">' . __('Privacy Policy Page') . '</a>' |
| 1705 |
]); |
| 1706 |
$section->add_option('choices', [ |
| 1707 |
'name' => 'cookie_placement', |
| 1708 |
'options' => [ |
| 1709 |
'' => __('Bottom'), |
| 1710 |
'top' => __('Top') |
| 1711 |
], |
| 1712 |
'label' => __('Banner Position', 'wp-extra') |
| 1713 |
]); |
| 1714 |
$section->add_option('text', [ |
| 1715 |
'type' => 'number', |
| 1716 |
'css' => ['input_class' => 'small-text'], |
| 1717 |
'min' => 1, |
| 1718 |
'max' => 365, |
| 1719 |
'default' => 30, |
| 1720 |
'name' => 'cookie_expire', |
| 1721 |
'label' => __('Cookie Expiry (Days)', 'wp-extra') |
| 1722 |
]); |
| 1723 |
$section->add_option('color', [ |
| 1724 |
'name' => 'cookie_bgcolor', |
| 1725 |
'show_if' => ['cookie_preset' => 'custom'], |
| 1726 |
'label' => __('Banner Background Color', 'wp-extra') |
| 1727 |
]); |
| 1728 |
$section->add_option('color', [ |
| 1729 |
'name' => 'cookie_textcolor', |
| 1730 |
'show_if' => ['cookie_preset' => 'custom'], |
| 1731 |
'label' => __('Banner Text Color', 'wp-extra') |
| 1732 |
]); |
| 1733 |
$section->add_option('color', [ |
| 1734 |
'name' => 'cookie_btnbgcolor', |
| 1735 |
'show_if' => ['cookie_preset' => 'custom'], |
| 1736 |
'label' => __('Button Background Color', 'wp-extra') |
| 1737 |
]); |
| 1738 |
$section->add_option('color', [ |
| 1739 |
'name' => 'cookie_btntextcolor', |
| 1740 |
'show_if' => ['cookie_preset' => 'custom'], |
| 1741 |
'label' => __('Button Text Color', 'wp-extra') |
| 1742 |
]); |
| 1743 |
} |
| 1744 |
|
| 1745 |
// 13. SMTP Mail Tab |
| 1746 |
if (self::get_option('modules') && in_array('smtp', self::get_option('modules'))) { |
| 1747 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4.5 4.5" width="24" height="24" aria-hidden="true" focusable="false"><path d="M4 0.75H0.5a0.25 0.25 0 0 0 -0.25 0.25v2.5a0.25 0.25 0 0 0 0.25 0.25h3.5a0.25 0.25 0 0 0 0.25 -0.25V1a0.25 0.25 0 0 0 -0.25 -0.25m-0.193 2.75H0.708l0.875 -0.905 -0.18 -0.174L0.5 3.355V1.19l1.554 1.546a0.25 0.25 0 0 0 0.352 0L4 1.151v2.188l-0.92 -0.92 -0.176 0.176ZM0.664 1h3.134L2.23 2.559Z"/></svg>' . __('SMTP', 'wp-extra')); |
| 1748 |
|
| 1749 |
$section = $tab->add_section(__('SMTP Mailer Configuration', 'wp-extra'), [ |
| 1750 |
'description' => __('Configure one or multiple SMTP accounts with daily send limits and automatic rotation.', 'wp-extra') |
| 1751 |
]); |
| 1752 |
$section->add_option('repeater', [ |
| 1753 |
'name' => 'smtp_accounts', |
| 1754 |
'label' => __('SMTP Accounts', 'wp-extra'), |
| 1755 |
'description' => __('Configure one or multiple SMTP accounts with daily send limits and automatic rotation.', 'wp-extra'), |
| 1756 |
'button_text' => __('+ Add SMTP Account', 'wp-extra'), |
| 1757 |
'fields' => [ |
| 1758 |
[ |
| 1759 |
'name' => 'provider', |
| 1760 |
'label' => __('SMTP Mail Service', 'wp-extra'), |
| 1761 |
'type' => 'select', |
| 1762 |
'options' => [ |
| 1763 |
'gmail' => 'Gmail SMTP [10,000 free emails/mo]', |
| 1764 |
'mailgun' => 'Mailgun SMTP [5,000 free emails/mo for 3 months]', |
| 1765 |
'outlook' => 'Outlook / Hotmail / Office 365', |
| 1766 |
'yahoo' => 'Yahoo Mail', |
| 1767 |
'aws_ses' => 'Amazon SES (AWS SES)', |
| 1768 |
'zoho' => 'Zoho Mail', |
| 1769 |
'sendgrid' => 'SendGrid', |
| 1770 |
'sendinblue' => 'Sendinblue (Brevo)', |
| 1771 |
'other' => __('Other Custom SMTP Server', 'wp-extra') |
| 1772 |
], |
| 1773 |
'default' => 'gmail', |
| 1774 |
'full_width' => true |
| 1775 |
], |
| 1776 |
[ |
| 1777 |
'name' => 'title', |
| 1778 |
'label' => __('Account Label', 'wp-extra'), |
| 1779 |
'type' => 'text', |
| 1780 |
'default' => 'Gmail SMTP' |
| 1781 |
], |
| 1782 |
[ |
| 1783 |
'name' => 'username', |
| 1784 |
'label' => __('Username / Email', 'wp-extra'), |
| 1785 |
'type' => 'text', |
| 1786 |
'placeholder' => 'your-email@example.com or api key' |
| 1787 |
], |
| 1788 |
[ |
| 1789 |
'name' => 'password', |
| 1790 |
'label' => __('Password / App Key', 'wp-extra'), |
| 1791 |
'type' => 'password', |
| 1792 |
'placeholder' => 'App Password or SMTP API Key' |
| 1793 |
], |
| 1794 |
[ |
| 1795 |
'name' => 'host', |
| 1796 |
'label' => __('SMTP Host', 'wp-extra'), |
| 1797 |
'type' => 'text', |
| 1798 |
'default' => 'smtp.gmail.com' |
| 1799 |
], |
| 1800 |
[ |
| 1801 |
'name' => 'port', |
| 1802 |
'label' => __('Port', 'wp-extra'), |
| 1803 |
'type' => 'number', |
| 1804 |
'default' => 465 |
| 1805 |
], |
| 1806 |
[ |
| 1807 |
'name' => 'encryption', |
| 1808 |
'label' => __('Encryption', 'wp-extra'), |
| 1809 |
'type' => 'select', |
| 1810 |
'options' => [ |
| 1811 |
'ssl' => 'SSL (Port 465)', |
| 1812 |
'tls' => 'TLS (Port 587)', |
| 1813 |
'none' => __('None', 'wp-extra') |
| 1814 |
], |
| 1815 |
'default' => 'ssl' |
| 1816 |
], |
| 1817 |
[ |
| 1818 |
'name' => 'daily_limit', |
| 1819 |
'label' => __('Daily Quota (emails/day, 0 = unlimited)', 'wp-extra'), |
| 1820 |
'type' => 'number', |
| 1821 |
'default' => 100 |
| 1822 |
] |
| 1823 |
] |
| 1824 |
]); |
| 1825 |
$section->add_option('text', [ |
| 1826 |
'name' => 'from_email', |
| 1827 |
'text' => 'email', |
| 1828 |
'css' => ['input_class' => 'regular-text'], |
| 1829 |
'label' => __('Global From Email Address', 'wp-extra') |
| 1830 |
]); |
| 1831 |
$section->add_option('text', [ |
| 1832 |
'name' => 'from_name', |
| 1833 |
'css' => ['input_class' => 'regular-text'], |
| 1834 |
'label' => __('Global From Sender Name', 'wp-extra') |
| 1835 |
]); |
| 1836 |
$section->add_option('checkbox-multiple', [ |
| 1837 |
'name' => 'smtp_options', |
| 1838 |
'options' => [ |
| 1839 |
'noverifyssl' => __('Disable SSL Certificate Verification', 'wp-extra'), |
| 1840 |
'antispam' => __('Anti-spam contact form filtering', 'wp-extra') |
| 1841 |
], |
| 1842 |
'label' => __('SMTP Options', 'wp-extra') |
| 1843 |
]); |
| 1844 |
$section->add_option('smtp', [ |
| 1845 |
'name' => 'test_email', |
| 1846 |
'label' => __('Send Test Email', 'wp-extra'), |
| 1847 |
'description' => __('Verify your SMTP mail configuration by sending a test message.', 'wp-extra') |
| 1848 |
]); |
| 1849 |
|
| 1850 |
$section = $tab->add_section(__('Email Delivery Logs', 'wp-extra'), [ |
| 1851 |
'description' => __('Track outgoing emails, check delivery status, inspect email content, and resend failed messages.', 'wp-extra') |
| 1852 |
]); |
| 1853 |
$section->add_option('checkbox', [ |
| 1854 |
'name' => 'email_log', |
| 1855 |
'label' => __('Enable Email Logging', 'wp-extra'), |
| 1856 |
'description' => sprintf( |
| 1857 |
__('Record all outgoing emails sent through WordPress. View your logs in the <a href="%s"><strong>Email Logs</strong></a> menu.', 'wp-extra'), |
| 1858 |
esc_url(admin_url('admin.php?page=wpex-email-logs')) |
| 1859 |
) |
| 1860 |
]); |
| 1861 |
$section->add_option('text', [ |
| 1862 |
'type' => 'number', |
| 1863 |
'name' => 'email_log_retention', |
| 1864 |
'show_if' => ['email_log' => true], |
| 1865 |
'css' => ['input_class' => 'small-text'], |
| 1866 |
'min' => 1, |
| 1867 |
'default' => 30, |
| 1868 |
'label' => __('Log Retention (Days)', 'wp-extra'), |
| 1869 |
'description' => __('Automatically delete logs older than this number of days (e.g. 30).', 'wp-extra') |
| 1870 |
]); |
| 1871 |
|
| 1872 |
$section = $tab->add_section(__('Email Notifications & Domain Filter', 'wp-extra')); |
| 1873 |
$section->add_option('checkbox-multiple', [ |
| 1874 |
'name' => 'no_emails', |
| 1875 |
'select' => true, |
| 1876 |
'options' => [ |
| 1877 |
'remove_admin' => __('Disable admin email address change confirmation', 'wp-extra'), |
| 1878 |
'auto_update' => __('Disable core auto-update notification emails', 'wp-extra'), |
| 1879 |
'new_user' => __('Disable new user registration notification emails to admin', 'wp-extra'), |
| 1880 |
'password_reset' => __('Disable password reset notification emails to admin', 'wp-extra') |
| 1881 |
], |
| 1882 |
'label' => __('Mute System Emails', 'wp-extra') |
| 1883 |
]); |
| 1884 |
$section->add_option('textarea', [ |
| 1885 |
'name' => 'email_domain', |
| 1886 |
'label' => __('Allowed Registration Email Domains', 'wp-extra'), |
| 1887 |
'description' => __('Only allow user registration from specified email domains (e.g. gmail.com, yahoo.com). One per line.', 'wp-extra') |
| 1888 |
]); |
| 1889 |
} |
| 1890 |
|
| 1891 |
// Transfer & Backup Tab (Tools) |
| 1892 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M17.3 10.1C17.3 7.60001 15.2 5.70001 12.5 5.70001C10.3 5.70001 8.4 7.10001 7.9 9.00001H7.7C5.7 9.00001 4 10.7 4 12.8C4 14.9 5.7 16.6 7.7 16.6H9.5V15.2H7.7C6.5 15.2 5.5 14.1 5.5 12.9C5.5 11.7 6.5 10.5 7.7 10.5H9L9.3 9.40001C9.7 8.10001 11 7.20001 12.5 7.20001C14.3 7.20001 15.8 8.50001 15.8 10.1V11.4L17.1 11.6C17.9 11.7 18.5 12.5 18.5 13.4C18.5 14.4 17.7 15.2 16.8 15.2H14.5V16.6H16.7C18.5 16.6 19.9 15.1 19.9 13.3C20 11.7 18.8 10.4 17.3 10.1Z M14.1245 14.2426L15.1852 13.182L12.0032 10L8.82007 13.1831L9.88072 14.2438L11.25 12.8745V18H12.75V12.8681L14.1245 14.2426Z"></path></svg>' . __('Tools')); |
| 1893 |
$section = $tab->add_section(__('Backup & Transfer Settings', 'wp-extra'), [ |
| 1894 |
'slug' => true, |
| 1895 |
]); |
| 1896 |
$section->add_option('restore', [ |
| 1897 |
'name' => 'restore', |
| 1898 |
'label' => __('Transfer Options (.json)', 'wp-extra') |
| 1899 |
]); |
| 1900 |
|
| 1901 |
// Donate Tab |
| 1902 |
$tab = $settings->add_tab('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>' . __('Donate', 'wp-extra'), 'donate'); |
| 1903 |
|
| 1904 |
$donate_html = ' |
| 1905 |
<div style="max-width: 860px; margin-top: 6px;"> |
| 1906 |
<p style="font-size: 14px; line-height: 1.7; color: #3c434a; margin-bottom: 22px;"> |
| 1907 |
' . sprintf( |
| 1908 |
esc_html__('WP EXtra is an open-source project dedicated to delivering lightweight, clean, and reliable WordPress optimizations for everyone. Over %s days of continuous development and maintenance, our mission has always been keeping your website fast, secure, and hassle-free.', 'wp-extra'), |
| 1909 |
'<strong>' . number_format_i18n($add_days) . '</strong>' |
| 1910 |
) . ' |
| 1911 |
</p> |
| 1912 |
|
| 1913 |
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin-bottom: 22px;"> |
| 1914 |
<div style="background: #fff; border: 1px solid #c3c4c7; border-radius: 6px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between;"> |
| 1915 |
<div> |
| 1916 |
<h3 style="margin-top: 0; margin-bottom: 10px; font-size: 15px; font-weight: 600; color: #1d2327; display: flex; align-items: center; gap: 8px;"> |
| 1917 |
<span>☕</span> ' . esc_html__('Buy Us a Coffee / Beer', 'wp-extra') . ' |
| 1918 |
</h3> |
| 1919 |
<p style="font-size: 13px; color: #646970; line-height: 1.6; margin-bottom: 18px;">' . esc_html__('Your financial support directly covers server costs, testing devices, and research into new optimization features to keep the plugin 100% free and actively maintained.', 'wp-extra') . '</p> |
| 1920 |
</div> |
| 1921 |
<div> |
| 1922 |
<a href="https://wpvnteam.com/donate/" target="_blank" class="button button-primary" style="display: inline-flex; align-items: center; gap: 6px; font-weight: 500;"> |
| 1923 |
' . esc_html__('Donate via WPVNTeam Portal →', 'wp-extra') . ' |
| 1924 |
</a> |
| 1925 |
</div> |
| 1926 |
</div> |
| 1927 |
|
| 1928 |
<div style="background: #fff; border: 1px solid #c3c4c7; border-radius: 6px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between;"> |
| 1929 |
<div> |
| 1930 |
<h3 style="margin-top: 0; margin-bottom: 10px; font-size: 15px; font-weight: 600; color: #1d2327; display: flex; align-items: center; gap: 8px;"> |
| 1931 |
<span>⭐</span> ' . esc_html__('Spread the Word', 'wp-extra') . ' |
| 1932 |
</h3> |
| 1933 |
<p style="font-size: 13px; color: #646970; line-height: 1.6; margin-bottom: 18px;">' . esc_html__('Take 1 minute to leave an honest 5-star rating on WordPress.org. It helps more webmasters discover WP EXtra and gives us tremendous motivation to keep improving.', 'wp-extra') . '</p> |
| 1934 |
</div> |
| 1935 |
<div> |
| 1936 |
<a href="https://wordpress.org/support/plugin/wp-extra/reviews/?filter=5#new-post" target="_blank" class="button button-secondary" style="display: inline-flex; align-items: center; gap: 6px; font-weight: 500;"> |
| 1937 |
' . esc_html__('Write a 5-Star Review � |
| 1938 |
� |
| 1939 |
� |
| 1940 |
� |
| 1941 |
� |
| 1942 |
', 'wp-extra') . ' |
| 1943 |
</a> |
| 1944 |
</div> |
| 1945 |
</div> |
| 1946 |
</div> |
| 1947 |
|
| 1948 |
<p style="font-size: 13px; color: #646970; line-height: 1.6; margin: 0;"> |
| 1949 |
' . esc_html__('Every single contribution — whether a donation, a positive review, or constructive feedback — is deeply appreciated and keeps WP EXtra moving forward. Thank you for your trust and partnership!', 'wp-extra') . ' |
| 1950 |
</p> |
| 1951 |
</div>'; |
| 1952 |
|
| 1953 |
$section = $tab->add_section(__('Support WP EXtra', 'wp-extra'), [ |
| 1954 |
'slug' => true, |
| 1955 |
'description' => $donate_html |
| 1956 |
]); |
| 1957 |
|
| 1958 |
$settings->enable_ajax_save(); |
| 1959 |
$settings->make(); |
| 1960 |
} |
| 1961 |
|
| 1962 |
public static function get_option($key, $fallback = null) |
| 1963 |
{ |
| 1964 |
return Helper::get_option($key, $fallback); |
| 1965 |
} |
| 1966 |
|
| 1967 |
public static function is_feature_active($key) |
| 1968 |
{ |
| 1969 |
return Helper::is_feature_active($key); |
| 1970 |
} |
| 1971 |
|
| 1972 |
public static function minifyCSS($css) |
| 1973 |
{ |
| 1974 |
return Helper::minifyCSS($css); |
| 1975 |
} |
| 1976 |
|
| 1977 |
public function enqueue_admin_assets($hook) |
| 1978 |
{ |
| 1979 |
$page = $_GET['page'] ?? ''; |
| 1980 |
if ($page !== 'wp-extra' && $page !== 'wpex-email-logs') { |
| 1981 |
return; |
| 1982 |
} |
| 1983 |
|
| 1984 |
wp_enqueue_style( |
| 1985 |
'wpex-settings', |
| 1986 |
WPEX_URL . 'assets/css/settings.css', |
| 1987 |
[], |
| 1988 |
WPEX_VERSION |
| 1989 |
); |
| 1990 |
|
| 1991 |
wp_enqueue_script( |
| 1992 |
'wpex-settings', |
| 1993 |
WPEX_URL . 'assets/js/settings.js', |
| 1994 |
['jquery'], |
| 1995 |
WPEX_VERSION, |
| 1996 |
true |
| 1997 |
); |
| 1998 |
|
| 1999 |
$today = current_time('Y-m-d'); |
| 2000 |
$accounts = (array) Helper::get_option('smtp_accounts', []); |
| 2001 |
$usage_data = []; |
| 2002 |
foreach ($accounts as $idx => $acc) { |
| 2003 |
$limit = intval($acc['daily_limit'] ?? 0); |
| 2004 |
$sent = intval(get_option('wpex_smtp_sent_' . $idx . '_' . $today, 0)); |
| 2005 |
$usage_data[$idx] = [ |
| 2006 |
'sent' => $sent, |
| 2007 |
'limit' => $limit, |
| 2008 |
'percent' => ($limit > 0) ? min(100, round(($sent / $limit) * 100)) : 0, |
| 2009 |
]; |
| 2010 |
} |
| 2011 |
|
| 2012 |
$config = [ |
| 2013 |
'nonces' => [ |
| 2014 |
'htaccess_protect' => wp_create_nonce('wpex_htaccess_protect_nonce'), |
| 2015 |
'transfer_backup' => wp_create_nonce('wpex_transfer_backup_nonce'), |
| 2016 |
'smtp_test' => wp_create_nonce('wpex_smtp_test_nonce'), |
| 2017 |
'reload_disk_file' => wp_create_nonce('wpex_reload_disk_file'), |
| 2018 |
'email_log' => wp_create_nonce('wpex_email_log_action'), |
| 2019 |
], |
| 2020 |
'smtp_providers' => [ |
| 2021 |
'gmail' => ['name' => 'Gmail SMTP', 'host' => 'smtp.gmail.com', 'port' => 587, 'encryption' => 'tls', 'hint' => '10,000 free emails/mo. Use your full Gmail address and a 16-character Google App Password.'], |
| 2022 |
'mailgun' => ['name' => 'Mailgun SMTP', 'host' => 'smtp.mailgun.org', 'port' => 587, 'encryption' => 'tls', 'hint' => '5,000 free emails/mo for 3 months. Username format: postmaster@yourdomain.com.'], |
| 2023 |
'outlook' => ['name' => 'Outlook / Hotmail / Office 365', 'host' => 'smtp.office365.com', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Use your Microsoft/Outlook email address and Microsoft App Password.'], |
| 2024 |
'yahoo' => ['name' => 'Yahoo Mail', 'host' => 'smtp.mail.yahoo.com', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Requires a dedicated Yahoo App Password from Account Security.'], |
| 2025 |
'aws_ses' => ['name' => 'Amazon SES (AWS SES)', 'host' => 'email-smtp.us-east-1.amazonaws.com', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Enter your AWS SES SMTP Username (AKIA...) and SMTP Password.'], |
| 2026 |
'zoho' => ['name' => 'Zoho Mail', 'host' => 'smtp.zoho.com', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Use your Zoho email address and Zoho generated App Password.'], |
| 2027 |
'sendgrid' => ['name' => 'SendGrid', 'host' => 'smtp.sendgrid.net', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Username is strictly "apikey" and Password is your SendGrid API Key.'], |
| 2028 |
'sendinblue' => ['name' => 'Sendinblue (Brevo)', 'host' => 'smtp-relay.brevo.com', 'port' => 587, 'encryption' => 'tls', 'hint' => 'Use your Brevo login email and the SMTP master key from your Brevo dashboard.'], |
| 2029 |
'other' => ['name' => 'Other Custom SMTP Server', 'host' => '', 'port' => 587, 'encryption' => 'tls', 'hint' => ''], |
| 2030 |
], |
| 2031 |
'smtp_usage' => $usage_data, |
| 2032 |
'i18n' => [ |
| 2033 |
'processing' => __('Processing...', 'wp-extra'), |
| 2034 |
'protected' => __('Protected', 'wp-extra'), |
| 2035 |
'not_protected' => __('Not Protected', 'wp-extra'), |
| 2036 |
'remove_protection' => __('Remove Protection', 'wp-extra'), |
| 2037 |
'create_protection' => __('Create Protection File', 'wp-extra'), |
| 2038 |
'confirm_remove_htaccess' => __('Are you sure you want to remove the .htaccess protection file?', 'wp-extra'), |
| 2039 |
'error_occurred' => __('An error occurred.', 'wp-extra'), |
| 2040 |
'request_failed' => __('Request failed.', 'wp-extra'), |
| 2041 |
'enter_recipient_email' => __('Please enter a recipient email address.', 'wp-extra'), |
| 2042 |
'connecting_sending' => __('Connecting & Sending...', 'wp-extra'), |
| 2043 |
'send_test_email' => __('Send Test Email', 'wp-extra'), |
| 2044 |
'delivery_successful' => __('Delivery Successful!', 'wp-extra'), |
| 2045 |
'delivery_failed' => __('Delivery Failed', 'wp-extra'), |
| 2046 |
'server_error' => __('Server Error', 'wp-extra'), |
| 2047 |
'loading_details' => __('Loading details...', 'wp-extra'), |
| 2048 |
'to' => __('To:', 'wp-extra'), |
| 2049 |
'subject' => __('Subject:', 'wp-extra'), |
| 2050 |
'date_time' => __('Date / Time:', 'wp-extra'), |
| 2051 |
'mailer_account' => __('Mailer Account:', 'wp-extra'), |
| 2052 |
'error_details' => __('Error Details:', 'wp-extra'), |
| 2053 |
'delivered_successfully' => __('Delivered Successfully', 'wp-extra'), |
| 2054 |
'confirm_resend_email' => __('Are you sure you want to resend this email?', 'wp-extra'), |
| 2055 |
'email_resent_successfully' => __('Email resent successfully!', 'wp-extra'), |
| 2056 |
'failed_resend_email' => __('Failed to resend email.', 'wp-extra'), |
| 2057 |
'confirm_delete_log' => __('Delete this email log record?', 'wp-extra'), |
| 2058 |
'confirm_clear_all_logs' => __('Are you sure you want to delete ALL email log records? This cannot be undone.', 'wp-extra'), |
| 2059 |
], |
| 2060 |
]; |
| 2061 |
|
| 2062 |
wp_localize_script('wpex-settings', 'wpex_settings', $config); |
| 2063 |
} |
| 2064 |
} |
| 2065 |
|