/** * AJAX hook for the "Recheck" action. */ public function ajax_recheck() { if (!current_user_can('edit_others_posts') || !check_ajax_referer('blc_recheck', false, false)) { die(json_encode(array('error' => __("You're not allowed to do that!", 'broken-link-checker')))); } if (!isset($_POST['link_id']) || !is_numeric($_POST['link_id'])) { die(json_encode(array('error' => __("Error : link_id not specified", 'broken-link-checker')))); } $id = intval($_POST['link_id']); $link = new blcLink($id); if (!$link->valid()) { die(json_encode(array('error' => sprintf(__("Oops, I can't find the link %d", 'broken-link-checker'), $id)))); } //In case the immediate check fails, this will ensure the link is checked during the next work() run. $link->last_check_attempt = 0; $link->isOptionLinkChanged = true; $link->save(); //Check the link and save the results. $link->check(true); $status = $link->analyse_status(); $response = array('status_text' => $status['text'], 'status_code' => $status['code'], 'http_code' => empty($link->http_code) ? '' : $link->http_code, 'redirect_count' => $link->redirect_count, 'final_url' => $link->final_url); die(json_encode($response)); }
/** * @param blcLink $link * @param blcLinkInstance[] $instances */ function column_status($link, $instances) { printf('<table class="mini-status" title="%s">', esc_attr(__('Show more info about this link', 'broken-link-checker'))); $status = $link->analyse_status(); printf('<tr class="link-status-row link-status-%s"> <td> <span class="http-code">%s</span> <span class="status-text">%s</span> </td> </tr>', $status['code'], empty($link->http_code) ? '' : $link->http_code, $status['text']); //Last checked... if ($link->last_check != 0) { $last_check = _x('Checked', 'checked how long ago', 'broken-link-checker') . ' '; $last_check .= blcUtility::fuzzy_delta(time() - $link->last_check, 'ago'); printf('<tr class="link-last-checked"><td>%s</td></tr>', $last_check); } //Broken for... if ($link->broken) { $delta = time() - $link->first_failure; $broken_for = blcUtility::fuzzy_delta($delta); printf('<tr class="link-broken-for"><td>%s %s</td></tr>', __('Broken for', 'broken-link-checker'), $broken_for); } echo '</table>'; }