/** * 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()); } } }
/** * 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; }
/** * * 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(); } }
/** * 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); }
/** * 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); } }
/** * * 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); }
/** * * Get menu settings * * @return array * @access public */ public function getSettings() { if ($this->debug) { Debug::dump($this->settings); } return $this->settings; }