PluginProbe ʕ •ᴥ•ʔ
AutoWP – AI Content Writer & Rewriter / 2.3.0
AutoWP – AI Content Writer & Rewriter v2.3.0
2.3.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9
autowp-ai-content-writer-rewriter / includes / new-rss-website-form.php
autowp-ai-content-writer-rewriter / includes Last commit date
new-ai-website-form.php 1 month ago new-gtrends-website-form.php 1 month ago new-news-website-form.php 1 month ago new-own-ai-agent-form.php 1 month ago new-rss-website-form.php 1 month ago new-wp-website-form.php 1 month ago
new-rss-website-form.php
527 lines
1 <?php
2
3
4
5
6 function autowp_rss_website_form_page_handler(){
7 global $wpdb;
8 $table_name = $wpdb->prefix . 'autowp_wordpress_websites';
9
10 $message = '';
11 $notice = '';
12
13
14 $default = array(
15 'id' => 0,
16 'website_name' => '',
17 'website_type' => '',
18 'domain_name' => '',
19 'category_id' => '',
20 'aigenerated_title' => '',
21 'aigenerated_content' => '',
22 'aigenerated_tags' => '',
23 'aigenerated_image' => '',
24 'post_count' => '',
25 'post_order' => '',
26 'title_prompt' => '',
27 'content_prompt' => '',
28 'tags_prompt' => '',
29 'image_prompt' => '',
30 'image_generating_status' => '',
31 'author_selection' => '',
32 'active' => ''
33
34
35
36 );
37
38
39 if ( isset($_REQUEST['nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), basename(__FILE__))) {
40
41
42
43
44 // Process only the specific values needed
45 $item_id = isset($_POST['id']) ? intval($_POST['id']) : 0;
46
47 $language = isset($_POST['languageSelect']) ? sanitize_text_field($_POST['languageSelect']) : '';
48 $subtitle = isset($_POST['subtitleSelect']) ? sanitize_text_field($_POST['subtitleSelect']) : '';
49 $narration = isset($_POST['narrationSelect']) ? sanitize_text_field($_POST['narrationSelect']) : '';
50
51 $item = array(
52 'website_name' => isset($_POST['website_name']) ? sanitize_text_field($_POST['website_name']) : '',
53 'domain_name' => isset($_POST['domain_name']) ? sanitize_text_field($_POST['domain_name']) : '',
54 'category_id' => isset($_POST['category_id']) ? array_map('intval', (array) $_POST['category_id']) : array(),
55 'aigenerated_title' => '1',
56 'aigenerated_content'=> '1',
57 'aigenerated_tags' => '1',
58 'aigenerated_image' => '1',
59 'post_count' => 5,
60 'post_order' => isset($_POST['post_order']) ? sanitize_text_field($_POST['post_order']) : 'desc',
61 'title_prompt' => isset($_POST['title_prompt']) ? sanitize_textarea_field($_POST['title_prompt']) : '',
62 'content_prompt' => '[autowp-rewriting-promptcode]' . $language . ',' . $subtitle . ',' . $narration . '[/autowp-rewriting-promptcode]',
63 'tags_prompt' => isset($_POST['tags_prompt']) ? sanitize_textarea_field($_POST['tags_prompt']) : '',
64 'image_prompt' => isset($_POST['image_prompt']) ? sanitize_textarea_field($_POST['image_prompt']) : '',
65 'website_type' => 'rss',
66 'image_generating_status' => isset($_POST['image_generating_status']) ? sanitize_text_field($_POST['image_generating_status']) : '0',
67 'author_selection' => isset($_POST['author_selection']) ? sanitize_text_field($_POST['author_selection']) : '1',
68 'active' => isset($_POST['active']) ? sanitize_text_field($_POST['active']) : '1'
69 );
70
71
72 //Convert category_id array to text
73 $category_ids = implode(",", $item['category_id']);
74 $item['category_id'] = $category_ids;
75
76
77 if ($item['aigenerated_title'] !== '1'){
78 $item['aigenerated_title'] = '0';
79 }
80
81 if($item['aigenerated_content'] !== '1'){
82 $item['aigenerated_content'] = '0';
83 }
84
85 if($item['aigenerated_tags'] !== '1'){
86 $item['aigenerated_tags'] = '0';
87 }
88
89 if($item['aigenerated_image'] !== '1'){
90 $item['aigenerated_image'] = '0';
91 }
92
93 $item['website_type'] = 'rss';
94 $item['id'] = $item_id;
95
96 // Set WP-CRON
97
98 $settings = unserialize(get_option('autowp_settings'));
99
100 $wpcron_status = $settings['wpcron_status'];
101
102 if(!isset($wpcron_status)){
103 autowp_update_wp_cron_status('1');
104 }
105
106 $time_value_type = $settings['selected_time_type'];
107
108 $user_wpcron_time = autowp_get_wpcron_time($time_value_type);
109
110 $next_two_minutes = time() + 2 * 60;
111
112 // Schedule WP-Cron
113 if (!wp_next_scheduled('autowp_cron')) {
114 wp_schedule_event($next_two_minutes, $user_wpcron_time, 'autowp_cron');
115
116 } else {
117 wp_clear_scheduled_hook('autowp_cron');
118 wp_schedule_event($next_two_minutes, $user_wpcron_time, 'autowp_cron');
119 }
120
121
122
123
124
125 $item_valid = autowp_validate_website($item);
126 if ($item_valid === true) {
127 $item_to_save = $item;
128 unset($item_to_save['id']);
129 if ($item_id == 0) {
130 $result = $wpdb->insert($table_name, $item_to_save);
131 $item_id = $wpdb->insert_id;
132 $item['id'] = $item_id;
133 if ($result) {
134 $message = __('New process was successfully saved! Next process execution time : ' . get_next_cron_time('autowp_cron') . ' in your server time. You can change process execution interval in your settings page! ', 'autowp');
135 } else {
136 $notice = __('There was an error while saving item', 'autowp');
137 }
138 } else {
139 $result = $wpdb->update($table_name, $item_to_save, array('id' => $item_id));
140 if ($result) {
141 $message = __('New process was successfully updated! Next process execution time : ' . get_next_cron_time('autowp_cron') . ' in your server time. You can change process execution interval in your settings page! ', 'autowp');
142 } else {
143 $notice = __('There was an error while updating item', 'autowp');
144 }
145 }
146 } else {
147
148 $notice = $item_valid;
149 }
150 }
151 else {
152
153 $item = $default;
154 if (isset($_REQUEST['id'])) {
155 $item_id = absint($_REQUEST['id']); // Sanitize the input as an integer
156 $item = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE id = %d", $item_id), ARRAY_A);
157
158 if (!$item) {
159 $item = $default;
160 $notice = esc_html__('Item not found', 'autowp'); // Escape the notice message
161 }
162 }
163
164 }
165
166
167 add_meta_box('websites_form_meta_box', __('Website Form', 'autowp'), 'autowp_rss_websites_form_meta_box_handler', 'add_new_rss_website_form', 'normal', 'default');
168
169 ?>
170 <div class="wrap">
171 <div class="icon32 icon32-posts-post" id="icon-edit"><br></div>
172 <h2><?php esc_html_e('Add New', 'autowp'); ?> <a class="add-new-h2"
173 href="<?php echo esc_url(get_admin_url(get_current_blog_id(), 'admin.php?page=autowp_automaticPost')); ?>"><?php esc_html_e('Back to List', 'autowp'); ?></a>
174 </h2>
175
176
177 <?php if (!empty($notice)): ?>
178 <div id="notice" class="error"><p><?php echo esc_html($notice) ?></p></div>
179 <?php endif;?>
180 <?php if (!empty($message)): ?>
181 <div id="message" class="updated"><p><?php echo esc_html($message) ?></p></div>
182 <?php endif;?>
183
184 <form id="form" method="POST">
185 <input type="hidden" name="nonce" value="<?php echo esc_attr(wp_create_nonce(basename(__FILE__))); ?>"/>
186
187
188 <input type="hidden" name="id" value="<?php echo esc_html($item['id']) ?>"/>
189
190 <div class="metabox-holder" id="poststuff">
191 <div id="post-body">
192 <div id="post-body-content">
193
194 <?php do_meta_boxes('add_new_rss_website_form', 'normal', $item); ?>
195 <input type="submit" value="<?php esc_attr_e('Save', 'autowp')?>" id="submit" class="button-primary" name="submit">
196 </div>
197 </div>
198 </div>
199 </form>
200 </div>
201 <?php
202 }
203
204
205
206 function autowp_rss_websites_form_meta_box_handler($item){
207
208 // Parsing the example content_prompt
209 $parsed_values = autowp_parse_rewriting_prompt_code($item['content_prompt']) ?? '';
210
211
212 $promptcode_language = $parsed_values['language'] ?? '';
213 $promptcode_subtitle = $parsed_values['subtitle'] ?? '';
214 $promptcode_narration = $parsed_values['narration'] ?? '';
215
216
217 ?>
218 <tbody >
219 <form>
220 <meta name="viewport" content="width=device-width, initial-scale=1.0">
221 <div class="container">
222 <form class="row g-3">
223 <h4 style="font-weight: bold;">General Settings</h4>
224
225 <div class="col-md-6">
226 <label for="website_name" class="form-label">Website Name:</label>
227 <?php
228 $autowp_admin_email = autowp_get_admin_email();
229 $autowp_domain_name = esc_url(get_site_url());
230
231 echo '<input type="hidden" id="autowp_admin_email" value="' . esc_attr($autowp_admin_email) . '">';
232 echo '<input type="hidden" id="autowp_domain_name" value="' . esc_attr($autowp_domain_name) . '">';
233 ?>
234
235 <input id="website_name" name="website_name" type="text" value="<?php echo esc_attr($item['website_name']) ?>" class="form-control" required>
236 </div>
237 <div class="col-md-6">
238 <label for="domain_name" class="form-label">RSS Feed URL:</label>
239 <input id="domain_name" name="domain_name" type="text" value="<?php echo esc_attr($item['domain_name']) ?>" class="form-control" required>
240 <p class="form-text"><?php esc_html_e('E.g https://kelimelerbenim.com/feed', 'autowp'); ?></p>
241 </div>
242 <div class="col-md-6">
243 <label class="form-label" for="author_selection"><?php esc_html_e('Author Selection', 'autowp'); ?></label>
244 <select name="author_selection" class="form-select">
245 <?php
246 $authors = get_users();
247
248 foreach ($authors as $author) {
249 $author_id = $author->ID;
250 $author_name = $author->display_name;
251 $author_description = get_the_author_meta('description', $author_id);
252
253 if ($item['author_selection'] === strval($author_id)) {
254 echo '<option value="' . esc_attr($author_id) . '" selected>' . esc_html($author_name) . '</option>';
255 continue;
256 }
257
258 echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>';
259 }
260 ?>
261 </select>
262 <p class="form-text"><?php esc_html_e('Select an author from the list.', 'autowp'); ?></p>
263 </div>
264 <div class="col-md-6">
265 <label for="category_id" class="form-label">Categories:</label>
266 <select id="category_id" name="category_id[]" class="form-select" required multiple>
267 <?php
268 $selected_categories = $item['category_id'];
269 $selected_categories = explode(',', $selected_categories);
270
271 $categories = get_categories(array(
272 'orderby' => 'name',
273 'order' => 'ASC',
274 'hide_empty' => false
275 ));
276
277 foreach ($categories as $category) {
278 if (isset($selected_categories) && in_array($category->term_id, $selected_categories)) {
279 echo '<option value="' . esc_attr($category->term_id) . '" selected>' . esc_html($category->name) . '</option>';
280 continue;
281 }
282 echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>';
283 }
284 ?>
285 </select>
286 </div>
287
288 <div class="col-md-6">
289 <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label>
290 <select name="image_generating_status" class="form-select">
291 <option value="0" <?php if ($item['image_generating_status'] === '0') {
292 echo 'selected';
293 } ?>><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option>
294 <option value="1" <?php if ($item['image_generating_status'] === '1') {
295 echo 'selected';
296 } ?>><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option>
297 <option value="2" <?php if ($item['image_generating_status'] === '2') {
298 echo 'selected';
299 } ?>><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option>
300 <option value="3" <?php if ($item['image_generating_status'] === '3') {
301 echo 'selected';
302 } ?>><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option>
303
304 <option value="4" <?php if ($item['image_generating_status'] === '4') {
305 echo 'selected';
306 } ?>><?php esc_html_e('GPT Image 2', 'autowp'); ?></option>
307
308 <option value="5" <?php if ($item['image_generating_status'] === '5') {
309 echo 'selected';
310 } ?>><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option>
311
312 <option value="6" <?php if ($item['image_generating_status'] === '6') {
313 echo 'selected';
314 } ?>><?php esc_html_e('Default Image', 'autowp'); ?></option>
315
316 <option value="7" <?php if ($item['image_generating_status'] === '7') {
317 echo 'selected';
318 } ?>><?php esc_html_e('No Image', 'autowp'); ?></option>
319
320
321
322
323 </select>
324 <p class="form-text"><?php esc_html_e('By default No Image is selected. Use DuckDuckGo Search to find images in the internet.', 'autowp'); ?></p>
325 </div>
326
327
328 <div class="col-md-6">
329 <label for="post_order" class="form-label">Post Order:</label>
330 <select id="post_order" name="post_order" class="form-select">
331 <option value="desc" <?php if ($item['post_order'] === 'desc') {
332 echo 'selected';
333 } ?>>Latest First</option>
334 <option value="asc" <?php if ($item['post_order'] === 'asc') {
335 echo 'selected';
336 } ?>>Oldest First</option>
337 <option value="rand" <?php if ($item['post_order'] === 'rand') {
338 echo 'selected';
339 } ?>>Random</option>
340 </select>
341 </div>
342
343
344 <br>
345 <h4 style="font-weight: bold;">Post Settings</h4>
346 <br>
347 <div class="col-md-6">
348 <label for="languageSelect" class="form-label">Post Language:</label>
349 <select class="form-select" id="languageSelect" name="languageSelect">
350 <?php
351 $languages = [
352 "Afrikaans",
353 "Albanian",
354 "Arabic",
355 "Armenian",
356 "Basque",
357 "Bengali",
358 "Bulgarian",
359 "Catalan",
360 "Cambodian",
361 "Chinese (Mandarin)",
362 "Croatian",
363 "Czech",
364 "Danish",
365 "Dutch",
366 "English",
367 "Estonian",
368 "Fiji",
369 "Finnish",
370 "French",
371 "Georgian",
372 "German",
373 "Greek",
374 "Gujarati",
375 "Hebrew",
376 "Hindi",
377 "Hungarian",
378 "Icelandic",
379 "Indonesian",
380 "Irish",
381 "Italian",
382 "Japanese",
383 "Javanese",
384 "Korean",
385 "Latin",
386 "Latvian",
387 "Lithuanian",
388 "Macedonian",
389 "Malay",
390 "Malayalam",
391 "Maltese",
392 "Maori",
393 "Marathi",
394 "Mongolian",
395 "Nepali",
396 "Norwegian",
397 "Persian",
398 "Polish",
399 "Portuguese",
400 "Punjabi",
401 "Quechua",
402 "Romanian",
403 "Russian",
404 "Samoan",
405 "Serbian",
406 "Slovak",
407 "Slovenian",
408 "Spanish",
409 "Swahili",
410 "Swedish",
411 "Tamil",
412 "Tatar",
413 "Telugu",
414 "Thai",
415 "Tibetan",
416 "Tonga",
417 "Turkish",
418 "Ukrainian",
419 "Urdu",
420 "Uzbek",
421 "Vietnamese",
422 "Welsh",
423 "Xhosa"
424 ];
425 ?>
426
427
428 <?php foreach ($languages as $language): ?>
429 <option value="<?php echo esc_attr($language); ?>" <?php echo ($language === $promptcode_language) ? 'selected' : ''; ?>>
430 <?php echo esc_html($language); ?>
431 </option>
432 <?php endforeach; ?>
433
434
435 </select>
436 </div>
437 <br>
438 <div class="col-md-6">
439 <label for="subtitleSelect" class="form-label">Subheading Count:</label>
440 <select class="form-select" id="subtitleSelect" name="subtitleSelect">
441 <?php
442 for ($i = 1; $i <= 10; $i++) {
443 $selected = ($promptcode_subtitle == strval($i)) ? 'selected' : '';
444 echo "<option value='" . esc_attr($i) . "' " . esc_attr($selected) . ">" . esc_html($i) . "</option>";
445
446 }
447 ?>
448 </select>
449 </div>
450 <br>
451 <div class="col-md-6">
452 <label for="narrationSelect" class="form-label">Writing Style:</label>
453 <select class="form-select" id="narrationSelect" name="narrationSelect">
454 <?php
455 $is_inactive = (isset($item['active']) && $item['active'] === '0');
456 $styles = [
457 "Descriptive" => "Descriptive",
458 "Narrative" => "Narrative",
459 "Explanatory" => "Explanatory",
460 "Argumentative" => "Argumentative",
461 "Comparative" => "Comparative",
462 "Process Analysis" => "Process Analysis",
463 "Allegorical" => "Allegorical",
464 "Chronological" => "Chronological",
465 "Ironic" => "Ironic",
466 "ConsistencyAndRepetition" => "Consistency and Repetition",
467 "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression",
468 "InternalMonologue" => "Internal Monologue",
469 "Dialogical" => "Dialogical"
470 ];
471 foreach ($styles as $value => $name) {
472 $selected = ($promptcode_narration == $value) ? 'selected' : '';
473 echo "<option value='" . esc_attr($value) . "' " . esc_attr($selected) . ">" . esc_html($name) . "</option>";
474
475 }
476 ?>
477
478 </select>
479
480 </div>
481
482 <br>
483 <h4 style="font-weight: bold;">Source Status</h4>
484
485
486 <!-- Status Field (Active/Inactive) -->
487 <div class="col-md-6">
488 <label for="active" class="form-label">Status:</label>
489
490
491 <select id="active" name="active" class="form-select">
492 <option value="1" <?php echo (!$is_inactive) ? 'selected' : ''; ?>>
493 Active
494 </option>
495 <option value="0" <?php echo ($is_inactive) ? 'selected' : ''; ?>>
496 Inactive
497 </option>
498 </select>
499
500 <p>
501 When the cron job is triggered, any task marked as "Active" will be executed.
502 If you select "Inactive," this task will be skipped, and the cron job will move
503 on to the remaining active tasks. This makes it easy to enable or disable tasks
504 without removing them entirely.
505 </p>
506 </div>
507
508
509 <br>
510 </form>
511
512 </div>
513
514
515
516
517
518
519 </form>
520
521
522 </tbody>
523 <?php
524 }
525
526 ?>
527