/** * Loads and configures NetDNA widget to be used in WP Dashboards. * @param $widget_id * @param array $form_inputs */ function widget_netdna($widget_id, $form_inputs = array()) { $authorized = $this->authorized; $have_zone = $this->have_zone; $is_sealed = $this->_sealed; if ($authorized && $have_zone) { $zone_id = $this->_config->get_integer('cdn.netdna.zone_id'); $zone_info = $this->api->get_pull_zone($zone_id); if ($zone_info) { $content_zone = $zone_info['name']; $summary = $this->api->get_stats_per_zone($zone_id); $filetypes = $this->api->get_list_of_file_types_per_zone($zone_id); $popular_files = $this->api->get_list_of_popularfiles_per_zone($zone_id); $popular_files = NetDNAPresentation::format_popular($popular_files); $popular_files = array_slice($popular_files, 0, 5); $account = $this->api->get_account(); $account_status = NetDNAPresentation::get_account_status($account['status']); include W3TC_INC_WIDGET_DIR . '/netdna.php'; } else { include W3TC_INC_WIDGET_DIR . '/netdna_signup.php'; } } else { include W3TC_INC_WIDGET_DIR . '/netdna_signup.php'; } }
/** * Loads and configures NetDNA widget to be used in WP Dashboards. * @param $widget_id * @param array $form_inputs */ function widget_maxcdn($widget_id, $form_inputs = array()) { w3_require_once(W3TC_INC_FUNCTIONS_DIR . '/ui.php'); $authorized = $this->authorized; $have_zone = $this->have_zone; $error = ''; $no_zone = $this->_config->get_integer('cdn.maxcdn.zone_id') == 0; $is_sealed = $this->_sealed; $pull_zones = array(); $zone_info = false; if ($this->authorized && $this->have_zone) { $zone_id = $this->_config->get_integer('cdn.maxcdn.zone_id'); try { $zone_info = $this->api->get_pull_zone($zone_id); } catch (Exception $ex) { $zone_info = false; $error = $ex->getMessage(); } if ($zone_info) { $content_zone = $zone_info['name']; try { $summary = $this->api->get_stats_per_zone($zone_id); $filetypes = $this->api->get_list_of_file_types_per_zone($zone_id); $popular_files = $this->api->get_list_of_popularfiles_per_zone($zone_id); $popular_files = NetDNAPresentation::format_popular($popular_files); $popular_files = array_slice($popular_files, 0, 5); $account = $this->api->get_account(); $account_status = NetDNAPresentation::get_account_status($account['status']); include W3TC_INC_WIDGET_DIR . '/maxcdn.php'; } catch (Exception $ex) { $error = $ex->getMessage(); try { $pull_zones = $this->api->get_zones_by_url(home_url()); } catch (Exception $ex) { } include W3TC_INC_WIDGET_DIR . '/maxcdn_signup.php'; } } else { try { $pull_zones = $this->api->get_zones_by_url(home_url()); } catch (Exception $ex) { } include W3TC_INC_WIDGET_DIR . '/maxcdn_signup.php'; } } else { include W3TC_INC_WIDGET_DIR . '/maxcdn_signup.php'; } }
/** * Validates that the API works and echos message and exists if it fails * @param NetDNA $api * @return null|array */ private function validate_account($api) { try { return $api->get_account(); } catch (Exception $ex) { $result = array('result' => 'error', 'message' => $ex->getMessage()); echo json_encode($result); exit; } }