PluginProbe
GetGenie – AI SEO Assistant & Content Writer with Keyword Research, AEO & GEO / 4.5.0
GetGenie – AI SEO Assistant & Content Writer with Keyword Research, AEO & GEO v4.5.0
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.2.0 All 106 releases
getgenie / getgenie.php

getgenie.php in GetGenie – AI SEO Assistant & Content Writer with Keyword Research, AEO & GEO 4.5.0, at getgenie.php

390 lines 11.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Plugin Name: GetGenie AI
5 * Description: GetGenie AI is the most intuitive A.I Content Wordpress Plugin that can help you save time and write smarter.
6 * Plugin URI: https://getgenie.ai/
7 * Author: getgenieai
8 * Version: 4.5.0
9 * Author URI: https://getgenie.ai/
10 *
11 * Text Domain: getgenie
12 * Domain Path: /languages
13 *
14 * @package GetGenie AI
15 * @category Pro
16 *
17 * License: GPL3 or later
18 * License URI: https://www.gnu.org/licenses/gpl-3.0.html
19 */
20
21 defined('ABSPATH') || exit;
22
23 define('GETGENIE_VERSION', '4.5.0');
24 define('GETGENIE_TEXTDOMAIN', 'getgenie');
25 define('GETGENIE_BASENAME', plugin_basename(__FILE__));
26 define('GETGENIE_URL', trailingslashit(plugin_dir_url(__FILE__)));
27 define('GETGENIE_DIR', trailingslashit(plugin_dir_path(__FILE__)));
28
29
30 define('GETGENIE_NLP_REMOTE_ADDR', 'https://bridge.getgenie.ai/');
31 define('GETGENIE_ACCOUNT_REMOTE_ADDR', 'https://getgenie.ai/account/');
32 define('GETGENIE_ACCOUNT_REMOTE_ADDR_FALLBACK', 'https://app.getgenie.ai/');
33
34
35 define('GETGENIE_BLOGWIZARD_PREFIX', 'getgenie_blogwizard_');
36 define('GETGENIE_HISTORY_PREFIX', 'getgenie_history_');
37
38 function getgenie_on_activation($plugin)
39 {
40
41 if ($plugin !== 'getgenie/getgenie.php') {
42 return;
43 }
44
45 $action = isset($_REQUEST['action']) ? sanitize_text_field($_REQUEST['action']) : '';
46 if ($action === 'activate-selected') {
47 return;
48 }
49
50 wp_safe_redirect(admin_url('admin.php?page=getgenie') . "#getting-started");
51 die();
52 }
53 add_action('activated_plugin', 'getgenie_on_activation');
54
55 add_filter('fluent_crm_asset_listed_slugs', function ($slugs) {
56 $slugs[] = '\/getgenie\/';
57 return $slugs;
58 });
59
60 function getgenie_blogwizard_store_objects()
61 {
62 return [
63 'keyword',
64 'seoEnabled',
65 'seoCountry',
66 'creativity',
67 'numberOfResult',
68
69 'generatedTitles',
70 'generatedIntros',
71 'generatedOutlines',
72 'generatedParagraphs',
73
74 'selectedTitle',
75 'selectedIntro',
76 'selectedOutlines',
77 'plagiarismStat',
78
79 'serpData',
80 'customKeywords',
81 'keywordData',
82 ];
83 }
84
85 function getgenie_templates()
86 {
87 $data = null;
88 $cache_key = 'getgenie_writing_templates_languages';
89 $cached = get_option($cache_key, ['time' => 0]);
90 if (!empty($cached['data']) && !empty($cached['time']) && $cached['time'] + (0 * 60 * 60) >= time()) {
91 return $cached['data'];
92 }
93
94 $remote_url = GETGENIE_NLP_REMOTE_ADDR . 'writer-default/get-template-infos';
95 $response = wp_remote_request(
96 $remote_url,
97 array(
98 'method' => 'POST',
99 'timeout' => 30,
100 'redirection' => 3,
101 'httpversion' => '1.0',
102 'sslverify' => true,
103 'blocking' => true,
104 'headers' => array(
105 'Content-Type' => 'application/json',
106 ),
107 )
108 );
109
110 if (200 === wp_remote_retrieve_response_code($response)) {
111 $response_body = wp_remote_retrieve_body($response);
112 $response_body_decoded = json_decode($response_body);
113
114 if ((is_array($response_body_decoded) || is_object($response_body_decoded)) && !empty($response_body_decoded)) {
115 $data = $response_body;
116 }
117 unset($response_body_decoded);
118 unset($response_body);
119 }
120
121 if ($data === null) {
122 if (!empty($cached['data'])) {
123 $cached_data_decoded = json_decode($cached['data']);
124 }
125
126 if ((is_array($cached_data_decoded) || is_object($cached_data_decoded)) && !empty($cached_data_decoded)) {
127 $data = $cached['data'];
128 unset($cached_data_decoded);
129 } else {
130 $data = file_get_contents(GETGENIE_DIR . 'config/templates.json');
131 }
132 }
133
134 update_option($cache_key, [
135 'data' => $data,
136 'time' => time()
137 ]);
138
139 return $data;
140 }
141
142 add_action('elementor/editor/after_enqueue_scripts', 'genei_editor_script');
143 add_action('elementor/editor/after_enqueue_scripts', 'genie_header_script_data');
144 add_action('admin_head', 'genie_header_script_data');
145 add_action('wp', 'genie_register_frontend_builder_scripts');
146
147 /**
148 * Register scripts for frontend builders like Bricks Builder and Oxygen Builder
149 *
150 * @return void
151 */
152 function genie_register_frontend_builder_scripts()
153 {
154 if (!is_user_logged_in() || !current_user_can('edit_posts')) {
155 return;
156 }
157
158 if (isset($_GET['bricks'])) {
159 add_action('wp_enqueue_scripts', 'genie_header_script_data');
160 }
161
162 if (isset($_GET['ct_builder'])) {
163 add_action('wp_enqueue_scripts', 'genie_header_script_data');
164 }
165 }
166
167 function genei_editor_script()
168 {
169 wp_enqueue_script('editor-panel-script', GETGENIE_URL . 'assets/dist/admin/js/elementor.js', [], GETGENIE_VERSION, true);
170 }
171
172 function genie_header_script_data()
173 {
174
175 if (!is_user_logged_in() || !current_user_can('publish_posts')) {
176 return;
177 }
178
179 $wizard_screen = null;
180 $is_block_editor = null;
181
182 if (isset($_GET['bricks'])) {
183 $wizard_screen = 'bricks';
184 }
185
186 if (isset($_GET['ct_builder'])) {
187 $wizard_screen = 'ct_builder';
188 }
189
190 if (isset($_GET['page']) && $_GET['page'] == 'fluentcrm-admin') {
191 $wizard_screen = 'fluentcrm';
192 }
193
194 if (function_exists('get_current_screen')) {
195 $current_screen = get_current_screen();
196 $elementor_action = isset($_GET['action']) && $_GET['action'] == 'elementor';
197 $bricks_action = isset($_GET['bricks']);
198 $oxygent_action = isset($_GET['ct_builder']);
199 $is_block_editor = (!empty($current_screen)) ? $current_screen->is_block_editor() : false;
200
201
202 if ($elementor_action) {
203 $wizard_screen = 'elementor';
204 }
205
206 if (
207 (!empty($current_screen)) &&
208 $current_screen->id == 'post'
209 && $current_screen->base == 'post'
210 && $current_screen->post_type == 'post'
211 && !$elementor_action
212 && !$bricks_action
213 && !$oxygent_action
214 ) {
215 $wizard_screen = 'post';
216 }
217
218 if (
219 (!empty($current_screen)) &&
220 $current_screen->id == 'product'
221 && $current_screen->base == 'post'
222 && $current_screen->post_type == 'product'
223 ) {
224 $wizard_screen = 'woo_product';
225 }
226 }
227
228
229 $blog_wizard_data = [
230 'post_id' => get_the_ID(),
231 ];
232
233 $blogwizard_objects = getgenie_blogwizard_store_objects();
234 foreach ($blogwizard_objects as $object) {
235 $blog_wizard_data[$object] = json_decode(
236 get_post_meta(
237 get_the_ID(),
238 GETGENIE_BLOGWIZARD_PREFIX . $object,
239 true
240 )
241 );
242 }
243
244 $token = new \GenieAi\App\Auth\TokenManager();
245 $_nonce = wp_create_nonce('wp_rest');
246
247 $config = [
248 'version' => GETGENIE_VERSION,
249 'avatarUrl' => get_avatar_url(get_current_user_id(), ['size' => 70]),
250 'restNonce' => $_nonce,
251 'siteUrl' => get_site_url(),
252 'assetsUrl' => GETGENIE_URL . 'assets/',
253 'baseApi' => get_rest_url(null, 'getgenie/v1/'),
254 'webviewBaseApi' => get_rest_url(null, 'v1/webview/'),
255 'genieChatApi' => get_rest_url(null, 'getgenie/v1/geniechat/'),
256 'parserApi' => GETGENIE_NLP_REMOTE_ADDR,
257 'parserApiWp' => get_rest_url(null, 'getgenie/v1/parser/'),
258 'usageLimitStatsApi' => get_rest_url(null, 'getgenie/v1/limit_usage_stats/'),
259 'storeApi' => get_rest_url(null, 'getgenie/v1/store/'),
260 'licenseApi' => get_rest_url(null, 'getgenie/v1/license/'),
261 'licenseKeyLength' => 46,
262 'feedbackApi' => get_rest_url(null, 'getgenie/v1/feedback/'),
263 'historyApi' => get_rest_url(null, 'getgenie/v1/history/'),
264 'siteToken' => get_option('getgenie_site_token', ''),
265 'authToken' => $token->generate(), // access_denied or 4gb3rv3dyvy3h59gvwscdt3rerf23
266 'authTokenLeaserApi' => admin_url('admin-ajax.php?action=lease_auth_token'), // wp-ajax
267 'isBlockEditor' => $is_block_editor,
268 'wizardScreen' => $wizard_screen,
269 'wcActivated' => is_plugin_active('woocommerce/woocommerce.php'),
270 'wizardScreenUrl' => [
271 'post' => admin_url('post-new.php#getgenie-open-blogwizard'),
272 'woo_product' => admin_url('post-new.php?post_type=product#getgenie-open-wooWizard'),
273 ],
274 'subscriptionUpgradeUrlApi' => get_rest_url(null, 'getgenie/v1/subscription_upgrade_urls/'),
275 ];
276
277 ?>
278 <script>
279 window.getGenie = window.getGenie ?? {};
280 window.getGenie.config = <?php echo json_encode($config); ?>;
281 window.getGenie.blogWizardData = <?php echo json_encode($blog_wizard_data); ?>;
282 window.getGenie.Components = window.getGenie.Components ?? {};
283 </script>
284 <?php
285 }
286
287
288 function getgenie_remote_request($remote_url_partial, $body, $header = [])
289 {
290 $remote_url = GETGENIE_ACCOUNT_REMOTE_ADDR . $remote_url_partial;
291 $response = getgenie_remote_request_try($remote_url, $body, $header);
292
293 if ($response === null) {
294 $remote_url = GETGENIE_ACCOUNT_REMOTE_ADDR_FALLBACK . $remote_url_partial;
295 $response = getgenie_remote_request_try($remote_url, $body, $header);
296 }
297
298 return $response;
299 }
300
301 function getgenie_remote_request_try($remote_url, $body, $header = [])
302 {
303 $response = wp_remote_post(
304 $remote_url,
305 array(
306 'method' => 'POST',
307 'timeout' => 300,
308 'redirection' => 3,
309 'httpversion' => '1.0',
310 'sslverify' => true,
311 'blocking' => true,
312 'body' => $body,
313 'headers' => array_merge(
314 $header,
315 array(
316 'Content-Type' => 'application/json',
317 )
318 ),
319 )
320 );
321
322 if (200 === wp_remote_retrieve_response_code($response)) {
323 $response_body = wp_remote_retrieve_body($response);
324 $data = json_decode($response_body);
325
326 return $data;
327 }
328
329 return null;
330 }
331
332 add_action('init', 'plugins_loaded');
333
334 function plugins_loaded()
335 {
336 load_plugin_textdomain('getgenie', false, dirname(plugin_basename(__FILE__)) . '/languages/');
337
338 //show seo feature notification for version after 4.1.0
339 if( is_admin() && current_user_can('manage_options') ){
340
341 $seo_feature_date = new DateTime( '2025-05-18' );
342 $install_date_str = get_option( 'getgenie_install_date' );
343 $genie_install_date = false;
344
345 if ($install_date_str) {
346 try {
347 $genie_install_date = new DateTime( $install_date_str );
348 } catch ( Exception $e ) {
349 $genie_install_date = false;
350 }
351 }
352
353 $user_id = get_current_user_id();
354
355 if(
356 $genie_install_date &&
357 $genie_install_date < $seo_feature_date &&
358 get_option( $user_id.'_getgenie_showed_notification', '') === ''
359 ){
360 wp_safe_redirect(admin_url('admin.php?page=getgenie&open_modal=1') . "#genie-ska");
361 }
362 }
363 }
364
365 include GETGENIE_DIR . 'vendor/autoload.php';
366
367
368 new \GenieAi\App\ProLabel\ProLabelInit();
369
370 new \GenieAi\App\Providers\EnqueueProvider();
371 new \GenieAi\App\Providers\SideMenuProvider();
372 new \GenieAi\App\Providers\SettingLinkProvider();
373
374 new \GenieAi\App\Api\Feedback();
375 new \GenieAi\App\Api\Parser();
376
377 new \GenieAi\App\Api\License();
378 new \GenieAi\App\Api\UsageLimitStats();
379 new \GenieAi\App\Api\LeaseToken();
380 new \GenieAi\App\Api\RoleManagement();
381 new \GenieAi\App\Api\AdminConfig();
382
383 new \GenieAi\App\Services\History\Cpt();
384 new \GenieAi\App\Services\GetGenieChat\Cpt();
385
386 new \GenieAi\App\Api\Store();
387 new \GenieAi\App\Api\History();
388 new \GenieAi\App\Api\GetGenieChat();
389 new \GenieAi\App\Api\UploadImage();
390 new \GenieAi\App\Api\SubscriptionUpgradeUrl();