admin_head.php
1 month ago
admin_init.php
1 month ago
admin_menu.php
1 month ago
admin_notices.php
1 month ago
init.php
1 month ago
pmxe_after_export.php
1 month ago
pmxe_before_export.php
1 month ago
pmxe_exported_post.php
1 month ago
wp_ajax_dismiss_export_warnings.php
1 month ago
wp_ajax_dismiss_review_modal.php
1 month ago
wp_ajax_dismiss_warnings.php
1 month ago
wp_ajax_generate_zapier_api_key.php
1 month ago
wp_ajax_redirect_after_addon_installed.php
1 month ago
wp_ajax_save_scheduling.php
1 month ago
wp_ajax_scheduling_dialog_content.php
1 month ago
wp_ajax_scheduling_subscribe_dialog_content.php
1 month ago
wp_ajax_send_feedback.php
1 month ago
wp_ajax_wpae_available_rules.php
1 month ago
wp_ajax_wpae_filtering.php
1 month ago
wp_ajax_wpae_filtering_count.php
1 month ago
wp_ajax_wpae_get_scheduling_connection_icon.php
1 month ago
wp_ajax_wpae_preview.php
1 month ago
wp_ajax_wpae_upgrade_notice.php
1 month ago
wp_ajax_wpallexport.php
1 month ago
wp_loaded.php
1 month ago
wpmu_new_blog.php
1 month ago
wp_ajax_save_scheduling.php
53 lines
| 1 | <?php |
| 2 | |
| 3 | // phpcs:ignoreFile WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound,WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- legitimate plugin prefixes (pmxe/PMXE/wpae/Wpae/wp_all_export/wpallexport/XmlExport/CdataStrategy/VariableProductTitle/Soflyy/GF_Export); Plugin Check does not honor phpcs.xml prefix declaration |
| 4 | defined( 'ABSPATH' ) || exit; |
| 5 | |
| 6 | |
| 7 | use Wpae\Scheduling\Interval\ScheduleTime; |
| 8 | use Wpae\Scheduling\Scheduling; |
| 9 | |
| 10 | /** |
| 11 | * @throws Exception |
| 12 | */ |
| 13 | function pmxe_wp_ajax_save_scheduling() |
| 14 | { |
| 15 | |
| 16 | if (!check_ajax_referer('wp_all_export_secure', 'security', false)) { |
| 17 | exit(esc_html__('Security check', 'wp-all-export')); |
| 18 | } |
| 19 | |
| 20 | if (!current_user_can(PMXE_Plugin::$capabilities)) { |
| 21 | exit(esc_html__('Security check', 'wp-all-export')); |
| 22 | } |
| 23 | |
| 24 | $elementId = isset( $_POST['element_id'] ) ? absint( $_POST['element_id'] ) : 0; |
| 25 | |
| 26 | $post = $_POST; |
| 27 | |
| 28 | foreach($post['scheduling_times'] as $schedulingTime) { |
| 29 | if(!preg_match('/^(0?[1-9]|1[012])(:[0-5]\d)[APap][mM]$/', $schedulingTime) && $schedulingTime != '') { |
| 30 | header('HTTP/1.1 400 Bad request', true, 400); |
| 31 | die('Invalid times provided'); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | try{ |
| 36 | $scheduling = Scheduling::create(); |
| 37 | $scheduling->handleScheduling($elementId, $post); |
| 38 | } catch (\Wpae\Scheduling\Exception\SchedulingHttpException $e) { |
| 39 | header('HTTP/1.1 503 Service unavailable', true, 503); |
| 40 | echo json_encode(array('success' => false)); |
| 41 | |
| 42 | die; |
| 43 | } |
| 44 | |
| 45 | $export = new PMXE_Export_Record(); |
| 46 | $export->getById($elementId); |
| 47 | $export->set(array('options' => array_merge($export->options, $post))); |
| 48 | $export->save(); |
| 49 | |
| 50 | echo json_encode(array('success' => true)); |
| 51 | die; |
| 52 | } |
| 53 |