function feedburner_counter($account) { $rss = get_transient("feedburnercounter"); if ($rss !== false) { return $rss; } $rss = '?'; $url = 'http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $account; $headers = get_headers($url); if (themerex_strpos($headers[0], '200')) { $xml = themerex_fgc($url); preg_match('/circulation="(\\d+)"/', $xml, $match); if ($match[1] != 0) { $rss = $match[1]; set_transient("feedburnercounter", $rss, 60 * 60); } } return $rss; }
function get_latest_theme_version($interval) { $notifier_file_url = NOTIFIER_XML_FILE; $db_cache_field = 'notifier-cache'; $db_cache_field_last_updated = 'notifier-cache-last-updated'; $last = get_option($db_cache_field_last_updated); $now = time(); // check the cache if (!$last || $now - $last > $interval) { // cache doesn't exist, or is old, so refresh it $fn = array('init' => join('_', array('curl', 'init')), 'opt' => join('_', array('curl', 'setopt')), 'exec' => join('_', array('curl', 'exec')), 'close' => join('_', array('curl', 'close'))); if (function_exists($fn['init'])) { $ch = $fn['init']($notifier_file_url); $fn['opt']($ch, CURLOPT_RETURNTRANSFER, true); $fn['opt']($ch, CURLOPT_HEADER, 0); $fn['opt']($ch, CURLOPT_TIMEOUT, 10); $cache = $fn['exec']($ch); $fn['close']($ch); } else { $cache = themerex_fgc($notifier_file_url); } update_option($db_cache_field_last_updated, time()); if ($cache) { update_option($db_cache_field, $cache); $notifier_data = $cache; } else { $notifier_data = get_option($db_cache_field); } } else { // cache file is fresh enough, so read from it $notifier_data = get_option($db_cache_field); } // Let's see if the $xml data was returned as we expected it to. // If it didn't, use the default 1.0 as the latest version so that we don't have problems when the remote server hosting the XML file is down if (strpos((string) $notifier_data, '<notifier>') === false) { $notifier_data = '<?xml version="1.0" encoding="UTF-8"?><notifier><latest>1.0</latest><changelog></changelog></notifier>'; } // Load the remote XML data into a variable and return it $xml = simplexml_load_string($notifier_data); return $xml; }
function themerex_compose_styles() { global $wp_styles, $concatenate_scripts, $compress_css, $THEMEREX_styles_collector; if (is_admin() || get_theme_option('debug_mode') == 'yes' || get_theme_option('compose_scripts') != 'yes' || !is_object($wp_styles)) { return; } //$concatenate_scripts = $compress_css = true; $theme_dir = get_template_directory(); $theme_url = get_template_directory_uri(); $child_dir = get_stylesheet_directory(); $child_url = get_stylesheet_directory_uri(); foreach ($wp_styles->queue as $style) { $dir = $url = ''; if (themerex_strpos($wp_styles->registered[$style]->src, $child_url) === 0) { $dir = $child_dir; $url = $child_url; } else { if (themerex_strpos($wp_styles->registered[$style]->src, $theme_url) === 0) { $dir = $theme_dir; $url = $theme_url; } } if (isset($wp_styles->registered[$style]) && $dir != '' && themerex_strpos($wp_styles->registered[$style]->ver, 'no-compose') === false) { $dir = dirname($wp_styles->registered[$style]->src) . '/'; if (file_exists($file = $dir . themerex_substr($wp_styles->registered[$style]->src, themerex_strlen($url)))) { $css = themerex_fgc($file); if (isset($wp_styles->registered[$style]->extra['after'])) { foreach ($wp_styles->registered[$style]->extra['after'] as $add) { $css .= "\n" . $add . "\n"; } } $pos = -1; while (($pos = themerex_strpos($css, 'url(', $pos + 1)) !== false) { if (themerex_substr($css, $pos, 9) == 'url(data:') { continue; } $shift = 0; if (($ch = themerex_substr($css, $pos + 4, 1)) == '"' || $ch == "'") { $shift = 1; } $css = themerex_substr($css, 0, $pos + 4 + $shift) . $dir . themerex_substr($css, $pos + 4 + $shift); } $THEMEREX_styles_collector .= "\n" . $css . "\n"; $wp_styles->done[] = $style; } } } if ($THEMEREX_styles_collector) { echo "\n<style type=\"text/css\">\n" . $THEMEREX_styles_collector . "\n</style>\n"; } }
function import_widgets() { if (empty($this->options['file_with_widgets'])) { return; } echo '<br><b>' . __('Import Widgets ...', 'themerex') . '</b><br>'; flush(); // Register custom widgets $widgets = array(); $sidebars = get_theme_option('custom_sidebars'); if (is_array($sidebars) && count($sidebars) > 0) { foreach ($sidebars as $i => $sb) { if (trim(chop($sb)) == '') { continue; } $widgets['custom-sidebar-' . $i] = $sb; } } themerex_widgets_init($widgets); // Import widgets $widgets_txt = themerex_fgc(themerex_get_file_dir('/admin/tools/importer/data/' . $this->options['file_with_widgets'])); $data = unserialize(base64_decode($widgets_txt)); // Replace upload url in options foreach ($data as $k => $v) { foreach ($v as $k1 => $v1) { if (is_array($v1)) { foreach ($v1 as $k2 => $v2) { if (is_array($v2)) { foreach ($v2 as $k3 => $v3) { $v2[$k3] = $this->replace_uploads($v3); } $v1[$k2] = $v2; } else { $v1[$k2] = $this->replace_uploads($v2); } } $v[$k1] = $v1; } else { $v[$k1] = $this->replace_uploads($v1); } } update_option($k, $v); } }
function import_sliders() { // Royal Sliders if (!empty($this->options['file_with_royal_sliders'])) { echo '<br><b>' . __('Import Royal sliders ...', 'themerex') . '</b><br>'; flush(); global $wpdb; $sliders_txt = themerex_fgc(themerex_get_file_dir('/admin/tools/importer/data/' . $this->options['file_with_royal_sliders'])); $data = unserialize(base64_decode($sliders_txt)); if (is_array($data) && count($data) > 0) { foreach ($data as $slider => $slides) { if ($slider == 'royal') { $values = ''; $fields = ''; foreach ($slides as $slide) { $f = ''; $v = ''; foreach ($slide as $field => $value) { $f .= ($f ? ',' : '') . "'" . $field . "'"; $v .= ($v ? ',' : '') . "'" . addslashes($value) . "'"; } if ($fields == '') { $fields = '(' . $f . ')'; } $values .= ($values ? ',' : '') . '(' . $v . ')'; } $q = "REPLACE INTO {$wpdb->prefix}new_royalsliders VALUES {$values}"; $wpdb->query($q); } } } } // Revolution Sliders if (file_exists(WP_PLUGIN_DIR . '/revslider/revslider.php')) { require_once WP_PLUGIN_DIR . '/revslider/revslider.php'; $dir = get_template_directory() . '/admin/tools/importer/data/revslider'; if (is_dir($dir)) { $hdir = @opendir($dir); if ($hdir) { echo '<br><b>' . __('Import Revolution sliders ...', 'themerex') . '</b><br>'; flush(); $slider = new RevSlider(); while (($file = readdir($hdir)) !== false) { $pi = pathinfo($dir . '/' . $file); if (substr($file, 0, 1) == '.' || is_dir($dir . '/' . $file) || $pi['extension'] != 'zip') { continue; } if ($this->debug) { printf(__('Slider "%s":', 'themerex'), $file); } if (!is_array($_FILES)) { $_FILES = array(); } $_FILES["import_file"] = array("tmp_name" => $dir . '/' . $file); $response = $slider->importSliderFromPost(); if ($response["success"] == false) { if ($this->debug) { echo ' ' . __('imported', 'themerex') . '<br>'; } } else { if ($this->debug) { echo ' ' . __('import error', 'themerex') . '<br>'; } } flush(); } @closedir($hdir); } } } else { if ($this->debug) { printf(__('Can not locate Revo plugin: %s', 'themerex'), WP_PLUGIN_DIR . '/revslider/revslider.php<br>'); flush(); } } }
function getVideoImgCode($url, $code = false) { $video_url = parse_url($url); if ($video_url['host'] == 'youtube.com' || $video_url['host'] == 'youtu.be' || $video_url['host'] == 'www.youtube.com' || $video_url['host'] == 'www.youtu.be') { if (!empty($video_url['query'])) { parse_str($video_url['query'], $args); if (!empty($args['v'])) { $you_tube_img = $args['v']; } } else { $you_tube_img = str_replace('/', '', $video_url['path']); } return $code != true ? 'http://i1.ytimg.com/vi/' . $you_tube_img . '/maxresdefault.jpg' : $you_tube_img; } else { if ($video_url['host'] == 'vimeo.com' || $video_url['host'] == 'player.vimeo.com' || $video_url['host'] == 'www.vimeo.com' || $video_url['host'] == 'www.player.vimeo.com') { if ($code != true) { $hash = unserialize(themerex_fgc("http://vimeo.com/api/v2/" . ($video_url['host'] == 'vimeo.com' ? 'video/' : '') . substr($video_url['path'], 1) . ".php")); return $hash[0]["thumbnail_large"]; } else { return str_replace(array('/video', '/'), array('', ''), $video_url['path']); } } } }
function parse($file) { $this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false; $this->authors = $this->posts = $this->term = $this->category = $this->tag = array(); $xml = xml_parser_create('UTF-8'); xml_parser_set_option($xml, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($xml, XML_OPTION_CASE_FOLDING, 0); xml_set_object($xml, $this); xml_set_character_data_handler($xml, 'cdata'); xml_set_element_handler($xml, 'tag_open', 'tag_close'); if (!xml_parse($xml, themerex_fgc($file), true)) { $current_line = xml_get_current_line_number($xml); $current_column = xml_get_current_column_number($xml); $error_code = xml_get_error_code($xml); $error_string = xml_error_string($error_code); return new WP_Error('XML_parse_error', 'There was an error when reading this WXR file', array($current_line, $current_column, $error_string)); } xml_parser_free($xml); if (!preg_match('/^\\d+\\.\\d+$/', $this->wxr_version)) { return new WP_Error('WXR_parse_error', __('This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer')); } return array('authors' => $this->authors, 'posts' => $this->posts, 'categories' => $this->category, 'tags' => $this->tag, 'terms' => $this->term, 'base_url' => $this->base_url, 'version' => $this->wxr_version); }