function UpdateWidgetTitleAndUrl($id) { global $alert; $pac = GetPac($id); $bac = GetBac(true); if ($pac == null || $bac == null) { $alert = __("Wordpress cannot modify your widget", "FWTD"); return; } $url = PrepareParam(get_permalink($id)); if ($url == "") { $alert = __("Error in the Post data", "FWTD"); return; } $post = get_post($id); $title = PrepareParam(ConvertHtml($post->post_title)); if ($title == "") { $alert = __("Error in the Post data", "FWTD"); return; } try { $params = array(); $params['page'] = $url; $params['title'] = $title; $query = GetFeedwebUrl() . "FBanner.aspx?action=npw&pac={$pac}&bac={$bac}"; $response = wp_remote_post($query, array('method' => 'POST', 'timeout' => 300, 'body' => $params)); if (is_wp_error($response)) { $alert = __("Cannot connect Feedweb server", "FWTD"); return; } $dom = new DOMDocument(); if ($dom->loadXML($response['body']) == true) { $el = $dom->documentElement; if ($el->tagName == "BANNER") { $alert = $el->getAttribute("error"); if ($alert == "") { $alert = __("The widget Title/Url have been updated", "FWTD"); } return; } } $alert = __("Feedweb service cannot update the widget", "FWTD"); } catch (Exception $e) { $alert = $e->getMessage(); } }
function UpdateBlogCapabilities() { if (current_user_can('manage_options') == false) { // Must be admin return null; } $bac = GetBac(false); if ($bac == null) { return null; } $params = array(); $params['bac'] = $bac; $params['title'] = PrepareParam(get_bloginfo('name')); // Request blog caps by Blog Access Code $query = GetFeedwebUrl() . "FBanner.aspx?action=cap"; $response = wp_remote_post($query, array('method' => 'POST', 'timeout' => 30, 'body' => $params)); //$response = wp_remote_get ($query, array('timeout' => 30)); if (is_wp_error($response)) { return null; } $dom = new DOMDocument(); if ($dom->loadXML($response['body']) == true) { if ($dom->documentElement->tagName == "BANNER") { $license = $dom->documentElement->getAttribute("license"); if ($license != null && $license != "") { SetSingleFeedwebOption("license", $license); } global $feedweb_blog_caps; $feedweb_blog_caps = array(); $caps = $dom->documentElement->getElementsByTagName("CAP"); foreach ($caps as $cap) { $name = $cap->getAttribute("name"); $used = intval($cap->getAttribute("used")); $limit = intval($cap->getAttribute("limit")); $value = array(); $value["used"] = $used; $value["limit"] = $limit; $feedweb_blog_caps[$name] = $value; } return $license; } } }