get_option('botwriter_cron_active'), 'next_cron' => $next_cron ? gmdate('Y-m-d H:i:s', $next_cron) . ' UTC' : 'not scheduled', ]); $table = new botwriter_tasks_Table(); $table->prepare_items(); $message = ''; if ('delete_all' === $table->current_action()) { $message = 'Items deleted'; } if ('delete' === $table->current_action()) { $message = 'Item deleted'; } $message = esc_html($message); ?>

display(); ?>
prefix . 'botwriter_tasks'; $message = ''; $notice = ''; $default = array( 'id' => 0, /* translators: %d: next task number */ 'task_name' => sprintf(__('Task %d', 'botwriter'), $wpdb->get_var("SELECT COUNT(*) FROM $table_name") + 1), 'writer' => 'orion', 'narration' => 'Descriptive', 'custom_style' => '', 'post_language' => '', 'post_length' => '800', 'custom_post_length' => '', 'post_status' => 'publish', 'days' => '', 'times_per_day' => 1, 'execution_count' => 0, // Initialize execution count to zero 'last_execution_date' => null, // Set last execution date to null initially 'website_type' => 'ai', 'website_name' => '', 'domain_name' => '', 'post_type' => 'post', 'category_id' => '', 'taxonomy_data' => '', 'website_category_id' => '', 'website_category_name' => '', 'aigenerated_title' => '', 'aigenerated_content' => '', 'aigenerated_tags' => '', 'aigenerated_image' => '', 'post_count' => '', 'post_order' => '', 'title_prompt' => '', 'content_prompt' => '', 'tags_prompt' => '', 'image_prompt' => '', 'image_generating_status' => '', 'author_selection' => '', 'news_keyword' => '', 'news_country' => '', 'news_language' => '', 'news_time_published' => '', 'news_source' => '', 'rss_source' => '', 'ai_keywords' => '', 'disable_ai_images' => 0, 'template_id' => null, ); if ( isset($_REQUEST['nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), basename(__FILE__))) { $days = isset($_POST['days']) ? implode(",", array_map('sanitize_text_field', wp_unslash($_POST['days']))) : ""; $times_per_day = isset($_POST['times_per_day']) ? intval(wp_unslash($_POST['times_per_day'])) : 1; // Process only the specific values needed $item = array( 'id' => isset($_POST['id']) ? intval(wp_unslash($_POST['id'])) : 0, 'task_name' => isset($_POST['task_name']) ? sanitize_text_field(wp_unslash($_POST['task_name'])) : '', 'post_status' => isset($_POST['post_status']) ? sanitize_text_field(wp_unslash($_POST['post_status'])) : '', 'days' => $days, 'times_per_day' => $times_per_day, 'writer' => isset($_POST['writer']) ? sanitize_text_field(wp_unslash($_POST['writer'])) : '', 'narration' => isset($_POST['narration']) ? sanitize_text_field(wp_unslash($_POST['narration'])) : '', 'post_length' => isset($_POST['post_length']) ? sanitize_text_field(wp_unslash($_POST['post_length'])) : '', 'custom_post_length'=> isset($_POST['custom_post_length']) ? sanitize_text_field(wp_unslash($_POST['custom_post_length'])) : '', 'custom_style' => isset($_POST['custom_style']) ? sanitize_text_field(wp_unslash($_POST['custom_style'])) : '', 'post_language' => isset($_POST['post_language']) ? sanitize_text_field(wp_unslash($_POST['post_language'])) : '', 'website_type' => isset($_POST['website_type']) ? sanitize_text_field(wp_unslash($_POST['website_type'])) : '', 'website_name' => '', 'domain_name' => isset($_POST['domain_name']) ? sanitize_url(wp_unslash($_POST['domain_name'])) : '', 'post_type' => isset($_POST['task_post_type']) ? sanitize_text_field(wp_unslash($_POST['task_post_type'])) : 'post', 'category_id' => isset($_POST['category_id']) ? array_map('intval', wp_unslash($_POST['category_id'])) : array(), 'taxonomy_data' => isset($_POST['taxonomy_data']) ? sanitize_text_field(wp_unslash($_POST['taxonomy_data'])) : '', 'website_category_id'=> isset($_POST['website_category_id']) ? array_map('intval', wp_unslash($_POST['website_category_id'])) : array(), 'website_category_name'=> isset($_POST['website_category_name']) ? sanitize_text_field(wp_unslash($_POST['website_category_name'])) : '', 'aigenerated_title' => '', 'aigenerated_content'=> '', 'aigenerated_tags' => '', 'aigenerated_image' => '', 'post_count' => 5, 'post_order' => '', 'title_prompt' => '', 'content_prompt' => '', 'tags_prompt' => '', 'image_prompt' => '', 'image_generating_status' => '', 'author_selection' => isset($_POST['author_selection']) ? sanitize_text_field(wp_unslash($_POST['author_selection'])) : '', 'news_keyword' => isset($_POST['news_keyword']) ? sanitize_text_field(wp_unslash($_POST['news_keyword'])) : '', 'news_country' => isset($_POST['news_country']) ? sanitize_text_field(wp_unslash($_POST['news_country'])) : '', 'news_language' => isset($_POST['news_language']) ? sanitize_text_field(wp_unslash($_POST['news_language'])) : '', 'news_time_published' => isset($_POST['news_time_published']) ? sanitize_text_field(wp_unslash($_POST['news_time_published'])) : '', 'news_source' => isset($_POST['news_source']) ? sanitize_text_field(wp_unslash($_POST['news_source'])) : '', 'rss_source' => isset($_POST['rss_source']) ? sanitize_text_field(wp_unslash($_POST['rss_source'])) : '', 'ai_keywords' => isset($_POST['ai_keywords']) ? sanitize_text_field(wp_unslash($_POST['ai_keywords'])) : '', 'disable_ai_images' => isset($_POST['disable_ai_images']) ? intval(wp_unslash($_POST['disable_ai_images'])) : 0, 'template_id' => isset($_POST['template_id']) && !empty($_POST['template_id']) ? intval(wp_unslash($_POST['template_id'])) : null ); // Process taxonomy terms and build taxonomy_data JSON $taxonomy_terms = isset($_POST['taxonomy_terms']) ? map_deep(wp_unslash($_POST['taxonomy_terms']), 'sanitize_text_field') : array(); $taxonomy_data = array(); foreach ($taxonomy_terms as $taxonomy_name => $term_ids) { $taxonomy_name = sanitize_key($taxonomy_name); $taxonomy_data[$taxonomy_name] = array_map('intval', (array)$term_ids); } $item['taxonomy_data'] = wp_json_encode($taxonomy_data); // For backward compatibility, extract category IDs if 'category' taxonomy is present if (isset($taxonomy_data['category'])) { $item['category_id'] = implode(',', $taxonomy_data['category']); } else { // Convert legacy category_id array to text $category_ids = implode(",", $item['category_id']); $item['category_id'] = $category_ids; } //Convert website_category_id to text $website_category_ids = implode(",", $item['website_category_id']); $item['website_category_id'] = $website_category_ids; botwriter_log('Task validation starting', [ 'task_name' => $item['task_name'], 'post_type' => $item['post_type'] ?? 'not set', 'category_id' => $item['category_id'], 'taxonomy_data' => $item['taxonomy_data'] ?? 'not set', ]); $item_valid = botwriter_validate_website($item); botwriter_log('Task validation result', ['valid' => $item_valid === true ? 'yes' : $item_valid]); if ($item_valid === true) { //$item = array_map('sanitize_text_field', $item); // Sanitize all inputs if ($item['id'] == 0) { // Do not insert primary key 'id' explicitly to allow AUTO_INCREMENT/SQLite AUTOINCREMENT to work $insert_data = $item; unset($insert_data['id']); botwriter_log('Task INSERT data', ['fields' => array_keys($insert_data), 'post_type' => $insert_data['post_type'] ?? 'not set', 'taxonomy_data' => $insert_data['taxonomy_data'] ?? 'not set']); $result = $wpdb->insert($table_name, $insert_data); $item['id'] = $wpdb->insert_id; if ($result) { botwriter_log('Task created', [ 'task_id' => $item['id'], 'website_type' => $item['website_type'], 'status' => $item['status'] ?? null, 'days' => $item['days'] ?? null, 'times_per_day' => $item['times_per_day'] ?? null, ]); $message = __('New task was successfully saved!', 'botwriter'); ?>
$wpdb->last_error, 'last_query' => $wpdb->last_query, ], 'error'); $notice = __('There was an error while saving item', 'botwriter') . ': ' . $wpdb->last_error; } } else { // Do not try to update the primary key value itself $update_data = $item; $row_id = (int) $item['id']; unset($update_data['id']); $result = $wpdb->update($table_name, $update_data, array('id' => $row_id)); if ($result !== false) { if ($result === 0) { botwriter_log('Task update no changes', [ 'task_id' => $row_id, 'website_type' => $item['website_type'], ]); $message = __('No changes were made, but the update was successful.', 'botwriter'); ?>
$row_id, 'website_type' => $item['website_type'], 'status' => $item['status'] ?? null, 'days' => $item['days'] ?? null, 'times_per_day' => $item['times_per_day'] ?? null, ]); $message = __('New task was successfully updated!', 'botwriter'); ?>
$row_id, 'error' => $wpdb->last_error, ], 'error'); $notice = __('There was an error while updating item: ', 'botwriter') . $wpdb->last_error; } } } else { $notice = $item_valid; } } else { $item = $default; if (isset($_REQUEST['id'])) { $sanitized_id = absint($_REQUEST['id']); // Sanitize as an integer $item = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$table_name} WHERE id = %d", $sanitized_id), ARRAY_A); if (!$item) { $item = $default; $notice = __('Item not found', 'botwriter'); } } } add_meta_box('botwriter_post_form_meta_box', __('Task Form', 'botwriter'), 'botwriter_post_form_meta_box_handler', 'botwriter_automatic_post_new', 'normal', 'default'); ?>

0; $title_text = $is_editing ? __('Edit Task', 'botwriter') : __('Add New', 'botwriter'); ?>



Select an author from the list.

Select the status of the post. Choose 'Draft' if you want to revise it before publishing.


" . esc_html($day) . "
"; } ?>

Select the days on which you want to write and publish.


public) { continue; } // Skip tag taxonomies (AI generates tags) if (in_array($taxonomy->name, $skip_taxonomies, true)) { continue; } $terms = get_terms(array( 'taxonomy' => $taxonomy->name, 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', )); if (is_wp_error($terms) || empty($terms)) { continue; } $selected_terms = isset($saved_taxonomy_data[$taxonomy->name]) ? (array)$saved_taxonomy_data[$taxonomy->name] : array(); // For 'category' taxonomy, if nothing selected, select first one if ($taxonomy->name === 'category' && empty($selected_terms) && !empty($terms)) { $selected_terms = array($terms[0]->term_id); } ?>


Enter the URL of the external WordPress site from which you want to get ideas. Later get the categories.



Try on https://news.google.com to see the type of news that will appear





Optional. Enter the source (website) of the news you want to get ideas from. For e.g. https://bbc.com or https://cnn.com

Enter the URL of the RSS feed. View awesome RSS feeds

Enter keywords or topics separated by commas, or write a prompt with instructions.

Tip: For full control over the prompt, select the "Custom Prompt (Empty)" template.



Select the desired post length or choose custom to enter a specific number of words.

Enter the number of words you want the post to have.


>

All Sources Images' ); ?>