public function dashboard_notice() { $path = wp_normalize_path(Upfront::get_root_dir() . '/library/external/dashboard-notice/wpmudev-dash-notification.php'); if (!file_exists($path)) { return false; } require_once $path; }
/** * Fetching and pre-processing the relative/absolute paths in styles. */ private function _get_style_contents($frags) { $path = upfront_element_dir($frags[0], $frags[1]); $url = upfront_element_url($frags[0], $frags[1]); if (!file_exists($path)) { return false; } $style = file_get_contents($path); // Obtain the first "../" level $base_url = trailingslashit(dirname(dirname($url))); // First up, let's build up allowed directories list $dirs = explode('/', $base_url); $relatives = array(); $upfront_root = preg_quote(Upfront::get_root_url(), '/'); while (array_pop($dirs) !== NULL) { $rel = join('/', $dirs); $relatives[] = $rel; if (preg_match('/^' . $upfront_root . '$/', $rel)) { break; } // Let's not allow relative paths inclusion higher than the Upfront root } if (empty($relatives)) { return $style; } // Next, let's build the matching patterns list $matchers = array(); foreach ($relatives as $idx => $relpath) { $count = $idx + 1; $matchers[$count] = array('url' => $relpath, 'pattern' => str_repeat('../', $count)); } $matchers = array_reverse($matchers); // Start with longest match first // Lastly, let's actually replace the relative paths $slash = preg_quote('/', '/'); foreach ($matchers as $match) { if (empty($match['pattern']) || empty($match['url'])) { continue; } $rx = "/([^{$slash}])" . preg_quote($match['pattern'], '/') . '([^.]{2})/'; // Let's start small $rpl = '$1' . trailingslashit($match['url']) . '$2'; $style = preg_replace($rx, $rpl, $style); } return $style; }
/** * Register scripts */ function upfront_register_vendor_scripts() { //Magnific lightbox if (defined("SCRIPT_DEBUG") && SCRIPT_DEBUG) { wp_register_script('magnific', Upfront::get_root_url() . '/scripts/magnific-popup/magnific-popup.js', array('jquery'), '1.0', true); } else { wp_register_script('magnific', Upfront::get_root_url() . '/scripts/magnific-popup/magnific-popup.min.js', array('jquery'), '1.0', true); } wp_register_style('magnific', Upfront::get_root_url() . '/scripts/magnific-popup/magnific-popup.css'); }
protected function get_style_template_path() { return realpath(Upfront::get_root_dir() . '/elements/upfront-tabs/tpl/preset-style.html'); }
function upfront_media_file_upload() { if (!Upfront_Permissions::current(Upfront_Permissions::UPLOAD)) { return false; } // Do not inject for users that can't use this $base_url = Upfront::get_root_url(); /* wp_enqueue_script('fileupload', "{$base_url}/scripts/file_upload/jquery.fileupload.js", array('jquery')); wp_enqueue_script('fileupload-iframe', "{$base_url}/scripts/file_upload/jquery.iframe-transport.js", array('fileupload')); */ $deps = Upfront_CoreDependencies_Registry::get_instance(); $deps->add_script("{$base_url}/scripts/file_upload/jquery.fileupload.js"); $deps->add_script("{$base_url}/scripts/file_upload/jquery.iframe-transport.js"); echo '<script>var _upfront_media_upload=' . json_encode(array('normal' => Upfront_UploadHandler::get_action_url('upfront-media-upload'), 'theme' => Upfront_UploadHandler::get_action_url('upfront-media-upload-theme-image'), 'embed_ref' => Upfront_UploadHandler::get_ref(Upfront_Permissions::EMBED), 'image_ref' => Upfront_UploadHandler::get_ref(Upfront_Permissions::UPLOAD))) . ';</script>'; }
public function add_form_validation() { wp_enqueue_script('upfront-form_validation', Upfront::get_root_url() . '/scripts/form_validation.js'); $form_data = array(); foreach ($this->_elements as $element) { $name = $element->get_name(); $form_data[$name] = array("rule" => $element->get_validation_rule(), "message" => $element->get_validation_message()); } echo '<script type="text/javascript">' . 'var _upfront_form_data = _upfront_form_data || {};' . '_upfront_form_data["' . esc_js($this->get_name()) . '"] = ' . json_encode($form_data) . '; ' . '</script>'; }
public function load_upfront_data() { include Upfront::get_root_dir() . '/scripts/upfront/upfront-data.php'; }