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

Show main page count in options.

parent 1746e473
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
1. Generate POT file:
1. Generate POT file:
   ```sh
   ```sh
   xgettext -L PHP -d word-count -s -j *.php  --from-code=UTF-8 -k_e -k__ -o languages/word-count.pot
   xgettext -L PHP -d ga-page-stats -s -j *.php  --from-code=UTF-8 -k_e -k__ -o languages/ga-page-stats.pot
   ```
   ```


2. Copy POT file to `.po` file:
2. Copy POT file to `.po` file:


    ```sh
    ```sh
    cp languages/word-count.pot languages/ll_LL.po
    cp languages/ga-page-stats.pot languages/ll_LL.po
    ```
    ```


3. Generate `.mo` file:
3. Generate `.mo` file:
@@ -18,5 +18,5 @@
4. Update `.po` file:
4. Update `.po` file:


    ```sh
    ```sh
    msgmerge -U languages/es_MX.po languages/word-count.pot
    msgmerge -U languages/es_MX.po languages/ga-page-stats.pot
    ```
    ```
+14 −10
Original line number Original line Diff line number Diff line
@@ -8,8 +8,8 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: ga-page-stats 0.0.1\n"
"Project-Id-Version: ga-page-stats 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-20 01:02-0500\n"
"POT-Creation-Date: 2021-10-21 17:06-0500\n"
"PO-Revision-Date: 2021-10-20 01:05-0500\n"
"PO-Revision-Date: 2021-10-21 17:07-0500\n"
"Last-Translator: Canek Peláez <canek@ciencias.unam.mx>\n"
"Last-Translator: Canek Peláez <canek@ciencias.unam.mx>\n"
"Language-Team: Spanish\n"
"Language-Team: Spanish\n"
"Language: Spanish\n"
"Language: Spanish\n"
@@ -25,27 +25,31 @@ msgstr "No se puede deserializar un singleton."
msgid "Google Analytics"
msgid "Google Analytics"
msgstr ""
msgstr ""


#: ga-page-stats.php:21 options.php:2
#: ga-page-stats.php:21 options.php:2 options.php:4
msgid "Google Analytics page statistics"
msgid "Google Analytics page statistics"
msgstr "Estadísticas de página con Google Analytics"
msgstr "Estadísticas de página con Google Analytics"


#: options.php:59
#: options.php:59 options.php:73
msgid "Key file"
msgid "Key file"
msgstr "Archivo de llave"
msgstr "Archivo de llave"


#: options.php:29
#: options.php:59
msgid "Main page"
msgstr "Página principal"

#: options.php:29 options.php:31
msgid "No option updated"
msgid "No option updated"
msgstr "Ninguna opción actualizada"
msgstr "Ninguna opción actualizada"


#: options.php:88
#: options.php:88 options.php:102
msgid "Save changes"
msgid "Save changes"
msgstr "Guardar cambios"
msgstr "Guardar cambios"


#: options.php:68
#: options.php:68 options.php:82
msgid "Show by default"
msgid "Show by default"
msgstr "Mostrar por omisión"
msgstr "Mostrar por omisión"


#: options.php:77
#: options.php:77 options.php:91
msgid "Show separator"
msgid "Show separator"
msgstr "Mostrar separador"
msgstr "Mostrar separador"


@@ -53,7 +57,7 @@ msgstr "Mostrar separador"
msgid "Users"
msgid "Users"
msgstr "Usuarios"
msgstr "Usuarios"


#: options.php:51
#: options.php:51 options.php:65
msgid "View ID"
msgid "View ID"
msgstr "Identificador de vista"
msgstr "Identificador de vista"


@@ -61,6 +65,6 @@ msgstr "Identificador de vista"
msgid "Views"
msgid "Views"
msgstr "Vistas"
msgstr "Vistas"


#: options.php:23
#: options.php:23 options.php:25
msgid "updated"
msgid "updated"
msgstr "actualizada"
msgstr "actualizada"
+13 −9
Original line number Original line Diff line number Diff line
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-10-20 01:02-0500\n"
"POT-Creation-Date: 2021-10-21 17:06-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -25,27 +25,31 @@ msgstr ""
msgid "Google Analytics"
msgid "Google Analytics"
msgstr ""
msgstr ""


#: ga-page-stats.php:21 options.php:2
#: ga-page-stats.php:21 options.php:2 options.php:4
msgid "Google Analytics page statistics"
msgid "Google Analytics page statistics"
msgstr ""
msgstr ""


#: options.php:59
#: options.php:59 options.php:73
msgid "Key file"
msgid "Key file"
msgstr ""
msgstr ""


#: options.php:29
#: options.php:59
msgid "Main page"
msgstr ""

#: options.php:29 options.php:31
msgid "No option updated"
msgid "No option updated"
msgstr ""
msgstr ""


#: options.php:88
#: options.php:88 options.php:102
msgid "Save changes"
msgid "Save changes"
msgstr ""
msgstr ""


#: options.php:68
#: options.php:68 options.php:82
msgid "Show by default"
msgid "Show by default"
msgstr ""
msgstr ""


#: options.php:77
#: options.php:77 options.php:91
msgid "Show separator"
msgid "Show separator"
msgstr ""
msgstr ""


@@ -53,7 +57,7 @@ msgstr ""
msgid "Users"
msgid "Users"
msgstr ""
msgstr ""


#: options.php:51
#: options.php:51 options.php:65
msgid "View ID"
msgid "View ID"
msgstr ""
msgstr ""


@@ -61,6 +65,6 @@ msgstr ""
msgid "Views"
msgid "Views"
msgstr ""
msgstr ""


#: options.php:23
#: options.php:23 options.php:25
msgid "updated"
msgid "updated"
msgstr ""
msgstr ""
+14 −0
Original line number Original line Diff line number Diff line
<?php
<?php
require_once(GA_PAGE_STATS__PLUGIN_DIR . 'class.ga-page-stats.php');

$gaps_title = __('Google Analytics page statistics', 'ga-page-stats');
$gaps_title = __('Google Analytics page statistics', 'ga-page-stats');
if (!empty($_POST['Submit'])) {
if (!empty($_POST['Submit'])) {
    check_admin_referer('ga-page-stats_options');
    check_admin_referer('ga-page-stats_options');
@@ -41,12 +43,24 @@ if (!empty($text)) {
    echo '<!-- Last Action --><div id="message" ' .
    echo '<!-- Last Action --><div id="message" ' .
        'class="updated fade"><p>' . $text . '</p></div>';
        'class="updated fade"><p>' . $text . '</p></div>';
}
}

$root = "/" . implode("/", array_slice(explode("/", get_home_url()), 3));
$r = GAPageStats::getPageStats($root);
$page_views = number_format($r['pageViews']);
$users = number_format($r['users']);
$stats = "Page views: $page_views; users: $users";
?>
?>
<form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
<form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>">
  <?php wp_nonce_field('ga-page-stats_options'); ?>
  <?php wp_nonce_field('ga-page-stats_options'); ?>
  <div class="wrap">
  <div class="wrap">
    <h2><?php echo $gaps_title; ?></h2>
    <h2><?php echo $gaps_title; ?></h2>
    <table class="form-table">
    <table class="form-table">
      <tr>
        <th scope="row" valign="top"><?php _e('Main page', 'ga-page-stats'); ?></th>
        <td>
          <input type="text" value="<?php echo $stats; ?>" size="30" disabled />
        </td>
      </tr>
      <tr>
      <tr>
        <th scope="row" valign="top"><?php _e('View ID', 'ga-page-stats'); ?></th>
        <th scope="row" valign="top"><?php _e('View ID', 'ga-page-stats'); ?></th>
        <td>
        <td>