public static function addKeyword($keyword, $path, $url) { array_unshift(self::$siteKeywords, $keyword); array_unshift(self::$imagePaths, $path); if (N2Settings::get('protocol-relative', '1')) { $url = self::protocolRelative($url); } array_unshift(self::$imageUrls, $url); }
public static function jQuery($force = false) { if (N2Settings::get('jquery') || N2Platform::$isAdmin || $force) { self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("jQuery.min.js", "njQuery.js"), "n2"); } else { if (N2Settings::get('async', '0')) { self::addInline(file_get_contents(N2LIBRARYASSETS . '/js/core/jquery/njQuery.js'), true); } else { self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2"); } } self::addFiles(N2LIBRARYASSETS . '/js', array("console.js"), "nextend-frontend"); }
public static function jQuery($force = false) { if ($force) { self::addFiles(ABSPATH . '/wp-includes/js/jquery/', array("jquery.js", "jquery-migrate.min.js"), "n2"); self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2"); } else { wp_enqueue_script('jquery'); if (N2Settings::get('async', '0')) { self::addInline(file_get_contents(N2LIBRARYASSETS . '/js/core/jquery/njQuery.js'), true); } else { self::addFiles(N2LIBRARYASSETS . '/js/core/jquery', array("njQuery.js"), "n2"); } } self::addFiles(N2LIBRARYASSETS . '/js', array("console.js"), "nextend-frontend"); }
public static function api($posts) { if (!isset($data)) { if (function_exists('curl_init') && N2Settings::get('curl', 1)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, self::$api); $posts_default = array('platform' => N2Platform::getPlatform()); curl_setopt($ch, CURLOPT_POSTFIELDS, $posts + $posts_default); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 30); if (N2Settings::get('curl-clean-proxy', 0)) { curl_setopt($ch, CURLOPT_PROXY, ''); } $data = curl_exec($ch); $contentType = curl_getinfo($ch, CURLINFO_CONTENT_TYPE); $error = curl_error($ch); $curlErrorNumber = curl_errno($ch); curl_close($ch); if ($curlErrorNumber) { N2Message::error($curlErrorNumber . $error); return array('status' => 'ERROR_HANDLED'); } } else { $posts_default = array('platform' => N2Platform::getPlatform()); $opts = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => http_build_query($posts + $posts_default))); $context = stream_context_create($opts); $data = file_get_contents(self::$api, false, $context); if ($data === false) { N2Message::error(n2_('CURL disabled in your php.ini configuration. Please enable it!')); return array('status' => 'ERROR_HANDLED'); } $headers = self::parseHeaders($http_response_header); if ($headers['status'] != '200') { N2Message::error(n2_('Unable to contact with the licensing server, please try again later!')); return array('status' => 'ERROR_HANDLED'); } if (isset($headers['content-type'])) { $contentType = $headers['content-type']; } } } switch ($contentType) { case 'application/json': return json_decode($data, true); } return $data; }
private static function animation($force = false) { static $once; if ($once != null && !$force) { return; } $once = true; if (N2Pluggable::hasAction('animationFramework')) { N2Pluggable::doAction('animationFramework'); } else { if (N2Settings::get('gsap')) { N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("gsap.js"), "nextend-frontend"); } else { if (N2Platform::$isAdmin) { N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("gsap.js"), "nextend-gsap"); } else { N2JS::addFiles(N2LIBRARYASSETS . "/js/core/gsap", array("NextendTimeline.js"), "nextend-gsap"); } } } }
public function getOutput() { $output = ""; $globalInline = $this->getGlobalInlineScripts(); if (!empty($globalInline)) { $output .= N2Html::script($globalInline . "\n"); } foreach ($this->urls as $url) { $output .= N2Html::script($url, true) . "\n"; } if (!N2Platform::$isAdmin && N2Settings::get('async', '0')) { $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false); foreach ($this->getFiles() as $file) { if (basename($file) == 'n2.js') { $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n"; } else { $jsCombined->add($file); } } $combinedFile = $jsCombined->make(); $scripts = 'nextend.loadScript("' . N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile) . '");'; $output .= N2Html::script($scripts . "\n"); } else { if (!N2Platform::$isAdmin && N2Settings::get('combine-js', '0')) { $jsCombined = new N2CacheCombine('js', N2Settings::get('minify-js', '0') ? 'N2MinifierJS::minify' : false); foreach ($this->getFiles() as $file) { $jsCombined->add($file); } $combinedFile = $jsCombined->make(); $output .= N2Html::script(N2Uri::pathToUri($combinedFile) . '?' . filemtime($combinedFile), true) . "\n"; } else { foreach ($this->getFiles() as $file) { $output .= N2Html::script(N2Uri::pathToUri($file) . '?' . filemtime($file), true) . "\n"; } } } $output .= N2Html::script(N2Localization::toJS() . "\n" . $this->getInlineScripts() . "\n"); return $output; }
public static function afterOutputEnd() { self::$nextend_wp_footer = true; if (defined('N2LIBRARY')) { ob_start(); do_action('nextend_css'); do_action('nextend_js'); if (class_exists('N2AssetsManager')) { echo N2AssetsManager::getCSS(); echo N2AssetsManager::getJs(); } self::$nextend_head = ob_get_clean(); } if (N2Settings::get('safemode') == 1) { echo self::$nextend_head; } return true; }