本文整理汇总了PHP中GADWP_Tools::guess_default_domain方法的典型用法代码示例。如果您正苦于以下问题:PHP GADWP_Tools::guess_default_domain方法的具体用法?PHP GADWP_Tools::guess_default_domain怎么用?PHP GADWP_Tools::guess_default_domain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GADWP_Tools
的用法示例。
在下文中一共展示了GADWP_Tools::guess_default_domain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dashboard_widget
public function dashboard_widget()
{
if (empty($this->gadwp->config->options['ga_dash_token'])) {
echo '<p>' . __("This plugin needs an authorization:", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Authorize Plugin", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
if (current_user_can('manage_options')) {
if (isset($_REQUEST['gadwp_selected_profile'])) {
$this->gadwp->config->options['ga_dash_tableid'] = $_REQUEST['gadwp_selected_profile'];
}
$profiles = $this->gadwp->config->options['ga_dash_profile_list'];
$profile_switch = '';
if (!empty($profiles)) {
if (!$this->gadwp->config->options['ga_dash_tableid']) {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
$this->gadwp->config->options['ga_dash_tableid'] = GADWP_Tools::guess_default_domain($profiles);
}
} else {
if ($this->gadwp->config->options['switch_profile'] == 0 && $this->gadwp->config->options['ga_dash_tableid_jail']) {
$this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
}
}
$profile_switch .= '<select id="gadwp_selected_profile" name="gadwp_selected_profile" onchange="this.form.submit()">';
foreach ($profiles as $profile) {
if (!$this->gadwp->config->options['ga_dash_tableid']) {
$this->gadwp->config->options['ga_dash_tableid'] = $profile[1];
}
if (isset($profile[3])) {
$profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
$profile_switch .= selected($profile[1], $this->gadwp->config->options['ga_dash_tableid'], false);
$profile_switch .= ' title="' . __("View Name:", 'google-analytics-dashboard-for-wp') . ' ' . esc_attr($profile[0]) . '">' . esc_attr(GADWP_Tools::strip_protocol($profile[3])) . '</option>';
}
}
$profile_switch .= "</select>";
} else {
echo '<p>' . __("Something went wrong while retrieving profiles list.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("More details", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
}
$this->gadwp->config->set_plugin_options();
?>
<form id="ga-dash" method="POST">
<?php
if (current_user_can('manage_options')) {
if ($this->gadwp->config->options['switch_profile'] == 0) {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
} else {
echo $profile_switch;
$projectId = $this->gadwp->config->options['ga_dash_tableid'];
}
} else {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
}
if (!$projectId) {
echo '<p>' . __("Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'google-analytics-dashboard-for-wp') . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button(__("Find out more!", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
if (isset($_REQUEST['gadwpquery'])) {
$query = $_REQUEST['gadwpquery'];
} else {
$default_metric = GADWP_Tools::get_cookie('default_metric');
$query = $default_metric ? $default_metric : 'sessions';
}
if (isset($_REQUEST['gadwpperiod'])) {
$period = $_REQUEST['gadwpperiod'];
} else {
$default_dimension = GADWP_Tools::get_cookie('default_dimension');
$period = $default_dimension ? $default_dimension : '30daysAgo';
}
?>
<select id="ga_dash_period" name="gadwpperiod" onchange="this.form.submit()">
<option value="realtime" <?php
selected("realtime", $period, true);
?>
><?php
_e("Real-Time", 'google-analytics-dashboard-for-wp');
?>
</option>
<option value="today" <?php
selected("today", $period, true);
?>
><?php
_e("Today", 'google-analytics-dashboard-for-wp');
?>
</option>
<option value="yesterday" <?php
selected("yesterday", $period, true);
?>
//.........这里部分代码省略.........
示例2: general_settings_network
public static function general_settings_network()
{
$gadwp = GADWP();
global $wp_version;
if (!current_user_can('manage_network_options')) {
return;
}
$options = self::update_options('network');
/*
* Include GAPI
*/
echo '<div id="gapi-warning" class="updated"><p>' . __('Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', 'google-analytics-dashboard-for-wp') . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
if (null === $gadwp->gapi_controller) {
$gadwp->gapi_controller = new GADWP_GAPI_Controller();
}
echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
if (isset($_POST['ga_dash_code'])) {
if (!stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
try {
$gadwp->gapi_controller->client->authenticate($_POST['ga_dash_code']);
$gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
$gadwp->config->options['automatic_updates_minorversion'] = 1;
$gadwp->config->set_plugin_options(true);
$options = self::update_options('network');
$message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp') . "</p></div>";
if (is_multisite()) {
// Cleanup errors on the entire network
foreach (wp_get_sites(array('limit' => apply_filters('gadwp_sites_limit', 100))) as $blog) {
switch_to_blog($blog['blog_id']);
GADWP_Tools::delete_cache('gapi_errors');
restore_current_blog();
}
} else {
GADWP_Tools::delete_cache('gapi_errors');
}
if ($gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken()) {
if (!empty($gadwp->config->options['ga_dash_profile_list'])) {
$profiles = $gadwp->config->options['ga_dash_profile_list'];
} else {
$profiles = $gadwp->gapi_controller->refresh_profiles();
}
if ($profiles) {
$gadwp->config->options['ga_dash_profile_list'] = $profiles;
if (isset($gadwp->config->options['ga_dash_tableid_jail']) && !$gadwp->config->options['ga_dash_tableid_jail']) {
$profile = GADWP_Tools::guess_default_domain($profiles);
$gadwp->config->options['ga_dash_tableid_jail'] = $profile;
$gadwp->config->options['ga_dash_tableid'] = $profile;
}
$gadwp->config->set_plugin_options(true);
$options = self::update_options('network');
}
}
} catch (Google_IO_Exception $e) {
GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html($e), $gadwp->gapi_controller->error_timeout);
return false;
} catch (Google_Service_Exception $e) {
GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $gadwp->gapi_controller->error_timeout);
GADWP_Tools::set_cache('gapi_errors', $e->getErrors(), $gadwp->gapi_controller->error_timeout);
return $e->getCode();
} catch (Exception $e) {
GADWP_Tools::set_cache('last_error', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $gadwp->gapi_controller->error_timeout);
$gadwp->gapi_controller->reset_token(false);
}
} else {
$message = "<div class='error'><p>" . __("The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp') . ".</p></div>";
}
}
if (isset($_POST['Refresh'])) {
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
$gadwp->config->options['ga_dash_profile_list'] = array();
$message = "<div class='updated'><p>" . __("Properties refreshed.", 'google-analytics-dashboard-for-wp') . "</p></div>";
$options = self::update_options('network');
if ($gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken()) {
if (!empty($gadwp->config->options['ga_dash_profile_list'])) {
$profiles = $gadwp->config->options['ga_dash_profile_list'];
} else {
$profiles = $gadwp->gapi_controller->refresh_profiles();
}
if ($profiles) {
$gadwp->config->options['ga_dash_profile_list'] = $profiles;
if (isset($gadwp->config->options['ga_dash_tableid_jail']) && !$gadwp->config->options['ga_dash_tableid_jail']) {
$profile = GADWP_Tools::guess_default_domain($profiles);
$gadwp->config->options['ga_dash_tableid_jail'] = $profile;
$gadwp->config->options['ga_dash_tableid'] = $profile;
}
$gadwp->config->set_plugin_options(true);
$options = self::update_options('network');
}
}
} else {
$message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
}
}
if (isset($_POST['Clear'])) {
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
GADWP_Tools::clear_cache();
$message = "<div class='updated'><p>" . __("Cleared Cache.", 'google-analytics-dashboard-for-wp') . "</p></div>";
} else {
$message = "<div class='error'><p>" . __("Cheating Huh?", 'google-analytics-dashboard-for-wp') . "</p></div>";
}
//.........这里部分代码省略.........
示例3: dashboard_widget
public function dashboard_widget()
{
if (empty($this->gadwp->config->options['ga_dash_token'])) {
echo '<p>' . __("This plugin needs an authorization:", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Authorize Plugin", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
if (current_user_can('manage_options')) {
if (isset($_REQUEST['gadwp_selected_profile'])) {
$this->gadwp->config->options['ga_dash_tableid'] = $_REQUEST['gadwp_selected_profile'];
}
$profiles = $this->gadwp->config->options['ga_dash_profile_list'];
$profile_switch = '';
if (!empty($profiles)) {
if (!$this->gadwp->config->options['ga_dash_tableid']) {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
$this->gadwp->config->options['ga_dash_tableid'] = GADWP_Tools::guess_default_domain($profiles);
}
} else {
if ($this->gadwp->config->options['switch_profile'] == 0 && $this->gadwp->config->options['ga_dash_tableid_jail']) {
$this->gadwp->config->options['ga_dash_tableid'] = $this->gadwp->config->options['ga_dash_tableid_jail'];
}
}
$profile_switch .= '<select id="gadwp_selected_profile" name="gadwp_selected_profile" onchange="this.form.submit()">';
foreach ($profiles as $profile) {
if (!$this->gadwp->config->options['ga_dash_tableid']) {
$this->gadwp->config->options['ga_dash_tableid'] = $profile[1];
}
if (isset($profile[3])) {
$profile_switch .= '<option value="' . esc_attr($profile[1]) . '" ';
$profile_switch .= selected($profile[1], $this->gadwp->config->options['ga_dash_tableid'], false);
$profile_switch .= ' title="' . __("View Name:", 'google-analytics-dashboard-for-wp') . ' ' . esc_attr($profile[0]) . '">' . esc_attr(GADWP_Tools::strip_protocol($profile[3])) . '</option>';
}
}
$profile_switch .= "</select>";
} else {
echo '<p>' . __("Something went wrong while retrieving profiles list.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("More details", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
}
$this->gadwp->config->set_plugin_options();
if (current_user_can('manage_options')) {
if ($this->gadwp->config->options['switch_profile'] == 0) {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
} else {
echo $profile_switch;
$projectId = $this->gadwp->config->options['ga_dash_tableid'];
}
} else {
if ($this->gadwp->config->options['ga_dash_tableid_jail']) {
$projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
} else {
echo '<p>' . __("An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp') . '</p><form action="' . menu_page_url('gadash_settings', false) . '" method="POST">' . get_submit_button(__("Select Domain", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
}
if (!$projectId) {
echo '<p>' . __("Something went wrong while retrieving property data. You need to create and properly configure a Google Analytics account:", 'google-analytics-dashboard-for-wp') . '</p> <form action="https://deconf.com/how-to-set-up-google-analytics-on-your-website/" method="POST">' . get_submit_button(__("Find out more!", 'google-analytics-dashboard-for-wp'), 'secondary') . '</form>';
return;
}
?>
<div id="gadwp-window-1"></div>
<?php
}