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