예제 #1
0
 /**
  * Catch exception and display error message
  *
  * @access public
  */
 public function catchException()
 {
     if (is_admin()) {
         echo $this->displayAdminNotice();
     } else {
         echo Message::alert($this->getMessage(), 'alert-error');
         if (WP_DEBUG) {
             \SilverWp\Debug::dumpPrint($this->getTrace());
         }
     }
 }
예제 #2
0
 /**
  * Get video data
  *
  * @param integer $post_id
  * @param string  $key_name field key name
  *
  * @return array
  */
 public function getMedia($post_id, $key_name = 'video')
 {
     $file_data = array();
     $meta_box = $this->get($post_id, $key_name);
     $video_url = false;
     if (isset($meta_box['video_url']) && $meta_box['video_url']) {
         $video_url = $meta_box['video_url'];
     }
     if ($video_url) {
         try {
             $oEmbed = new Oembed($video_url);
             $file_data['provider_name'] = $oEmbed->provider_name;
             $file_data['file_url'] = $video_url;
             $file_data['thumbnail_url'] = $oEmbed->getThumbnailUrl();
         } catch (Exception $ex) {
             echo Message::alert($ex->getMessage(), 'alert-danger');
             if (WP_DEBUG) {
                 Debug::dumpPrint($ex->getTraceAsString(), 'Stack trace:');
                 Debug::dumpPrint($ex->getTrace(), 'Full stack:');
             }
         }
     }
     return $file_data;
 }
예제 #3
0
 /**
  *
  * Generate CSS file from less variable and save it
  *
  * @access public
  */
 public function generateAfterSave()
 {
     try {
         $css_path = FileSystem::getDirectory('css_path');
         $css_uri = FileSystem::getDirectory('css_uri');
         $template = Sass::getInstance();
         $template->setUploadDir($css_path);
         $template->setUploadUrl($css_uri);
         $variable = $this->getVariablesFromControls();
         if ($this->debug) {
             Debug::dumpPrint($variable);
         }
         $template->setVariables($variable);
         $template->registerFallback();
         $template->deleteCssTmp();
     } catch (Exception $ex) {
         $ex->catchException();
     }
 }
예제 #4
0
 /**
  * Initialize short code
  *
  * @access public
  */
 public function init()
 {
     $this->create();
     $this->settings['base'] = $this->getTagBase();
     if ($this->debug) {
         Debug::dumpPrint($this->settings);
     }
     vc_map($this->settings);
 }
예제 #5
0
 /**
  * Initialize class and register Custom Post Type
  *
  * @access public
  * @throws \SilverWp\PostType\Exception
  */
 public function init()
 {
     $parent_class = get_called_class();
     if (is_null($this->name)) {
         throw new Exception(Translate::translate('Property %s is required and can\'t be empty.', $parent_class . '::name'));
     }
     //setup default args
     //display in admin menu
     $this->show_ui = true;
     $this->query_var = true;
     $this->exclude_from_search = false;
     // Permalinks format
     $this->rewrite = array('slug' => $this->name, 'with_front' => false);
     //set up post type
     $this->setUp();
     $default_args = array('labels' => wp_parse_args($this->labels, $this->getDefaultLabels()), 'public' => $this->public, 'supports' => $this->supports);
     $this->args = wp_parse_args($this->args, $default_args);
     $post_type = register_post_type($this->name, $this->args);
     flush_rewrite_rules();
     //debug
     if ($this->debug) {
         Debug::dumpPrint($this->args, $this->name);
         Debug::dumpPrint($post_type);
     }
 }
예제 #6
0
 /**
  *
  * Register and add menu settings
  *
  * @access public
  */
 public function init()
 {
     $this->setUp();
     $settings = array('is_dev_mode' => self::DEV_MODE, 'option_key' => THEME_OPTION_PREFIX, 'page_slug' => SILVERWP_THEME_TEXT_DOMAIN . '-' . $this->menu_slug, 'template' => $this->getTemplate(), 'use_auto_group_naming' => $this->use_auto_group_naming, 'use_exim_menu' => $this->use_exim_menu, 'minimum_role' => $this->min_role, 'layout' => 'fixed', 'page_title' => $this->labels['page_title'], 'menu_label' => $this->labels['menu_label']);
     if ($this->debug) {
         Debug::dumpPrint($settings);
     }
     new VP_Option($settings);
 }
예제 #7
0
 /**
  *
  * Get menu settings
  *
  * @return array
  * @access public
  */
 public function getSettings()
 {
     if ($this->debug) {
         Debug::dump($this->settings);
     }
     return $this->settings;
 }