function axiom_get_feedburner_counter($account) { $rss = get_transient("feedburnercounter"); if ($rss !== false) { return $rss; } $rss = '?'; $url = esc_url('http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=' . $account); $headers = get_headers($url); if (axiom_strpos($headers[0], '200')) { $xml = axiom_fgc($url); preg_match('/circulation="(\\d+)"/', $xml, $match); if ($match[1] != 0) { $rss = $match[1]; set_transient("feedburnercounter", $rss, 60 * 60); } } return $rss; }
function axiom_get_latest_theme_version($interval) { global $AXIOM_GLOBALS; $notifier_file_url = $AXIOM_GLOBALS['update_notifier_options']['xml_url'] . $AXIOM_GLOBALS['update_notifier_options']['theme_folder']; $db_cache_field = 'axiom_notifier_cache'; $db_cache_field_last_updated = 'axiom_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 = axiom_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 import_essgrids() { if (axiom_exists_essgrids()) { $dir = axiom_get_folder_dir($this->options['folder_with_essgrids']); if (is_dir($dir)) { $hdir = @opendir($dir); if ($hdir) { echo '<br><b>' . __('Import Essential Grids ...', 'axiom') . '</b><br>'; flush(); while (($file = readdir($hdir)) !== false) { $pi = pathinfo($dir . '/' . $file); if (substr($file, 0, 1) == '.' || is_dir($dir . '/' . $file) || $pi['extension'] != 'json') { continue; } if ($this->options['debug']) { printf(__('Ess.Grid "%s":', 'axiom'), $file); } try { $im = new Essential_Grid_Import(); $data = json_decode(axiom_fgc($dir . '/' . $file), true); // Prepare arrays with overwrite flags $tmp = array(); foreach ($data as $k => $v) { if ($k == 'grids') { $name = 'grids'; $name_1 = 'grid'; $name_id = 'id'; } else { if ($k == 'skins') { $name = 'skins'; $name_1 = 'skin'; $name_id = 'id'; } else { if ($k == 'elements') { $name = 'elements'; $name_1 = 'element'; $name_id = 'id'; } else { if ($k == 'navigation-skins') { $name = 'navigation-skins'; $name1 = 'nav-skin'; $name_id = 'id'; } else { if ($k == 'punch-fonts') { $name = 'punch-fonts'; $name1 = 'punch-fonts'; $name_id = 'handle'; } else { if ($k == 'custom-meta') { $name = 'custom-meta'; $name1 = 'custom-meta'; $name_id = 'handle'; } } } } } } if ($k == 'global-css') { $tmp['import-global-styles'] = "on"; $tmp['global-styles-overwrite'] = "append"; } else { $tmp['import-' . $name] = "true"; $tmp['import-' . $name . '-' . $name_id] = array(); foreach ($v as $v1) { $tmp['import-' . $name . '-' . $name_id][] = $v1[$name_id]; $tmp[$name_1 . '-overwrite-' . $name_id] = 'append'; } } } $im->set_overwrite_data($tmp); //set overwrite data global to class $skins = @$data['skins']; if (!empty($skins) && is_array($skins)) { $skins_ids = @$tmp['import-skins-id']; $skins_imported = $im->import_skins($skins, $skins_ids); } $navigation_skins = @$data['navigation-skins']; if (!empty($navigation_skins) && is_array($navigation_skins)) { $navigation_skins_ids = @$tmp['import-navigation-skins-id']; $navigation_skins_imported = $im->import_navigation_skins(@$navigation_skins, $navigation_skins_ids); } $grids = @$data['grids']; if (!empty($grids) && is_array($grids)) { $grids_ids = @$tmp['import-grids-id']; $grids_imported = $im->import_grids($grids, $grids_ids); } $elements = @$data['elements']; if (!empty($elements) && is_array($elements)) { $elements_ids = @$tmp['import-elements-id']; $elements_imported = $im->import_elements(@$elements, $elements_ids); } $custom_metas = @$data['custom-meta']; if (!empty($custom_metas) && is_array($custom_metas)) { $custom_metas_handle = @$tmp['import-custom-meta-handle']; $custom_metas_imported = $im->import_custom_meta($custom_metas, $custom_metas_handle); } $custom_fonts = @$data['punch-fonts']; if (!empty($custom_fonts) && is_array($custom_fonts)) { $custom_fonts_handle = @$tmp['import-punch-fonts-handle']; $custom_fonts_imported = $im->import_punch_fonts($custom_fonts, $custom_fonts_handle); } if (@$tmp['import-global-styles'] == 'on') { $global_css = @$data['global-css']; $global_styles_imported = $im->import_global_styles($tglobal_css); } if ($this->options['debug']) { echo ' ' . __('imported', 'axiom') . '<br>'; } } catch (Exception $d) { if ($this->options['debug']) { echo ' ' . __('import error:', 'axiom') . '<br>' . dumpVar($response); } } flush(); break; } @closedir($hdir); } } } else { if ($this->options['debug']) { printf(__('Can not locate Essential Grid plugin: %s', 'axiom'), EG_PLUGIN_PATH . '/essential-grid.php<br>'); flush(); } } }
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, axiom_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); }