public static function renderCron() { $cron_array = _get_cron_array(); $schedules = wp_get_schedules(); ?> <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0"> <thead> <tr> <th scope="col" class="manage-column column-posts" style=""><span><?php _e('Next due', 'mainwp'); ?> </span></th> <th scope="col" class="manage-column column-posts" style=""><span><?php _e('Schedule', 'mainwp'); ?> </span></th> <th scope="col" class="manage-column column-posts" style=""><span><?php _e('Hook', 'mainwp'); ?> </span></th> </tr> </thead> <tbody id="the-sites-list" class="list:sites"> <?php foreach ($cron_array as $time => $cron) { foreach ($cron as $hook => $cron_info) { foreach ($cron_info as $key => $schedule) { ?> <tr><td><?php echo MainWPHelper::formatTimestamp(MainWPHelper::getTimestamp($time)); ?> </td><td><?php echo isset($schedule['schedule']) && isset($schedules[$schedule['schedule']]) && isset($schedules[$schedule['schedule']]['display']) ? $schedules[$schedule['schedule']]['display'] : ''; ?> </td><td><?php echo $hook; ?> </td></tr> <?php } } } ?> </tbody> </table> <?php }
function get_section_loop_data($records, $tokens, $section) { $convert_context_name = array("comment" => "comments", "plugin" => "plugins", "profile" => "profiles", "session" => "sessions", "setting" => "settings", "theme" => "themes", "posts" => "post", "pages" => "page", "widget" => "widgets", "menu" => "menus", "backups" => "mainwp_backups", "backup" => "mainwp_backups", "sucuri" => "mainwp_sucuri"); $convert_action_name = array("restored" => "untrashed", "spam" => "spammed", "backup" => "mainwp_backup"); $some_allowed_data = array('name', 'title', 'oldversion', 'currentversion', 'date', 'count', 'author', 'old.version', 'current.version'); $context = $action = ""; $str_tmp = str_replace(array('[', ']'), "", $section); $array_tmp = explode(".", $str_tmp); if (is_array($array_tmp)) { if (count($array_tmp) == 2) { list($str1, $context) = $array_tmp; } else { if (count($array_tmp) == 3) { list($str1, $context, $action) = $array_tmp; } } } $context = isset($convert_context_name[$context]) ? $convert_context_name[$context] : $context; $action = isset($convert_action_name[$action]) ? $convert_action_name[$action] : $action; $loops = array(); $loop_count = 0; foreach ($records as $record) { $theme_edited = $users_updated = $plugin_edited = false; if ($plugin_edited) { // ok next } else { if ($context == "themes" && $action == "edited") { if ($record->action !== "updated" || $record->connector !== "editor") { continue; } else { $theme_edited = true; } } else { if ($context == "users" && $action == "updated") { if ($record->context !== "profiles" || $record->connector !== "users") { continue; } else { $users_updated = true; } } else { if ($context == "mainwp_backups") { if ($record->context !== "mainwp_backups" && $record->context !== "updraftplus_backups" && $record->context !== "backupwordpress_backups") { continue; } } else { if ($context == "mainwp_sucuri") { if ($record->context !== "mainwp_sucuri") { continue; } } else { if ($action !== $record->action) { continue; } if ($context === "comments" && $record->context !== "page" && $record->context !== "post") { continue; } else { if ($context === "media" && $record->connector !== "media") { continue; } else { if ($context === "widgets" && $record->connector !== "widgets") { continue; } else { if ($context === "menus" && $record->connector !== "menus") { continue; } } } } // else if ($context === "themes" && $record->connector !== "themes") // continue; if ($context !== "comments" && $context !== "media" && $context !== "widgets" && $context !== "menus" && $record->context !== $context) { continue; } } } } } } $token_values = array(); foreach ($tokens as $token) { $data = ""; $token_name = str_replace(array('[', ']'), "", $token); $array_tmp = explode(".", $token_name); if ($token_name == "user.name") { $data = "display_name"; } else { if (count($array_tmp) == 1) { list($data) = $array_tmp; } else { if (count($array_tmp) == 2) { list($str1, $data) = $array_tmp; } else { if (count($array_tmp) == 3) { list($str1, $str2, $data) = $array_tmp; } } } if ($data == "version") { if ($str2 == "old") { $data = "old_version"; } else { if ($str2 == "current" && $str1 == "wordpress") { $data = "new_version"; } } } } if ($data == "role") { $data = "roles"; } switch ($data) { case "date": $token_values[$token] = MainWPHelper::formatTimestamp(MainWPHelper::getTimestamp(strtotime($record->created))); break; case "area": $data = "sidebar_name"; $token_values[$token] = $this->get_stream_meta_data($record, $data); break; case "name": case "version": case "old_version": case "new_version": case "display_name": case "roles": if ($data == "name") { if ($theme_edited) { $data = "theme_name"; } else { if ($plugin_edited) { $data = "plugin_name"; } else { if ($users_updated) { $data = "display_name"; } } } } if ($data == "roles" && $users_updated) { $user_info = get_userdata($record->object_id); if (!(is_object($user_info) && is_a($user_info, 'WP_User'))) { $roles = ""; } else { $roles = implode(", ", $user_info->roles); } $token_values[$token] = $roles; } else { $token_values[$token] = $this->get_stream_meta_data($record, $data); } break; case "title": if ($context == "page" || $context == "post" || $context == "comments") { $data = "post_title"; } else { if ($record->connector == "menus") { $data = "name"; } } $token_values[$token] = $this->get_stream_meta_data($record, $data); break; case "author": $data = "author_meta"; $token_values[$token] = $this->get_stream_meta_data($record, $data); break; case "status": // sucuri cases // sucuri cases case "webtrust": if ($context == "mainwp_sucuri") { $token_values[$token] = $this->get_stream_meta_data($record, $data); } else { $token_values[$token] = $token; } break; case "destination": // backup cases // backup cases case "type": if ($context == "mainwp_backups") { $token_values[$token] = $this->get_stream_meta_data($record, $data); } else { $token_values[$token] = $token; } break; default: $token_values[$token] = "N/A"; break; } } // foreach $tokens if (!empty($token_values)) { $loops[$loop_count] = $token_values; $loop_count++; } } // foreach $records return $loops; }