Пример #1
0
 public function purgeUrl()
 {
     if (!current_user_can('edit_posts')) {
         return;
     }
     if (isset($_GET['vhp_flush_url']) && check_admin_referer('varnish-http-purge')) {
         global $post;
         global $purger;
         if (!isset($post) && isset($_GET['post']) && is_numeric($_GET['post']) && $_GET['post'] > 0) {
             $post = get_post(sanitize_text_field($_GET['post']));
         }
         if (!isset($post) || !is_object($post) || !isset($purger)) {
             return;
         }
         $purger->purgeUrl(get_permalink($post->ID));
         add_action('admin_notices', function () {
             echo "<div id='message' class='updated fade'><p><strong>" . __('Varnish cache purged for this post!', 'municipio') . "</strong></p></div>";
         });
         \Municipio\Helper\Notice::add('Page purged!', 'success');
     }
 }
Пример #2
0
 /**
  * Load controller and view
  * @param  string $template Template
  * @return mixed            Exception or false, false to make sure no
  *                          standard template file from wordpres is beeing included
  */
 public function load($template)
 {
     if (!empty(get_page_template_slug()) && get_page_template_slug() != $template) {
         if (file_exists(get_page_template_slug())) {
             $template = get_page_template_slug();
         }
     }
     if (!\Municipio\Helper\Template::isBlade($template)) {
         $path = get_template_directory() . '/' . $template;
         // Return path if file exists, else default to page.blade.php
         if (file_exists($path)) {
             return $path;
         } else {
             if (current_user_can('administrator')) {
                 \Municipio\Helper\Notice::add('<strong>' . __('Admin notice', 'municipio') . ':</strong> ' . sprintf(__('View [%s] was not found. Defaulting to [page.blade.php].', 'municipio'), $template), 'warning', 'pricon pricon-notice-warning');
             }
             $template = \Municipio\Helper\Template::locateTemplate('views/page.blade.php');
         }
     }
     // Clean the view path
     $view = $this->cleanViewPath($template);
     // Load view controller
     $controller = $this->loadController($view);
     // Render the view
     $data = null;
     if ($controller) {
         $data = $controller->getData();
     }
     $this->render($view, $data);
     return false;
 }