prefix . ABW_DB_NAME; $page = isset( $_GET['page'] ) ? $_GET['page'] : ABW_ADMIN_MENU_SLUG; $page_uri = add_query_arg( array( 'page' => $page, ), trailingslashit( admin_url() ) . $pagenow ); $current_url = get_current_url(); $nonce = wp_create_nonce( 'clear_background_worker_jobs' ); $paged = isset( $_GET['paged'] ) ? intval( $_GET['paged'] ) : 1; $status = isset( $_GET['status'] ) ? $_GET['status'] : ''; $per_page = 20; $offset = ($per_page * $paged) - $per_page; $sql = "SELECT * FROM $table_name ORDER BY id, created_datetime, attempts ASC"; $total_active_jobs = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE attempts < 3" ); $total_failed_jobs = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name WHERE attempts > 2" ); $total_jobs = $wpdb->get_var( "SELECT COUNT(*) FROM ($sql) AS derived_table" ); $max_pages = max( 1, ceil( $total_jobs / $per_page ) ); if ( '' != $status ) { if ( 'active' == $status ) { $sql = $wpdb->prepare( " SELECT * FROM $table_name WHERE attempts < %d ORDER BY id, created_datetime, attempts ASC ", array( 3 ) ); $total_active_jobs = $wpdb->get_var( "SELECT COUNT(*) FROM ($sql) AS derived_table" ); $max_pages = max( 1, ceil( $total_active_jobs / $per_page ) ); } else { $sql = $wpdb->prepare( " SELECT * FROM $table_name WHERE attempts > %d ORDER BY id, created_datetime, attempts DESC ", array( 2 ) ); $total_failed_jobs = $wpdb->get_var( "SELECT COUNT(*) FROM ($sql) AS derived_table" ); $max_pages = max( 1, ceil( $total_failed_jobs / $per_page ) ); } } $jobs = $wpdb->get_results( $sql . " LIMIT $offset, $per_page" ); ?>

Background Worker Log

query( "DELETE FROM $table_name WHERE 1" ); if ( ! is_wp_error( $delete ) ) { echo '

' . __( 'All jobs have been cleared.' ) . '

'; } else { echo '

Error : ' . $delete->get_error_message() . '

'; } echo '' . __( 'Return to plugin homepage' ) . ''; return; } ?>
Total Jobs: Failed Jobs:
$job ) { $i++; $number++; $payload = unserialize( @$job->payload ); ?>
#
id; ?> created_datetime ) ? $job->created_datetime : '-'; ?> function; if ( is_array( $function ) ) { $obj = $function[0]; unset( $function[0] ); foreach ( $function as $func ) { echo $func; } } else { echo $function; } /* * Params */ // echo "
"; // $user_data = $payload->user_data; // echo "
";
											// if ( is_array($user_data) ) {
											// foreach ($user_data as $key_param => $param ) {
											// echo "[".$key_param."]" . " => " . $param;
											// echo "
"; // } // } else { // echo "User data: " . $user_data; // } // echo "
"; ?>
queue; ?> '; echo 'Retry Job'; echo ''; echo ''; } else { echo $job->attempts; } ?>
get_contents( BACKGROUND_WORKER_LOG ); $filearray = explode( "\n",$filearray ); $filearray = array_slice( $filearray, -100 ); $filearray = array_reverse( $filearray ); $content = ''; if ( $filearray ) { foreach ( $filearray as $key => $value ) { $content .= $value . "\n"; } if ( $content == '' ) { $content = 'Nothing to read, permission problem maybe ? '; } } else { $content = 'No Log'; } } ?>

prefix . ABW_DB_NAME; $response = []; $dataForm = $_POST['dataForm']; $_POST = $dataForm; $job_id = $_POST['id']; $update = $wpdb->update( $table_name, array( 'attempts' => 0, ), array( 'id' => $job_id, ), array( '%d' ), array( '%d' ) ); if ( ! is_wp_error( $update ) ) { $response['message'] = 'Active'; } else { $response['message'] = $update->get_error_message(); } wp_send_json( $response ); }