Пример #1
0
 /**
  * Render view
  *
  * @param string $view_file path to file important: without extension
  * @param array  $data      data to load to theme
  *
  * @static
  * @access public
  */
 public static function render($view_file, array $data)
 {
     try {
         $view = View::getInstance()->load($view_file, $data);
         return $view;
     } catch (Exception $ex) {
         echo $ex->displayAdminNotice();
     }
 }
Пример #2
0
 public function render($is_compact = false)
 {
     $this->_setup_data();
     $this->add_data('is_compact', $is_compact);
     $this->add_data('is_media_button', $this->is_media_button);
     $view_path = \SilverWp\FileSystem::getDirectory('ssvp_views');
     $content = \SilverWp\View::getInstance()->load($view_path . 'control/wpeditor', $this->get_data());
     return $content;
 }
Пример #3
0
 /**
  * Render widget view
  *
  * @param array $data data passed too view
  *
  * @param null|string $view_file
  *
  * @return string
  * @access protected
  */
 protected function render(array $data, $view_file = null)
 {
     if (\is_null($view_file)) {
         $view_file = $this->id_base;
     }
     try {
         $view_path = FileSystem::getDirectory('widgets_views');
         $view = View::getInstance()->load($view_path . $view_file, $data);
         echo $view;
     } catch (Exception $ex) {
         echo $ex->displayAdminNotice($ex->getMessage());
     }
 }
Пример #4
0
 /**
  * Render short code view
  *
  * @param array       $data data passed too view
  *
  * @param null|string $view_file
  *
  * @return string
  * @access protected
  */
 protected function render(array $data, $view_file = null)
 {
     if (\is_null($view_file)) {
         $view_file = $this->tag_base;
     }
     try {
         $view_path = FileSystem::getDirectory('sc_templates');
         $view = View::getInstance()->load($view_path . $view_file, $data);
         return $view;
     } catch (Exception $ex) {
         echo $ex->catchException();
     }
 }
Пример #5
0
 /**
  * Ajax response in HTML format
  *
  * @param array  $data      data
  * @param string $view_file view file name
  *
  * @return string rendered view
  * @throws Exception
  */
 protected function responseHtml(array $data, $view_file = null)
 {
     if (\is_null($view_file)) {
         $view_file = $this->name;
     }
     try {
         $view_path = FileSystem::getDirectory('views');
         $view = View::getInstance()->load($view_path . 'ajax/' . $view_file, $data);
         //some servers don't display content with out echo
         echo $view;
         //fix display 0
         //return $view;
     } catch (Exception $ex) {
         echo $ex->displayAdminNotice($ex->getMessage());
     }
     exit;
 }
Пример #6
0
 /**
  * WPML lang switcher
  *
  * @static
  * @access public
  *
  * @param string $view_file
  *
  * @return string
  * @throws \SilverWp\Exception
  */
 public static function langSwitcher($view_file = 'lang-symbol-switcher')
 {
     if (function_exists('icl_get_languages')) {
         $args = 'skip_missing=1&orderby=code&order=ASC&link_empty_to=str';
         $languages = icl_get_languages($args);
         $view_path = FileSystem::getDirectory('views');
         $view = View::getInstance();
         $content = $view->load($view_path . $view_file, array('data' => $languages));
         return $content;
     }
     return false;
 }