Plugin Directory

Changeset 2931216


Ignore:
Timestamp:
06/27/2023 04:35:54 AM (3 years ago)
Author:
termageddon
Message:

[1.3.4] Privacy Settings Link, Divi Compatibility, and improved WP-CLI compatibility.

Location:
termageddon-usercentrics
Files:
6 edited
19 copied

Legend:

Unmodified
Added
Removed
  • termageddon-usercentrics/tags/1.3.4/README.txt

    r2922465 r2931216  
    55Requires at least: 3.0.1
    66Tested up to: 6.2.2
    7 Stable tag: 1.3.3
     7Stable tag: 1.3.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626
    2727== Changelog ==
     28
     29= 1.3.4 =
     30
     31-   [ADD] Added alternate privacy settings link embed as an alternative for shortcodes (Divi Support).
     32-   [ADD] Added settings section to showcase privacy settings link settings.
     33-   [CHANGE] Moved Hide Privacy Settings Link option to Settings page instead of geolocation page.
     34-   [FIX] Improved handling for WP_CLI actions and error logging.
    2835
    2936= 1.3.3 =
  • termageddon-usercentrics/tags/1.3.4/admin/class-termageddon-usercentrics-admin.php

    r2922465 r2931216  
    213213
    214214        return array(
    215             'before_section' => '<div class="tu-settings-tab tu-tab-' . $tab . ( $tab_active ? '' : ' tu-section-hidden' ) . '" >', // Start a new tab
     215            'before_section' => '<div class="tu-settings-tab tu-tab-' . $tab . ( $tab_active ? '' : ' tu-section-hidden' ) . '" >', // Start a new tab.
    216216            'after_section'  => '</div></div>
    217217            </div>', // Finish the additional sections setup in the html callbacks (2) and then finish the tab for a total of 3 divs.
     
    220220
    221221
    222     /** Build the default arguments for the current section
    223      *
    224      * @param mixed $tab The tab you are setting up; For use with identifying current tab and hiding/showing the tab.
    225      * @return string[]
    226      */
    227     public function add_new_subsection( string $section, array $options=[]) {
    228 
    229         $name = (isset($options['name']) ? $options['name'] : false);
    230         $description = (isset($options['description']) ? $options['description'] : false);
    231         $indent = (isset($options['indent']) ? $options['indent'] === true : false);
    232         $slim = (isset($options['slim']) ? $options['slim'] === true : false);
    233 
    234         add_settings_field(
    235             'termageddon_usercentrics_end-section-'.Termageddon_Usercentrics::generate_random_string(5),
     222    /**
     223     * Generate and appends the HTML for a new subsection based on options provided.
     224     *
     225     * @param string $section The section slug to add the section to.
     226     * @param array  $options name, description, indent, slim; Various options.
     227     * @return void
     228     */
     229    public function add_new_subsection( string $section, array $options = array() ) {
     230
     231        $name        = ( isset( $options['name'] ) ? $options['name'] : false );
     232        $description = ( isset( $options['description'] ) ? $options['description'] : false );
     233        $indent      = ( isset( $options['indent'] ) ? true === $options['indent'] : false );
     234        $slim        = ( isset( $options['slim'] ) ? true === $options['slim'] : false );
     235
     236        add_settings_field(
     237            'termageddon_usercentrics_end-section-' . Termageddon_Usercentrics::generate_random_string( 5 ),
    236238            '   </th></tr></tbody></table>
    237239            </div>
    238240            <div class="tu-toggle-section">
    239                 <span class="tu-section-title">' . esc_html__( $name , 'termageddon-usercentrics') . ':</span>
    240                 '.(empty($description) ? '' : '<p>' . esc_html__( $description, 'termageddon-usercentrics' ) . '</p>').'
     241                <span class="tu-section-title">' . esc_html( $name ) . ':</span>
     242                ' . ( empty( $description ) ? '' : '<p>' . wp_kses_post( $description ) . '</p>' ) . '
    241243            </div>
    242             <div class="'.($indent ? 'tu-toggle-section' : 'tu-settings-section').($slim ? ' slim-section' : '').'">
     244            <div class="' . ( $indent ? 'tu-toggle-section' : 'tu-settings-section' ) . ( $slim ? ' slim-section' : '' ) . '">
    243245                <table class="form-table" role="presentation">
    244246                    <tbody>
     
    253255
    254256
     257    /** Generates and appends the beta label for a field.
     258     *
     259     *  @return string  */
    255260    public static function mark_as_beta() {
    256261        return ' <span class="tu-label-warning">BETA</span>';
     
    379384        );
    380385
    381         // BREAK SECTION FOR GEOLOCATION SETTINGS
    382         $this->add_new_subsection('termageddon_usercentrics_section_settings', [
    383             'name' => 'Integrations',
    384             'description' => 'We love to partner with other plugin developers to improve support with their plugins. If you encounter an issue, please contact our support to let us know.',
    385         ]);
    386        
    387         // Disable Login.
     386        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     387        $this->add_new_subsection(
     388            'termageddon_usercentrics_section_settings',
     389            array(
     390                'name'        => 'Privacy Settings Link',
     391                'description' => 'Giving users the ability to change their privacy/consent settings is a requirement under several privacy laws. Within your Termageddon account, if you selected (on page 1 of the Cookie Policy and Consent Tool questionnaire) to use the Privacy Settings hyperlink (instead of the \'fingerprint icon\'), you will see an additional script in the \'view embed code\' page that will need to be added to your website.</p>
     392                <p>As an alternative to that additional script, you can simply use the [uc-privacysettings] shortcode, which will embed the privacy settings link. This is an easy way to add the Privacy Settings link within your global footer, for example. You can also pass in a text parameter to change the text of the link (for example, <code>[uc-privacysettings text="Change Privacy Settings"]</code>).',
     393            )
     394        );
     395
     396        // Privacy Settings Link Disable.
     397        add_settings_field(
     398            'termageddon_usercentrics_location_psl_hide',
     399            __( 'Hide Privacy Settings Link when cookie consent tool is disabled', 'termageddon-usercentrics' ),
     400            array( &$this, 'location_psl_disable_html' ), // function which prints the field.
     401            'termageddon-usercentrics', // page slug.
     402            'termageddon_usercentrics_section_settings', // section ID.
     403            array(
     404                'label_for'   => 'termageddon_usercentrics_location_psl_hide',
     405                'description' => __( 'When enabled, the Privacy Settings link will be hidden from certain users, whether that be certain logged in users (via your selections above in the “Hide widget for:” area) or if you enabled geolocation and are hiding the consent tool from certain visitors. For example, if you enable the option to hide the consent tool for logged in administrator (and enable this toggle), the Privacy Settings link will <strong>not</strong> show to logged in administrators.  If you enable the option to hide the consent tool based on geolocation for certain users, the Privacy Settings link will no longer be displayed to those respective users as well.', 'termageddon-usercentrics' ),
     406            )
     407        );
     408
     409        register_setting(
     410            'termageddon_usercentrics_settings', // settings group name.
     411            'termageddon_usercentrics_location_psl_hide', // option name.
     412            '' // sanitization function.
     413        );
     414
     415        // Privacy Settings Link Alternative Implementation.
     416        add_settings_field(
     417            'termageddon_usercentrics_psl_alternate',
     418            __( 'Privacy Settings Link - Alternative Implementation', 'termageddon-usercentrics' ),
     419            array( &$this, 'psl_alternate_implementation' ), // function which prints the field.
     420            'termageddon-usercentrics', // page slug.
     421            'termageddon_usercentrics_section_settings', // section ID.
     422            array(
     423                'label_for'   => 'termageddon_usercentrics_psl_alternate',
     424                'description' => __( 'For some theme builders including Divi, the footer (bottom bar) does not support shortcodes. If you are experiencing issues, use the following HTML code where you want to the privacy settings link to be instead of the shortcode and enable this option:', 'termageddon-usercentrics' ) . '<br><code>&lt;a id=&quot;usercentrics-psl&quot;&gt;Privacy Settings&lt;/a&gt;</code>',
     425            )
     426        );
     427
     428        register_setting(
     429            'termageddon_usercentrics_settings', // settings group name.
     430            'termageddon_usercentrics_psl_alternate', // option name.
     431            '' // sanitization function.
     432        );
     433
     434        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     435        $this->add_new_subsection(
     436            'termageddon_usercentrics_section_settings',
     437            array(
     438                'name'        => 'Integrations',
     439                'description' => 'We love to partner with other plugin developers to improve support with their plugins. If you encounter an issue, please contact our support to let us know.',
     440            )
     441        );
     442
     443        // Presto Player.
    388444        add_settings_field(
    389445            'termageddon_usercentrics_integration_presto_player',
    390             __( 'Presto Player', 'termageddon-usercentrics' ).$this->mark_as_beta(),
     446            __( 'Presto Player', 'termageddon-usercentrics' ) . $this->mark_as_beta(),
    391447            array( &$this, 'presto_player_support' ), // function which prints the field.
    392448            'termageddon-usercentrics', // page slug.
     
    516572        );
    517573
    518         // BREAK SECTION FOR GEOLOCATION SETTINGS
    519         $this->add_new_subsection('termageddon_usercentrics_section_geolocation', [
    520             'name' => 'Geo-Location Settings',
    521             'description' => 'If you are experiencing issues or unexpected behavior, toggle the "Enable Location Logging" option. Please contact our support if you have any questions.',
    522         ]);
     574        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     575        $this->add_new_subsection(
     576            'termageddon_usercentrics_section_geolocation',
     577            array(
     578                'name'        => 'Geo-Location Settings',
     579                'description' => 'If you are experiencing issues or unexpected behavior, toggle the "Enable Location Logging" option. Please contact our support if you have any questions.',
     580            )
     581        );
    523582
    524583        // Enable Geolocation Debug Mode.
     
    542601        );
    543602
    544         // Privacy Settings Link Disable.
    545         add_settings_field(
    546             'termageddon_usercentrics_location_psl_hide',
    547             __( 'Hide Privacy Settings Link when disabled', 'termageddon-usercentrics' ),
    548             array( &$this, 'location_psl_disable_html' ), // function which prints the field.
    549             'termageddon-usercentrics', // page slug.
    550             'termageddon_usercentrics_section_geolocation', // section ID.
    551             array(
    552                 'label_for'   => 'termageddon_usercentrics_location_psl_hide',
    553                 'description' => __( 'When enabled, the privacy settings link will be hidden alongside the plugin if the visitor is outside of the geo-location marked above.', 'termageddon-usercentrics' ),
    554             )
    555         );
    556 
    557         register_setting(
    558             'termageddon_usercentrics_settings', // settings group name.
    559             'termageddon_usercentrics_location_psl_hide', // option name.
    560             '' // sanitization function.
    561         );
    562603        // Enable Geolocation AJAX Mode.
    563604        add_settings_field(
     
    652693        // Options.
    653694        $default     = ( isset( $args['default'] ) ? $args['default'] : false );
    654         $label       = ( isset( $args['label'] ) ? $args['label'] : false );
     695        $label       = ( isset( $args['label'] ) ? $args['label'] : '' );
    655696        $tip         = ( isset( $args['tip'] ) ? $args['tip'] : null );
    656697        $description = ( isset( $args['description'] ) ? $args['description'] : null );
     
    659700        $is_checked = get_option( $option_name, $default ) ? true : false;
    660701
    661         echo '<input type="checkbox"  class="termageddon-checkbox wppd-ui-toggle' . ( $label ? ' label-' . esc_attr( $label ) : '' ) . '" id="' . esc_attr( $option_name ) . '" name="' . esc_attr( $option_name ) . '" value="1" ' . checked( 1, $is_checked, false ) . ' />';
     702        echo '<input type="checkbox"  class="termageddon-checkbox wppd-ui-toggle' . ( ! empty( $label ) ? ' label-' . esc_attr( $label ) : '' ) . '" id="' . esc_attr( $option_name ) . '" name="' . esc_attr( $option_name ) . '" value="1" ' . checked( 1, $is_checked, false ) . ' />';
    662703
    663704        if ( $tip ) {
     
    665706        }
    666707        if ( $description ) {
    667             echo '<p>' . esc_html( $description ) . '</p>';
     708            echo '<p>' . wp_kses_post( $description ) . '</p>';
    668709        }
    669710
     
    702743        self::generate_checkbox( 'admin', 'disable', $args );
    703744    }
    704    
     745
    705746    /**
    706747     * The HTML field for the admin disable checkbox.
     
    730771     */
    731772    public function location_psl_disable_html( array $args ) {
    732         $args['default'] = true;
    733773        self::generate_checkbox( 'psl_hide', 'location', $args );
     774    }
     775    /**
     776     * The HTML field for the psl hidden checkbox.
     777     *
     778     * @param array $args The arguments provided by the add_settings_field() method.
     779     * @return void
     780     */
     781    public function psl_alternate_implementation( array $args ) {
     782        self::generate_checkbox( 'alternate', 'psl', $args );
    734783    }
    735784    /**
  • termageddon-usercentrics/tags/1.3.4/includes/class-termageddon-usercentrics.php

    r2922465 r2931216  
    312312        return $execution_time;
    313313    }
    314    
    315    
     314
     315
    316316    /**
    317317     * Generate a random string with specified paramaters
    318318     *
    319      * @param int $length The length of string to generate.
     319     * @param int   $length The length of string to generate.
    320320     * @param array $options The various options to pass in. 'type' is a valid option.
    321321     * @return string $randomString - The randomized string
    322322     */
    323     public static function generate_random_string(int $length=10, array $options=[]) {
    324         $type = (isset($options['type']) ? $options['type'] : null);
    325         switch (strtolower($type)) {
     323    public static function generate_random_string( int $length = 10, array $options = array() ) {
     324        $type = ( isset( $options['type'] ) ? $options['type'] : null );
     325        switch ( strtolower( $type ) ) {
    326326            case 'letters':
    327327                $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     
    335335        }
    336336
    337         //Generate String
    338         $charactersLength = strlen($characters);
    339         $randomString     = '';
    340         for ($i = 0; $i < $length; $i++) {
    341             $randomString .= $characters[rand(0, $charactersLength - 1)];
    342         }
    343 
    344         return $randomString;
     337        // Generate String.
     338        $characters_length = strlen( $characters );
     339        $random_string     = '';
     340        for ( $i = 0; $i < $length; $i++ ) {
     341            $random_string .= $characters[ wp_rand( 0, $characters_length - 1 ) ];
     342        }
     343
     344        return $random_string;
    345345
    346346    }
     
    420420    }
    421421
    422     /** @return int  */
     422    /**
     423     * Return the integer count of database download errors.
     424     *
     425     * @return int  */
    423426    public static function count_download_errors(): int {
    424427        return (int) get_option( 'termageddon_usercentrics_download_error_count', 0 );
     
    426429
    427430
    428     /** @return array  */
     431    /**
     432     * Return a list of error logs generated by the download.
     433     *
     434     * @return array  */
    429435    public static function get_download_error_logs(): array {
    430436        return (array) array_filter( get_option( 'termageddon_usercentrics_download_error_log', array() ) );
     
    725731     */
    726732    public static function should_hide_psl() {
    727         return ( get_option( 'termageddon_usercentrics_location_psl_hide', true ) ? true : false );
     733        return ( get_option( 'termageddon_usercentrics_location_psl_hide', false ) ? true : false );
     734
     735    }
     736
     737
     738    /**
     739     * Returns whether debug mode is enabled via the query paramater
     740     *
     741     * @return bool
     742     */
     743    public static function should_use_alternate_psl() {
     744        return ( get_option( 'termageddon_usercentrics_psl_alternate', false ) ? true : false );
    728745
    729746    }
     
    736753     */
    737754    public static function debug( ...$msg ) {
    738         if ( self::is_debug_mode_enabled() && ! wp_doing_ajax() ) {
    739             // Display message on frontend.
    740             // echo '<div class="error"><pre>' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '</pre></div>';.
    741 
    742             // Display message in browser console.
    743             echo '<script>
    744                 console.log(\'TERMAGEDDON USERCENTRICS\', `' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '`);
    745             </script>';
    746         }
     755        if ( ! self::is_debug_mode_enabled() ) {
     756            return; // Check to ensure debug mode is enabled.
     757        }
     758
     759        if ( wp_doing_ajax() ) {
     760            return; // Check for Ajax.
     761        }
     762
     763        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     764            return; // Check for CLI.
     765        }
     766
     767        // Display message on frontend.
     768        // echo '<div class="error"><pre>' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '</pre></div>';.
     769
     770        // Display message in browser console.
     771        echo '<script>
     772            console.log(\'TERMAGEDDON USERCENTRICS\', `' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '`);
     773        </script>';
    747774    }
    748775
     
    840867     *
    841868     * @return string  */
    842     public static function get_location_displayname() {
     869    public static function get_location_displayname(): string {
    843870        list('city' => $city, 'state' => $state, 'country' => $country) = self::lookup_ip_address();
    844871
     
    854881     * @return bool
    855882     */
    856     public static function is_geoip_enabled() {
     883    public static function is_geoip_enabled(): bool {
    857884        $show_in_eu         = get_option( 'termageddon_usercentrics_show_in_eu', false ) ? true : false;
    858885        $show_in_uk         = get_option( 'termageddon_usercentrics_show_in_uk', false ) ? true : false;
     
    862889        return ( $show_in_eu || $show_in_uk || $show_in_canada || $show_in_california || $show_in_virginia );
    863890    }
    864    
    865     /** Identifies if any geoip location is enabled.
    866      *
     891
     892
     893    /**
     894     * Check if the given integration is enabled.
     895     *
     896     * @param string $integration The slug of the integration to check.
    867897     * @return bool
    868898     */
    869     public static function is_integration_enabled( string $int ) {
    870         return get_option( 'termageddon_usercentrics_integration_'.$int, false ) ? true : false;
     899    public static function is_integration_enabled( string $integration ): bool {
     900        return get_option( 'termageddon_usercentrics_integration_' . $integration, false ) ? true : false;
    871901    }
    872902
     
    875905     *
    876906     * @return bool  */
    877     public static function is_located_in_colorado() {
     907    public static function is_located_in_colorado(): bool {
    878908        list( 'state' => $state ) = self::lookup_ip_address();
    879909        return ( null === $state || 'Colorado' === $state );
     
    885915     *
    886916     * @return bool  */
    887     public static function is_located_in_california() {
     917    public static function is_located_in_california(): bool {
    888918        list( 'state' => $state ) = self::lookup_ip_address();
    889919        return ( null === $state || 'California' === $state );
     
    895925     *
    896926     * @return bool  */
    897     public static function is_located_in_virginia() {
     927    public static function is_located_in_virginia(): bool {
    898928        list( 'state' => $state ) = self::lookup_ip_address();
    899929        return ( null === $state || 'Virginia' === $state );
     
    905935     *
    906936     * @return bool  */
    907     public static function is_located_in_canada() {
     937    public static function is_located_in_canada(): bool {
    908938        list( 'country' => $country ) = self::lookup_ip_address();
    909939        return ( null === $country || 'Canada' === $country );
     
    915945     *
    916946     * @return bool  */
    917     public static function is_located_in_eu() {
     947    public static function is_located_in_eu(): bool {
    918948        list( 'country' => $country ) = self::lookup_ip_address();
    919949
     
    959989     *
    960990     * @return bool  */
    961     public static function is_located_in_uk() {
     991    public static function is_located_in_uk(): bool {
    962992        list( 'country' => $country ) = self::lookup_ip_address();
    963993        return ( null === $country || 'United Kingdom' === $country );
     
    9701000     *
    9711001     * @return bool  */
    972     public static function should_hide_due_to_location() {
     1002    public static function should_hide_due_to_location(): bool {
    9731003        $show_in_eu         = get_option( 'termageddon_usercentrics_show_in_eu', false ) ? true : false;
    9741004        $show_in_uk         = get_option( 'termageddon_usercentrics_show_in_uk', false ) ? true : false;
     
    10211051     *
    10221052     * @return bool  */
    1023     public static function is_ajax_mode_enabled() {
     1053    public static function is_ajax_mode_enabled(): bool {
    10241054        if ( ! self::is_geoip_enabled() ) {
    10251055            return false;
  • termageddon-usercentrics/tags/1.3.4/languages/termageddon-usercentrics.pot

    r2890756 r2931216  
    44"Project-Id-Version: Termageddon + Usercentrics\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2023-03-30 22:08+0000\n"
     6"POT-Creation-Date: 2023-06-27 04:32+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1717"X-Domain: termageddon-usercentrics"
    1818
    19 #: admin/class-termageddon-usercentrics-admin.php:292
     19#: admin/class-termageddon-usercentrics-admin.php:335
    2020msgid "Administrators"
    2121msgstr ""
     
    2525msgstr ""
    2626
    27 #: admin/class-termageddon-usercentrics-admin.php:423
     27#: admin/class-termageddon-usercentrics-admin.php:541
    2828msgid "California (CPRA)"
    2929msgstr ""
    3030
    31 #: admin/class-termageddon-usercentrics-admin.php:405
     31#: admin/class-termageddon-usercentrics-admin.php:523
    3232msgid "Canada (PIPEDA)"
    3333msgstr ""
    3434
    3535#. section ID.
    36 #: admin/class-termageddon-usercentrics-admin.php:544
     36#: admin/class-termageddon-usercentrics-admin.php:633
    3737msgid "Control Panel"
    3838msgstr ""
    3939
    40 #: admin/class-termageddon-usercentrics-admin.php:796
     40#: admin/class-termageddon-usercentrics-admin.php:904
    4141msgid "Cookie Policy and Consent Solution"
    4242msgstr ""
     
    5252msgstr ""
    5353
    54 #: admin/class-termageddon-usercentrics-admin.php:310
     54#: admin/class-termageddon-usercentrics-admin.php:353
    5555msgid "Editors"
    5656msgstr ""
    5757
    5858#: admin/class-termageddon-usercentrics-admin.php:162
    59 #: admin/class-termageddon-usercentrics-admin.php:255
     59#: admin/class-termageddon-usercentrics-admin.php:298
    6060msgid "Embed Code"
    6161msgstr ""
    6262
    63 #: admin/class-termageddon-usercentrics-admin.php:479
     63#: admin/class-termageddon-usercentrics-admin.php:586
    6464msgid "Enable location logging"
    6565msgstr ""
    6666
    67 #: admin/class-termageddon-usercentrics-admin.php:517
     67#: admin/class-termageddon-usercentrics-admin.php:606
    6868msgid "Enable page caching support via AJAX"
    6969msgstr ""
    7070
    71 #: admin/class-termageddon-usercentrics-admin.php:558
     71#: admin/class-termageddon-usercentrics-admin.php:647
    7272msgid "Error Count"
    7373msgstr ""
     
    7777msgstr ""
    7878
    79 #: admin/class-termageddon-usercentrics-admin.php:576
     79#: admin/class-termageddon-usercentrics-admin.php:665
    8080msgid "Error List"
    8181msgstr ""
    8282
    83 #: admin/class-termageddon-usercentrics-admin.php:369
     83#: admin/class-termageddon-usercentrics-admin.php:487
    8484msgid "European Union & European Economic Area (GDPR)"
    8585msgstr ""
     
    8989msgstr ""
    9090
     91#: admin/class-termageddon-usercentrics-admin.php:424
     92msgid ""
     93"For some theme builders including Divi, the footer (bottom bar) does not "
     94"support shortcodes. If you are experiencing issues, use the following HTML "
     95"code where you want to the privacy settings link to be instead of the "
     96"shortcode and enable this option:"
     97msgstr ""
     98
    9199#. section ID.
    92100#: admin/class-termageddon-usercentrics-admin.php:164
    93 #: admin/class-termageddon-usercentrics-admin.php:355
     101#: admin/class-termageddon-usercentrics-admin.php:473
    94102msgid "Geo-Location"
    95103msgstr ""
     
    119127msgstr ""
    120128
    121 #: admin/class-termageddon-usercentrics-admin.php:499
    122 msgid "Hide Privacy Settings Link when disabled"
     129#: admin/class-termageddon-usercentrics-admin.php:399
     130msgid "Hide Privacy Settings Link when cookie consent tool is disabled"
    123131msgstr ""
    124132
     
    127135msgstr ""
    128136
    129 #: admin/class-termageddon-usercentrics-admin.php:463
    130 msgid ""
    131 "If you are experiencing issues or unexpected behavior, toggle the \"Enable "
    132 "Location Logging\" option. Please contact our support if you have any "
    133 "questions."
    134 msgstr ""
    135 
    136 #: admin/class-termageddon-usercentrics-admin.php:814
     137#: admin/class-termageddon-usercentrics-admin.php:922
    137138msgid "If you are using the Divi theme"
    138139msgstr ""
    139140
    140 #: admin/class-termageddon-usercentrics-admin.php:813
     141#: admin/class-termageddon-usercentrics-admin.php:921
    141142msgid ""
    142143"If you would like to remove Usercentrics for logged in users such as admins, "
     
    152153msgstr ""
    153154
    154 #: admin/class-termageddon-usercentrics-admin.php:328
     155#: admin/class-termageddon-usercentrics-admin.php:371
    155156msgid "Logged-in Users"
    156157msgstr ""
    157158
     159#: admin/class-termageddon-usercentrics-admin.php:446
     160msgid "Presto Player"
     161msgstr ""
     162
     163#: admin/class-termageddon-usercentrics-admin.php:418
     164msgid "Privacy Settings Link - Alternative Implementation"
     165msgstr ""
     166
    158167#. section ID.
    159 #: includes/class-termageddon-usercentrics.php:344
     168#: includes/class-termageddon-usercentrics.php:378
    160169#: admin/class-termageddon-usercentrics-admin.php:163
    161 #: admin/class-termageddon-usercentrics-admin.php:283
     170#: admin/class-termageddon-usercentrics-admin.php:326
    162171msgid "Settings"
    163172msgstr ""
     
    178187msgstr ""
    179188
    180 #: admin/class-termageddon-usercentrics-admin.php:850
     189#: admin/class-termageddon-usercentrics-admin.php:958
    181190msgid ""
    182191"To reset any of the backend variables, update the values below and save your "
     
    184193msgstr ""
    185194
    186 #: admin/class-termageddon-usercentrics-admin.php:387
     195#: admin/class-termageddon-usercentrics-admin.php:505
    187196msgid "United Kingdom (UK DPA)"
    188197msgstr ""
    189198
    190 #: admin/class-termageddon-usercentrics-admin.php:795
     199#: admin/class-termageddon-usercentrics-admin.php:903
    191200msgid "Upon generating your "
    192201msgstr ""
    193202
    194 #: admin/class-termageddon-usercentrics-admin.php:781
     203#: admin/class-termageddon-usercentrics-admin.php:889
    195204msgid "Upon saving, all previous errors in the log will be deleted."
    196205msgstr ""
    197206
    198 #: admin/class-termageddon-usercentrics-admin.php:441
     207#: admin/class-termageddon-usercentrics-admin.php:559
    199208msgid "Virginia (VCDPA)"
    200209msgstr ""
     
    207216msgstr ""
    208217
    209 #: admin/class-termageddon-usercentrics-admin.php:505
    210 msgid ""
    211 "When enabled, the privacy settings link will be hidden alongside the plugin "
    212 "if the visitor is outside of the geo-location marked above."
    213 msgstr ""
    214 
    215 #: admin/class-termageddon-usercentrics-admin.php:485
     218#: admin/class-termageddon-usercentrics-admin.php:405
     219msgid ""
     220"When enabled, the Privacy Settings link will be hidden from certain users, "
     221"whether that be certain logged in users (via your selections above in the "
     222"“Hide widget for:” area) or if you enabled geolocation and are hiding the "
     223"consent tool from certain visitors. For example, if you enable the option to "
     224"hide the consent tool for logged in administrator (and enable this toggle), "
     225"the Privacy Settings link will <strong>not</strong> show to logged in "
     226"administrators.  If you enable the option to hide the consent tool based on "
     227"geolocation for certain users, the Privacy Settings link will no longer be "
     228"displayed to those respective users as well."
     229msgstr ""
     230
     231#: admin/class-termageddon-usercentrics-admin.php:592
    216232msgid ""
    217233"When enabled, the visitor's location can be viewed in the browser console, "
     
    219235msgstr ""
    220236
    221 #: admin/class-termageddon-usercentrics-admin.php:523
     237#: admin/class-termageddon-usercentrics-admin.php:612
    222238msgid ""
    223239"When enabled, the visitor's location is checked via javascript to allow "
     
    225241msgstr ""
    226242
    227 #: admin/class-termageddon-usercentrics-admin.php:832
     243#: admin/class-termageddon-usercentrics-admin.php:940
    228244msgid ""
    229245"When enabled, you will be collecting IP addresses for the purposes of "
     
    241257msgstr ""
    242258
    243 #: admin/class-termageddon-usercentrics-admin.php:797
     259#: admin/class-termageddon-usercentrics-admin.php:905
    244260msgid ""
    245261"within your Termageddon account, you will be brought to the \"View embed "
     
    248264msgstr ""
    249265
    250 #: admin/class-termageddon-usercentrics-admin.php:815
     266#: admin/class-termageddon-usercentrics-admin.php:923
    251267msgid ""
    252268"you will need to enable at least one of the settings below to ensure logged "
  • termageddon-usercentrics/tags/1.3.4/public/class-termageddon-usercentrics-public.php

    r2922465 r2931216  
    112112            );
    113113        }
     114
     115        // Load Alternate PSL Logic.
     116        if ( Termageddon_Usercentrics::should_use_alternate_psl() ) {
     117            add_action( 'wp_footer', array( $this, 'replace_usercentrics_psl_with_shortcode' ) );
     118        }
    114119    }
    115120
     
    134139        echo wp_kses( $script, self::ALLOWED_HTML );
    135140        echo '<!-- END TERMAGEDDON + USERCENTRICS -->';
     141    }
     142
     143
     144    /**
     145     * Action to allow replacing a broken psl with the fully functional psl.
     146     *
     147     * @return void  */
     148    public function replace_usercentrics_psl_with_shortcode() {
     149        ob_start();
     150        ?>
     151        <script id="termageddon-psl-alternate-js">
     152            (function($) {
     153                $(document).ready(function() {
     154                    jQuery('a#usercentrics-psl').each(function() {
     155                        let newElem = jQuery(`<?php echo do_shortcode( '[uc-privacysettings]' ); ?>`);
     156                        if (!["","Privacy Settings"].includes(jQuery(this).text())) newElem.text(jQuery(this).text())
     157                        jQuery(this).replaceWith(newElem);
     158                    })
     159                })
     160            })(jQuery);
     161        </script>
     162        <?php
     163        ob_end_flush();
    136164    }
    137165
     
    195223          </script>';
    196224        }
    197        
     225
    198226        // Presto Player Integration Javascript.
    199         if ( Termageddon_Usercentrics::is_integration_enabled('presto_player') ) {
     227        if ( Termageddon_Usercentrics::is_integration_enabled( 'presto_player' ) ) {
    200228            $script .= '<script type="application/javascript" id="uc-integration-presto-player">
    201229    function uc_integration_setup(iID,service) {
  • termageddon-usercentrics/tags/1.3.4/termageddon-usercentrics.php

    r2922465 r2931216  
    1515 * Plugin Name:       Termageddon + Usercentrics
    1616 * Description:       Easily integrate the Usercentrics consent solution into your website while controlling visibility for logged in users and admins.
    17  * Version:           1.3.3
     17 * Version:           1.3.4
    1818 * Author:            Termageddon
    1919 * Author URI:        https://termageddon.com
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.3.3' );
     36define( 'TERMAGEDDON_COOKIE_VERSION', '1.3.4' );
    3737
    3838define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
  • termageddon-usercentrics/trunk/README.txt

    r2922465 r2931216  
    55Requires at least: 3.0.1
    66Tested up to: 6.2.2
    7 Stable tag: 1.3.3
     7Stable tag: 1.3.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626
    2727== Changelog ==
     28
     29= 1.3.4 =
     30
     31-   [ADD] Added alternate privacy settings link embed as an alternative for shortcodes (Divi Support).
     32-   [ADD] Added settings section to showcase privacy settings link settings.
     33-   [CHANGE] Moved Hide Privacy Settings Link option to Settings page instead of geolocation page.
     34-   [FIX] Improved handling for WP_CLI actions and error logging.
    2835
    2936= 1.3.3 =
  • termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php

    r2922465 r2931216  
    213213
    214214        return array(
    215             'before_section' => '<div class="tu-settings-tab tu-tab-' . $tab . ( $tab_active ? '' : ' tu-section-hidden' ) . '" >', // Start a new tab
     215            'before_section' => '<div class="tu-settings-tab tu-tab-' . $tab . ( $tab_active ? '' : ' tu-section-hidden' ) . '" >', // Start a new tab.
    216216            'after_section'  => '</div></div>
    217217            </div>', // Finish the additional sections setup in the html callbacks (2) and then finish the tab for a total of 3 divs.
     
    220220
    221221
    222     /** Build the default arguments for the current section
    223      *
    224      * @param mixed $tab The tab you are setting up; For use with identifying current tab and hiding/showing the tab.
    225      * @return string[]
    226      */
    227     public function add_new_subsection( string $section, array $options=[]) {
    228 
    229         $name = (isset($options['name']) ? $options['name'] : false);
    230         $description = (isset($options['description']) ? $options['description'] : false);
    231         $indent = (isset($options['indent']) ? $options['indent'] === true : false);
    232         $slim = (isset($options['slim']) ? $options['slim'] === true : false);
    233 
    234         add_settings_field(
    235             'termageddon_usercentrics_end-section-'.Termageddon_Usercentrics::generate_random_string(5),
     222    /**
     223     * Generate and appends the HTML for a new subsection based on options provided.
     224     *
     225     * @param string $section The section slug to add the section to.
     226     * @param array  $options name, description, indent, slim; Various options.
     227     * @return void
     228     */
     229    public function add_new_subsection( string $section, array $options = array() ) {
     230
     231        $name        = ( isset( $options['name'] ) ? $options['name'] : false );
     232        $description = ( isset( $options['description'] ) ? $options['description'] : false );
     233        $indent      = ( isset( $options['indent'] ) ? true === $options['indent'] : false );
     234        $slim        = ( isset( $options['slim'] ) ? true === $options['slim'] : false );
     235
     236        add_settings_field(
     237            'termageddon_usercentrics_end-section-' . Termageddon_Usercentrics::generate_random_string( 5 ),
    236238            '   </th></tr></tbody></table>
    237239            </div>
    238240            <div class="tu-toggle-section">
    239                 <span class="tu-section-title">' . esc_html__( $name , 'termageddon-usercentrics') . ':</span>
    240                 '.(empty($description) ? '' : '<p>' . esc_html__( $description, 'termageddon-usercentrics' ) . '</p>').'
     241                <span class="tu-section-title">' . esc_html( $name ) . ':</span>
     242                ' . ( empty( $description ) ? '' : '<p>' . wp_kses_post( $description ) . '</p>' ) . '
    241243            </div>
    242             <div class="'.($indent ? 'tu-toggle-section' : 'tu-settings-section').($slim ? ' slim-section' : '').'">
     244            <div class="' . ( $indent ? 'tu-toggle-section' : 'tu-settings-section' ) . ( $slim ? ' slim-section' : '' ) . '">
    243245                <table class="form-table" role="presentation">
    244246                    <tbody>
     
    253255
    254256
     257    /** Generates and appends the beta label for a field.
     258     *
     259     *  @return string  */
    255260    public static function mark_as_beta() {
    256261        return ' <span class="tu-label-warning">BETA</span>';
     
    379384        );
    380385
    381         // BREAK SECTION FOR GEOLOCATION SETTINGS
    382         $this->add_new_subsection('termageddon_usercentrics_section_settings', [
    383             'name' => 'Integrations',
    384             'description' => 'We love to partner with other plugin developers to improve support with their plugins. If you encounter an issue, please contact our support to let us know.',
    385         ]);
    386        
    387         // Disable Login.
     386        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     387        $this->add_new_subsection(
     388            'termageddon_usercentrics_section_settings',
     389            array(
     390                'name'        => 'Privacy Settings Link',
     391                'description' => 'Giving users the ability to change their privacy/consent settings is a requirement under several privacy laws. Within your Termageddon account, if you selected (on page 1 of the Cookie Policy and Consent Tool questionnaire) to use the Privacy Settings hyperlink (instead of the \'fingerprint icon\'), you will see an additional script in the \'view embed code\' page that will need to be added to your website.</p>
     392                <p>As an alternative to that additional script, you can simply use the [uc-privacysettings] shortcode, which will embed the privacy settings link. This is an easy way to add the Privacy Settings link within your global footer, for example. You can also pass in a text parameter to change the text of the link (for example, <code>[uc-privacysettings text="Change Privacy Settings"]</code>).',
     393            )
     394        );
     395
     396        // Privacy Settings Link Disable.
     397        add_settings_field(
     398            'termageddon_usercentrics_location_psl_hide',
     399            __( 'Hide Privacy Settings Link when cookie consent tool is disabled', 'termageddon-usercentrics' ),
     400            array( &$this, 'location_psl_disable_html' ), // function which prints the field.
     401            'termageddon-usercentrics', // page slug.
     402            'termageddon_usercentrics_section_settings', // section ID.
     403            array(
     404                'label_for'   => 'termageddon_usercentrics_location_psl_hide',
     405                'description' => __( 'When enabled, the Privacy Settings link will be hidden from certain users, whether that be certain logged in users (via your selections above in the “Hide widget for:” area) or if you enabled geolocation and are hiding the consent tool from certain visitors. For example, if you enable the option to hide the consent tool for logged in administrator (and enable this toggle), the Privacy Settings link will <strong>not</strong> show to logged in administrators.  If you enable the option to hide the consent tool based on geolocation for certain users, the Privacy Settings link will no longer be displayed to those respective users as well.', 'termageddon-usercentrics' ),
     406            )
     407        );
     408
     409        register_setting(
     410            'termageddon_usercentrics_settings', // settings group name.
     411            'termageddon_usercentrics_location_psl_hide', // option name.
     412            '' // sanitization function.
     413        );
     414
     415        // Privacy Settings Link Alternative Implementation.
     416        add_settings_field(
     417            'termageddon_usercentrics_psl_alternate',
     418            __( 'Privacy Settings Link - Alternative Implementation', 'termageddon-usercentrics' ),
     419            array( &$this, 'psl_alternate_implementation' ), // function which prints the field.
     420            'termageddon-usercentrics', // page slug.
     421            'termageddon_usercentrics_section_settings', // section ID.
     422            array(
     423                'label_for'   => 'termageddon_usercentrics_psl_alternate',
     424                'description' => __( 'For some theme builders including Divi, the footer (bottom bar) does not support shortcodes. If you are experiencing issues, use the following HTML code where you want to the privacy settings link to be instead of the shortcode and enable this option:', 'termageddon-usercentrics' ) . '<br><code>&lt;a id=&quot;usercentrics-psl&quot;&gt;Privacy Settings&lt;/a&gt;</code>',
     425            )
     426        );
     427
     428        register_setting(
     429            'termageddon_usercentrics_settings', // settings group name.
     430            'termageddon_usercentrics_psl_alternate', // option name.
     431            '' // sanitization function.
     432        );
     433
     434        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     435        $this->add_new_subsection(
     436            'termageddon_usercentrics_section_settings',
     437            array(
     438                'name'        => 'Integrations',
     439                'description' => 'We love to partner with other plugin developers to improve support with their plugins. If you encounter an issue, please contact our support to let us know.',
     440            )
     441        );
     442
     443        // Presto Player.
    388444        add_settings_field(
    389445            'termageddon_usercentrics_integration_presto_player',
    390             __( 'Presto Player', 'termageddon-usercentrics' ).$this->mark_as_beta(),
     446            __( 'Presto Player', 'termageddon-usercentrics' ) . $this->mark_as_beta(),
    391447            array( &$this, 'presto_player_support' ), // function which prints the field.
    392448            'termageddon-usercentrics', // page slug.
     
    516572        );
    517573
    518         // BREAK SECTION FOR GEOLOCATION SETTINGS
    519         $this->add_new_subsection('termageddon_usercentrics_section_geolocation', [
    520             'name' => 'Geo-Location Settings',
    521             'description' => 'If you are experiencing issues or unexpected behavior, toggle the "Enable Location Logging" option. Please contact our support if you have any questions.',
    522         ]);
     574        // BREAK SECTION FOR GEOLOCATION SETTINGS.
     575        $this->add_new_subsection(
     576            'termageddon_usercentrics_section_geolocation',
     577            array(
     578                'name'        => 'Geo-Location Settings',
     579                'description' => 'If you are experiencing issues or unexpected behavior, toggle the "Enable Location Logging" option. Please contact our support if you have any questions.',
     580            )
     581        );
    523582
    524583        // Enable Geolocation Debug Mode.
     
    542601        );
    543602
    544         // Privacy Settings Link Disable.
    545         add_settings_field(
    546             'termageddon_usercentrics_location_psl_hide',
    547             __( 'Hide Privacy Settings Link when disabled', 'termageddon-usercentrics' ),
    548             array( &$this, 'location_psl_disable_html' ), // function which prints the field.
    549             'termageddon-usercentrics', // page slug.
    550             'termageddon_usercentrics_section_geolocation', // section ID.
    551             array(
    552                 'label_for'   => 'termageddon_usercentrics_location_psl_hide',
    553                 'description' => __( 'When enabled, the privacy settings link will be hidden alongside the plugin if the visitor is outside of the geo-location marked above.', 'termageddon-usercentrics' ),
    554             )
    555         );
    556 
    557         register_setting(
    558             'termageddon_usercentrics_settings', // settings group name.
    559             'termageddon_usercentrics_location_psl_hide', // option name.
    560             '' // sanitization function.
    561         );
    562603        // Enable Geolocation AJAX Mode.
    563604        add_settings_field(
     
    652693        // Options.
    653694        $default     = ( isset( $args['default'] ) ? $args['default'] : false );
    654         $label       = ( isset( $args['label'] ) ? $args['label'] : false );
     695        $label       = ( isset( $args['label'] ) ? $args['label'] : '' );
    655696        $tip         = ( isset( $args['tip'] ) ? $args['tip'] : null );
    656697        $description = ( isset( $args['description'] ) ? $args['description'] : null );
     
    659700        $is_checked = get_option( $option_name, $default ) ? true : false;
    660701
    661         echo '<input type="checkbox"  class="termageddon-checkbox wppd-ui-toggle' . ( $label ? ' label-' . esc_attr( $label ) : '' ) . '" id="' . esc_attr( $option_name ) . '" name="' . esc_attr( $option_name ) . '" value="1" ' . checked( 1, $is_checked, false ) . ' />';
     702        echo '<input type="checkbox"  class="termageddon-checkbox wppd-ui-toggle' . ( ! empty( $label ) ? ' label-' . esc_attr( $label ) : '' ) . '" id="' . esc_attr( $option_name ) . '" name="' . esc_attr( $option_name ) . '" value="1" ' . checked( 1, $is_checked, false ) . ' />';
    662703
    663704        if ( $tip ) {
     
    665706        }
    666707        if ( $description ) {
    667             echo '<p>' . esc_html( $description ) . '</p>';
     708            echo '<p>' . wp_kses_post( $description ) . '</p>';
    668709        }
    669710
     
    702743        self::generate_checkbox( 'admin', 'disable', $args );
    703744    }
    704    
     745
    705746    /**
    706747     * The HTML field for the admin disable checkbox.
     
    730771     */
    731772    public function location_psl_disable_html( array $args ) {
    732         $args['default'] = true;
    733773        self::generate_checkbox( 'psl_hide', 'location', $args );
     774    }
     775    /**
     776     * The HTML field for the psl hidden checkbox.
     777     *
     778     * @param array $args The arguments provided by the add_settings_field() method.
     779     * @return void
     780     */
     781    public function psl_alternate_implementation( array $args ) {
     782        self::generate_checkbox( 'alternate', 'psl', $args );
    734783    }
    735784    /**
  • termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php

    r2922465 r2931216  
    312312        return $execution_time;
    313313    }
    314    
    315    
     314
     315
    316316    /**
    317317     * Generate a random string with specified paramaters
    318318     *
    319      * @param int $length The length of string to generate.
     319     * @param int   $length The length of string to generate.
    320320     * @param array $options The various options to pass in. 'type' is a valid option.
    321321     * @return string $randomString - The randomized string
    322322     */
    323     public static function generate_random_string(int $length=10, array $options=[]) {
    324         $type = (isset($options['type']) ? $options['type'] : null);
    325         switch (strtolower($type)) {
     323    public static function generate_random_string( int $length = 10, array $options = array() ) {
     324        $type = ( isset( $options['type'] ) ? $options['type'] : null );
     325        switch ( strtolower( $type ) ) {
    326326            case 'letters':
    327327                $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
     
    335335        }
    336336
    337         //Generate String
    338         $charactersLength = strlen($characters);
    339         $randomString     = '';
    340         for ($i = 0; $i < $length; $i++) {
    341             $randomString .= $characters[rand(0, $charactersLength - 1)];
    342         }
    343 
    344         return $randomString;
     337        // Generate String.
     338        $characters_length = strlen( $characters );
     339        $random_string     = '';
     340        for ( $i = 0; $i < $length; $i++ ) {
     341            $random_string .= $characters[ wp_rand( 0, $characters_length - 1 ) ];
     342        }
     343
     344        return $random_string;
    345345
    346346    }
     
    420420    }
    421421
    422     /** @return int  */
     422    /**
     423     * Return the integer count of database download errors.
     424     *
     425     * @return int  */
    423426    public static function count_download_errors(): int {
    424427        return (int) get_option( 'termageddon_usercentrics_download_error_count', 0 );
     
    426429
    427430
    428     /** @return array  */
     431    /**
     432     * Return a list of error logs generated by the download.
     433     *
     434     * @return array  */
    429435    public static function get_download_error_logs(): array {
    430436        return (array) array_filter( get_option( 'termageddon_usercentrics_download_error_log', array() ) );
     
    725731     */
    726732    public static function should_hide_psl() {
    727         return ( get_option( 'termageddon_usercentrics_location_psl_hide', true ) ? true : false );
     733        return ( get_option( 'termageddon_usercentrics_location_psl_hide', false ) ? true : false );
     734
     735    }
     736
     737
     738    /**
     739     * Returns whether debug mode is enabled via the query paramater
     740     *
     741     * @return bool
     742     */
     743    public static function should_use_alternate_psl() {
     744        return ( get_option( 'termageddon_usercentrics_psl_alternate', false ) ? true : false );
    728745
    729746    }
     
    736753     */
    737754    public static function debug( ...$msg ) {
    738         if ( self::is_debug_mode_enabled() && ! wp_doing_ajax() ) {
    739             // Display message on frontend.
    740             // echo '<div class="error"><pre>' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '</pre></div>';.
    741 
    742             // Display message in browser console.
    743             echo '<script>
    744                 console.log(\'TERMAGEDDON USERCENTRICS\', `' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '`);
    745             </script>';
    746         }
     755        if ( ! self::is_debug_mode_enabled() ) {
     756            return; // Check to ensure debug mode is enabled.
     757        }
     758
     759        if ( wp_doing_ajax() ) {
     760            return; // Check for Ajax.
     761        }
     762
     763        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     764            return; // Check for CLI.
     765        }
     766
     767        // Display message on frontend.
     768        // echo '<div class="error"><pre>' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '</pre></div>';.
     769
     770        // Display message in browser console.
     771        echo '<script>
     772            console.log(\'TERMAGEDDON USERCENTRICS\', `' . wp_json_encode( $msg, JSON_PRETTY_PRINT ) . '`);
     773        </script>';
    747774    }
    748775
     
    840867     *
    841868     * @return string  */
    842     public static function get_location_displayname() {
     869    public static function get_location_displayname(): string {
    843870        list('city' => $city, 'state' => $state, 'country' => $country) = self::lookup_ip_address();
    844871
     
    854881     * @return bool
    855882     */
    856     public static function is_geoip_enabled() {
     883    public static function is_geoip_enabled(): bool {
    857884        $show_in_eu         = get_option( 'termageddon_usercentrics_show_in_eu', false ) ? true : false;
    858885        $show_in_uk         = get_option( 'termageddon_usercentrics_show_in_uk', false ) ? true : false;
     
    862889        return ( $show_in_eu || $show_in_uk || $show_in_canada || $show_in_california || $show_in_virginia );
    863890    }
    864    
    865     /** Identifies if any geoip location is enabled.
    866      *
     891
     892
     893    /**
     894     * Check if the given integration is enabled.
     895     *
     896     * @param string $integration The slug of the integration to check.
    867897     * @return bool
    868898     */
    869     public static function is_integration_enabled( string $int ) {
    870         return get_option( 'termageddon_usercentrics_integration_'.$int, false ) ? true : false;
     899    public static function is_integration_enabled( string $integration ): bool {
     900        return get_option( 'termageddon_usercentrics_integration_' . $integration, false ) ? true : false;
    871901    }
    872902
     
    875905     *
    876906     * @return bool  */
    877     public static function is_located_in_colorado() {
     907    public static function is_located_in_colorado(): bool {
    878908        list( 'state' => $state ) = self::lookup_ip_address();
    879909        return ( null === $state || 'Colorado' === $state );
     
    885915     *
    886916     * @return bool  */
    887     public static function is_located_in_california() {
     917    public static function is_located_in_california(): bool {
    888918        list( 'state' => $state ) = self::lookup_ip_address();
    889919        return ( null === $state || 'California' === $state );
     
    895925     *
    896926     * @return bool  */
    897     public static function is_located_in_virginia() {
     927    public static function is_located_in_virginia(): bool {
    898928        list( 'state' => $state ) = self::lookup_ip_address();
    899929        return ( null === $state || 'Virginia' === $state );
     
    905935     *
    906936     * @return bool  */
    907     public static function is_located_in_canada() {
     937    public static function is_located_in_canada(): bool {
    908938        list( 'country' => $country ) = self::lookup_ip_address();
    909939        return ( null === $country || 'Canada' === $country );
     
    915945     *
    916946     * @return bool  */
    917     public static function is_located_in_eu() {
     947    public static function is_located_in_eu(): bool {
    918948        list( 'country' => $country ) = self::lookup_ip_address();
    919949
     
    959989     *
    960990     * @return bool  */
    961     public static function is_located_in_uk() {
     991    public static function is_located_in_uk(): bool {
    962992        list( 'country' => $country ) = self::lookup_ip_address();
    963993        return ( null === $country || 'United Kingdom' === $country );
     
    9701000     *
    9711001     * @return bool  */
    972     public static function should_hide_due_to_location() {
     1002    public static function should_hide_due_to_location(): bool {
    9731003        $show_in_eu         = get_option( 'termageddon_usercentrics_show_in_eu', false ) ? true : false;
    9741004        $show_in_uk         = get_option( 'termageddon_usercentrics_show_in_uk', false ) ? true : false;
     
    10211051     *
    10221052     * @return bool  */
    1023     public static function is_ajax_mode_enabled() {
     1053    public static function is_ajax_mode_enabled(): bool {
    10241054        if ( ! self::is_geoip_enabled() ) {
    10251055            return false;
  • termageddon-usercentrics/trunk/languages/termageddon-usercentrics.pot

    r2890756 r2931216  
    44"Project-Id-Version: Termageddon + Usercentrics\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2023-03-30 22:08+0000\n"
     6"POT-Creation-Date: 2023-06-27 04:32+0000\n"
    77"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    88"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     
    1717"X-Domain: termageddon-usercentrics"
    1818
    19 #: admin/class-termageddon-usercentrics-admin.php:292
     19#: admin/class-termageddon-usercentrics-admin.php:335
    2020msgid "Administrators"
    2121msgstr ""
     
    2525msgstr ""
    2626
    27 #: admin/class-termageddon-usercentrics-admin.php:423
     27#: admin/class-termageddon-usercentrics-admin.php:541
    2828msgid "California (CPRA)"
    2929msgstr ""
    3030
    31 #: admin/class-termageddon-usercentrics-admin.php:405
     31#: admin/class-termageddon-usercentrics-admin.php:523
    3232msgid "Canada (PIPEDA)"
    3333msgstr ""
    3434
    3535#. section ID.
    36 #: admin/class-termageddon-usercentrics-admin.php:544
     36#: admin/class-termageddon-usercentrics-admin.php:633
    3737msgid "Control Panel"
    3838msgstr ""
    3939
    40 #: admin/class-termageddon-usercentrics-admin.php:796
     40#: admin/class-termageddon-usercentrics-admin.php:904
    4141msgid "Cookie Policy and Consent Solution"
    4242msgstr ""
     
    5252msgstr ""
    5353
    54 #: admin/class-termageddon-usercentrics-admin.php:310
     54#: admin/class-termageddon-usercentrics-admin.php:353
    5555msgid "Editors"
    5656msgstr ""
    5757
    5858#: admin/class-termageddon-usercentrics-admin.php:162
    59 #: admin/class-termageddon-usercentrics-admin.php:255
     59#: admin/class-termageddon-usercentrics-admin.php:298
    6060msgid "Embed Code"
    6161msgstr ""
    6262
    63 #: admin/class-termageddon-usercentrics-admin.php:479
     63#: admin/class-termageddon-usercentrics-admin.php:586
    6464msgid "Enable location logging"
    6565msgstr ""
    6666
    67 #: admin/class-termageddon-usercentrics-admin.php:517
     67#: admin/class-termageddon-usercentrics-admin.php:606
    6868msgid "Enable page caching support via AJAX"
    6969msgstr ""
    7070
    71 #: admin/class-termageddon-usercentrics-admin.php:558
     71#: admin/class-termageddon-usercentrics-admin.php:647
    7272msgid "Error Count"
    7373msgstr ""
     
    7777msgstr ""
    7878
    79 #: admin/class-termageddon-usercentrics-admin.php:576
     79#: admin/class-termageddon-usercentrics-admin.php:665
    8080msgid "Error List"
    8181msgstr ""
    8282
    83 #: admin/class-termageddon-usercentrics-admin.php:369
     83#: admin/class-termageddon-usercentrics-admin.php:487
    8484msgid "European Union & European Economic Area (GDPR)"
    8585msgstr ""
     
    8989msgstr ""
    9090
     91#: admin/class-termageddon-usercentrics-admin.php:424
     92msgid ""
     93"For some theme builders including Divi, the footer (bottom bar) does not "
     94"support shortcodes. If you are experiencing issues, use the following HTML "
     95"code where you want to the privacy settings link to be instead of the "
     96"shortcode and enable this option:"
     97msgstr ""
     98
    9199#. section ID.
    92100#: admin/class-termageddon-usercentrics-admin.php:164
    93 #: admin/class-termageddon-usercentrics-admin.php:355
     101#: admin/class-termageddon-usercentrics-admin.php:473
    94102msgid "Geo-Location"
    95103msgstr ""
     
    119127msgstr ""
    120128
    121 #: admin/class-termageddon-usercentrics-admin.php:499
    122 msgid "Hide Privacy Settings Link when disabled"
     129#: admin/class-termageddon-usercentrics-admin.php:399
     130msgid "Hide Privacy Settings Link when cookie consent tool is disabled"
    123131msgstr ""
    124132
     
    127135msgstr ""
    128136
    129 #: admin/class-termageddon-usercentrics-admin.php:463
    130 msgid ""
    131 "If you are experiencing issues or unexpected behavior, toggle the \"Enable "
    132 "Location Logging\" option. Please contact our support if you have any "
    133 "questions."
    134 msgstr ""
    135 
    136 #: admin/class-termageddon-usercentrics-admin.php:814
     137#: admin/class-termageddon-usercentrics-admin.php:922
    137138msgid "If you are using the Divi theme"
    138139msgstr ""
    139140
    140 #: admin/class-termageddon-usercentrics-admin.php:813
     141#: admin/class-termageddon-usercentrics-admin.php:921
    141142msgid ""
    142143"If you would like to remove Usercentrics for logged in users such as admins, "
     
    152153msgstr ""
    153154
    154 #: admin/class-termageddon-usercentrics-admin.php:328
     155#: admin/class-termageddon-usercentrics-admin.php:371
    155156msgid "Logged-in Users"
    156157msgstr ""
    157158
     159#: admin/class-termageddon-usercentrics-admin.php:446
     160msgid "Presto Player"
     161msgstr ""
     162
     163#: admin/class-termageddon-usercentrics-admin.php:418
     164msgid "Privacy Settings Link - Alternative Implementation"
     165msgstr ""
     166
    158167#. section ID.
    159 #: includes/class-termageddon-usercentrics.php:344
     168#: includes/class-termageddon-usercentrics.php:378
    160169#: admin/class-termageddon-usercentrics-admin.php:163
    161 #: admin/class-termageddon-usercentrics-admin.php:283
     170#: admin/class-termageddon-usercentrics-admin.php:326
    162171msgid "Settings"
    163172msgstr ""
     
    178187msgstr ""
    179188
    180 #: admin/class-termageddon-usercentrics-admin.php:850
     189#: admin/class-termageddon-usercentrics-admin.php:958
    181190msgid ""
    182191"To reset any of the backend variables, update the values below and save your "
     
    184193msgstr ""
    185194
    186 #: admin/class-termageddon-usercentrics-admin.php:387
     195#: admin/class-termageddon-usercentrics-admin.php:505
    187196msgid "United Kingdom (UK DPA)"
    188197msgstr ""
    189198
    190 #: admin/class-termageddon-usercentrics-admin.php:795
     199#: admin/class-termageddon-usercentrics-admin.php:903
    191200msgid "Upon generating your "
    192201msgstr ""
    193202
    194 #: admin/class-termageddon-usercentrics-admin.php:781
     203#: admin/class-termageddon-usercentrics-admin.php:889
    195204msgid "Upon saving, all previous errors in the log will be deleted."
    196205msgstr ""
    197206
    198 #: admin/class-termageddon-usercentrics-admin.php:441
     207#: admin/class-termageddon-usercentrics-admin.php:559
    199208msgid "Virginia (VCDPA)"
    200209msgstr ""
     
    207216msgstr ""
    208217
    209 #: admin/class-termageddon-usercentrics-admin.php:505
    210 msgid ""
    211 "When enabled, the privacy settings link will be hidden alongside the plugin "
    212 "if the visitor is outside of the geo-location marked above."
    213 msgstr ""
    214 
    215 #: admin/class-termageddon-usercentrics-admin.php:485
     218#: admin/class-termageddon-usercentrics-admin.php:405
     219msgid ""
     220"When enabled, the Privacy Settings link will be hidden from certain users, "
     221"whether that be certain logged in users (via your selections above in the "
     222"“Hide widget for:” area) or if you enabled geolocation and are hiding the "
     223"consent tool from certain visitors. For example, if you enable the option to "
     224"hide the consent tool for logged in administrator (and enable this toggle), "
     225"the Privacy Settings link will <strong>not</strong> show to logged in "
     226"administrators.  If you enable the option to hide the consent tool based on "
     227"geolocation for certain users, the Privacy Settings link will no longer be "
     228"displayed to those respective users as well."
     229msgstr ""
     230
     231#: admin/class-termageddon-usercentrics-admin.php:592
    216232msgid ""
    217233"When enabled, the visitor's location can be viewed in the browser console, "
     
    219235msgstr ""
    220236
    221 #: admin/class-termageddon-usercentrics-admin.php:523
     237#: admin/class-termageddon-usercentrics-admin.php:612
    222238msgid ""
    223239"When enabled, the visitor's location is checked via javascript to allow "
     
    225241msgstr ""
    226242
    227 #: admin/class-termageddon-usercentrics-admin.php:832
     243#: admin/class-termageddon-usercentrics-admin.php:940
    228244msgid ""
    229245"When enabled, you will be collecting IP addresses for the purposes of "
     
    241257msgstr ""
    242258
    243 #: admin/class-termageddon-usercentrics-admin.php:797
     259#: admin/class-termageddon-usercentrics-admin.php:905
    244260msgid ""
    245261"within your Termageddon account, you will be brought to the \"View embed "
     
    248264msgstr ""
    249265
    250 #: admin/class-termageddon-usercentrics-admin.php:815
     266#: admin/class-termageddon-usercentrics-admin.php:923
    251267msgid ""
    252268"you will need to enable at least one of the settings below to ensure logged "
  • termageddon-usercentrics/trunk/public/class-termageddon-usercentrics-public.php

    r2922465 r2931216  
    112112            );
    113113        }
     114
     115        // Load Alternate PSL Logic.
     116        if ( Termageddon_Usercentrics::should_use_alternate_psl() ) {
     117            add_action( 'wp_footer', array( $this, 'replace_usercentrics_psl_with_shortcode' ) );
     118        }
    114119    }
    115120
     
    134139        echo wp_kses( $script, self::ALLOWED_HTML );
    135140        echo '<!-- END TERMAGEDDON + USERCENTRICS -->';
     141    }
     142
     143
     144    /**
     145     * Action to allow replacing a broken psl with the fully functional psl.
     146     *
     147     * @return void  */
     148    public function replace_usercentrics_psl_with_shortcode() {
     149        ob_start();
     150        ?>
     151        <script id="termageddon-psl-alternate-js">
     152            (function($) {
     153                $(document).ready(function() {
     154                    jQuery('a#usercentrics-psl').each(function() {
     155                        let newElem = jQuery(`<?php echo do_shortcode( '[uc-privacysettings]' ); ?>`);
     156                        if (!["","Privacy Settings"].includes(jQuery(this).text())) newElem.text(jQuery(this).text())
     157                        jQuery(this).replaceWith(newElem);
     158                    })
     159                })
     160            })(jQuery);
     161        </script>
     162        <?php
     163        ob_end_flush();
    136164    }
    137165
     
    195223          </script>';
    196224        }
    197        
     225
    198226        // Presto Player Integration Javascript.
    199         if ( Termageddon_Usercentrics::is_integration_enabled('presto_player') ) {
     227        if ( Termageddon_Usercentrics::is_integration_enabled( 'presto_player' ) ) {
    200228            $script .= '<script type="application/javascript" id="uc-integration-presto-player">
    201229    function uc_integration_setup(iID,service) {
  • termageddon-usercentrics/trunk/termageddon-usercentrics.php

    r2922465 r2931216  
    1515 * Plugin Name:       Termageddon + Usercentrics
    1616 * Description:       Easily integrate the Usercentrics consent solution into your website while controlling visibility for logged in users and admins.
    17  * Version:           1.3.3
     17 * Version:           1.3.4
    1818 * Author:            Termageddon
    1919 * Author URI:        https://termageddon.com
     
    3434 * Rename this for your plugin and update it as you release new versions.
    3535 */
    36 define( 'TERMAGEDDON_COOKIE_VERSION', '1.3.3' );
     36define( 'TERMAGEDDON_COOKIE_VERSION', '1.3.4' );
    3737
    3838define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
Note: See TracChangeset for help on using the changeset viewer.