function ns_log_write($message, $logfile) { global $ns_log_start_time; // save start time if it's not set so we can compare against it for getting current relative # of seconds into clone if (is_null($ns_log_start_time)) { $ns_log_start_time = microtime(true); } if (!is_writable($logfile)) { ns_log_check($logfile); if (!is_writable($logfile)) { return false; } } // calculate current time into process and set up message $current_seconds = number_format(microtime(true) - $ns_log_start_time, 4); $formatted_message = ""; foreach ((array) $message as $message_part) { $formatted_message .= is_string($message_part) ? "<span>{$message_part}</span>" : @Kint::dump($message_part); } // log it! $time_cell = "<td>{$current_seconds}s</td>"; $message_cell = "<td>{$formatted_message}</td>"; error_log("<tr>{$time_cell}{$message_cell}</tr>", 3, $logfile); }
function admin_init() { // if we are on a cloner admin page if (ns_is_admin_page($this->menu_slug) || ns_is_admin_subpage($this->menu_slug)) { // check that logs are writeable ns_log_check(NS_CLONER_LOG_FILE); ns_log_check(NS_CLONER_LOG_FILE_DETAILED, false); // run action for addons to hook on admin page whether or not a clone process is being triggered // (ns_cloner_before_everything below will only trigger if an action is being run) do_action('ns_cloner_admin_init'); } // run cloner if on the core cloner page and an action has been submitted and user is allowed to clone if (ns_is_admin_page($this->menu_slug) && !empty($this->request['action']) && $this->check_permissions()) { $this->dlog_header(); $this->process_init(); } }