Admin.php
1 month ago
AdminEnqueue.php
1 month ago
AdminHelp.php
1 month ago
AdminMenu.php
1 month ago
PluginActionLinks.php
3 months ago
SupportExport.php
2 months ago
SupportExport.php
123 lines
| 1 | <?php |
| 2 | |
| 3 | namespace OnlineOptimisation\EmailEncoderBundle\Admin; |
| 4 | |
| 5 | if ( ! defined( 'ABSPATH' ) ) exit; |
| 6 | |
| 7 | use OnlineOptimisation\EmailEncoderBundle\Traits\PluginHelper; |
| 8 | |
| 9 | class SupportExport |
| 10 | { |
| 11 | use PluginHelper; |
| 12 | |
| 13 | |
| 14 | public function generate(): string |
| 15 | { |
| 16 | $saved = $this->plugin()->settings->get_saved(); |
| 17 | $theme = wp_get_theme(); |
| 18 | |
| 19 | $lines = []; |
| 20 | |
| 21 | // Header |
| 22 | $lines[] = '=== Email Encoder Support Info ==='; |
| 23 | $lines[] = 'Plugin Version: ' . EEB_VERSION; |
| 24 | $lines[] = 'PHP Version: ' . phpversion(); |
| 25 | $lines[] = 'WordPress Version: ' . get_bloginfo( 'version' ); |
| 26 | $lines[] = 'Theme: ' . $theme->get( 'Name' ) . ' (' . $theme->get( 'Version' ) . ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ? ', block theme' : ', classic theme' ) . ')'; |
| 27 | $lines[] = 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ); |
| 28 | $lines[] = 'GD Library: ' . ( extension_loaded( 'gd' ) ? 'Yes' : 'No' ); |
| 29 | $lines[] = 'Memory Limit: ' . ( ini_get( 'memory_limit' ) ?: 'Unknown' ); |
| 30 | |
| 31 | // Settings |
| 32 | $lines[] = ''; |
| 33 | $lines[] = '=== Settings ==='; |
| 34 | $lines[] = 'Protection: ' . $this->format_protection_mode( $saved['protect'] ?? '' ); |
| 35 | $lines[] = 'Method: ' . $this->format_method( $saved['protect_using'] ?? '' ); |
| 36 | $lines[] = 'RSS Protection: ' . $this->on_off( $saved['filter_rss'] ?? '' ); |
| 37 | $lines[] = 'AJAX Protection: ' . $this->on_off( $saved['ajax_requests'] ?? '' ); |
| 38 | $lines[] = 'Admin Protection: ' . $this->on_off( $saved['admin_requests'] ?? '' ); |
| 39 | $lines[] = 'Convert to mailto: ' . $this->on_off( $saved['encode_mailtos'] ?? '' ); |
| 40 | $lines[] = 'Convert to images: ' . $this->on_off( $saved['convert_plain_to_image'] ?? '' ); |
| 41 | $lines[] = 'Input field protection: ' . $this->on_off( $saved['input_strong_protection'] ?? '' ); |
| 42 | $lines[] = 'Protection Text: ' . ( $saved['protection_text'] ?? '*protected email*' ); |
| 43 | $lines[] = 'Custom Classes: ' . ( ! empty( $saved['class_name'] ) ? $saved['class_name'] : '(none)' ); |
| 44 | $lines[] = 'Custom Href Attrs: ' . ( ! empty( $saved['custom_href_attr'] ) ? $saved['custom_href_attr'] : '(none)' ); |
| 45 | $lines[] = 'Skip Posts: ' . ( ! empty( $saved['skip_posts'] ) ? $saved['skip_posts'] : '(none)' ); |
| 46 | $lines[] = 'Skip Query Params: ' . ( ! empty( $saved['skip_query_parameters'] ) ? $saved['skip_query_parameters'] : '(none)' ); |
| 47 | $lines[] = 'Footer Scripts: ' . $this->on_off( $saved['footer_scripts'] ?? '' ); |
| 48 | $lines[] = 'Security Check: ' . $this->on_off( $saved['show_encoded_check'] ?? '' ); |
| 49 | |
| 50 | // Active plugins |
| 51 | if ( ! function_exists( 'get_plugins' ) ) { |
| 52 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 53 | } |
| 54 | |
| 55 | $plugins = get_plugins(); |
| 56 | $active = (array) get_option( 'active_plugins', [] ); |
| 57 | $active_plugins = []; |
| 58 | |
| 59 | foreach ( $active as $plugin_path ) { |
| 60 | if ( isset( $plugins[ $plugin_path ] ) ) { |
| 61 | $active_plugins[] = $plugins[ $plugin_path ]['Name'] . ' (' . $plugins[ $plugin_path ]['Version'] . ')'; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | if ( is_multisite() ) { |
| 66 | $network_plugins = get_site_option( 'active_sitewide_plugins', [] ); |
| 67 | foreach ( array_keys( (array) $network_plugins ) as $plugin_path ) { |
| 68 | if ( isset( $plugins[ $plugin_path ] ) ) { |
| 69 | $active_plugins[] = $plugins[ $plugin_path ]['Name'] . ' (' . $plugins[ $plugin_path ]['Version'] . ') [network]'; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | $lines[] = ''; |
| 75 | $lines[] = '=== Active Plugins (' . count( $active_plugins ) . ') ==='; |
| 76 | foreach ( $active_plugins as $plugin_name ) { |
| 77 | $lines[] = $plugin_name; |
| 78 | } |
| 79 | |
| 80 | return implode( "\n", $lines ); |
| 81 | } |
| 82 | |
| 83 | |
| 84 | /** |
| 85 | * @param mixed $value |
| 86 | */ |
| 87 | private function format_protection_mode( $value ): string |
| 88 | { |
| 89 | $modes = [ |
| 90 | '1' => 'Full-page scan', |
| 91 | '2' => 'WordPress filters', |
| 92 | '3' => 'Disabled', |
| 93 | ]; |
| 94 | |
| 95 | return $modes[ (string) $value ] ?? 'Unknown (' . $value . ')'; |
| 96 | } |
| 97 | |
| 98 | |
| 99 | /** |
| 100 | * @param mixed $value |
| 101 | */ |
| 102 | private function format_method( $value ): string |
| 103 | { |
| 104 | $methods = [ |
| 105 | 'with_javascript' => 'With JavaScript (auto best)', |
| 106 | 'without_javascript' => 'Without JavaScript (CSS)', |
| 107 | 'strong_method' => 'Strong method', |
| 108 | 'char_encode' => 'Character encoding', |
| 109 | ]; |
| 110 | |
| 111 | return $methods[ (string) $value ] ?? 'Unknown (' . $value . ')'; |
| 112 | } |
| 113 | |
| 114 | |
| 115 | /** |
| 116 | * @param mixed $value |
| 117 | */ |
| 118 | private function on_off( $value ): string |
| 119 | { |
| 120 | return ( $value === 1 || $value === '1' ) ? 'On' : 'Off'; |
| 121 | } |
| 122 | } |
| 123 |