/** * Class constructor * * @param string $name * * @access public */ public function __construct($name) { parent::__construct($name); $css_path = FileSystem::getDirectory('fonts_path') . 'fontello.css'; $items = SectionAbstract::flipSourceData(MetaBox::getFontelloIcons('icon', $css_path, 'silverwp_fontello_icons')); $this->setOptions($items); }
/** * * Class constructor * * @param string $name * @access public */ public function __construct($name = 'sidebar') { parent::__construct($name); $images_uri = FileSystem::getDirectory('images_uri'); $sidebar_positions = array(array('value' => 0, 'label' => Translate::translate('None'), 'img' => $images_uri . 'admin/sidebar/icon_0_sidebar_off.png'), array('value' => 1, 'label' => Translate::translate('Left sidebar'), 'img' => $images_uri . 'admin/sidebar/icon_1_sidebar_off.png'), array('value' => 2, 'label' => Translate::translate('Right sidebar'), 'img' => $images_uri . 'admin/sidebar/icon_2_sidebar_off.png')); $this->setOptions($sidebar_positions); }
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; }
/** * * path to file this function can be overwriten * * @return string * @access protected */ protected function getFontFile() { $data_dir = FileSystem::getDirectory('data'); $path = $data_dir . $this->font_file; return $path; }
/** * 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()); } }
/** * * Delete all tmp generated CSS files * * @access private */ private function deleteCssTmp() { $css_path = FileSystem::getDirectory('css_path'); $files = File::get_file_list($css_path . 'generated', array(), false, true); foreach ($files as $file) { unlink($file); } }
public function autoRegisterWidgets() { $widget_path = FileSystem::getDirectory('widgets_path'); $files_list = File::get_file_list($widget_path); foreach ($files_list as $file) { if ($file != '.' && $file != '..') { $class_file = $widget_path . DIRECTORY_SEPARATOR . $file; $classes = String::getClassNameFromFile($class_file); foreach ($classes as $class) { if (class_exists($class)) { \register_widget($class); } } } } }
/** * 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(); } }
/** * * Get list of icons (default: Fontello) * * @param string $name of css class * @param string $path path to css file with fonts * * @param string $transient_name cache key name * * @return array * @static */ public static function getFontelloIcons($name = 'icon', $path = null, $transient_name = 'silverwp_fontello') { if (\is_null($path)) { $fonts_path = FileSystem::getDirectory('fonts_path'); $path = $fonts_path . 'fontello.css'; } if (($icons = \get_transient($transient_name)) == false) { if (!file_exists($path)) { return false; } $matches = array(); $pattern = '/\\.(' . $name . '-(?:\\w+(?:-)?)+):before\\s*{\\s*content/'; $subject = \file_get_contents($path); \preg_match_all($pattern, $subject, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $icons[] = array('value' => $match[1], 'label' => str_replace($name . '-', '', $match[1])); } \set_transient($transient_name, $icons, 60 * 60 * 24); } return $icons; }
/** * 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; }
/** * Configure directories * * @param \WPScssPlugin $WPScssPlugin * @access private */ private function configDirs(\WPScssPlugin $WPScssPlugin) { $scss_config = $WPScssPlugin->getConfiguration(); if (isset($this->upload_dir) && isset($this->upload_url)) { $scss_config->setUploadDir($this->upload_dir); $scss_config->setUploadUrl($this->upload_url); } $css_template_path = FileSystem::getDirectory('css_template_path'); $WPScssPlugin->setImportDir($css_template_path); \WPScssStylesheet::$upload_dir = $scss_config->getUploadDir(); \WPScssStylesheet::$upload_uri = $scss_config->getUploadUrl(); }
/** * theme options logo * * @access protected * @return string * @since 1.9 */ protected function getLogo() { $image_uri = FileSystem::getDirectory('images_uri'); $logo = $image_uri . 'admin/logo_theme_option_panel.png'; return $logo; }
/** * * Add additional css or js files * * @return void * @access public */ public function enqueueAssets() { $fonts_uri = FileSystem::getDirectory('fonts_uri'); wp_register_style('fontello_icons', $fonts_uri . 'fontello.css'); wp_enqueue_style('fontello_icons'); }
/** * 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; }
/** * Add javascript file * * @return string * @access string */ protected function getJsScript() { return FileSystem::getDirectory('assets_uri') . 'js/admin/vc_slider.js'; }