Plugin Directory

Changeset 3421924


Ignore:
Timestamp:
12/17/2025 12:57:48 PM (3 months ago)
Author:
justwatchplugin
Message:

Update to version 1.0.2 from GitHub

Location:
justwatch-partner-integrations
Files:
12 added
16 edited
1 copied

Legend:

Unmodified
Added
Removed
  • justwatch-partner-integrations/tags/1.0.2/justwatch-partner-integrations.php

    r3388865 r3421924  
    44 * Plugin Name: JustWatch - Partner Integrations
    55 * Description: Connect your audience to the best streaming services worldwide.
    6  * Version: 1.0.0
     6 * Version: 1.0.2
    77 * Author: JustWatch
    88 * Author URI: https://www.justwatch.com
  • justwatch-partner-integrations/tags/1.0.2/lib/Locale/Locale.php

    r3388865 r3421924  
    463463        $preferredLocales = array_filter(
    464464            array_merge(
    465                 [$this->preferredLocale],
    466                 // $this->getThirdPartyGeoIpLocales(),
     465                array( $this->preferredLocale ),
     466                array($this->getLocaleFromIp()),
    467467                $this->getUserLocales(),
    468468            ),
     
    491491        return $this->matchLocale($preferredLocales);
    492492    }
     493
     494    private function getCountryCodeFromIp(): ?string
     495    {
     496        // Option 1: GeoIP Detection Plugin
     497        if (function_exists('geoip_detect2_get_info_from_current_ip')) {
     498            $info = geoip_detect2_get_info_from_current_ip();
     499            return $info && isset($info->country->isoCode) ? strtoupper($info->country->isoCode) : null;
     500        }
     501
     502        // Option 2: Cloudflare header
     503        if (!empty($_SERVER['HTTP_CF_IPCOUNTRY'])) {
     504            return strtoupper(sanitize_text_field(wp_unslash($_SERVER['HTTP_CF_IPCOUNTRY'])));
     505        }
     506
     507        // Option 3: IP2Location via their plugin or manual integration
     508        if (function_exists('ip2location_get_country_short')) {
     509            return strtoupper(ip2location_get_country_short());
     510        }
     511
     512        return null;
     513    }
     514
     515    public function getLocaleFromIp(): ?string
     516    {
     517        $countryCode = $this->getCountryCodeFromIp();
     518
     519        if (! $countryCode) {
     520            return null;
     521        }
     522
     523        if (isset($this->regionToLocaleMap['countries'][$countryCode])) {
     524            foreach ($this->regionToLocaleMap['countries'][$countryCode] as $locale) {
     525                if (in_array($locale, $this->getAvailableLocales(), true)) {
     526                    return $locale;
     527                }
     528            }
     529        }
     530
     531        return null;
     532    }
    493533}
  • justwatch-partner-integrations/tags/1.0.2/lib/PartnerIntegrations.php

    r3388865 r3421924  
    7777            __('Customization', 'justwatch-partner-integrations'),
    7878            __('Customize the JustWatch plugin', 'justwatch-partner-integrations')
     79        );
     80        $this->addSettingsSection(
     81            'error_reporting',
     82            __('Error Reporting', 'justwatch-partner-integrations'),
    7983        );
    8084
  • justwatch-partner-integrations/tags/1.0.2/lib/Traits/ErrorTrait.php

    r3388865 r3421924  
    8282    }
    8383
     84    public function isErrorReportingEnabled(): bool
     85    {
     86        // Check if error reporting is enabled in the settings
     87        $settings = $this->getSettings();
     88
     89        if (! isset($settings['errorReportingEnabled'])) {
     90            // If the setting is not defined, return false
     91            return false; // Default to false if the setting is not defined
     92        }
     93        return (bool) $settings['errorReportingEnabled'];
     94    }
     95
    8496    public function handleError($errno, $errstr, $errfile, $errline): void
    8597    {
     98        // If error reporting is disabled, do nothing
     99        if (! $this->isErrorReportingEnabled()) {
     100            return;
     101        }
    86102        // Ignore errors that are not in the error reporting level
    87103        if ($errno === 0) {
     
    110126    private function shouldHandleException(Throwable $exception): bool
    111127    {
     128        // If error tracking is disabled, do not log the exception
     129        if (! $this->isErrorReportingEnabled()) {
     130            return false;
     131        }
    112132        // Get the stack trace
    113133        $stackTrace = $exception->getTrace();
     
    189209    public function logError(Throwable $exception): void
    190210    {
     211        if ($this->isErrorReportingEnabled() === false) {
     212            return; // Do not log if error tracking is disabled
     213        }
     214
     215        if (! defined('WP_CONTENT_DIR')) {
     216            return;
     217        }
     218
    191219        // Path to the debug.log file
    192220        $debugLogPath = $this->getDebugLogPath();
     
    275303    public function showAdminErrorNotice(): void
    276304    {
     305        if (! $this->isErrorReportingEnabled()) {
     306            return; // Do not render the script if error tracking is disabled
     307        }
    277308        $lastErrorMessage = get_transient($this->TRANSIENT_KEY_PREFIX . 'last_error_message');
    278 
    279309        if ($lastErrorMessage) {
    280310            // Create the link to the settings page
     
    439469
    440470        $envInfo   = array();
    441         $envInfo[] = 'WordPress Version: ' . $wp_version;
    442         $envInfo[] = 'Site URL: ' . site_url();
    443         $envInfo[] = 'Home URL: ' . home_url();
    444         $envInfo[] = 'PHP Version: ' . phpversion();
    445         $envInfo[] = 'MySQL Version: ' . $wpdb->db_version();
    446         $envInfo[] = 'Web Server Info: ' . $serverSoftware;
    447 
    448         $theme     = wp_get_theme();
     471        $envInfo[] = 'Environment:';
     472        $envInfo[] = '- Site URL: ' . site_url();
     473        $envInfo[] = '- Home URL: ' . home_url();
     474        $envInfo[] = '- Plugin Version: ' . $this->version;
     475        $envInfo[] = '- WordPress Version: ' . $wp_version;
     476        $envInfo[] = '- PHP Version: ' . phpversion();
     477        $envInfo[] = '- MySQL Version: ' . $wpdb->db_version();
     478        $envInfo[] = '- Web Server Info: ' . $serverSoftware;
     479
     480        // Collect the most common wp-config constants
     481        $envInfo[] = 'Config:';
     482        $envInfo[] = '- WP_DEBUG: ' . (defined('WP_DEBUG') ? (WP_DEBUG ? 'true' : 'false') : 'Not defined');
     483        $envInfo[] = '- WP_DEBUG_LOG: ' . (defined('WP_DEBUG_LOG') ? (WP_DEBUG_LOG ? 'true' : 'false') : 'Not defined');
     484        $envInfo[] = '- WP_DEBUG_DISPLAY: ' . (defined('WP_DEBUG_DISPLAY')
     485            ? (boolval(constant('WP_DEBUG_DISPLAY')) ? 'true' : 'false') : 'Not defined' // Please Psalm
     486        );
     487        $envInfo[] = '- WP_MEMORY_LIMIT: ' . (defined('WP_MEMORY_LIMIT') ? WP_MEMORY_LIMIT : 'Not defined');
     488        $envInfo[] = '- WP_MAX_MEMORY_LIMIT: ' . (defined('WP_MAX_MEMORY_LIMIT') ? WP_MAX_MEMORY_LIMIT : 'Not defined');
     489        $envInfo[] = '- WP_CONTENT_DIR: ' . (defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : 'Not defined');
     490        $envInfo[] = '- WP_PLUGIN_DIR: ' . (defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : 'Not defined');
     491
     492        // Multisite information
     493        if (is_multisite()) {
     494            $envInfo[] = 'Multisite: Enabled';
     495            $networkDetails = get_network();
     496
     497            if ($networkDetails) {
     498                $envInfo[] = '- Network ID: ' . $networkDetails->id;
     499                $envInfo[] = '- Network Name: ' . $networkDetails->site_name;
     500                $envInfo[] = '- Network Domain: ' . $networkDetails->domain;
     501                $envInfo[] = '- Network Path: ' . $networkDetails->path;
     502            } else {
     503                $envInfo[] = '- Network ID: Not available';
     504            }
     505        } else {
     506            $envInfo[] = 'Multisite: Disabled';
     507        }
     508
     509        $theme = wp_get_theme();
    449510        $envInfo[] =
    450511            'Active Theme: ' .
  • justwatch-partner-integrations/tags/1.0.2/lib/Traits/SettingsTrait.php

    r3388865 r3421924  
    381381                    esc_attr((string) ( $attrs['placeholder'] ?? '' )),
    382382                    checked($value, 1, false),
    383                     esc_html($field['text'] ?? '')
     383                    esc_html($field['text'] ?? ($field['label'] ?? ''))
    384384                );
    385385                break;
  • justwatch-partner-integrations/tags/1.0.2/lib/schema.php

    r3388865 r3421924  
    184184        ],
    185185    ],
     186    'errorReportingEnabled' => [
     187        'label' => __('Error Reporting Enabled', 'justwatch-partner-integrations'),
     188        'option' => 'justwatch/partner-settings/error_reporting_enabled',
     189        'type' => 'checkbox',
     190        'default' => false,
     191        'section' => 'error_reporting',
     192        'text' => __('Enable Error Reporting', 'justwatch-partner-integrations'),
     193        'description' => __("
     194            Enable error reporting for the JustWatch plugin.<br/>
     195            This will help us improve the service by collecting error reports
     196            without the need of putting your site into debug mode.
     197        ", 'justwatch-partner-integrations'),
     198        'attrs' => [
     199            'rows' => 3,
     200        ],
     201    ],
    186202];
  • justwatch-partner-integrations/tags/1.0.2/package.json

    r3388865 r3421924  
    11{
    22  "name": "wp-justwatch-partners",
    3   "version": "1.0.0",
     3  "version": "1.0.2",
    44  "description": "Real-time Video-On-Demand availability for up to 250,000 movies and 60,000 TV shows in over 100 countries.",
    55  "main": "index.js",
  • justwatch-partner-integrations/tags/1.0.2/readme.txt

    r3388865 r3421924  
    22Contributors: justwatchplugin
    33Tags: streaming, movies, tv-shows, Video-On-Demand, content-creation
    4 Stable tag: 1.0.0
     4Stable tag: 1.0.2
    55Requires at least: 6.5
    66Tested up to: 6.8
     
    9090== Changelog ==
    9191
     92= 1.0.2 - 2025-11-18 =
     93* Added: Fix geo-ip integration issue
     94* Added: Make error reporting optional
     95
     96= 1.0.1 - 2025-11-18 =
     97* Maintenance release
     98
    9299= 1.0.0 - 2025-03-28 =
    93100* Added: Add WP store requirements
  • justwatch-partner-integrations/trunk/justwatch-partner-integrations.php

    r3388865 r3421924  
    44 * Plugin Name: JustWatch - Partner Integrations
    55 * Description: Connect your audience to the best streaming services worldwide.
    6  * Version: 1.0.0
     6 * Version: 1.0.2
    77 * Author: JustWatch
    88 * Author URI: https://www.justwatch.com
  • justwatch-partner-integrations/trunk/lib/Locale/Locale.php

    r3388865 r3421924  
    463463        $preferredLocales = array_filter(
    464464            array_merge(
    465                 [$this->preferredLocale],
    466                 // $this->getThirdPartyGeoIpLocales(),
     465                array( $this->preferredLocale ),
     466                array($this->getLocaleFromIp()),
    467467                $this->getUserLocales(),
    468468            ),
     
    491491        return $this->matchLocale($preferredLocales);
    492492    }
     493
     494    private function getCountryCodeFromIp(): ?string
     495    {
     496        // Option 1: GeoIP Detection Plugin
     497        if (function_exists('geoip_detect2_get_info_from_current_ip')) {
     498            $info = geoip_detect2_get_info_from_current_ip();
     499            return $info && isset($info->country->isoCode) ? strtoupper($info->country->isoCode) : null;
     500        }
     501
     502        // Option 2: Cloudflare header
     503        if (!empty($_SERVER['HTTP_CF_IPCOUNTRY'])) {
     504            return strtoupper(sanitize_text_field(wp_unslash($_SERVER['HTTP_CF_IPCOUNTRY'])));
     505        }
     506
     507        // Option 3: IP2Location via their plugin or manual integration
     508        if (function_exists('ip2location_get_country_short')) {
     509            return strtoupper(ip2location_get_country_short());
     510        }
     511
     512        return null;
     513    }
     514
     515    public function getLocaleFromIp(): ?string
     516    {
     517        $countryCode = $this->getCountryCodeFromIp();
     518
     519        if (! $countryCode) {
     520            return null;
     521        }
     522
     523        if (isset($this->regionToLocaleMap['countries'][$countryCode])) {
     524            foreach ($this->regionToLocaleMap['countries'][$countryCode] as $locale) {
     525                if (in_array($locale, $this->getAvailableLocales(), true)) {
     526                    return $locale;
     527                }
     528            }
     529        }
     530
     531        return null;
     532    }
    493533}
  • justwatch-partner-integrations/trunk/lib/PartnerIntegrations.php

    r3388865 r3421924  
    7777            __('Customization', 'justwatch-partner-integrations'),
    7878            __('Customize the JustWatch plugin', 'justwatch-partner-integrations')
     79        );
     80        $this->addSettingsSection(
     81            'error_reporting',
     82            __('Error Reporting', 'justwatch-partner-integrations'),
    7983        );
    8084
  • justwatch-partner-integrations/trunk/lib/Traits/ErrorTrait.php

    r3388865 r3421924  
    8282    }
    8383
     84    public function isErrorReportingEnabled(): bool
     85    {
     86        // Check if error reporting is enabled in the settings
     87        $settings = $this->getSettings();
     88
     89        if (! isset($settings['errorReportingEnabled'])) {
     90            // If the setting is not defined, return false
     91            return false; // Default to false if the setting is not defined
     92        }
     93        return (bool) $settings['errorReportingEnabled'];
     94    }
     95
    8496    public function handleError($errno, $errstr, $errfile, $errline): void
    8597    {
     98        // If error reporting is disabled, do nothing
     99        if (! $this->isErrorReportingEnabled()) {
     100            return;
     101        }
    86102        // Ignore errors that are not in the error reporting level
    87103        if ($errno === 0) {
     
    110126    private function shouldHandleException(Throwable $exception): bool
    111127    {
     128        // If error tracking is disabled, do not log the exception
     129        if (! $this->isErrorReportingEnabled()) {
     130            return false;
     131        }
    112132        // Get the stack trace
    113133        $stackTrace = $exception->getTrace();
     
    189209    public function logError(Throwable $exception): void
    190210    {
     211        if ($this->isErrorReportingEnabled() === false) {
     212            return; // Do not log if error tracking is disabled
     213        }
     214
     215        if (! defined('WP_CONTENT_DIR')) {
     216            return;
     217        }
     218
    191219        // Path to the debug.log file
    192220        $debugLogPath = $this->getDebugLogPath();
     
    275303    public function showAdminErrorNotice(): void
    276304    {
     305        if (! $this->isErrorReportingEnabled()) {
     306            return; // Do not render the script if error tracking is disabled
     307        }
    277308        $lastErrorMessage = get_transient($this->TRANSIENT_KEY_PREFIX . 'last_error_message');
    278 
    279309        if ($lastErrorMessage) {
    280310            // Create the link to the settings page
     
    439469
    440470        $envInfo   = array();
    441         $envInfo[] = 'WordPress Version: ' . $wp_version;
    442         $envInfo[] = 'Site URL: ' . site_url();
    443         $envInfo[] = 'Home URL: ' . home_url();
    444         $envInfo[] = 'PHP Version: ' . phpversion();
    445         $envInfo[] = 'MySQL Version: ' . $wpdb->db_version();
    446         $envInfo[] = 'Web Server Info: ' . $serverSoftware;
    447 
    448         $theme     = wp_get_theme();
     471        $envInfo[] = 'Environment:';
     472        $envInfo[] = '- Site URL: ' . site_url();
     473        $envInfo[] = '- Home URL: ' . home_url();
     474        $envInfo[] = '- Plugin Version: ' . $this->version;
     475        $envInfo[] = '- WordPress Version: ' . $wp_version;
     476        $envInfo[] = '- PHP Version: ' . phpversion();
     477        $envInfo[] = '- MySQL Version: ' . $wpdb->db_version();
     478        $envInfo[] = '- Web Server Info: ' . $serverSoftware;
     479
     480        // Collect the most common wp-config constants
     481        $envInfo[] = 'Config:';
     482        $envInfo[] = '- WP_DEBUG: ' . (defined('WP_DEBUG') ? (WP_DEBUG ? 'true' : 'false') : 'Not defined');
     483        $envInfo[] = '- WP_DEBUG_LOG: ' . (defined('WP_DEBUG_LOG') ? (WP_DEBUG_LOG ? 'true' : 'false') : 'Not defined');
     484        $envInfo[] = '- WP_DEBUG_DISPLAY: ' . (defined('WP_DEBUG_DISPLAY')
     485            ? (boolval(constant('WP_DEBUG_DISPLAY')) ? 'true' : 'false') : 'Not defined' // Please Psalm
     486        );
     487        $envInfo[] = '- WP_MEMORY_LIMIT: ' . (defined('WP_MEMORY_LIMIT') ? WP_MEMORY_LIMIT : 'Not defined');
     488        $envInfo[] = '- WP_MAX_MEMORY_LIMIT: ' . (defined('WP_MAX_MEMORY_LIMIT') ? WP_MAX_MEMORY_LIMIT : 'Not defined');
     489        $envInfo[] = '- WP_CONTENT_DIR: ' . (defined('WP_CONTENT_DIR') ? WP_CONTENT_DIR : 'Not defined');
     490        $envInfo[] = '- WP_PLUGIN_DIR: ' . (defined('WP_PLUGIN_DIR') ? WP_PLUGIN_DIR : 'Not defined');
     491
     492        // Multisite information
     493        if (is_multisite()) {
     494            $envInfo[] = 'Multisite: Enabled';
     495            $networkDetails = get_network();
     496
     497            if ($networkDetails) {
     498                $envInfo[] = '- Network ID: ' . $networkDetails->id;
     499                $envInfo[] = '- Network Name: ' . $networkDetails->site_name;
     500                $envInfo[] = '- Network Domain: ' . $networkDetails->domain;
     501                $envInfo[] = '- Network Path: ' . $networkDetails->path;
     502            } else {
     503                $envInfo[] = '- Network ID: Not available';
     504            }
     505        } else {
     506            $envInfo[] = 'Multisite: Disabled';
     507        }
     508
     509        $theme = wp_get_theme();
    449510        $envInfo[] =
    450511            'Active Theme: ' .
  • justwatch-partner-integrations/trunk/lib/Traits/SettingsTrait.php

    r3388865 r3421924  
    381381                    esc_attr((string) ( $attrs['placeholder'] ?? '' )),
    382382                    checked($value, 1, false),
    383                     esc_html($field['text'] ?? '')
     383                    esc_html($field['text'] ?? ($field['label'] ?? ''))
    384384                );
    385385                break;
  • justwatch-partner-integrations/trunk/lib/schema.php

    r3388865 r3421924  
    184184        ],
    185185    ],
     186    'errorReportingEnabled' => [
     187        'label' => __('Error Reporting Enabled', 'justwatch-partner-integrations'),
     188        'option' => 'justwatch/partner-settings/error_reporting_enabled',
     189        'type' => 'checkbox',
     190        'default' => false,
     191        'section' => 'error_reporting',
     192        'text' => __('Enable Error Reporting', 'justwatch-partner-integrations'),
     193        'description' => __("
     194            Enable error reporting for the JustWatch plugin.<br/>
     195            This will help us improve the service by collecting error reports
     196            without the need of putting your site into debug mode.
     197        ", 'justwatch-partner-integrations'),
     198        'attrs' => [
     199            'rows' => 3,
     200        ],
     201    ],
    186202];
  • justwatch-partner-integrations/trunk/package.json

    r3388865 r3421924  
    11{
    22  "name": "wp-justwatch-partners",
    3   "version": "1.0.0",
     3  "version": "1.0.2",
    44  "description": "Real-time Video-On-Demand availability for up to 250,000 movies and 60,000 TV shows in over 100 countries.",
    55  "main": "index.js",
  • justwatch-partner-integrations/trunk/readme.txt

    r3388865 r3421924  
    22Contributors: justwatchplugin
    33Tags: streaming, movies, tv-shows, Video-On-Demand, content-creation
    4 Stable tag: 1.0.0
     4Stable tag: 1.0.2
    55Requires at least: 6.5
    66Tested up to: 6.8
     
    9090== Changelog ==
    9191
     92= 1.0.2 - 2025-11-18 =
     93* Added: Fix geo-ip integration issue
     94* Added: Make error reporting optional
     95
     96= 1.0.1 - 2025-11-18 =
     97* Maintenance release
     98
    9299= 1.0.0 - 2025-03-28 =
    93100* Added: Add WP store requirements
Note: See TracChangeset for help on using the changeset viewer.