Plugin Directory

Changeset 3064212


Ignore:
Timestamp:
04/03/2024 11:23:56 PM (2 years ago)
Author:
jwz
Message:

Version 1.2

Location:
geolocate-comments
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • geolocate-comments/tags/1.2/geolocate-comments.php

    r2782903 r3064212  
    33Plugin Name: Geolocate Comments
    44Plugin URI: https://www.jwz.org/geolocate-comments/
    5 Version: 1.1
     5Version: 1.2
    66Description: Save the geolocation when a new comment is posted.
    77Author: Jamie Zawinski
     
    99*/
    1010
    11 /* Copyright © 2022 Jamie Zawinski <jwz@jwz.org>
     11/* Copyright © 2022-2023 Jamie Zawinski <jwz@jwz.org>
    1212
    1313   Permission to use, copy, modify, distribute, and sell this software and its
     
    2424
    2525     geolocate_service_urls - filter the preferences setting
    26      geolocate_comment_text - filter the formatteted location output
     26     geolocate_comment_text - filter the formatted location output
    2727     geolocate_user_agent_text - filter the formatteted UA output
    2828
     
    105105
    106106  if ($json) {
    107     $errmsg = ($json['response'] ? $json['response'] :   // ip2location.com
    108                ($json['message'] ? $json['message']  :   // ipbase.com
    109                 ''));
     107    $errmsg = (($json['response'] ?? '')
     108               ? $json['response']      // ip2location.com
     109               : (($json['message'] ?? '')
     110                  ? $json['message']        // ipbase.com
     111                  : ''));
    110112    if (preg_match ('/^OK/i', $errmsg))
    111113      $errmsg = '';
     
    119121  }
    120122
    121   if ($json['data']) {
     123  if ($json['data'] ?? 0) {
    122124    $json = $json['data'];  // ipbase.com/v2/ rather than ipbase.com/json/
    123125  }
     
    142144
    143145  if ($rez == 'none')
    144     return "";
     146    return apply_filters ('geolocate_comment_text', "", $comment, $loc, $rez);
    145147
    146148  if (!$loc)
     
    294296  }
    295297
    296   if (!$rez || $rez == 'none')
    297     return $comment_text;
    298 
    299298  $loc = geolocate_comment_text ($comment, null, $rez);
    300299  if (!$loc && $admin_p)
    301300    $loc = 'Location unknown';
    302301
    303   $ua = geolocate_user_agent_text ($comment);
     302  $ua = '';
     303  if ($rez == 'city' || $rez == 'state')
     304    $ua = geolocate_user_agent_text ($comment);
    304305  if ($ua)
    305306    $loc = $loc . ($loc ? '; ' : '') . $ua;
  • geolocate-comments/tags/1.2/readme.txt

    r2782903 r3064212  
    44Tags: Geolocation, Comments
    55Requires at least: 2.7
    6 Tested up to: 6.0.2
    7 Stable tag: 1.1
     6Tested up to: 6.5
     7Stable tag: 1.2
    88License: MIT
    99
     
    3535* Support a few other sites.
    3636
     37= 1.2 =
     38* Better error messages.
     39* Added `geolocate_comment_text` filter.
     40
  • geolocate-comments/trunk/geolocate-comments.php

    r2782903 r3064212  
    33Plugin Name: Geolocate Comments
    44Plugin URI: https://www.jwz.org/geolocate-comments/
    5 Version: 1.1
     5Version: 1.2
    66Description: Save the geolocation when a new comment is posted.
    77Author: Jamie Zawinski
     
    99*/
    1010
    11 /* Copyright © 2022 Jamie Zawinski <jwz@jwz.org>
     11/* Copyright © 2022-2023 Jamie Zawinski <jwz@jwz.org>
    1212
    1313   Permission to use, copy, modify, distribute, and sell this software and its
     
    2424
    2525     geolocate_service_urls - filter the preferences setting
    26      geolocate_comment_text - filter the formatteted location output
     26     geolocate_comment_text - filter the formatted location output
    2727     geolocate_user_agent_text - filter the formatteted UA output
    2828
     
    105105
    106106  if ($json) {
    107     $errmsg = ($json['response'] ? $json['response'] :   // ip2location.com
    108                ($json['message'] ? $json['message']  :   // ipbase.com
    109                 ''));
     107    $errmsg = (($json['response'] ?? '')
     108               ? $json['response']      // ip2location.com
     109               : (($json['message'] ?? '')
     110                  ? $json['message']        // ipbase.com
     111                  : ''));
    110112    if (preg_match ('/^OK/i', $errmsg))
    111113      $errmsg = '';
     
    119121  }
    120122
    121   if ($json['data']) {
     123  if ($json['data'] ?? 0) {
    122124    $json = $json['data'];  // ipbase.com/v2/ rather than ipbase.com/json/
    123125  }
     
    142144
    143145  if ($rez == 'none')
    144     return "";
     146    return apply_filters ('geolocate_comment_text', "", $comment, $loc, $rez);
    145147
    146148  if (!$loc)
     
    294296  }
    295297
    296   if (!$rez || $rez == 'none')
    297     return $comment_text;
    298 
    299298  $loc = geolocate_comment_text ($comment, null, $rez);
    300299  if (!$loc && $admin_p)
    301300    $loc = 'Location unknown';
    302301
    303   $ua = geolocate_user_agent_text ($comment);
     302  $ua = '';
     303  if ($rez == 'city' || $rez == 'state')
     304    $ua = geolocate_user_agent_text ($comment);
    304305  if ($ua)
    305306    $loc = $loc . ($loc ? '; ' : '') . $ua;
  • geolocate-comments/trunk/readme.txt

    r2782903 r3064212  
    44Tags: Geolocation, Comments
    55Requires at least: 2.7
    6 Tested up to: 6.0.2
    7 Stable tag: 1.1
     6Tested up to: 6.5
     7Stable tag: 1.2
    88License: MIT
    99
     
    3535* Support a few other sites.
    3636
     37= 1.2 =
     38* Better error messages.
     39* Added `geolocate_comment_text` filter.
     40
Note: See TracChangeset for help on using the changeset viewer.