本文整理汇总了PHP中GADWP_Tools::get_cookie方法的典型用法代码示例。如果您正苦于以下问题:PHP GADWP_Tools::get_cookie方法的具体用法?PHP GADWP_Tools::get_cookie怎么用?PHP GADWP_Tools::get_cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GADWP_Tools
的用法示例。
在下文中一共展示了GADWP_Tools::get_cookie方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
?>
//.........这里部分代码省略.........