Ejemplo n.º 1
0
 protected function makeRequest($url, $params, $ch = null)
 {
     $http = _wp_http_get_object();
     $args = array();
     $args['method'] = 'POST';
     $args['body'] = http_build_query($params, null, '&');
     // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
     // for 2 seconds if the server does not support this header.
     $opts = self::$CURL_OPTS;
     if (isset($opts[CURLOPT_HTTPHEADER])) {
         $existing_headers = $opts[CURLOPT_HTTPHEADER];
         $existing_headers[] = 'Expect:';
         $opts[CURLOPT_HTTPHEADER] = $existing_headers;
     } else {
         $opts[CURLOPT_HTTPHEADER] = array('Expect:');
     }
     $args['headers'] = $opts[CURLOPT_HTTPHEADER];
     $args['sslverify'] = false;
     $args['timeout'] = $opts[CURLOPT_CONNECTTIMEOUT] * 1000;
     $result = $http->request($url, $args);
     if (is_wp_error($result)) {
         throw new SpFacebookApiException(array('error_code' => (int) $result->get_error_code(), 'error' => array('message' => $result->get_error_message(), 'type' => 'WP_Error')));
     }
     return $result['body'];
 }
Ejemplo n.º 2
0
 /**
  * @ticket 37768
  */
 public function test_normalize_cookies_scalar_values()
 {
     $http = _wp_http_get_object();
     $cookies = array('x' => 'foo', 'y' => 2, 'z' => 0.45, 'foo' => array('bar'));
     $cookie_jar = $http->normalize_cookies(array('x' => 'foo', 'y' => 2, 'z' => 0.45, 'foo' => array('bar')));
     $this->assertInstanceOf('Requests_Cookie_Jar', $cookie_jar);
     foreach (array_keys($cookies) as $cookie) {
         if ('foo' === $cookie) {
             $this->assertFalse(isset($cookie_jar[$cookie]));
         } else {
             $this->assertInstanceOf('Requests_Cookie', $cookie_jar[$cookie]);
         }
     }
 }
 function sparkpostSend()
 {
     $this->edebug('Preparing request data');
     $data = array('method' => 'POST', 'timeout' => 15, 'headers' => $this->get_request_headers(), 'body' => json_encode($this->get_request_body()));
     $http = apply_filters('wpsp_get_http_lib', _wp_http_get_object());
     $this->edebug(sprintf('Request headers: %s', print_r($this->get_request_headers(true), true)));
     $this->edebug(sprintf('Request body: %s', $data['body']));
     $this->edebug(sprintf('Making HTTP POST request to %s', $this->endpoint));
     do_action('wpsp_before_send', $this->endpoint, $data);
     $result = $http->request($this->endpoint, $data);
     do_action('wpsp_after_send', $result);
     $this->edebug('Response received');
     $result = apply_filters('wpsp_handle_response', $result);
     if (is_bool($result)) {
         // it means, response been already processed by the hooked filter. so just return the value.
         $this->edebug('Skipping response processing');
         return $result;
     } else {
         return $this->handle_response($result);
     }
 }
Ejemplo n.º 4
0
/**
 * Retrieve the raw response from the HTTP request using the HEAD method.
 *
 * @see wp_remote_request() For more information on the response array format.
 *
 * @since 2.7.0
 *
 * @param string $url Site URL to retrieve.
 * @param array $args Optional. Override the defaults.
 * @return WP_Error|array The response or WP_Error on failure.
 */
function wp_remote_head($url, $args = array())
{
    $objFetchSite = _wp_http_get_object();
    return $objFetchSite->head($url, $args);
}
 function upgrader_extension_pre_download_filter($reply, $package, $upgrader)
 {
     global $wp_filesystem;
     $option = get_option($this->option_key);
     $current_theme_name = "";
     if (isset($upgrader->skin->theme_info)) {
         $current_theme_name = $upgrader->skin->theme_info->get('Name');
     } else {
         return false;
     }
     if (is_array($option) && isset($option['data']['extensions']) && is_array($option['data']['extensions'])) {
         foreach ($option['data']['extensions'] as $key => $response) {
             //find extensions in updater
             if ($key == $current_theme_name && isset($response['rw_extension']) && $response['rw_extension'] == true) {
                 $upgrade_folder = $wp_filesystem->wp_content_dir() . 'upgrade/';
                 if (is_array($package)) {
                     $package = $package[0];
                 }
                 $http = _wp_http_get_object();
                 $http_response = $http->get($package);
                 if ($http_response['response']['code'] == '500') {
                     return false;
                 }
                 $fname = $wp_filesystem->wp_content_dir() . basename($package);
                 $file = fopen($fname, 'w+');
                 // Create a new file, or overwrite the existing one.
                 fwrite($file, $http_response['body']);
                 fclose($file);
                 return $fname;
             }
         }
     }
     return false;
 }
    function display_feedfinder()
    {
        global $wpdb;
        $lookup = isset($_REQUEST['lookup']) ? $_REQUEST['lookup'] : NULL;
        $auth = FeedWordPress::param('link_rss_auth_method');
        $username = FeedWordPress::param('link_rss_username');
        $password = FeedWordPress::param('link_rss_password');
        $credentials = array("authentication" => $auth, "username" => $username, "password" => $password);
        $feeds = array();
        $feedSwitch = false;
        $current = null;
        if ($this->for_feed_settings()) {
            // Existing feed?
            $feedSwitch = true;
            if (is_null($lookup)) {
                // Switch Feed without a specific feed yet suggested
                // Go to the human-readable homepage to look for
                // auto-detection links
                $lookup = $this->link->link->link_url;
                $auth = $this->link->setting('http auth method');
                $username = $this->link->setting('http username');
                $password = $this->link->setting('http password');
                // Guarantee that you at least have the option to
                // stick with what works.
                $current = $this->link->link->link_rss;
                $feeds[] = $current;
            }
            $name = esc_html($this->link->link->link_name);
        } else {
            // Or a new subscription to add?
            $name = "Subscribe to <code>" . esc_html(feedwordpress_display_url($lookup)) . "</code>";
        }
        ?>
		<div class="wrap" id="feed-finder">
		<h2>Feed Finder: <?php 
        echo $name;
        ?>
</h2>

		<?php 
        if ($feedSwitch) {
            $this->display_alt_feed_box($lookup);
        }
        $finder = array();
        if (!is_null($current)) {
            $finder[$current] = new FeedFinder($current);
        }
        $finder[$lookup] = new FeedFinder($lookup);
        foreach ($finder as $url => $ff) {
            $feeds = array_merge($feeds, $ff->find(NULL, $credentials));
        }
        $feeds = array_values($feeds);
        if (count($feeds) > 0) {
            if ($feedSwitch) {
                ?>
				<h3>Feeds Found</h3>
				<?php 
            }
            if (count($feeds) > 1) {
                $option_template = 'Option %d: ';
                $form_class = ' class="multi"';
                ?>
				<p><strong>This web page provides at least <?php 
                print count($feeds);
                ?>
 different feeds.</strong> These feeds may provide the same information
				in different formats, or may track different items. (You can check the Feed Information and the
				Sample Item for each feed to get an idea of what the feed provides.) Please select the feed that you'd like to subscribe to.</p>
				<?php 
            } else {
                $option_template = '';
                $form_class = '';
            }
            global $fwp_credentials;
            foreach ($feeds as $key => $f) {
                $ofc = $fwp_credentials;
                $fwp_credentials = $credentials;
                // Set
                $pie = FeedWordPress::fetch($f);
                $fwp_credentials = $ofc;
                // Re-Set
                $rss = is_wp_error($pie) ? $pie : new MagpieFromSimplePie($pie);
                if ($this->url_for_401($pie)) {
                    $this->display_alt_feed_box($lookup, array("err" => $pie, "auth" => $auth, "username" => $username, "password" => $password));
                    continue;
                }
                if ($rss and !is_wp_error($rss)) {
                    $feed_link = isset($rss->channel['link']) ? $rss->channel['link'] : '';
                    $feed_title = isset($rss->channel['title']) ? $rss->channel['title'] : $feed_link;
                    $feed_type = $rss->feed_type ? $rss->feed_type : 'Unknown';
                    $feed_version_template = '%.1f';
                    $feed_version = $rss->feed_version;
                } else {
                    // Give us some sucky defaults
                    $feed_title = feedwordpress_display_url($lookup);
                    $feed_link = $lookup;
                    $feed_type = 'Unknown';
                    $feed_version_template = '';
                    $feed_version = '';
                }
                ?>
					<form<?php 
                print $form_class;
                ?>
 action="admin.php?page=<?php 
                print $GLOBALS['fwp_path'];
                ?>
/syndication.php" method="post">
					<div class="inside"><?php 
                FeedWordPressCompatibility::stamp_nonce('feedwordpress_switchfeed');
                ?>

					<?php 
                $classes = array('feed-found');
                $currentFeed = '';
                if (!is_null($current) and $current == $f) {
                    $classes[] = 'current';
                    $currentFeed = ' (currently subscribed)';
                }
                if ($key % 2) {
                    $classes[] = 'alt';
                }
                ?>
					<fieldset class="<?php 
                print implode(" ", $classes);
                ?>
">
					<legend><?php 
                printf($option_template, $key + 1);
                print $feed_type . " ";
                printf($feed_version_template, $feed_version);
                ?>
 feed<?php 
                print $currentFeed;
                ?>
</legend>

					<?php 
                $this->stamp_link_id();
                // No feed specified = add new feed; we
                // need to pass along a starting title
                // and homepage URL for the new Link.
                if (!$this->for_feed_settings()) {
                    ?>
						<input type="hidden" name="feed_title" value="<?php 
                    echo esc_html($feed_title);
                    ?>
" />
						<input type="hidden" name="feed_link" value="<?php 
                    echo esc_html($feed_link);
                    ?>
" />
						<?php 
                }
                ?>

					<input type="hidden" name="feed" value="<?php 
                echo esc_html($f);
                ?>
" />
					<input type="hidden" name="action" value="switchfeed" />

					<div>
					<div class="feed-sample">
					<?php 
                $link = NULL;
                $post = NULL;
                if (!is_wp_error($rss) and count($rss->items) > 0) {
                    // Prepare to display Sample Item
                    $link = new MagpieMockLink(array('simplepie' => $pie, 'magpie' => $rss), $f);
                    $post = new SyndicatedPost(array('simplepie' => $rss->originals[0], 'magpie' => $rss->items[0]), $link);
                    ?>
						<h3>Sample Item</h3>
						<ul>
						<li><strong>Title:</strong> <a href="<?php 
                    echo $post->post['meta']['syndication_permalink'];
                    ?>
"><?php 
                    echo $post->post['post_title'];
                    ?>
</a></li>
						<li><strong>Date:</strong> <?php 
                    print date('d-M-y g:i:s a', $post->published());
                    ?>
</li>
						</ul>
						<div class="entry">
						<?php 
                    print $post->post['post_content'];
                    ?>
						</div>
						<?php 
                    do_action('feedwordpress_feed_finder_sample_item', $f, $post, $link);
                } else {
                    if (is_wp_error($rss)) {
                        print '<div class="feed-problem">';
                        print "<h3>Problem:</h3>\n";
                        print "<p>FeedWordPress encountered the following error\n\t\t\t\t\t\t\twhen trying to retrieve this feed:</p>";
                        print '<p style="margin: 1.0em 3.0em"><code>' . $rss->get_error_message() . '</code></p>';
                        print "<p>If you think this is a temporary problem, you can still force FeedWordPress to add the subscription. FeedWordPress will not be able to find any syndicated posts until this problem is resolved.</p>";
                        print "</div>";
                    }
                    ?>
						<h3>No Items</h3>
						<p>FeedWordPress found no posts on this feed.</p>
						<?php 
                }
                ?>
					</div>
	
					<div>
					<h3>Feed Information</h3>
					<ul>
					<li><strong>Homepage:</strong> <a href="<?php 
                echo $feed_link;
                ?>
"><?php 
                echo is_null($feed_title) ? '<em>Unknown</em>' : $feed_title;
                ?>
</a></li>
					<li><strong>Feed URL:</strong> <a title="<?php 
                echo esc_html($f);
                ?>
" href="<?php 
                echo esc_html($f);
                ?>
"><?php 
                echo esc_html(feedwordpress_display_url($f, 40, 10));
                ?>
</a> (<a title="Check feed &lt;<?php 
                echo esc_html($f);
                ?>
&gt; for validity" href="http://feedvalidator.org/check.cgi?url=<?php 
                echo urlencode($f);
                ?>
">validate</a>)</li>
					<li><strong>Encoding:</strong> <?php 
                echo isset($rss->encoding) ? esc_html($rss->encoding) : "<em>Unknown</em>";
                ?>
</li>
					<li><strong>Description:</strong> <?php 
                echo isset($rss->channel['description']) ? esc_html($rss->channel['description']) : "<em>Unknown</em>";
                ?>
</li>
					</ul>
					<?php 
                $this->display_authentication_credentials_box(array('username' => $username, 'password' => $password, 'method' => $auth));
                ?>
					<?php 
                do_action('feedwordpress_feedfinder_form', $f, $post, $link, $this->for_feed_settings());
                ?>
					<div class="submit"><input type="submit" class="button-primary" name="Use" value="&laquo; Use this feed" />
					<input type="submit" class="button" name="Cancel" value="× Cancel" /></div>
					</div>
					</div>
					</fieldset>
					</div> <!-- class="inside" -->
					</form>
					<?php 
                unset($link);
                unset($post);
            }
        } else {
            foreach ($finder as $url => $ff) {
                $url = esc_html($url);
                print "<h3>Searched for feeds at {$url}</h3>\n";
                print "<p><strong>" . __('Error') . ":</strong> " . __("FeedWordPress couldn't find any feeds at") . ' <code><a href="' . htmlspecialchars($lookup) . '">' . htmlspecialchars($lookup) . '</a></code>';
                print ". " . __('Try another URL') . ".</p>";
                // Diagnostics
                print "<div class=\"updated\" style=\"margin-left: 3.0em; margin-right: 3.0em;\">\n";
                print "<h3>" . __('Diagnostic information') . "</h3>\n";
                if (!is_null($ff->error()) and strlen($ff->error()) > 0) {
                    print "<h4>" . __('HTTP request failure') . "</h4>\n";
                    print "<p>" . $ff->error() . "</p>\n";
                } else {
                    print "<h4>" . __('HTTP request completed') . "</h4>\n";
                    print "<p><strong>Status " . $ff->status() . ":</strong> " . $this->HTTPStatusMessages[(int) $ff->status()] . "</p>\n";
                }
                // Do some more diagnostics if the API for it is available.
                if (function_exists('_wp_http_get_object')) {
                    $httpObject = _wp_http_get_object();
                    if (is_callable(array($httpObject, '_getTransport'))) {
                        $transports = $httpObject->_getTransport();
                        print "<h4>" . __('HTTP Transports available') . ":</h4>\n";
                        print "<ol>\n";
                        print "<li>" . implode("</li>\n<li>", array_map('get_class', $transports)) . "</li>\n";
                        print "</ol>\n";
                    } elseif (is_callable(array($httpObject, '_get_first_available_transport'))) {
                        $transport = $httpObject->_get_first_available_transport(array(), $url);
                        print "<h4>" . __("HTTP Transport") . ":</h4>\n";
                        print "<ol>\n";
                        print "<li>" . FeedWordPress::val($transport) . "</li>\n";
                        print "</ol>\n";
                    }
                    print "</div>\n";
                }
            }
        }
        if (!$feedSwitch) {
            $this->display_alt_feed_box($lookup, true);
        }
        ?>
	</div> <!-- class="wrap" -->
		<?php 
        return false;
        // Don't continue
    }
Ejemplo n.º 7
0
 function GAPI($username, $password)
 {
     $this->username = $username;
     $this->password = $password;
     $this->request = _wp_http_get_object();
 }
Ejemplo n.º 8
0
 /**
  * How does the site communicate with Facebook?
  *
  * @since 1.1.6
  *
  * @return void
  */
 public static function server_info()
 {
     echo '<section id="debug-server"><header><h3>' . esc_html(__('Server configuration', 'facebook')) . '</h3></header><table><thead><th>' . esc_html(__('Feature', 'facebook')) . '</th><th>' . esc_html(_x('Info', 'Information', 'facebook')) . '</th></thead><tbody>';
     // PHP version
     echo '<tr><th>' . esc_html(sprintf(_x('%s version', 'software version', 'facebook'), 'PHP')) . '</th><td>';
     // PHP > 5.2.7
     if (defined('PHP_MAJOR_VERSION') && defined('PHP_MINOR_VERSION') && defined('PHP_RELEASE_VERSION')) {
         echo esc_html(PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION);
     } else {
         esc_html(phpversion());
     }
     echo '</td></tr>';
     // WordPress version
     echo '<tr><th>' . esc_html(sprintf(_x('%s version', 'software version', 'facebook'), 'WordPress')) . '</th><td>' . esc_html(get_bloginfo('version')) . '</td></tr>';
     if (isset($_SERVER['SERVER_SOFTWARE'])) {
         echo '<tr><th>' . esc_html(__('Server software', 'facebook')) . '</th><td>' . esc_html($_SERVER['SERVER_SOFTWARE']) . '</td></tr>';
     }
     // WP_HTTP connection for SSL
     echo '<tr id="debug-server-http">';
     echo '<th>' . sprintf(esc_html(_x('%s connection method', 'server-to-server connection', 'facebook')), '<a href="http://codex.wordpress.org/HTTP_API">WP_HTTP</a>') . '</th><td>';
     $http_obj = _wp_http_get_object();
     $http_transport = $http_obj->_get_first_available_transport(array('ssl' => true));
     if (is_string($http_transport) && strlen($http_transport) > 8) {
         $http_transport = strtolower(substr($http_transport, 8));
         if ($http_transport === 'curl') {
             echo '<a href="http://php.net/manual/book.curl.php">cURL</a>';
             $curl_version = curl_version();
             if (isset($curl_version['version'])) {
                 echo ' ' . esc_html($curl_version['version']);
             }
             if (isset($curl_version['ssl_version'])) {
                 echo '; ';
                 $ssl_version = $curl_version['ssl_version'];
                 if (strlen($curl_version['ssl_version']) > 8 && substr_compare($ssl_version, 'OpenSSL/', 0, 8) === 0) {
                     echo '<a href="http://openssl.org/">OpenSSL</a>/' . esc_html(substr($ssl_version, 8));
                 } else {
                     echo esc_html($ssl_version);
                 }
                 unset($ssl_version);
             }
             unset($curl_version);
         } else {
             if ($http_transport === 'streams') {
                 echo '<a href="http://www.php.net/manual/book.stream.php">Stream</a>';
             } else {
                 if ($http_transport === 'fsockopen') {
                     echo '<a href="http://php.net/manual/function.fsockopen.php">fsockopen</a>';
                 } else {
                     echo $http_transport;
                 }
             }
         }
     } else {
         echo __('none available', 'facebook');
     }
     echo '</td></tr>';
     unset($http_transport);
     unset($http_obj);
     echo '</table></section>';
 }
Ejemplo n.º 9
0
 function _remote_delete($request_url, $args = array())
 {
     // fetch
     $objFetchSite = _wp_http_get_object();
     $defaults = array('method' => 'DELETE');
     $r = wp_parse_args($args, $defaults);
     // log
     mgm_log($request_url, __FUNCTION__);
     // log
     mgm_log($args, __FUNCTION__);
     // request
     $request = $objFetchSite->request($request_url, $r);
     // log
     mgm_log($request, __FUNCTION__);
     // validate, 200 and 302, WP permalink cacuses 302 Found/Temp Redirect often
     if (is_wp_error($request)) {
         return $request->get_error_message();
     }
     // return
     return wp_remote_retrieve_body($request);
 }
Ejemplo n.º 10
0
 public function request($url, $method = 'GET')
 {
     $this->method = strtoupper($method);
     $args = array();
     foreach (get_object_vars($this) as $prop => $val) {
         $args[str_replace('_', '-', $prop)] = $this->{$prop};
     }
     $start_time = microtime(true);
     $response = _wp_http_get_object()->request($url, $args);
     if ($response instanceof WP_Error) {
         return $response;
     }
     $response = (array) $response;
     $response['_start_time'] = $start_time;
     return new Response($response);
 }
Ejemplo n.º 11
0
 /**
  * Maybe skip the cURL transport for this request
  * @access private
  * @return boolean
  */
 private function skip_curl()
 {
     // if we already skipped curl, don't bother
     if ($this->skipped_curl === true) {
         return false;
     }
     $transport_used = _wp_http_get_object()->_get_first_available_transport($this->args, $this->url);
     if (strtolower($transport_used) !== 'wp_http_curl') {
         return false;
     }
     add_filter('http_api_transports', array($this, 'disable_curl_transport'));
     $this->skipped_curl = true;
     return true;
 }
Ejemplo n.º 12
0
 /**
  * Send a request to the Graph API.
  * @param $path
  * @param $params
  * @param $method
  * @return The API response or a WP_Error object
  */
 function api($path, $params = null, $method = 'GET')
 {
     $http = _wp_http_get_object();
     $url = 'https://graph.facebook.com/' . trim($path, '/');
     $args = array();
     $args['method'] = $method;
     if ($method == 'POST') {
         $args['body'] = http_build_query($params, null, '&');
     } else {
         if ($params) {
             $url .= '/?' . http_build_query($params, null, '&');
         }
     }
     // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
     // for 2 seconds if the server does not support this header.
     $opts = array(CURLOPT_CONNECTTIMEOUT => 10, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60, CURLOPT_USERAGENT => __CLASS__);
     if (isset($opts[CURLOPT_HTTPHEADER])) {
         $existing_headers = $opts[CURLOPT_HTTPHEADER];
         $existing_headers[] = 'Expect:';
         $opts[CURLOPT_HTTPHEADER] = $existing_headers;
     } else {
         $opts[CURLOPT_HTTPHEADER] = array('Expect:');
     }
     $args['headers'] = $opts[CURLOPT_HTTPHEADER];
     $args['sslverify'] = false;
     $args['timeout'] = $opts[CURLOPT_CONNECTTIMEOUT] * 1000;
     // echo "{$url}\n";
     $result = $http->request($url, $args);
     if (!is_wp_error($result)) {
         return json_decode($result['body']);
     } else {
         error_log($result->get_error_message());
         return false;
     }
 }
Ejemplo n.º 13
0
 function get_bitly_link($post_id)
 {
     $post = get_page($post_id);
     if (!$post->ID) {
         return false;
     }
     $permalink = $this->get_permalink($post->ID);
     if (!($login = $this->setting('bitly_login'))) {
         return $permalink;
     }
     if (!($apikey = $this->setting('bitly_apikey'))) {
         return $permalink;
     }
     if ($post->post_status == 'publish') {
         $response = _wp_http_get_object()->request('https://api-ssl.bitly.com/v3/shorten?' . http_build_query(array('login' => $login, 'apikey' => $apikey, 'longUrl' => $this->get_permalink($post->ID), 'format' => 'json', 'sslverify' => false)), array('method' => 'GET'));
         if (is_wp_error($response)) {
             SharePress::log('Bit.ly issue: ' . json_encode($response), 'ERROR');
             return $permalink;
         } else {
             $result = json_decode($response['body']);
             if ($result->status_code == 200) {
                 return $result->data->url;
             } else {
                 SharePress::log('Bit.ly issue: ' . json_encode($response), 'ERROR');
                 return $permalink;
             }
         }
     } else {
         return $permalink;
     }
 }
 /**
  * Make a request using the WP http API
  *
  * @since  0.2.2
  *
  * @param  string  $uri          URI to make request to
  * @param  string  $request_type Type of request. Defaults to 'get'
  *
  * @return mixed                 Return of the request.
  */
 public function request($uri, $request_type = 'get')
 {
     $http = _wp_http_get_object();
     $response = $http->{$request_type}($uri, $this->args);
     if (is_wp_error($response)) {
         throw new Exception($response->get_error_code() . ': ' . $response->get_error_message());
     }
     $code = $response['response']['code'];
     $success = $code >= 200 && $code < 300;
     if (!$success) {
         // Use Requests error handling.
         $exception = Requests_Exception_HTTP::get_class($code);
         throw new $exception(null, $this);
     }
     return $response;
 }
Ejemplo n.º 15
0
 function on_init()
 {
     $this->boot_loader->pass_checkpoint('hook:init');
     $http = _wp_http_get_object();
     //force collect of transports
     global $wp_version;
     if (version_compare($wp_version, "2.8", '<')) {
         wp_deregister_script('jquery');
         wp_deregister_script('jquery-ui-core');
         wp_deregister_script('jquery-ui-tabs');
         wp_deregister_script('jquery-ui-sortable');
         wp_deregister_script('jquery-ui-draggable');
         wp_deregister_script('jquery-ui-resizable');
         wp_deregister_script('jquery-ui-dialog');
         wp_register_script('jquery', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/jquery.js', false, '1.3.2');
         wp_register_script('jquery-ui-core', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.core.js', array('jquery'), '1.7.1');
         wp_register_script('jquery-ui-tabs', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.tabs.js', array('jquery-ui-core'), '1.7.1');
         wp_register_script('jquery-ui-sortable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.sortable.js', array('jquery-ui-core'), '1.7.1');
         wp_register_script('jquery-ui-draggable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.draggable.js', array('jquery-ui-core'), '1.7.1');
         wp_register_script('jquery-ui-resizable', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.resizable.js', array('jquery-ui-core'), '1.7.1');
         wp_register_script('jquery-ui-dialog', WP_PLUGIN_URL . '/' . dirname(plugin_basename(__FILE__)) . '/js/wordpress-2.7/ui.dialog.js', array('jquery-ui-resizable', 'jquery-ui-draggable'), '1.7.1');
     }
 }
Ejemplo n.º 16
0
 /**
  * Some hosts disable the OpenSSL extension and so cannot make outgoing HTTPS requsets
  */
 function fix_url_for_bad_hosts($url, &$args)
 {
     if (0 !== strpos($url, 'https://')) {
         return $url;
     }
     switch (JETPACK_CLIENT__HTTPS) {
         case 'ALWAYS':
             return $url;
         case 'NEVER':
             return substr_replace($url, '', 4, 1);
             // default : case 'AUTO' :
     }
     $jetpack = Jetpack::init();
     if (version_compare($GLOBALS['wp_version'], '3.2-something', '<')) {
         // WordPress < 3.2
         if (isset($args['method']) && 'POST' == strtoupper($args['method'])) {
             $method = 'POST';
         } else {
             $method = 'GET';
         }
         if (empty($jetpack->use_ssl)) {
             if (function_exists('_wp_http_get_object')) {
                 _wp_http_get_object();
             } else {
                 new WP_Http();
             }
         }
         // Yay! Your host is good!
         if ($jetpack->use_ssl[$method]) {
             return $url;
         }
     } else {
         // WordPress >= 3.2
         if (wp_http_supports(array('ssl' => true))) {
             return $url;
         }
     }
     // Boo! Your host is bad and makes Jetpack cry!
     return substr_replace($url, '', 4, 1);
 }
Ejemplo n.º 17
0
/**
 * Determines if there is an HTTP Transport that can process this request.
 *
 * @since 3.2.0
 *
 * @param array  $capabilities Array of capabilities to test or a wp_remote_request() $args array.
 * @param string $url Optional.  If given, will check if the URL requires SSL and adds that requirement to the capabilities array.
 *
 * @return bool
 */
function wp_http_supports($capabilities = array(), $url = null)
{
    $objFetchSite = _wp_http_get_object();
    $capabilities = wp_parse_args($capabilities);
    $count = count($capabilities);
    // If we have a numeric $capabilities array, spoof a wp_remote_request() associative $args array
    if ($count && count(array_filter(array_keys($capabilities), 'is_numeric')) == $count) {
        $capabilities = array_combine(array_values($capabilities), array_fill(0, $count, true));
    }
    if ($url && !isset($capabilities['ssl'])) {
        $scheme = parse_url($url, PHP_URL_SCHEME);
        if ('https' == $scheme || 'ssl' == $scheme) {
            $capabilities['ssl'] = true;
        }
    }
    return (bool) $objFetchSite->_get_first_available_transport($capabilities);
}
 /**
  * Tribe__Utils__Coordinates_Provider constructor.
  *
  * @param WP_Http|null $http
  */
 public function __construct(WP_Http $http = null)
 {
     $this->http = !empty($http) ? $http : _wp_http_get_object();
 }