PluginProbe ʕ •ᴥ•ʔ
AutoWP – AI Content Writer & Rewriter / 2.3.0
AutoWP – AI Content Writer & Rewriter v2.3.0
2.3.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9
autowp-ai-content-writer-rewriter / autowp.php
autowp-ai-content-writer-rewriter Last commit date
assets 1 month ago includes 1 month ago languages 1 month ago LICENSE.txt 1 month ago autowp.php 1 month ago index.php 1 month ago readme.txt 1 month ago
autowp.php
7334 lines
1 <?php
2
3
4
5 /**
6 * Plugin Name: AutoWP - AI Content Writer & Rewriter
7 * Plugin URI: https://autowp.app
8 * Description: AI Content Writer & Rewriter. Write content with AI from zero. Import content from RSS, Wordpress and rewrite with AI. Generate SEO optimized content,tags,title and generate image. ChatGPT, Content Writer, Auto Content Writer, Image Generator, AutoGPT, ChatPDF, SEO optimizer, AI Training.
9 * Version: 2.3.0
10 * Requires at least: 5.2
11 * Requires PHP: 7.2
12 * Author: basarventures
13 * Author URI: https://autowp.app
14 * License: GPL v2 or later
15 * License URI: https://www.gnu.org/licenses/gpl-2.0.html
16 * Text Domain: autowp
17 * Domain Path: /languages
18 */
19
20
21
22 defined( 'ABSPATH' ) or die( 'PERMISSION ERROR!' );
23
24 require plugin_dir_path( __FILE__ ) . 'includes/new-wp-website-form.php';
25 require plugin_dir_path( __FILE__ ) . 'includes/new-rss-website-form.php';
26 require plugin_dir_path( __FILE__ ) . 'includes/new-ai-website-form.php';
27 require plugin_dir_path( __FILE__ ) . 'includes/new-news-website-form.php';
28 require plugin_dir_path( __FILE__ ) . 'includes/new-own-ai-agent-form.php';
29
30
31
32
33
34 // Enqueque JS Files
35 function autowp_enqueue_scripts() {
36 $autowp_my_plugin_dir_url = plugin_dir_url(__FILE__);
37 $autowp_my_plugin_dir_path = plugin_dir_path(__FILE__);
38
39 $bootstrap_js_path = $autowp_my_plugin_dir_path . 'assets/js/bootstrap.min.js';
40 $bootstrap_js_url = $autowp_my_plugin_dir_url . 'assets/js/bootstrap.min.js';
41 $bootstrap_js_ver = file_exists($bootstrap_js_path) ? filemtime($bootstrap_js_path) : false;
42
43 //Enqueque AutoWP JS File
44 wp_register_script('bootstrapjs', $bootstrap_js_url, array('jquery'), $bootstrap_js_ver, true);
45
46 wp_enqueue_script( 'bootstrapjs' );
47
48 wp_register_script( 'autowpjs',$autowp_my_plugin_dir_url.'assets/js/autowp.js' , array('jquery'), false, true );
49 wp_enqueue_script( 'autowpjs' );
50
51 wp_register_script( 'autowp_ai_modal',$autowp_my_plugin_dir_url.'assets/js/autowp_ai_modal.js' , array('jquery'), false, true );
52 wp_enqueue_script( 'autowp_ai_modal' );
53
54 wp_register_script( 'autowp_rewriting_modal',$autowp_my_plugin_dir_url.'assets/js/autowp_rewriting_modal.js' , array('jquery'), false, true );
55 wp_enqueue_script( 'autowp_rewriting_modal' );
56
57 wp_register_script( 'autowp_bootstrap_bundle',$autowp_my_plugin_dir_url.'assets/js/bootstrap.bundle.min.js' , array('jquery','autowp_jquery_ui'), false, true );
58 wp_enqueue_script( 'autowp_bootstrap_bundle' );
59
60 wp_register_script( 'autowp_jquery_ui',$autowp_my_plugin_dir_url.'assets/js/jquery-ui.min.js' , array('jquery'), false, true );
61 wp_enqueue_script( 'autowp_jquery_ui' );
62
63 wp_register_script( 'autowp_sortable_list',$autowp_my_plugin_dir_url.'assets/js/sortable_list.js' , array('jquery'), false, true );
64 wp_enqueue_script( 'autowp_sortable_list' );
65
66 wp_enqueue_script('autowp-toggle-js', plugins_url('assets/js/admin-toggle.js', __FILE__), array('jquery'), '1.0', true);
67
68
69
70
71
72
73
74
75
76 }
77
78 add_action('admin_enqueue_scripts','autowp_enqueue_scripts');
79
80
81 function autowp_toggle_website() {
82 // Güvenlik kontrolü: Nonce doğrulaması
83 check_ajax_referer('autowp_toggle_nonce', 'security');
84 $website_id = intval($_POST['id']);
85 global $wpdb;
86 $table_name = $wpdb->prefix . 'autowp_wordpress_websites';
87
88 // Mevcut "active" değerini al (eğer yoksa varsayılan olarak 1 kabul edilir)
89 $current = $wpdb->get_var($wpdb->prepare("SELECT active FROM $table_name WHERE id = %d", $website_id));
90 $current = isset($current) ? intval($current) : 1;
91 // Yeni durumu tersine çevir: Eğer aktifse 0 (pasif) yap, pasifse 1 (aktif) yap
92 $new_status = $current ? 0 : 1;
93
94 // Veritabanında güncelleme yapın
95 $wpdb->update($table_name, array('active' => $new_status), array('id' => $website_id), array('%d'), array('%d'));
96 wp_send_json_success(array('new_status' => $new_status));
97 }
98 add_action('wp_ajax_autowp_toggle_website', 'autowp_toggle_website');
99
100
101
102 //Set FAQ Schema
103
104 // JSON-LD ekleme fonksiyonu
105
106
107 // 4. Post başlığında meta veriyi kontrol et ve şema yapısını ekle
108 function inject_faq_schema_into_head() {
109 if (is_single()) {
110 global $post;
111 $faq_schema = get_post_meta($post->ID, '_faq_schema', true);
112
113 // Meta veride schema varsa header'a ekleyelim
114 if ($faq_schema) {
115 // Yalnızca belirli HTML etiketlerine izin verelim
116 $allowed_tags = array(
117 'script' => array(
118 'type' => true,
119 ),
120 );
121
122 echo wp_kses($faq_schema, $allowed_tags);
123 }
124 }
125 }
126 add_action('wp_head', 'inject_faq_schema_into_head');
127
128
129
130
131
132
133 //Enqueque CSS Files
134 function autowp_enqueue_styles(){
135 $my_plugin_dir = plugin_dir_url(__FILE__);
136
137 $screen = get_current_screen();
138 $slug = $screen->id;
139
140
141
142
143
144 if($slug == 'toplevel_page_autowp_menu' || $slug == 'autowp_page_autowp_manualPost' || $slug == 'autowp_page_autowp_automaticPost' || $slug == 'admin_page_add_new_wp_website_form' || $slug == 'autowp_page_autowp_settings' || $slug == 'autowp_page_autowp_linking_management' || $slug == 'admin_page_add_new_rss_website_form' || $slug == 'admin_page_add_new_ai_website_form' || $slug == 'autowp_page_autowp_add_new_website_form' || $slug == 'admin_page_add_new_agenticscraper_form' || $slug == 'admin_page_manual_post_wp_website_form' || $slug == 'admin_page_manual_post_rss_website_form' || $slug == 'admin_page_manual_post_ai_website_form' || $slug == 'admin_page_manual_post_agenticscraper_website_form' || $slug == 'admin_page_manual_post_news_website_form' || $slug == 'admin_page_add_new_news_website_form' || $slug == 'admin_page_autowp_promptschemes' || $slug == 'autowp_page_autowp_promptSettings' or $slug == 'admin_page_autowp_rewriting_promptschemes' or $slug=='admin_page_autowp-setup' ){
145 wp_register_style('autowp_bootstrap', $my_plugin_dir.'assets/css/bootstrap.min.css', array(), 1);
146 wp_enqueue_style('autowp_bootstrap');
147
148
149
150
151 wp_register_style('autowp_jquery_ui', $my_plugin_dir.'assets/css/jquery-ui.css', array(), 1);
152 wp_enqueue_style('autowp_jquery_ui');
153
154
155 wp_register_style('autowp_loader', $my_plugin_dir.'assets/css/loader.css', array(), 1);
156 wp_enqueue_style('autowp_loader');
157
158 wp_register_style('autowp_style', $my_plugin_dir.'assets/css/style.css', array(), 1);
159 wp_enqueue_style('autowp_style');
160
161
162
163
164
165
166 }
167
168
169
170
171 }
172
173 add_action('admin_print_styles','autowp_enqueue_styles');
174
175 //Register AutoWP API with Domain
176
177 // Eklenti etkinleştirildiğinde çalışacak fonksiyon
178 function autowp_activate() {
179 $settings = unserialize(get_option('autowp_settings'));
180
181 // API e-posta ve anahtarını kontrol et
182 if (empty($settings['api_email']) || empty($settings['api_key'])) {
183 // Kullanıcıyı kurulum sayfasına yönlendir
184 add_option('autowp_show_setup', true);
185 }
186 }
187 register_activation_hook(__FILE__, 'autowp_activate');
188
189 // Admin sayfasına yönlendirme
190 function autowp_redirect_to_setup() {
191 if (get_option('autowp_show_setup')) {
192 delete_option('autowp_show_setup');
193 wp_redirect(admin_url('admin.php?page=autowp-setup'));
194 exit;
195 }
196 }
197 add_action('admin_init', 'autowp_redirect_to_setup');
198
199
200
201 function autowp_get_page_slug_from_website_type($website_type){
202
203 switch($website_type){
204 case 'wordpress':
205 return 'add_new_wp_website_form';
206 case 'rss':
207 return 'add_new_rss_website_form';
208 case 'ai':
209 return 'add_new_ai_website_form';
210 case 'news':
211 return 'add_new_news_website_form';
212 case 'agenticscraper':
213 return 'add_new_agenticscraper_form';
214 default:
215 return '';
216 }
217
218 }
219
220 //WP-CRON START
221
222
223 function autowp_get_wpcron_time($time){
224
225 switch($time){
226 case 1:
227 return 'hourly';
228 case 2:
229 return 'twicedaily';
230 case 3:
231 return 'daily';
232 case 4:
233 return 'weekly';
234 default:
235 return 'hourly';
236
237 }
238
239 }
240
241
242 function autowp_set_featured_image($image_url, $post_id) {
243 error_log('[AutoWP] set_featured_image start post_id=' . intval($post_id) . ' image_url=' . esc_url_raw($image_url));
244 if (empty($image_url)) {
245 error_log('[AutoWP] set_featured_image missing_image_url post_id=' . intval($post_id));
246 return false;
247 }
248
249 require_once ABSPATH . 'wp-admin/includes/file.php';
250 require_once ABSPATH . 'wp-admin/includes/media.php';
251 require_once ABSPATH . 'wp-admin/includes/image.php';
252
253 $tmp_file = download_url($image_url, 30);
254 if (is_wp_error($tmp_file)) {
255 error_log('[AutoWP] set_featured_image download_url failed post_id=' . intval($post_id) . ' image_url=' . esc_url_raw($image_url) . ' error=' . $tmp_file->get_error_message());
256 return false;
257 }
258
259 $path = wp_parse_url($image_url, PHP_URL_PATH);
260 $filename = sanitize_file_name(basename($path ? $path : $image_url));
261 if (empty($filename) || strpos($filename, '.') === false) {
262 $filetype = wp_check_filetype_and_ext($tmp_file, $filename ? $filename : 'autowp-image');
263 $extension = !empty($filetype['ext']) ? $filetype['ext'] : 'jpg';
264 $filename = 'autowp-image-' . wp_generate_password(12, false, false) . '.' . $extension;
265 }
266
267 $file_array = array(
268 'name' => $filename,
269 'tmp_name' => $tmp_file,
270 );
271
272 $attachment_id = media_handle_sideload($file_array, $post_id, get_the_title($post_id));
273
274 if (is_wp_error($attachment_id)) {
275 @unlink($tmp_file);
276 error_log('[AutoWP] set_featured_image media_handle_sideload failed post_id=' . intval($post_id) . ' image_url=' . esc_url_raw($image_url) . ' error=' . $attachment_id->get_error_message());
277 return false;
278 }
279
280 error_log('[AutoWP] set_featured_image success post_id=' . intval($post_id) . ' attachment_id=' . intval($attachment_id) . ' filename=' . $filename);
281 return $attachment_id;
282 }
283
284
285
286
287
288
289 function autowp_upload_image_to_media($image_url) {
290 require_once(ABSPATH . 'wp-admin/includes/image.php');
291 require_once(ABSPATH . 'wp-admin/includes/file.php');
292 require_once(ABSPATH . 'wp-admin/includes/media.php');
293
294 // Using WordPress HTTP API to get image data
295 $response = wp_safe_remote_get($image_url);
296
297 if (is_wp_error($response)) {
298 return false;
299 }
300
301 $image_data = wp_remote_retrieve_body($response);
302
303 // Get the file name and extension
304 $file_name = basename($image_url);
305 $file_array = wp_upload_bits($file_name, null, $image_data);
306
307 // Check for errors during upload
308 if ($file_array['error']) {
309 return false;
310 }
311
312 // Create the attachment post
313 $attachment = array(
314 'post_mime_type' => $file_array['type'],
315 'post_title' => sanitize_file_name($file_name),
316 'post_content' => '',
317 'post_status' => 'inherit',
318 );
319
320 // Insert the attachment into the media library
321 $attachment_id = wp_insert_attachment($attachment, $file_array['file']);
322
323 // Generate the metadata for the attachment
324 $attachment_data = wp_generate_attachment_metadata($attachment_id, $file_array['file']);
325
326 // Update the attachment metadata
327 wp_update_attachment_metadata($attachment_id, $attachment_data);
328
329 // Return the upload URL of the image
330 return wp_get_attachment_url($attachment_id);
331 }
332
333
334
335 function autowp_upload_and_replace_image_sources($html) {
336 $dom = new DOMDocument();
337 $dom->encoding = 'UTF-8';
338 libxml_use_internal_errors(true);
339 $dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
340 libxml_clear_errors();
341
342 $images = $dom->getElementsByTagName('img');
343 foreach ($images as $image) {
344 $src = $image->getAttribute('src');
345 $new_image_url = autowp_upload_image_to_media($src);
346 if ($new_image_url) {
347 $image->setAttribute('src', $new_image_url);
348 }
349 }
350
351 return $dom->saveHTML();
352 }
353
354 function get_excerpt_from_content($content) {
355 // HTML etiketlerini kaldır
356 $plain_text_content = strip_tags($content);
357
358 // HTML özel karakterlerini dönüştür
359 $plain_text_content = html_entity_decode($plain_text_content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
360
361 // Metni cümlelere böl ('.', '!' veya '?' sonrası boşluk karakteriyle ayır)
362 $sentences = preg_split('/(\.|\!|\?)\s+/', $plain_text_content, 3, PREG_SPLIT_DELIM_CAPTURE);
363
364 // İlk iki cümleyi birleştir
365 $excerpt = isset($sentences[0]) ? $sentences[0] : '';
366 $excerpt .= isset($sentences[1]) ? $sentences[1] : '';
367 $excerpt .= isset($sentences[2]) ? $sentences[2] : '';
368 $excerpt .= isset($sentences[3]) ? $sentences[3] : '';
369
370 return trim($excerpt);
371 }
372
373 function autowp_apply_linking_to_content($post_content) {
374 // Linkleme ayarlarını veritabanından çek
375 $linking_settings = get_option('autowp_linking_settings', []);
376
377 // Eğer hiç kayıtlı linkleme ayarı yoksa, içeriği değiştirmeden döndür
378 if (empty($linking_settings) || !is_array($linking_settings)) {
379 return $post_content;
380 }
381
382 // Kullanıcının eklediği tüm anahtar kelimeleri organize etmek için bir dizi oluştur
383 $keyword_settings = [];
384
385 foreach ($linking_settings as $setting) {
386 $keyword = $setting['keyword'];
387 $link = $setting['link'];
388 $html_tag = $setting['html_tag'];
389 $link_count = $setting['link_count'];
390
391
392
393 // Eğer anahtar kelime daha önce eklenmişse, mevcut dizinin içine ekle
394 if (!isset($keyword_settings[$keyword])) {
395 $keyword_settings[$keyword] = [];
396 }
397
398 // Kullanıcının eklediği tüm HTML etiketlerini aynı kelime için sakla
399 $keyword_settings[$keyword][] = [
400 'link' => $link,
401 'html_tag' => $html_tag,
402 'link_count' => $link_count
403 ];
404 }
405
406 // İçeriği değiştirmek için işlemi başlat
407 foreach ($keyword_settings as $keyword => $settings) {
408 // Eğer içerikte bu anahtar kelime yoksa, devam et
409 if (stripos($post_content, $keyword) === false) {
410 continue;
411 }
412
413 // Bu kelime için kaç tane değişiklik yapıldığını takip eden sayaç
414 $count = 0;
415
416 // Regex kullanarak kelimeyi değiştir
417 $post_content = preg_replace_callback(
418 '/\b' . preg_quote($keyword, '/') . '\b/i',
419 function ($matches) use ($settings, &$count) {
420 $original_keyword = $matches[0]; // Orijinal metin içinde nasıl geçtiyse onu al
421
422 // Kullanıcının seçtiği tüm etiketleri uygula
423 $modified_keyword = $original_keyword;
424 foreach ($settings as $setting) {
425 $html_tag = $setting['html_tag'];
426 $link = $setting['link'];
427 $link_count = $setting['link_count'];
428
429 // Eğer "a" etiketi seçildiyse, SEO uyumlu link ekle
430 if ($html_tag === "a") {
431 if ($count < intval($link_count) || $link_count === "all") {
432 $modified_keyword = "<a href=\"$link\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"$original_keyword\">$modified_keyword</a>";
433
434 }
435 } else {
436 // Link değilse sadece belirlenen etiketi uygula
437 if ($count < intval($link_count) || $link_count === "all") {
438 $modified_keyword = "<$html_tag>$modified_keyword</$html_tag>";
439
440 }
441
442 }
443 $count++;
444 }
445
446 return $modified_keyword;
447 },
448 $post_content
449 );
450 }
451
452 return $post_content;
453 }
454
455
456
457 function autowp_set_new_post($post_title, $post_content, $post_status, $post_author, $post_type, $featured_image_url, $post_category, $post_tags, $focus_keyword,$faq_schema) {
458
459 $post_content = autowp_upload_and_replace_image_sources($post_content);
460
461 $post_content = autowp_apply_linking_to_content($post_content);
462
463 //Set SEO
464 //focus keyword
465 $title_explode = explode(" ", $post_title);
466 // $focus_keyword = //$title_explode[0] . " " . $title_explode[1];
467
468 //Meta desc
469 $meta_desc = substr(strip_tags($post_content), 0, 155);
470
471 $meta_input = ["_yoast_wpseo_title" => $post_title, "_yoast_wpseo_metadesc" => $meta_desc, "_yoast_wpseo_focuskw" => $focus_keyword, "rank_math_title" => $post_title, "rank_math_description" => $meta_desc, "rank_math_focus_keyword" => $focus_keyword, "_faq_schema" => $faq_schema];
472
473
474
475 $post = array(
476 'post_title' => $post_title,
477 'post_content' => $post_content,
478 'post_status' => $post_status, // "publish" olarak ayarla
479 'post_author' => $post_author, // 1 olarak ayarla
480 'post_type' => $post_type, // "post" olarak ayarla
481 'post_category' => $post_category, //category array
482 'tags_input' => $post_tags, //tags
483 'meta_input' => $meta_input, //meta inputs
484 'post_excerpt' => get_excerpt_from_content($post_content)
485
486 );
487
488
489
490 $new_post_id = wp_insert_post($post);
491 if (is_wp_error($new_post_id)) {
492 error_log('[AutoWP] set_new_post wp_insert_post failed title=' . sanitize_text_field($post_title) . ' error=' . $new_post_id->get_error_message());
493 return false;
494 }
495
496 if (!empty($featured_image_url)) {
497 error_log('[AutoWP] set_new_post attempting_featured_image post_id=' . intval($new_post_id) . ' image_url=' . esc_url_raw($featured_image_url));
498 $image_id = autowp_set_featured_image($featured_image_url, $new_post_id);
499 if ($image_id !== false) {
500 $thumbnail_result = set_post_thumbnail($new_post_id, $image_id);
501 error_log('[AutoWP] set_new_post set_post_thumbnail result post_id=' . intval($new_post_id) . ' attachment_id=' . intval($image_id) . ' result=' . var_export($thumbnail_result, true));
502 } else {
503 error_log('[AutoWP] set_new_post featured_image_import_failed post_id=' . intval($new_post_id) . ' image_url=' . esc_url_raw($featured_image_url));
504 }
505 } else {
506 error_log('[AutoWP] set_new_post no_featured_image_url post_id=' . intval($new_post_id));
507 }
508
509 return $new_post_id; // Fonksiyonun sonunda bu satırı ekleyin
510
511 }
512
513
514
515
516
517
518 function autowp_wpcron_setAutoPosting(){
519
520 $settings = unserialize(get_option('autowp_settings'));
521
522 $wpcron_status = $settings['wpcron_status'];
523
524 if($wpcron_status === '1'){
525 autowp_wordpress_post();
526 }
527
528 }
529
530 add_filter('autowp_cron','autowp_wpcron_setAutoPosting');
531
532 function autowp_get_wp_autowp_wordpress_websites() {
533 global $wpdb;
534 $table_name = $wpdb->prefix . 'autowp_wordpress_websites';
535 $sql = "SELECT * FROM $table_name";
536 $results = $wpdb->get_results($wpdb->prepare($sql), ARRAY_A);
537 return $results;
538 }
539
540
541
542 function autowp_stringToArray($input) {
543 $numbers = explode(",", $input);
544 $result = array();
545
546 foreach ($numbers as $number) {
547 $result[] = (int)$number;
548 }
549
550 return $result;
551 }
552
553
554 function autowp_update_published_post_ids($new_post_ids) {
555 $autowp_settings = get_option('autowp_post_settings');
556 $autowp_settings = unserialize($autowp_settings);
557
558 // Update the published_post_ids value
559 $autowp_settings['published_post_ids'] = $new_post_ids;
560
561 // Serialize and update the option value
562 update_option('autowp_post_settings', serialize($autowp_settings));
563 }
564
565 function autowp_update_wp_cron_status($new_status) {
566 $autowp_settings = get_option('autowp_settings');
567 $autowp_settings = unserialize($autowp_settings);
568
569 // Update the published_post_ids value
570 $autowp_settings['wpcron_status'] = $new_status;
571
572 // Serialize and update the option value
573 update_option('autowp_settings', serialize($autowp_settings));
574 }
575
576 add_action('admin_notices', 'autowp_create_alert');
577
578 function autowp_create_alert() {
579 $alerts = get_option('autowp_alerts');
580 $settings = get_option('autowp_settings');
581 $settings = $settings ? unserialize($settings) : [];
582
583 $announcements = get_option('autowp_announcements'); // Duyuruları opsiyondan al
584 $dismissed_announcements = get_option('autowp_dismissed_announcements', []); // Kullanıcı tarafından gizlenmiş duyuruları al
585
586 // Eğer dismissed_announcements bir string ise, diziye çevir
587 if (!is_array($dismissed_announcements)) {
588 $dismissed_announcements = [];
589 }
590
591 $has_actionable_alert = !empty($alerts);
592 $notice_button_url = $has_actionable_alert ? admin_url('admin.php?page=autowp_settings') : admin_url('admin.php?page=autowp_menu');
593 $notice_button_label = $has_actionable_alert ? __('Go to Settings', 'autowp') : __('Upgrade Membership', 'autowp');
594
595 // Eğer alert veya duyurular varsa
596 if (!empty($alerts) || !empty($announcements)) {
597 echo '
598 <div class="notice notice-info is-dismissible">
599 <p><strong>AutoWP Announcement:</strong></p>';
600
601 // Eğer alerts varsa göster
602 if (!empty($alerts)) {
603 $alert_message = rtrim((string) $alerts);
604 $cron_message = __('Please update your settings and wait until the next cron trigger. This notice will be cleared then.', 'autowp');
605
606 if (strpos($alert_message, $cron_message) === false) {
607 $alert_message .= ' ' . $cron_message;
608 }
609
610 echo '<p>' . esc_html(trim($alert_message)) . '</p>';
611 }
612
613 // Eğer duyurular varsa, her birini ayrı bir satırda göster
614 if (!empty($announcements)) {
615 foreach ($announcements as $announcement_id => $announcement) {
616 // Eğer bu duyuru gizlenmediyse göster
617 if (!in_array($announcement_id, $dismissed_announcements)) {
618 echo '<p>' . esc_html($announcement['title']) . ': ' . wp_kses_post($announcement['message']) . '</p>';
619 echo '<button data-announcement-id="' . esc_attr($announcement_id) . '" class="button dismiss-announcement">Dismiss</button>';
620 }
621 }
622 }
623
624 echo '<p><a href="' . esc_url($notice_button_url) . '" class="button button-primary">' . esc_html($notice_button_label) . '</a></p>
625 </div>';
626
627 // Bu butonlar için JavaScript ekle (AJAX ile belirli bir duyuruyu gizle)
628 echo '
629 <script type="text/javascript">
630 jQuery(document).on("click", ".dismiss-announcement", function() {
631 var announcement_id = jQuery(this).data("announcement-id");
632
633 var data = {
634 action: "autowp_dismiss_announcement",
635 security: "' . esc_js(wp_create_nonce("autowp_dismiss_nonce")) . '",
636 announcement_id: announcement_id
637 };
638
639 jQuery.post(ajaxurl, data, function(response) {
640 if(response.success) {
641 location.reload(); // Sayfayı yeniden yükle
642 }
643 });
644 });
645 </script>';
646 }
647
648 // İkinci alert: Setup kontrolü
649 if (empty($settings['api_email']) || empty($settings['api_key'])) {
650 echo '
651 <div class="notice notice-error is-dismissible">
652 <p><strong>AutoWP Setup Required</strong></p>
653 <p>AutoWP is not set up properly. To use this plugin, you need to complete the setup process.</p>
654 <p>If you do not complete the setup, AutoWP will not work correctly.</p>
655 <p><a href="admin.php?page=autowp-setup" class="button button-primary">Go to Setup</a></p>
656 </div>';
657 }
658 }
659
660 // AJAX isteğini ele alan fonksiyon
661 function autowp_dismiss_announcement() {
662 check_ajax_referer('autowp_dismiss_nonce', 'security');
663
664 if (isset($_POST['announcement_id'])) {
665 $announcement_id = sanitize_text_field($_POST['announcement_id']);
666
667 // Daha önce dismissed duyuruları al
668 $dismissed_announcements = get_option('autowp_dismissed_announcements', []);
669
670 // Eğer dismissed_announcements bir string ise, diziye çevir
671 if (!is_array($dismissed_announcements)) {
672 $dismissed_announcements = [];
673 }
674
675 // Yeni dismissed duyuruyu ekle
676 if (!in_array($announcement_id, $dismissed_announcements)) {
677 $dismissed_announcements[] = $announcement_id;
678 update_option('autowp_dismissed_announcements', $dismissed_announcements);
679 }
680
681 wp_send_json_success();
682 } else {
683 wp_send_json_error();
684 }
685 }
686 add_action('wp_ajax_autowp_dismiss_announcement', 'autowp_dismiss_announcement');
687
688
689
690 // Eklenti etkinleştirildiğinde çalışan fonksiyon
691 function autowp_announcements_activation() {
692 if ( ! wp_next_scheduled( 'autowp_fetch_announcements' ) ) {
693 wp_schedule_event( time(), 'ten_minutes', 'autowp_fetch_announcements' );
694 }
695 }
696 register_activation_hook( __FILE__, 'autowp_announcements_activation' );
697
698 // Eklenti devre dışı bırakıldığında çalışan fonksiyon
699 function autowp_announcements_deactivation() {
700 wp_clear_scheduled_hook( 'autowp_fetch_announcements' );
701 }
702 register_deactivation_hook( __FILE__, 'autowp_announcements_deactivation' );
703
704 // Zamanlanmış olayları (interval) ekle
705 function autowp_custom_intervals( $schedules ) {
706 $schedules['ten_minutes'] = array(
707 'interval' => 600, // 600 saniye = 10 dakika
708 'display' => __( 'Every 10 Minutes' ),
709 );
710 return $schedules;
711 }
712 add_filter( 'cron_schedules', 'autowp_custom_intervals' );
713
714 // API'den duyuruları çekme fonksiyonu
715 function autowp_fetch_announcements() {
716 // autowp_settings opsiyonunu al ve çöz
717 $settings_option = get_option( 'autowp_settings' );
718 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
719
720
721 if ( empty( $settings_option ) ) {
722 return; // Ayar yoksa işlemi durdur
723 }
724
725 // Ayarlardan api_key değerini al
726 $settings = maybe_unserialize( $settings_option );
727 $api_key = isset( $settings['api_key'] ) ? $settings['api_key'] : '';
728
729 $api_url = 'https://api.autowp.app/announcements';
730
731
732
733
734 if ( isset( $server_url )
735 && $server_url !== null
736 && $server_url !== ''
737 && strpos( $server_url, 'autowp.app' ) === false
738 ) {
739
740 $api_url = $server_url . '/announcements';
741
742 }
743
744
745 // API isteğini api_key varsa ona göre yapılandır
746 $request_url = ! empty( $api_key ) ? add_query_arg( 'api_key', $api_key, $api_url ) : $api_url;
747
748 // API'ye istek yap
749 $response = wp_remote_get( $request_url, array(
750 'timeout' => 15,
751 'sslverify' => false,
752 'headers' => array(
753 'Content-Type' => 'application/json',
754 'Accept' => 'application/json',
755 )
756 ) );
757
758 if ( is_wp_error( $response ) ) {
759 return; // Hata varsa işlemi durdur
760 }
761
762 $body = wp_remote_retrieve_body( $response );
763 $announcements = json_decode( $body, true );
764
765 if ( is_array( $announcements ) ) {
766 // Duyuruları WordPress opsiyonuna kaydet
767 update_option( 'autowp_announcements', $announcements );
768 }
769 }
770
771 add_action( 'autowp_fetch_announcements', 'autowp_fetch_announcements' );
772
773 function autowp_get_user_email_from_settings() {
774 // autowp_settings opsiyonunu alın
775 $autowp_settings = get_option('autowp_settings');
776 $autowp_settings = $autowp_settings ? unserialize($autowp_settings) : [];
777
778 // Ayarlardan email'i çek
779 $user_email = isset($autowp_settings['api_email']) ? sanitize_email($autowp_settings['api_email']) : '';
780
781 return $user_email;
782 }
783
784
785 function autowp_wordpress_post(){
786 $wordpress_websites = autowp_get_wp_autowp_wordpress_websites();
787 // Randomize the order of the array
788 shuffle($wordpress_websites);
789 $counter = 0;
790 $max_posts_per_cron = absint(unserialize(get_option('autowp_settings'))['max_posts_per_cron'] ?? 1);
791
792 foreach($wordpress_websites as $wordpress_website){
793
794 if ($counter >= $max_posts_per_cron) {
795 break;
796 }
797
798 if ($wordpress_website['active'] === '0'){
799 continue;
800 }
801
802
803
804
805 $user_domainname = esc_url(get_site_url());
806 $user_email = autowp_get_user_email_from_settings();
807 $website_domainname = sanitize_url($wordpress_website['domain_name']);
808 $website_categories = $wordpress_website['website_category_id'];
809 $wordpress_categories = $wordpress_website['category_id'];
810
811
812 $post_count = $wordpress_website['post_count'];
813 $post_order = $wordpress_website['post_order'];
814
815 $title_prompt = $wordpress_website['title_prompt'];
816 $content_prompt = $wordpress_website['content_prompt'];
817 $tags_prompt = $wordpress_website['tags_prompt'];
818 $image_prompt = $wordpress_website['image_prompt'];
819
820 $aigenerated_title = 1;
821 $aigenerated_content = 1;
822 $aigenerated_tags = 1;
823 $aigenerated_image = 1;
824
825 $source_type = $wordpress_website['website_type'];
826
827 $image_generating_status = $wordpress_website['image_generating_status'];
828
829 $author_selection = $wordpress_website['author_selection'];
830
831 //News
832
833 $news_keyword = $wordpress_website['news_keyword'];
834 $news_country = $wordpress_website['news_country'];
835 $news_language = $wordpress_website['news_language'];
836 $news_time_published = $wordpress_website['news_time_published'];
837 $is_html = true;
838
839
840
841
842 $image_settings = unserialize(get_option('autowp_settings'));
843 $image_settings_json = [];
844
845 if(!empty($image_settings)){
846 $image_settings_json = json_encode($image_settings);
847 }
848
849 $prompts_option = get_option('autowp_rewriting_promptscheme');
850 $prompt_option_str = strval($prompts_option);
851 $rewriting_prompt_scheme = [];
852
853 if (!empty($prompts_option)) {
854 $rewriting_prompt_scheme = json_encode($prompts_option);
855
856 // JSON'dan diziye dönüşüm yapılıyor ve true ile birlikte kullanıldığı için asosiyatif dizi elde ediliyor
857 }
858
859
860
861
862
863
864 $get_data_from_api = autowp_get_posts_from_wp_website($user_domainname, $user_email, $website_domainname, $website_categories, $post_count,$post_order,'',$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings_json,$source_type,$image_generating_status,$news_keyword,$news_country,$news_language,$news_time_published,$is_html,$prompt_option_str);
865 sleep(rand(2, 3)); // 2-3 saniye bekleme süresi eklendi
866 $wp_posts = $get_data_from_api['autowp-api'];
867
868 if($get_data_from_api['error']){
869 update_option('autowp_alerts', $get_data_from_api['error']);
870 continue;
871 }else{
872 update_option('autowp_alerts', '');
873 }
874
875
876
877
878
879 foreach($wp_posts as $post){
880 $post_title = $post['post_title'];
881 $post_content = $post['content'];
882 $post_featured_image = $post['preview_image_original'];
883 $post_tags = $post['tags'];
884 $post_status = $image_settings['post_status'] ?? 'publish';
885 $post_author = $author_selection;
886 $post_type = 'post';
887 $focus_keyword = $post['focus_keyword'];
888 $faq_schema = $post['faq_schema'];
889
890
891
892
893 $new_post_id = autowp_set_new_post($post_title,$post_content,$post_status,$post_author,$post_type,$post_featured_image, autowp_stringToArray($wordpress_categories),$post_tags,$focus_keyword,$faq_schema);
894 $counter++;
895
896
897 }
898
899
900
901
902
903 }
904 }
905
906 function autowp_get_posts_from_wp_website($user_domainname, $user_email, $website_domainname, $website_categories, $post_count,$post_order,$post_ids,$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings,$source_type,$image_generating_status,$news_keyword = '',$news_country = '',$news_language = '',$news_time_published = '',$is_html = false,$rewriting_prompt_scheme = null) {
907
908
909 $prompts_option = get_option('autowp_rewriting_promptscheme');
910
911 if (!is_array($prompts_option)) {
912 $prompts_option = json_decode($prompts_option, true);
913 }
914
915 $prompt_option_string = json_encode($prompts_option);
916
917 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
918
919
920
921
922 $url = 'https://api.autowp.app/latest-posts';
923
924 if ( isset( $server_url )
925 && $server_url !== null
926 && $server_url !== ''
927 && strpos( $server_url, 'autowp.app' ) === false
928 ) {
929
930 $url = $server_url . '/latest-posts';
931
932 }
933
934
935
936
937 $data = array(
938 'user_domainname' => $user_domainname,
939 'user_email' => $user_email,
940 'website_domainname' => $website_domainname,
941 'website_categories' => $website_categories,
942 'post_count' => 5,
943 'post_order' => $post_order,
944 'published_post_ids' => $post_ids,
945
946 'title_prompt' => $title_prompt,
947 'content_prompt' => $content_prompt,
948 'tags_prompt' => $tags_prompt,
949 'image_prompt' => $image_prompt,
950
951
952 'aigenerated_title' => $aigenerated_title,
953 'aigenerated_content' => $aigenerated_content,
954 'aigenerated_tags' => $aigenerated_tags,
955 'aigenerated_image' => $aigenerated_image,
956
957
958 'image_settings' => $image_settings,
959
960
961 'source_type' => $source_type,
962
963 'image_generating_status' => $image_generating_status,
964
965 'news_keyword' => $news_keyword,
966 'news_country' => $news_country,
967 'news_language' => $news_language,
968 'news_time_published' => $news_time_published,
969 'is_html' => $is_html,
970
971 'rewriting_prompt_scheme' => $prompt_option_string
972 );
973
974
975
976 $response = wp_remote_post($url, array(
977
978 'timeout' => 2400, // Timeout set to 4 minutes.
979
980 'body' => $data,
981
982 ));
983
984 update_option('autowp_alerts', strval($response));
985
986 if (is_wp_error($response)) {
987 $error_message = wp_remote_retrieve_response_message($response);
988 return 'Error: ' . $error_message;
989 }
990
991
992 $body = wp_remote_retrieve_body($response);
993
994
995 $result = json_decode($body, true);
996
997
998
999 return $result;
1000 }
1001
1002
1003 function autowp_set_wpcron(){
1004 // Current settings
1005 $current_settings = unserialize(get_option('autowp_settings'));
1006
1007 // Received data from user
1008 $received_data = array(
1009 "selected_time_type" => '1',
1010 "wpcron_status" => '1',
1011 "watermark_link" => '',
1012 "nano_banana_prompt" => '',
1013 "image_modification_status" => '0',
1014 "image_generating_status" => '0',
1015 "ai_image_width" => 0,
1016 "ai_image_height" => 0,
1017 "stable_diffusion_style" => 'None',
1018 // OpenAI image settings stored under legacy option keys for compatibility
1019 "flux_image_size" => 'landscape_16_9', // Default value for flux image size
1020 "stable_diffusion_size" => '16:9', // Default value for stable diffusion size
1021 "dalle_2_size" => '1024x1024', // Default value for GPT Image 1 Mini size
1022 "dalle_3_size" => '1024x1024', // Default value for GPT Image 2 size
1023 "dalle_3_style" => 'natural',
1024 "image_format" => "png",
1025 // New default values
1026 "max_posts_per_cron" => 1, // Default value for maximum posts per cron
1027 "max_posts_per_day" => 20, // Default value for maximum posts per day
1028 "spam_ad_filter" => '0', // Default value for spam and ad filter (passive)
1029 "duplicate_content_filter" => '1', // Default value for duplicate content filter (active)
1030 "primary_llm" => 'openai',
1031 "secondary_llm" => 'xai',
1032 "default_image_url" => "https://gorsel.autowp.app/en/en/1.png",
1033 "autowp_server_url" => 'https://api.autowp.app',
1034
1035 );
1036
1037 if(empty($current_settings)){
1038
1039 // Serialize and update options
1040 update_option('autowp_settings', serialize($received_data), "yes");
1041
1042 }
1043
1044 $time_value_type = sanitize_text_field('2');
1045
1046 $user_wpcron_time = autowp_get_wpcron_time($time_value_type);
1047
1048
1049 // Schedule WP-Cron
1050 if (!wp_next_scheduled('autowp_cron')) {
1051 wp_schedule_event(time(), $user_wpcron_time, 'autowp_cron');
1052 } else {
1053 wp_clear_scheduled_hook('autowp_cron');
1054 wp_schedule_event(time(), $user_wpcron_time, 'autowp_cron');
1055 }
1056 }
1057
1058
1059 function update_autowp_promptscheme_option() {
1060 // Define the data as an array
1061 $data = [
1062 [
1063 'name' => 'AutoWP Introduction',
1064 'detailed_prompt' => 'autowp-introduction',
1065 'max_tokens' => 300000,
1066 ],
1067 [
1068 'name' => 'AutoWP Subheadings',
1069 'detailed_prompt' => 'autowp-subheadings',
1070 'max_tokens' => 300000,
1071 ],
1072 [
1073 'name' => 'AutoWP FAQ',
1074 'detailed_prompt' => 'autowp-faq',
1075 'max_tokens' => 300000,
1076 ],
1077 [
1078 'name' => 'AutoWP Results',
1079 'detailed_prompt' => 'autowp-result',
1080 'max_tokens' => 300000,
1081 ]
1082 ];
1083
1084 // Serialize the array
1085 $serialized_data = serialize($data);
1086
1087 // Check if the option is empty before updating
1088 if (empty(get_option('autowp_rewriting_promptscheme'))) {
1089 update_option('autowp_rewriting_promptscheme', $serialized_data);
1090 }
1091 }
1092
1093 register_activation_hook(__FILE__, 'update_autowp_promptscheme_option');
1094
1095
1096
1097
1098
1099
1100 register_activation_hook(__FILE__, 'autowp_set_wpcron');
1101
1102 function autowp_unset_wpcron(){
1103
1104 // find out when the last event was scheduled
1105 $timestamp = wp_next_scheduled ('autowp_cron');
1106 // unschedule previous event if any
1107 wp_unschedule_event ($timestamp, 'autowp_cron');
1108
1109 }
1110
1111 register_deactivation_hook(__FILE__,'autowp_unset_wpcron');
1112
1113 //WP-CRON END
1114
1115 // Dil desteği için 'autowp' önekini kullanarak metinleri çevirelim
1116
1117
1118
1119 function autowp_get_user_from_autowp_api() {
1120
1121 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
1122
1123
1124 // API URL'si
1125 $url = 'https://api.autowp.app/getUserByDomain';
1126
1127
1128
1129
1130
1131
1132 if ( isset( $server_url )
1133 && $server_url !== null
1134 && $server_url !== ''
1135 && strpos( $server_url, 'autowp.app' ) === false
1136 ) {
1137
1138 $url = $server_url . '/getUserByDomain';
1139
1140 }
1141
1142 // Setup kısmında kaydedilen ayarları al
1143 $autowp_settings = get_option('autowp_settings');
1144 $autowp_settings = $autowp_settings ? unserialize($autowp_settings) : [];
1145
1146 // autowp_settings içinden user_email ve api_key'i al
1147 $user_email = isset($autowp_settings['api_email']) ? sanitize_email($autowp_settings['api_email']) : 'email@example.com';
1148 $api_key = isset($autowp_settings['api_key']) ? sanitize_text_field($autowp_settings['api_key']) : '';
1149
1150 // API'ye gönderilecek veriler
1151 $args = array(
1152 'body' => array(
1153 'user_domainname' => esc_url(get_site_url()),
1154 'user_email' => $user_email,
1155 'api_key' => $api_key
1156 )
1157 );
1158
1159 // API çağrısı
1160 $response = wp_remote_post($url, $args);
1161
1162 // Yanıtı JSON olarak ayrıştır
1163 $json = json_decode(wp_remote_retrieve_body($response), true);
1164
1165 return $json;
1166 }
1167
1168 function autowp_generalSettings(){
1169 ?>
1170
1171 <!-- Logo Eklemesi -->
1172
1173 <form method="post" class="form-horizontal">
1174 <fieldset>
1175
1176 <?php
1177 $user = autowp_get_user_from_autowp_api();
1178 $isUserPremium = $user['product_name'] ?? 'Free Users';
1179
1180 // Eğer kullanıcının AIContentGenerator kredisi ve premium üyeliği yoksa
1181 if ($isUserPremium == 'Free User') {
1182 echo '<div class="alert alert-warning" role="alert">' .
1183 esc_html__('You are not a premium user so you have limited balance. If you want to generate more posts or image, you should upgrade to premium membership.','autowp') . ' ' .
1184 '</div>';
1185 }
1186 ?>
1187
1188 <div class="form-group">
1189 <div class="card text-center">
1190 <div class="card-body">
1191 <h4 class="card-title"><img src="<?php echo esc_url(plugins_url( '/assets/images/logo128.png', __FILE__ )) ?>" alt="AutoWP" style="height: 100px; width: 100px;"></h4>
1192 <p class="card-text"> <?php echo esc_html__('Package Name:', 'autowp'); ?> <?php echo esc_html($isUserPremium); ?></p>
1193 <p class="card-text"> <?php echo esc_html__('Renewal Date:', 'autowp'); ?> <?php echo esc_html($user['renewal_date'] ?? esc_html__('NO RENEWAL DATE', 'autowp')); ?></p>
1194 <p class="card-text"> <?php echo esc_html__('AI-Generated Post Balance:', 'autowp'); ?> <?php echo esc_html($user['aigenerated_post_balance']) . ' ' . esc_html__('Posts', 'autowp'); ?></p>
1195 <p class="card-text"> <?php echo esc_html__('AI-Generated Image Balance:', 'autowp'); ?> <?php echo esc_html($user['aigenerated_image_balance']) . ' ' . esc_html__('Images', 'autowp'); ?></p>
1196 <br>
1197 <a href="https://api.whatsapp.com/send/?phone=61410688978" class="btn btn-primary"><?php echo esc_html__('Contact Us', 'autowp'); ?></a>
1198 <a href="https://billing.stripe.com/p/login/eVq28scVg4UT1qw929fQI00" class="btn btn-primary"><?php echo esc_html__('Manage Subscription', 'autowp'); ?></a>
1199 </div>
1200 </div>
1201 </div>
1202
1203
1204
1205 <br>
1206
1207
1208 <!-- Yeni Card: "R10 Özel Fiyatlar için Tıklayın!" -->
1209
1210
1211
1212 <?php
1213
1214 $request_url = 'https://api.autowp.app/getPackages';
1215
1216 if ( get_locale() === 'tr_TR' ) {
1217 $request_url = 'https://api.autowp.app/getPackages?is_turkish=True';
1218 }
1219 $response = wp_remote_get($request_url);
1220
1221
1222
1223
1224
1225 if (is_wp_error($response)) {
1226 echo '<div class="alert alert-danger" role="alert">' .
1227 esc_html__('An error occurred while fetching packages. Please try again later.', 'autowp') . ' ' .
1228 '</div>';
1229 } else {
1230 $packages = json_decode(wp_remote_retrieve_body($response), true);
1231
1232 // Unlimited paketleri önce sıralamak için düzenleme
1233 usort($packages, function($a, $b) {
1234 return ($b['is_unlimited'] ?? false) - ($a['is_unlimited'] ?? false);
1235 });
1236
1237 $hasAnnual = false;
1238 $hasMonthly = false;
1239
1240 foreach ($packages as $package) {
1241 if ($package['is_annual']) {
1242 $hasAnnual = true;
1243 } else {
1244 $hasMonthly = true;
1245 }
1246 }
1247
1248
1249
1250 if ($hasMonthly && $hasAnnual) {
1251 echo '<center><div class="btn-group" role="group" aria-label="Package Options">';
1252
1253 if ($hasMonthly) {
1254 echo '<button type="button" class="btn btn-primary active" id="monthly-tab" onclick="filterPackages(\'monthly\')">' . esc_html__('Monthly', 'autowp') . '</button>';
1255 }
1256
1257 if ($hasAnnual) {
1258 echo '<button type="button" class="btn btn-secondary" id="annual-tab" onclick="filterPackages(\'annual\')">' . esc_html__('Annual', 'autowp') . '</button>';
1259 }
1260
1261 echo '</div><center>';
1262 }
1263
1264 if ( get_locale() === 'tr_TR' ) {
1265 echo '<div class="card text-center" style="width: 100%; margin-bottom: 20px;">
1266 <div class="card-body">
1267 <h4 class="card-title" style="font-weight: bold; color: #FF6347;">' . esc_html__('TÜRKÇE DESTEK HATTI VE ÖZEL İNDİRİMLER İÇİN TIKLAYIN!', 'autowp') . '</h4>
1268 <a href="https://api.whatsapp.com/send/?phone=61410688978" class="btn btn-warning">' . esc_html__('Tıklayın', 'autowp') . '</a>
1269 </div>
1270 </div>';
1271 }
1272
1273
1274 echo '<div id="packagesContainer">';
1275
1276 if (!empty($packages)) {
1277 foreach ($packages as $package) {
1278 $isUnlimited = !empty($package['is_unlimited']) && $package['is_unlimited'];
1279 $isAnnualClass = $package['is_annual'] ? 'annual' : 'monthly';
1280
1281 $currency = '£';
1282
1283 if ( get_locale() === 'tr_TR' ) {
1284 $currency = 'TL';
1285 }
1286
1287 if ($isUnlimited) {
1288 ?>
1289 <div class="columns package unlimited <?php echo esc_attr($isAnnualClass); ?>">
1290 <ul class="price special-unlimited">
1291 <li class="header" style="background-color: #FFD700; color: #000;"><?php echo esc_html(ucwords($package['name'])); ?></li>
1292 <li class="grey">
1293 <?php echo esc_html($currency); ?>
1294 <?php echo esc_html(number_format($package['package_price'], 2)); ?> /
1295 <?php echo $package['is_annual'] ? esc_html__('Year', 'autowp') : esc_html__('Month', 'autowp'); ?>
1296 </li>
1297
1298 <li><?php echo esc_html__('Unlimited AI-Generated Posts', 'autowp'); ?></li>
1299 <li><?php echo esc_html__('Unlimited AI-Generated Images', 'autowp'); ?></li>
1300 <li>
1301 <?php
1302 echo $package['max_website'] == 0
1303 ? esc_html__('Unlimited Websites', 'autowp')
1304 : esc_html($package['max_website']) . ' ' . esc_html__('max website', 'autowp');
1305 ?>
1306 </li>
1307
1308 <li><?php echo esc_html__('Auto Indexing', 'autowp'); ?></li>
1309 <li><?php echo esc_html__('Social Media Sharing', 'autowp'); ?></li>
1310 <li><?php echo esc_html__('Auto Image Editing', 'autowp'); ?></li>
1311 <li><?php echo esc_html__('Use Your Own API Keys', 'autowp'); ?></li>
1312 <li class="grey"><a href="https://api.autowp.app/v2/subscribe?package_id=<?php echo esc_attr($package['id']); ?>&user_id=<?php echo esc_attr($user['user_id']); ?>" class="button"><?php echo esc_html__('Sign Up', 'autowp'); ?></a></li>
1313 </ul>
1314 </div>
1315 <?php
1316 }
1317 else {
1318 ?>
1319 <div class="columns package <?php echo esc_attr($isAnnualClass); ?>" style="<?php echo $package['is_annual'] ? 'display: none;' : ''; ?>">
1320 <ul class="price">
1321 <li class="header"><?php echo esc_html(ucwords($package['name'])); ?></li>
1322 <li class="grey">
1323 <?php echo esc_html($currency); ?>
1324 <?php echo esc_html(number_format($package['package_price'], 2)); ?> /
1325 <?php echo $package['is_annual'] ? esc_html__('Year', 'autowp') : esc_html__('Month', 'autowp'); ?>
1326 </li>
1327
1328 <li><?php echo esc_html($package['max_ai_generated_post_per_month']) . ' ' . esc_html__('AI-Generated Post per Month', 'autowp'); ?></li>
1329 <li><?php echo esc_html($package['max_ai_generated_image_per_month']) . ' ' . esc_html__('AI-Generated Image per Month', 'autowp'); ?></li>
1330 <li><?php echo esc_html__('Unlimited Websites', 'autowp'); ?></li>
1331 <li><?php echo esc_html__('Auto Indexing', 'autowp'); ?></li>
1332 <li><?php echo esc_html__('Social Media Sharing', 'autowp'); ?></li>
1333 <li><?php echo esc_html__('Auto Image Editing', 'autowp'); ?></li>
1334 <li class="grey"><a href="https://api.autowp.app/v2/subscribe?package_id=<?php echo esc_attr($package['id']); ?>&user_id=<?php echo esc_attr($user['user_id']); ?>" class="button"><?php echo esc_html__('Sign Up', 'autowp'); ?></a></li>
1335 </ul>
1336 </div>
1337 <?php
1338 }
1339 }
1340
1341 } else {
1342 echo '<div class="alert alert-info" role="alert">' .
1343 esc_html__('No packages available at the moment. Please check back later.', 'autowp') . ' ' .
1344 '</div>';
1345 }
1346
1347 echo '</div>';
1348 }
1349 ?>
1350
1351 </form>
1352
1353
1354 <?php
1355 }
1356
1357
1358
1359
1360 // Loading WP_List_Table class file
1361 // We need to load it as it's not automatically loaded by WordPress
1362 if (!class_exists('WP_List_Table')) {
1363 require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
1364 }
1365
1366
1367
1368
1369
1370
1371 function autowp_create_table() {
1372 global $wpdb;
1373 $table_name = $wpdb->prefix . 'autowp_wordpress_websites';
1374
1375 // Check if the table already exists
1376 $prepared_query = $wpdb->prepare("SHOW TABLES LIKE %s", $table_name);
1377 if ($wpdb->get_var($prepared_query) === $table_name) {
1378 return;
1379 }
1380
1381
1382 $charset_collate = $wpdb->get_charset_collate();
1383
1384 // Define the table structure
1385 $sql = "CREATE TABLE $table_name (
1386 `id` int(11) NOT NULL AUTO_INCREMENT,
1387 `website_name` varchar(255) NOT NULL,
1388 `website_type` text NOT NULL,
1389 `domain_name` varchar(255) NOT NULL,
1390 `category_id` text NOT NULL,
1391 `website_category_id` text NOT NULL,
1392 `aigenerated_title` text NOT NULL,
1393 `aigenerated_content` text NOT NULL,
1394 `aigenerated_tags` text NOT NULL,
1395 `aigenerated_image` text NOT NULL,
1396 `post_count` text NOT NULL,
1397 `post_order` text NOT NULL,
1398 `title_prompt` text NOT NULL,
1399 `content_prompt` text NOT NULL,
1400 `tags_prompt` text NOT NULL,
1401 `image_prompt` text NOT NULL,
1402 `image_generating_status` text NOT NULL,
1403 `author_selection` text NOT NULL,
1404
1405
1406 `news_time_published` text NOT NULL,
1407 `news_language` text NOT NULL,
1408 `news_country` text NOT NULL,
1409 `news_keyword` text NOT NULL,
1410
1411 PRIMARY KEY (`id`)
1412 );";
1413
1414
1415 // Include the necessary file for dbDelta()
1416 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
1417
1418 // Create the table
1419 dbDelta($sql);
1420 }
1421 register_activation_hook(__FILE__, 'autowp_create_table');
1422
1423
1424
1425 function autowp_create_table_or_update() {
1426 global $wpdb;
1427 $table_name = $wpdb->prefix . 'autowp_wordpress_websites';
1428
1429 // Tablo var mı kontrol et
1430 if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
1431 return; // Eğer tablo yoksa, değişiklik yapma
1432 }
1433
1434 // "active" sütunu var mı kontrol et?
1435 $column_exists = $wpdb->get_var("SELECT COUNT(*)
1436 FROM INFORMATION_SCHEMA.COLUMNS
1437 WHERE TABLE_NAME = '$table_name'
1438 AND COLUMN_NAME = 'active'");
1439
1440 if (!$column_exists) {
1441 // Eğer "active" sütunu yoksa, ekleyelim.
1442 $wpdb->query("ALTER TABLE $table_name ADD COLUMN active TINYINT(1) NOT NULL DEFAULT 1");
1443 }
1444
1445 }
1446
1447 // Güncellemeleri kontrol etmek için init hook'u kullan
1448 function autowp_check_for_updates() {
1449 autowp_create_table_or_update();
1450 }
1451
1452 add_action('init', 'autowp_check_for_updates');
1453
1454 register_activation_hook(__FILE__, 'autowp_check_for_updates');
1455
1456
1457
1458
1459
1460
1461 // Plugin menu callback function
1462 function autowp_automaticPost()
1463 {
1464 // Creating an instance
1465 $table = new AutoWP_Wordpress_Websites();
1466
1467 echo '<div class="wrap"><h2>SupportHost Admin Table</h2>';
1468 echo '<form method="post">';
1469
1470 // Add nonce field
1471 wp_nonce_field('autowp_websites_menu_nonce', '_wpnonce');
1472 // Prepare table
1473 $table->prepare_items();
1474 // Search form
1475 $table->search_box('search', 'search_id');
1476 // Display table
1477 $table->display();
1478 echo '</div></form>';
1479 }
1480
1481
1482 // Extending class
1483 class AutoWP_Wordpress_Websites extends WP_List_Table
1484 {
1485 // Here we will add our code
1486
1487 // Define table columns
1488 function get_columns()
1489 {
1490 $columns = array(
1491
1492 'cb' => '<input type="checkbox" />',
1493 'website_type' => __('Website Type', 'autowp'),
1494 'website_name' => __('Website Name', 'autowp'),
1495 'domain_name' => __('Domain Name', 'autowp'),
1496 'category_id' => __('Your Categories', 'autowp'),
1497 'website_category_id' => __('Website Categories', 'autowp'),
1498 'active' => __('Status', 'autowp'),
1499
1500 );
1501 return $columns;
1502 }
1503
1504 function column_active( $item ) {
1505 // Eğer değer 1 ise aktif, aksi durumda pasif
1506 if ( (int) $item['active'] !== 0 ) {
1507 // Dashicons kullanarak ikon ekleyelim: https://developer.wordpress.org/resource/dashicons/
1508 return '<span class="dashicons dashicons-yes" style="color:green;"></span> '
1509 . __('Active/Running', 'autowp');
1510 } else {
1511 return '<span class="dashicons dashicons-no-alt" style="color:red;"></span> '
1512 . __('Passive/Paused', 'autowp');
1513 }
1514 }
1515
1516
1517 // define $table_data property
1518 private $table_data;
1519
1520 // Bind table with columns, data and all
1521 function prepare_items()
1522 {
1523 //data
1524 if ( isset( $_POST['s'] ) && isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_websites_menu_nonce' ) ) {
1525 $search_query = sanitize_text_field($_POST['s']);
1526 $this->table_data = $this->get_table_data($search_query);
1527 } else {
1528 $this->table_data = $this->get_table_data();
1529 }
1530
1531
1532 $columns = $this->get_columns();
1533 $hidden = ( is_array(get_user_meta( get_current_user_id(), 'managetoplevel_page_list_tablecolumnshidden', true)) ) ? get_user_meta( get_current_user_id(), 'managetoplevel_page_list_tablecolumnshidden', true) : array();
1534 $sortable = $this->get_sortable_columns();
1535 $primary = 'name';
1536 $this->_column_headers = array($columns, $hidden, $sortable, $primary);
1537 $this->process_bulk_action();
1538 $this->table_data = $this->get_table_data();
1539
1540 usort($this->table_data, array($this, 'usort_reorder'));
1541
1542 /* pagination */
1543 $per_page = $this->get_items_per_page('elements_per_page', 10);
1544 $current_page = $this->get_pagenum();
1545 $total_items = count($this->table_data);
1546
1547 $this->table_data = array_slice($this->table_data, (($current_page - 1) * $per_page), $per_page);
1548
1549 $this->set_pagination_args(array(
1550 'total_items' => $total_items, // total number of items
1551 'per_page' => $per_page, // items to show on a page
1552 'total_pages' => ceil( $total_items / $per_page ) // use ceil to round up
1553 ));
1554
1555 $this->items = $this->table_data;
1556 }
1557
1558
1559
1560 function column_website_type($item) {
1561 // Website type bilgisini alıyoruz.
1562 $type = $item['website_type'];
1563
1564 // Her website type için ikon URL’lerini tanımlayan dizi:
1565 $icons = array(
1566 'wordpress' => plugins_url('assets/images/wordpress-icon.png', __FILE__),
1567 'rss' => plugins_url('assets/images/rss-icon.png', __FILE__),
1568 'ai' => plugins_url('assets/images/robot-icon.png', __FILE__),
1569 'news' => plugins_url('assets/images/gnews.png', __FILE__),
1570 'agenticscraper' => plugins_url('assets/images/robot-icon.png', __FILE__),
1571 );
1572
1573 // İlgili type için ikon URL'si; yoksa varsayılan ikon:
1574 $icon_url = isset($icons[$type]) ? $icons[$type] : plugins_url('assets/images/default-icon.png', __FILE__);
1575
1576 // Orijinal fonksiyonda website type'a göre edit sayfa slug'ı alınıyordu:
1577 $website_page = autowp_get_page_slug_from_website_type($type);
1578
1579 // Edit ve Delete linklerini oluşturuyoruz. URL'leri oluşturmak için admin_url() kullanıyoruz:
1580 $actions = array(
1581 'edit' => sprintf(
1582 '<a href="%s?page=%s&id=%s">%s</a>',
1583 admin_url('admin.php'),
1584 $website_page,
1585 $item['id'],
1586 __('Edit', 'autowp')
1587 ),
1588 'delete' => sprintf(
1589 '<a href="%s?page=%s&action=delete&id=%s">%s</a>',
1590 admin_url('admin.php'),
1591 sanitize_text_field($_REQUEST['page']),
1592 $item['id'],
1593 __('Delete', 'autowp')
1594 ),
1595 );
1596
1597 return sprintf(
1598 '<span style="display:inline-flex; align-items:center;">
1599 <img src="%s" alt="%s" style="width:40px; height:40px; margin-right:8px;">
1600 <strong>%s</strong>
1601 </span> %s',
1602 esc_url($icon_url),
1603 esc_attr($type),
1604 esc_html(strtoupper($type)), // İsterseniz burada büyük/küçük harf dönüşümü yapmadan doğrudan $type da kullanabilirsiniz.
1605 $this->row_actions($actions)
1606 );
1607 }
1608
1609
1610
1611
1612
1613
1614 // To show bulk action dropdown
1615 function get_bulk_actions()
1616 {
1617 $actions = array(
1618 'delete_all' => __('Delete', 'autowp'),
1619
1620 );
1621 return $actions;
1622 }
1623
1624 function process_bulk_action()
1625 {
1626 global $wpdb;
1627
1628 $table = $wpdb->prefix . 'autowp_wordpress_websites';
1629
1630 if ('delete_all' === $this->current_action() || ('delete' === $this->current_action() && isset($_REQUEST['id']))) {
1631 $request_id = isset($_REQUEST['id']) ? array_map('absint', (array) $_REQUEST['id']) : array();
1632
1633 if (!empty($request_id)) {
1634 // Prepare the DELETE query with proper escaping
1635 $placeholders = implode(',', array_fill(0, count($request_id), '%d'));
1636 $query = $wpdb->prepare("DELETE FROM $table WHERE id IN($placeholders)", $request_id);
1637
1638 // Execute the query
1639 $wpdb->query($query);
1640 }
1641 }
1642 }
1643
1644
1645
1646 // Get table data
1647 private function get_table_data( $search = '' ) {
1648 global $wpdb;
1649
1650 $table = $wpdb->prefix."autowp_wordpress_websites";
1651
1652
1653 if ( ! empty( $search ) ) {
1654 $prepared_search = $wpdb->esc_like( $search );
1655 $prepared_search = '%' . $wpdb->esc_like( $search ) . '%';
1656
1657 return $wpdb->get_results(
1658 $wpdb->prepare(
1659 "SELECT * FROM {$table} WHERE website_name LIKE %s OR domain_name LIKE %s OR category_id LIKE %s",
1660 $prepared_search,
1661 $prepared_search,
1662 $prepared_search
1663 ),
1664 ARRAY_A
1665 );
1666 } else {
1667
1668 return $wpdb->get_results(
1669 $wpdb->prepare(
1670 "SELECT * FROM {$table}",
1671 $table
1672 ),
1673 ARRAY_A
1674 );
1675
1676 }
1677 }
1678
1679 function column_default($item, $column_name)
1680 {
1681
1682
1683 switch ($column_name) {
1684 case 'id':
1685 case 'website_type':
1686 case 'website_name':
1687 case 'domain_name':
1688 case 'category_id':
1689 case 'website_category_id':
1690 default:
1691 return $item[$column_name];
1692 }
1693 }
1694
1695 function column_cb($item){
1696 return sprintf(
1697 '<input type="checkbox" name="id[]" value="%s" />',
1698 $item['id']
1699 );
1700 }
1701
1702 protected function get_sortable_columns(){
1703 $sortable_columns = array(
1704 'website_name' => array('website_name', false),
1705 'domain_name' => array('website_name', false),
1706 'id' => array('id', true)
1707 );
1708 return $sortable_columns;
1709 }
1710
1711 // Sorting function
1712 function usort_reorder($a, $b)
1713 {
1714 $sortable_columns = array('website_name', 'domain_name', 'id');
1715 $orderby = isset($_GET['orderby']) ? sanitize_key(wp_unslash($_GET['orderby'])) : 'website_name';
1716 $orderby = in_array($orderby, $sortable_columns, true) ? $orderby : 'website_name';
1717
1718 $order = isset($_GET['order']) ? strtolower(sanitize_text_field(wp_unslash($_GET['order']))) : 'asc';
1719 $order = ('desc' === $order) ? 'desc' : 'asc';
1720
1721 $value_a = isset($a[$orderby]) ? (string) $a[$orderby] : '';
1722 $value_b = isset($b[$orderby]) ? (string) $b[$orderby] : '';
1723 $result = strnatcasecmp($value_a, $value_b);
1724
1725 return ('asc' === $order) ? $result : -$result;
1726 }
1727
1728
1729
1730
1731 }
1732
1733 // add screen options
1734 function autowp_wordpress_websites_options() {
1735
1736 global $autowp_wordpress_website_list_page;
1737 global $table;
1738
1739 $screen = get_current_screen();
1740
1741 // get out of here if we are not on our settings page
1742 if(!is_object($screen) || $screen->id != $autowp_wordpress_website_list_page)
1743 return;
1744
1745 $args = array(
1746 'label' => __('Elements per page', 'autowp'),
1747 'default' => 2,
1748 'option' => 'elements_per_page'
1749 );
1750 add_screen_option( 'per_page', $args );
1751
1752 $table = new AutoWP_Wordpress_Websites();
1753
1754 }
1755
1756 function autowp_isValidDomain($domain) {
1757 // WordPress wp_http_validate_url fonksiyonunu kullanarak URL'yi doğrula
1758 $valid_url = wp_http_validate_url( $domain);
1759
1760 // Eğer geçerli bir URL dönerse, alan adı geçerlidir
1761 if (!is_wp_error($valid_url)) {
1762 return true;
1763 } else {
1764 return false;
1765 }
1766 }
1767
1768
1769 function autowp_is_site_working($site_url, $site_type) {
1770
1771
1772 $api_url = 'https://api.autowp.app/check_website'; // Flask API URL
1773
1774 // JSON formatında veriyi hazırlayın
1775 $body = json_encode([
1776 'site_url' => $site_url,
1777 'site_type' => $site_type,
1778 ]);
1779
1780 // WordPress'in HTTP API'si ile POST isteği gönderin
1781 $response = wp_remote_post($api_url, [
1782 'body' => $body,
1783 'headers' => [
1784 'Content-Type' => 'application/json',
1785 ],
1786 'timeout' => 5,
1787 ]);
1788
1789 // Eğer yanıt bir hata dönerse veya geçerli değilse false döner
1790 if (is_wp_error($response)) {
1791 return false;
1792 }
1793
1794 // Yanıtı alın ve JSON olarak çözümleyin
1795 $body = wp_remote_retrieve_body($response);
1796 $data = json_decode($body, true);
1797
1798 // Yanıtta 'valid' değeri varsa onu döndürün, aksi halde false döner
1799 return isset($data['valid']) ? $data['valid'] : false;
1800 }
1801
1802
1803 function autowp_validate_agenticscraper( $item, $is_manual = false ) {
1804 $messages = array();
1805
1806 // AgenticScraper için "content_prompt" (long description) zorunludur.
1807 if ( empty( $item['content_prompt'] ) ) {
1808 $messages[] = __( 'Long Description prompt is required for Agentic Scraper.', 'autowp' );
1809 }
1810
1811 // --- Custom Tools Doğrulamaları ---
1812
1813 // Website Tools: Eğer alan etkinse ve URL girilmişse, geçerli URL formatında olmalıdır.
1814 if ( ! empty( $item['enable_website_tools'] ) ) {
1815 if ( ! empty( $item['website_tools_knowledge_base_url'] ) ) {
1816 $url = esc_url_raw( trim( $item['website_tools_knowledge_base_url'] ) );
1817 if ( false === wp_http_validate_url( $url ) ) {
1818 $messages[] = __( 'Website Tools Knowledge Base URL is invalid.', 'autowp' );
1819 }
1820 }
1821 }
1822
1823 // DuckDuckGO Search: Eğer etkinse, girilmiş "Fixed Max Results" değeri sayısal olmalıdır.
1824 if ( ! empty( $item['enable_duckduckgo'] ) ) {
1825 if ( ! empty( $item['duckduckgo_fixed_max_results'] ) && ! is_numeric( $item['duckduckgo_fixed_max_results'] ) ) {
1826 $messages[] = __( 'Fixed Max Results for DuckDuckGO must be a number.', 'autowp' );
1827 }
1828 }
1829
1830 // Wikipedia: Aktifse, konu listesi girilmişse ek doğrulama gerekmez.
1831 // YFinanceTools ve Hacker News: Ek zorunlu doğrulama kuralları bulunmamaktadır.
1832
1833
1834 // --- Knowledge Base Doğrulamaları ---
1835 // PDF Knowledge Base: Eğer etkinse, URL girilmeli ve geçerli bir URL olmalıdır.
1836 if ( ! empty( $item['enable_pdf_kb'] ) ) {
1837 if ( empty( $item['pdf_url_knowledge_base'] ) ) {
1838 $messages[] = __( 'PDF Knowledge Base URL is required when enabled.', 'autowp' );
1839 } else {
1840 $url = esc_url_raw( trim( $item['pdf_url_knowledge_base'] ) );
1841 if ( false === wp_http_validate_url( $url ) ) {
1842 $messages[] = __( 'Invalid PDF Knowledge Base URL.', 'autowp' );
1843 }
1844 }
1845 }
1846
1847 // CSV Knowledge Base: Eğer etkinse, URL girilmeli ve geçerli bir URL olmalıdır.
1848 if ( ! empty( $item['enable_csv_kb'] ) ) {
1849 if ( empty( $item['csv_url_knowledge_base'] ) ) {
1850 $messages[] = __( 'CSV Knowledge Base URL is required when enabled.', 'autowp' );
1851 } else {
1852 $url = esc_url_raw( trim( $item['csv_url_knowledge_base'] ) );
1853 if ( false === wp_http_validate_url( $url ) ) {
1854 $messages[] = __( 'Invalid CSV Knowledge Base URL.', 'autowp' );
1855 }
1856 }
1857 }
1858
1859 // Text Knowledge Base: Eğer etkinse, metin alanı boş olmamalıdır.
1860 if ( ! empty( $item['enable_text_kb'] ) ) {
1861 if ( empty( $item['text_knowledge_base'] ) ) {
1862 $messages[] = __( 'Text Knowledge Base is required when enabled.', 'autowp' );
1863 }
1864 }
1865
1866 // --- Ortak Alanlar ---
1867 // Manuel gönderim değilse, "website_name" zorunludur.
1868 if ( empty( $item['website_name'] ) && ! $is_manual ) {
1869 $messages[] = __( 'Website name is required', 'autowp' );
1870 }
1871 if ( empty( $item['category_id'] ) ) {
1872 $messages[] = __( 'Category is required', 'autowp' );
1873 }
1874
1875 if ( empty( $messages ) ) {
1876 return true;
1877 }
1878 return implode( '<br />', $messages );
1879 }
1880
1881
1882
1883 function autowp_validate_website($item,$is_manual = false)
1884 {
1885 $messages = array();
1886
1887 if($item['website_type'] !== 'ai' && $item['website_type'] !== 'agenticscraper'){
1888
1889
1890
1891 if($item['website_type'] !== 'news'){
1892 if (empty($item['domain_name'])) $messages[] = __('Domain Name is required', 'autowp');
1893
1894
1895
1896 if(!autowp_is_site_working(sanitize_text_field($item['domain_name']), sanitize_text_field($item['website_type']))){
1897 $messages[] = __('Domain name should be valid.', 'autowp');
1898 }
1899
1900 }else{
1901
1902 if (empty($item['news_keyword'])) $messages[] = __('Keyword is required', 'autowp');
1903
1904 }
1905
1906
1907
1908 }else{
1909
1910 if(empty($item['title_prompt']) && empty($item['content_prompt']) && empty($item['tags_prompt']) && empty($item['image_prompt']) ){
1911 $messages[] = __('You should enter at least 1 prompt! ', 'autowp');
1912 }
1913
1914 if(str_contains($item['content_prompt'],'autowp-promptcode') && !autowp_validate_prompt_code($item['content_prompt'] )){
1915 $messages[] = __('invalid prompt code. ', 'autowp');
1916 }
1917
1918 if(str_contains($item['title_prompt'],'autowp-promptcode') || str_contains($item['tags_prompt'],'autowp-promptcode') || str_contains($item['image_prompt'],'autowp-promptcode') ){
1919 $messages[] = __('only content prompt can use prompt codes. ', 'autowp');
1920 }
1921
1922
1923 }
1924
1925 if (empty($item['website_name']) && !$is_manual) $messages[] = __('Website name is required', 'autowp');
1926 if (empty($item['category_id'])) $messages[] = __('Category is required', 'autowp');
1927
1928 if($item['website_type'] === 'news'){
1929
1930 if($item['news_country'] === 'any' && $item['news_language'] !== 'any' ){
1931 $messages[] = __('you should select a country! ', 'autowp');
1932
1933
1934 }
1935
1936 }
1937
1938 if (empty($messages)) return true;
1939 return implode('<br />', $messages);
1940 }
1941
1942
1943 function autowp_validate_prompt_code($input) {
1944 // "autowp-promptcode" yapısını arayın ve içeriğini alın
1945 preg_match('/\[autowp-promptcode\](.*?)\[\/autowp-promptcode\]/s', $input, $matches);
1946
1947 if (empty($matches) || count($matches) < 2) {
1948 // Eğer "autowp-promptcode" yapısı bulunamazsa veya içeriği eksikse false döndürün
1949 return false;
1950 }
1951
1952 $content = $matches[1]; // "autowp-promptcode" içeriğini alın
1953 $fields = explode(',', $content); // Virgülle ayrılmış alanları parçalayın
1954
1955 // Gerekli sayıda alanın olduğunu ve her bir alanın dolu olduğunu kontrol edin
1956 if (count($fields) != 6) {
1957 return false;
1958 }
1959
1960 foreach ($fields as $field) {
1961 if (empty(trim($field))) {
1962 return false;
1963 }
1964 }
1965
1966 return true; // Geçerli ise true döndürün
1967 }
1968
1969
1970 function autowp_get_last_cron_time($cron_name) {
1971 // _get_cron_array fonksiyonunu kullanarak cron görevlerini al
1972 $cron_array = _get_cron_array();
1973
1974 // autowp_cron görevinin en son çalışma zamanını al
1975 $last_execution_time = isset($cron_array[$cron_name]['schedule']) ? $cron_array[$cron_name]['schedule'] : 0;
1976
1977 // Zamanı okunabilir bir formata çevir (isteğe bağlı)
1978 $last_execution_time_readable = date('Y-m-d H:i:s', $last_execution_time);
1979
1980 // En son çalışma zamanını döndür
1981 return $last_execution_time_readable;
1982 }
1983
1984 function autowp_is_cron_executed_recently($cron_name) {
1985 // Cron'un en son çalışma zamanını al
1986 $last_execution_time = autowp_get_last_cron_time($cron_name);
1987
1988 // Şu anki zamanı al
1989 $current_time = time();
1990
1991 // 10 dakika önceki zamanı hesapla
1992 $ten_minutes_ago = $current_time - (10 * 60);
1993
1994 // Eğer en son çalışma zamanı 10 dakika içindeyse true döndür, aksi takdirde false döndür
1995 return $last_execution_time >= $ten_minutes_ago;
1996 }
1997
1998
1999
2000
2001 function autowp_settings_page_set_options() {
2002 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
2003
2004
2005 $url = 'https://api.autowp.app/confirm_email';
2006
2007 if ( isset( $server_url )
2008 && $server_url !== null
2009 && $server_url !== ''
2010 && strpos( $server_url, 'autowp.app' ) === false
2011 ) {
2012
2013 $url = $server_url . '/confirm_email';
2014
2015 }
2016
2017
2018
2019
2020
2021 if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_settings_nonce')) {
2022
2023 $time_value_type = sanitize_text_field($_POST["selected_time_type"]);
2024 $user_wpcron_time = autowp_get_wpcron_time($time_value_type);
2025
2026 // API email and API key to be sent to the Flask API for confirmation
2027 $api_email = sanitize_text_field($_POST["api_email"]);
2028 $api_key = sanitize_text_field($_POST["api_key"]);
2029
2030 // API request body
2031 $api_request_body = array(
2032 'body' => json_encode(array(
2033 'user_email' => $api_email,
2034 'api_key' => $api_key,
2035 )),
2036 'headers' => array(
2037 'Content-Type' => 'application/json'
2038 ),
2039 );
2040
2041 // Send a POST request to the Flask API
2042 $api_response = wp_remote_post($url, $api_request_body);
2043
2044 // Check for errors in the API response
2045 $save_api_key_email = false;
2046 if (!is_wp_error($api_response)) {
2047 $response_code = wp_remote_retrieve_response_code($api_response);
2048 $response_body = json_decode(wp_remote_retrieve_body($api_response), true);
2049
2050 if ($response_code === 200 && isset($response_body['message']) && $response_body['message'] === 'Successfully confirmed!') {
2051 // If the API confirms successfully, save the API key and email
2052 $save_api_key_email = true;
2053 } else {
2054 // If there's an error in the API response, show the error message
2055 echo '<div class="alert alert-danger" role="alert">' . esc_html__('Error: ' . $response_body['error'], 'autowp') . '</div>';
2056 }
2057 } else {
2058 // If there's a request error
2059 $error_message = $api_response->get_error_message();
2060 echo '<div class="alert alert-danger" role="alert">' . esc_html__('API Request Error: ' . $error_message, 'autowp') . '</div>';
2061 }
2062
2063 $existing_settings_serialized = get_option('autowp_settings');
2064 if ($existing_settings_serialized) {
2065 $existing_settings = unserialize($existing_settings_serialized);
2066 } else {
2067 $existing_settings = array();
2068 }
2069
2070 // Prepare data to save
2071 $received_data = array(
2072 "selected_time_type" => sanitize_text_field($_POST["selected_time_type"]),
2073 "wpcron_status" => sanitize_text_field($_POST['wpcron_status']),
2074 "watermark_link" => sanitize_text_field($_POST['watermark_link']),
2075 "nano_banana_prompt" => sanitize_text_field($_POST['nano_banana_prompt']),
2076 "image_modification_status" => sanitize_text_field($_POST['image_modification_status']),
2077 "ai_image_width" => absint($_POST['ai_image_width']),
2078 "ai_image_height" => absint($_POST['ai_image_height']),
2079 "stable_diffusion_style" => sanitize_text_field($_POST['stable_diffusion_style']),
2080 "flux_image_size" => sanitize_text_field($_POST['flux_image_size']),
2081 "stable_diffusion_size" => sanitize_text_field($_POST['stable_diffusion_size']),
2082 "dalle_2_size" => sanitize_text_field($_POST['dalle_2_size']),
2083 "dalle_3_size" => sanitize_text_field($_POST['dalle_3_size']),
2084 "dalle_3_style" => sanitize_text_field($_POST["dalle_3_style"]),
2085 "image_format" => sanitize_text_field($_POST["image_format"]),
2086 "post_status" => sanitize_text_field($_POST['post_status']),
2087 "content_image_generation_method" => sanitize_text_field($_POST['content_image_generation_method']),
2088
2089 // New fields
2090 "max_posts_per_cron" => absint($_POST['max_posts_per_cron']),
2091 "max_posts_per_day" => absint($_POST['max_posts_per_day']),
2092 "spam_ad_filter" => sanitize_text_field($_POST['spam_ad_filter']),
2093 "duplicate_content_filter" => sanitize_text_field($_POST['duplicate_content_filter']),
2094
2095 // New fields
2096 "openai_api_key" => sanitize_text_field($_POST['openai_api_key']),
2097 "xai_api_key" => sanitize_text_field($_POST['xai_api_key']),
2098 "falai_api_key" => sanitize_text_field($_POST['falai_api_key']),
2099 "stabilityai_api_key" => sanitize_text_field($_POST['stabilityai_api_key']),
2100 "serperdev_api_key" => sanitize_text_field($_POST['serperdev_api_key']),
2101 "primary_llm" => sanitize_text_field($_POST['primary_llm']),
2102 "secondary_llm" => sanitize_text_field($_POST['secondary_llm']),
2103 "deepseek_api_key" => sanitize_text_field(($_POST['deepseek_api_key'])),
2104 "groq_model" => sanitize_text_field($_POST['groq_model']),
2105 "default_image_url" => sanitize_url(($_POST['default_image_url'])),
2106
2107 // Social media sharing settings
2108 "social_media_status" => sanitize_text_field($_POST['social_media_status']),
2109 "twitter_api_key" => sanitize_text_field($_POST['twitter_api_key']),
2110 "telegram_api_key" => sanitize_text_field($_POST['telegram_api_key']),
2111 "instagram_api_key" => sanitize_text_field($_POST['instagram_api_key']),
2112 "openai_base_url" => sanitize_text_field($_POST['openai_base_url']),
2113
2114 "autowp_server_url" => sanitize_text_field($_POST['autowp_server_url'])
2115
2116
2117 );
2118
2119
2120 // API e-posta ve anahtarını sadece API başarılı şekilde onaylanırsa kaydedin
2121 if ($save_api_key_email) {
2122 $received_data["api_key"] = $api_key;
2123 $received_data["api_email"] = $api_email;
2124 } else {
2125 // Mevcut API anahtarı ve e-postayı koru
2126 if (isset($existing_settings["api_key"])) {
2127 $received_data["api_key"] = $existing_settings["api_key"];
2128 }
2129 if (isset($existing_settings["api_email"])) {
2130 $received_data["api_email"] = $existing_settings["api_email"];
2131 }
2132 }
2133
2134 // Serialize and save the data
2135 $save = serialize($received_data);
2136 update_option('autowp_settings', $save, "yes");
2137
2138 // Show success message if successfully saved, if not show error message
2139 if (get_option('autowp_settings') == $save) {
2140 echo '<div class="alert alert-success" role="alert">' . esc_html__('Settings saved successfully!', 'autowp') . '</div>';
2141 } else {
2142 echo '<div class="alert alert-danger" role="alert">' . esc_html__('Error saving settings!', 'autowp') . '</div>';
2143 }
2144
2145 // Schedule WP-Cron
2146 if (!wp_next_scheduled('autowp_cron')) {
2147 wp_schedule_event(time(), $user_wpcron_time, 'autowp_cron');
2148 } else {
2149 wp_clear_scheduled_hook('autowp_cron');
2150 wp_schedule_event(time(), $user_wpcron_time, 'autowp_cron');
2151 }
2152 }
2153 }
2154
2155
2156 function autowp_linking_page_handler() {
2157 // Veritabanından mevcut linkleme ayarlarını yükle
2158 $linking_settings = get_option('autowp_linking_settings', []);
2159 if (!is_array($linking_settings)) {
2160 $linking_settings = maybe_unserialize($linking_settings);
2161 if (!is_array($linking_settings)) {
2162 $linking_settings = [];
2163 }
2164 }
2165
2166 // Form gönderildiğinde veriyi işle
2167 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2168 if (isset($_POST['add_link'])) {
2169 // Nonce kontrolü
2170 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_add_link_nonce')) {
2171 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2172 }
2173
2174 // Kullanıcı girişlerini temizleme
2175 $keyword = sanitize_text_field($_POST['keyword']);
2176 $link = esc_url_raw($_POST['link']);
2177 $html_tag = sanitize_text_field($_POST['html_tag']);
2178 $link_count = sanitize_text_field($_POST['link_count']);
2179
2180 // Boş değer kontrolü
2181 // "a" etiketi seçildiyse, URL zorunludur. Diğer etiketler için URL gerekmiyor.
2182 if (empty($keyword)) {
2183 echo '<div class="alert alert-danger" role="alert">Keyword field cannot be empty!</div>';
2184 } elseif ($html_tag === "a" && empty($link)) {
2185 echo '<div class="alert alert-danger" role="alert">Error: A URL is required when selecting the "a" (anchor link) tag.</div>';
2186 } else {
2187 // Yeni linkleme ayarını oluştur
2188 $new_link = [
2189 'keyword' => $keyword,
2190 'link' => ($html_tag === "a") ? $link : '', // Sadece "a" etiketi için URL ekle
2191 'html_tag' => $html_tag,
2192 'link_count' => $link_count,
2193 ];
2194 $linking_settings[] = $new_link;
2195
2196 // Veriyi veritabanına kaydet
2197 update_option('autowp_linking_settings', $linking_settings);
2198 echo '<div class="alert alert-success" role="alert">Your linking setting has been saved!</div>';
2199 }
2200
2201 } elseif (isset($_POST['delete_link'])) {
2202 // Nonce kontrolü
2203 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_delete_link_nonce')) {
2204 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2205 }
2206
2207 // Silinecek indexi al
2208 $index_to_delete = intval($_POST['delete_index']);
2209 array_splice($linking_settings, $index_to_delete, 1);
2210
2211 // Güncellenmiş listeyi kaydet
2212 update_option('autowp_linking_settings', $linking_settings);
2213 echo '<div class="alert alert-success" role="alert">Your linking setting has been deleted!</div>';
2214 }
2215 }
2216
2217 ?>
2218
2219 <div class="wrap">
2220 <h2 class="mb-4"><?php echo esc_html__('Linking Management', 'autowp'); ?></h2>
2221
2222 <form method="post" class="mb-4">
2223 <?php wp_nonce_field('autowp_add_link_nonce', 'autowp_nonce'); ?>
2224
2225 <div class="mb-3">
2226 <label for="keyword" class="form-label"><?php echo esc_html__('Keyword', 'autowp'); ?></label>
2227 <input type="text" id="keyword" name="keyword" required class="form-control" />
2228 </div>
2229
2230 <div class="mb-3">
2231 <label for="link" class="form-label"><?php echo esc_html__('Link (URL)', 'autowp'); ?></label>
2232 <input type="url" id="link" name="link" class="form-control" />
2233 </div>
2234
2235 <div class="mb-3">
2236 <label for="html_tag" class="form-label"><?php echo esc_html__('HTML Tag', 'autowp'); ?></label>
2237 <select id="html_tag" name="html_tag" class="form-control" required>
2238 <option value="a">Anchor Link (&lt;a&gt;)</option>
2239 <option value="strong">Bold Text (&lt;strong&gt;)</option>
2240 <option value="span">Span Element (&lt;span&gt;)</option>
2241 <option value="em">Italic Text (&lt;em&gt;)</option>
2242 </select>
2243 <small class="form-text text-muted">Choose how the link should be wrapped.</small>
2244 </div>
2245
2246 <div class="mb-3">
2247 <label for="link_count" class="form-label"><?php echo esc_html__('Linking Count', 'autowp'); ?></label>
2248 <select id="link_count" name="link_count" class="form-control" required>
2249 <option value="all">All Keywords</option>
2250 <option value="1">1</option>
2251 <option value="2">2</option>
2252 <option value="3">3</option>
2253 <option value="4">4</option>
2254 <option value="5">5</option>
2255 </select>
2256 <small class="form-text text-muted">Select how many times the keyword should be linked.</small>
2257 </div>
2258
2259 <button type="submit" name="add_link" class="btn btn-primary"><?php echo esc_attr__('Save Link Setting', 'autowp'); ?></button>
2260 </form>
2261
2262 <h3 class="mt-5 mb-3"><?php echo esc_html__('Existing Linking Settings', 'autowp'); ?></h3>
2263 <ul class="list-group">
2264 <?php foreach ($linking_settings as $index => $setting) { ?>
2265 <li class="list-group-item d-flex justify-content-between align-items-start">
2266 <div>
2267 <strong>Keyword:</strong> <?php echo esc_html($setting['keyword']); ?><br>
2268 <strong>Link:</strong>
2269 <?php
2270 if ($setting['html_tag'] === "a" && !empty($setting['link'])) {
2271 echo '<a href="' . esc_url($setting['link']) . '" target="_blank" rel="noopener noreferrer">' . esc_html($setting['link']) . '</a>';
2272 } else {
2273 echo "N/A"; // Eğer "a" değilse veya link yoksa, "N/A" göster
2274 }
2275 ?><br>
2276
2277 <strong>HTML Tag:</strong> <?php echo esc_html($setting['html_tag']); ?><br>
2278 <strong>Linking Count:</strong> <?php echo esc_html($setting['link_count']); ?>
2279 </div>
2280 <div>
2281 <form method="post">
2282 <?php wp_nonce_field('autowp_delete_link_nonce', 'autowp_nonce'); ?>
2283 <input type="hidden" name="delete_index" value="<?php echo esc_attr($index); ?>">
2284 <button type="submit" name="delete_link" class="btn btn-danger btn-sm">Delete</button>
2285 </form>
2286 </div>
2287 </li>
2288 <?php } ?>
2289 </ul>
2290 </div>
2291
2292 <?php
2293 }
2294
2295
2296
2297
2298 function autowp_rewriting_promptscheme_page_handler() {
2299 // Veritabanından mevcut ayarları yükle
2300 $prompts = get_option('autowp_rewriting_promptscheme', []);
2301 if (!is_array($prompts)) {
2302 $prompts = maybe_unserialize($prompts); // Serileştirilmiş veriyi çözümleme
2303 if (!is_array($prompts)) {
2304 $prompts = []; // Eğer hala dizi değilse, boş bir diziye ayarla
2305 }
2306 }
2307
2308
2309 // Formdan gelen veriyi işle (ekleme, silme, sıralama değiştirme)
2310 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2311 if (isset($_POST['add_prompt'])) {
2312
2313 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_add_prompt_nonce')) {
2314 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2315 }
2316
2317
2318
2319 $element_type = sanitize_text_field($_POST['element_type']);
2320 $detailed_prompt = '';
2321 $is_content_or_blank = false;
2322
2323
2324 if($element_type == 'static-content'){
2325 $detailed_prompt = wp_kses_post($_POST['content']);
2326 $is_content_or_blank = ($detailed_prompt == '' or $detailed_prompt == null);
2327 }else{
2328 $detailed_prompt = sanitize_text_field($_POST['prompt']);
2329 $is_content_or_blank = ($detailed_prompt == '' or $detailed_prompt == null);
2330 }
2331
2332
2333
2334 // Ekleme sırasında kontroller
2335 if (count($prompts) >= 10 or $is_content_or_blank) {
2336 echo '<div class="alert alert-danger" role="alert">Maximum 10 prompts allowed and prompt/content cannot be empty!</div>';
2337 } else {
2338
2339 // Kelime sınırı kontrolü
2340 $prompt_words = explode(" ", $_POST['prompt']);
2341 if (count($prompt_words) > 300) {
2342 echo '<div class="alert alert-danger" role="alert">Detailed Prompt should not exceed 300 words.</div>';
2343 } else {
2344
2345 $new_prompt = [
2346 'name' => sanitize_text_field($_POST['name']),
2347 'detailed_prompt' => $detailed_prompt,
2348 'element_type' => sanitize_text_field($_POST['element_type']),
2349 ];
2350 $prompts[] = $new_prompt;
2351 echo '<div class="alert alert-success" role="alert">Your prompt successfully added to scheme!</div>';
2352 }
2353 }
2354 } elseif (isset($_POST['delete_prompt'])) {
2355 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_delete_prompt_nonce')) {
2356 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2357 }
2358
2359 $index_to_delete = intval($_POST['delete_index']);
2360 array_splice($prompts, $index_to_delete, 1);
2361 echo '<div class="alert alert-success" role="alert">Your prompt successfully deleted!</div>';
2362 } elseif (isset($_POST['move_up'])) {
2363 $index = intval($_POST['index']);
2364 if ($index > 0) {
2365 $temp = $prompts[$index - 1];
2366 $prompts[$index - 1] = $prompts[$index];
2367 $prompts[$index] = $temp;
2368 echo '<div class="alert alert-success" role="alert">Your prompt successfully move up!</div>';
2369 }
2370 } elseif (isset($_POST['move_down'])) {
2371 $index = intval($_POST['index']);
2372 if ($index < count($prompts) - 1) {
2373 $temp = $prompts[$index + 1];
2374 $prompts[$index + 1] = $prompts[$index];
2375 $prompts[$index] = $temp;
2376 echo '<div class="alert alert-success" role="alert">Your prompt successfully move down!</div>';
2377 }
2378 } elseif (isset($_POST['add_template'])) {
2379 $template_name = sanitize_text_field($_POST['template_name']);
2380 $template_prompt = sanitize_text_field($_POST['template_prompt']);
2381 if (count($prompts) >= 10) {
2382 echo '<div class="alert alert-danger" role="alert">Maximum 10 prompts allowed.</div>';
2383 } else {
2384 $new_prompt = [
2385 'name' => $template_name,
2386 'detailed_prompt' => $template_prompt,
2387 'max_tokens' => 300000
2388 ];
2389 $prompts[] = $new_prompt;
2390 echo '<div class="alert alert-success" role="alert">Your prompt successfully added to scheme!</div>';
2391 }
2392 }
2393 update_option('autowp_rewriting_promptscheme', $prompts);
2394 }
2395
2396 // HTML form ve mevcut verileri göster
2397 ?>
2398 <div class="wrap">
2399 <h2 class="mb-4"><?php echo esc_html__('Content Planner', 'autowp'); ?></h2>
2400
2401 <form method="post" class="mb-4">
2402 <?php wp_nonce_field('autowp_add_prompt_nonce', 'autowp_nonce'); ?>
2403 <div class="mb-3">
2404 <label for="name" class="form-label"><?php echo esc_html__('Name', 'autowp'); ?></label>
2405 <input type="text" id="name" name="name" required class="form-control" />
2406 </div>
2407
2408
2409 <div class="mb-3" id="prompt-container">
2410 <label for="prompt" class="form-label"><?php echo esc_html__('Detailed Prompt', 'autowp'); ?></label>
2411 <div class="tag-buttons mb-2">
2412 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{new_title}')">Post Title</button>
2413 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{language_code}')">Language Name</button>
2414 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{focus_keyword}')">Focus Keyword</button>
2415 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{combined_content}')">Original Content</button>
2416 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{subheading_count}')">Subheading Count</button>
2417 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{narration_style}')">Narration Style</button>
2418 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{related_keywords}')">Related Keywords</button>
2419 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{original_link}')">Original Link</button>
2420 </div>
2421 <textarea id="prompt" name="prompt" rows="4" maxlength="1500" class="form-control"></textarea>
2422
2423 <small class="form-text text-muted">Maximum 300 words.</small>
2424 </div>
2425
2426 <!-- Static Content (hidden by default) -->
2427 <div class="mb-3" id="content-container" style="display: none;">
2428
2429 <label for="content" class="form-label"><?php echo esc_html__('HTML Content', 'autowp'); ?></label>
2430 <div class="tag-buttons mb-2">
2431 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<h1>Your Heading</h1>')">Heading 1</button>
2432 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<h2>Your Subheading</h2>')">Heading 2</button>
2433 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<p>Your paragraph text goes here.</p>')">Paragraph</button>
2434 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<img src=\'your-image-url.jpg\' alt=\'Image description\' />')">Image</button>
2435 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<blockquote>Your blockquote text.</blockquote>')">Blockquote</button>
2436 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<pre><code>Your code goes here.</code></pre>')">Code Block</button>
2437 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<ul><li>Item 1</li><li>Item 2</li></ul>')">Unordered List</button>
2438 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<ol><li>Item 1</li><li>Item 2</li></ol>')">Ordered List</button>
2439 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<hr />')">Horizontal Line</button>
2440 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertHTMLTag('<br />')">Line Break</button>
2441
2442 </div>
2443 <textarea id="content" name="content" rows="6" class="form-control"></textarea>
2444 <small class="form-text text-muted">Enter custom HTML content for static generation.</small>
2445 </div>
2446
2447
2448
2449
2450 <!-- Element Type Select -->
2451 <div class="mb-3">
2452 <label for="element_type" class="form-label"><?php echo esc_html__('HTML Tag Type', 'autowp'); ?></label>
2453 <select id="element_type" name="element_type" class="form-control" required>
2454 <option value="p">Paragraph (&lt;p&gt;)</option>
2455 <option value="ph2">Paragraphs with H2 Subheadings (&lt;p&gt;,&lt;h2&gt;)</option>
2456 <option value="h1">Subheading H1 (&lt;h1&gt;)</option>
2457 <option value="h2">Subheading H2 (&lt;h2&gt;)</option>
2458 <option value="h3">Subheading H3 (&lt;h3&gt;)</option>
2459 <option value="h4">Subheading H4 (&lt;h4&gt;)</option>
2460 <option value="h5">Subheading H5 (&lt;h5&gt;)</option>
2461 <option value="h6">Subheading H6 (&lt;h6&gt;)</option>
2462 <option value="img">AI-Generated Image (&lt;img&gt;)</option>
2463 <option value="blockquote">Block Quote (&lt;blockquote&gt;)</option>
2464 <option value="code">Code Block (&lt;code&gt;)</option>
2465 <option value="table">HTML Table (&lt;table&gt;)</option>
2466 <option value="faq">FAQ (Without Heading) </option>
2467 <option value="static-content">Static HTML Content</option>
2468 <option value="ai-generated-html">AI-Generated HTML Part</option>
2469
2470
2471 </select>
2472 <small class="form-text text-muted">Select the HTML element type for content generation (e.g., paragraphs, subheadings).</small>
2473 </div>
2474 <button type="submit" name="add_prompt" class="btn btn-primary"><?php echo esc_attr__('Add Prompt', 'autowp'); ?></button>
2475 </form>
2476
2477 <h3 class="mb-3"><?php echo esc_html__('Ready-Made Templates', 'autowp'); ?></h3>
2478 <!-- Template butonları için ayrı form yapıları -->
2479 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2480 <input type="hidden" name="add_template" value="true">
2481 <input type="hidden" name="template_name" value="AutoWP Introduction">
2482 <input type="hidden" name="template_prompt" value="autowp-introduction">
2483 <button type="submit" class="btn btn-secondary">Add Introduction Template</button>
2484 </form>
2485 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2486 <input type="hidden" name="add_template" value="true">
2487 <input type="hidden" name="template_name" value="AutoWP Subheadings">
2488 <input type="hidden" name="template_prompt" value="autowp-subheadings">
2489 <button type="submit" class="btn btn-secondary">Add Subheadings Template</button>
2490 </form>
2491 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2492 <input type="hidden" name="add_template" value="true">
2493 <input type="hidden" name="template_name" value="AutoWP FAQ">
2494 <input type="hidden" name="template_prompt" value="autowp-faq">
2495 <button type="submit" class="btn btn-secondary">Add FAQ Template</button>
2496 </form>
2497 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2498 <input type="hidden" name="add_template" value="true">
2499 <input type="hidden" name="template_name" value="AutoWP Results">
2500 <input type="hidden" name="template_prompt" value="autowp-result">
2501 <button type="submit" class="btn btn-secondary">Add Table + Results Template</button>
2502 </form>
2503
2504 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2505 <input type="hidden" name="add_template" value="true">
2506 <input type="hidden" name="template_name" value="AutoWP Source Link">
2507 <input type="hidden" name="template_prompt" value="autowp-source-link">
2508 <button type="submit" class="btn btn-secondary">Add Source Link Template</button>
2509 </form>
2510
2511 <h3 class="mt-5 mb-3"><?php echo esc_html__('Existing Prompts', 'autowp'); ?></h3>
2512 <ul class="list-group">
2513 <?php foreach ($prompts as $index => $prompt) { ?>
2514 <li class="list-group-item d-flex justify-content-between align-items-start">
2515 <div>
2516 <strong>Prompt or Content: </strong><pre style="white-space: pre-wrap;"><?php echo esc_html($prompt['detailed_prompt']); ?></pre><br>
2517
2518 <strong>Element Type: </strong><?php echo isset($prompt['element_type']) ? esc_html($prompt['element_type']) : 'AutoWP Template'; ?><br>
2519 </div>
2520 <div class="btn-group">
2521 <form method="post" style="display: inline;">
2522 <?php wp_nonce_field('autowp_delete_prompt_nonce', 'autowp_nonce'); ?>
2523 <input type="hidden" name="delete_index" value="<?php echo esc_attr($index); ?>">
2524 <button type="submit" name="delete_prompt" class="btn btn-danger btn-sm">×</button>
2525 </form>
2526 <?php if ($index > 0) { ?>
2527 <form method="post" style="display: inline;">
2528 <input type="hidden" name="index" value="<?php echo esc_attr($index); ?>">
2529 <button type="submit" name="move_up" class="btn btn-link btn-sm text-primary"></button>
2530 </form>
2531 <?php } ?>
2532 <?php if ($index < count($prompts) - 1) { ?>
2533 <form method="post" style="display: inline;">
2534 <input type="hidden" name="index" value="<?php echo esc_attr($index); ?>">
2535 <button type="submit" name="move_down" class="btn btn-link btn-sm text-primary"></button>
2536 </form>
2537 <?php } ?>
2538 </div>
2539 </li>
2540 <?php } ?>
2541 </ul>
2542
2543 </div>
2544 <?php
2545 }
2546
2547
2548
2549 function autowp_writing_promptscheme_page_handler() {
2550 // Veritabanından mevcut ayarları yükle
2551 $prompts = get_option('autowp_writing_promptscheme', []);
2552
2553 // Formdan gelen veriyi işle (ekleme, silme, sıralama değiştirme)
2554 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
2555 if (isset($_POST['add_prompt'])) {
2556
2557 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_add_prompt_nonce')) {
2558 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2559 }
2560
2561
2562 // Ekleme sırasında kontroller
2563 if (count($prompts) >= 5) {
2564 echo '<div class="alert alert-danger" role="alert">Maximum 5 prompts allowed.</div>';
2565 } else {
2566
2567 // Kelime sınırı kontrolü
2568 $prompt_words = explode(" ", $_POST['prompt']);
2569 if (count($prompt_words) > 300) {
2570 echo '<div class="alert alert-danger" role="alert">Detailed Prompt should not exceed 300 words.</div>';
2571 } else {
2572 $new_prompt = [
2573 'name' => sanitize_text_field($_POST['name']),
2574 'detailed_prompt' => sanitize_textarea_field($_POST['prompt']),
2575 'max_tokens' => intval($_POST['tokens'])
2576 ];
2577 $prompts[] = $new_prompt;
2578 echo '<div class="alert alert-success" role="alert">Your prompt successfully added to scheme!</div>';
2579
2580 }
2581 }
2582 } elseif (isset($_POST['delete_prompt'])) {
2583 if (!isset($_POST['autowp_nonce']) || !wp_verify_nonce($_POST['autowp_nonce'], 'autowp_delete_prompt_nonce')) {
2584 wp_die(esc_html__('Invalid request. Nonce verification failed.', 'autowp'));
2585 }
2586
2587 $index_to_delete = intval($_POST['delete_index']);
2588 array_splice($prompts, $index_to_delete, 1);
2589 echo '<div class="alert alert-success" role="alert">Your prompt successfully deleted!</div>';
2590
2591 } elseif (isset($_POST['move_up'])) {
2592 $index = intval($_POST['index']);
2593 if ($index > 0) {
2594 $temp = $prompts[$index - 1];
2595 $prompts[$index - 1] = $prompts[$index];
2596 $prompts[$index] = $temp;
2597 echo '<div class="alert alert-success" role="alert">Your prompt successfully move up!</div>';
2598
2599 }
2600 } elseif (isset($_POST['move_down'])) {
2601 $index = intval($_POST['index']);
2602 if ($index < count($prompts) - 1) {
2603 $temp = $prompts[$index + 1];
2604 $prompts[$index + 1] = $prompts[$index];
2605 $prompts[$index] = $temp;
2606 echo '<div class="alert alert-success" role="alert">Your prompt successfully move down!</div>';
2607
2608 }
2609 } elseif (isset($_POST['add_template'])) {
2610 $template_name = sanitize_text_field($_POST['template_name']);
2611 $template_prompt = sanitize_text_field($_POST['template_prompt']);
2612 if (count($prompts) >= 5) {
2613
2614 echo '<div class="alert alert-danger" role="alert">Maximum 5 prompts allowed.</div>';
2615
2616
2617 }else{
2618
2619 $new_prompt = [
2620 'name' => $template_name,
2621 'detailed_prompt' => $template_prompt,
2622 'max_tokens' => 3000
2623 ];
2624 $prompts[] = $new_prompt;
2625 echo '<div class="alert alert-success" role="alert">Your prompt successfully added to scheme!</div>';
2626
2627
2628 }
2629
2630 }
2631 update_option('autowp_writing_promptscheme', $prompts);
2632 }
2633
2634 // HTML form ve mevcut verileri göster
2635 ?>
2636 <div class="wrap">
2637 <h2 class="mb-4"><?php echo esc_html__('Writing Prompt Schemes', 'autowp'); ?></h2>
2638 <a class="btn btn-secondary mb-4" href="<?php echo esc_url(admin_url('admin.php?page=autowp_promptSettings')); ?>"><?php echo esc_html__('Back', 'autowp'); ?></a>
2639
2640 <form method="post" class="mb-4">
2641 <div class="mb-3">
2642 <label for="name" class="form-label"><?php echo esc_html__('Name', 'autowp'); ?></label>
2643 <input type="text" id="name" name="name" required class="form-control" />
2644 </div>
2645 <div class="mb-3">
2646 <label for="prompt" class="form-label"><?php echo esc_html__('Detailed Prompt', 'autowp'); ?></label>
2647 <!-- Tag Buttons -->
2648 <div class="tag-buttons mb-2">
2649 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{new_title}')">New Title</button>
2650 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{language_code}')">Language Code</button>
2651 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{focus_keyword}')">Focus Keyword</button>
2652 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{combined_content}')">Combined Content</button>
2653 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{subheading_count}')">Subheading Count</button>
2654 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{narration_style}')">Narration Style</button>
2655 <button type="button" class="btn btn-sm btn-outline-primary" onclick="insertTag('{related_keywords}')">Related Keywords</button>
2656 </div>
2657 <textarea id="prompt" name="prompt" required rows="4" maxlength="1500" class="form-control"></textarea>
2658 <small class="form-text text-muted">Maximum 300 words.</small>
2659 <br><br>
2660 <div class="alert alert-info" role="alert">
2661 <h4 class="alert-heading">Prompt Codes</h4>
2662 <p>$keywords: If you have selected Google Trends, it will return the most talked about topics related to your keyword on Trends. If you have selected "aigenerated", it will return the keywords with the highest search volume related to your keyword in search engines.</p>
2663
2664 </div>
2665 </div>
2666 <div class="mb-3">
2667 <label for="tokens" class="form-label"><?php echo esc_html__('Maximum Tokens', 'autowp'); ?></label>
2668 <input type="number" id="tokens" name="tokens" required min="300" max="1000" class="form-control" />
2669 </div>
2670 <button type="submit" name="add_prompt" class="btn btn-primary"><?php echo esc_attr__('Add Prompt', 'autowp'); ?></button>
2671 </form>
2672
2673 <h3 class="mb-3"><?php echo esc_html__('Ready-Made Templates', 'autowp'); ?></h3>
2674 <!-- Template butonları için ayrı form yapıları -->
2675 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2676 <input type="hidden" name="add_template" value="true">
2677 <input type="hidden" name="template_name" value="AutoWP Introduction">
2678 <input type="hidden" name="template_prompt" value="autowp-introduction">
2679 <button type="submit" class="btn btn-secondary">Add Introduction Template</button>
2680 </form>
2681 <form method="post" class="d-grid gap-2 d-md-block mb-3">
2682 <input type="hidden" name="add_template" value="true">
2683 <input type="hidden" name="template_name" value="AutoWP Subheadings">
2684 <input type="hidden" name="template_prompt" value="autowp-subheadings">
2685 <button type="submit" class="btn btn-secondary">Add Subheadings Template</button>
2686 </form>
2687 <form method="post" class="d-grid gap-2 d-md-block">
2688 <input type="hidden" name="add_template" value="true">
2689 <input type="hidden" name="template_name" value="AutoWP Results">
2690 <input type="hidden" name="template_prompt" value="autowp-result">
2691 <button type="submit" class="btn btn-secondary">Add Results Template</button>
2692 </form>
2693
2694 <h3 class="mt-5 mb-3"><?php echo esc_html__('Existing Prompts', 'autowp'); ?></h3>
2695 <ul class="list-group">
2696 <?php foreach ($prompts as $index => $prompt) { ?>
2697 <li class="list-group-item d-flex justify-content-between align-items-start">
2698 <?php echo esc_html($prompt['name'] . ' - ' . $prompt['detailed_prompt'] . ' (Max Tokens: ' . $prompt['max_tokens'] . ')'); ?>
2699 <div class="btn-group">
2700 <form method="post" style="display: inline;">
2701 <input type="hidden" name="delete_index" value="<?php echo esc_attr($index); ?>">
2702 <button type="submit" name="delete_prompt" class="btn btn-danger btn-sm">×</button>
2703 </form>
2704 <?php if ($index > 0) { ?>
2705 <form method="post" style="display: inline;">
2706 <input type="hidden" name="index" value="<?php echo esc_attr($index); ?>">
2707 <button type="submit" name="move_up" class="btn btn-link btn-sm text-primary"></button>
2708 </form>
2709 <?php } ?>
2710 <?php if ($index < count($prompts) - 1) { ?>
2711 <form method="post" style="display: inline;">
2712 <input type="hidden" name="index" value="<?php echo esc_attr($index); ?>">
2713 <button type="submit" name="move_down" class="btn btn-link btn-sm text-primary"></button>
2714 </form>
2715 <?php } ?>
2716 </div>
2717 </li>
2718 <?php } ?>
2719 </ul>
2720 </div>
2721
2722
2723 <?php
2724 }
2725
2726
2727
2728
2729
2730
2731 function autowp_settings_page_handler() {
2732
2733 autowp_settings_page_set_options();
2734
2735 // Prepare the next cron time
2736 $next_cron_time = wp_next_scheduled('autowp_cron');
2737 $next_cron_time_formatted = $next_cron_time ? date_i18n('Y-m-d H:i:s', $next_cron_time) : __('No scheduled cron event found', 'autowp');
2738 ?>
2739
2740 <!-- Include the success/error message container -->
2741 <div id="cron-message" class="alert" style="display:none;"></div>
2742
2743 <form method="post" class="form-horizontal">
2744 <?php wp_nonce_field('autowp_settings_nonce', '_wpnonce'); ?>
2745 <fieldset>
2746 <!-- Form Name -->
2747 <legend><?php esc_html_e('Cron Settings', 'autowp'); ?></legend>
2748
2749 <!-- Next Scheduled Cron Time -->
2750 <div class="form-group">
2751 <label class="col-md-4 control-label"><?php esc_html_e('Next Cron Trigger Time', 'autowp'); ?></label>
2752 <div class="col-md-4">
2753 <p id="next-cron-time"><?php echo esc_html($next_cron_time_formatted); ?></p>
2754 </div>
2755 </div>
2756
2757
2758
2759
2760 <!-- Time Type -->
2761 <div class="form-group">
2762 <label class="col-md-4 control-label" for="selected_time_type"><?php esc_html_e('Time Type', 'autowp'); ?></label>
2763 <div class="col-md-4">
2764 <select id="selected_time_type" name="selected_time_type" class="form-control">
2765 <option value="1" <?php if(unserialize(get_option("autowp_settings"))["selected_time_type"] === '1') {echo ' selected'; } ?>><?php esc_html_e('Hour', 'autowp'); ?></option>
2766 <option value="2" <?php if(unserialize(get_option("autowp_settings"))["selected_time_type"] === '2') {echo ' selected'; } ?>><?php esc_html_e('Twice Daily', 'autowp'); ?></option>
2767 <option value="3" <?php if(unserialize(get_option("autowp_settings"))["selected_time_type"] === '3') {echo ' selected'; } ?>><?php esc_html_e('Daily', 'autowp'); ?></option>
2768 <option value="4" <?php if(unserialize(get_option("autowp_settings"))["selected_time_type"] === '4') {echo ' selected'; } ?>><?php esc_html_e('Weekly', 'autowp'); ?></option>
2769 </select>
2770 </div>
2771 </div>
2772
2773
2774
2775 <!-- WP-Cron Status -->
2776 <div class="form-group">
2777 <label class="col-md-4 control-label" for="wpcron_status"><?php esc_html_e('WP-Cron Status', 'autowp'); ?></label>
2778 <div class="col-md-4">
2779 <label class="radio-inline">
2780 <input type="radio" name="wpcron_status" value="1" <?php $settings = unserialize(get_option('autowp_settings')); if($settings['wpcron_status'] === '1' || !isset($settings['wpcron_status']) ){ echo 'checked="checked"'; } ?> ><?php esc_html_e('Active', 'autowp'); ?>
2781 </label>
2782 <label class="radio-inline">
2783 <input type="radio" name="wpcron_status" value="2" <?php $settings = unserialize(get_option('autowp_settings')); if($settings['wpcron_status'] !== '1' && isset($settings['wpcron_status']) ){ echo 'checked="checked"'; } ?> ><?php esc_html_e('Passive', 'autowp'); ?>
2784 </label>
2785 </div>
2786 </div>
2787
2788 <!-- Description -->
2789 <div class="form-group">
2790 <label class="col-md-4 control-label" for="description"><?php esc_html_e('If you want to stop generating new posts, you should set WP-Cron to passive.', 'autowp'); ?></label>
2791 <div class="col-md-4">
2792 <label><?php esc_html_e('', 'autowp'); ?></label>
2793 </div>
2794 </div>
2795 <!-- API Ayarları -->
2796 <legend><?php esc_html_e('API Settings', 'autowp'); ?></legend>
2797
2798 <!-- Email -->
2799 <div class="form-group">
2800 <label class="col-md-4 control-label" for="api_email"><?php esc_html_e('Email', 'autowp'); ?></label>
2801 <div class="col-md-4">
2802 <input id="api_email" name="api_email" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["api_email"]); ?>" placeholder="<?php esc_html_e('Enter your email', 'autowp'); ?>">
2803 <p class="help-block"><?php esc_html_e('IMPORTANT! This email is used for API registration and authentication.', 'autowp'); ?></p>
2804 </div>
2805 </div>
2806
2807 <!-- API Key -->
2808 <div class="form-group">
2809 <label class="col-md-4 control-label" for="api_key"><?php esc_html_e('AutoWP API Key', 'autowp'); ?></label>
2810 <div class="col-md-4">
2811 <input id="api_key" name="api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["api_key"]); ?>" placeholder="<?php esc_html_e('Enter your API key', 'autowp'); ?>">
2812 <p class="help-block"><?php esc_html_e('IMPORTANT! AutoWP API key for generating content. If you left it empty, you cannot generate any content!', 'autowp'); ?></p>
2813 </div>
2814 </div>
2815
2816 <!-- OpenAI API Key -->
2817 <div class="form-group">
2818 <label class="col-md-4 control-label" for="openai_api_key"><?php esc_html_e('OpenAI API Key', 'autowp'); ?></label>
2819 <div class="col-md-4">
2820 <input id="openai_api_key" name="openai_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["openai_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your OpenAI API key', 'autowp'); ?>">
2821 <p class="help-block"><?php esc_html_e('IMPORTANT! Only users with the UNLIMITED package need to configure this setting. Learn how to obtain the key here: https://www.youtube.com/watch?v=OB99E7Y1cMA', 'autowp'); ?></p>
2822 </div>
2823 </div>
2824
2825 <!-- OpenAI Base URL -->
2826 <div class="form-group">
2827 <label class="col-md-4 control-label" for="openai_base_url"><?php esc_html_e('OpenAI Base URL', 'autowp'); ?></label>
2828 <div class="col-md-4">
2829 <input id="openai_base_url" name="openai_base_url" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["openai_base_url"]); ?>" placeholder="<?php esc_html_e('Enter your OpenAI Base URL (optional)', 'autowp'); ?>">
2830 <p class="help-block"><?php esc_html_e('OPTIONAL: Only set this if you are using a custom proxy or self-hosted OpenAI-compatible server. Leave empty to use the default OpenAI API.', 'autowp'); ?></p>
2831 </div>
2832 </div>
2833
2834
2835 <!-- xAI API Key -->
2836 <div class="form-group">
2837 <label class="col-md-4 control-label" for="xai_api_key"><?php esc_html_e('xAI API Key', 'autowp'); ?></label>
2838 <div class="col-md-4">
2839 <input id="xai_api_key" name="xai_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["xai_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your xAI API key', 'autowp'); ?>">
2840 <p class="help-block"><?php esc_html_e('IMPORTANT! Only users with the UNLIMITED package need to configure this setting. Learn how to obtain the key here: https://www.youtube.com/watch?v=4Tzs4qunYJY', 'autowp'); ?></p>
2841 </div>
2842 </div>
2843
2844 <!-- Groq API Key -->
2845 <div class="form-group">
2846 <label class="col-md-4 control-label" for="deepseek_api_key"><?php esc_html_e('Groq API Key', 'autowp'); ?></label>
2847 <div class="col-md-4">
2848 <input id="deepseek_api_key" name="deepseek_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["deepseek_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your Groq API key', 'autowp'); ?>">
2849 <p class="help-block"><?php esc_html_e('IMPORTANT! Enter your Groq API key for accessing Groq services.', 'autowp'); ?></p>
2850 </div>
2851 </div>
2852
2853 <!-- Groq Model Selection (Statik) -->
2854 <div class="form-group">
2855 <label class="col-md-4 control-label" for="groq_model"><?php esc_html_e('Groq Model', 'autowp'); ?></label>
2856 <div class="col-md-4">
2857 <select id="groq_model" name="groq_model" class="form-control">
2858 <?php
2859 // Groq model seçiminin kaydedilen değerini alıyoruz
2860 $selected_groq_model = isset(unserialize(get_option("autowp_settings"))["groq_model"]) ? unserialize(get_option("autowp_settings"))["groq_model"] : '';
2861
2862 // Ekteki ekran görüntülerindeki model gruplarına göre statik bir dizi oluşturuyoruz.
2863 $static_models = array(
2864 'Alibaba Cloud' => array(
2865 'qwen-2.5-32b',
2866 'qwen-2.5-coder-32b',
2867 'qwen-qwq-32b',
2868 ),
2869 'DeepSeek / Alibaba Cloud' => array(
2870 'deepseek-r1-distill-qwen-32b',
2871 ),
2872 'DeepSeek / Meta' => array(
2873 'deepseek-r1-distill-llama-70b',
2874 ),
2875 'Google' => array(
2876 'gemma2-9b-it',
2877 ),
2878 'Hugging Face' => array(
2879 'distil-whisper-large-v3-en',
2880 ),
2881 'OpenAI' => array(
2882 'whisper-large-v3',
2883 'whisper-large-v3-turbo',
2884 ),
2885 'Mistral AI' => array(
2886 'mistral-saba-24b',
2887 'mixtral-8x7b-32768',
2888 ),
2889 'Llama' => array(
2890 'llama-3.2-11b-vision-preview',
2891 'llama-3.2-3b-preview',
2892 'llama-3.2-7b-preview',
2893 'llama-3.2-90b-vision-preview',
2894 'llama-3.2-90b-preview',
2895 'llama-3.2-70b-vision-preview',
2896 'llama-3.3-70b-versatile',
2897 'llama-3.3-70b-specdec',
2898 'llama-guard-3-8b',
2899 'llama-70b-8192',
2900 'llama-3-8b-8192',
2901 ),
2902 );
2903
2904 // Grupları ve modelleri select içinde listeliyoruz
2905 foreach ($static_models as $group_label => $models) {
2906 echo '<optgroup label="'.esc_attr($group_label).'">';
2907 foreach ($models as $model) {
2908 $selected = ($model === $selected_groq_model) ? 'selected' : '';
2909 echo '<option value="'.esc_attr($model).'" '.$selected.'>'.esc_html($model).'</option>';
2910 }
2911 echo '</optgroup>';
2912 }
2913 ?>
2914 </select>
2915 <p class="help-block"><?php esc_html_e('Select a Groq model to use from the static list of available models.', 'autowp'); ?></p>
2916 </div>
2917 </div>
2918
2919
2920
2921
2922 <!-- FalAI API Key -->
2923 <div class="form-group">
2924 <label class="col-md-4 control-label" for="falai_api_key"><?php esc_html_e('FalAI API Key', 'autowp'); ?></label>
2925 <div class="col-md-4">
2926 <input id="falai_api_key" name="falai_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["falai_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your FalAI API key', 'autowp'); ?>">
2927 <p class="help-block"><?php esc_html_e('IMPORTANT! Only users with the UNLIMITED package need to configure this setting. Learn how to obtain the key here: https://fal.ai', 'autowp'); ?></p>
2928 </div>
2929 </div>
2930
2931 <!-- StabilityAI API Key -->
2932 <div class="form-group">
2933 <label class="col-md-4 control-label" for="stabilityai_api_key"><?php esc_html_e('StabilityAI API Key', 'autowp'); ?></label>
2934 <div class="col-md-4">
2935 <input id="stabilityai_api_key" name="stabilityai_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["stabilityai_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your StabilityAI API key', 'autowp'); ?>">
2936 <p class="help-block"><?php esc_html_e('IMPORTANT! Only users with the UNLIMITED package need to configure this setting. Learn how to obtain the key here: https://www.youtube.com/watch?v=De-SOrWHMh8', 'autowp'); ?></p>
2937 </div>
2938 </div>
2939
2940 <!-- SerperDEV API Key -->
2941 <div class="form-group">
2942 <label class="col-md-4 control-label" for="serperdev_api_key"><?php esc_html_e('SerperDEV API Key', 'autowp'); ?></label>
2943 <div class="col-md-4">
2944 <input id="serperdev_api_key" name="serperdev_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["serperdev_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your SerperDEV API key', 'autowp'); ?>">
2945 <p class="help-block"><?php esc_html_e('IMPORTANT! Only users with the UNLIMITED package need to configure this setting. Learn how to obtain the key here: https://serper.dev/signup', 'autowp'); ?></p>
2946 </div>
2947 </div>
2948
2949 <!-- Primary LLM Option -->
2950 <div class="form-group">
2951 <label class="col-md-4 control-label" for="primary_llm"><?php esc_html_e('Primary LLM Option', 'autowp'); ?></label>
2952 <div class="col-md-4">
2953 <select id="primary_llm" name="primary_llm" class="form-control">
2954 <option value="openai" <?php if (isset(unserialize(get_option("autowp_settings"))["primary_llm"]) && unserialize(get_option("autowp_settings"))["primary_llm"] === 'openai') { echo 'selected'; } ?>><?php esc_html_e('OpenAI', 'autowp'); ?></option>
2955 <option value="xai" <?php if (isset(unserialize(get_option("autowp_settings"))["primary_llm"]) && unserialize(get_option("autowp_settings"))["primary_llm"] === 'xai') { echo 'selected'; } ?>><?php esc_html_e('xAI Grok', 'autowp'); ?></option>
2956 <option value="groq" <?php if (isset(unserialize(get_option("autowp_settings"))["primary_llm"]) && unserialize(get_option("autowp_settings"))["primary_llm"] === 'groq') { echo 'selected'; } ?>><?php esc_html_e('Groq', 'autowp'); ?></option>
2957 </select>
2958 <p class="help-block"><?php esc_html_e('Select the primary LLM provider. This provider will be used as the default for content generation.', 'autowp'); ?></p>
2959 </div>
2960 </div>
2961
2962 <!-- Secondary LLM Option -->
2963 <div class="form-group">
2964 <label class="col-md-4 control-label" for="secondary_llm"><?php esc_html_e('Secondary LLM Option', 'autowp'); ?></label>
2965 <div class="col-md-4">
2966 <select id="secondary_llm" name="secondary_llm" class="form-control">
2967 <option value="openai" <?php if (isset(unserialize(get_option("autowp_settings"))["secondary_llm"]) && unserialize(get_option("autowp_settings"))["secondary_llm"] === 'openai') { echo 'selected'; } ?>><?php esc_html_e('OpenAI', 'autowp'); ?></option>
2968 <option value="xai" <?php if (isset(unserialize(get_option("autowp_settings"))["primary_llm"]) && unserialize(get_option("autowp_settings"))["secondary_llm"] === 'xai') { echo 'selected'; } ?>><?php esc_html_e('xAI Grok', 'autowp'); ?></option>
2969 <option value="groq" <?php if (isset(unserialize(get_option("autowp_settings"))["secondary_llm"]) && unserialize(get_option("autowp_settings"))["secondary_llm"] === 'groq') { echo 'selected'; } ?>><?php esc_html_e('Groq', 'autowp'); ?></option>
2970 </select>
2971 <p class="help-block"><?php esc_html_e('Select the secondary LLM provider. This option will be used if the primary provider fails.', 'autowp'); ?></p>
2972 </div>
2973 </div>
2974
2975
2976 <!-- Post Status -->
2977 <legend><?php esc_html_e('Post Settings', 'autowp'); ?></legend>
2978
2979 <!-- Default Image URL -->
2980 <div class="form-group">
2981 <label class="col-md-4 control-label" for="default_image_url"><?php esc_html_e('Default Image URL', 'autowp'); ?></label>
2982 <div class="col-md-4">
2983 <input id="default_image_url" name="default_image_url" type="url" class="form-control" value="<?php
2984 echo isset(unserialize(get_option("autowp_settings"))["default_image_url"]) ? esc_url(unserialize(get_option("autowp_settings"))["default_image_url"]) : '';
2985 ?>" placeholder="<?php esc_html_e('Enter default image URL', 'autowp'); ?>">
2986 <p class="help-block"><?php esc_html_e('If no specific thumbnail is set for a post, this image URL will be used as the default thumbnail. Leave empty to disable this feature.', 'autowp'); ?></p>
2987 </div>
2988 </div>
2989
2990
2991 <div class="form-group">
2992 <label class="col-md-4 control-label" for="post_status"><?php esc_html_e('Post Status', 'autowp'); ?></label>
2993 <div class="col-md-4">
2994 <select id="post_status" name="post_status" class="form-control">
2995 <?php
2996 $selected_post_status = isset(unserialize(get_option("autowp_settings"))["post_status"]) ? unserialize(get_option("autowp_settings"))["post_status"] : 'publish';
2997
2998 $statuses = array(
2999 'publish' => __('Published', 'autowp'),
3000 'draft' => __('Draft', 'autowp')
3001 );
3002
3003 foreach ($statuses as $status_value => $status_label) {
3004 $selected = ($status_value === $selected_post_status) ? 'selected' : '';
3005 echo '<option value="' . esc_attr($status_value) . '" ' . esc_attr($selected) . '>' . esc_html($status_label) . '</option>';
3006 }
3007 ?>
3008 </select>
3009 </div>
3010 </div>
3011
3012
3013 <!-- Content Image Generation Method -->
3014 <div class="form-group">
3015 <label class="col-md-4 control-label" for="content_image_generation_method"><?php esc_html_e('Content Image Generation Method', 'autowp'); ?></label>
3016 <div class="col-md-4">
3017 <select id="content_image_generation_method" name="content_image_generation_method" class="form-control">
3018 <?php
3019 $methods = array(
3020 'stable_diffusion' => __('Stable Diffusion', 'autowp'),
3021 'duckduckgo_image_search' => __('DuckDuckGo Image Search', 'autowp')
3022 );
3023
3024 $selected_method = isset(unserialize(get_option("autowp_settings"))["content_image_generation_method"]) ? unserialize(get_option("autowp_settings"))["content_image_generation_method"] : 'stable_diffusion';
3025
3026 foreach ($methods as $method_value => $method_label) {
3027 $selected = ($method_value === $selected_method) ? 'selected' : '';
3028 echo '<option value="' . esc_attr($method_value) . '" ' . esc_attr($selected) . '>' . esc_html($method_label) . '</option>';
3029 }
3030 ?>
3031 </select>
3032 <p class="help-block">
3033 <?php esc_html_e('This setting defines the method used to generate images within the post content. It is not related to the thumbnail image.', 'autowp'); ?>
3034 </p>
3035 </div>
3036 </div>
3037
3038 <!-- Maximum Posts Per Cron -->
3039 <div class="form-group">
3040 <label class="col-md-4 control-label" for="max_posts_per_cron"><?php esc_html_e('Maximum Posts Per Cron Trigger', 'autowp'); ?></label>
3041 <div class="col-md-4">
3042 <select id="max_posts_per_cron" name="max_posts_per_cron" class="form-control">
3043 <?php
3044 $current_value = isset(unserialize(get_option("autowp_settings"))["max_posts_per_cron"]) ?
3045 esc_html(unserialize(get_option("autowp_settings"))["max_posts_per_cron"]) : 1;
3046 ?>
3047 <option value="1" <?php selected($current_value, 1); ?>>1</option>
3048 <option value="2" <?php selected($current_value, 2); ?>>2</option>
3049 <option value="3" <?php selected($current_value, 3); ?>>3</option>
3050 </select>
3051 <p class="help-block"><?php esc_html_e('This sets the maximum number of posts that can be generated each time the cron job is triggered. Default: 1.', 'autowp'); ?></p>
3052 </div>
3053 </div>
3054
3055
3056 <!-- Maximum Posts Per Day -->
3057 <div class="form-group">
3058 <label class="col-md-4 control-label" for="max_posts_per_day"><?php esc_html_e('Maximum Posts Per Day', 'autowp'); ?></label>
3059 <div class="col-md-4">
3060 <input id="max_posts_per_day" name="max_posts_per_day" type="number" class="form-control" value="<?php
3061 echo isset(unserialize(get_option("autowp_settings"))["max_posts_per_day"]) ? esc_html(unserialize(get_option("autowp_settings"))["max_posts_per_day"]) : 20;
3062 ?>" placeholder="<?php esc_html_e('Enter maximum posts per day', 'autowp'); ?>" min="1">
3063 <p class="help-block"><?php esc_html_e('This sets the maximum number of posts that can be generated within a single day. Default: 20.', 'autowp'); ?></p>
3064 </div>
3065 </div>
3066
3067 <!-- Spam and Ad Filter -->
3068 <div class="form-group">
3069 <label class="col-md-4 control-label" for="spam_ad_filter"><?php esc_html_e('Spam and Ad Filter', 'autowp'); ?></label>
3070 <div class="col-md-4">
3071 <label class="radio-inline">
3072 <input type="radio" name="spam_ad_filter" value="1" <?php if(unserialize(get_option("autowp_settings"))["spam_ad_filter"] === '1') { echo 'checked'; } ?>>
3073 <?php esc_html_e('Active', 'autowp'); ?>
3074 </label>
3075 <label class="radio-inline">
3076 <input type="radio" name="spam_ad_filter" value="0" <?php if(unserialize(get_option("autowp_settings"))["spam_ad_filter"] !== '1') { echo 'checked'; } ?>>
3077 <?php esc_html_e('Passive', 'autowp'); ?>
3078 </label>
3079 <p class="help-block"><?php esc_html_e('When active, content sources will be checked for spam and advertisements before generating posts. Processing will start only if the content passes the spam filter. Default: Passive.', 'autowp'); ?></p>
3080 </div>
3081 </div>
3082
3083 <!-- Duplicate Content Filter -->
3084 <div class="form-group">
3085 <label class="col-md-4 control-label" for="duplicate_content_filter"><?php esc_html_e('Similar Content Filter', 'autowp'); ?></label>
3086 <div class="col-md-4">
3087 <label class="radio-inline">
3088 <input type="radio" name="duplicate_content_filter" value="1" <?php if(!isset(unserialize(get_option("autowp_settings"))["duplicate_content_filter"]) || unserialize(get_option("autowp_settings"))["duplicate_content_filter"] === '1') { echo 'checked'; } ?>>
3089 <?php esc_html_e('Active', 'autowp'); ?>
3090 </label>
3091 <label class="radio-inline">
3092 <input type="radio" name="duplicate_content_filter" value="0" <?php if(isset(unserialize(get_option("autowp_settings"))["duplicate_content_filter"]) && unserialize(get_option("autowp_settings"))["duplicate_content_filter"] === '0') { echo 'checked'; } ?>>
3093 <?php esc_html_e('Passive', 'autowp'); ?>
3094 </label>
3095 <p class="help-block"><?php esc_html_e('When active, the plugin will avoid generating content that is similar to existing posts. Default: Active.', 'autowp'); ?></p>
3096 </div>
3097 </div>
3098
3099
3100
3101
3102
3103 <legend><?php esc_html_e('Image Format', 'autowp'); ?></legend>
3104 <!-- Image Format -->
3105 <div class="form-group">
3106 <label class="col-md-4 control-label" for="image_format"><?php esc_html_e('Image Format', 'autowp'); ?></label>
3107 <div class="col-md-4">
3108 <select id="image_format" name="image_format" class="form-control">
3109 <?php
3110 $image_formats = array('png', 'jpeg', 'webp');
3111 $selected_image_format = isset(unserialize(get_option("autowp_settings"))["image_format"]) ? unserialize(get_option("autowp_settings"))["image_format"] : 'jpeg';
3112
3113 foreach ($image_formats as $format) {
3114 $selected = ($format === $selected_image_format) ? 'selected' : '';
3115 echo '<option value="' . esc_attr($format) . '" ' . esc_attr($selected) . '>' . esc_html(strtoupper($format)) . '</option>';
3116 }
3117 ?>
3118 </select>
3119 </div>
3120 </div>
3121
3122
3123 <legend><?php esc_html_e('Stable Diffusion Settings', 'autowp'); ?></legend>
3124 <!-- Stable Diffusion Style -->
3125 <div class="form-group">
3126 <label class="col-md-4 control-label" for="stable_diffusion_style"><?php esc_html_e('Stable Diffusion Style', 'autowp'); ?></label>
3127 <div class="col-md-4">
3128 <select id="stable_diffusion_style" name="stable_diffusion_style" class="form-control">
3129 <?php
3130 $styles = array('None', 'enhance', 'anime', 'photographic', 'digital-art','comic-book','fantasy-art','line-art','analog-film','neon-punk','isometric','low-poly','origami','modeling-compound','cinematic','3d-model','pixel-art','tile-texture');
3131 $selected_style = isset(unserialize(get_option("autowp_settings"))["stable_diffusion_style"]) ? unserialize(get_option("autowp_settings"))["stable_diffusion_style"] : 'None';
3132
3133 foreach ($styles as $style) {
3134 $selected = ($style === $selected_style) ? 'selected' : '';
3135 echo '<option value="' . esc_attr($style) . '" ' . esc_attr($selected) . '>' . esc_html($style) . '</option>';
3136 }
3137
3138 ?>
3139 </select>
3140 </div>
3141 </div>
3142
3143
3144 <!-- Stable Diffusion Size -->
3145 <div class="form-group">
3146 <label class="col-md-4 control-label" for="stable_diffusion_size"><?php esc_html_e('Stable Diffusion Size', 'autowp'); ?></label>
3147 <div class="col-md-4">
3148 <select id="stable_diffusion_size" name="stable_diffusion_size" class="form-control">
3149 <?php
3150 $sd_sizes = array('16:9', '1:1', '21:9', '2:3', '3:2', '4:5', '5:4', '9:16', '9:21');
3151 $selected_sd_size = isset(unserialize(get_option("autowp_settings"))["stable_diffusion_size"]) ? unserialize(get_option("autowp_settings"))["stable_diffusion_size"] : '16:9';
3152
3153 foreach ($sd_sizes as $size) {
3154 $selected = ($size === $selected_sd_size) ? 'selected' : '';
3155 echo '<option value="' . esc_attr($size) . '" ' . esc_attr($selected) . '>' . esc_html($size) . '</option>';
3156 }
3157 ?>
3158 </select>
3159 </div>
3160 </div>
3161
3162
3163
3164 <!-- Flux Settings -->
3165 <legend><?php esc_html_e('Flux Settings', 'autowp'); ?></legend>
3166
3167 <!-- Image Size -->
3168 <div class="form-group">
3169 <label class="col-md-4 control-label" for="flux_image_size"><?php esc_html_e('Image Size', 'autowp'); ?></label>
3170 <div class="col-md-4">
3171 <select id="flux_image_size" name="flux_image_size" class="form-control">
3172 <?php
3173 $flux_sizes = array('square_hd', 'square', 'portrait_3_4', 'portrait_9_16', 'landscape_4_3', 'landscape_16_9');
3174 $selected_flux_size = isset(unserialize(get_option("autowp_settings"))["flux_image_size"]) ? unserialize(get_option("autowp_settings"))["flux_image_size"] : 'square_hd';
3175
3176 foreach ($flux_sizes as $size) {
3177 $selected = ($size === $selected_flux_size) ? 'selected' : '';
3178 echo '<option value="' . esc_attr($size) . '" ' . esc_attr($selected) . '>' . esc_html(str_replace('_', ' ', ucfirst($size))) . '</option>';
3179 }
3180 ?>
3181 </select>
3182 </div>
3183 </div>
3184
3185 <legend><?php esc_html_e('OpenAI Image Settings', 'autowp'); ?></legend>
3186
3187 <!-- GPT Image 1 Mini Size -->
3188 <div class="form-group">
3189 <label class="col-md-4 control-label" for="dalle_2_size"><?php esc_html_e('GPT Image 1 Mini Size', 'autowp'); ?></label>
3190 <div class="col-md-4">
3191 <select id="dalle_2_size" name="dalle_2_size" class="form-control">
3192 <?php
3193 $dalle_2_sizes = array('1024x1024','512x512','256x256');
3194 $selected_dalle_2_size = isset(unserialize(get_option("autowp_settings"))["dalle_2_size"]) ? unserialize(get_option("autowp_settings"))["dalle_2_size"] : '1024x1024';
3195
3196 foreach ($dalle_2_sizes as $size) {
3197 $selected = ($size === $selected_dalle_2_size) ? 'selected' : '';
3198 echo '<option value="' . esc_attr($size) . '" ' . esc_attr($selected) . '>' . esc_html($size) . '</option>';
3199 }
3200 ?>
3201 </select>
3202 </div>
3203 </div>
3204
3205
3206 <!-- GPT Image 2 Size -->
3207 <div class="form-group">
3208 <label class="col-md-4 control-label" for="dalle_3_size"><?php esc_html_e('GPT Image 2 Size', 'autowp'); ?></label>
3209 <div class="col-md-4">
3210 <select id="dalle_3_size" name="dalle_3_size" class="form-control">
3211 <?php
3212 $dalle_3_sizes = array('1024x1024', '1792x1024', '1024x1792');
3213 $selected_dalle_3_size = isset(unserialize(get_option("autowp_settings"))["dalle_3_size"]) ? unserialize(get_option("autowp_settings"))["dalle_3_size"] : '1024x1024';
3214
3215 foreach ($dalle_3_sizes as $size) {
3216 $selected = ($size === $selected_dalle_3_size) ? 'selected' : '';
3217 echo '<option value="' . esc_attr($size) . '" ' . esc_attr($selected) . '>' . esc_html($size) . '</option>';
3218 }
3219 ?>
3220 </select>
3221 </div>
3222 </div>
3223
3224
3225 <!-- Legacy OpenAI Style -->
3226 <div class="form-group">
3227 <label class="col-md-4 control-label" for="dalle_3_style"><?php esc_html_e('Legacy OpenAI Style', 'autowp'); ?></label>
3228 <div class="col-md-4">
3229 <select id="dalle_3_style" name="dalle_3_style" class="form-control">
3230 <?php
3231 $dalle_3_styles = array('natural', 'vivid');
3232 $selected_dalle_3_style = isset(unserialize(get_option("autowp_settings"))["dalle_3_style"]) ? unserialize(get_option("autowp_settings"))["dalle_3_style"] : 'natural';
3233
3234 foreach ($dalle_3_styles as $style) {
3235 $selected = ($style === $selected_dalle_3_style) ? 'selected' : '';
3236 echo '<option value="' . esc_attr($style) . '" ' . esc_attr($selected) . '>' . esc_html(ucfirst($style)) . '</option>';
3237 }
3238 ?>
3239 </select>
3240 <p class="help-block"><?php esc_html_e('This legacy style setting is kept for backward compatibility and is not used by GPT Image 2 or GPT Image 1 Mini.', 'autowp'); ?></p>
3241 </div>
3242 </div>
3243
3244
3245
3246
3247 <!-- Image Motification Settings -->
3248 <legend><?php esc_html_e('Image Modification Settings', 'autowp'); ?></legend>
3249
3250
3251
3252 <!-- Image Modification Status -->
3253 <div class="form-group">
3254 <label class="col-md-4 control-label" for="image_modification_status"><?php esc_html_e('Image Modification Status', 'autowp'); ?></label>
3255 <div class="col-md-4">
3256 <label class="radio-inline">
3257 <input type="radio" name="image_modification_status" value="1" <?php if(unserialize(get_option("autowp_settings"))["image_modification_status"] === '1') {echo ' checked'; } ?>><?php esc_html_e('Active', 'autowp'); ?>
3258 </label>
3259 <label class="radio-inline">
3260 <input type="radio" name="image_modification_status" value="0" <?php if(unserialize(get_option("autowp_settings"))["image_modification_status"] !== '1') {echo ' checked'; } ?>><?php esc_html_e('Inactive', 'autowp'); ?>
3261 </label>
3262 <p class="help-block"><?php esc_html_e('If inactive, the images will be published without any modification.', 'autowp'); ?></p>
3263 </div>
3264 </div>
3265
3266
3267
3268
3269 <!-- Nano Banana -->
3270 <div class="form-group">
3271 <label class="col-md-4 control-label" for="nano_banana_prompt"><?php esc_html_e('AI Image Editing', 'autowp'); ?></label>
3272 <div class="col-md-4">
3273 <input id="nano_banana_prompt" name="nano_banana_prompt" type="text" class="form-control" value="<?php echo esc_html(unserialize(get_option("autowp_settings"))["nano_banana_prompt"]) ?>" placeholder="<?php esc_html_e('Enter the prompt for image editing using Gemini Nano Banana', 'autowp'); ?>">
3274 <p class="help-block"><?php esc_html_e('You can perform AI-powered image editing using the Gemini Nano Banana model. The image will be modified based on the prompt you enter.
3275
3276 e.g: "Make the image black and white."
3277 "Remove any logos or links in the image."', 'autowp'); ?></p>
3278 </div>
3279 </div>
3280
3281
3282 <!-- Image Generating Settings -->
3283 <!-- Width -->
3284 <div class="form-group">
3285 <label class="col-md-4 control-label" for="ai_image_width"><?php esc_html_e('Width', 'autowp'); ?></label>
3286 <div class="col-md-4">
3287 <input id="ai_image_width" name="ai_image_width" type="number" class="form-control" value="<?php
3288 if (isset(unserialize(get_option("autowp_settings"))["ai_image_width"])) {
3289 echo esc_html(unserialize(get_option("autowp_settings"))["ai_image_width"]);
3290 } else{
3291 echo '0';
3292 }
3293 ?>" placeholder="Enter width">
3294 </div>
3295 </div>
3296
3297 <!-- Height -->
3298 <div class="form-group">
3299 <label class="col-md-4 control-label" for="ai_image_height"><?php esc_html_e('Height', 'autowp'); ?></label>
3300 <div class="col-md-4">
3301 <input id="ai_image_height" name="ai_image_height" type="number" class="form-control" value="<?php
3302 if (isset(unserialize(get_option("autowp_settings"))["ai_image_height"])){
3303 echo esc_html(unserialize(get_option("autowp_settings"))["ai_image_height"]);
3304 }else{
3305 echo '0';
3306 }
3307 ?>" placeholder="Enter height">
3308 <br><p class="help-block"><?php esc_html_e('If you want to resize the images you can enter a value here. If you do not enter a value here the images will remain in their original size.', 'autowp'); ?></p>
3309 </div>
3310 </div>
3311
3312
3313 <!-- Watermark Link -->
3314 <div class="form-group">
3315 <label class="col-md-4 control-label" for="watermark_link"><?php esc_html_e('Watermark Link', 'autowp'); ?></label>
3316 <div class="col-md-4">
3317 <input id="watermark_link" name="watermark_link" type="text" class="form-control" value="<?php echo esc_html(unserialize(get_option("autowp_settings"))["watermark_link"]) ?>" placeholder="<?php esc_html_e('Enter the watermark link for post cover images', 'autowp'); ?>">
3318 <p class="help-block"><?php esc_html_e('Leave it empty if you do not want to add a watermark.', 'autowp'); ?></p>
3319 </div>
3320 </div>
3321
3322
3323 <legend><?php esc_html_e('Social Media Settings', 'autowp'); ?></legend>
3324
3325 <!-- Social Media Status -->
3326 <div class="form-group">
3327 <label class="col-md-4 control-label" for="social_media_status"><?php esc_html_e('Social Media Sharing Status', 'autowp'); ?></label>
3328 <div class="col-md-4">
3329 <label class="radio-inline">
3330 <input type="radio" name="social_media_status" value="1" <?php if (unserialize(get_option("autowp_settings"))["social_media_status"] === '1') { echo 'checked'; } ?>>
3331 <?php esc_html_e('Active', 'autowp'); ?>
3332 </label>
3333 <label class="radio-inline">
3334 <input type="radio" name="social_media_status" value="0" <?php if (unserialize(get_option("autowp_settings"))["social_media_status"] !== '1') { echo 'checked'; } ?>>
3335 <?php esc_html_e('Inactive', 'autowp'); ?>
3336 </label>
3337 <p class="help-block"><?php esc_html_e('Enable or disable social media sharing globally for your posts.', 'autowp'); ?></p>
3338 </div>
3339 </div>
3340
3341
3342 <!-- Twitter API Key -->
3343 <div class="form-group">
3344 <label class="col-md-4 control-label" for="twitter_api_key"><?php esc_html_e('Twitter API Key', 'autowp'); ?></label>
3345 <div class="col-md-4">
3346 <input id="twitter_api_key" name="twitter_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["twitter_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your Twitter API key', 'autowp'); ?>">
3347 <p class="help-block"><?php esc_html_e('IMPORTANT! Obtain your Twitter API key from https://developer.twitter.com/en/apps.', 'autowp'); ?></p>
3348 </div>
3349 </div>
3350
3351 <!-- Telegram API Key -->
3352 <div class="form-group">
3353 <label class="col-md-4 control-label" for="telegram_api_key"><?php esc_html_e('Telegram API Key', 'autowp'); ?></label>
3354 <div class="col-md-4">
3355 <input id="telegram_api_key" name="telegram_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["telegram_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your Telegram API key', 'autowp'); ?>">
3356 <p class="help-block"><?php esc_html_e('IMPORTANT! Obtain your Telegram API key by creating a bot through BotFather: https://core.telegram.org/bots.', 'autowp'); ?></p>
3357 </div>
3358 </div>
3359
3360 <!-- Instagram API Key -->
3361 <div class="form-group">
3362 <label class="col-md-4 control-label" for="instagram_api_key"><?php esc_html_e('Instagram API Key', 'autowp'); ?></label>
3363 <div class="col-md-4">
3364 <input id="instagram_api_key" name="instagram_api_key" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["instagram_api_key"]); ?>" placeholder="<?php esc_html_e('Enter your Instagram API key', 'autowp'); ?>">
3365 <p class="help-block"><?php esc_html_e('IMPORTANT! Obtain your Instagram API key by registering an app on the Meta for Developers platform: https://developers.facebook.com.', 'autowp'); ?></p>
3366 </div>
3367 </div>
3368
3369 <legend><?php esc_html_e('Server Settings', 'autowp'); ?></legend>
3370
3371 <!-- AutoWP Server Base URL -->
3372 <div class="form-group">
3373 <label class="col-md-4 control-label" for="autowp_server_url"><?php esc_html_e('AutoWP Server Base URL', 'autowp'); ?></label>
3374 <div class="col-md-4">
3375 <input id="autowp_server_url" name="autowp_server_url" type="text" class="form-control" value="<?php echo esc_attr(unserialize(get_option("autowp_settings"))["autowp_server_url"]); ?>" placeholder="<?php esc_html_e('Enter AutoWP Backend Server Base URL (only if you have LİFETIME package): ', 'autowp'); ?>">
3376 <p class="help-block"><?php esc_html_e('IMPORTANT WARNING! This field should only be used by users with the SELF HOSTING/LIFETIME package. The AutoWP plugin will not function properly if users with packages other than the Lifetime package change it.', 'autowp'); ?></p>
3377 </div>
3378 </div>
3379
3380
3381
3382 <!-- Button -->
3383 <div class="form-group">
3384 <label class="col-md-4 control-label" for="singlebutton"></label>
3385 <div class="col-md-4">
3386 <button id="singlebutton" name="singlebutton" class="btn btn-primary"><?php esc_html_e('Save', 'autowp'); ?></button>
3387 </div>
3388 </div>
3389 </fieldset>
3390 </form>
3391
3392
3393 <?php
3394 }
3395
3396 function autowp_show_alert_with_message($isSuccess,$message) {
3397 if ($isSuccess) {
3398 $alertType = "success";
3399 } else {
3400 $alertType = "danger";
3401 }
3402
3403 echo '<div class="alert alert-' . esc_html($alertType) . ' alert-dismissible fade show" role="alert">';
3404 echo esc_html($message);
3405 echo '<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>';
3406 echo '</div>';
3407 }
3408
3409
3410 // Register AJAX action for triggering cron
3411 add_action('wp_ajax_autowp_trigger_cron_now', 'autowp_trigger_cron_now');
3412
3413 function autowp_trigger_cron_now() {
3414 // Check if the user has the correct capabilities
3415 if (!current_user_can('manage_options')) {
3416 wp_send_json_error(array('message' => __('Unauthorized', 'autowp')));
3417 }
3418
3419 // Attempt to run the cron job immediately
3420 if (wp_unschedule_event(time(), 'autowp_cron')) {
3421 // Schedule it now
3422 wp_schedule_single_event(time(), 'autowp_cron');
3423
3424 // Get the next cron time
3425 $next_cron_time = wp_next_scheduled('autowp_cron');
3426 $next_cron_time_formatted = $next_cron_time ? date_i18n('Y-m-d H:i:s', $next_cron_time) : __('No scheduled cron event found', 'autowp');
3427
3428 wp_send_json_success(array('message' => __('Cron triggered successfully!', 'autowp'), 'next_cron_time' => $next_cron_time_formatted));
3429 } else {
3430 wp_send_json_error(array('message' => __('Failed to trigger cron.', 'autowp')));
3431 }
3432 }
3433
3434
3435
3436 function autowp_manual_post_rss_form_page_setOptions($form_data){
3437
3438
3439
3440
3441
3442
3443 $autowp_admin_email = autowp_get_admin_email();
3444 $autowp_domain_name = esc_url(get_site_url());
3445 $website_domainname = sanitize_url($form_data['domain_name']);
3446 $website_categories = '1,2,3';
3447 $post_count = 5;
3448 $post_order = sanitize_text_field($form_data['post_order']);
3449 $post_ids = '';
3450 $title_prompt = sanitize_text_field($form_data['title_prompt']);
3451 $content_prompt = sanitize_text_field($form_data['content_prompt']);
3452 $tags_prompt = sanitize_text_field($form_data['tags_prompt']);
3453 $image_prompt = sanitize_text_field($form_data['image_prompt']);
3454
3455 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
3456
3457 $author_selection = sanitize_text_field($form_data['author_selection']) ?? 1;
3458
3459
3460 $aigenerated_title = '0';
3461 $aigenerated_content = '0';
3462 $aigenerated_tags = '0';
3463 $aigenerated_image = '0';
3464
3465 if(isset($form_data['aigenerated_title'])){
3466 $aigenerated_title = sanitize_text_field($form_data['aigenerated_title']);
3467 }
3468
3469 if(isset($form_data['aigenerated_content'])){
3470 $aigenerated_content = sanitize_text_field($form_data['aigenerated_content']);
3471 }
3472
3473 if(isset($form_data['aigenerated_tags'])){
3474 $aigenerated_tags = sanitize_text_field($form_data['aigenerated_tags']);
3475 }
3476
3477 if(isset($form_data['aigenerated_image'])){
3478 $aigenerated_image = sanitize_text_field($form_data['aigenerated_image']);
3479 }
3480
3481
3482
3483
3484 $source_type = 'rss';
3485
3486
3487 $wordpress_categories = isset($form_data['category_id']) ? array_map('intval', $form_data['category_id']) : array();
3488
3489 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
3490
3491 $prompts_option = get_option('autowp_rewriting_promptscheme');
3492 $prompt_option_str = strval($prompts_option);
3493 $rewriting_prompt_scheme = [];
3494
3495 if (!empty($prompts_option)) {
3496 $rewriting_prompt_scheme = json_encode($prompts_option);
3497
3498 // JSON'dan diziye dönüşüm yapılıyor ve true ile birlikte kullanıldığı için asosiyatif dizi elde ediliyor
3499 }
3500
3501
3502 $image_settings = unserialize(get_option('autowp_settings'));
3503 $image_settings_json = [];
3504
3505 if(!empty($image_settings)){
3506 $image_settings_json = json_encode($image_settings);
3507 }
3508
3509
3510
3511 $user_email = autowp_get_user_email_from_settings();
3512
3513 $get_data_from_api = autowp_get_posts_from_wp_website($autowp_domain_name, $user_email, $website_domainname, $website_categories, $post_count,$post_order,$post_ids,$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings_json,$source_type,$image_generating_status,$prompt_option_str);
3514
3515
3516 $wp_posts = $get_data_from_api['autowp-api'];
3517
3518
3519 if($get_data_from_api['error']){
3520 update_option('autowp_alerts', $get_data_from_api['error']);
3521
3522 }else{
3523 update_option('autowp_alerts', '');
3524 if(!empty($wp_posts)){
3525 // autowp_show_alert_with_message(true,'Success!');
3526 }else{
3527 // autowp_show_alert_with_message(false,'There is no new post from your feed url!');
3528 update_option('autowp_alerts', 'There is no new post from your feed url!');
3529 }
3530 }
3531
3532
3533
3534 foreach($wp_posts as $post){
3535
3536 $post_ids = $post_ids . ',' . $post['post_id'];
3537 $post_title = $post['post_title'];
3538 $post_content = $post['content'];
3539 $post_featured_image = $post['preview_image_original'];
3540 $post_tags = $post['tags'];
3541 $post_status = $image_settings['post_status'] ?? 'publish';
3542 $post_author = $author_selection;
3543 $post_type = 'post';
3544 $focus_keyword = $post['focus_keyword'];
3545 $faq_schema = $post['faq_schema'];
3546
3547 autowp_set_new_post($post_title,$post_content,$post_status,$post_author,$post_type,$post_featured_image, $wordpress_categories,$post_tags,$focus_keyword,$faq_schema);
3548
3549 }
3550
3551 autowp_update_published_post_ids($post_ids);
3552
3553
3554
3555
3556 }
3557
3558 function schedule_autowp_manual_post_rss_event($form_data = array()) {
3559 if (!is_array($form_data) || empty($form_data) || !isset($form_data['website_type'])) {
3560 return;
3561 }
3562
3563 // Schedule the event and pass form data as parameters
3564 $timestamp = time() + 2;
3565 wp_schedule_single_event($timestamp, 'autowp_manual_post_rss_event', array($form_data));
3566 }
3567
3568 // Hook this function to run when the form is submitted
3569 add_action('init', 'schedule_autowp_manual_post_rss_event');
3570
3571
3572
3573
3574 function autowp_manual_post_wp_form_page_setOptions($form_data){
3575
3576
3577 $autowp_admin_email = autowp_get_admin_email();
3578 $autowp_domain_name = esc_url(get_site_url());
3579 $website_domainname = sanitize_url($form_data['domain_name']);
3580 $website_categories = implode(",", array_map('sanitize_text_field', $form_data['website_category_id']));
3581 $post_count = 5;
3582 $post_order = sanitize_text_field($form_data['post_order']);
3583 $post_ids = '';
3584 $title_prompt = sanitize_text_field($form_data['title_prompt']);
3585 $content_prompt = sanitize_text_field($form_data['content_prompt']);
3586 $tags_prompt = sanitize_text_field($form_data['tags_prompt']);
3587 $image_prompt = sanitize_text_field($form_data['image_prompt']);
3588
3589 $author_selection = sanitize_text_field($form_data['author_selection']) ?? 1;
3590
3591 $aigenerated_title = '0';
3592 $aigenerated_content = '0';
3593 $aigenerated_tags = '0';
3594 $aigenerated_image = '0';
3595
3596 if(isset($form_data['aigenerated_title'])){
3597 $aigenerated_title = sanitize_text_field($form_data['aigenerated_title']);
3598 }
3599
3600 if(isset($form_data['aigenerated_content'])){
3601 $aigenerated_content = sanitize_text_field($form_data['aigenerated_content']);
3602 }
3603
3604 if(isset($form_data['aigenerated_tags'])){
3605 $aigenerated_tags = sanitize_text_field($form_data['aigenerated_tags']);
3606 }
3607
3608 if(isset($form_data['aigenerated_image'])){
3609 $aigenerated_image = sanitize_text_field($form_data['aigenerated_image']);
3610 }
3611
3612
3613 $image_settings = unserialize(get_option('autowp_settings'));
3614 $image_settings_json = [];
3615
3616 if(!empty($image_settings)){
3617 $image_settings_json = json_encode($image_settings);
3618 }
3619
3620
3621
3622
3623 $source_type = 'wordpress';
3624
3625
3626 $wordpress_categories = isset($form_data['category_id']) ? array_map('intval', $form_data['category_id']) : array();
3627
3628 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
3629
3630 $prompts_option = get_option('autowp_rewriting_promptscheme');
3631 $prompt_option_str = strval($prompts_option);
3632 $rewriting_prompt_scheme = [];
3633
3634 if (!empty($prompts_option)) {
3635 $rewriting_prompt_scheme = json_encode($prompts_option);
3636
3637 // JSON'dan diziye dönüşüm yapılıyor ve true ile birlikte kullanıldığı için asosiyatif dizi elde ediliyor
3638 }
3639
3640 $user_email = autowp_get_user_email_from_settings();
3641
3642 $get_data_from_api = autowp_get_posts_from_wp_website($autowp_domain_name, $user_email, $website_domainname, $website_categories, $post_count,$post_order,$post_ids,$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings_json,$source_type,$image_generating_status,$prompt_option_str);
3643 $wp_posts = $get_data_from_api['autowp-api'];
3644
3645
3646
3647
3648 if($get_data_from_api['error']){
3649 update_option('autowp_alerts', $get_data_from_api['error']);
3650
3651 }else{
3652 update_option('autowp_alerts', '');
3653 if(!empty($wp_posts)){
3654 // autowp_show_alert_with_message(true,'Success!');
3655 }else{
3656 // autowp_show_alert_with_message(false,'There is no new post from your feed url!');
3657 update_option('autowp_alerts', 'There is no new post from your feed url!');
3658 }
3659 }
3660
3661
3662
3663
3664 foreach($wp_posts as $post){
3665
3666 $post_ids = $post_ids . ',' . $post['post_id'] . $post['slug'];
3667 $post_title = $post['post_title'];
3668 $post_content = $post['content'];
3669 $post_featured_image = $post['preview_image_original'];
3670 $post_tags = $post['tags'];
3671 $post_status = $image_settings['post_status'] ?? 'publish';
3672 $post_author = $author_selection;
3673 $post_type = 'post';
3674 $focus_keyword = $post['focus_keyword'];
3675 $faq_schema = $post['faq_schema'];
3676
3677
3678 autowp_set_new_post($post_title,$post_content,$post_status,$post_author,$post_type,$post_featured_image, $wordpress_categories,$post_tags,$focus_keyword,$faq_schema);
3679
3680
3681 }
3682
3683 autowp_update_published_post_ids($post_ids);
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693 }
3694
3695 function autowp_manual_post_news_form_page_setOptions($form_data){
3696
3697
3698 $autowp_admin_email = autowp_get_admin_email();
3699 $autowp_domain_name = esc_url(get_site_url());
3700 $website_domainname = sanitize_url($form_data['domain_name']);
3701 $website_categories = '1,2,3';
3702 $post_count = 5;
3703 $post_order = sanitize_text_field($form_data['post_order']);
3704 $post_ids = '';
3705 $title_prompt = sanitize_text_field($form_data['title_prompt']);
3706 $content_prompt = sanitize_text_field($form_data['content_prompt']);
3707 $tags_prompt = sanitize_text_field($form_data['tags_prompt']);
3708 $image_prompt = sanitize_text_field($form_data['image_prompt']);
3709
3710 $author_selection = sanitize_text_field($form_data['author_selection']) ?? 1;
3711
3712 $aigenerated_title = '0';
3713 $aigenerated_content = '0';
3714 $aigenerated_tags = '0';
3715 $aigenerated_image = '0';
3716
3717 if(isset($form_data['aigenerated_title'])){
3718 $aigenerated_title = sanitize_text_field($form_data['aigenerated_title']);
3719 }
3720
3721 if(isset($form_data['aigenerated_content'])){
3722 $aigenerated_content = sanitize_text_field($form_data['aigenerated_content']);
3723 }
3724
3725 if(isset($form_data['aigenerated_tags'])){
3726 $aigenerated_tags = sanitize_text_field($form_data['aigenerated_tags']);
3727 }
3728
3729 if(isset($form_data['aigenerated_image'])){
3730 $aigenerated_image = sanitize_text_field($form_data['aigenerated_image']);
3731 }
3732
3733
3734 $image_settings = unserialize(get_option('autowp_settings'));
3735 $image_settings_json = [];
3736
3737 if(!empty($image_settings)){
3738 $image_settings_json = json_encode($image_settings);
3739 }
3740
3741
3742
3743
3744 $source_type = 'news';
3745
3746
3747 $wordpress_categories = isset($form_data['category_id']) ? array_map('intval', $form_data['category_id']) : array();
3748
3749 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
3750
3751
3752
3753 $news_keyword = sanitize_text_field($form_data['news_keyword']); // New field for News website
3754 $news_country = sanitize_text_field($form_data['news_country']);
3755 $news_language = sanitize_text_field($form_data['news_language']);
3756 $news_time_published = sanitize_text_field($form_data['news_time_published']);
3757
3758 $prompts_option = get_option('autowp_rewriting_promptscheme');
3759 $prompt_option_str = strval($prompts_option);
3760 $rewriting_prompt_scheme = [];
3761
3762 if (!empty($prompts_option)) {
3763 $rewriting_prompt_scheme = json_encode($prompts_option);
3764
3765 // JSON'dan diziye dönüşüm yapılıyor ve true ile birlikte kullanıldığı için asosiyatif dizi elde ediliyor
3766 }
3767
3768 $user_email = autowp_get_user_email_from_settings();
3769
3770
3771 $get_data_from_api = autowp_get_posts_from_wp_website($autowp_domain_name, $user_email, $website_domainname, $website_categories, $post_count,$post_order,$post_ids,$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings_json,$source_type,$image_generating_status,$news_keyword,$news_country,$news_language,$news_time_published,$prompt_option_str);
3772 $wp_posts = $get_data_from_api['autowp-api'];
3773
3774
3775
3776
3777 if($get_data_from_api['error']){
3778 update_option('autowp_alerts', $get_data_from_api['error']);
3779
3780 }else{
3781 update_option('autowp_alerts', '');
3782 if(!empty($wp_posts)){
3783 // autowp_show_alert_with_message(true,'Success!');
3784 }else{
3785 // autowp_show_alert_with_message(false,'There is no new post from your feed url!');
3786 update_option('autowp_alerts', 'There is no new post from your feed url!');
3787 }
3788 }
3789
3790
3791
3792
3793 foreach($wp_posts as $post){
3794
3795 $post_ids = $post_ids . ',' . $post['post_id'] . $post['slug'];
3796 $post_title = $post['post_title'];
3797 $post_content = $post['content'];
3798 $post_featured_image = $post['preview_image_original'];
3799 $post_tags = $post['tags'];
3800 $post_status = $image_settings['post_status'] ?? 'publish';
3801 $post_author = $author_selection;
3802 $post_type = 'post';
3803 $focus_keyword = $post['focus_keyword'];
3804 $faq_schema = $post['faq_schema'];
3805
3806
3807 autowp_set_new_post($post_title,$post_content,$post_status,$post_author,$post_type,$post_featured_image, $wordpress_categories,$post_tags,$focus_keyword,$faq_schema);
3808
3809
3810 }
3811
3812 autowp_update_published_post_ids($post_ids);
3813
3814
3815
3816
3817
3818
3819
3820 }
3821
3822
3823
3824
3825 function autowp_manual_post_news_form_page_handler(){
3826 //autowp_manual_post_news_form_page_setOptions();
3827
3828 if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_manual_post_news_nonce')) {
3829
3830 $form_data = $_POST;
3831
3832 $form_data['website_type'] = 'news';
3833
3834 $form_data['content_prompt'] = '[autowp-rewriting-promptcode]' .
3835 sanitize_text_field($form_data['languageSelect']) . ',' .
3836 sanitize_text_field($form_data['subtitleSelect']) . ',' .
3837 sanitize_text_field($form_data['narrationSelect']) .
3838 '[/autowp-rewriting-promptcode]';
3839
3840 $validate_form = autowp_validate_website($form_data,true);
3841
3842
3843
3844 if($validate_form === true){
3845 autowp_show_alert_with_message(true,'Your process successfully started!');
3846 schedule_autowp_manual_post_rss_event($form_data);
3847 }else{
3848
3849
3850 autowp_show_alert_with_message(false,$validate_form);
3851
3852 }
3853
3854
3855
3856
3857 }
3858
3859 ?>
3860 <div class="wrap">
3861 <h1>Manual Post - News</h1>
3862 <a href="javascript:history.back()" class="btn btn-primary">Go Back</a>
3863
3864 <div id="poststuff">
3865 <div id="post-body" class="metabox-holder columns-2">
3866 <!-- Main Content -->
3867 <div id="post-body-content">
3868 <div class="meta-box-sortables ui-sortable">
3869 <div class="postbox">
3870 <h2 class="hndle ui-sortable-handle">Manual News Settings</h2>
3871 <div class="inside">
3872 <div id="loading">
3873 <div class="loader">
3874 <div class="inner one"></div>
3875 <div class="inner two"></div>
3876 <div class="inner three"></div>
3877 </div>
3878 </div>
3879 <form id="autowp_manual_post_form" method="post">
3880 <?php wp_nonce_field('autowp_manual_post_news_nonce', '_wpnonce'); ?>
3881
3882 <div class="form2bc">
3883 <div class="container">
3884 <form class="row g-3" id="post_generation_form">
3885 <div class="col-md-6">
3886 <label for="website_name" class="form-label">Name:</label>
3887 <input id="website_name" name="website_name" type="text" value="" class="form-control" required>
3888 </div>
3889 <div class="col-md-6">
3890 <label class="form-label" for="author_selection">Author Selection:</label>
3891 <select name="author_selection" id="author_selection" class="form-select">
3892 <?php
3893 $authors = get_users();
3894
3895 foreach ($authors as $author) {
3896 $author_id = $author->ID;
3897 $author_name = $author->display_name;
3898
3899 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
3900 }
3901 ?>
3902 </select>
3903 </div>
3904
3905 <div class="col-md-6">
3906 <label for="category_id" class="form-label">Categories:</label>
3907 <select id="category_id" name="category_id[]" class="form-select" required multiple>
3908 <?php
3909
3910
3911 $categories = get_categories(array(
3912 'orderby' => 'name',
3913 'order' => 'ASC',
3914 'hide_empty' => false
3915 ));
3916
3917 foreach ($categories as $category) {
3918
3919 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
3920 }
3921 ?>
3922 </select>
3923 </div>
3924
3925 <div class="col-md-6">
3926 <label for="news_keyword" class="form-label">Keyword:</label>
3927 <input id="news_keyword" name="news_keyword" type="text" value="" class="form-control">
3928 </div>
3929
3930 <div class="col-md-6">
3931 <label class="form-label" for="news_country">News Country:</label>
3932 <select name="news_country" class="form-select">
3933 <!-- ISO 3166-1 alpha-2 country codes -->
3934 <!-- Replace with actual country codes and names -->
3935 <?php
3936 $countries = [
3937 'any' => 'Anywhere',
3938 'AF' => 'Afghanistan',
3939 'AX' => '�
3940 land Islands',
3941 'AL' => 'Albania',
3942 'DZ' => 'Algeria',
3943 'AS' => 'American Samoa',
3944 'AD' => 'Andorra',
3945 'AO' => 'Angola',
3946 'AI' => 'Anguilla',
3947 'AQ' => 'Antarctica',
3948 'AG' => 'Antigua and Barbuda',
3949 'AR' => 'Argentina',
3950 'AM' => 'Armenia',
3951 'AW' => 'Aruba',
3952 'AU' => 'Australia',
3953 'AT' => 'Austria',
3954 'AZ' => 'Azerbaijan',
3955 'BS' => 'Bahamas',
3956 'BH' => 'Bahrain',
3957 'BD' => 'Bangladesh',
3958 'BB' => 'Barbados',
3959 'BY' => 'Belarus',
3960 'BE' => 'Belgium',
3961 'BZ' => 'Belize',
3962 'BJ' => 'Benin',
3963 'BM' => 'Bermuda',
3964 'BT' => 'Bhutan',
3965 'BO' => 'Bolivia, Plurinational State of',
3966 'BQ' => 'Bonaire, Sint Eustatius and Saba',
3967 'BA' => 'Bosnia and Herzegovina',
3968 'BW' => 'Botswana',
3969 'BV' => 'Bouvet Island',
3970 'BR' => 'Brazil',
3971 'IO' => 'British Indian Ocean Territory',
3972 'BN' => 'Brunei Darussalam',
3973 'BG' => 'Bulgaria',
3974 'BF' => 'Burkina Faso',
3975 'BI' => 'Burundi',
3976 'KH' => 'Cambodia',
3977 'CM' => 'Cameroon',
3978 'CA' => 'Canada',
3979 'CV' => 'Cape Verde',
3980 'KY' => 'Cayman Islands',
3981 'CF' => 'Central African Republic',
3982 'TD' => 'Chad',
3983 'CL' => 'Chile',
3984 'CN' => 'China',
3985 'CX' => 'Christmas Island',
3986 'CC' => 'Cocos (Keeling) Islands',
3987 'CO' => 'Colombia',
3988 'KM' => 'Comoros',
3989 'CG' => 'Congo',
3990 'CD' => 'Congo, the Democratic Republic of the',
3991 'CK' => 'Cook Islands',
3992 'CR' => 'Costa Rica',
3993 'CI' => "Côte d'Ivoire",
3994 'HR' => 'Croatia',
3995 'CU' => 'Cuba',
3996 'CW' => 'Curaçao',
3997 'CY' => 'Cyprus',
3998 'CZ' => 'Czech Republic',
3999 'DK' => 'Denmark',
4000 'DJ' => 'Djibouti',
4001 'DM' => 'Dominica',
4002 'DO' => 'Dominican Republic',
4003 'EC' => 'Ecuador',
4004 'EG' => 'Egypt',
4005 'SV' => 'El Salvador',
4006 'GQ' => 'Equatorial Guinea',
4007 'ER' => 'Eritrea',
4008 'EE' => 'Estonia',
4009 'ET' => 'Ethiopia',
4010 'FK' => 'Falkland Islands (Malvinas)',
4011 'FO' => 'Faroe Islands',
4012 'FJ' => 'Fiji',
4013 'FI' => 'Finland',
4014 'FR' => 'France',
4015 'GF' => 'French Guiana',
4016 'PF' => 'French Polynesia',
4017 'TF' => 'French Southern Territories',
4018 'GA' => 'Gabon',
4019 'GM' => 'Gambia',
4020 'GE' => 'Georgia',
4021 'DE' => 'Germany',
4022 'GH' => 'Ghana',
4023 'GI' => 'Gibraltar',
4024 'GR' => 'Greece',
4025 'GL' => 'Greenland',
4026 'GD' => 'Grenada',
4027 'GP' => 'Guadeloupe',
4028 'GU' => 'Guam',
4029 'GT' => 'Guatemala',
4030 'GG' => 'Guernsey',
4031 'GN' => 'Guinea',
4032 'GW' => 'Guinea-Bissau',
4033 'GY' => 'Guyana',
4034 'HT' => 'Haiti',
4035 'HM' => 'Heard Island and McDonald Islands',
4036 'VA' => 'Holy See (Vatican City State)',
4037 'HN' => 'Honduras',
4038 'HK' => 'Hong Kong',
4039 'HU' => 'Hungary',
4040 'IS' => 'Iceland',
4041 'IN' => 'India',
4042 'ID' => 'Indonesia',
4043 'IR' => 'Iran, Islamic Republic of',
4044 'IQ' => 'Iraq',
4045 'IE' => 'Ireland',
4046 'IM' => 'Isle of Man',
4047 'IL' => 'Israel',
4048 'IT' => 'Italy',
4049 'JM' => 'Jamaica',
4050 'JP' => 'Japan',
4051 'JE' => 'Jersey',
4052 'JO' => 'Jordan',
4053 'KZ' => 'Kazakhstan',
4054 'KE' => 'Kenya',
4055 'KI' => 'Kiribati',
4056 'KP' => "Korea, Democratic People's Republic of",
4057 'KR' => 'Korea, Republic of',
4058 'KW' => 'Kuwait',
4059 'KG' => 'Kyrgyzstan',
4060 'LA' => "Lao People's Democratic Republic",
4061 'LV' => 'Latvia',
4062 'LB' => 'Lebanon',
4063 'LS' => 'Lesotho',
4064 'LR' => 'Liberia',
4065 'LY' => 'Libya',
4066 'LI' => 'Liechtenstein',
4067 'LT' => 'Lithuania',
4068 'LU' => 'Luxembourg',
4069 'MO' => 'Macao',
4070 'MK' => 'Macedonia, The Former Yugoslav Republic of',
4071 'MG' => 'Madagascar',
4072 'MW' => 'Malawi',
4073 'MY' => 'Malaysia',
4074 'MV' => 'Maldives',
4075 'ML' => 'Mali',
4076 'MT' => 'Malta',
4077 'MH' => 'Marshall Islands',
4078 'MQ' => 'Martinique',
4079 'MR' => 'Mauritania',
4080 'MU' => 'Mauritius',
4081 'YT' => 'Mayotte',
4082 'MX' => 'Mexico',
4083 'FM' => 'Micronesia, Federated States of',
4084 'MD' => 'Moldova, Republic of',
4085 'MC' => 'Monaco',
4086 'MN' => 'Mongolia',
4087 'ME' => 'Montenegro',
4088 'MS' => 'Montserrat',
4089 'MA' => 'Morocco',
4090 'MZ' => 'Mozambique',
4091 'MM' => 'Myanmar',
4092 'NA' => 'Namibia',
4093 'NR' => 'Nauru',
4094 'NP' => 'Nepal',
4095 'NL' => 'Netherlands',
4096 'NC' => 'New Caledonia',
4097 'NZ' => 'New Zealand',
4098 'NI' => 'Nicaragua',
4099 'NE' => 'Niger',
4100 'NG' => 'Nigeria',
4101 'NU' => 'Niue',
4102 'NF' => 'Norfolk Island',
4103 'MP' => 'Northern Mariana Islands',
4104 'NO' => 'Norway',
4105 'OM' => 'Oman',
4106 'PK' => 'Pakistan',
4107 'PW' => 'Palau',
4108 'PS' => 'Palestinian Territory, Occupied',
4109 'PA' => 'Panama',
4110 'PG' => 'Papua New Guinea',
4111 'PY' => 'Paraguay',
4112 'PE' => 'Peru',
4113 'PH' => 'Philippines',
4114 'PN' => 'Pitcairn',
4115 'PL' => 'Poland',
4116 'PT' => 'Portugal',
4117 'PR' => 'Puerto Rico',
4118 'QA' => 'Qatar',
4119 'RE' => 'Réunion',
4120 'RO' => 'Romania',
4121 'RU' => 'Russian Federation',
4122 'RW' => 'Rwanda',
4123 'BL' => 'Saint Barthélemy',
4124 'SH' => 'Saint Helena, Ascension and Tristan da Cunha',
4125 'KN' => 'Saint Kitts and Nevis',
4126 'LC' => 'Saint Lucia',
4127 'MF' => 'Saint Martin (French part)',
4128 'PM' => 'Saint Pierre and Miquelon',
4129 'VC' => 'Saint Vincent and the Grenadines',
4130 'WS' => 'Samoa',
4131 'SM' => 'San Marino',
4132 'ST' => 'Sao Tome and Principe',
4133 'SA' => 'Saudi Arabia',
4134 'SN' => 'Senegal',
4135 'RS' => 'Serbia',
4136 'SC' => 'Seychelles',
4137 'SL' => 'Sierra Leone',
4138 'SG' => 'Singapore',
4139 'SX' => 'Sint Maarten (Dutch part)',
4140 'SK' => 'Slovakia',
4141 'SI' => 'Slovenia',
4142 'SB' => 'Solomon Islands',
4143 'SO' => 'Somalia',
4144 'ZA' => 'South Africa',
4145 'GS' => 'South Georgia and the South Sandwich Islands',
4146 'SS' => 'South Sudan',
4147 'ES' => 'Spain',
4148 'LK' => 'Sri Lanka',
4149 'SD' => 'Sudan',
4150 'SR' => 'Suriname',
4151 'SJ' => 'Svalbard and Jan Mayen',
4152 'SZ' => 'Swaziland',
4153 'SE' => 'Sweden',
4154 'CH' => 'Switzerland',
4155 'SY' => 'Syrian Arab Republic',
4156 'TW' => 'Taiwan, Province of China',
4157 'TJ' => 'Tajikistan',
4158 'TZ' => 'Tanzania, United Republic of',
4159 'TH' => 'Thailand',
4160 'TL' => 'Timor-Leste',
4161 'TG' => 'Togo',
4162 'TK' => 'Tokelau',
4163 'TO' => 'Tonga',
4164 'TT' => 'Trinidad and Tobago',
4165 'TN' => 'Tunisia',
4166 'TR' => 'Turkey',
4167 'TM' => 'Turkmenistan',
4168 'TC' => 'Turks and Caicos Islands',
4169 'TV' => 'Tuvalu',
4170 'UG' => 'Uganda',
4171 'UA' => 'Ukraine',
4172 'AE' => 'United Arab Emirates',
4173 'GB' => 'United Kingdom',
4174 'US' => 'United States',
4175 'UM' => 'United States Minor Outlying Islands',
4176 'UY' => 'Uruguay',
4177 'UZ' => 'Uzbekistan',
4178 'VU' => 'Vanuatu',
4179 'VE' => 'Venezuela, Bolivarian Republic of',
4180 'VN' => 'Viet Nam',
4181 'VG' => 'Virgin Islands, British',
4182 'VI' => 'Virgin Islands, U.S.',
4183 'WF' => 'Wallis and Futuna',
4184 'EH' => 'Western Sahara',
4185 'YE' => 'Yemen',
4186 'ZM' => 'Zambia',
4187 'ZW' => 'Zimbabwe',
4188 ];
4189
4190 foreach ($countries as $code => $name) {
4191
4192 echo '<option value="' . esc_attr($code) . '">' . esc_html($name) . '</option>';
4193 }
4194 ?>
4195 </select>
4196 </div>
4197
4198
4199 <div class="col-md-6">
4200 <label class="form-label" for="news_language">Language:</label>
4201 <select name="news_language" class="form-select">
4202 <!-- ISO 639-1 alpha-2 language codes -->
4203 <!-- Replace with actual language codes and names -->
4204 <?php
4205 $languages = [
4206 'any' => 'Any Language',
4207 'af' => 'Afrikaans',
4208 'sq' => 'Albanian',
4209 'am' => 'Amharic',
4210 'ar' => 'Arabic',
4211 'hy' => 'Armenian',
4212 'az' => 'Azerbaijani',
4213 'eu' => 'Basque',
4214 'be' => 'Belarusian',
4215 'bn' => 'Bengali',
4216 'bs' => 'Bosnian',
4217 'bg' => 'Bulgarian',
4218 'ca' => 'Catalan',
4219 'ceb' => 'Cebuano',
4220 'ny' => 'Chichewa',
4221 'zh-CN' => 'Chinese',
4222 'co' => 'Corsican',
4223 'hr' => 'Croatian',
4224 'cs' => 'Czech',
4225 'da' => 'Danish',
4226 'nl' => 'Dutch',
4227 'en' => 'English',
4228 'eo' => 'Esperanto',
4229 'et' => 'Estonian',
4230 'tl' => 'Filipino',
4231 'fi' => 'Finnish',
4232 'fr' => 'French',
4233 'fy' => 'Frisian',
4234 'gl' => 'Galician',
4235 'ka' => 'Georgian',
4236 'de' => 'German',
4237 'el' => 'Greek',
4238 'gu' => 'Gujarati',
4239 'ht' => 'Haitian Creole',
4240 'ha' => 'Hausa',
4241 'haw' => 'Hawaiian',
4242 'iw' => 'Hebrew',
4243 'hi' => 'Hindi',
4244 'hmn' => 'Hmong',
4245 'hu' => 'Hungarian',
4246 'is' => 'Icelandic',
4247 'ig' => 'Igbo',
4248 'id' => 'Indonesian',
4249 'ga' => 'Irish',
4250 'it' => 'Italian',
4251 'ja' => 'Japanese',
4252 'jw' => 'Javanese',
4253 'kn' => 'Kannada',
4254 'kk' => 'Kazakh',
4255 'km' => 'Khmer',
4256 'ko' => 'Korean',
4257 'ku' => 'Kurdish (Kurmanji)',
4258 'ky' => 'Kyrgyz',
4259 'lo' => 'Lao',
4260 'la' => 'Latin',
4261 'lv' => 'Latvian',
4262 'lt' => 'Lithuanian',
4263 'lb' => 'Luxembourgish',
4264 'mk' => 'Macedonian',
4265 'mg' => 'Malagasy',
4266 'ms' => 'Malay',
4267 'ml' => 'Malayalam',
4268 'mt' => 'Maltese',
4269 'mi' => 'Maori',
4270 'mr' => 'Marathi',
4271 'mn' => 'Mongolian',
4272 'my' => 'Myanmar (Burmese)',
4273 'ne' => 'Nepali',
4274 'no' => 'Norwegian',
4275 'ps' => 'Pashto',
4276 'fa' => 'Persian',
4277 'pl' => 'Polish',
4278 'pt' => 'Portuguese',
4279 'pa' => 'Punjabi',
4280 'ro' => 'Romanian',
4281 'ru' => 'Russian',
4282 'sm' => 'Samoan',
4283 'gd' => 'Scots Gaelic',
4284 'sr' => 'Serbian',
4285 'st' => 'Sesotho',
4286 'sn' => 'Shona',
4287 'sd' => 'Sindhi',
4288 'si' => 'Sinhala',
4289 'sk' => 'Slovak',
4290 'sl' => 'Slovenian',
4291 'so' => 'Somali',
4292 'es' => 'Spanish',
4293 'su' => 'Sundanese',
4294 'sw' => 'Swahili',
4295 'sv' => 'Swedish',
4296 'tg' => 'Tajik',
4297 'ta' => 'Tamil',
4298 'te' => 'Telugu',
4299 'th' => 'Thai',
4300 'tr' => 'Turkish',
4301 'uk' => 'Ukrainian',
4302 'ur' => 'Urdu',
4303 'uz' => 'Uzbek',
4304 'vi' => 'Vietnamese',
4305 'cy' => 'Welsh',
4306 'xh' => 'Xhosa',
4307 'yi' => 'Yiddish',
4308 'yo' => 'Yoruba',
4309 'zu' => 'Zulu',
4310 ];
4311
4312 foreach ($languages as $code => $name) {
4313
4314 echo '<option value="' . esc_attr($code) . '">' . esc_html($name) . '</option>';
4315 }
4316 ?>
4317 </select>
4318 </div>
4319
4320 <div class="col-md-6">
4321 <label class="form-label" for="news_time_published">Time Published:</label>
4322 <select name="news_time_published" class="form-select">
4323 <?php
4324 $time_options = [
4325 'anytime' => 'Anytime',
4326 '1h' => 'Last Hour',
4327 '1d' => 'Last Day',
4328 '7d' => 'Last 7 Days',
4329 '1y' => 'Last Year',
4330 ];
4331
4332 foreach ($time_options as $value => $label) {
4333 echo '<option value="' . esc_attr($value) . '">' . esc_html($label) . '</option>';
4334 }
4335 ?>
4336 </select>
4337 </div>
4338
4339
4340 <div class="col-md-6">
4341 <label for="domain_name" class="form-label">Source URL (optional):</label>
4342 <input id="domain_name" name="domain_name" type="text" value="" class="form-control">
4343 </div>
4344 <br>
4345 <p>If you want to get news from a specific source website, enter the site's address here. It is not mandatory to fill in this field.</p>
4346
4347
4348 <div class="col-md-6">
4349 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
4350 <select name="image_generating_status" class="form-select">
4351 <option value="0"><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
4352 <option value="1"><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
4353 <option value="2"><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
4354 <option value="3"><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
4355 <option value="4"><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
4356 <option value="5"><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
4357
4358 <option value="6"><?php esc_html_e('Default Image', 'autowp'); ?></option>
4359 <option value="7"><?php esc_html_e('No Image', 'autowp'); ?></option>
4360 </select>
4361 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet.', 'autowp'); ?></p>
4362 </div>
4363
4364
4365 <div class="col-md-6">
4366 <label for="post_order" class="form-label">Post Order:</label>
4367 <select id="post_order" name="post_order" class="form-select">
4368 <option value="desc">Latest First</option>
4369 <option value="asc">Oldest First</option>
4370 <option value="rand">Random</option>
4371 </select>
4372 </div>
4373
4374
4375
4376
4377 <br>
4378 <h4 style="font-weight: bold;">Post Settings</h4>
4379
4380 <br>
4381
4382 <div class="col-md-6">
4383 <label for="languageSelect" class="form-label">Post Language:</label>
4384 <select class="form-select" id="languageSelect" name="languageSelect">
4385 <?php
4386 $languages = [
4387 "Afrikaans",
4388 "Albanian",
4389 "Arabic",
4390 "Armenian",
4391 "Basque",
4392 "Bengali",
4393 "Bulgarian",
4394 "Catalan",
4395 "Cambodian",
4396 "Chinese (Mandarin)",
4397 "Croatian",
4398 "Czech",
4399 "Danish",
4400 "Dutch",
4401 "English",
4402 "Estonian",
4403 "Fiji",
4404 "Finnish",
4405 "French",
4406 "Georgian",
4407 "German",
4408 "Greek",
4409 "Gujarati",
4410 "Hebrew",
4411 "Hindi",
4412 "Hungarian",
4413 "Icelandic",
4414 "Indonesian",
4415 "Irish",
4416 "Italian",
4417 "Japanese",
4418 "Javanese",
4419 "Korean",
4420 "Latin",
4421 "Latvian",
4422 "Lithuanian",
4423 "Macedonian",
4424 "Malay",
4425 "Malayalam",
4426 "Maltese",
4427 "Maori",
4428 "Marathi",
4429 "Mongolian",
4430 "Nepali",
4431 "Norwegian",
4432 "Persian",
4433 "Polish",
4434 "Portuguese",
4435 "Punjabi",
4436 "Quechua",
4437 "Romanian",
4438 "Russian",
4439 "Samoan",
4440 "Serbian",
4441 "Slovak",
4442 "Slovenian",
4443 "Spanish",
4444 "Swahili",
4445 "Swedish",
4446 "Tamil",
4447 "Tatar",
4448 "Telugu",
4449 "Thai",
4450 "Tibetan",
4451 "Tonga",
4452 "Turkish",
4453 "Ukrainian",
4454 "Urdu",
4455 "Uzbek",
4456 "Vietnamese",
4457 "Welsh",
4458 "Xhosa"
4459 ];
4460 ?>
4461 <?php foreach ($languages as $language): ?>
4462 <option value="<?php echo esc_attr($language); ?>">
4463 <?php echo esc_html($language); ?>
4464 </option>
4465 <?php endforeach; ?>
4466
4467
4468 </select>
4469 </div>
4470 <br>
4471 <div class="col-md-6">
4472 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
4473 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
4474 <?php
4475 for ($i = 1; $i <= 10; $i++) {
4476 echo '<option value="' . esc_attr($i) . '">' . esc_html($i) . '</option>';
4477 }
4478 ?>
4479 </select>
4480 </div>
4481 <br>
4482 <div class="col-md-6">
4483 <label for="narrationSelect" class="form-label">Writing Style:</label>
4484 <select class="form-select" id="narrationSelect" name="narrationSelect">
4485 <?php
4486 $styles = [
4487 "Descriptive" => "Descriptive",
4488 "Narrative" => "Narrative",
4489 "Explanatory" => "Explanatory",
4490 "Argumentative" => "Argumentative",
4491 "Comparative" => "Comparative",
4492 "Process Analysis" => "Process Analysis",
4493 "Allegorical" => "Allegorical",
4494 "Chronological" => "Chronological",
4495 "Ironic" => "Ironic",
4496 "ConsistencyAndRepetition" => "Consistency and Repetition",
4497 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
4498 "InternalMonologue" => "Internal Monologue",
4499 "Dialogical" => "Dialogical"
4500 ];
4501 foreach ($styles as $value => $name) {
4502 echo '<option value="' . esc_attr($value) . '">' . esc_html($name) . '</option>';
4503 }
4504 ?>
4505
4506 </select>
4507 <br>
4508 </div>
4509
4510
4511
4512 <div class="mb-3">
4513 <p class="submit">
4514 <input type="submit" name="submit" id="submit" class="btn btn-primary" value="Generate Post">
4515 </p>
4516 </div>
4517
4518 </form>
4519 </div>
4520
4521 </form>
4522 </div>
4523 </div>
4524 </div>
4525 </div>
4526 <!-- Sidebar -->
4527 <div id="postbox-container-1" class="postbox-container">
4528 <!-- Sidebar content here (if any) -->
4529 </div>
4530 </div>
4531 <br class="clear">
4532 </div>
4533 </div>
4534 <?php
4535
4536 }
4537
4538
4539 function get_next_cron_time($cron_id) {
4540 // Önce, wpcron ID'ye ait cron işleminin zamanlamasını alalım
4541 $next_cron_timestamp = wp_next_scheduled($cron_id);
4542
4543 // Eğer bir sonraki tetiklenme zamanı varsa, tarih ve saat formatında geri döndürelim
4544 if ($next_cron_timestamp) {
4545 return date('Y-m-d H:i:s', $next_cron_timestamp);
4546 } else {
4547 // Eğer bir sonraki tetiklenme zamanı yoksa, boş bir değer döndürelim veya hata durumuna göre düzenleyebilirsiniz
4548 return 'Bir sonraki tetiklenme zamanı bulunamadı.';
4549 }
4550 }
4551
4552
4553 function autowp_manual_post_wp_form_page_handler() {
4554 //autowp_manual_post_wp_form_page_setOptions();
4555
4556 if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_manual_post_wp_nonce')) {
4557
4558 $form_data = $_POST;
4559
4560 $form_data['website_type'] = 'wordpress';
4561
4562 $form_data['content_prompt'] = '[autowp-rewriting-promptcode]' .
4563 sanitize_text_field($_POST['languageSelect']) . ',' .
4564 sanitize_text_field($_POST['subtitleSelect']) . ',' .
4565 sanitize_text_field($_POST['narrationSelect']) .
4566 '[/autowp-rewriting-promptcode]';
4567
4568 $validate_form = autowp_validate_website($form_data,true);
4569
4570
4571
4572 if($validate_form === true){
4573 autowp_show_alert_with_message(true,'Your process successfully started!');
4574 schedule_autowp_manual_post_rss_event($form_data);
4575 }else{
4576
4577
4578 autowp_show_alert_with_message(false,$validate_form);
4579
4580 }
4581
4582
4583
4584
4585 }
4586
4587 ?>
4588 <div class="wrap">
4589 <h1>Manual Post - Wordpress</h1>
4590 <a href="javascript:history.back()" class="btn btn-primary">Go Back</a>
4591
4592 <div id="poststuff">
4593 <div id="post-body" class="metabox-holder columns-2">
4594 <!-- Main Content -->
4595 <div id="post-body-content">
4596 <div class="meta-box-sortables ui-sortable">
4597 <div class="postbox">
4598 <h2 class="hndle ui-sortable-handle">Wordpress Settings</h2>
4599 <div class="inside">
4600 <div id="loading">
4601 <div class="loader">
4602 <div class="inner one"></div>
4603 <div class="inner two"></div>
4604 <div class="inner three"></div>
4605 </div>
4606 </div>
4607 <form id="autowp_manual_post_form" method="post">
4608 <?php wp_nonce_field('autowp_manual_post_wp_nonce', '_wpnonce'); ?>
4609
4610 <div class="form2bc">
4611 <div class="container">
4612 <form class="row g-3" id="post_generation_form">
4613 <div class="col-md-6">
4614 <label for="website_name" class="form-label">Website Name:</label>
4615 <?php
4616 $autowp_admin_email = autowp_get_admin_email();
4617 $autowp_domain_name = esc_url(get_site_url());
4618 $is_empty = empty($item['domain_name']);
4619 ?>
4620 <input type="hidden" id="autowp_admin_email" value="<?= esc_attr($autowp_admin_email) ?>">
4621 <input type="hidden" id="autowp_domain_name" value="<?= esc_attr($autowp_domain_name) ?>">
4622 <input id="website_name" name="website_name" type="text" class="form-control" required>
4623 </div>
4624 <div class="col-md-6">
4625 <label for="domain_name" class="form-label">Domain Name:</label>
4626 <input id="domain_name" name="domain_name" type="text" class="form-control" required>
4627 </div>
4628
4629 <div class="col-md-6">
4630 <label for="author_selection" class="form-label"><?php esc_html_e('Author Selection', 'autowp'); ?></label>
4631 <select name="author_selection" class="form-select">
4632 <?php
4633 $authors = get_users();
4634 foreach ($authors as $author) {
4635 $author_id = $author->ID;
4636 $author_name = $author->display_name;
4637 $author_description = get_the_author_meta('description', $author_id);
4638 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
4639 }
4640 ?>
4641 </select>
4642 <p class="form-text"><?php esc_html_e('Select an author from the list.', 'autowp'); ?></p>
4643 </div>
4644
4645 <div class="col-md-6">
4646 <label for="website_category_id" class="form-label">Website Categories:</label>
4647 <br>
4648 <select id="website_category_id" name="website_category_id[]" multiple style="display: none;"></select>
4649 <button type="button" class="btn btn-primary" onclick="refreshWebsiteCategories()">
4650 <i class="bi bi-arrow-clockwise"></i>
4651 Get Categories
4652 </button>
4653 </div>
4654 <br>
4655 <div class="col-md-6">
4656 <label for="category_id" class="form-label">Categories:</label>
4657 <select id="category_id" name="category_id[]" required multiple class="form-select">
4658 <?php
4659 $categories = get_categories(array(
4660 'orderby' => 'name',
4661 'order' => 'ASC',
4662 'hide_empty' => false
4663 ));
4664
4665 foreach ($categories as $category) {
4666 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
4667 }
4668 ?>
4669 </select>
4670 </div>
4671
4672
4673
4674 <div class="col-md-6">
4675 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
4676 <select name="image_generating_status" class="form-select">
4677 <option value="0"><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
4678 <option value="1"><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
4679 <option value="2"><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
4680 <option value="3"><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
4681 <option value="4"><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
4682 <option value="5"><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
4683 <option value="6"><?php esc_html_e('Default Image', 'autowp'); ?></option>
4684 <option value="7"><?php esc_html_e('No Image', 'autowp'); ?></option>
4685 <option value="8"><?php esc_html_e('Original Image', 'autowp'); ?></option>
4686 </select>
4687 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet.', 'autowp'); ?></p>
4688 </div>
4689
4690
4691
4692 <div class="col-md-6">
4693 <label for="post_order" class="form-label">Post Order:</label>
4694 <select id="post_order" name="post_order" class="form-select">
4695 <option value="desc">Latest First</option>
4696 <option value="asc">Oldest First</option>
4697 <option value="rand">Random</option>
4698 </select>
4699 </div>
4700
4701
4702
4703
4704 <h4 style="font-weight: bold;">Post Settings</h4>
4705 <br>
4706 <div class="col-md-6">
4707 <label for="languageSelect" class="form-label">Post Language:</label>
4708 <select class="form-select" id="languageSelect" name="languageSelect">
4709 <?php
4710 $languages = [
4711 "Afrikaans",
4712 "Albanian",
4713 "Arabic",
4714 "Armenian",
4715 "Basque",
4716 "Bengali",
4717 "Bulgarian",
4718 "Catalan",
4719 "Cambodian",
4720 "Chinese (Mandarin)",
4721 "Croatian",
4722 "Czech",
4723 "Danish",
4724 "Dutch",
4725 "English",
4726 "Estonian",
4727 "Fiji",
4728 "Finnish",
4729 "French",
4730 "Georgian",
4731 "German",
4732 "Greek",
4733 "Gujarati",
4734 "Hebrew",
4735 "Hindi",
4736 "Hungarian",
4737 "Icelandic",
4738 "Indonesian",
4739 "Irish",
4740 "Italian",
4741 "Japanese",
4742 "Javanese",
4743 "Korean",
4744 "Latin",
4745 "Latvian",
4746 "Lithuanian",
4747 "Macedonian",
4748 "Malay",
4749 "Malayalam",
4750 "Maltese",
4751 "Maori",
4752 "Marathi",
4753 "Mongolian",
4754 "Nepali",
4755 "Norwegian",
4756 "Persian",
4757 "Polish",
4758 "Portuguese",
4759 "Punjabi",
4760 "Quechua",
4761 "Romanian",
4762 "Russian",
4763 "Samoan",
4764 "Serbian",
4765 "Slovak",
4766 "Slovenian",
4767 "Spanish",
4768 "Swahili",
4769 "Swedish",
4770 "Tamil",
4771 "Tatar",
4772 "Telugu",
4773 "Thai",
4774 "Tibetan",
4775 "Tonga",
4776 "Turkish",
4777 "Ukrainian",
4778 "Urdu",
4779 "Uzbek",
4780 "Vietnamese",
4781 "Welsh",
4782 "Xhosa"
4783 ];
4784 ?>
4785 <?php foreach ($languages as $language): ?>
4786 <option value="<?php echo esc_attr($language); ?>">
4787 <?php echo esc_html($language); ?>
4788 </option>
4789 <?php endforeach; ?>
4790
4791
4792 </select>
4793 </div>
4794 <br>
4795 <div class="col-md-6">
4796 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
4797 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
4798 <?php
4799 for ($i = 1; $i <= 10; $i++) {
4800
4801 echo '<option value="' . esc_attr($i) . '">' . esc_html($i) . '</option>';
4802 }
4803 ?>
4804 </select>
4805 </div>
4806 <br>
4807 <div class="col-md-6">
4808 <label for="narrationSelect" class="form-label">Writing Style:</label>
4809 <select class="form-select" id="narrationSelect" name="narrationSelect">
4810 <?php
4811 $styles = [
4812 "Descriptive" => "Descriptive",
4813 "Narrative" => "Narrative",
4814 "Explanatory" => "Explanatory",
4815 "Argumentative" => "Argumentative",
4816 "Comparative" => "Comparative",
4817 "Process Analysis" => "Process Analysis",
4818 "Allegorical" => "Allegorical",
4819 "Chronological" => "Chronological",
4820 "Ironic" => "Ironic",
4821 "ConsistencyAndRepetition" => "Consistency and Repetition",
4822 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
4823 "InternalMonologue" => "Internal Monologue",
4824 "Dialogical" => "Dialogical"
4825 ];
4826 foreach ($styles as $value => $name) {
4827 echo '<option value="' . esc_attr($value) . '">' . esc_html($name) . '</option>';
4828 }
4829 ?>
4830
4831 </select>
4832
4833 </div>
4834
4835 <div class="col-md-12">
4836 <p class="message">For prompt examples, visit <a class="link" href="https://www.aiprm.com/prompts/">aiprm.com/prompts</a></p>
4837 </div>
4838 <div class="col-12">
4839 <input type="submit" name="submit" id="submit" class="btn btn-primary" value="Generate Post">
4840 </div>
4841 </form>
4842 </div>
4843
4844 </form>
4845 </div>
4846 </div>
4847 </div>
4848 </div>
4849 <!-- Sidebar -->
4850 <div id="postbox-container-1" class="postbox-container">
4851 <!-- Sidebar content here (if any) -->
4852 </div>
4853 </div>
4854 <br class="clear">
4855 </div>
4856 </div>
4857 <?php
4858 }
4859
4860
4861
4862 function autowp_manual_post_rss_scheduled_event($form_data) {
4863 if (!is_array($form_data) || !isset($form_data['website_type'])) {
4864 return;
4865 }
4866
4867 if($form_data['website_type'] === 'rss'){
4868 // Call the function with the form data
4869 autowp_manual_post_rss_form_page_setOptions($form_data);
4870 }else if ( $form_data['website_type'] === 'wordpress'){
4871 autowp_manual_post_wp_form_page_setOptions($form_data);
4872
4873 }else if ($form_data['website_type'] === 'news'){
4874 autowp_manual_post_news_form_page_setOptions($form_data);
4875 }else if ($form_data['website_type'] === 'ai'){
4876 autowp_manual_post_ai_form_page_setOptions($form_data);
4877 }else if ($form_data['website_type'] === 'agenticscraper') {
4878 autowp_manual_post_agenticscraper_form_page_setOptions($form_data);
4879
4880 }
4881
4882 }
4883
4884
4885 // Hook this function to run when the scheduled event occurs
4886 add_action('autowp_manual_post_rss_event', 'autowp_manual_post_rss_scheduled_event');
4887
4888
4889
4890
4891
4892
4893 function autowp_manual_post_rss_form_page_handler() {
4894
4895 if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_manual_post_rss_nonce')) {
4896
4897 $form_data = $_POST;
4898
4899 $form_data['website_type'] = 'rss';
4900
4901
4902 $form_data['content_prompt'] ='[autowp-rewriting-promptcode]' .
4903 sanitize_text_field($form_data['languageSelect']) . ',' .
4904 sanitize_text_field($form_data['subtitleSelect']) . ',' .
4905 sanitize_text_field($form_data['narrationSelect']) .
4906 '[/autowp-rewriting-promptcode]';
4907
4908 $validate_form = autowp_validate_website($form_data,true);
4909
4910
4911
4912 if($validate_form === true){
4913 autowp_show_alert_with_message(true,'Your process successfully started!');
4914 schedule_autowp_manual_post_rss_event($form_data);
4915 }else{
4916
4917
4918 autowp_show_alert_with_message(false,$validate_form);
4919
4920 }
4921
4922
4923
4924
4925 }
4926 ?>
4927
4928 <div class="wrap">
4929 <h1>Manual Post - RSS</h1>
4930 <a href="javascript:history.back()" class="btn btn-primary">Go Back</a>
4931
4932 <div id="poststuff">
4933 <div id="post-body" class="metabox-holder columns-2">
4934 <!-- Main Content -->
4935 <div id="post-body-content">
4936 <div class="meta-box-sortables ui-sortable">
4937 <div class="postbox">
4938 <h2 class="hndle ui-sortable-handle">RSS Settings</h2>
4939 <div class="inside">
4940 <div id="loading">
4941 <div class="loader">
4942 <div class="inner one"></div>
4943 <div class="inner two"></div>
4944 <div class="inner three"></div>
4945 </div>
4946 </div>
4947 <form id="autowp_manual_post_form" method="post">
4948 <?php wp_nonce_field('autowp_manual_post_rss_nonce', '_wpnonce'); ?>
4949 <tbody>
4950 <div class="form2bc">
4951
4952 <div class="container">
4953 <form class="row g-3" id="post_generation_form">
4954 <div class="col-md-6">
4955 <label for="domain_name" class="form-label">RSS Feed URL:</label>
4956 <input id="domain_name" name="domain_name" type="text" class="form-control" value="" required>
4957 <p class="form-text"><?php esc_html_e('E.g https://kelimelerbenim.com/feed', 'autowp'); ?></p>
4958 </div>
4959
4960 <div class="col-md-6">
4961 <label for="category_id" class="form-label">Categories:</label>
4962 <select id="category_id" name="category_id[]" required multiple class="form-select">
4963 <?php
4964 $categories = get_categories(array(
4965 'orderby' => 'name',
4966 'order' => 'ASC',
4967 'hide_empty' => false
4968 ));
4969
4970 foreach ($categories as $category) {
4971 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
4972 }
4973 ?>
4974 </select>
4975 </div>
4976
4977 <div class="col-md-6">
4978 <label for="author_selection" class="form-label"><?php esc_html_e('Author Selection', 'autowp'); ?></label>
4979 <select name="author_selection" class="form-select">
4980 <?php
4981 $authors = get_users();
4982 foreach ($authors as $author) {
4983 $author_id = $author->ID;
4984 $author_name = $author->display_name;
4985 $author_description = get_the_author_meta('description', $author_id);
4986 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
4987 }
4988 ?>
4989 </select>
4990 <p class="form-text"><?php esc_html_e('Select an author from the list.', 'autowp'); ?></p>
4991 </div>
4992
4993
4994
4995 <div class="col-md-6">
4996 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
4997 <select name="image_generating_status" class="form-select">
4998 <option value="0"><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
4999 <option value="1"><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
5000 <option value="2"><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
5001 <option value="3"><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
5002 <option value="4"><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
5003 <option value="5"><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
5004 <option value="6"><?php esc_html_e('Default Image', 'autowp'); ?></option>
5005 <option value="7"><?php esc_html_e('No Image', 'autowp'); ?></option>
5006
5007 </select>
5008 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet. ', 'autowp'); ?></p>
5009 </div>
5010
5011
5012
5013 <div class="col-md-6">
5014 <label for="post_order" class="form-label">Post Order:</label>
5015 <select id="post_order" name="post_order" class="form-select">
5016 <option value="desc">Latest First</option>
5017 <option value="asc">Oldest First</option>
5018 <option value="rand">Random</option>
5019 </select>
5020 </div>
5021
5022
5023
5024 <h4 style="font-weight: bold;">Post Settings</h4>
5025 <br>
5026 <div class="col-md-6">
5027 <label for="languageSelect" class="form-label">Post Language:</label>
5028 <select class="form-select" id="languageSelect" name="languageSelect">
5029 <?php
5030 $languages = [
5031 "Afrikaans",
5032 "Albanian",
5033 "Arabic",
5034 "Armenian",
5035 "Basque",
5036 "Bengali",
5037 "Bulgarian",
5038 "Catalan",
5039 "Cambodian",
5040 "Chinese (Mandarin)",
5041 "Croatian",
5042 "Czech",
5043 "Danish",
5044 "Dutch",
5045 "English",
5046 "Estonian",
5047 "Fiji",
5048 "Finnish",
5049 "French",
5050 "Georgian",
5051 "German",
5052 "Greek",
5053 "Gujarati",
5054 "Hebrew",
5055 "Hindi",
5056 "Hungarian",
5057 "Icelandic",
5058 "Indonesian",
5059 "Irish",
5060 "Italian",
5061 "Japanese",
5062 "Javanese",
5063 "Korean",
5064 "Latin",
5065 "Latvian",
5066 "Lithuanian",
5067 "Macedonian",
5068 "Malay",
5069 "Malayalam",
5070 "Maltese",
5071 "Maori",
5072 "Marathi",
5073 "Mongolian",
5074 "Nepali",
5075 "Norwegian",
5076 "Persian",
5077 "Polish",
5078 "Portuguese",
5079 "Punjabi",
5080 "Quechua",
5081 "Romanian",
5082 "Russian",
5083 "Samoan",
5084 "Serbian",
5085 "Slovak",
5086 "Slovenian",
5087 "Spanish",
5088 "Swahili",
5089 "Swedish",
5090 "Tamil",
5091 "Tatar",
5092 "Telugu",
5093 "Thai",
5094 "Tibetan",
5095 "Tonga",
5096 "Turkish",
5097 "Ukrainian",
5098 "Urdu",
5099 "Uzbek",
5100 "Vietnamese",
5101 "Welsh",
5102 "Xhosa"
5103 ];
5104 ?>
5105 <?php foreach ($languages as $language): ?>
5106 <option value="<?php echo esc_attr($language); ?>">
5107 <?php echo esc_html($language); ?>
5108 </option>
5109 <?php endforeach; ?>
5110
5111
5112 </select>
5113 </div>
5114 <br>
5115 <div class="col-md-6">
5116 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
5117 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
5118 <?php
5119 for ($i = 1; $i <= 10; $i++) {
5120 echo '<option value="' . esc_attr($i) . '">' . esc_html($i) . '</option>';
5121 }
5122 ?>
5123 </select>
5124 </div>
5125 <br>
5126 <div class="col-md-6">
5127 <label for="narrationSelect" class="form-label">Writing Style:</label>
5128 <select class="form-select" id="narrationSelect" name="narrationSelect">
5129 <?php
5130 $styles = [
5131 "Descriptive" => "Descriptive",
5132 "Narrative" => "Narrative",
5133 "Explanatory" => "Explanatory",
5134 "Argumentative" => "Argumentative",
5135 "Comparative" => "Comparative",
5136 "Process Analysis" => "Process Analysis",
5137 "Allegorical" => "Allegorical",
5138 "Chronological" => "Chronological",
5139 "Ironic" => "Ironic",
5140 "ConsistencyAndRepetition" => "Consistency and Repetition",
5141 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
5142 "InternalMonologue" => "Internal Monologue",
5143 "Dialogical" => "Dialogical"
5144 ];
5145 foreach ($styles as $value => $name) {
5146 echo '<option value="' . esc_attr($value) . '">' . esc_html($name) . '</option>';
5147 }
5148 ?>
5149
5150 </select>
5151
5152 </div>
5153
5154 <div class="col-md-12">
5155 <p class="message">For prompt examples, visit <a class="link" href="https://www.aiprm.com/prompts/">aiprm.com/prompts</a></p>
5156 </div>
5157 <div class="col-12">
5158 <input type="submit" name="submit" id="submit" class="btn btn-primary" value="Generate Post">
5159 </div>
5160
5161 </form>
5162 </div>
5163
5164 </div>
5165 </tbody>
5166
5167 </form>
5168 </div>
5169 </div>
5170 </div>
5171 </div>
5172 <!-- Sidebar -->
5173 <div id="postbox-container-1" class="postbox-container">
5174 <!-- Sidebar content here (if any) -->
5175 </div>
5176 </div>
5177 <br class="clear">
5178 </div>
5179 </div>
5180
5181
5182 <?php
5183 }
5184
5185 function autowp_manual_post_agenticscraper_form_page_setOptions($form_data) {
5186
5187 // Temel ayarlar
5188 $autowp_admin_email = autowp_get_admin_email();
5189 $autowp_domain_name = esc_url(get_site_url());
5190 $website_domainname = '';
5191 $website_categories = '';
5192 $post_count = '';
5193 $post_order = '';
5194 $post_ids = '';
5195
5196 // Başlık, etiket ve resim promptları kullanılmıyor
5197 $title_prompt = '';
5198 $tags_prompt = '';
5199 $image_prompt = '';
5200
5201 // Kaynak tipi özel formumuz için
5202 $source_type = 'agenticscraper';
5203
5204 // Yazar seçimi (varsayılan 1)
5205 $author_selection = isset($form_data['author_selection']) ? sanitize_text_field($form_data['author_selection']) : 1;
5206
5207 // İçerik promptunda kullanılacak uzun açıklama (long description)
5208 $long_description = sanitize_textarea_field($form_data['long_description']);
5209
5210 $keywordInput = isset($form_data['keywordInput']) ? sanitize_text_field($form_data['keywordInput']) : '';
5211 $languageSelect = isset($form_data['languageSelect']) ? sanitize_text_field($form_data['languageSelect']) : '';
5212 $subtitleSelect = isset($form_data['subtitleSelect']) ? intval($form_data['subtitleSelect']) : 1;
5213 $narrationSelect = isset($form_data['narrationSelect']) ? sanitize_text_field($form_data['narrationSelect']) : '';
5214
5215
5216 $wordpress_categories = isset($form_data['category_id']) ? array_map('intval', $form_data['category_id']) : array();
5217
5218
5219 // Varsayılanlar (başlık, içerik, etiketler için)
5220 $aigenerated_title = '1';
5221 $aigenerated_content = '1';
5222 $aigenerated_tags = '1';
5223 $aigenerated_image = '1';
5224
5225 if(isset($form_data['aigenerated_image'])){
5226 $aigenerated_image = sanitize_text_field($form_data['aigenerated_image']);
5227 }
5228
5229 // Resim ayarlarını alıyoruz
5230 $image_settings = unserialize(get_option('autowp_settings'));
5231 $image_settings_json = !empty($image_settings) ? json_encode($image_settings) : '';
5232
5233 // Bu formda resim oluşturma durumu kullanılmayabilir
5234 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
5235
5236 // Yeniden yazım prompt şeması
5237 $prompts_option = get_option('autowp_rewriting_promptscheme');
5238 $prompt_option_str = strval($prompts_option);
5239
5240 // Kullanıcı e-postasını alıyoruz
5241 $user_email = autowp_get_user_email_from_settings();
5242
5243 /*
5244 * Özel Araçlar (Custom Tools) Ayarları
5245 */
5246 // Website Tools: Knowledge Base URL (varsa, geçerli URL olmalı)
5247 $website_tools_knowledge_base_url = !empty($form_data['website_tools_knowledge_base_url'])
5248 ? sanitize_url($form_data['website_tools_knowledge_base_url'])
5249 : '';
5250
5251 // DuckDuckGO Search ayarları
5252 $duckduckgo_news = isset($form_data['duckduckgo_news']) ? '1' : '0';
5253 $duckduckgo_fixed_max_results = !empty($form_data['duckduckgo_fixed_max_results'])
5254 ? intval($form_data['duckduckgo_fixed_max_results'])
5255 : null;
5256
5257 // Wikipedia ayarları: virgülle ayrılmış konu listesi
5258 $wikipedia_knowledge_base = !empty($form_data['wikipedia_knowledge_base'])
5259 ? sanitize_text_field($form_data['wikipedia_knowledge_base'])
5260 : '';
5261
5262 // YFinanceTools ayarları
5263 $yfinance_stock_price = isset($form_data['yfinance_stock_price']) ? '1' : '0';
5264 $yfinance_company_info = isset($form_data['yfinance_company_info']) ? '1' : '0';
5265 $yfinance_stock_fundamentals = isset($form_data['yfinance_stock_fundamentals']) ? '1' : '0';
5266 $yfinance_income_statements = isset($form_data['yfinance_income_statements']) ? '1' : '0';
5267 $yfinance_key_financial_ratios = isset($form_data['yfinance_key_financial_ratios']) ? '1' : '0';
5268 $yfinance_analyst_recommendations = isset($form_data['yfinance_analyst_recommendations']) ? '1' : '0';
5269 $yfinance_company_news = isset($form_data['yfinance_company_news']) ? '1' : '0';
5270 $yfinance_technical_indicators = isset($form_data['yfinance_technical_indicators']) ? '1' : '0';
5271 $yfinance_historical_prices = isset($form_data['yfinance_historical_prices']) ? '1' : '0';
5272
5273
5274
5275 // Toggles for custom tools and knowledge base
5276 $enable_website_tools = isset($form_data['enable_website_tools']) ? '1' : '0';
5277 $enable_duckduckgo = isset($form_data['enable_duckduckgo']) ? '1' : '0';
5278 $enable_wikipedia = isset($form_data['enable_wikipedia']) ? '1' : '0';
5279 $enable_yfinancetools = isset($form_data['enable_yfinancetools']) ? '1' : '0';
5280 $enable_hackernews = isset($form_data['enable_hackernews']) ? '1' : '0';
5281
5282 $enable_pdf_kb = isset($form_data['enable_pdf_kb']) ? '1' : '0';
5283 $enable_csv_kb = isset($form_data['enable_csv_kb']) ? '1' : '0';
5284 $enable_text_kb = isset($form_data['enable_text_kb']) ? '1' : '0';
5285
5286
5287 // Hacker News ayarları
5288 $hackernews_get_top_stories = isset($form_data['hackernews_get_top_stories']) ? '1' : '0';
5289 $hackernews_get_user_details = isset($form_data['hackernews_get_user_details']) ? '1' : '0';
5290
5291 // Özel araç ayarlarını diziye ekleyelim
5292 $custom_tools = [
5293 'website_tools' => [
5294 'knowledge_base_url' => $website_tools_knowledge_base_url,
5295 ],
5296 'duckduckgo' => [
5297 'news' => $duckduckgo_news,
5298 'fixed_max_results' => $duckduckgo_fixed_max_results,
5299 ],
5300 'wikipedia' => [
5301 'knowledge_base' => $wikipedia_knowledge_base,
5302 ],
5303 'yfinancetools' => [
5304 'stock_price' => $yfinance_stock_price,
5305 'company_info' => $yfinance_company_info,
5306 'stock_fundamentals' => $yfinance_stock_fundamentals,
5307 'income_statements' => $yfinance_income_statements,
5308 'key_financial_ratios' => $yfinance_key_financial_ratios,
5309 'analyst_recommendations' => $yfinance_analyst_recommendations,
5310 'company_news' => $yfinance_company_news,
5311 'technical_indicators' => $yfinance_technical_indicators,
5312 'historical_prices' => $yfinance_historical_prices,
5313 ],
5314 'hackernews' => [
5315 'get_top_stories' => $hackernews_get_top_stories,
5316 'get_user_details' => $hackernews_get_user_details,
5317 ],
5318 ];
5319
5320 /*
5321 * Knowledge Base Ayarları
5322 */
5323 $pdf_url_knowledge_base = !empty($form_data['pdf_url_knowledge_base'])
5324 ? sanitize_url($form_data['pdf_url_knowledge_base'])
5325 : '';
5326 $csv_url_knowledge_base = !empty($form_data['csv_url_knowledge_base'])
5327 ? sanitize_url($form_data['csv_url_knowledge_base'])
5328 : '';
5329 $text_knowledge_base = !empty($form_data['text_knowledge_base'])
5330 ? sanitize_textarea_field($form_data['text_knowledge_base'])
5331 : '';
5332
5333 $knowledge_base = [
5334 'pdf_url' => $pdf_url_knowledge_base,
5335 'csv_url' => $csv_url_knowledge_base,
5336 'text' => $text_knowledge_base,
5337 ];
5338
5339 /*
5340 * Ekstra parametreleri içerik promptu içinde JSON formatında birleştiriyoruz.
5341 * Böylece API çağrısında content_prompt içerisinde hem long description hem de
5342 * custom tools ve knowledge base ayarlarını gönderebiliyoruz.
5343 */
5344 $combined_prompt = [
5345 'content' => $long_description,
5346 'keyword' => $keywordInput,
5347 'language' => $languageSelect,
5348 'subheading_count' => $subtitleSelect,
5349 'writing_style' => $narrationSelect,
5350 'custom_tools' => $custom_tools,
5351 'knowledge_base' => $knowledge_base,
5352 'enable_website_tools' => $enable_website_tools,
5353 'enable_duckduckgo' => $enable_duckduckgo,
5354 'enable_wikipedia' => $enable_wikipedia,
5355 'enable_yfinancetools' => $enable_yfinancetools,
5356 'enable_hackernews' => $enable_hackernews,
5357 'enable_pdf_kb' => $enable_pdf_kb,
5358 'enable_csv_kb' => $enable_csv_kb,
5359 'enable_text_kb' => $enable_text_kb,
5360 ];
5361
5362 $content_prompt = json_encode($combined_prompt);
5363
5364 /*
5365 * API çağrısını mevcut parametrelerle yapıyoruz. Artık ek parametre eklemeye gerek kalmadı.
5366 */
5367 $get_data_from_api = autowp_get_posts_from_wp_website(
5368 $autowp_domain_name,
5369 $user_email,
5370 $website_domainname,
5371 $website_categories,
5372 $post_count,
5373 $post_order,
5374 $post_ids,
5375 $title_prompt,
5376 $content_prompt,
5377 $tags_prompt,
5378 $image_prompt,
5379 $aigenerated_title,
5380 $aigenerated_content,
5381 $aigenerated_tags,
5382 $aigenerated_image,
5383 $image_settings_json,
5384 $source_type,
5385 $image_generating_status,
5386 $prompt_option_str
5387 );
5388 $wp_posts = $get_data_from_api['autowp-api'];
5389
5390 if ($get_data_from_api['error']) {
5391 update_option('autowp_alerts', $get_data_from_api['error']);
5392 } else {
5393 update_option('autowp_alerts', '');
5394 if (empty($wp_posts)) {
5395 update_option('autowp_alerts', 'There is no new post from your feed url!');
5396 }
5397 }
5398
5399 // İşlenen postları oluşturuyoruz
5400 foreach ($wp_posts as $post) {
5401 $post_ids .= ',' . $post['post_id'] . $post['slug'];
5402 $post_title = $post['post_title'];
5403 $post_content = $post['content'];
5404 $post_featured_image = $post['preview_image_original'];
5405 $post_tags = $post['tags'];
5406 $post_status = $image_settings['post_status'] ?? 'publish';
5407 $post_author = $author_selection;
5408 $post_type = 'post';
5409 $focus_keyword = $post['focus_keyword'];
5410 $faq_schema = $post['faq_schema'];
5411
5412 autowp_set_new_post(
5413 $post_title,
5414 $post_content,
5415 $post_status,
5416 $post_author,
5417 $post_type,
5418 $post_featured_image,
5419 $wordpress_categories, // Bu formda kategori gönderilmiyor
5420 $post_tags,
5421 $focus_keyword,
5422 $faq_schema
5423 );
5424 }
5425
5426 autowp_update_published_post_ids($post_ids);
5427 }
5428
5429
5430 function autowp_manual_post_ai_form_page_setOptions($form_data){
5431
5432 $autowp_admin_email = autowp_get_admin_email();
5433 $autowp_domain_name = esc_url(get_site_url());
5434 $website_domainname = '';
5435 $website_categories = '';
5436 $post_count = '';
5437 $post_order = '';
5438 $post_ids = '';
5439 $title_prompt = sanitize_text_field($form_data['title_prompt']);
5440 $content_prompt = sanitize_text_field($form_data['content_prompt']);
5441 $tags_prompt = sanitize_text_field($form_data['tags_prompt']);
5442 $image_prompt = sanitize_text_field($form_data['image_prompt']);
5443
5444 $author_selection = sanitize_text_field($form_data['author_selection']) ?? 1;
5445
5446 $aigenerated_title = '1';
5447 $aigenerated_content = '1';
5448 $aigenerated_tags = '1';
5449 $aigenerated_image = '1';
5450
5451 if(isset($form_data['aigenerated_image'])){
5452 $aigenerated_image = sanitize_text_field($form_data['aigenerated_image']);
5453 }
5454
5455 $image_settings = unserialize(get_option('autowp_settings'));
5456 $image_settings_json = [];
5457
5458 if(!empty($image_settings)){
5459 $image_settings_json = json_encode($image_settings);
5460 }
5461
5462
5463 $source_type = 'ai';
5464
5465
5466 $wordpress_categories = isset($form_data['category_id']) ? array_map('intval', $form_data['category_id']) : array();
5467
5468 $image_generating_status = sanitize_text_field($form_data['image_generating_status']);
5469
5470 $prompts_option = get_option('autowp_rewriting_promptscheme');
5471 $prompt_option_str = strval($prompts_option);
5472 $rewriting_prompt_scheme = [];
5473
5474 if (!empty($prompts_option)) {
5475 $rewriting_prompt_scheme = json_encode($prompts_option);
5476
5477 // JSON'dan diziye dönüşüm yapılıyor ve true ile birlikte kullanıldığı için asosiyatif dizi elde ediliyor
5478 }
5479
5480 $user_email = autowp_get_user_email_from_settings();
5481
5482
5483 $get_data_from_api = autowp_get_posts_from_wp_website($autowp_domain_name, $user_email, $website_domainname, $website_categories, $post_count,$post_order,$post_ids,$title_prompt,$content_prompt,$tags_prompt,$image_prompt,$aigenerated_title,$aigenerated_content,$aigenerated_tags,$aigenerated_image,$image_settings_json,$source_type,$image_generating_status,$prompt_option_str);
5484 $wp_posts = $get_data_from_api['autowp-api'];
5485
5486
5487
5488
5489 if($get_data_from_api['error']){
5490 update_option('autowp_alerts', $get_data_from_api['error']);
5491
5492 }else{
5493 update_option('autowp_alerts', '');
5494 if(!empty($wp_posts)){
5495 // autowp_show_alert_with_message(true,'Success!');
5496 }else{
5497 // autowp_show_alert_with_message(false,'There is no new post from your feed url!');
5498 update_option('autowp_alerts', 'There is no new post from your feed url!');
5499 }
5500 }
5501
5502
5503
5504
5505 foreach($wp_posts as $post){
5506
5507 $post_ids = $post_ids . ',' . $post['post_id'] . $post['slug'];
5508 $post_title = $post['post_title'];
5509 $post_content = $post['content'];
5510 $post_featured_image = $post['preview_image_original'];
5511 $post_tags = $post['tags'];
5512 $post_status = $image_settings['post_status'] ?? 'publish';
5513 $post_author = $author_selection;
5514 $post_type = 'post';
5515 $focus_keyword = $post['focus_keyword'];
5516 $faq_schema = $post['faq_schema'];
5517
5518
5519
5520
5521 autowp_set_new_post($post_title,$post_content,$post_status,$post_author,$post_type,$post_featured_image, $wordpress_categories,$post_tags,$focus_keyword,$faq_schema);
5522
5523
5524 }
5525
5526 autowp_update_published_post_ids($post_ids);
5527
5528
5529
5530 }
5531
5532
5533 function autowp_manual_post_agenticscraper_form_page_handler() {
5534
5535 // Process form submission
5536 if ( isset( $_POST['_wpnonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['_wpnonce'] ) ), 'autowp_manual_post_agenticscraper_nonce' ) ) {
5537
5538 $form_data = $_POST;
5539 $form_data['website_type'] = 'agenticscraper';
5540
5541 // Use long description as content prompt
5542 $form_data['content_prompt'] = sanitize_text_field( $form_data['long_description'] );
5543
5544 // Additional validations can be added here
5545 $validate_form = autowp_validate_agenticscraper( $form_data, true );
5546
5547 if ( $validate_form === true ) {
5548 autowp_show_alert_with_message( true, 'Your process successfully started!' );
5549 schedule_autowp_manual_post_rss_event( $form_data );
5550 } else {
5551 autowp_show_alert_with_message( false, $validate_form );
5552 }
5553 }
5554 ?>
5555 <div class="wrap">
5556 <h1>Manual Post - Agentic Scraper</h1>
5557 <a href="javascript:history.back()" class="btn btn-primary mb-3">Go Back</a>
5558 <div id="poststuff">
5559 <div id="post-body" class="metabox-holder">
5560 <div id="post-body-content" class="row">
5561 <div class="col-md-9">
5562 <div class="meta-box-sortables ui-sortable">
5563 <div class="postbox mb-4">
5564 <h2 class="hndle ui-sortable-handle">Agentic Scraper Settings</h2>
5565 <div class="inside">
5566 <form method="post">
5567 <?php wp_nonce_field( 'autowp_manual_post_agenticscraper_nonce', '_wpnonce' ); ?>
5568
5569 <div class="mb-3">
5570 <label for="author_selection" class="form-label"><?php esc_html_e('Author Selection', 'autowp'); ?></label>
5571 <select name="author_selection" class="form-select">
5572 <?php
5573 $authors = get_users();
5574
5575 foreach ($authors as $author) {
5576 $author_id = $author->ID;
5577 $author_name = $author->display_name;
5578 $author_description = get_the_author_meta('description', $author_id);
5579
5580 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
5581 }
5582 ?>
5583 </select>
5584 <p class="form-text"><?php esc_html_e('Select an author from the list.', 'autowp'); ?></p>
5585 </div>
5586
5587 <div class="mb-3">
5588 <label for="category_id" class="form-label">Categories:</label>
5589 <select id="category_id" name="category_id[]" required multiple class="form-select">
5590 <?php
5591 $categories = get_categories(array(
5592 'orderby' => 'name',
5593 'order' => 'ASC',
5594 'hide_empty' => false
5595 ));
5596
5597 foreach ($categories as $category) {
5598 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
5599 }
5600 ?>
5601 </select>
5602 </div>
5603
5604 <div class="mb-3">
5605 <label class="form-check-label">AI Settings :</label>
5606 <div class="form-check">
5607 <br>
5608 <input type="checkbox" id="aigenerated_image" name="aigenerated_image" value="1" class="form-check-input">
5609 <label for="aigenerated_image" class="form-check-label">Generated thumbnail with AI (SEO Friendly)</label>
5610 </div>
5611 </div>
5612
5613 <div class="col-md-6">
5614 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
5615 <select name="image_generating_status" class="form-select">
5616 <option value="0"><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
5617 <option value="1"><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
5618 <option value="2"><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
5619 <option value="3"><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
5620 <option value="4"><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
5621 <option value="5"><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
5622 <option value="6"><?php esc_html_e('Default Image', 'autowp'); ?></option>
5623 <option value="7"><?php esc_html_e('No Image', 'autowp'); ?></option>
5624 </select>
5625 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet.', 'autowp'); ?></p>
5626 </div>
5627
5628
5629
5630 <!-- Long Description Prompt -->
5631 <div class="mb-3">
5632 <label for="long_description" class="form-label">Long Description Prompt:</label>
5633 <textarea class="form-control" id="long_description" name="long_description" rows="5" placeholder="Enter your detailed prompt here..."></textarea>
5634 <div class="form-text">Provide a detailed prompt for generating content.</div>
5635 </div>
5636
5637
5638
5639
5640 <h4 style="font-weight: bold;">Post Settings</h4>
5641 <!-- Integration of your initial form inputs starts here -->
5642 <div class="mb-3">
5643 <label for="keywordInput" class="form-label">Keyword:</label>
5644 <input type="text" class="form-control" id="keywordInput" name="keywordInput" placeholder="Enter keyword" value="" required class="form-control">
5645 </div>
5646
5647
5648 <?php
5649 $languages = [
5650 "Afrikaans",
5651 "Albanian",
5652 "Arabic",
5653 "Armenian",
5654 "Basque",
5655 "Bengali",
5656 "Bulgarian",
5657 "Catalan",
5658 "Cambodian",
5659 "Chinese (Mandarin)",
5660 "Croatian",
5661 "Czech",
5662 "Danish",
5663 "Dutch",
5664 "English",
5665 "Estonian",
5666 "Fiji",
5667 "Finnish",
5668 "French",
5669 "Georgian",
5670 "German",
5671 "Greek",
5672 "Gujarati",
5673 "Hebrew",
5674 "Hindi",
5675 "Hungarian",
5676 "Icelandic",
5677 "Indonesian",
5678 "Irish",
5679 "Italian",
5680 "Japanese",
5681 "Javanese",
5682 "Korean",
5683 "Latin",
5684 "Latvian",
5685 "Lithuanian",
5686 "Macedonian",
5687 "Malay",
5688 "Malayalam",
5689 "Maltese",
5690 "Maori",
5691 "Marathi",
5692 "Mongolian",
5693 "Nepali",
5694 "Norwegian",
5695 "Persian",
5696 "Polish",
5697 "Portuguese",
5698 "Punjabi",
5699 "Quechua",
5700 "Romanian",
5701 "Russian",
5702 "Samoan",
5703 "Serbian",
5704 "Slovak",
5705 "Slovenian",
5706 "Spanish",
5707 "Swahili",
5708 "Swedish",
5709 "Tamil",
5710 "Tatar",
5711 "Telugu",
5712 "Thai",
5713 "Tibetan",
5714 "Tonga",
5715 "Turkish",
5716 "Ukrainian",
5717 "Urdu",
5718 "Uzbek",
5719 "Vietnamese",
5720 "Welsh",
5721 "Xhosa"
5722 ];
5723 ?>
5724
5725 <div class="mb-3">
5726 <label for="languageSelect" class="form-label">Post Language:</label>
5727 <select class="form-select" id="languageSelect" name="languageSelect">
5728 <?php foreach ($languages as $language): ?>
5729 <option value="<?php echo esc_attr($language); ?>">
5730 <?php echo esc_html($language); ?>
5731 </option>
5732 <?php endforeach; ?>
5733
5734
5735 </select>
5736 </div>
5737
5738 <div class="mb-3">
5739 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
5740 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
5741 <?php
5742 for ($i = 1; $i <= 10; $i++) {
5743 echo '<option value="' . esc_attr($i) . '">' . esc_html($i) . '</option>';
5744 }
5745 ?>
5746 </select>
5747 </div>
5748
5749 <div class="mb-3">
5750 <label for="narrationSelect" class="form-label">Writing Style:</label>
5751 <select class="form-select" id="narrationSelect" name="narrationSelect">
5752 <?php
5753 $styles = [
5754 "Descriptive" => "Descriptive",
5755 "Narrative" => "Narrative",
5756 "Explanatory" => "Explanatory",
5757 "Argumentative" => "Argumentative",
5758 "Comparative" => "Comparative",
5759 "Process Analysis" => "Process Analysis",
5760 "Allegorical" => "Allegorical",
5761 "Chronological" => "Chronological",
5762 "Ironic" => "Ironic",
5763 "ConsistencyAndRepetition" => "Consistency and Repetition",
5764 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
5765 "InternalMonologue" => "Internal Monologue",
5766 "Dialogical" => "Dialogical"
5767 ];
5768 foreach ($styles as $value => $name) {
5769 echo '<option value="' . esc_attr($value) . '">' . esc_html($name) . '</option>';
5770 }
5771 ?>
5772 </select>
5773 </div>
5774
5775 <!-- Custom Tools Section -->
5776 <h3 class="mb-3">Custom Tools</h3>
5777 <div class="accordion mb-4" id="accordionCustomTools">
5778 <!-- Website Tools -->
5779 <div class="accordion-item">
5780 <h2 class="accordion-header" id="headingWebsiteTools">
5781 <div class="d-flex justify-content-between align-items-center w-100">
5782 <button class="accordion-button flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWebsiteTools" aria-expanded="true" aria-controls="collapseWebsiteTools">
5783 Website Tools
5784 </button>
5785 <div class="form-check form-switch ms-2">
5786 <input class="form-check-input" type="checkbox" role="switch" id="toggle_website_tools" name="enable_website_tools" checked style="transform: scale(1.3);" onchange="toggleAccordion('collapseWebsiteTools', this.checked);">
5787 </div>
5788 </div>
5789 </h2>
5790 <div id="collapseWebsiteTools" class="accordion-collapse collapse show" aria-labelledby="headingWebsiteTools">
5791 <div class="accordion-body">
5792 <div class="mb-3">
5793 <label for="website_tools_knowledge_base_url" class="form-label">Knowledge Base URL</label>
5794 <input type="url" class="form-control" id="website_tools_knowledge_base_url" name="website_tools_knowledge_base_url" placeholder="https://example.com">
5795 <div class="form-text">Enter a valid URL if you want to include a knowledge base. Must be in proper URL format.</div>
5796 </div>
5797 </div>
5798 </div>
5799 </div>
5800
5801 <!-- DuckDuckGO Search -->
5802 <div class="accordion-item">
5803 <h2 class="accordion-header" id="headingDuckDuckGO">
5804 <div class="d-flex justify-content-between align-items-center w-100">
5805 <button class="accordion-button flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseDuckDuckGO" aria-expanded="true" aria-controls="collapseDuckDuckGO">
5806 DuckDuckGO Search
5807 </button>
5808 <div class="form-check form-switch ms-2">
5809 <input class="form-check-input" type="checkbox" role="switch" id="toggle_duckduckgo" name="enable_duckduckgo" checked style="transform: scale(1.3);" onchange="toggleAccordion('collapseDuckDuckGO', this.checked);">
5810 </div>
5811 </div>
5812 </h2>
5813 <div id="collapseDuckDuckGO" class="accordion-collapse collapse show" aria-labelledby="headingDuckDuckGO">
5814 <div class="accordion-body">
5815 <div class="form-check form-switch mb-3">
5816 <input type="checkbox" class="form-check-input" id="duckduckgo_news" name="duckduckgo_news" value="1" checked>
5817 <label class="form-check-label" for="duckduckgo_news">Include News (Default: Enabled)</label>
5818 </div>
5819 <div class="mb-3">
5820 <label for="duckduckgo_fixed_max_results" class="form-label">Fixed Max Results</label>
5821 <input type="number" class="form-control" id="duckduckgo_fixed_max_results" name="duckduckgo_fixed_max_results" placeholder="Enter a number or leave blank">
5822 <div class="form-text">Optional: set a maximum number of results.</div>
5823 </div>
5824 </div>
5825 </div>
5826 </div>
5827
5828 <!-- Wikipedia -->
5829 <div class="accordion-item">
5830 <h2 class="accordion-header" id="headingWikipedia">
5831 <div class="d-flex justify-content-between align-items-center w-100">
5832 <button class="accordion-button flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseWikipedia" aria-expanded="true" aria-controls="collapseWikipedia">
5833 Wikipedia
5834 </button>
5835 <div class="form-check form-switch ms-2">
5836 <input class="form-check-input" type="checkbox" role="switch" id="toggle_wikipedia" name="enable_wikipedia" checked style="transform: scale(1.3);" onchange="toggleAccordion('collapseWikipedia', this.checked);">
5837 </div>
5838 </div>
5839 </h2>
5840 <div id="collapseWikipedia" class="accordion-collapse collapse show" aria-labelledby="headingWikipedia">
5841 <div class="accordion-body">
5842 <div class="mb-3">
5843 <label for="wikipedia_knowledge_base" class="form-label">Knowledge Base Topics</label>
5844 <input type="text" class="form-control" id="wikipedia_knowledge_base" name="wikipedia_knowledge_base" placeholder="topic1, topic2, topic3">
5845 <div class="form-text">Enter topics separated by commas if you want to include a knowledge base.</div>
5846 </div>
5847 </div>
5848 </div>
5849 </div>
5850
5851 <!-- YFinanceTools -->
5852 <div class="accordion-item">
5853 <h2 class="accordion-header" id="headingYFinanceTools">
5854 <div class="d-flex justify-content-between align-items-center w-100">
5855 <button class="accordion-button flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseYFinanceTools" aria-expanded="true" aria-controls="collapseYFinanceTools">
5856 YFinanceTools
5857 </button>
5858 <div class="form-check form-switch ms-2">
5859 <input class="form-check-input" type="checkbox" role="switch" id="toggle_yfinancetools" name="enable_yfinancetools" checked style="transform: scale(1.3);" onchange="toggleAccordion('collapseYFinanceTools', this.checked);">
5860 </div>
5861 </div>
5862 </h2>
5863 <div id="collapseYFinanceTools" class="accordion-collapse collapse show" aria-labelledby="headingYFinanceTools">
5864 <div class="accordion-body">
5865 <div class="form-check form-switch mb-2">
5866 <input type="checkbox" class="form-check-input" id="yfinance_stock_price" name="yfinance_stock_price" value="1" checked>
5867 <label class="form-check-label" for="yfinance_stock_price">Stock Price (Default: Enabled)</label>
5868 </div>
5869 <div class="form-check form-switch mb-2">
5870 <input type="checkbox" class="form-check-input" id="yfinance_company_info" name="yfinance_company_info" value="1">
5871 <label class="form-check-label" for="yfinance_company_info">Company Info</label>
5872 </div>
5873 <div class="form-check form-switch mb-2">
5874 <input type="checkbox" class="form-check-input" id="yfinance_stock_fundamentals" name="yfinance_stock_fundamentals" value="1">
5875 <label class="form-check-label" for="yfinance_stock_fundamentals">Stock Fundamentals</label>
5876 </div>
5877 <div class="form-check form-switch mb-2">
5878 <input type="checkbox" class="form-check-input" id="yfinance_income_statements" name="yfinance_income_statements" value="1">
5879 <label class="form-check-label" for="yfinance_income_statements">Income Statements</label>
5880 </div>
5881 <div class="form-check form-switch mb-2">
5882 <input type="checkbox" class="form-check-input" id="yfinance_key_financial_ratios" name="yfinance_key_financial_ratios" value="1">
5883 <label class="form-check-label" for="yfinance_key_financial_ratios">Key Financial Ratios</label>
5884 </div>
5885 <div class="form-check form-switch mb-2">
5886 <input type="checkbox" class="form-check-input" id="yfinance_analyst_recommendations" name="yfinance_analyst_recommendations" value="1">
5887 <label class="form-check-label" for="yfinance_analyst_recommendations">Analyst Recommendations</label>
5888 </div>
5889 <div class="form-check form-switch mb-2">
5890 <input type="checkbox" class="form-check-input" id="yfinance_company_news" name="yfinance_company_news" value="1">
5891 <label class="form-check-label" for="yfinance_company_news">Company News</label>
5892 </div>
5893 <div class="form-check form-switch mb-2">
5894 <input type="checkbox" class="form-check-input" id="yfinance_technical_indicators" name="yfinance_technical_indicators" value="1">
5895 <label class="form-check-label" for="yfinance_technical_indicators">Technical Indicators</label>
5896 </div>
5897 <div class="form-check form-switch mb-2">
5898 <input type="checkbox" class="form-check-input" id="yfinance_historical_prices" name="yfinance_historical_prices" value="1">
5899 <label class="form-check-label" for="yfinance_historical_prices">Historical Prices</label>
5900 </div>
5901 </div>
5902 </div>
5903 </div>
5904
5905 <!-- Hacker News -->
5906 <div class="accordion-item">
5907 <h2 class="accordion-header" id="headingHackerNews">
5908 <div class="d-flex justify-content-between align-items-center w-100">
5909 <button class="accordion-button flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseHackerNews" aria-expanded="true" aria-controls="collapseHackerNews">
5910 Hacker News
5911 </button>
5912 <div class="form-check form-switch ms-2">
5913 <input class="form-check-input" type="checkbox" role="switch" id="toggle_hackernews" name="enable_hackernews" checked style="transform: scale(1.3);" onchange="toggleAccordion('collapseHackerNews', this.checked);">
5914 </div>
5915 </div>
5916 </h2>
5917 <div id="collapseHackerNews" class="accordion-collapse collapse show" aria-labelledby="headingHackerNews">
5918 <div class="accordion-body">
5919 <div class="form-check form-switch mb-2">
5920 <input type="checkbox" class="form-check-input" id="hackernews_get_top_stories" name="hackernews_get_top_stories" value="1" checked>
5921 <label class="form-check-label" for="hackernews_get_top_stories">Get Top Stories (Default: Enabled)</label>
5922 </div>
5923 <div class="form-check form-switch mb-2">
5924 <input type="checkbox" class="form-check-input" id="hackernews_get_user_details" name="hackernews_get_user_details" value="1" checked>
5925 <label class="form-check-label" for="hackernews_get_user_details">Get User Details (Default: Enabled)</label>
5926 </div>
5927 </div>
5928 </div>
5929 </div>
5930 </div> <!-- End of accordionCustomTools -->
5931
5932 <!-- Knowledge Base Section (3 Separate Items) -->
5933 <h3 class="mb-3">Knowledge Base</h3>
5934 <div class="accordion mb-4" id="accordionKnowledgeBase">
5935 <!-- PDF Knowledge Base -->
5936 <div class="accordion-item">
5937 <h2 class="accordion-header" id="headingPDFKB">
5938 <div class="d-flex justify-content-between align-items-center w-100">
5939 <button class="accordion-button collapsed flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapsePDFKB" aria-expanded="false" aria-controls="collapsePDFKB">
5940 PDF Knowledge Base
5941 </button>
5942 <div class="form-check form-switch ms-2">
5943 <input class="form-check-input" type="checkbox" role="switch" id="toggle_pdf_kb" name="enable_pdf_kb" style="transform: scale(1.3);" onchange="toggleAccordion('collapsePDFKB', this.checked);">
5944 </div>
5945 </div>
5946 </h2>
5947 <div id="collapsePDFKB" class="accordion-collapse collapse" aria-labelledby="headingPDFKB">
5948 <div class="accordion-body">
5949 <div class="mb-3">
5950 <label for="pdf_url_knowledge_base" class="form-label">PDF URL Knowledge Base</label>
5951 <input type="url" class="form-control" id="pdf_url_knowledge_base" name="pdf_url_knowledge_base" placeholder="https://example.com/document.pdf">
5952 <div class="form-text">Provide a URL to a PDF document. If filled, it must point to a valid PDF file.</div>
5953 </div>
5954 </div>
5955 </div>
5956 </div>
5957 <!-- CSV Knowledge Base -->
5958 <div class="accordion-item">
5959 <h2 class="accordion-header" id="headingCSVKB">
5960 <div class="d-flex justify-content-between align-items-center w-100">
5961 <button class="accordion-button collapsed flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseCSVKB" aria-expanded="false" aria-controls="collapseCSVKB">
5962 CSV Knowledge Base
5963 </button>
5964 <div class="form-check form-switch ms-2">
5965 <input class="form-check-input" type="checkbox" role="switch" id="toggle_csv_kb" name="enable_csv_kb" style="transform: scale(1.3);" onchange="toggleAccordion('collapseCSVKB', this.checked);">
5966 </div>
5967 </div>
5968 </h2>
5969 <div id="collapseCSVKB" class="accordion-collapse collapse" aria-labelledby="headingCSVKB">
5970 <div class="accordion-body">
5971 <div class="mb-3">
5972 <label for="csv_url_knowledge_base" class="form-label">CSV URL Knowledge Base</label>
5973 <input type="url" class="form-control" id="csv_url_knowledge_base" name="csv_url_knowledge_base" placeholder="https://example.com/data.csv">
5974 <div class="form-text">Provide a URL to a CSV file. If filled, it must be a valid URL.</div>
5975 </div>
5976 </div>
5977 </div>
5978 </div>
5979 <!-- Text Knowledge Base -->
5980 <div class="accordion-item">
5981 <h2 class="accordion-header" id="headingTextKB">
5982 <div class="d-flex justify-content-between align-items-center w-100">
5983 <button class="accordion-button collapsed flex-grow-1" type="button" data-bs-toggle="collapse" data-bs-target="#collapseTextKB" aria-expanded="false" aria-controls="collapseTextKB">
5984 Text Knowledge Base
5985 </button>
5986 <div class="form-check form-switch ms-2">
5987 <input class="form-check-input" type="checkbox" role="switch" id="toggle_text_kb" name="enable_text_kb" style="transform: scale(1.3);" onchange="toggleAccordion('collapseTextKB', this.checked);">
5988 </div>
5989 </div>
5990 </h2>
5991 <div id="collapseTextKB" class="accordion-collapse collapse" aria-labelledby="headingTextKB">
5992 <div class="accordion-body">
5993 <div class="mb-3">
5994 <label for="text_knowledge_base" class="form-label">Text Knowledge Base</label>
5995 <textarea class="form-control" id="text_knowledge_base" name="text_knowledge_base" rows="5" placeholder="Enter your knowledge base text here..."></textarea>
5996 <div class="form-text">Enter plain text for your knowledge base. This field supports a longer description.</div>
5997 </div>
5998 </div>
5999 </div>
6000 </div>
6001 </div> <!-- End of accordionKnowledgeBase -->
6002
6003 <div class="mb-3">
6004 <button type="submit" name="submit" id="submit" class="btn btn-primary">Generate Post</button>
6005 </div>
6006 </form>
6007 </div><!-- .inside -->
6008 </div><!-- .postbox -->
6009 </div><!-- .meta-box-sortables -->
6010 </div><!-- .col-md-9 -->
6011 </div><!-- #post-body-content -->
6012 </div><!-- #poststuff -->
6013 </div><!-- .wrap -->
6014
6015 <!-- Inline JavaScript to handle toggle-controlled accordion behavior -->
6016 <script>
6017 function toggleAccordion(collapseId, isActive) {
6018 var collapseElement = document.getElementById(collapseId);
6019 var bsCollapse = new bootstrap.Collapse(collapseElement, {
6020 toggle: false
6021 });
6022 if (isActive) {
6023 bsCollapse.show();
6024 } else {
6025 bsCollapse.hide();
6026 }
6027 }
6028 </script>
6029 <?php
6030 }
6031
6032
6033
6034
6035
6036
6037 function autowp_manual_post_ai_form_page_handler() {
6038
6039 if (isset($_POST['_wpnonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'autowp_manual_post_ai_nonce')) {
6040
6041 $form_data = $_POST;
6042
6043 $form_data['website_type'] = 'ai';
6044
6045 $form_data['content_prompt'] = '[autowp-promptcode]' .
6046 sanitize_text_field($form_data['keywordInput']) . ',' .
6047 'aiGenerated' . ',' .
6048 sanitize_text_field($form_data['countrySelect']) . ',' .
6049 sanitize_text_field($form_data['languageSelect']) . ',' .
6050 sanitize_text_field($form_data['subtitleSelect']) . ',' .
6051 sanitize_text_field($form_data['narrationSelect']) .
6052 '[/autowp-promptcode]';
6053
6054 $validate_form = autowp_validate_website($form_data,true);
6055
6056
6057
6058 if($validate_form === true){
6059 autowp_show_alert_with_message(true,'Your process successfully started!');
6060 schedule_autowp_manual_post_rss_event($form_data);
6061 }else{
6062
6063
6064 autowp_show_alert_with_message(false,$validate_form);
6065
6066 }
6067
6068
6069
6070
6071 }
6072 //autowp_manual_post_ai_form_page_setOptions();
6073 ?>
6074
6075 <div class="wrap">
6076 <h1>Manual Post - AI</h1>
6077 <a href="javascript:history.back()" class="btn btn-primary">Go Back</a>
6078
6079 <div id="poststuff">
6080 <div id="post-body" class="metabox-holder">
6081 <!-- Main Content -->
6082 <div id="post-body-content" class="row">
6083 <div class="col-md-9">
6084 <div class="meta-box-sortables ui-sortable">
6085 <div class="postbox">
6086 <h2 class="hndle ui-sortable-handle">AI Settings</h2>
6087 <div class="inside">
6088 <form method="post">
6089 <?php wp_nonce_field('autowp_manual_post_ai_nonce', '_wpnonce'); ?>
6090 <form class="row g-3" id="post_generation_form">
6091 <div class="col-md-6">
6092 <div class="mb-3">
6093 <label for="author_selection" class="form-label"><?php esc_html_e('Author Selection', 'autowp'); ?></label>
6094 <select name="author_selection" class="form-select">
6095 <?php
6096 $authors = get_users();
6097
6098 foreach ($authors as $author) {
6099 $author_id = $author->ID;
6100 $author_name = $author->display_name;
6101 $author_description = get_the_author_meta('description', $author_id);
6102
6103 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
6104 }
6105 ?>
6106 </select>
6107 <p class="form-text"><?php esc_html_e('Select an author from the list.', 'autowp'); ?></p>
6108 </div>
6109
6110 <div class="mb-3">
6111 <label for="category_id" class="form-label">Categories:</label>
6112 <select id="category_id" name="category_id[]" required multiple class="form-select">
6113 <?php
6114 $categories = get_categories(array(
6115 'orderby' => 'name',
6116 'order' => 'ASC',
6117 'hide_empty' => false
6118 ));
6119
6120 foreach ($categories as $category) {
6121 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
6122 }
6123 ?>
6124 </select>
6125 </div>
6126
6127 <div class="mb-3">
6128 <label class="form-check-label">AI Settings :</label>
6129 <div class="form-check">
6130 <br>
6131 <input type="checkbox" id="aigenerated_image" name="aigenerated_image" value="1" class="form-check-input">
6132 <label for="aigenerated_image" class="form-check-label">Generated thumbnail with AI (SEO Friendly)</label>
6133 </div>
6134 </div>
6135
6136 <div class="col-md-6">
6137 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
6138 <select name="image_generating_status" class="form-select">
6139 <option value="0"><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
6140 <option value="1"><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
6141 <option value="2"><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
6142 <option value="3"><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
6143 <option value="4"><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
6144 <option value="5"><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
6145
6146 <option value="6"><?php esc_html_e('Default Image', 'autowp'); ?></option>
6147 <option value="7"><?php esc_html_e('No Image', 'autowp'); ?></option>
6148 </select>
6149 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet.', 'autowp'); ?></p>
6150 </div>
6151
6152
6153
6154
6155
6156
6157 <h4 style="font-weight: bold;">Post Settings</h4>
6158 <!-- Integration of your initial form inputs starts here -->
6159 <div class="mb-3">
6160 <label for="keywordInput" class="form-label">Keyword:</label>
6161 <input type="text" class="form-control" id="keywordInput" name="keywordInput" placeholder="Enter keyword" value="" required class="form-control">
6162 </div>
6163
6164 <div class="mb-3">
6165 <label for="countrySelect" class="form-label">Country:</label>
6166 <select class="form-select" id="countrySelect" name="countrySelect">
6167 <!-- Countries list -->
6168 <?php
6169 $countries = array
6170 (
6171 'AF' => 'Afghanistan',
6172 'AX' => 'Aland Islands',
6173 'AL' => 'Albania',
6174 'DZ' => 'Algeria',
6175 'AS' => 'American Samoa',
6176 'AD' => 'Andorra',
6177 'AO' => 'Angola',
6178 'AI' => 'Anguilla',
6179 'AQ' => 'Antarctica',
6180 'AG' => 'Antigua And Barbuda',
6181 'AR' => 'Argentina',
6182 'AM' => 'Armenia',
6183 'AW' => 'Aruba',
6184 'AU' => 'Australia',
6185 'AT' => 'Austria',
6186 'AZ' => 'Azerbaijan',
6187 'BS' => 'Bahamas',
6188 'BH' => 'Bahrain',
6189 'BD' => 'Bangladesh',
6190 'BB' => 'Barbados',
6191 'BY' => 'Belarus',
6192 'BE' => 'Belgium',
6193 'BZ' => 'Belize',
6194 'BJ' => 'Benin',
6195 'BM' => 'Bermuda',
6196 'BT' => 'Bhutan',
6197 'BO' => 'Bolivia',
6198 'BA' => 'Bosnia And Herzegovina',
6199 'BW' => 'Botswana',
6200 'BV' => 'Bouvet Island',
6201 'BR' => 'Brazil',
6202 'IO' => 'British Indian Ocean Territory',
6203 'BN' => 'Brunei Darussalam',
6204 'BG' => 'Bulgaria',
6205 'BF' => 'Burkina Faso',
6206 'BI' => 'Burundi',
6207 'KH' => 'Cambodia',
6208 'CM' => 'Cameroon',
6209 'CA' => 'Canada',
6210 'CV' => 'Cape Verde',
6211 'KY' => 'Cayman Islands',
6212 'CF' => 'Central African Republic',
6213 'TD' => 'Chad',
6214 'CL' => 'Chile',
6215 'CN' => 'China',
6216 'CX' => 'Christmas Island',
6217 'CC' => 'Cocos (Keeling) Islands',
6218 'CO' => 'Colombia',
6219 'KM' => 'Comoros',
6220 'CG' => 'Congo',
6221 'CD' => 'Congo, Democratic Republic',
6222 'CK' => 'Cook Islands',
6223 'CR' => 'Costa Rica',
6224 'CI' => 'Cote D\'Ivoire',
6225 'HR' => 'Croatia',
6226 'CU' => 'Cuba',
6227 'CY' => 'Cyprus',
6228 'CZ' => 'Czech Republic',
6229 'DK' => 'Denmark',
6230 'DJ' => 'Djibouti',
6231 'DM' => 'Dominica',
6232 'DO' => 'Dominican Republic',
6233 'EC' => 'Ecuador',
6234 'EG' => 'Egypt',
6235 'SV' => 'El Salvador',
6236 'GQ' => 'Equatorial Guinea',
6237 'ER' => 'Eritrea',
6238 'EE' => 'Estonia',
6239 'ET' => 'Ethiopia',
6240 'FK' => 'Falkland Islands (Malvinas)',
6241 'FO' => 'Faroe Islands',
6242 'FJ' => 'Fiji',
6243 'FI' => 'Finland',
6244 'FR' => 'France',
6245 'GF' => 'French Guiana',
6246 'PF' => 'French Polynesia',
6247 'TF' => 'French Southern Territories',
6248 'GA' => 'Gabon',
6249 'GM' => 'Gambia',
6250 'GE' => 'Georgia',
6251 'DE' => 'Germany',
6252 'GH' => 'Ghana',
6253 'GI' => 'Gibraltar',
6254 'GR' => 'Greece',
6255 'GL' => 'Greenland',
6256 'GD' => 'Grenada',
6257 'GP' => 'Guadeloupe',
6258 'GU' => 'Guam',
6259 'GT' => 'Guatemala',
6260 'GG' => 'Guernsey',
6261 'GN' => 'Guinea',
6262 'GW' => 'Guinea-Bissau',
6263 'GY' => 'Guyana',
6264 'HT' => 'Haiti',
6265 'HM' => 'Heard Island & Mcdonald Islands',
6266 'VA' => 'Holy See (Vatican City State)',
6267 'HN' => 'Honduras',
6268 'HK' => 'Hong Kong',
6269 'HU' => 'Hungary',
6270 'IS' => 'Iceland',
6271 'IN' => 'India',
6272 'ID' => 'Indonesia',
6273 'IR' => 'Iran, Islamic Republic Of',
6274 'IQ' => 'Iraq',
6275 'IE' => 'Ireland',
6276 'IM' => 'Isle Of Man',
6277 'IL' => 'Israel',
6278 'IT' => 'Italy',
6279 'JM' => 'Jamaica',
6280 'JP' => 'Japan',
6281 'JE' => 'Jersey',
6282 'JO' => 'Jordan',
6283 'KZ' => 'Kazakhstan',
6284 'KE' => 'Kenya',
6285 'KI' => 'Kiribati',
6286 'KR' => 'Korea',
6287 'KW' => 'Kuwait',
6288 'KG' => 'Kyrgyzstan',
6289 'LA' => 'Lao People\'s Democratic Republic',
6290 'LV' => 'Latvia',
6291 'LB' => 'Lebanon',
6292 'LS' => 'Lesotho',
6293 'LR' => 'Liberia',
6294 'LY' => 'Libyan Arab Jamahiriya',
6295 'LI' => 'Liechtenstein',
6296 'LT' => 'Lithuania',
6297 'LU' => 'Luxembourg',
6298 'MO' => 'Macao',
6299 'MK' => 'Macedonia',
6300 'MG' => 'Madagascar',
6301 'MW' => 'Malawi',
6302 'MY' => 'Malaysia',
6303 'MV' => 'Maldives',
6304 'ML' => 'Mali',
6305 'MT' => 'Malta',
6306 'MH' => 'Marshall Islands',
6307 'MQ' => 'Martinique',
6308 'MR' => 'Mauritania',
6309 'MU' => 'Mauritius',
6310 'YT' => 'Mayotte',
6311 'MX' => 'Mexico',
6312 'FM' => 'Micronesia, Federated States Of',
6313 'MD' => 'Moldova',
6314 'MC' => 'Monaco',
6315 'MN' => 'Mongolia',
6316 'ME' => 'Montenegro',
6317 'MS' => 'Montserrat',
6318 'MA' => 'Morocco',
6319 'MZ' => 'Mozambique',
6320 'MM' => 'Myanmar',
6321 'NA' => 'Namibia',
6322 'NR' => 'Nauru',
6323 'NP' => 'Nepal',
6324 'NL' => 'Netherlands',
6325 'AN' => 'Netherlands Antilles',
6326 'NC' => 'New Caledonia',
6327 'NZ' => 'New Zealand',
6328 'NI' => 'Nicaragua',
6329 'NE' => 'Niger',
6330 'NG' => 'Nigeria',
6331 'NU' => 'Niue',
6332 'NF' => 'Norfolk Island',
6333 'MP' => 'Northern Mariana Islands',
6334 'NO' => 'Norway',
6335 'OM' => 'Oman',
6336 'PK' => 'Pakistan',
6337 'PW' => 'Palau',
6338 'PS' => 'Palestinian Territory, Occupied',
6339 'PA' => 'Panama',
6340 'PG' => 'Papua New Guinea',
6341 'PY' => 'Paraguay',
6342 'PE' => 'Peru',
6343 'PH' => 'Philippines',
6344 'PN' => 'Pitcairn',
6345 'PL' => 'Poland',
6346 'PT' => 'Portugal',
6347 'PR' => 'Puerto Rico',
6348 'QA' => 'Qatar',
6349 'RE' => 'Reunion',
6350 'RO' => 'Romania',
6351 'RU' => 'Russian Federation',
6352 'RW' => 'Rwanda',
6353 'BL' => 'Saint Barthelemy',
6354 'SH' => 'Saint Helena',
6355 'KN' => 'Saint Kitts And Nevis',
6356 'LC' => 'Saint Lucia',
6357 'MF' => 'Saint Martin',
6358 'PM' => 'Saint Pierre And Miquelon',
6359 'VC' => 'Saint Vincent And Grenadines',
6360 'WS' => 'Samoa',
6361 'SM' => 'San Marino',
6362 'ST' => 'Sao Tome And Principe',
6363 'SA' => 'Saudi Arabia',
6364 'SN' => 'Senegal',
6365 'RS' => 'Serbia',
6366 'SC' => 'Seychelles',
6367 'SL' => 'Sierra Leone',
6368 'SG' => 'Singapore',
6369 'SK' => 'Slovakia',
6370 'SI' => 'Slovenia',
6371 'SB' => 'Solomon Islands',
6372 'SO' => 'Somalia',
6373 'ZA' => 'South Africa',
6374 'GS' => 'South Georgia And Sandwich Isl.',
6375 'ES' => 'Spain',
6376 'LK' => 'Sri Lanka',
6377 'SD' => 'Sudan',
6378 'SR' => 'Suriname',
6379 'SJ' => 'Svalbard And Jan Mayen',
6380 'SZ' => 'Swaziland',
6381 'SE' => 'Sweden',
6382 'CH' => 'Switzerland',
6383 'SY' => 'Syrian Arab Republic',
6384 'TW' => 'Taiwan',
6385 'TJ' => 'Tajikistan',
6386 'TZ' => 'Tanzania',
6387 'TH' => 'Thailand',
6388 'TL' => 'Timor-Leste',
6389 'TG' => 'Togo',
6390 'TK' => 'Tokelau',
6391 'TO' => 'Tonga',
6392 'TT' => 'Trinidad And Tobago',
6393 'TN' => 'Tunisia',
6394 'TR' => 'Turkey',
6395 'TM' => 'Turkmenistan',
6396 'TC' => 'Turks And Caicos Islands',
6397 'TV' => 'Tuvalu',
6398 'UG' => 'Uganda',
6399 'UA' => 'Ukraine',
6400 'AE' => 'United Arab Emirates',
6401 'GB' => 'United Kingdom',
6402 'US' => 'United States',
6403 'UM' => 'United States Outlying Islands',
6404 'UY' => 'Uruguay',
6405 'UZ' => 'Uzbekistan',
6406 'VU' => 'Vanuatu',
6407 'VE' => 'Venezuela',
6408 'VN' => 'Viet Nam',
6409 'VG' => 'Virgin Islands, British',
6410 'VI' => 'Virgin Islands, U.S.',
6411 'WF' => 'Wallis And Futuna',
6412 'EH' => 'Western Sahara',
6413 'YE' => 'Yemen',
6414 'ZM' => 'Zambia',
6415 'ZW' => 'Zimbabwe',
6416 );
6417
6418 foreach ($countries as $code => $name) {
6419 echo '<option value="' . esc_attr($code) . '">' . esc_html($name) . '</option>';
6420 }
6421
6422 ?>
6423 </select>
6424 </div>
6425 <?php
6426 $languages = [
6427 "Afrikaans",
6428 "Albanian",
6429 "Arabic",
6430 "Armenian",
6431 "Basque",
6432 "Bengali",
6433 "Bulgarian",
6434 "Catalan",
6435 "Cambodian",
6436 "Chinese (Mandarin)",
6437 "Croatian",
6438 "Czech",
6439 "Danish",
6440 "Dutch",
6441 "English",
6442 "Estonian",
6443 "Fiji",
6444 "Finnish",
6445 "French",
6446 "Georgian",
6447 "German",
6448 "Greek",
6449 "Gujarati",
6450 "Hebrew",
6451 "Hindi",
6452 "Hungarian",
6453 "Icelandic",
6454 "Indonesian",
6455 "Irish",
6456 "Italian",
6457 "Japanese",
6458 "Javanese",
6459 "Korean",
6460 "Latin",
6461 "Latvian",
6462 "Lithuanian",
6463 "Macedonian",
6464 "Malay",
6465 "Malayalam",
6466 "Maltese",
6467 "Maori",
6468 "Marathi",
6469 "Mongolian",
6470 "Nepali",
6471 "Norwegian",
6472 "Persian",
6473 "Polish",
6474 "Portuguese",
6475 "Punjabi",
6476 "Quechua",
6477 "Romanian",
6478 "Russian",
6479 "Samoan",
6480 "Serbian",
6481 "Slovak",
6482 "Slovenian",
6483 "Spanish",
6484 "Swahili",
6485 "Swedish",
6486 "Tamil",
6487 "Tatar",
6488 "Telugu",
6489 "Thai",
6490 "Tibetan",
6491 "Tonga",
6492 "Turkish",
6493 "Ukrainian",
6494 "Urdu",
6495 "Uzbek",
6496 "Vietnamese",
6497 "Welsh",
6498 "Xhosa"
6499 ];
6500 ?>
6501
6502 <div class="mb-3">
6503 <label for="languageSelect" class="form-label">Post Language:</label>
6504 <select class="form-select" id="languageSelect" name="languageSelect">
6505 <?php foreach ($languages as $language): ?>
6506 <option value="<?php echo esc_attr($language); ?>">
6507 <?php echo esc_html($language); ?>
6508 </option>
6509 <?php endforeach; ?>
6510
6511
6512 </select>
6513 </div>
6514
6515 <div class="mb-3">
6516 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
6517 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
6518 <?php
6519 for ($i = 1; $i <= 10; $i++) {
6520 echo '<option value="' . esc_attr($i) . '">' . esc_html($i) . '</option>';
6521 }
6522 ?>
6523 </select>
6524 </div>
6525
6526 <div class="mb-3">
6527 <label for="narrationSelect" class="form-label">Writing Style:</label>
6528 <select class="form-select" id="narrationSelect" name="narrationSelect">
6529 <?php
6530 $styles = [
6531 "Descriptive" => "Descriptive",
6532 "Narrative" => "Narrative",
6533 "Explanatory" => "Explanatory",
6534 "Argumentative" => "Argumentative",
6535 "Comparative" => "Comparative",
6536 "Process Analysis" => "Process Analysis",
6537 "Allegorical" => "Allegorical",
6538 "Chronological" => "Chronological",
6539 "Ironic" => "Ironic",
6540 "ConsistencyAndRepetition" => "Consistency and Repetition",
6541 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
6542 "InternalMonologue" => "Internal Monologue",
6543 "Dialogical" => "Dialogical"
6544 ];
6545 foreach ($styles as $value => $name) {
6546 echo '<option value="' . esc_attr($value) . '">' . esc_html($name) . '</option>';
6547 }
6548 ?>
6549 </select>
6550 </div>
6551
6552
6553
6554
6555
6556
6557 <div class="mb-3">
6558 <p class="submit">
6559 <input type="submit" name="submit" id="submit" class="btn btn-primary" value="Generate Post">
6560 </p>
6561 </div>
6562
6563
6564 </form>
6565 </div>
6566 </div>
6567 </div>
6568 </div>
6569 <!-- Sidebar -->
6570 </div>
6571 </div>
6572 </div>
6573 </div>
6574 <?php
6575 }
6576
6577 function autowp_prompt_settings_page_handler(){
6578 ?>
6579 <div class="wrap">
6580 <h2><?php esc_html_e('Content Schemes', 'autowp'); ?></h2>
6581 <p class="lead"><?php esc_html_e('Select ', 'autowp'); ?></p>
6582 <ul class="list-group">
6583
6584 <!-- Writing Prompt Scheme Option -->
6585 <li class="list-group-item">
6586 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=autowp_promptschemes')); ?>" class="d-flex justify-content-between align-items-center">
6587 <div class="d-flex align-items-center">
6588 <img src="<?php echo esc_url(plugins_url('assets/images/wordpress-icon.png', __FILE__)); ?>" alt="<?php esc_attr_e('Writing Prompt Scheme', 'autowp'); ?>" class="me-3" style="width: 80px; height: 80px;">
6589 <div>
6590 <h5 class="mb-1"><?php esc_html_e('Writing Prompt Scheme', 'autowp'); ?></h5>
6591 <p class="mb-0"><?php esc_html_e('Create a prompt scheme from scratch for generating new posts.', 'autowp'); ?></p>
6592 </div>
6593 </div>
6594 </a>
6595 </li>
6596
6597 <!-- Rewriting Prompt Scheme Option -->
6598 <li class="list-group-item">
6599 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=autowp_rewriting_promptschemes')); ?>" class="d-flex justify-content-between align-items-center">
6600 <div class="d-flex align-items-center">
6601 <img src="<?php echo esc_url(plugins_url('assets/images/rss-icon.png', __FILE__)); ?>" alt="<?php esc_attr_e('Rewriting Prompt Scheme', 'autowp'); ?>" class="me-3" style="width: 80px; height: 80px;">
6602 <div>
6603 <h5 class="mb-1"><?php esc_html_e('Rewriting Prompt Scheme', 'autowp'); ?></h5>
6604 <p class="mb-0"><?php esc_html_e('Create a prompt scheme that rewrites posts based on source content (e.g., RSS Feeds).', 'autowp'); ?></p>
6605 </div>
6606 </div>
6607 </a>
6608 </li>
6609
6610 <!-- Other Prompt Settings Option -->
6611 <li class="list-group-item">
6612 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_ai_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6613 <div class="d-flex align-items-center">
6614 <img src="<?php echo esc_url(plugins_url('assets/images/robot-icon.png', __FILE__)); ?>" alt="<?php esc_attr_e('Other Prompt Settings', 'autowp'); ?>" class="me-3" style="width: 80px; height: 80px;">
6615 <div>
6616 <h5 class="mb-1"><?php esc_html_e('Other Prompt Settings', 'autowp'); ?></h5>
6617 <p class="mb-0"><?php esc_html_e('Customize titles, keywords, thumbnails, tags, and other prompt settings.', 'autowp'); ?></p>
6618 </div>
6619 </div>
6620 </a>
6621 </li>
6622
6623 <!-- Video Tutorials Option (with modal trigger) -->
6624 <li class="list-group-item">
6625 <a href="#" data-bs-toggle="modal" data-bs-target="#tutorialModal" class="d-flex justify-content-between align-items-center">
6626 <div class="d-flex align-items-center">
6627 <img src="<?php echo esc_url(plugins_url('assets/images/tutorial.png', __FILE__)); ?>" alt="<?php esc_attr_e('Video Tutorials', 'autowp'); ?>" class="me-3" style="width: 80px; height: 80px;">
6628 <div>
6629 <h5 class="mb-1"><?php esc_html_e('Video Tutorials', 'autowp'); ?></h5>
6630 <p class="mb-0"><?php esc_html_e('Watch tutorials to learn how to configure and use the AI prompt settings.', 'autowp'); ?></p>
6631 </div>
6632 </div>
6633 </a>
6634 </li>
6635
6636 </ul>
6637
6638 <!-- Bootstrap Modal -->
6639 <div class="modal fade" id="tutorialModal" tabindex="-1" aria-labelledby="tutorialModalLabel" aria-hidden="true">
6640 <div class="modal-dialog modal-dialog-centered">
6641 <div class="modal-content">
6642 <div class="modal-header">
6643 <h5 class="modal-title" id="tutorialModalLabel"><?php esc_html_e('Video Tutorials', 'autowp'); ?></h5>
6644 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
6645 </div>
6646 <div class="modal-body">
6647 <div class="mb-3">
6648 <h5><?php esc_html_e('Manual Processes', 'autowp'); ?></h5>
6649 <p><?php esc_html_e('Once you click "Generate Post", the process will run in the background, typically taking about 5 minutes. You can monitor errors or progress in the WordPress admin panel.', 'autowp'); ?></p>
6650 </div>
6651
6652 <div class="mb-3">
6653 <h5><?php esc_html_e('Automatic Processes', 'autowp'); ?></h5>
6654 <p><?php esc_html_e('Automatic processes are triggered based on the cron schedule you set in the settings. Make sure to configure the interval after adding new processes.', 'autowp'); ?></p>
6655 </div>
6656
6657 <!-- Video Tutorials Section -->
6658 <div class="mb-3">
6659 <h6><?php esc_html_e('How to Generate Posts with AI', 'autowp'); ?></h6>
6660 <iframe width="450" height="350" src="https://www.youtube.com/embed/p5KpM9eZftE" frameborder="0" allowfullscreen></iframe>
6661 </div>
6662
6663 <div class="mb-3">
6664 <h6><?php esc_html_e('How to Rewrite Posts with AI from RSS Feed', 'autowp'); ?></h6>
6665 <iframe width="450" height="350" src="https://www.youtube.com/embed/A-wTvmlz7og" frameborder="0" allowfullscreen></iframe>
6666 </div>
6667
6668 <div class="mb-3">
6669 <h6><?php esc_html_e('How to Rewrite Posts with AI from WordPress Websites', 'autowp'); ?></h6>
6670 <iframe width="450" height="350" src="https://www.youtube.com/embed/xo9IbyZ_HXY" frameborder="0" allowfullscreen></iframe>
6671 </div>
6672
6673 <div class="mb-3">
6674 <h6><?php esc_html_e('How to Rewrite Posts with AI from Google News', 'autowp'); ?></h6>
6675 <iframe width="450" height="350" src="https://www.youtube.com/embed/z8sM2953VBQ" frameborder="0" allowfullscreen></iframe>
6676 </div>
6677 </div>
6678 <div class="modal-footer">
6679 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal"><?php esc_html_e('Close', 'autowp'); ?></button>
6680 </div>
6681 </div>
6682 </div>
6683 </div>
6684
6685 </div>
6686 <?php
6687 }
6688
6689
6690 function autowp_setup_page() {
6691 $user_email = wp_get_current_user()->user_email;
6692
6693 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
6694
6695
6696 $url = 'https://api.autowp.app/register_email';
6697 $url_confirm = 'https://api.autowp.app/confirm_email';
6698
6699 if ( isset( $server_url )
6700 && $server_url !== null
6701 && $server_url !== ''
6702 && strpos( $server_url, 'autowp.app' ) === false
6703 ) {
6704
6705 $url = $server_url . '/register_email';
6706 $url_confirm = $server_url . '/confirm_email';
6707
6708 }
6709
6710 ?>
6711 <div class="wrap">
6712 <h1><?php esc_html_e('AutoWP Setup', 'autowp'); ?></h1>
6713 <form method="post" class="form-horizontal" id="autowp-setup-form">
6714 <fieldset>
6715 <legend><?php esc_html_e('API Registration', 'autowp'); ?></legend>
6716
6717 <!-- Email -->
6718 <div class="form-group">
6719 <label class="col-md-4 control-label" for="api_email"><?php esc_html_e('Email', 'autowp'); ?></label>
6720 <div class="col-md-4">
6721 <input id="api_email" name="api_email" type="text" class="form-control" value="<?php echo esc_attr($user_email); ?>" placeholder="<?php esc_html_e('Enter your email', 'autowp'); ?>">
6722 <p class="help-block"><?php esc_html_e('This email will be used to register and retrieve your API key.', 'autowp'); ?></p>
6723 </div>
6724 </div>
6725
6726 <!-- API Key -->
6727 <div class="form-group">
6728 <label class="col-md-4 control-label" for="api_key"><?php esc_html_e('API Key', 'autowp'); ?></label>
6729 <div class="col-md-4">
6730 <input id="api_key" name="api_key" type="text" class="form-control" placeholder="<?php esc_html_e('Enter your API key', 'autowp'); ?>">
6731 <p class="help-block"><?php esc_html_e('If you don’t have an API key, use the button below to request one.', 'autowp'); ?></p>
6732 </div>
6733 </div>
6734
6735 <!-- Request API Key Button -->
6736 <div class="form-group">
6737 <div class="col-md-4 col-md-offset-4">
6738 <button type="button" id="request_api_key" class="btn btn-info"><?php esc_html_e('Request API Key', 'autowp'); ?></button>
6739 </div>
6740 </div>
6741
6742 <!-- Save Settings Button -->
6743 <div class="form-group" style="margin-top: 20px;">
6744 <div class="col-md-4 col-md-offset-4">
6745 <button type="submit" class="btn btn-primary"><?php esc_html_e('Save Settings', 'autowp'); ?></button>
6746 </div>
6747 </div>
6748
6749 </fieldset>
6750 </form>
6751
6752 <!-- Bilgilendirme Mesajları -->
6753 <div id="autowp-messages"></div>
6754 </div>
6755
6756 <script>
6757 jQuery(document).ready(function($) {
6758 // Request API Key Button Click Event
6759 $('#request_api_key').click(function() {
6760 var email = $('#api_email').val();
6761
6762 if (!email) {
6763 $('#autowp-messages').html('<div class="alert alert-danger">Please enter an email address.</div>');
6764 return;
6765 }
6766
6767 // API çağrısını yap
6768 // API çağrısını yap
6769 $.ajax({
6770 url: '<?php echo esc_url( $url ); ?>',
6771 type: 'POST',
6772 contentType: 'application/json',
6773 data: JSON.stringify({ user_email: email }),
6774 success: function(response) {
6775 $('#autowp-messages').html('<div class="alert alert-success">API key has been sent to your email.</div>');
6776 },
6777 error: function(xhr, status, error) {
6778 var errorMessage = 'Error occurred while requesting API key. Please try again later.';
6779
6780 // Hata mesajını API'den gelen cevaba göre ayarla
6781 if (xhr.responseJSON && xhr.responseJSON.error) {
6782 errorMessage = xhr.responseJSON.error;
6783 } else if (xhr.responseText) {
6784 // JSON değilse ham yanıtı göster
6785 errorMessage = xhr.responseText;
6786 }
6787
6788 $('#autowp-messages').html('<div class="alert alert-danger">' + errorMessage + '</div>');
6789 }
6790 });
6791
6792 });
6793
6794 // Save Settings Button Click Event
6795 $('#autowp-setup-form').submit(function(event) {
6796 event.preventDefault(); // Formun varsayılan davranışını engelle
6797
6798 var email = $('#api_email').val();
6799 var api_key = $('#api_key').val();
6800
6801 if (!email || !api_key) {
6802 $('#autowp-messages').html('<div class="alert alert-danger">Email and API key cannot be empty.</div>');
6803 return;
6804 }
6805
6806 // API confirm_email çağrısını yap
6807 $.ajax({
6808 url: '<?php echo esc_url( $url_confirm ); ?>',
6809 type: 'POST',
6810 contentType: 'application/json',
6811 data: JSON.stringify({ user_email: email, api_key: api_key }),
6812 success: function(response) {
6813 // Başarılı ise bilgileri kaydet
6814 var settings = {
6815 'api_email': email,
6816 'api_key': api_key
6817 };
6818
6819 // AJAX ile WordPress'te settings güncelle
6820 $.ajax({
6821 url: ajaxurl, // WordPress'in global ajax URL'si
6822 type: 'POST',
6823 data: {
6824 action: 'save_autowp_settings',
6825 settings: settings
6826 },
6827 success: function() {
6828 $('#autowp-messages').html('<div class="alert alert-success">API settings saved successfully.</div>');
6829
6830 // 1-2 saniye sonra yönlendirme yap
6831 setTimeout(function() {
6832 window.location.href = 'admin.php?page=autowp_add_new_website_form';
6833 }, 1500); // 1500 milisaniye = 1.5 saniye
6834 }
6835 });
6836 },
6837 error: function(xhr, status, error) {
6838 var errorMessage = 'Error: An error occurred while confirming the email and API key.';
6839
6840 // Hata mesajını API'den gelen cevaba göre ayarla
6841 if (xhr.responseJSON && xhr.responseJSON.error) {
6842 errorMessage = 'Error: ' + xhr.responseJSON.error;
6843 } else if (xhr.responseText) {
6844 // JSON değilse ham yanıtı göster
6845 errorMessage = 'Error: ' + xhr.responseText;
6846 }
6847
6848 $('#autowp-messages').html('<div class="alert alert-danger">' + errorMessage + '</div>');
6849 }
6850 });
6851
6852 });
6853 });
6854 </script>
6855
6856 <?php
6857 }
6858
6859 // AJAX ile ayarları kaydetme fonksiyonu
6860 function save_autowp_settings() {
6861 // Mevcut ayarları al
6862 $existing_settings = get_option('autowp_settings');
6863 $existing_settings = $existing_settings ? unserialize($existing_settings) : [];
6864
6865 if (isset($_POST['settings'])) {
6866 // Sadece api_email ve api_key değerlerini güncelle
6867 $new_settings = $_POST['settings'];
6868
6869 // Mevcut ayarlarla birleştir (sadece api_email ve api_key'i günceller)
6870 $updated_settings = array_merge($existing_settings, [
6871 'api_email' => isset($new_settings['api_email']) ? sanitize_email($new_settings['api_email']) : '',
6872 'api_key' => isset($new_settings['api_key']) ? sanitize_text_field($new_settings['api_key']) : ''
6873 ]);
6874
6875 // Ayarları güncelle
6876 update_option('autowp_settings', serialize($updated_settings));
6877 }
6878
6879 wp_die(); // AJAX çağrısının sonlandırılması için gerekli
6880 }
6881 add_action('wp_ajax_save_autowp_settings', 'save_autowp_settings');
6882
6883
6884 function autowp_manual_post_selection_page_handler(){
6885 ?>
6886 <!-- Add this in the <head> section of your HTML -->
6887
6888 <div class="wrap">
6889 <h2><?php esc_html__('Manual Post', 'autowp')?></h2>
6890 <p><?php esc_html__('Please select the type of website you want manual posting:', 'autowp')?></p>
6891 <ul class="list-group">
6892 <li class="list-group-item">
6893 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_wp_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6894 <div class="d-flex align-items-center">
6895 <img src="<?php echo esc_url( plugins_url( 'assets/images/wordpress-icon.png', __FILE__ ) ); ?>" alt="<?php esc_attr_e('WordPress Website'); ?>" class="me-3" style="width: 80px; height: 80px;">
6896 <div>
6897 <h5><?php esc_html_e('AI-Rewrite From Wordpress Website', 'autowp')?></h5>
6898 <p><?php esc_html_e('Fetch posts from WordPress site and rewrite with artificial intelligence.', 'autowp')?></p>
6899 </div>
6900 </div>
6901 </a>
6902 </li>
6903 <li class="list-group-item">
6904 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_rss_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6905 <div class="d-flex align-items-center">
6906 <img src="<?php echo esc_url( plugins_url( 'assets/images/rss-icon.png', __FILE__ ) ); ?>" alt="<?php esc_attr_e('RSS Website'); ?>" class="me-3" style="width: 80px; height: 80px;">
6907 <div>
6908 <h5><?php esc_html_e('AI-Rewrite From RSS Website', 'autowp')?></h5>
6909 <p><?php esc_html_e('Fetch content with RSS and rewrite with artificial intelligence.', 'autowp')?></p>
6910 </div>
6911 </div>
6912 </a>
6913 </li>
6914 <li class="list-group-item">
6915 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_ai_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6916 <div class="d-flex align-items-center">
6917 <img src="<?php echo esc_url(plugins_url( 'assets/images/robot-icon.png', __FILE__ )); ?>" alt="Artificial Intelligence" class="me-3" style="width: 80px; height: 80px;">
6918 <div>
6919 <h5><?php esc_attr_e('AI Agents with Web Research Tools', 'autowp')?></h5>
6920 <p><?php esc_attr_e('Create original content from scratch using AutoWP AI Agent with web research tool !', 'autowp')?></p>
6921 </div>
6922 </div>
6923 </a>
6924 </li>
6925
6926 <li class="list-group-item">
6927 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_agenticscraper_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6928 <div class="d-flex align-items-center">
6929 <img src="<?php echo esc_url(plugins_url('assets/images/robot-icon.png', __FILE__)); ?>" alt="<?php esc_attr_e('Artificial Intelligence'); ?>" class="me-3" style="width: 80px; height: 80px;">
6930 <div>
6931 <h5><?php esc_attr_e('Agentic Scraper with Custom Tools and Prompts', 'autowp')?></h5>
6932 <p><?php esc_attr_e('Create your own Agentic Scraper with your customize tools and prompts!', 'autowp')?></p>
6933 </div>
6934 </div>
6935 </a>
6936 </li>
6937
6938
6939 <li class="list-group-item">
6940 <a href="<?php echo esc_url(get_admin_url(null, 'admin.php?page=manual_post_news_website_form')); ?>" class="d-flex justify-content-between align-items-center">
6941 <div class="d-flex align-items-center">
6942 <img src="<?php echo esc_url( plugins_url( 'assets/images/gnews.png', __FILE__ ) ); ?>" alt="<?php esc_attr_e('Rewrite With AI From News'); ?>" class="me-3" style="width: 80px; height: 80px;">
6943 <div>
6944 <h5><?php esc_html_e('AI-Rewrite News From Google News ', 'autowp')?></h5>
6945 <p><?php esc_html_e('Fetch content from Google News and rewrite with artificial intelligence.', 'autowp')?></p>
6946 </div>
6947 </div>
6948 </a>
6949 </li>
6950
6951 <!-- New item with modal trigger -->
6952 <li class="list-group-item">
6953 <a href="#" data-bs-toggle="modal" data-bs-target="#tutorialModal" class="d-flex justify-content-between align-items-center">
6954 <div class="d-flex align-items-center">
6955 <img src="<?php echo esc_url(plugins_url( 'assets/images/tutorial.png', __FILE__ )); ?>" alt="Tutorial" class="me-3" style="width: 80px; height: 80px;">
6956 <div>
6957 <h5><?php esc_html_e('Video Tutorials', 'autowp')?></h5>
6958 <p><?php esc_html_e('Learn how to add new process.', 'autowp')?></p>
6959 </div>
6960 </div>
6961 </a>
6962 </li>
6963 </ul>
6964 </div>
6965
6966 <!-- Bootstrap Modal -->
6967 <div class="modal fade" id="tutorialModal" tabindex="-1" aria-labelledby="tutorialModalLabel" aria-hidden="true">
6968 <div class="modal-dialog modal-dialog-centered">
6969 <div class="modal-content">
6970
6971 <div class="modal-header">
6972 <h5 class="modal-title" id="tutorialModalLabel">Video Tutorials</h5>
6973 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
6974 </div>
6975 <div class="modal-body">
6976 <div class="mb-3">
6977 <h5>Manual Processes:</h5>
6978 <p>After clicking the "Generate Post" button at the bottom, your process will start running in the background. The average duration of this process is around 5 minutes. If an error occurs, you can find detailed information at the top of your WordPress admin panel.</p>
6979 </div>
6980
6981 <div class="mb-3">
6982 <h5>Automatic Processes:</h5>
6983 <p>For each added process, it will be automatically triggered at the specified time interval (you can set this in the settings, under the cron section). Therefore, after adding processes, you need to set the time and wait for the posts to be generated automatically.</p>
6984 </div>
6985 <!-- Video Tutorials -->
6986 <div class="mb-3">
6987 <h6>How to Use - Detailed Tutorial </h6>
6988 <iframe width="450" height="350" src="https://www.youtube.com/embed/idN8NNyyjW8" frameborder="0" allowfullscreen></iframe>
6989 </div>
6990
6991 <!-- Timestamp Links -->
6992 <div class="video-timestamps">
6993 <ul>
6994 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=0s" target="_blank"><strong>0:00</strong> - Setup AutoWP</a></li>
6995 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=46s" target="_blank"><strong>0:46</strong> - Add WordPress website as a source</a></li>
6996 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=90s" target="_blank"><strong>1:30</strong> - Add RSS Feed as a source</a></li>
6997 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=126s" target="_blank"><strong>2:06</strong> - Add Google News as a source</a></li>
6998 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=178s" target="_blank"><strong>2:58</strong> - Posts generated by AutoWP</a></li>
6999 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=204s" target="_blank"><strong>3:24</strong> - Content Planner – Adding a Section with Your Own Prompt</a></li>
7000 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=440s" target="_blank"><strong>7:20</strong> - Content Planner – Adding a Fixed HTML Section</a></li>
7001 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=455s" target="_blank"><strong>7:35</strong> - Content Planner – Ready-Made Section Templates</a></li>
7002 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=466s" target="_blank"><strong>7:46</strong> - Content Planner – Adding/Removing Ready-Made Section Templates</a></li>
7003 <li><a href="https://www.youtube.com/watch?v=idN8NNyyjW8&t=487s" target="_blank"><strong>8:07</strong> - Exit</a></li>
7004 </ul>
7005 </div>
7006
7007
7008 <!-- End Video Tutorials -->
7009
7010 </div>
7011
7012 <div class="modal-footer">
7013 <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
7014 </div>
7015 </div>
7016 </div>
7017 </div>
7018
7019
7020
7021
7022
7023
7024
7025 <?php
7026 }
7027
7028 // Setup sayfasını kayıt etme
7029 function autowp_register_setup_page() {
7030 add_submenu_page(null, 'AutoWP Setup', 'AutoWP Setup', 'manage_options', 'autowp-setup', 'autowp_setup_page');
7031 }
7032 add_action('admin_menu', 'autowp_register_setup_page');
7033
7034 function autowp_setAdminMenu(){
7035 add_menu_page(__('AutoWP', 'autowp'), __('AutoWP', 'autowp'), 'activate_plugins', 'autowp_menu', 'autowp_generalSettings',plugins_url( '/assets/images/autowp-icon25.png',__FILE__ ));
7036 add_submenu_page('autowp_menu', __('Automatic Post', 'autowp'), __('Automatic Post', 'autowp'), 'activate_plugins', 'autowp_automaticPost', 'autowp_wp_page_handler');
7037 add_submenu_page('autowp_menu', __('Add new', 'autowp'), __('Add new', 'autowp'), 'activate_plugins', 'autowp_add_new_website_form', 'autowp_website_selection_page_handler');
7038 add_submenu_page('autowp_menu', __("Manual Post","autowp"), __("Manual Post","autowp"), '2' ,'autowp_manualPost' ,'autowp_manual_post_selection_page_handler', '7');
7039 add_submenu_page('autowp_menu', __("Content Planner","autowp"), __("Content Planner","autowp"), '3' ,'autowp_promptSettings' ,'autowp_rewriting_promptscheme_page_handler', '8');
7040 add_submenu_page(
7041 'autowp_menu',
7042 __('Linking Management', 'autowp'),
7043 __('Linking Management', 'autowp'),
7044 'manage_options',
7045 'autowp_linking_management',
7046 'autowp_linking_page_handler'
7047 );
7048
7049
7050 //Automatic Post
7051 add_submenu_page('autowp_add_new_website_form', __('Add new WordPress Website', 'autowp'), __('Add new WordPress Website', 'autowp'), 'manage_options', 'add_new_wp_website_form', 'autowp_wp_website_form_page_handler');
7052 add_submenu_page('autowp_add_new_website_form',__('Add new RSS Website', 'autowp'), __('Add new RSS Website', 'autowp'), 'manage_options', 'add_new_rss_website_form', 'autowp_rss_website_form_page_handler');
7053 add_submenu_page('autowp_add_new_website_form', __('Add new AI-Generated Process', 'autowp'), __('Add new AI-Generated Process', 'autowp'), 'manage_options', 'add_new_ai_website_form', 'autowp_ai_website_form_page_handler');
7054 add_submenu_page('autowp_add_new_website_form', __('Add new News Website', 'autowp'), __('Add new News Website', 'autowp'), 'manage_options', 'add_new_news_website_form', 'autowp_news_website_form_page_handler');
7055 add_submenu_page('autowp_add_new_website_form', __('Add new Customize AI Agent', 'autowp'), __('Add new Customize AI Agent', 'autowp'), 'manage_options', 'add_new_agenticscraper_form', 'autowp_auto_post_agent_form_page_handler');
7056
7057
7058 //Manual Post
7059
7060 add_submenu_page('autowp_manualPost', __('Wordpress Website', 'autowp'), __('AI Post Writing', 'autowp'), 'manage_options', 'manual_post_ai_website_form', 'autowp_manual_post_ai_form_page_handler');
7061 add_submenu_page('autowp_manualPost', __('Wordpress Website', 'autowp'), __('Agentic Scraper with Custom Tools', 'autowp'), 'manage_options', 'manual_post_agenticscraper_website_form', 'autowp_manual_post_agenticscraper_form_page_handler');
7062 add_submenu_page('autowp_manualPost', __('Wordpress Website', 'autowp'), __('AI Rewrite Post From RSS Website', 'autowp'), 'manage_options', 'manual_post_rss_website_form', 'autowp_manual_post_rss_form_page_handler');
7063 add_submenu_page('autowp_manualPost', __('Wordpress Website', 'autowp'), __('AI Rewrite Post From Wordpress Website', 'autowp'), 'manage_options', 'manual_post_wp_website_form', 'autowp_manual_post_wp_form_page_handler');
7064 add_submenu_page('autowp_manualPost', __('Wordpress Website', 'autowp'), __('Wordpress Website', 'autowp'), 'manage_options', 'manual_post_news_website_form', 'autowp_manual_post_news_form_page_handler');
7065
7066 //Prompt Settings
7067
7068
7069
7070 //Add a new submenu for Prompt Scheme Management
7071
7072 add_submenu_page('autowp_promptSettings', __('Writing Prompt Schemes', 'autowp'), __('Writing Prompt Schemes', 'autowp'), 'manage_options', 'autowp_promptschemes', 'autowp_writing_promptscheme_page_handler');
7073 add_submenu_page('autowp_promptSettings', __('Content Planner', 'autowp'), __('Prompt Schemes', 'autowp'), 'manage_options', 'autowp_rewriting_promptschemes', 'autowp_rewriting_promptscheme_page_handler');
7074
7075 add_submenu_page(
7076 'autowp_menu', // Parent slug (the AutoWP main menu)
7077 __('Transactions', 'autowp'), // Page title
7078 __('Transactions', 'autowp'), // Menu title
7079 'manage_options', // Capability required to access the page
7080 'autowp_transactions', // Menu slug
7081 'autowp_transactions_page_handler' // Function to display the content
7082 );
7083
7084 // Add a new submenu page for Settings
7085 add_submenu_page('autowp_menu', __('Settings', 'autowp'), __('Settings', 'autowp'), 'activate_plugins', 'autowp_settings', 'autowp_settings_page_handler');
7086
7087
7088 }
7089
7090 add_action('admin_menu','autowp_setAdminMenu');
7091
7092
7093
7094 function autowp_transactions_page_handler() {
7095
7096
7097 $server_url = unserialize(get_option("autowp_settings"))["autowp_server_url"];
7098
7099
7100 $autowp_server_url = 'https://api.autowp.app';
7101
7102
7103 if ( isset( $server_url )
7104 && $server_url !== null
7105 && $server_url !== ''
7106 && strpos( $server_url, 'autowp.app' ) === false
7107 ) {
7108 $autowp_server_url = $server_url;
7109
7110 }
7111
7112
7113
7114 // Enqueue Bootstrap styles and scripts
7115 wp_enqueue_style('bootstrap-css', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css');
7116 wp_enqueue_script('bootstrap-js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js', array('jquery'), null, true);
7117
7118 ?>
7119 <div class="container-fluid mt-5">
7120 <h1 class="text-center"><?php esc_html_e('Transactions Overview', 'autowp'); ?></h1>
7121
7122
7123 <!-- Tab Navigation -->
7124 <ul class="nav nav-tabs" id="transactionsTabs" role="tablist">
7125 <li class="nav-item">
7126
7127 <a class="nav-link active" id="post-tab" data-toggle="tab" href="#post" role="tab" aria-controls="post" aria-selected="true"><?php esc_html_e('Post Transactions', 'autowp'); ?></a>
7128
7129 </li>
7130 <li class="nav-item">
7131 <a class="nav-link" id="image-tab" data-toggle="tab" href="#image" role="tab" aria-controls="image" aria-selected="false"><?php esc_html_e('Image Transactions', 'autowp'); ?></a>
7132
7133 </li>
7134 <li class="nav-item">
7135 <a class="nav-link" id="exceptions-tab" data-toggle="tab" href="#exceptions" role="tab" aria-controls="exceptions" aria-selected="false"><?php esc_html_e('Error Logs', 'autowp'); ?></a>
7136 </li>
7137 </ul>
7138
7139 <!-- Tab Content -->
7140 <div class="tab-content" id="transactionsTabsContent">
7141 <!-- Post Transactions Tab -->
7142 <div class="tab-pane fade show active" id="post" role="tabpanel" aria-labelledby="post-tab">
7143
7144 <div class="card-header">
7145
7146 <h2><?php esc_html_e('Post Transactions', 'autowp'); ?></h2>
7147
7148 </div>
7149 <div class="card-body p-0">
7150
7151 <div class="spinner-border text-primary" role="status" id="post-loading">
7152 <span class="sr-only">Loading...</span>
7153 </div>
7154 <!-- Tam genişlikte tablo ve responsive yapı -->
7155 <div class="table-responsive">
7156 <table class="table table-striped table-bordered w-100" id="post-transactions-table" style="display:none;">
7157 <thead class="thead-light">
7158 <tr id="post-transactions-header"></tr>
7159 </thead>
7160 <tbody></tbody>
7161 </table>
7162 </div>
7163 <div class="alert alert-info" id="post-no-data" style="display:none;">No Post Transactions found.</div>
7164 </div>
7165
7166 </div>
7167
7168 <!-- Image Transactions Tab -->
7169 <div class="tab-pane fade" id="image" role="tabpanel" aria-labelledby="image-tab">
7170
7171 <div class="card-header">
7172 <h2><?php esc_html_e('Image Transactions', 'autowp'); ?></h2>
7173 </div>
7174 <div class="card-body p-0">
7175
7176 <div class="spinner-border text-primary" role="status" id="image-loading">
7177 <span class="sr-only">Loading...</span>
7178 </div>
7179 <div class="table-responsive">
7180 <table class="table table-striped table-bordered w-100" id="image-transactions-table" style="display:none;">
7181 <thead class="thead-light">
7182 <tr id="image-transactions-header"></tr>
7183 </thead>
7184 <tbody></tbody>
7185 </table>
7186 </div>
7187 <div class="alert alert-info" id="image-no-data" style="display:none;">No Image Transactions found.</div>
7188 </div>
7189
7190 </div>
7191
7192 <!-- Exceptions Tab -->
7193 <div class="tab-pane fade" id="exceptions" role="tabpanel" aria-labelledby="exceptions-tab">
7194
7195 <div class="card-header">
7196 <h2><?php esc_html_e('Error Logs', 'autowp'); ?></h2>
7197 </div>
7198 <div class="card-body p-0">
7199
7200 <div class="spinner-border text-primary" role="status" id="exceptions-loading">
7201 <span class="sr-only">Loading...</span>
7202 </div>
7203 <div class="table-responsive">
7204 <table class="table table-striped table-bordered w-100" id="exceptions-table" style="display:none;">
7205 <thead class="thead-light">
7206 <tr id="exceptions-header"></tr>
7207 </thead>
7208 <tbody></tbody>
7209 </table>
7210 </div>
7211 <div class="alert alert-info" id="exceptions-no-data" style="display:none;">No Exceptions found.</div>
7212 </div>
7213 </div>
7214 </div>
7215
7216 </div>
7217
7218 <script type="text/javascript">
7219
7220 const API_BASE_URL = '<?php echo esc_js( $autowp_server_url ); ?>';
7221
7222 document.addEventListener('DOMContentLoaded', function() {
7223 var userEmail = '<?php
7224 $settings = unserialize(get_option('autowp_settings'));
7225 echo esc_js($settings["api_email"]);
7226 ?>'; // Get the API email from autowp_settings
7227
7228 fetchTransactions(userEmail);
7229 });
7230
7231 function createTableHeaders(fields, tableHeaderId) {
7232 let headerHtml = '';
7233 fields.forEach(field => {
7234 headerHtml += '<th>' + field + '</th>';
7235 });
7236 document.getElementById(tableHeaderId).innerHTML = headerHtml;
7237 }
7238
7239 function fetchTransactions(userEmail) {
7240 // Post Transactions
7241 fetch(API_BASE_URL + '/post_transactions?user_email=' + encodeURIComponent(userEmail))
7242
7243 .then(response => response.json())
7244 .then(data => {
7245 var postTable = document.getElementById('post-transactions-table');
7246 var postLoading = document.getElementById('post-loading');
7247 var postNoData = document.getElementById('post-no-data');
7248 if (data.length > 0) {
7249 postTable.style.display = 'table';
7250 const fields = Object.keys(data[0]);
7251 createTableHeaders(fields, 'post-transactions-header');
7252 let html = '';
7253 data.forEach(transaction => {
7254 html += '<tr>';
7255 fields.forEach(field => {
7256
7257 html += '<td>' + transaction[field] + '</td>';
7258 });
7259 html += '</tr>';
7260 });
7261 postTable.querySelector('tbody').innerHTML = html;
7262 } else {
7263 postNoData.style.display = 'block';
7264 }
7265 postLoading.style.display = 'none';
7266 });
7267
7268 // Image Transactions
7269 fetch(API_BASE_URL + '/image_transactions?user_email=' + encodeURIComponent(userEmail))
7270
7271 .then(response => response.json())
7272 .then(data => {
7273 var imageTable = document.getElementById('image-transactions-table');
7274 var imageLoading = document.getElementById('image-loading');
7275 var imageNoData = document.getElementById('image-no-data');
7276 if (data.length > 0) {
7277 imageTable.style.display = 'table';
7278 const fields = Object.keys(data[0]);
7279 createTableHeaders(fields, 'image-transactions-header');
7280 let html = '';
7281 data.forEach(transaction => {
7282 html += '<tr>';
7283 fields.forEach(field => {
7284 if (field === 'image_url') {
7285 html += '<td><img src="' + transaction[field] + '" alt="Image" class="img-thumbnail" width="100"></td>';
7286 } else {
7287 html += '<td>' + transaction[field] + '</td>';
7288 }
7289 });
7290 html += '</tr>';
7291 });
7292 imageTable.querySelector('tbody').innerHTML = html;
7293 } else {
7294 imageNoData.style.display = 'block';
7295 }
7296 imageLoading.style.display = 'none';
7297 });
7298
7299 // Exceptions
7300 fetch(API_BASE_URL + '/exceptions?user_mail=' + encodeURIComponent(userEmail))
7301
7302 .then(response => response.json())
7303 .then(data => {
7304 var exceptionsTable = document.getElementById('exceptions-table');
7305 var exceptionsLoading = document.getElementById('exceptions-loading');
7306 var exceptionsNoData = document.getElementById('exceptions-no-data');
7307 if (data.length > 0) {
7308 exceptionsTable.style.display = 'table';
7309 const fields = Object.keys(data[0]);
7310 createTableHeaders(fields, 'exceptions-header');
7311 let html = '';
7312 data.forEach(exception => {
7313 html += '<tr>';
7314 fields.forEach(field => {
7315 html += '<td>' + exception[field] + '</td>';
7316 });
7317 html += '</tr>';
7318 });
7319 exceptionsTable.querySelector('tbody').innerHTML = html;
7320 } else {
7321 exceptionsNoData.style.display = 'block';
7322 }
7323 exceptionsLoading.style.display = 'none';
7324 });
7325 }
7326 </script>
7327 <?php
7328 }
7329
7330
7331
7332
7333 ?>
7334