/** * Functionality to hook in the WordPress theme updater. Included in * PressWork but only really needed for child themes. * * @since PressWork 1.0 */ function check_for_update() { $contents = wp_remote_fopen('http://themes.bavotasan.com/?themeversion=wpt-' . THEME_CODE); if (version_compare($contents, THEME_VERSION, '>')) { return $contents; } }
function in_plugin_update_message($plugin_data, $r) { // vars $version = apply_filters('acf/get_info', 'version'); $readme = wp_remote_fopen('http://plugins.svn.wordpress.org/advanced-custom-fields/trunk/readme.txt'); $regexp = '/== Changelog ==(.*)= ' . $version . ' =/sm'; $o = ''; // validate if (!$readme) { return; } // regexp preg_match($regexp, $readme, $matches); if (!isset($matches[1])) { return; } // render changelog $changelog = explode('*', $matches[1]); array_shift($changelog); if (!empty($changelog)) { $o .= '<div class="acf-plugin-update-info">'; $o .= '<h3>' . __("What's new", 'acf') . '</h3>'; $o .= '<ul>'; foreach ($changelog as $item) { $item = explode('http', $item); $o .= '<li>' . $item[0]; if (isset($item[1])) { $o .= '<a href="http' . $item[1] . '" target="_blank">' . __("credits", 'acf') . '</a>'; } $o .= '</li>'; } $o .= '</ul></div>'; } echo $o; }
function woo_vm_status_widget() { $vl_plugins = array(); if ($check = wp_remote_fopen('http://www.visser.com.au/?woo_vm_data')) { $raw_plugins = explode('<br />', $check); foreach ($raw_plugins as $raw_plugin) { $raw_plugin = explode('@', $raw_plugin); $vl_plugins[] = array('name' => $raw_plugin[1], 'version' => $raw_plugin[3], 'url' => $raw_plugin[5]); } } if ($wp_plugins = get_plugins()) { foreach ($wp_plugins as $wp_plugin) { if ($wp_plugin['Author'] == 'Visser Labs') { if ($vl_plugins) { $size = count($vl_plugins); for ($i = 0; $i < $size; $i++) { if ($vl_plugins[$i]['name'] == $wp_plugin['Name']) { $vl_plugins[$i]['name'] = str_replace('WooCommerce - ', '', $vl_plugins[$i]['name']); $vl_plugins[$i]['installed'] = true; if (version_compare(strval($vl_plugins[$i]['version']), strval($wp_plugin['Version']), '>') == 1) { $wp_plugins_update = true; $vl_plugins[$i]['version_existing'] = $wp_plugin['Version']; } if (strval($wp_plugin['Version']) > strval($vl_plugins[$i]['version'])) { $vl_plugins[$i]['version_beta'] = $wp_plugin['Version']; } } } } } } } include_once WOO_CD_PATH . 'templates/admin/woocommerce-admin_dashboard_vm-plugins.php'; }
function widget($args, $instance) { extract($args, EXTR_SKIP); $title = empty($instance['title']) ? ' ' : apply_filters('widget_title', $instance['title']); $username = $instance['username']; $limit = $instance['number']; $link = $instance['link']; echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } $feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=" . $limit; $twitterFeed = wp_remote_fopen($feed); $this->pw_parse_feed($twitterFeed); ?> <p class="clear"><a href="http://twitter.com/<?php echo $username; ?> "><?php echo $link; ?> </a></p> <?php echo $after_widget; }
function in_plugin_update_message($plugin_data, $r) { // vars $readme = wp_remote_fopen(str_replace('/info/', '/trunk/readme.txt', $this->settings['remote'])); $regexp = '/== Changelog ==(.*)= ' . $this->get_version() . ' =/sm'; $o = ''; // validate if (!$readme) { return; } // regexp preg_match($regexp, $readme, $matches); if (!isset($matches[1])) { return; } // add style $o .= '<style type="text/css">'; $o .= '#advanced-custom-fields-options-page + .plugin-update-tr .update-message { background: #EAF2FA; border: #C7D7E2 solid 1px; padding: 10px; }'; $o .= '</style>'; // render changelog $changelog = explode('*', $matches[1]); array_shift($changelog); if (!empty($changelog)) { $o .= '<div class="acf-plugin-update-info">'; $o .= '<h3>' . __("What's new", 'acf') . '</h3>'; $o .= '<ul>'; foreach ($changelog as $item) { $o .= '<li>' . make_clickable($item) . '</li>'; } $o .= '</ul></div>'; } echo $o; }
function image_to_base64($image_url) { $type = pathinfo($image_url, PATHINFO_EXTENSION); $data = wp_remote_fopen($image_url); $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data); return $base64; }
function create_data() { $svg_file = find_file($this->paths['tempdir'], '.svg'); $return = array(); if (empty($svg_file)) { zn_delete_folder($this->paths['tempdir']); $return['message'] = 'The zip did not contained any svg files.'; } $file_data = wp_remote_fopen(trailingslashit($this->paths['tempurl']) . $svg_file); if (!is_wp_error($file_data) && !empty($file_data)) { $xml = simplexml_load_string($file_data); $font_attr = $xml->defs->font->attributes(); $this->font_name = (string) $font_attr['id']; $icon_list = array(); $glyphs = $xml->defs->font->children(); $class = ''; foreach ($glyphs as $item => $glyph) { if ($item == 'glyph') { $attributes = $glyph->attributes(); $unicode = (string) $attributes['unicode']; $d = (string) $attributes['d']; if ($class != 'hidden' && !empty($d)) { $unicode_key = trim(json_encode($unicode), '\\\\"'); if ($item == 'glyph' && !empty($unicode_key) && trim($unicode_key) != '') { $icon_list[$this->font_name][$unicode_key] = $unicode_key; } } } } if (!empty($icon_list) && !empty($this->font_name)) { $icon_list_file = fopen($this->paths['tempdir'] . '/icon_list.php', 'w'); if ($icon_list_file) { fwrite($icon_list_file, '<?php $icons = array();'); foreach ($icon_list[$this->font_name] as $unicode) { if (!empty($unicode)) { $delimiter = "'"; if (strpos($unicode, "'") !== false) { $delimiter = '"'; } fwrite($icon_list_file, "\r\n" . '$icons[\'' . $this->font_name . '\'][' . $delimiter . $unicode . $delimiter . '] = ' . $delimiter . $unicode . $delimiter . ';'); } } fclose($icon_list_file); } else { zn_delete_folder($this->paths['tempdir']); $return['message'] = 'There was a problem creating the icon list file'; return; } // RENAME ALL FILES SO WE CAN LOAD THEM BY FONT NAME $this->rename_files(); // RENAME THE FOLDER WITH THE FONT NAME $this->rename_folder(); // ADD FONT DATA TO FONT OPTION $this->add_font_data(); } } else { $return['message'] = 'The svg file could not be opened.'; } return $return; }
function rssmi_plugin_update_info() { if (rssmi_remoteFileExists("http://www.allenweiss.com/a/plugin-updates.txt") === True) { $info = wp_remote_fopen("http://www.allenweiss.com/a/plugin-updates.txt"); echo '<br />' . strip_tags($info, "<br><a><b><i><span>"); } }
function process_before($code, $target) { // Determine what we are passing to: local URL, remote URL, file if (substr($target, 0, 7) == 'http://' || substr($target, 0, 8) == 'https://') { echo @wp_remote_fopen($target); } else { if (substr($target, 0, 7) == 'file://') { $parts = explode('?', substr($target, 7)); if (count($parts) > 1) { // Put parameters into the environment $args = explode('&', $parts[1]); if (count($args) > 0) { foreach ($args as $arg) { $tmp = explode('=', $arg); if (count($tmp) == 1) { $_GET[$arg] = ''; } else { $_GET[$tmp[0]] = $tmp[1]; } } } } include $parts[0]; exit; } else { $_SERVER['REQUEST_URI'] = $target; if (strpos($target, '?')) { $_SERVER['QUERY_STRING'] = substr($target, strpos($target, '?') + 1); parse_str($_SERVER['QUERY_STRING'], $_GET); } } } return true; }
public function __construct($manifest_path) { if (file_exists($manifest_path)) { $this->manifest = json_decode(wp_remote_fopen($manifest_path), true); } else { $this->manifest = array(); } }
function request($api_key) { $url = "http://www.123contactform.com/wp_dispatcher.php"; $res = wp_remote_fopen("{$url}?api_key=" . $api_key); if ($res === false) { return false; } return json_decode($res); }
function dw_get_gfonts() { $fontsSeraliazed = wp_remote_fopen(get_template_directory_uri() . '/inc/font/gfonts_v2.txt'); $fontArray = unserialize(trim($fontsSeraliazed)); if (!empty($fontArray)) { return $fontArray->items; } return array(); }
function get_remote_version($name) { $checkfile = 'http://trac.landryonline.com/trac.fcgi/export/head/' . $name . '/trunk/check.chk'; $status = array(); $vcheck = wp_remote_fopen($checkfile); if ($vcheck) { $status = explode('@', $vcheck); return $status; } }
/** * Helper function to fetch games data from vmidag.se. */ function _vmidag_get_games_data() { $data = wp_cache_get('games.json', 'vmidag'); if (empty($data)) { $contents = wp_remote_fopen('http://www.vmidag.se/games.json'); $data = json_decode($contents); wp_cache_set('games.json', $data, 'vmidag'); } return $data; }
function skype_status_check($skypeid=false, $format=".txt") { if (!$skypeid) return 'error'; $tmp = wp_remote_fopen('http://mystatus.skype.com/'.$skypeid.$format); if (!$tmp) return 'error'; else $contents = str_replace("\n", "", $tmp); if ($contents!="") return $contents; else return 'error'; }
public function output() { echo $this->element_before(); $defaults_value = array('family' => 'Arial', 'variant' => 'regular', 'font' => 'websafe'); $default_variants = apply_filters('zels_websafe_fonts_variants', array('regular', 'italic', '700', '700italic', 'inherit')); $websafe_fonts = apply_filters('zels_websafe_fonts', array('Arial', 'Arial Black', 'Comic Sans MS', 'Impact', 'Lucida Sans Unicode', 'Tahoma', 'Trebuchet MS', 'Verdana', 'Courier New', 'Lucida Console', 'Georgia, serif', 'Palatino Linotype', 'Times New Roman')); $value = wp_parse_args($this->element_value(), $defaults_value); $family_value = $value['family']; $variant_value = $value['variant']; $is_variant = isset($this->field['variant']) && $this->field['variant'] === false ? false : true; $is_chosen = isset($this->field['chosen']) && $this->field['chosen'] === false ? '' : 'chosen '; $google_json = json_decode(wp_remote_fopen(ZELS_URI . '/fields/typography/google-fonts.json')); $chosen_rtl = is_rtl() && !empty($is_chosen) ? 'chosen-rtl ' : ''; if (!empty($google_json)) { $googlefonts = array(); foreach ($google_json->items as $key => $font) { $googlefonts[$font->family] = $font->variants; } $is_google = array_key_exists($family_value, $googlefonts) ? true : false; echo '<label class="zels-typography-family">'; echo '<select name="' . $this->element_name('[family]') . '" class="' . $is_chosen . $chosen_rtl . 'zels-typo-family" data-atts="family"' . $this->element_attributes() . '>'; do_action('zels_typography_family', $family_value, $this); echo '<optgroup label="' . __('Web Safe Fonts', ZELS_TEXTDOMAIN) . '">'; foreach ($websafe_fonts as $websafe_value) { echo '<option value="' . $websafe_value . '" data-variants="' . implode('|', $default_variants) . '" data-type="websafe"' . selected($websafe_value, $family_value, true) . '>' . $websafe_value . '</option>'; } echo '</optgroup>'; echo '<optgroup label="' . __('Google Fonts', ZELS_TEXTDOMAIN) . '">'; foreach ($googlefonts as $google_key => $google_value) { echo '<option value="' . $google_key . '" data-variants="' . implode('|', $google_value) . '" data-type="google"' . selected($google_key, $family_value, true) . '>' . $google_key . '</option>'; } echo '</optgroup>'; echo '</select>'; echo '</label>'; if (!empty($is_variant)) { $variants = $is_google ? $googlefonts[$family_value] : $default_variants; $variants = $value['font'] === 'google' || $value['font'] === 'websafe' ? $variants : array('regular'); echo '<label class="zels-typography-variant">'; echo '<select name="' . $this->element_name('[variant]') . '" class="' . $is_chosen . $chosen_rtl . 'zels-typo-variant" data-atts="variant">'; foreach ($variants as $variant) { echo '<option value="' . $variant . '"' . $this->checked($variant_value, $variant, 'selected') . '>' . $variant . '</option>'; } echo '</select>'; echo '</label>'; } echo '<input type="text" name="' . $this->element_name('[font]') . '" class="zels-typo-font hidden" data-atts="font" value="' . $value['font'] . '" />'; } else { _e('Error! Can not load json file.', ZELS_TEXTDOMAIN); } echo $this->element_after(); }
function getTwitFeedburnCount($username, $type) { if ($type == "feedburner") { $option_name = 'gazpo_feedburner_counter'; } elseif ($type == "twitter") { $option_name = 'gazpo_twitter_counter'; } $current_time = time(); $last_update_time = get_option("gazpo_social_counter_update_time"); if (empty($last_update_time)) { $timestamp = strtotime('31-12-2011'); //set an old time. update_option('gazpo_social_counter_update_time', $timestamp); } $difference = ($current_time - $last_update_time) / 86400; if ($difference >= 4) { // if difference is 4 days or more if ($type == "feedburner") { $feedburner_count = 0; //set initial value $date = date('Y-m-d', strtotime('-4 days')); //average subscribers in last 4 days $data = wp_remote_fopen("http://feedburner.google.com/api/awareness/1.0/GetFeedData?uri=" . $username . "&dates=" . $date . "," . $date); if ($data) { preg_match('/circulation=\\"([0-9]+)\\"/', $data, $match); if ($match[1] != 0) { $feedburner_count = $match[1]; } } $total = $feedburner_count; //return subscribers count } elseif ($type == "twitter") { $twitter_count = 0; //set initial value $data = wp_remote_fopen('http://twitter.com/users/show/' . $username); preg_match('/followers_count>(.*)</', $data, $match); if ($match[1] != 0) { $twitter_count = $match[1]; } $total = $twitter_count; //return followers count } if ($total > 0) { update_option($option_name, $total); } return strval($total); } else { $total = get_option($option_name); return strval($total); } }
function zels_get_icons() { $jsons = glob(ZELS_DIR . '/fields/icon/*.json'); if (!empty($jsons)) { foreach ($jsons as $path) { $object = json_decode(wp_remote_fopen(ZELS_URI . '/fields/icon/' . basename($path))); echo count($jsons) >= 2 ? '<h4 class="zels-icon-title">' . $object->name . '</h4>' : ''; foreach ($object->icons as $icon) { echo '<a class="zels-icon-tooltip" data-icon="' . $icon . '" data-title="' . $icon . '"><span class="zels-icon zels-selector"><i class="' . $icon . '"></i></span></a>'; } } } do_action('zels_add_icons'); die; }
/** * CSV ShortCode * * @uses function shortcode_atts * @uses function wp_remote_fopen * * @param array $atts User-defined shortcode attributes. * @return string HTML for rendered table, or blank string if no data. */ function shortCode($atts) { $defaults = array('src' => null, 'id' => ''); $atts = shortcode_atts($defaults, $atts); // Enqueue plugin JavaScript & CSS only on pages where shortcode is used. $this->loadJsCssLibs(); // Determine .csv file source based on 'src' and 'source' attributes; default to test.csv URL. $src = $this->getCsvSource($atts); // Get contents of .CSV file as string. $file = wp_remote_fopen($src); // Parse CSV string into a multidimensional array. $rows = $this->parseCsv($file); // Render table and return HTML string. return $this->getRenderTable($rows, $atts); }
function enter_license() { global $licensing_server; if (isset($_POST["license_key"])) { ${${"GLOBALS"}["yhdawfobcwh"]} = trailingslashit(${${"GLOBALS"}["kegsmhrnrn"]}) . "?remote_key_auth=" . base64_encode($_POST["license_key"]) . "&remote_site=" . base64_encode(trailingslashit(site_url())); $cgoolndww = "licensing_string"; if (wp_remote_fopen(${$cgoolndww}) == 1) { update_option("license_key", $_POST["license_key"]); echo "Activated!"; echo "<script>document.location='/';</script>"; } else { echo "<p>Sorry the license key you entered is invalid. Please try again or contact us for help at help@magazine3.com</p>"; } } if (!check_key()) { echo "<form method=\"post\">\n Enter license key: <input type=\"text\" name=\"license_key\" /> <input type=\"submit\" name=\"validate_license_key\" value=\"Activate\" />\n </form>\n <br /> <font color=\"red\"><b>Where is my key?:</b></font> <font color=\"green\">Your license key has been sent to your registered email address or you can get the license key from <a style=\"color:blue\" href=\"http://magazine3.com/license-key\" target=\"_blank\">Magazine3.com/license-key</a></font> <br />\n <font color=\"#111\">If for some reason key is not working, Send us an email on help@magazine3.com </font><br /> "; } }
/** * Functionality to hook in the WordPress theme updater. * * This function is attached to the 'pre_set_site_transient_update_themes' filter hook. * * @since 1.0.0 */ public function check_for_update($checked_data) { if (isset($checked_data->response)) { $get_theme_info = wp_remote_fopen('https://dl.dropboxusercontent.com/u/5917529/updater.inc'); $theme_check = json_decode($get_theme_info); if ($theme_check) { $latest_version = $theme_check->{BAVOTASAN_THEME_CODE}->version; if (version_compare(BAVOTASAN_THEME_VERSION, $latest_version, '<')) { $update_data['new_version'] = $latest_version; $update_data['url'] = $theme_check->{BAVOTASAN_THEME_CODE}->url; $update_data['package'] = 'https://dl.dropboxusercontent.com/u/5917529/' . md5('wpt-' . BAVOTASAN_THEME_CODE) . '/wpt-' . BAVOTASAN_THEME_CODE . '.zip'; $checked_data->response[BAVOTASAN_THEME_FILE] = $update_data; } else { unset($checked_data->response[BAVOTASAN_THEME_FILE]); } } } return $checked_data; }
function validate($data = null) { $this->errors = array(); if (!empty($data)) { $data = empty($data[$this->model]) ? $data : $data[$this->model]; foreach ($data as $dkey => $dval) { $this->data->{$dkey} = stripslashes($dval); } extract($data, EXTR_SKIP); if (empty($title)) { $this->errors['title'] = __('Please fill in a title', $this->plugin_name); } if (empty($description)) { $this->errors['description'] = __('Please fill in a description', $this->plugin_name); } if (empty($image_url)) { $this->errors['image_url'] = __('Please specify an image', $this->plugin_name); } else { if ($image = wp_remote_fopen($image_url)) { $filename = basename($image_url); $filepath = ABSPATH . 'wp-content' . DS . 'uploads' . DS . $this->plugin_name . DS; $filefull = $filepath . $filename; if (!file_exists($filefull)) { $fh = @fopen($filefull, "w"); @fwrite($fh, $image); @fclose($fh); $name = GalleryHtmlHelper::strip_ext($filename, 'filename'); $ext = GalleryHtmlHelper::strip_ext($filename, 'ext'); $thumbfull = $filepath . $name . '-thumb.' . $ext; $smallfull = $filepath . $name . '-small.' . $ext; image_resize($filefull, $width = null, $height = 75, $crop = false, $append = 'thumb', $dest = null, $quality = 100); image_resize($filefull, $width = 50, $height = 50, $crop = true, $append = 'small', $dest = null, $quality = 100); @chmod($filefull, 0777); @chmod($thumbfull, 0777); @chmod($smallfull, 0777); } } } } else { $this->errors[] = __('No data was posted', $this->plugin_name); } return $this->errors; }
function bb_svg($atts = null) { //prar($atts); extract(shortcode_atts(array('src' => null, 'fallback' => null, 'class' => 'bb-svg', 'alt' => null, 'id' => null, 'method' => 'image', 'data' => null), $atts)); $svg = null; if ($method == null) { $method = 'image'; } if (filter_var($src, FILTER_VALIDATE_URL)) { if ($id) { $id = 'id="' . $id . '" '; } if ($class) { $class = 'class="' . $class . '" '; } if ($alt) { $alt = 'alt="' . $alt . '" '; } if ($data) { $data = 'alt="' . $data . '" '; } if ($method == 'inline') { $svg = wp_remote_fopen($src); } elseif ($method == 'image') { if (filter_var($fallback, FILTER_VALIDATE_URL)) { $fallback = 'onerror="this.onerror=null; this.src=' . $fallback . '"'; } $svg = '<img src="' . $src . '" ' . $alt . $id . $class . $fallback . $data . '>'; } elseif ($method == 'object') { if (filter_var($fallback, FILTER_VALIDATE_URL)) { $fallback = '<img src="' . $fallback . '" ' . $alt . $id . $class . $data . '>'; } if (!$fallback) { $fallback = '<img src="" alt="Your browser does not support SVG">'; } $svg = '<object type="image/svg+xml" data="' . $src . '" ' . $alt . $id . $class . $data . '>' . $fallback . '</object>'; //prar($svg); } } return $svg; }
function gold_check_plugin_version($plugin) { if (strpos(WPSC_GOLD_DIR_NAME . '/' . __FILE__, $plugin) !== false) { $checkfile = "http://getshopped.org/wp-content/uploads/wpsc/updates/wpsc_goldcart.chk"; $vcheck = wp_remote_fopen($checkfile); if ($vcheck) { $version = WPSC_GOLD_VERSION; $status = explode('@', $vcheck); $theVersion = $status[1]; $theMessage = $status[3]; if (version_compare(strval($theVersion), strval($version), '>') == 1) { echo ' <td colspan="5" class="plugin-update" style="line-height:1.2em; font-size:11px; padding:1px;"> <div style="color:#000; font-weight:bold; margin:4px; padding:6px 5px; background-color:#fffbe4; border-color:#dfdfdf; border-width:1px; border-style:solid; -moz-border-radius:5px; -khtml-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;">' . __("There is a new version of Gold Cart for WP e-Commerce available.", "gold") . ' <a href="' . $theMessage . '" target="_blank">View version ' . $theVersion . ' details</a>.</div > </td>'; } else { return; } } } }
function Registration() { if (isset($_SESSION["activated_plugin"]) && $_SESSION["activated_plugin"] == $this->slug) { $_SESSION["activated_plugin"] = ""; echo ' <div id="message" class="updated fade"> <p style="line-height:1.4em"> '; if ($this->register_message == "" || strpos($this->register_message, "%1") === false) { echo ' <strong>Please consider <a href="plugins.php?paged=' . @$_GET["paged"] . '&' . $this->slug . '=register">registering your use of ' . $this->name . '</a></strong> to tell <a href="' . $this->homepage . '">' . $this->developer . ' (the plugin maker)</a> you are using it. This sends only your site name and URL to ' . $this->developer . ' so they know where their plugin is being used. No other data is sent.'; } else { echo str_replace("%1", "plugins.php?paged=" . @$_GET["paged"] . "&" . $this->slug . "=register", $this->register_message); } echo ' </p> </div>'; } if (isset($_GET[$this->slug]) && $_GET[$this->slug] == "register") { $site = get_option("blogname"); $url = get_option("siteurl"); $register_url = trim($this->homepage, "/") . "/?plugin=" . urlencode($this->name) . "&version=" . urlencode($this->version) . "&site=" . urlencode($site) . "&url=" . urlencode($url); wp_remote_fopen($register_url); echo ' <div id="message" class="updated fade"> <p>'; if ($this->thanks_message == "") { echo ' <strong>Thank you for registering ' . $this->name . '.</strong> '; } else { echo $this->thanks_message; } echo ' </p> </div> '; } }
public function migrate() { if (isset($_POST['migrate'])) { foreach ($this->pageMap as $newUrl => $oldUrl) { $postId = url_to_postid($newUrl); $html = wp_remote_fopen('http://www.edcwc.com' . $oldUrl); $content = $this->extractText($html, '<!-- InstanceBeginEditable name="page_content" -->', '<!-- InstanceEndEditable -->'); $content = trim($content); echo "<h3>{$oldUrl}</h3>"; echo "<h4>NEW URL: {$newUrl}</h4>"; echo "<h4>POST ID: {$postId}</h4>"; echo "<textarea style='width: 90%;' readonly='readonly' rows='20'>{$content}</textarea>"; echo '<br /><br /><br /><br />'; try { /** * @var WPDB $wpdb */ global $wpdb; $result = $wpdb->query("\n\t\t\t\t\t\t\tUPDATE {$wpdb->posts}\n\t\t\t\t\t\t\tSET post_content = '" . stripslashes($content) . "'\n\t\t\t\t\t\t\tWHERE ID = {$postId}\n\t\t\t\t\t\t"); } catch (Exception $e) { echo "<strong><em>There was an error saving post# {$postId}!!</em></strong>"; } } echo '<strong><em>Done!!</em></strong>'; } else { echo <<<HTML <div class="wrap"> \t<h2>Migrate EDC Site</h2> \t<h3>Import HTML content from existing EDC site to Wordpress pages</h3> \t<p>Click below to import content.</p> \t<form method="post"> \t\t<input class="button-primary" type="submit" name="migrate" value="Migrate" /> \t</form> </div> HTML; } }
function pingback_ping($args) { global $wpdb, $wp_version; $this->escape($args); $pagelinkedfrom = $args[0]; $pagelinkedto = $args[1]; $title = ''; $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); $pagelinkedto = str_replace('&', '&', $pagelinkedto); $pagelinkedto = str_replace('&', '&', $pagelinkedto); $error_code = -1; // Check if the page linked to is in our site $pos1 = strpos($pagelinkedto, str_replace(array('http://www.', 'http://', 'https://www.', 'https://'), '', get_option('home'))); if (!$pos1) { return new IXR_Error(0, __('Is there no link to us?')); } // let's find which post is linked to // FIXME: does url_to_postid() cover all these cases already? // if so, then let's use it and drop the old code. $urltest = parse_url($pagelinkedto); if ($post_ID = url_to_postid($pagelinkedto)) { $way = 'url_to_postid()'; } elseif (preg_match('#p/[0-9]{1,}#', $urltest['path'], $match)) { // the path defines the post_ID (archives/p/XXXX) $blah = explode('/', $match[0]); $post_ID = (int) $blah[1]; $way = 'from the path'; } elseif (preg_match('#p=[0-9]{1,}#', $urltest['query'], $match)) { // the querystring defines the post_ID (?p=XXXX) $blah = explode('=', $match[0]); $post_ID = (int) $blah[1]; $way = 'from the querystring'; } elseif (isset($urltest['fragment'])) { // an #anchor is there, it's either... if (intval($urltest['fragment'])) { // ...an integer #XXXX (simpliest case) $post_ID = (int) $urltest['fragment']; $way = 'from the fragment (numeric)'; } elseif (preg_match('/post-[0-9]+/', $urltest['fragment'])) { // ...a post id in the form 'post-###' $post_ID = preg_replace('/[^0-9]+/', '', $urltest['fragment']); $way = 'from the fragment (post-###)'; } elseif (is_string($urltest['fragment'])) { // ...or a string #title, a little more complicated $title = preg_replace('/[^a-z0-9]/i', '.', $urltest['fragment']); $sql = "SELECT ID FROM {$wpdb->posts} WHERE post_title RLIKE '{$title}'"; if (!($post_ID = $wpdb->get_var($sql))) { // returning unknown error '0' is better than die()ing return new IXR_Error(0, ''); } $way = 'from the fragment (title)'; } } else { // TODO: Attempt to extract a post ID from the given URL return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); } $post_ID = (int) $post_ID; logIO("O", "(PB) URL='{$pagelinkedto}' ID='{$post_ID}' Found='{$way}'"); $post = get_post($post_ID); if (!$post) { // Post_ID not found return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); } if ($post_ID == url_to_postid($pagelinkedfrom)) { return new IXR_Error(0, __('The source URL and the target URL cannot both point to the same resource.')); } // Check if pings are on if ('closed' == $post->ping_status) { return new IXR_Error(33, __('The specified target URL cannot be used as a target. It either doesn\'t exist, or it is not a pingback-enabled resource.')); } // Let's check that the remote site didn't already pingback this entry $result = $wpdb->get_results("SELECT * FROM {$wpdb->comments} WHERE comment_post_ID = '{$post_ID}' AND comment_author_url = '{$pagelinkedfrom}'"); if ($wpdb->num_rows) { // We already have a Pingback from this URL return new IXR_Error(48, __('The pingback has already been registered.')); } // very stupid, but gives time to the 'from' server to publish ! sleep(1); // Let's check the remote site $linea = wp_remote_fopen($pagelinkedfrom); if (!$linea) { return new IXR_Error(16, __('The source URL does not exist.')); } // Work around bug in strip_tags(): $linea = str_replace('<!DOC', '<DOC', $linea); $linea = preg_replace('/[\\s\\r\\n\\t]+/', ' ', $linea); // normalize spaces $linea = preg_replace("/ <(h1|h2|h3|h4|h5|h6|p|th|td|li|dt|dd|pre|caption|input|textarea|button|body)[^>]*>/", "\n\n", $linea); preg_match('|<title>([^<]*?)</title>|is', $linea, $matchtitle); $title = $matchtitle[1]; if (empty($title)) { return new IXR_Error(32, __('We cannot find a title on that page.')); } $linea = strip_tags($linea, '<a>'); // just keep the tag we need $p = explode("\n\n", $linea); $preg_target = preg_quote($pagelinkedto); foreach ($p as $para) { if (strpos($para, $pagelinkedto) !== false) { // it exists, but is it a link? preg_match("|<a[^>]+?" . $preg_target . "[^>]*>([^>]+?)</a>|", $para, $context); // If the URL isn't in a link context, keep looking if (empty($context)) { continue; } // We're going to use this fake tag to mark the context in a bit // the marker is needed in case the link text appears more than once in the paragraph $excerpt = preg_replace('|\\</?wpcontext\\>|', '', $para); // prevent really long link text if (strlen($context[1]) > 100) { $context[1] = substr($context[1], 0, 100) . '...'; } $marker = '<wpcontext>' . $context[1] . '</wpcontext>'; // set up our marker $excerpt = str_replace($context[0], $marker, $excerpt); // swap out the link for our marker $excerpt = strip_tags($excerpt, '<wpcontext>'); // strip all tags but our context marker $excerpt = trim($excerpt); $preg_marker = preg_quote($marker); $excerpt = preg_replace("|.*?\\s(.{0,100}{$preg_marker}.{0,100})\\s.*|s", '$1', $excerpt); $excerpt = strip_tags($excerpt); // YES, again, to remove the marker wrapper break; } } if (empty($context)) { // Link to target not found return new IXR_Error(17, __('The source URL does not contain a link to the target URL, and so cannot be used as a source.')); } $pagelinkedfrom = str_replace('&', '&', $pagelinkedfrom); $context = '[...] ' . wp_specialchars($excerpt) . ' [...]'; $original_pagelinkedfrom = $pagelinkedfrom; $pagelinkedfrom = $wpdb->escape($pagelinkedfrom); $original_title = $title; $comment_post_ID = (int) $post_ID; $comment_author = $title; $this->escape($comment_author); $comment_author_url = $pagelinkedfrom; $comment_content = $context; $this->escape($comment_content); $comment_type = 'pingback'; $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_content', 'comment_type'); $comment_ID = wp_new_comment($commentdata); do_action('pingback_post', $comment_ID); return sprintf(__('Pingback from %1$s to %2$s registered. Keep the web talking! :-)'), $pagelinkedfrom, $pagelinkedto); }
function get_gfonts($what = null) { //checks if transient exists or has expired if (false == get_transient('tc_gfonts')) { $gfont_raw = @file_get_contents(dirname(dirname(__FILE__)) . "/assets/fonts/webfonts.json"); if ($gfont_raw === false) { $gfont_raw = wp_remote_fopen(dirname(dirname(__FILE__)) . "/assets/fonts/webfonts.json"); } $gfonts_decoded = json_decode($gfont_raw, true); set_transient('tc_gfonts', $gfonts_decoded, 60 * 60 * 24 * 30); } else { $gfonts_decoded = get_transient('tc_gfonts'); } $gfonts = array(); $subsets = array(); $subsets['all-subsets'] = sprintf('%1$s ( %2$s %3$s )', __('All subsets', TC_wfc::$instance->plug_lang), count($gfonts_decoded['items']) + count($this->get_cfonts()), __('fonts', TC_wfc::$instance->plug_lang)); foreach ($gfonts_decoded['items'] as $font) { foreach ($font['variants'] as $variant) { $name = str_replace(' ', '+', $font['family']); $gfonts[] = array('name' => $name . ':' . $variant, 'subsets' => $font['subsets']); } //generates subset list : subset => font number foreach ($font['subsets'] as $sub) { $subsets[$sub] = isset($subsets[$sub]) ? $subsets[$sub] + 1 : 1; } } //finalizes the subset array foreach ($subsets as $subset => $font_number) { if ('all-subsets' == $subset) { continue; } $subsets[$subset] = sprintf('%1$s ( %2$s %3$s )', $subset, $font_number, __('fonts', TC_wfc::$instance->plug_lang)); } return 'subsets' == $what ? apply_filters('tc_font_customizer_gfonts_subsets ', $subsets) : apply_filters('tc_font_customizer_gfonts', $gfonts); }
function tc_get_selector_list() { $theme_name = self::$theme_name; $path = dirname(__FILE__) . '/sets/'; //first check if option exists and get it, else create/update option if (get_option("tc_font_customizer_selectors_{$theme_name}") && !isset($_GET['wfc-refresh-selector']) && 1 == get_transient('wfc_refresh_selectors')) { //html_entity_decode for selector => fixes characters (unrecognized expression) issue in javascript $_to_return = apply_filters("tc_default_selectors_{$theme_name}", get_option("tc_font_customizer_selectors_{$theme_name}")); $_to_return = $this->_clean_selector_css($_to_return); return $_to_return; } $default_selector_settings = file_exists("{$path}{$theme_name}.json") ? @file_get_contents("{$path}{$theme_name}.json") : @file_get_contents("{$path}default.json"); if ($default_selector_settings === false) { $default_selector_settings = !wp_remote_fopen(sprintf("%s/sets/{$theme_name}.json", TC_WFC_BASE_URL)) ? wp_remote_fopen(sprintf("%s/sets/default.json", TC_WFC_BASE_URL)) : wp_remote_fopen(sprintf("%s/sets/{$theme_name}.json", TC_WFC_BASE_URL)); } $default_selector_settings = json_decode($default_selector_settings, true); $default_selector_settings = isset($default_selector_settings['default']) ? $default_selector_settings['default'] : $default_selector_settings; $property_list = $this->tc_get_property_list(); $property_list_keys = array_keys($property_list); $selector_list = array(); foreach ($default_selector_settings as $sel => $sets) { foreach ($sets as $key => $value) { $prop = $property_list_keys[$key]; switch ($prop) { case 'color-hover': if (0 === $value) { continue; } //if color-hover set to 1 then it is the main color, else there's a custom value $selector_list[$sel][$prop] = 1 === $value ? $property_list[$prop] : $value; break; default: $selector_list[$sel][$prop] = 0 === $value ? $property_list[$prop] : $value; break; } } } update_option("tc_font_customizer_selectors_{$theme_name}", $selector_list); //html_entity_decode for selector => fixes characters (unrecognized expression) issue in javascript $_to_return = apply_filters("tc_default_selectors_{$theme_name}", $selector_list); $_to_return = $this->_clean_selector_css($_to_return); //update refresh transient for 24 hours set_transient('wfc_refresh_selectors', 1, 60 * 60 * 24); return $_to_return; }
/** * Retrieve all image URLs from given URI. * * @package WordPress * @subpackage Press_This * @since 2.6.0 * * @param string $uri * @return string */ function get_images_from_uri($uri) { $uri = preg_replace('/\\/#.+?$/', '', $uri); if (preg_match('/\\.(jpe?g|jpe|gif|png)\\b/i', $uri) && !strpos($uri, 'blogger.com')) { return "'" . esc_attr(html_entity_decode($uri)) . "'"; } $content = wp_remote_fopen($uri); if (false === $content) { return ''; } $host = parse_url($uri); $pattern = '/<img ([^>]*)src=(\\"|\')([^<>\'\\"]+)(\\2)([^>]*)\\/*>/i'; $content = str_replace(array("\n", "\t", "\r"), '', $content); preg_match_all($pattern, $content, $matches); if (empty($matches[0])) { return ''; } $sources = array(); foreach ($matches[3] as $src) { // if no http in url if (strpos($src, 'http') === false) { // if it doesn't have a relative uri if (strpos($src, '../') === false && strpos($src, './') === false && strpos($src, '/') === 0) { $src = 'http://' . str_replace('//', '/', $host['host'] . '/' . $src); } else { $src = 'http://' . str_replace('//', '/', $host['host'] . '/' . dirname($host['path']) . '/' . $src); } } $sources[] = esc_url($src); } return "'" . implode("','", $sources) . "'"; }