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.1.6 1.6.86 0.1.7 1.6.87 0.1.8 1.6.88 0.1.9 1.6.89 0.2.0 1.6.90
ai-engine / classes / modules / advisor.php
ai-engine / classes / modules Last commit date
advisor.php 2 years ago chatbot.php 1 year ago discussions.php 1 year ago files.php 1 year ago gdpr.php 1 year ago security.php 1 year ago tasks.php 2 years ago wand.php 1 year ago
advisor.php
186 lines
1 <?php
2
3 class Meow_MWAI_Modules_Advisor {
4 private $core = null;
5 private $update_interval = 24 * 60 * 60;
6 private $prompt = "Based on all the plugins I have installed and my WordPress information, can you give me general advice and recommendations about my WordPress setup? Aim for a concise list of 6-8 recommendations total. Consider factors such as whether certain types of plugins are still needed, if some might be deprecated, their overall impact on performance, if there are redundancies or conflicts between plugins, and if some functionality is no longer required with recent versions of WordPress. Provide the recommendations in a JSON format with 'level', 'severity', 'title', and 'description' fields:
7
8 'level' can be 'success', 'warning', or 'danger'. Use 'success' to highlight areas that are working well and should be maintained to keep things running optimally. This motivates the user to continue good practices. Use 'warning' for issues that are not critical but could be improved. Use 'danger' for critical issues that should be addressed immediately.
9 'severity' should be an integer from 0 to 100, with 0 being the least severe and 100 being the most severe.
10 'title' should be a concise description of the recommendation.
11 'description' should provide more details about the recommendation.
12 Here is a simple JSON example of the format to use, without any actual data:
13 [
14 {
15 \"level\": \"success\",
16 \"severity\": 0,
17 \"title\": \"Example Success\",
18 \"description\": \"This is an example of a successful recommendation.\"
19 },
20 {
21
22 \"level\": \"warning\",
23 \"severity\": 50,
24 \"title\": \"Example Warning\",
25 \"description\": \"This is an example of a non-critical recommendation.\"
26 },
27 {
28 \"level\": \"danger\",
29 \"severity\": 100,
30 \"title\": \"Example Danger\",
31 \"description\": \"This is an example of a critical recommendation.\"
32 }
33 ]
34
35 Instead of focusing on individual plugins, provide more general and holistic recommendations based on the overall WordPress system and the installed plugins as a whole. Feel free to use titles like \"Useless Plugins\" or \"Performance Considerations\" to group related recommendations. Avoid repeating the same or very similar recommendations. Only output the JSON - do not include any other text or formatting like markdown. If you don't have any recommendations, output an empty array [].
36
37 Here are the plugins I have installed, along with my WordPress information:";
38
39 public function __construct( $core ) {
40 $this->core = $core;
41 add_action( 'init', array( $this, 'init' ) );
42 add_action( 'wp_dashboard_setup', array( $this, 'add_dashboard_widget' ) );
43 }
44
45 public function init() {
46 if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_POST['refresh_advisor_nonce'] ) ) {
47 if ( wp_verify_nonce( $_POST['refresh_advisor_nonce'], 'refresh_advisor_action' ) ) {
48 $this->run_advisor();
49 wp_safe_redirect( remove_query_arg( 'refresh_advisor' ) );
50 exit;
51 }
52 }
53 else if ( $this->core->get_option( 'module_advisor', false ) ) {
54 add_action( 'mwai_tasks_run', array( $this, 'check_and_run_advisor' ) );
55 }
56 }
57
58 private function check_and_run_advisor() {
59 $last_run_data = get_option( 'mwai_advisor_data', [] );
60 $last_run_time = $last_run_data['date'] ?? 0;
61 $current_time = time();
62 if ( $current_time - $last_run_time > $this->update_interval ) {
63 $this->run_advisor();
64 }
65 }
66
67 public function run_advisor() {
68 try {
69 global $mwai;
70 $mwai->checkStatus();
71 $plugins = $this->get_all_installed_plugins();
72
73 $finalPrompt = $this->prompt;
74 foreach ( $plugins as $plugin ) {
75 $finalPrompt .= "Plugin: " . $plugin['title'] . "\n";
76 $finalPrompt .= "- Version: " . $plugin['version'] . "\n";
77 $finalPrompt .= "- Description: " . $plugin['description'] . "\n";
78 $finalPrompt .= "- Enabled: " . ( $plugin['enabled'] ? 'Yes' : 'No' ) . "\n";
79 }
80 $finalPrompt .= "\n";
81
82 $finalPrompt .= "WordPress Information:\n";
83 $finalPrompt .= "- Number of Plugins: " . count( $plugins ) . "\n";
84 $finalPrompt .= "- Site URL: " . get_site_url() . "\n";
85 $finalPrompt .= "- PHP Version: " . phpversion() . "\n";
86 $finalPrompt .= "- WordPress Version: " . get_bloginfo( 'version' ) . "\n";
87 $finalPrompt .= "- Theme: " . wp_get_theme()->get( 'Name' ) . "\n";
88 $finalPrompt .= "\n";
89
90 $finalPrompt .= "General Information:\n";
91 $finalPrompt .= "- Today's Date: " . date( 'Y-m-d' ) . "\n";
92 $finalPrompt .= "\n";
93
94 $errors = MeowCommon_Helpers::php_error_logs();
95 $errors = array_slice( $errors, -10 );
96 if ( !empty( $errors ) ) {
97 $finalPrompt .= "PHP Errors: \n";
98 foreach ( $errors as $error ) {
99 $finalPrompt .= $error['date'] . ' - ' . $error['type'] . ' - ' . $error['content'] . "\n";
100 }
101 }
102
103 $answer = $mwai->simpleTextQuery( $finalPrompt, [ "scope" => 'advisor' ] );
104 $recommendations = json_decode( $answer, true );
105 update_option( 'mwai_advisor_data', [
106 'date' => time(),
107 'data' => $recommendations
108 ], false );
109
110 }
111 catch ( Exception $e ) {
112 error_log( 'AI Engine: ' . $e->getMessage() );
113 }
114 }
115
116 function get_all_installed_plugins() {
117 if ( ! function_exists( 'get_plugins' ) ) {
118 require_once ABSPATH . 'wp-admin/includes/plugin.php';
119 }
120 $all_plugins = get_plugins();
121 $active_plugins = get_option( 'active_plugins', array() );
122 $plugins_info = array();
123 foreach ( $all_plugins as $plugin_path => $plugin_data ) {
124 $plugin_info = array(
125 'title' => $plugin_data['Name'],
126 'version' => $plugin_data['Version'],
127 'description' => $plugin_data['Description'],
128 'enabled' => in_array($plugin_path, $active_plugins) ? true : false
129 );
130 $plugins_info[] = $plugin_info;
131 }
132 return $plugins_info;
133 }
134
135 function add_dashboard_widget() {
136 wp_add_dashboard_widget(
137 'mwai_advisor_widget',
138 'AI Engine Advisor',
139 array( $this, 'advisor_metabox' )
140 );
141 }
142
143 function advisor_metabox() {
144 $data = get_option( 'mwai_advisor_data', [] );
145 $recommendations = $data['data'] ?? [];
146 if ( empty( $recommendations ) ) {
147 echo '<p>No recommendations yet.</p>';
148 }
149 else {
150 echo '<p>Everyday, AI Engine will analyze your WordPress setup and provide you with recommendations to improve it.</p>';
151 echo '<ul>';
152 foreach ( $recommendations as $recommendation ) {
153 $title = isset( $recommendation['title'] ) ? $recommendation['title'] : 'Miscellaneous';
154 $description = isset( $recommendation['description'] ) ? $recommendation['description'] : 'No information available.';
155 echo '<li style="display: inline;">';
156 echo '<div style="display: flex; margin-bottom: 10px;">';
157 echo $this->generate_badge( $recommendation['level'] );
158 echo '<div>';
159 echo '<strong>' . $title . '</strong> - ' . $description;
160 echo '</div>';
161 echo '</div>';
162 echo '</li>';
163 }
164 echo '</ul>';
165 }
166 echo '<form method="POST">';
167 wp_nonce_field( 'refresh_advisor_action', 'refresh_advisor_nonce' );
168 echo '<div style="display: flex; justify-content: end;">';
169 echo '<input type="submit" class="button" value="Refresh Recommendations">';
170 echo '</div>';
171 echo '</form>';
172 }
173
174 function generate_badge( $level ) {
175 $color = ($level === 'success') ? '#00ba37' : (($level === 'warning') ? '#dba617' : '#e65054');
176 return '<div style="display: flex; align-items: center; margin-bottom: 5px;">
177 <div style="width: 20px; height: 20px; margin-right: 10px;">
178 <svg aria-hidden="true" focusable="false" width="100%" height="100%" viewBox="0 0 200 200" version="1.1" xmlns="http://www.w3.org/2000/svg">
179 <circle r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0" style="stroke: #e2e2e2;"></circle>
180 <circle id="bar" r="90" cx="100" cy="100" fill="transparent" stroke-dasharray="565.48" stroke-dashoffset="0" style="stroke-width: 15px; stroke: ' . $color . ';"></circle>
181 </svg>
182 </div>
183 </div>';
184 }
185 }
186