0, 'msg' => 'Please, enter correct tag.'])); } $posts_updated = URALP_UpdAmazonPlugin::updateDB($new_id); $is_scheduled = sanitize_text_field($_POST['is-scheduled']); wp_unschedule_hook('uralp_hook'); if ($is_scheduled) { wp_schedule_event( time(), 'daily', 'uralp_hook', array($new_id) ); } if ($posts_updated >= 0) { die(json_encode(['success'=> 1, 'msg' => "Plugin updated $posts_updated posts/pages."])); } else { die(json_encode(['success'=> 1, 'msg' => "Can't run update. Currently job is running."])); } } add_action( 'wp_ajax_uralp_backup', 'uralp_backup_callback' ); function uralp_backup_callback() { check_ajax_referer( 'upd-plugin-for-amazon-backup', 'security' ); URALP_UpdAmazonPlugin::makeBackup(); die(json_encode(['msg' => 'Backup has been done'])); } add_action( 'wp_ajax_uralp_restore', 'uralp_restore_callback' ); function uralp_restore_callback() { check_ajax_referer( 'upd-plugin-for-amazon-restore', 'security' ); URALP_UpdAmazonPlugin::restoreDB(); die(json_encode(['msg' => 'Data has been restored from the latest backup'])); } add_action( 'wp_ajax_uralp_no_follow', 'uralp_no_follow_callback'); function uralp_no_follow_callback() { check_ajax_referer( 'upd-plugin-for-amazon-no_follow', 'security' ); $posts_updated = URALP_UpdAmazonPlugin::noFollow(); if ($posts_updated >= 0) { die(json_encode(['success'=> 1, 'msg' => "Plugin updated $posts_updated posts/pages."])); } else { die(json_encode(['success'=> 1, 'msg' => "Can't run update. Currently job is running."])); } } add_action( 'wp_ajax_uralp_no_affiliate', 'uralp_no_affiliate_callback'); function uralp_no_affiliate_callback() { check_ajax_referer( 'upd-plugin-for-amazon-no_affiliate', 'security' ); $posts_updated = URALP_UpdAmazonPlugin::noAffiliate(); if ($posts_updated >= 0) { die(json_encode(['success'=> 1, 'msg' => "Plugin updated $posts_updated posts/pages."])); } else { die(json_encode(['success'=> 1, 'msg' => "Can't run update. Currently job is running."])); } } add_action( 'wp_ajax_uralp_expand', 'uralp_expand_callback'); function uralp_expand_callback() { check_ajax_referer( 'upd-plugin-for-amazon-expand', 'security' ); $posts_updated = URALP_UpdAmazonPlugin::expand(); if ($posts_updated >= 0) { die(json_encode(['success'=> 1, 'msg' => "Plugin updated $posts_updated posts/pages."])); } else { die(json_encode(['success'=> 1, 'msg' => "Can't run update. Currently job is running."])); } } add_action( 'wp_ajax_uralp_get_progress', 'uralp_get_progress_callback'); function uralp_get_progress_callback() { check_ajax_referer( 'upd-plugin-for-amazon-get_progress', 'security' ); $job = URALP_UpdAmazonPlugin::getProgress(); die(json_encode(['success'=> 1, 'msg' => $job])); } // activateion register_activation_hook( __FILE__, [$updAmazonPlugin, 'activate'] ); // deactivation register_deactivation_hook( __FILE__, [$updAmazonPlugin, 'deactivate'] ); function uralp_schedule_func($keyword) { URALP_UpdAmazonPlugin.updateDB($keyword); }