Besucherzähler, kleine techn. Frage

  • Hi

    Ich hab von Tamagothi den 'Besucherzähler' installiert. Nun ist es so, dass dieses Widget nicht mit meinem Theme 'i3Theme' funktioniert. Leider ist es so, dass es genau das ist, was ich brauche.

    Auf meiner HP sieht ihr den aktuellen Stand und bin total unzufrieden. Ich hab an Tamagothi auch schon geschrieben. Leider (das zweite Mal) ohne Erfolg.

    Kann mir jemand sagen, was ich ändern muss, damit der Besucherzähler genau so aussieht wie die anderen Widget auf meiner Page ?

    Besten Dank

    • Anzeige

    Hallo!

    Wenn du gerade an deiner Website arbeitest oder dein aktuelles Hosting überdenkst: Wir betreiben mit NetzLiving eine Hosting-Plattform, die speziell auf Performance, Sicherheit und einfache Verwaltung ausgelegt ist.

    • ✔️ Schnelle Ladezeiten (optimiert für WordPress & Co.)
    • ✔️ Deutsche Server & DSGVO-konform
    • ✔️ Persönlicher Support (kein 0815-Ticket-System)

    Mehr erfahren

  • Zitat

    Kann mir jemand sagen, was ich ändern muss, damit der Besucherzähler genau so aussieht wie die anderen Widget auf meiner Page ?

    Du müsstest dafür sorgen, dass das HTML des neuen Widgets mit dem der schon vorhandenen Widgets übereinstimmt. Im Moment besteht Deine Sidebar offenbar aus divs mit h3-Tags als Überschrift. Das neue Widget liegt aber in einem li mit einem h2-Tag als Überschrift.

    Wenn ich mich mühsam dran erinnere, wie die Widgets funktionieren, dann sollte das eigentlich ja nicht passieren. Würde das nicht das Theme setzen, wenn nicht der Standard verwendet werden soll?! Da gibt es Variablen für "before widget", "after widget", "before headline" und "after headline". Entweder Dein Theme baut an der Stelle also Mist oder das Plugin nutzt nicht die vorgesehenen Strukturen. Hast Du mal einen Link zu beidem, dann kann ich genauer schauen, woran es liegt.

  • statt

    Code
    <li><h2>Besucher-Zähler</h2>
    <p><span class="visitorcount">3412</span> Besucher</p></li>


    lieber so

    Code
    <div class="dbx-box dbx-box-open"><h3 class="dbx-handle dbx-handle-cursor">Besucher-Zähler</h3>
    <div class="dbx-content"><span class="visitorcount">3411</span> Besucher</div></div>

    Dann bekommst du es etwa so wie im Bild :-D

  • so sieht ja der code aus (plugin):


    <?php

    /*
    Plugin Name: Visitor Counter Widget
    Plugin URI: Lumières dans la nuit » Wordpress-Widget: Besucherzähler
    Description: A simple visitor counter for WordPress. It is a simple widget I missed in the plugin databases.
    Author: Elias Schwerdtfeger
    Version: 1.1
    Author URI: Lumières dans la nuit
    */


    /*
    ** Copyright 2007 Elias Schwerdtfeger Lumières dans la nuit
    **
    ** This program is free software; you can redistribute it and/or modify
    ** it under the terms of the GNU General Public License as published by
    ** the Free Software Foundation; either version 2 of the License, or
    ** (at your option) any later version.
    **
    ** This program is distributed in the hope that it will be useful,
    ** but WITHOUT ANY WARRANTY; without even the implied warranty of
    ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    ** GNU General Public License for more details.
    **
    ** You should have received a copy of the GNU General Public License
    ** along with this program; if not, write to the Free Software
    ** Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
    */


    load_plugin_textdomain('visitorcounter', 'wp-content/plugins/visitorcounter');


    if(!function_exists('get_ipaddress')) {
    function get_ipaddress() {
    if (empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
    $ip_address = $_SERVER["REMOTE_ADDR"];
    } else {
    $ip_address = $_SERVER["HTTP_X_FORWARDED_FOR"];
    }
    if(strpos($ip_address, ',') !== false) {
    $ip_address = explode(',', $ip_address);
    $ip_address = $ip_address[0];
    }
    return $ip_address;
    }
    }


    function wpvc_remove_oldentries ($var)
    {
    global $wpvc_global_keepfrom;
    return $var > $wpvc_global_keepfrom;
    }


    function wpvc_count ($p_keepfor)
    {
    global $wpvc_global_keepfrom;
    $now_ip = get_ipaddress ();
    $now_time = time ();
    $keepfor = $p_keepfor ? $p_keepfor : get_option ('visitorcounter_keepfor');
    $count = get_option ('visitorcounter_count');
    $array = get_option ('visitorcounter_blocked');
    if ($count == FALSE)
    {
    $count = 0;
    }
    if ($keepfor == FALSE)
    {
    $keepfor = 10 * 60;
    }
    if ($array == FALSE)
    {
    $array = array ();
    }
    $wpvc_global_keepfrom = $now_time - $keepfor;
    $array = array_filter ($array, 'wpvc_remove_oldentries');
    if (!array_key_exists ($now_ip, $array))
    {
    $count++;
    update_option ('visitorcounter_count', $count);
    $array[$now_ip] = $now_time;
    update_option ('visitorcounter_blocked', $array);
    }
    return $count;
    }


    function wpvc_sidebar_count ($title = FALSE, $before = FALSE, $after = FALSE, $showtitle = FALSE, $listitem = FALSE, $keepfor = 600)
    {
    $count = wpvc_count ($keepfor);
    if (!$title)
    {
    $title = __('Counter', 'visitorcounter');
    }
    if (!$after)
    {
    $after = __('Visitors', 'visitorcounter');
    }
    echo '<li>';
    if ($showtitle)
    {
    echo '<h2>' . stripslashes($title) . "</h2>\n";
    }
    echo $listitem ? '<ul><li>' : '<p>';
    if ($before)
    {
    echo stripslashes($before) . ' ';
    }
    echo "<span class=\"visitorcount\">$count</span>";
    if ($after)
    {
    echo ' ' . stripslashes($after);
    }
    echo $listitem ? '</li></ul>' : '</p>';
    echo "</li>\n";
    }


    function wpvc_sidebar_widget ()
    {
    $opt = get_option ('visitorcounter_widget_options');
    wpvc_sidebar_count ($opt['title'], $opt['before'], $opt['after'], $opt['showtitle'], $opt['listitem']);
    }


    function wpvc_widget_options ()
    {
    $opt = get_option ('visitorcounter_widget_options');
    $cnt = get_option ('visitorcounter_count');
    $kf = get_option ('visitorcounter_keepfor');
    if (!is_array ($opt))
    {
    $opt = array (
    'title' => __('Counter', 'visitorcounter'),
    'before' => '',
    'after' => __('Visitors', 'visitorcounter'),
    'showtitle' => 1,
    'listitem' => 0
    );
    }
    if (!$cnt)
    {
    $cnt = 0;
    }
    if (!kf)
    {
    $kf = 600;
    }
    if ($_POST['visitorcounter_submit'])
    {
    $opt['title'] = $_POST['visitorcounter_title'];
    $opt['before'] = $_POST['visitorcounter_before'];
    $opt['after'] = $_POST['visitorcounter_after'];
    $opt['showtitle'] = $_POST['visitorcounter_showtitle'];
    $opt['listitem'] = $_POST['visitorcounter_listitem'];
    $cnt = intval ($_POST['visitorcounter_count']);
    $kf = intval ($_POST['visitorcounter_keepfor']);
    update_option ('visitorcounter_widget_options', $opt);
    if ($cnt > 0 && $cnt != $_POST['visitorcounter_oldcount'])
    {
    update_option ('visitorcounter_count', $cnt);
    }
    update_option ('visitorcounter_keepfor', $kf);
    }
    ?>
    <p style="text-align:left">
    <label
    for="visitorcounter_title"
    title="<?php _e('This text will appear as widget title in the sidebar, if you activate the option for displaying the title.', 'visitorcounter'); ?>"
    ><?php _e('Widget Title:', 'visitorcounter'); ?></label><br />
    <input
    style="width:100%"
    type="text"
    id="visitorcounter_title"
    name="visitorcounter_title"
    value="<?php echo htmlspecialchars (stripslashes ($opt['title'])); ?>"
    title="<?php _e('This text will appear as widget title in the sidebar, if you activate the option for displaying the title.', 'visitorcounter'); ?>"
    />
    </p>
    <p style="text-align:left">
    <label
    for="visitorcounter_before"
    title="<?php _e('This text will appear before the number of visitors', 'visitorcounter'); ?>"
    ><?php _e('Text before the count (with HTML markup):', 'visitorcounter'); ?></label><br />
    <input
    style="width:100%"
    type="text"
    id="visitorcounter_before"
    name="visitorcounter_before"
    value="<?php echo htmlspecialchars (stripslashes ($opt['before'])); ?>"
    title="<?php _e('This text will appear before the number of visitors', 'visitorcounter'); ?>"
    />
    </p>
    <p style="text-align:left">
    <label
    for="visitorcounter_after"
    title="<?php _e('This text will appear after the number of visitors', 'visitorcounter'); ?>"
    ><?php _e('Text after the count (with HTML markup):', 'visitorcounter'); ?></label><br />
    <input
    style="width:100%"
    type="text"
    id="visitorcounter_after"
    name="visitorcounter_after"
    value="<?php echo htmlspecialchars (stripslashes ($opt['after'])); ?>"
    title="<?php _e('This text will appear after the number of visitors', 'visitorcounter'); ?>"
    />
    </p>
    <p style="text-align:left">
    <label
    for="visitorcounter_keepfor"
    title="<?php _e('For this number of seconds a visitor\'s IP address will be blocked for counting again', 'visitorcounter'); ?>"
    ><?php _e('Seconds to block counting the IP again:', 'visitorcounter'); ?></label><br />
    <input
    style="width:100%"
    type="text"
    id="visitorcounter_keepfor"
    name="visitorcounter_keepfor"
    value="<?php echo $kf; ?>"
    title="<?php _e('For this number of seconds a visitor\'s IP address will be blocked for counting again', 'visitorcounter'); ?>"
    />
    </p>
    <p style="text-align:left">
    <label
    for="visitorcounter_count"
    title="<?php _e('This is the actual number of visitors, you can edit it to let your site look more popular than it is', 'visitorcounter'); ?>"
    ><?php _e('Edit counter value:', 'visitorcounter'); ?></label><br />
    <input
    style="width:100%"
    type="text"
    id="visitorcounter_count"
    name="visitorcounter_count"
    value="<?php echo $cnt; ?>"
    title="<?php _e('This is the actual number of visitors, you can edit it to let your site look more popular than it is', 'visitorcounter'); ?>"
    />
    </p>
    <p style="text-align:left">
    <input
    type="checkbox"
    id="visitorcounter_showtitle"
    name="visitorcounter_showtitle"
    <?php if($opt['showtitle']) { ?>checked="checked"<?php } ?>
    title="<?php _e('If you check this box, the title of the widget will be displayed in the sidebar', 'visitorcounter'); ?>"
    />
    <label
    for="visitorcounter_showtitle"
    title="<?php _e('If you check this box, the title of the widget will be displayed in the sidebar', 'visitorcounter'); ?>"
    ><?php _e('Show the widget\'s title', 'visitorcounter'); ?></label>
    </p>
    <p style="text-align:left">
    <input
    type="checkbox"
    id="visitorcounter_listitem"
    name="visitorcounter_listitem"
    <?php if($opt['listitem']) { ?>checked="checked"<?php } ?>
    title="<?php _e('If you check this box, the display will be shown in a HTML list, which is the standard in many themes. Checking this can make the widget\'s appearence more consistent in your theme.', 'visitorcounter'); ?>"
    />
    <label
    for="visitorcounter_listitem"
    title="<?php _e('If you check this box, the display will be shown in a HTML list, which is the standard in many themes. Checking this can make the widget\'s appearence more consistent in your theme.', 'visitorcounter'); ?>"
    ><?php _e('Display as a list item', 'visitorcounter'); ?></label>
    </p>
    <p style="text-align:left; font-size:85%;">
    <?php _e("This <b>visitor counter</b> widget was developed for you by <a href=\"http://www.tamagothi.de%5c">Elias Schwerdtfeger</a>. If you like it, please make a little donation in my blog.", 'visitorcounter'); ?>
    </p>
    <input type="hidden" id="visitorcounter_submit" name="visitorcounter_submit" value="1" />
    <input type="hidden" id="visitorcounter_oldcount" name="visitorcounter_oldcount" value="<?php echo $cnt; ?>" />
    <?php
    }


    function wpvc_add_widget ()
    {
    if (function_exists ('register_sidebar_widget'))
    {
    register_sidebar_widget (__('Visitor Counter', 'visitorcounter'), 'wpvc_sidebar_widget');
    register_widget_control (__('Visitor Counter', 'visitorcounter'), 'wpvc_widget_options', 300, 440);
    }
    }


    add_action ('init', 'wpvc_add_widget');


    /*
    ** It must be a starving man
    ** Who likes to hear
    ** These crippled minds talk...
    ** Greetings from me
    ** Following the wind.
    **
    ** Wolfsheim, Elias
    */

    ?>

  • Also der Link zum Autor reicht völlig, bitte [COLOR=Red]keine kilometerlangen Scripts[/COLOR] einkleben. Ich seh mir mal das Original vom Autor an.

    Also ab Zeile 92 im Counter, den ich runtergeladen hab, findest du:

    Das ersetzt du wie folgt:

    Sei dir aber im Klaren darüber, dass dies eine spezielle Anpassung und dein aktuelles Theme ist. Falls dir das mal zum Hals raushängt, solltest du es erst mal wieder mit dem Original versuchen.

  • Wie schon gesagt, das Plugin nutzt nicht die für Widgets vorgesehenen Mechanismen. Ich habe dem Autor mal einen Kommentar hinterlassen. Widgets sollen sich nämlich eigentlich nahtlos in alle Themes einfügen, egal wie deren spezielles HTML nun gerade aussieht. Obiger Fix tut es aber auch, solange keine neue Plugin-Version erschienen ist. ;-)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!