/** * Handles form submission on StaticWP admin pages. * * @return void */ public function handlePost() { if (!isset($_POST['staticwp-action'])) { return; } if (!check_admin_referer('staticwp')) { return; } switch ($_POST['staticwp-action']) { case 'preload': set_error_handler(array(__CLASS__, 'errorToException'), E_ALL); try { $types = apply_filters('staticwp_preload_post_types', array('post', 'page')); foreach ($types as $type) { $this->preload($type); } $this->addNotice(View::notice('admin/preload-success')); } catch (Exception $e) { $this->addNotice(View::notice('admin/preload-error', 'error')); } restore_error_handler(); wp_reset_postdata(); wp_safe_redirect(self::url('preload')); exit; break; default: break; } }