Commit 4ba4b55c authored by Canek Peláez's avatar Canek Peláez
Browse files

Add separator option.

parent 9032186a
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ Description: This plugin allows to get the page stats from Google Analytics.
Author: Canek Peláez
Version: 0.0.1
Author URI: https://aztlan.fciencias.unam.mx/~canek/
Text Domain: ga-page-stats
*/

define('GA_PAGE_STATS__PLUGIN_DIR', plugin_dir_path(__FILE__));
@@ -33,7 +34,7 @@ function ga_page_stats_content_filter($content) {
    $users = number_format($r['users']);
    $views_label = __('Views', 'ga-page-stats');
    $users_label = __('Users', 'ga-page-stats');
    $sep = " | "; // $ga_options['separator']
    $sep = $ga_options['separator'] ? " | " : "";
    return $content . "<span style=\"font-size:small;\">" .
        "<em>$views_label: $page_views</em> | " .
        "<em>$users_label: $users</em>$sep</span>";
@@ -42,7 +43,8 @@ function ga_page_stats_content_filter($content) {
register_activation_hook(__FILE__, 'ga_page_stats_activation');
function ga_page_stats_activation($network_wide) {
	$option_name = 'ga_page_stats_options';
	$option = array('view_id' => '', 'key_file' => '', 'show_default' => false);
	$option = array('view_id' => '', 'key_file' => '',
                    'show_default' => false, 'separator' => false);

	if (is_multisite() && $network_wide) {
		$ms_sites = function_exists('get_sites') ? get_sites() : wp_get_sites();
@@ -60,3 +62,8 @@ function ga_page_stats_activation($network_wide) {
		add_option($option_name, $option);
	}
}

add_action('plugins_loaded', 'ga_page_stats_load_textdomain');
function ga_page_stats_load_textdomain() {
    load_plugin_textdomain('ga-page-stats');
}
+11 −0
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ if (!empty($_POST['Submit'])) {
    $ga_options['key_file'] = !empty($_POST['key_file_text']) ?
        addslashes(trim(wp_filter_kses($_POST['key_file_text']))) : '';
    $ga_options['show_default'] = !empty($_POST['show_default_check']);
    $ga_options['separator'] = !empty($_POST['separator_check']);

    $update_ga_queries = array();
    $update_ga_text = array();
@@ -34,6 +35,7 @@ $ga_options = get_option('ga_page_stats_options');
$view_id = $ga_options['view_id'];
$key_file = $ga_options['key_file'];
$show_default = $ga_options['show_default'];
$separator = $ga_options['separator'];

if (!empty($text)) {
    echo '<!-- Last Action --><div id="message" ' .
@@ -71,6 +73,15 @@ if (!empty($text)) {
          </td>
        </tr>
      <tr>
      <tr>
        <th scope="row" valign="top"><?php _e('Show separator', 'ga-page-stats'); ?></th>
          <td>
            <input type="checkbox" name="separator_check"
                   <?php if ($separator)
                             echo 'value="checked" checked '; ?>/>
          </td>
        </tr>
      <tr>
    </table>
    <p class="submit">
      <input type="submit" name="Submit" class="button"