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-news-website-form.php
944 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | function autowp_news_website_form_page_handler(){ |
| 5 | // News website form content and handling |
| 6 | global $wpdb; |
| 7 | $table_name = $wpdb->prefix . 'autowp_wordpress_websites'; |
| 8 | |
| 9 | $message = ''; |
| 10 | $notice = ''; |
| 11 | |
| 12 | |
| 13 | $default = array( |
| 14 | 'id' => 0, |
| 15 | 'domain_name' => '', |
| 16 | 'website_name' => '', |
| 17 | 'website_type' => '', |
| 18 | 'category_id' => '', |
| 19 | |
| 20 | 'aigenerated_title' => '', |
| 21 | 'aigenerated_content' => '', |
| 22 | 'aigenerated_tags' => '', |
| 23 | 'aigenerated_image' => '', |
| 24 | |
| 25 | 'title_prompt' => '', |
| 26 | 'content_prompt' => '', |
| 27 | 'tags_prompt' => '', |
| 28 | 'image_prompt' => '', |
| 29 | |
| 30 | 'image_generating_status' => '', |
| 31 | 'author_selection' => '', |
| 32 | 'post_count' => '', |
| 33 | 'post_order' => '', |
| 34 | |
| 35 | 'news_keyword' => '', // New field for News website |
| 36 | 'news_country' => '', // New field for News website |
| 37 | 'news_language' => '', // New field for News website |
| 38 | 'news_time_published' => '', // New field for News website |
| 39 | 'active' => '', |
| 40 | |
| 41 | ); |
| 42 | |
| 43 | |
| 44 | if ( isset($_REQUEST['nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['nonce'])), basename(__FILE__))) { |
| 45 | |
| 46 | |
| 47 | |
| 48 | // Only retrieve the specific values needed |
| 49 | $item = array( |
| 50 | 'id' => isset($_POST['id']) ? intval($_POST['id']) : 0, |
| 51 | 'website_name' => sanitize_text_field($_POST['website_name']), |
| 52 | 'category_id' => isset($_POST['category_id']) ? array_map('intval', $_POST['category_id']) : array(), |
| 53 | |
| 54 | 'title_prompt' => sanitize_textarea_field($_POST['title_prompt']), |
| 55 | 'tags_prompt' => sanitize_textarea_field($_POST['tags_prompt']), |
| 56 | 'image_prompt' => sanitize_textarea_field($_POST['image_prompt']), |
| 57 | |
| 58 | 'content_prompt' => '[autowp-rewriting-promptcode]' . |
| 59 | sanitize_text_field($_POST['languageSelect']) . ',' . |
| 60 | sanitize_text_field($_POST['subtitleSelect']) . ',' . |
| 61 | sanitize_text_field($_POST['narrationSelect']) . |
| 62 | '[/autowp-rewriting-promptcode]', |
| 63 | |
| 64 | |
| 65 | 'website_type' => 'news', |
| 66 | |
| 67 | 'image_generating_status' => sanitize_text_field($_POST['image_generating_status']), |
| 68 | 'author_selection' => sanitize_text_field($_POST['author_selection']), |
| 69 | 'domain_name' => sanitize_url($_POST['domain_name']), |
| 70 | 'post_count' => 5, |
| 71 | 'post_order' => sanitize_text_field($_POST['post_order']), |
| 72 | |
| 73 | 'aigenerated_title' => '1', |
| 74 | 'aigenerated_content' => '1', |
| 75 | 'aigenerated_tags' => '1', |
| 76 | 'aigenerated_image' => '1', |
| 77 | |
| 78 | |
| 79 | 'news_keyword' => sanitize_text_field($_POST['news_keyword']), // New field for News website |
| 80 | 'news_country' => sanitize_text_field($_POST['news_country']), // New field for News website |
| 81 | 'news_language' => sanitize_text_field($_POST['news_language']), // New field for News website |
| 82 | 'news_time_published' => sanitize_text_field($_POST['news_time_published']), // New field for News website |
| 83 | 'active' => sanitize_text_field(($_POST['active'])) |
| 84 | ); |
| 85 | |
| 86 | |
| 87 | // Convert category_id array to text |
| 88 | $category_ids = implode(",", $item['category_id']); |
| 89 | $item['category_id'] = $category_ids; |
| 90 | |
| 91 | |
| 92 | |
| 93 | if ($item['aigenerated_title'] !== '1'){ |
| 94 | $item['aigenerated_title'] = '0'; |
| 95 | } |
| 96 | |
| 97 | if($item['aigenerated_content'] !== '1'){ |
| 98 | $item['aigenerated_content'] = '0'; |
| 99 | } |
| 100 | |
| 101 | if($item['aigenerated_tags'] !== '1'){ |
| 102 | $item['aigenerated_tags'] = '0'; |
| 103 | } |
| 104 | |
| 105 | if($item['aigenerated_image'] !== '1'){ |
| 106 | $item['aigenerated_image'] = '0'; |
| 107 | } |
| 108 | |
| 109 | |
| 110 | $item['website_type'] = 'news'; |
| 111 | |
| 112 | // Set WP-CRON |
| 113 | |
| 114 | $settings = unserialize(get_option('autowp_settings')); |
| 115 | |
| 116 | $wpcron_status = $settings['wpcron_status']; |
| 117 | |
| 118 | if(!isset($wpcron_status)){ |
| 119 | autowp_update_wp_cron_status('1'); |
| 120 | } |
| 121 | |
| 122 | $time_value_type = $settings['selected_time_type']; |
| 123 | |
| 124 | $user_wpcron_time = autowp_get_wpcron_time($time_value_type); |
| 125 | |
| 126 | $next_two_minutes = time() + 2 * 60; |
| 127 | |
| 128 | // Schedule WP-Cron |
| 129 | if (!wp_next_scheduled('autowp_cron')) { |
| 130 | wp_schedule_event($next_two_minutes, $user_wpcron_time, 'autowp_cron'); |
| 131 | |
| 132 | } else { |
| 133 | wp_clear_scheduled_hook('autowp_cron'); |
| 134 | wp_schedule_event($next_two_minutes, $user_wpcron_time, 'autowp_cron'); |
| 135 | } |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | $item_valid = autowp_validate_website($item); |
| 142 | if ($item_valid === true) { |
| 143 | if ($item['id'] == 0) { |
| 144 | $result = $wpdb->insert($table_name, $item); |
| 145 | $item['id'] = $wpdb->insert_id; |
| 146 | if ($result) { |
| 147 | $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'); |
| 148 | } else { |
| 149 | $notice = __('There was an error while saving item', 'autowp'); |
| 150 | } |
| 151 | } else { |
| 152 | $result = $wpdb->update($table_name, $item, array('id' => $item['id'])); |
| 153 | if ($result) { |
| 154 | $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'); |
| 155 | } else { |
| 156 | $notice = __('There was an error while updating item', 'autowp'); |
| 157 | } |
| 158 | } |
| 159 | } else { |
| 160 | |
| 161 | $notice = $item_valid; |
| 162 | } |
| 163 | } |
| 164 | else { |
| 165 | |
| 166 | $item = $default; |
| 167 | $sanitized_id = absint($_REQUEST['id']); |
| 168 | if (isset($_REQUEST['id'])) { |
| 169 | $item = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE id = %d", $sanitized_id), ARRAY_A); |
| 170 | if (!$item) { |
| 171 | $item = $default; |
| 172 | $notice = __('Item not found', 'autowp'); |
| 173 | } |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | |
| 178 | add_meta_box('websites_form_meta_box', __('Form', 'autowp'), 'autowp_news_websites_form_meta_box_handler', 'add_new_news_website_form', 'normal', 'default'); |
| 179 | |
| 180 | ?> |
| 181 | <div class="wrap"> |
| 182 | <div class="icon32 icon32-posts-post" id="icon-edit"><br></div> |
| 183 | <h2><?php esc_html_e('Add New', 'autowp'); ?> <a class="add-new-h2" |
| 184 | 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> |
| 185 | </h2> |
| 186 | |
| 187 | |
| 188 | <?php if (!empty($notice)): ?> |
| 189 | <div id="notice" class="error"><p><?php echo esc_html($notice) ?></p></div> |
| 190 | <?php endif;?> |
| 191 | <?php if (!empty($message)): ?> |
| 192 | <div id="message" class="updated"><p><?php echo esc_html($message) ?></p></div> |
| 193 | <?php endif;?> |
| 194 | |
| 195 | <form id="form" method="POST"> |
| 196 | <input type="hidden" name="nonce" value="<?php echo esc_attr(wp_create_nonce(basename(__FILE__))); ?>"/> |
| 197 | |
| 198 | |
| 199 | <input type="hidden" name="id" value="<?php echo esc_html($item['id']) ?>"/> |
| 200 | |
| 201 | <div class="metabox-holder" id="poststuff"> |
| 202 | <div id="post-body"> |
| 203 | <div id="post-body-content"> |
| 204 | |
| 205 | <?php do_meta_boxes('add_new_news_website_form', 'normal', $item); ?> |
| 206 | <input type="submit" value="<?php esc_attr_e('Save', 'autowp')?>" id="submit" class="button-primary" name="submit"> |
| 207 | </div> |
| 208 | </div> |
| 209 | </div> |
| 210 | </form> |
| 211 | </div> |
| 212 | <?php |
| 213 | } |
| 214 | |
| 215 | function autowp_news_websites_form_meta_box_handler($item){ |
| 216 | |
| 217 | // Parsing the example content_prompt |
| 218 | $parsed_values = autowp_parse_rewriting_prompt_code($item['content_prompt']) ?? ''; |
| 219 | |
| 220 | |
| 221 | $promptcode_language = $parsed_values['language'] ?? ''; |
| 222 | $promptcode_subtitle = $parsed_values['subtitle'] ?? ''; |
| 223 | $promptcode_narration = $parsed_values['narration'] ?? ''; |
| 224 | |
| 225 | |
| 226 | |
| 227 | ?> |
| 228 | <tbody > |
| 229 | <form method="post"> |
| 230 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 231 | <div class="container"> |
| 232 | <form class="row g-3"> |
| 233 | <h4 style="font-weight: bold;">General Settings</h4> |
| 234 | |
| 235 | <div class="col-md-6"> |
| 236 | <label for="website_name" class="form-label">Name:</label> |
| 237 | <input id="website_name" name="website_name" type="text" value="<?php echo esc_attr($item['website_name']) ?>" class="form-control" required> |
| 238 | </div> |
| 239 | <div class="col-md-6"> |
| 240 | <label class="form-label" for="author_selection">Author Selection:</label> |
| 241 | <select name="author_selection" id="author_selection" class="form-select"> |
| 242 | <?php |
| 243 | $authors = get_users(); |
| 244 | |
| 245 | foreach ($authors as $author) { |
| 246 | $author_id = $author->ID; |
| 247 | $author_name = $author->display_name; |
| 248 | |
| 249 | |
| 250 | if ($item['author_selection'] === strval($author_id)) { |
| 251 | echo '<option value="' . esc_attr($author_id) . '" selected>' . esc_html($author_name) . '</option>'; |
| 252 | continue; |
| 253 | } |
| 254 | |
| 255 | echo '<option value="' . esc_attr($author_id) . '">' . esc_html($author_name) . '</option>'; |
| 256 | } |
| 257 | ?> |
| 258 | </select> |
| 259 | </div> |
| 260 | |
| 261 | <div class="col-md-6"> |
| 262 | <label for="category_id" class="form-label">Categories:</label> |
| 263 | <select id="category_id" name="category_id[]" class="form-select" required multiple> |
| 264 | <?php |
| 265 | $selected_categories = $item['category_id']; |
| 266 | $selected_categories = explode(',', $selected_categories); |
| 267 | |
| 268 | $categories = get_categories(array( |
| 269 | 'orderby' => 'name', |
| 270 | 'order' => 'ASC', |
| 271 | 'hide_empty' => false |
| 272 | )); |
| 273 | |
| 274 | foreach ($categories as $category) { |
| 275 | if (isset($selected_categories) && in_array($category->term_id, $selected_categories)) { |
| 276 | echo '<option value="' . esc_attr($category->term_id) . '" selected>' . esc_html($category->name) . '</option>'; |
| 277 | continue; |
| 278 | } |
| 279 | echo '<option value="' . esc_attr($category->term_id) . '">' . esc_html($category->name) . '</option>'; |
| 280 | } |
| 281 | ?> |
| 282 | </select> |
| 283 | </div> |
| 284 | |
| 285 | <div class="col-md-6"> |
| 286 | <label for="news_keyword" class="form-label">Keyword:</label> |
| 287 | <input id="news_keyword" name="news_keyword" type="text" value="<?php echo esc_attr($item['news_keyword']) ?>" class="form-control"> |
| 288 | </div> |
| 289 | |
| 290 | <div class="col-md-6"> |
| 291 | <label class="form-label" for="news_country">News Country:</label> |
| 292 | <select name="news_country" class="form-select"> |
| 293 | <!-- ISO 3166-1 alpha-2 country codes --> |
| 294 | <!-- Replace with actual country codes and names --> |
| 295 | <?php |
| 296 | $countries = [ |
| 297 | 'any' => 'Anywhere', |
| 298 | 'AF' => 'Afghanistan', |
| 299 | 'AX' => '� |
| 300 | land Islands', |
| 301 | 'AL' => 'Albania', |
| 302 | 'DZ' => 'Algeria', |
| 303 | 'AS' => 'American Samoa', |
| 304 | 'AD' => 'Andorra', |
| 305 | 'AO' => 'Angola', |
| 306 | 'AI' => 'Anguilla', |
| 307 | 'AQ' => 'Antarctica', |
| 308 | 'AG' => 'Antigua and Barbuda', |
| 309 | 'AR' => 'Argentina', |
| 310 | 'AM' => 'Armenia', |
| 311 | 'AW' => 'Aruba', |
| 312 | 'AU' => 'Australia', |
| 313 | 'AT' => 'Austria', |
| 314 | 'AZ' => 'Azerbaijan', |
| 315 | 'BS' => 'Bahamas', |
| 316 | 'BH' => 'Bahrain', |
| 317 | 'BD' => 'Bangladesh', |
| 318 | 'BB' => 'Barbados', |
| 319 | 'BY' => 'Belarus', |
| 320 | 'BE' => 'Belgium', |
| 321 | 'BZ' => 'Belize', |
| 322 | 'BJ' => 'Benin', |
| 323 | 'BM' => 'Bermuda', |
| 324 | 'BT' => 'Bhutan', |
| 325 | 'BO' => 'Bolivia, Plurinational State of', |
| 326 | 'BQ' => 'Bonaire, Sint Eustatius and Saba', |
| 327 | 'BA' => 'Bosnia and Herzegovina', |
| 328 | 'BW' => 'Botswana', |
| 329 | 'BV' => 'Bouvet Island', |
| 330 | 'BR' => 'Brazil', |
| 331 | 'IO' => 'British Indian Ocean Territory', |
| 332 | 'BN' => 'Brunei Darussalam', |
| 333 | 'BG' => 'Bulgaria', |
| 334 | 'BF' => 'Burkina Faso', |
| 335 | 'BI' => 'Burundi', |
| 336 | 'KH' => 'Cambodia', |
| 337 | 'CM' => 'Cameroon', |
| 338 | 'CA' => 'Canada', |
| 339 | 'CV' => 'Cape Verde', |
| 340 | 'KY' => 'Cayman Islands', |
| 341 | 'CF' => 'Central African Republic', |
| 342 | 'TD' => 'Chad', |
| 343 | 'CL' => 'Chile', |
| 344 | 'CN' => 'China', |
| 345 | 'CX' => 'Christmas Island', |
| 346 | 'CC' => 'Cocos (Keeling) Islands', |
| 347 | 'CO' => 'Colombia', |
| 348 | 'KM' => 'Comoros', |
| 349 | 'CG' => 'Congo', |
| 350 | 'CD' => 'Congo, the Democratic Republic of the', |
| 351 | 'CK' => 'Cook Islands', |
| 352 | 'CR' => 'Costa Rica', |
| 353 | 'CI' => "Côte d'Ivoire", |
| 354 | 'HR' => 'Croatia', |
| 355 | 'CU' => 'Cuba', |
| 356 | 'CW' => 'Curaçao', |
| 357 | 'CY' => 'Cyprus', |
| 358 | 'CZ' => 'Czech Republic', |
| 359 | 'DK' => 'Denmark', |
| 360 | 'DJ' => 'Djibouti', |
| 361 | 'DM' => 'Dominica', |
| 362 | 'DO' => 'Dominican Republic', |
| 363 | 'EC' => 'Ecuador', |
| 364 | 'EG' => 'Egypt', |
| 365 | 'SV' => 'El Salvador', |
| 366 | 'GQ' => 'Equatorial Guinea', |
| 367 | 'ER' => 'Eritrea', |
| 368 | 'EE' => 'Estonia', |
| 369 | 'ET' => 'Ethiopia', |
| 370 | 'FK' => 'Falkland Islands (Malvinas)', |
| 371 | 'FO' => 'Faroe Islands', |
| 372 | 'FJ' => 'Fiji', |
| 373 | 'FI' => 'Finland', |
| 374 | 'FR' => 'France', |
| 375 | 'GF' => 'French Guiana', |
| 376 | 'PF' => 'French Polynesia', |
| 377 | 'TF' => 'French Southern Territories', |
| 378 | 'GA' => 'Gabon', |
| 379 | 'GM' => 'Gambia', |
| 380 | 'GE' => 'Georgia', |
| 381 | 'DE' => 'Germany', |
| 382 | 'GH' => 'Ghana', |
| 383 | 'GI' => 'Gibraltar', |
| 384 | 'GR' => 'Greece', |
| 385 | 'GL' => 'Greenland', |
| 386 | 'GD' => 'Grenada', |
| 387 | 'GP' => 'Guadeloupe', |
| 388 | 'GU' => 'Guam', |
| 389 | 'GT' => 'Guatemala', |
| 390 | 'GG' => 'Guernsey', |
| 391 | 'GN' => 'Guinea', |
| 392 | 'GW' => 'Guinea-Bissau', |
| 393 | 'GY' => 'Guyana', |
| 394 | 'HT' => 'Haiti', |
| 395 | 'HM' => 'Heard Island and McDonald Islands', |
| 396 | 'VA' => 'Holy See (Vatican City State)', |
| 397 | 'HN' => 'Honduras', |
| 398 | 'HK' => 'Hong Kong', |
| 399 | 'HU' => 'Hungary', |
| 400 | 'IS' => 'Iceland', |
| 401 | 'IN' => 'India', |
| 402 | 'ID' => 'Indonesia', |
| 403 | 'IR' => 'Iran, Islamic Republic of', |
| 404 | 'IQ' => 'Iraq', |
| 405 | 'IE' => 'Ireland', |
| 406 | 'IM' => 'Isle of Man', |
| 407 | 'IL' => 'Israel', |
| 408 | 'IT' => 'Italy', |
| 409 | 'JM' => 'Jamaica', |
| 410 | 'JP' => 'Japan', |
| 411 | 'JE' => 'Jersey', |
| 412 | 'JO' => 'Jordan', |
| 413 | 'KZ' => 'Kazakhstan', |
| 414 | 'KE' => 'Kenya', |
| 415 | 'KI' => 'Kiribati', |
| 416 | 'KP' => "Korea, Democratic People's Republic of", |
| 417 | 'KR' => 'Korea, Republic of', |
| 418 | 'KW' => 'Kuwait', |
| 419 | 'KG' => 'Kyrgyzstan', |
| 420 | 'LA' => "Lao People's Democratic Republic", |
| 421 | 'LV' => 'Latvia', |
| 422 | 'LB' => 'Lebanon', |
| 423 | 'LS' => 'Lesotho', |
| 424 | 'LR' => 'Liberia', |
| 425 | 'LY' => 'Libya', |
| 426 | 'LI' => 'Liechtenstein', |
| 427 | 'LT' => 'Lithuania', |
| 428 | 'LU' => 'Luxembourg', |
| 429 | 'MO' => 'Macao', |
| 430 | 'MK' => 'Macedonia, The Former Yugoslav Republic of', |
| 431 | 'MG' => 'Madagascar', |
| 432 | 'MW' => 'Malawi', |
| 433 | 'MY' => 'Malaysia', |
| 434 | 'MV' => 'Maldives', |
| 435 | 'ML' => 'Mali', |
| 436 | 'MT' => 'Malta', |
| 437 | 'MH' => 'Marshall Islands', |
| 438 | 'MQ' => 'Martinique', |
| 439 | 'MR' => 'Mauritania', |
| 440 | 'MU' => 'Mauritius', |
| 441 | 'YT' => 'Mayotte', |
| 442 | 'MX' => 'Mexico', |
| 443 | 'FM' => 'Micronesia, Federated States of', |
| 444 | 'MD' => 'Moldova, Republic of', |
| 445 | 'MC' => 'Monaco', |
| 446 | 'MN' => 'Mongolia', |
| 447 | 'ME' => 'Montenegro', |
| 448 | 'MS' => 'Montserrat', |
| 449 | 'MA' => 'Morocco', |
| 450 | 'MZ' => 'Mozambique', |
| 451 | 'MM' => 'Myanmar', |
| 452 | 'NA' => 'Namibia', |
| 453 | 'NR' => 'Nauru', |
| 454 | 'NP' => 'Nepal', |
| 455 | 'NL' => 'Netherlands', |
| 456 | 'NC' => 'New Caledonia', |
| 457 | 'NZ' => 'New Zealand', |
| 458 | 'NI' => 'Nicaragua', |
| 459 | 'NE' => 'Niger', |
| 460 | 'NG' => 'Nigeria', |
| 461 | 'NU' => 'Niue', |
| 462 | 'NF' => 'Norfolk Island', |
| 463 | 'MP' => 'Northern Mariana Islands', |
| 464 | 'NO' => 'Norway', |
| 465 | 'OM' => 'Oman', |
| 466 | 'PK' => 'Pakistan', |
| 467 | 'PW' => 'Palau', |
| 468 | 'PS' => 'Palestinian Territory, Occupied', |
| 469 | 'PA' => 'Panama', |
| 470 | 'PG' => 'Papua New Guinea', |
| 471 | 'PY' => 'Paraguay', |
| 472 | 'PE' => 'Peru', |
| 473 | 'PH' => 'Philippines', |
| 474 | 'PN' => 'Pitcairn', |
| 475 | 'PL' => 'Poland', |
| 476 | 'PT' => 'Portugal', |
| 477 | 'PR' => 'Puerto Rico', |
| 478 | 'QA' => 'Qatar', |
| 479 | 'RE' => 'Réunion', |
| 480 | 'RO' => 'Romania', |
| 481 | 'RU' => 'Russian Federation', |
| 482 | 'RW' => 'Rwanda', |
| 483 | 'BL' => 'Saint Barthélemy', |
| 484 | 'SH' => 'Saint Helena, Ascension and Tristan da Cunha', |
| 485 | 'KN' => 'Saint Kitts and Nevis', |
| 486 | 'LC' => 'Saint Lucia', |
| 487 | 'MF' => 'Saint Martin (French part)', |
| 488 | 'PM' => 'Saint Pierre and Miquelon', |
| 489 | 'VC' => 'Saint Vincent and the Grenadines', |
| 490 | 'WS' => 'Samoa', |
| 491 | 'SM' => 'San Marino', |
| 492 | 'ST' => 'Sao Tome and Principe', |
| 493 | 'SA' => 'Saudi Arabia', |
| 494 | 'SN' => 'Senegal', |
| 495 | 'RS' => 'Serbia', |
| 496 | 'SC' => 'Seychelles', |
| 497 | 'SL' => 'Sierra Leone', |
| 498 | 'SG' => 'Singapore', |
| 499 | 'SX' => 'Sint Maarten (Dutch part)', |
| 500 | 'SK' => 'Slovakia', |
| 501 | 'SI' => 'Slovenia', |
| 502 | 'SB' => 'Solomon Islands', |
| 503 | 'SO' => 'Somalia', |
| 504 | 'ZA' => 'South Africa', |
| 505 | 'GS' => 'South Georgia and the South Sandwich Islands', |
| 506 | 'SS' => 'South Sudan', |
| 507 | 'ES' => 'Spain', |
| 508 | 'LK' => 'Sri Lanka', |
| 509 | 'SD' => 'Sudan', |
| 510 | 'SR' => 'Suriname', |
| 511 | 'SJ' => 'Svalbard and Jan Mayen', |
| 512 | 'SZ' => 'Swaziland', |
| 513 | 'SE' => 'Sweden', |
| 514 | 'CH' => 'Switzerland', |
| 515 | 'SY' => 'Syrian Arab Republic', |
| 516 | 'TW' => 'Taiwan, Province of China', |
| 517 | 'TJ' => 'Tajikistan', |
| 518 | 'TZ' => 'Tanzania, United Republic of', |
| 519 | 'TH' => 'Thailand', |
| 520 | 'TL' => 'Timor-Leste', |
| 521 | 'TG' => 'Togo', |
| 522 | 'TK' => 'Tokelau', |
| 523 | 'TO' => 'Tonga', |
| 524 | 'TT' => 'Trinidad and Tobago', |
| 525 | 'TN' => 'Tunisia', |
| 526 | 'TR' => 'Turkey', |
| 527 | 'TM' => 'Turkmenistan', |
| 528 | 'TC' => 'Turks and Caicos Islands', |
| 529 | 'TV' => 'Tuvalu', |
| 530 | 'UG' => 'Uganda', |
| 531 | 'UA' => 'Ukraine', |
| 532 | 'AE' => 'United Arab Emirates', |
| 533 | 'GB' => 'United Kingdom', |
| 534 | 'US' => 'United States', |
| 535 | 'UM' => 'United States Minor Outlying Islands', |
| 536 | 'UY' => 'Uruguay', |
| 537 | 'UZ' => 'Uzbekistan', |
| 538 | 'VU' => 'Vanuatu', |
| 539 | 'VE' => 'Venezuela, Bolivarian Republic of', |
| 540 | 'VN' => 'Viet Nam', |
| 541 | 'VG' => 'Virgin Islands, British', |
| 542 | 'VI' => 'Virgin Islands, U.S.', |
| 543 | 'WF' => 'Wallis and Futuna', |
| 544 | 'EH' => 'Western Sahara', |
| 545 | 'YE' => 'Yemen', |
| 546 | 'ZM' => 'Zambia', |
| 547 | 'ZW' => 'Zimbabwe', |
| 548 | ]; |
| 549 | |
| 550 | foreach ($countries as $code => $name) { |
| 551 | $selected = ($item['news_country'] == $code) ? 'selected' : ''; |
| 552 | echo "<option value='" . esc_attr($code) . "' " . esc_attr($selected) . ">" . esc_html($name) . "</option>"; |
| 553 | |
| 554 | } |
| 555 | ?> |
| 556 | </select> |
| 557 | </div> |
| 558 | |
| 559 | |
| 560 | <div class="col-md-6"> |
| 561 | <label class="form-label" for="news_language">Language:</label> |
| 562 | <select name="news_language" class="form-select"> |
| 563 | <!-- ISO 639-1 alpha-2 language codes --> |
| 564 | <!-- Replace with actual language codes and names --> |
| 565 | <?php |
| 566 | $languages = [ |
| 567 | 'any' => 'Any Language', |
| 568 | 'af' => 'Afrikaans', |
| 569 | 'sq' => 'Albanian', |
| 570 | 'am' => 'Amharic', |
| 571 | 'ar' => 'Arabic', |
| 572 | 'hy' => 'Armenian', |
| 573 | 'az' => 'Azerbaijani', |
| 574 | 'eu' => 'Basque', |
| 575 | 'be' => 'Belarusian', |
| 576 | 'bn' => 'Bengali', |
| 577 | 'bs' => 'Bosnian', |
| 578 | 'bg' => 'Bulgarian', |
| 579 | 'ca' => 'Catalan', |
| 580 | 'ceb' => 'Cebuano', |
| 581 | 'ny' => 'Chichewa', |
| 582 | 'zh-CN' => 'Chinese', |
| 583 | 'co' => 'Corsican', |
| 584 | 'hr' => 'Croatian', |
| 585 | 'cs' => 'Czech', |
| 586 | 'da' => 'Danish', |
| 587 | 'nl' => 'Dutch', |
| 588 | 'en' => 'English', |
| 589 | 'eo' => 'Esperanto', |
| 590 | 'et' => 'Estonian', |
| 591 | 'tl' => 'Filipino', |
| 592 | 'fi' => 'Finnish', |
| 593 | 'fr' => 'French', |
| 594 | 'fy' => 'Frisian', |
| 595 | 'gl' => 'Galician', |
| 596 | 'ka' => 'Georgian', |
| 597 | 'de' => 'German', |
| 598 | 'el' => 'Greek', |
| 599 | 'gu' => 'Gujarati', |
| 600 | 'ht' => 'Haitian Creole', |
| 601 | 'ha' => 'Hausa', |
| 602 | 'haw' => 'Hawaiian', |
| 603 | 'iw' => 'Hebrew', |
| 604 | 'hi' => 'Hindi', |
| 605 | 'hmn' => 'Hmong', |
| 606 | 'hu' => 'Hungarian', |
| 607 | 'is' => 'Icelandic', |
| 608 | 'ig' => 'Igbo', |
| 609 | 'id' => 'Indonesian', |
| 610 | 'ga' => 'Irish', |
| 611 | 'it' => 'Italian', |
| 612 | 'ja' => 'Japanese', |
| 613 | 'jw' => 'Javanese', |
| 614 | 'kn' => 'Kannada', |
| 615 | 'kk' => 'Kazakh', |
| 616 | 'km' => 'Khmer', |
| 617 | 'ko' => 'Korean', |
| 618 | 'ku' => 'Kurdish (Kurmanji)', |
| 619 | 'ky' => 'Kyrgyz', |
| 620 | 'lo' => 'Lao', |
| 621 | 'la' => 'Latin', |
| 622 | 'lv' => 'Latvian', |
| 623 | 'lt' => 'Lithuanian', |
| 624 | 'lb' => 'Luxembourgish', |
| 625 | 'mk' => 'Macedonian', |
| 626 | 'mg' => 'Malagasy', |
| 627 | 'ms' => 'Malay', |
| 628 | 'ml' => 'Malayalam', |
| 629 | 'mt' => 'Maltese', |
| 630 | 'mi' => 'Maori', |
| 631 | 'mr' => 'Marathi', |
| 632 | 'mn' => 'Mongolian', |
| 633 | 'my' => 'Myanmar (Burmese)', |
| 634 | 'ne' => 'Nepali', |
| 635 | 'no' => 'Norwegian', |
| 636 | 'ps' => 'Pashto', |
| 637 | 'fa' => 'Persian', |
| 638 | 'pl' => 'Polish', |
| 639 | 'pt' => 'Portuguese', |
| 640 | 'pa' => 'Punjabi', |
| 641 | 'ro' => 'Romanian', |
| 642 | 'ru' => 'Russian', |
| 643 | 'sm' => 'Samoan', |
| 644 | 'gd' => 'Scots Gaelic', |
| 645 | 'sr' => 'Serbian', |
| 646 | 'st' => 'Sesotho', |
| 647 | 'sn' => 'Shona', |
| 648 | 'sd' => 'Sindhi', |
| 649 | 'si' => 'Sinhala', |
| 650 | 'sk' => 'Slovak', |
| 651 | 'sl' => 'Slovenian', |
| 652 | 'so' => 'Somali', |
| 653 | 'es' => 'Spanish', |
| 654 | 'su' => 'Sundanese', |
| 655 | 'sw' => 'Swahili', |
| 656 | 'sv' => 'Swedish', |
| 657 | 'tg' => 'Tajik', |
| 658 | 'ta' => 'Tamil', |
| 659 | 'te' => 'Telugu', |
| 660 | 'th' => 'Thai', |
| 661 | 'tr' => 'Turkish', |
| 662 | 'uk' => 'Ukrainian', |
| 663 | 'ur' => 'Urdu', |
| 664 | 'uz' => 'Uzbek', |
| 665 | 'vi' => 'Vietnamese', |
| 666 | 'cy' => 'Welsh', |
| 667 | 'xh' => 'Xhosa', |
| 668 | 'yi' => 'Yiddish', |
| 669 | 'yo' => 'Yoruba', |
| 670 | 'zu' => 'Zulu', |
| 671 | ]; |
| 672 | |
| 673 | foreach ($languages as $code => $name) { |
| 674 | $selected = ($item['news_language'] == $code) ? 'selected' : ''; |
| 675 | echo "<option value='" . esc_attr($code) . "' " . esc_attr($selected) . ">" . esc_html($name) . "</option>"; |
| 676 | |
| 677 | } |
| 678 | ?> |
| 679 | </select> |
| 680 | </div> |
| 681 | |
| 682 | <div class="col-md-6"> |
| 683 | <label class="form-label" for="news_time_published">Time Published:</label> |
| 684 | <select name="news_time_published" class="form-select"> |
| 685 | <?php |
| 686 | $time_options = [ |
| 687 | 'anytime' => 'Anytime', |
| 688 | '1h' => 'Last Hour', |
| 689 | '1d' => 'Last Day', |
| 690 | '7d' => 'Last 7 Days', |
| 691 | '1y' => 'Last Year', |
| 692 | ]; |
| 693 | |
| 694 | foreach ($time_options as $value => $label) { |
| 695 | $selected = ($item['news_time_published'] == $value) ? 'selected' : ''; |
| 696 | echo "<option value='" . esc_attr($value) . "' " . esc_attr($selected) . ">" . esc_html($label) . "</option>"; |
| 697 | |
| 698 | |
| 699 | } |
| 700 | ?> |
| 701 | </select> |
| 702 | </div> |
| 703 | |
| 704 | |
| 705 | <div class="col-md-6"> |
| 706 | <label for="domain_name" class="form-label">Source URL (optional):</label> |
| 707 | <input id="domain_name" name="domain_name" type="text" value="<?php echo esc_attr($item['domain_name']) ?>" class="form-control"> |
| 708 | </div> |
| 709 | <br> |
| 710 | <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> |
| 711 | |
| 712 | |
| 713 | <div class="col-md-6"> |
| 714 | <label class="form-label" for="image_generating_status"><?php esc_html_e('Image Generating Method', 'autowp'); ?></label> |
| 715 | <select name="image_generating_status" class="form-select"> |
| 716 | <option value="0" <?php if ($item['image_generating_status'] === '0') { |
| 717 | echo 'selected'; |
| 718 | } ?>><?php esc_html_e('FLUX Realism LoRA', 'autowp'); ?></option> |
| 719 | <option value="1" <?php if ($item['image_generating_status'] === '1') { |
| 720 | echo 'selected'; |
| 721 | } ?>><?php esc_html_e('Stable Diffusion Ultra', 'autowp'); ?></option> |
| 722 | <option value="2" <?php if ($item['image_generating_status'] === '2') { |
| 723 | echo 'selected'; |
| 724 | } ?>><?php esc_html_e('Stable Diffusion Core', 'autowp'); ?></option> |
| 725 | <option value="3" <?php if ($item['image_generating_status'] === '3') { |
| 726 | echo 'selected'; |
| 727 | } ?>><?php esc_html_e('GPT Image 1 Mini', 'autowp'); ?></option> |
| 728 | <option value="4" <?php if ($item['image_generating_status'] === '4') { |
| 729 | echo 'selected'; |
| 730 | } ?>><?php esc_html_e('GPT Image 2', 'autowp'); ?></option> |
| 731 | <option value="5" <?php if ($item['image_generating_status'] === '5') { |
| 732 | echo 'selected'; |
| 733 | } ?>><?php esc_html_e('DuckDuckGo Search', 'autowp'); ?></option> |
| 734 | |
| 735 | <option value="6" <?php if ($item['image_generating_status'] === '6') { |
| 736 | echo 'selected'; |
| 737 | } ?>><?php esc_html_e('Default Image', 'autowp'); ?></option> |
| 738 | |
| 739 | <option value="7" <?php if ($item['image_generating_status'] === '7') { |
| 740 | echo 'selected'; |
| 741 | } ?>><?php esc_html_e('No Image', 'autowp'); ?></option> |
| 742 | |
| 743 | |
| 744 | |
| 745 | </select> |
| 746 | <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> |
| 747 | </div> |
| 748 | |
| 749 | |
| 750 | <div class="col-md-6"> |
| 751 | <label for="post_order" class="form-label">Post Order:</label> |
| 752 | <select id="post_order" name="post_order" class="form-select"> |
| 753 | <option value="desc" <?php if ($item['post_order'] === 'desc') { |
| 754 | echo 'selected'; |
| 755 | } ?>>Latest First</option> |
| 756 | <option value="asc" <?php if ($item['post_order'] === 'asc') { |
| 757 | echo 'selected'; |
| 758 | } ?>>Oldest First</option> |
| 759 | <option value="rand" <?php if ($item['post_order'] === 'rand') { |
| 760 | echo 'selected'; |
| 761 | } ?>>Random</option> |
| 762 | </select> |
| 763 | </div> |
| 764 | |
| 765 | |
| 766 | <br> |
| 767 | |
| 768 | <h4 style="font-weight: bold;">Post Settings</h4> |
| 769 | |
| 770 | <br> |
| 771 | |
| 772 | <div class="col-md-6"> |
| 773 | <label for="languageSelect" class="form-label">Post Language:</label> |
| 774 | <select class="form-select" id="languageSelect" name="languageSelect"> |
| 775 | <?php |
| 776 | $languages = [ |
| 777 | "Afrikaans", |
| 778 | "Albanian", |
| 779 | "Arabic", |
| 780 | "Armenian", |
| 781 | "Basque", |
| 782 | "Bengali", |
| 783 | "Bulgarian", |
| 784 | "Catalan", |
| 785 | "Cambodian", |
| 786 | "Chinese (Mandarin)", |
| 787 | "Croatian", |
| 788 | "Czech", |
| 789 | "Danish", |
| 790 | "Dutch", |
| 791 | "English", |
| 792 | "Estonian", |
| 793 | "Fiji", |
| 794 | "Finnish", |
| 795 | "French", |
| 796 | "Georgian", |
| 797 | "German", |
| 798 | "Greek", |
| 799 | "Gujarati", |
| 800 | "Hebrew", |
| 801 | "Hindi", |
| 802 | "Hungarian", |
| 803 | "Icelandic", |
| 804 | "Indonesian", |
| 805 | "Irish", |
| 806 | "Italian", |
| 807 | "Japanese", |
| 808 | "Javanese", |
| 809 | "Korean", |
| 810 | "Latin", |
| 811 | "Latvian", |
| 812 | "Lithuanian", |
| 813 | "Macedonian", |
| 814 | "Malay", |
| 815 | "Malayalam", |
| 816 | "Maltese", |
| 817 | "Maori", |
| 818 | "Marathi", |
| 819 | "Mongolian", |
| 820 | "Nepali", |
| 821 | "Norwegian", |
| 822 | "Persian", |
| 823 | "Polish", |
| 824 | "Portuguese", |
| 825 | "Punjabi", |
| 826 | "Quechua", |
| 827 | "Romanian", |
| 828 | "Russian", |
| 829 | "Samoan", |
| 830 | "Serbian", |
| 831 | "Slovak", |
| 832 | "Slovenian", |
| 833 | "Spanish", |
| 834 | "Swahili", |
| 835 | "Swedish", |
| 836 | "Tamil", |
| 837 | "Tatar", |
| 838 | "Telugu", |
| 839 | "Thai", |
| 840 | "Tibetan", |
| 841 | "Tonga", |
| 842 | "Turkish", |
| 843 | "Ukrainian", |
| 844 | "Urdu", |
| 845 | "Uzbek", |
| 846 | "Vietnamese", |
| 847 | "Welsh", |
| 848 | "Xhosa" |
| 849 | ]; |
| 850 | ?> |
| 851 | <?php foreach ($languages as $language): ?> |
| 852 | <option value="<?php echo esc_attr($language); ?>" <?php echo ($language === $promptcode_language) ? 'selected' : ''; ?>> |
| 853 | |
| 854 | <?php echo esc_html($language); ?> |
| 855 | </option> |
| 856 | <?php endforeach; ?> |
| 857 | |
| 858 | </select> |
| 859 | </div> |
| 860 | <br> |
| 861 | <div class="col-md-6"> |
| 862 | <label for="subtitleSelect" class="form-label">Subheading Count:</label> |
| 863 | <select class="form-select" id="subtitleSelect" name="subtitleSelect"> |
| 864 | <?php |
| 865 | for ($i = 1; $i <= 10; $i++) { |
| 866 | $selected = ($promptcode_subtitle == strval($i)) ? 'selected' : ''; |
| 867 | echo "<option value='" . esc_attr($i) . "' " . esc_attr($selected) . ">" . esc_html($i) . "</option>"; |
| 868 | |
| 869 | } |
| 870 | ?> |
| 871 | </select> |
| 872 | </div> |
| 873 | <br> |
| 874 | <div class="col-md-6"> |
| 875 | <label for="narrationSelect" class="form-label">Writing Style:</label> |
| 876 | <select class="form-select" id="narrationSelect" name="narrationSelect"> |
| 877 | <?php |
| 878 | $is_inactive = (isset($item['active']) && $item['active'] === '0'); |
| 879 | $styles = [ |
| 880 | "Descriptive" => "Descriptive", |
| 881 | "Narrative" => "Narrative", |
| 882 | "Explanatory" => "Explanatory", |
| 883 | "Argumentative" => "Argumentative", |
| 884 | "Comparative" => "Comparative", |
| 885 | "Process Analysis" => "Process Analysis", |
| 886 | "Allegorical" => "Allegorical", |
| 887 | "Chronological" => "Chronological", |
| 888 | "Ironic" => "Ironic", |
| 889 | "ConsistencyAndRepetition" => "Consistency and Repetition", |
| 890 | "LanguagePlayAndPoeticExpression" => "Language Play and Poetic Expression", |
| 891 | "InternalMonologue" => "Internal Monologue", |
| 892 | "Dialogical" => "Dialogical" |
| 893 | ]; |
| 894 | foreach ($styles as $value => $name) { |
| 895 | $selected = ($promptcode_narration == $value) ? 'selected' : ''; |
| 896 | echo "<option value='" . esc_attr($value) . "' " . esc_attr($selected) . ">" . esc_html($name) . "</option>"; |
| 897 | |
| 898 | } |
| 899 | ?> |
| 900 | |
| 901 | </select> |
| 902 | <br> |
| 903 | </div> |
| 904 | |
| 905 | <h4 style="font-weight: bold;">Source Status</h4> |
| 906 | |
| 907 | |
| 908 | <!-- Status Field (Active/Inactive) --> |
| 909 | <div class="col-md-6"> |
| 910 | <label for="active" class="form-label">Status:</label> |
| 911 | |
| 912 | |
| 913 | <select id="active" name="active" class="form-select"> |
| 914 | <option value="1" <?php echo (!$is_inactive) ? 'selected' : ''; ?>> |
| 915 | Active |
| 916 | </option> |
| 917 | <option value="0" <?php echo ($is_inactive) ? 'selected' : ''; ?>> |
| 918 | Inactive |
| 919 | </option> |
| 920 | </select> |
| 921 | |
| 922 | <p> |
| 923 | When the cron job is triggered, any task marked as "Active" will be executed. |
| 924 | If you select "Inactive," this task will be skipped, and the cron job will move |
| 925 | on to the remaining active tasks. This makes it easy to enable or disable tasks |
| 926 | without removing them entirely. |
| 927 | </p> |
| 928 | </div> |
| 929 | <!-- /Status Field --> |
| 930 | |
| 931 | |
| 932 | <br> |
| 933 | |
| 934 | |
| 935 | |
| 936 | </form> |
| 937 | </div> |
| 938 | |
| 939 | </form> |
| 940 | |
| 941 | </tbody> |
| 942 | <?php |
| 943 | } |
| 944 |