Plugin Directory

Changeset 3126962


Ignore:
Timestamp:
07/29/2024 02:27:28 AM (20 months ago)
Author:
termageddon
Message:

[1.4.3] Custom Embed Priority & Bug Fixes

Location:
termageddon-usercentrics
Files:
155 added
5 edited

Legend:

Unmodified
Added
Removed
  • termageddon-usercentrics/trunk/README.txt

    r3115041 r3126962  
    44Tags: termageddon, cookie, consent, embed, usercentrics
    55Requires at least: 3.0.1
    6 Tested up to: 6.5.5
    7 Stable tag: 1.4.2
     6Tested up to: 6.6.1
     7Stable tag: 1.4.3
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2626
    2727== Changelog ==
     28
     29= 1.4.3 =
     30
     31-   [ADD] Added Custom Embed Code Priority (Under Settings) option to allow for more control over the priority of the embed script.
     32-   [FIX] Fixed a rare issue where crash on enabling geolocation.
    2833
    2934= 1.4.2 =
  • termageddon-usercentrics/trunk/admin/class-termageddon-usercentrics-admin.php

    r3115041 r3126962  
    285285    }
    286286
     287    /**
     288     * Sanitize all settings and validate them if needed.
     289     *
     290     * @param mixed $value The value to sanitize.
     291     *
     292     * @return int $value The sanitized value.
     293     */
     294    public static function sanitize_integer( $value ) {
     295        return intval( $value );
     296    }
     297    /**
     298     * Sanitize all settings and validate them if needed.
     299     *
     300     * @param mixed $value The value to sanitize.
     301     *
     302     * @return string $value The sanitized value.
     303     */
     304    public static function sanitize_text( $value ) {
     305        return strval( $value );
     306    }
     307    /**
     308     * Sanitize all settings and validate them if needed.
     309     *
     310     * @param mixed $value The value to sanitize.
     311     *
     312     * @return bool $value The sanitized value.
     313     */
     314    public static function sanitize_boolean( $value ) {
     315        return $value ? true : false;
     316    }
     317
     318    // ============================================= //
     319    // ======== Custom Sanitation Functions ======== //
     320    // ============================================= //
     321
     322    /**
     323     * Ensure that the embed priority is an integer between 1 and 10.
     324     * If not, return 1.
     325     *
     326     * @param mixed $value The value to sanitize.
     327     *
     328     * @return int $value The sanitized value.
     329     **/
     330    public static function sanitize_embed_priority( $value ) {
     331        $priority = self::sanitize_integer( $value );
     332        if ( $priority <= 10 && $priority >= 1 ) {
     333            return intval( $value );
     334        }
     335        return 1;
     336    }
    287337
    288338    /**
     
    516566
    517567        // Privacy Settings Link Disable.
     568        add_settings_field(
     569            'termageddon_usercentrics_embed_priority',
     570            __( 'Embed Code Priority', 'termageddon-usercentrics' ) . $this->mark_as_beta(),
     571            array( &$this, 'embed_priority_html' ), // function which prints the field.
     572            'termageddon-usercentrics', // page slug.
     573            'termageddon_usercentrics_section_settings', // section ID.
     574            array(
     575                'label_for'   => 'termageddon_usercentrics_embed_priority',
     576                'description' => __( 'Override the default priority of the embed code (Defaults to 1). By adjusting this value (number between 1 and 10), you can change the priority of the embed code. The higher the number, the sooner the embed code will be rendered in the source code.', 'termageddon-usercentrics' ),
     577            )
     578        );
     579
     580        register_setting(
     581            'termageddon_usercentrics_settings', // settings group name.
     582            'termageddon_usercentrics_embed_priority', // option name.
     583            array(
     584                'type'              => 'int',
     585                'sanitize_callback' => array( &$this, 'sanitize_embed_priority' ),
     586                'default'           => 1,
     587            )
     588        );
     589
    518590        add_settings_field(
    519591            'termageddon_usercentrics_disable_troubleshooting',
     
    762834
    763835    /**
    764      * Helper method to easily generate a quick checkbox.
    765      *
    766      * @param string $area - The option name/location you are building the checkbox for.
    767      * @param string $prefix - The prefix to the option.
     836     * Helper method to easily generate a quick input field.
     837     *
     838     * @param string $option - The option name/location you are building the input for.
    768839     * @param array  $args The arguments provided by the add_settings_field() method.
    769840     * @return void
    770841     */
    771     private static function generate_checkbox( string $area, string $prefix = 'show_in', array $args = array() ) {
    772         $option_name = 'termageddon_usercentrics_' . $prefix . '_' . $area;
     842    private static function generate_input( string $option, array $args = array() ) {
     843        $option_name = 'termageddon_usercentrics_' . $option;
    773844
    774845        // Options.
    775         $default     = ( isset( $args['default'] ) ? $args['default'] : false );
     846        $default     = ( isset( $args['default'] ) ? $args['default'] : null );
     847        $min         = ( isset( $args['min'] ) ? $args['min'] : null );
     848        $max         = ( isset( $args['max'] ) ? $args['max'] : null );
     849        $type        = ( isset( $args['type'] ) ? $args['type'] : 'text' );
    776850        $label       = ( isset( $args['label'] ) ? $args['label'] : '' );
    777851        $tip         = ( isset( $args['tip'] ) ? $args['tip'] : null );
     
    779853
    780854        // Is the option currently active?
    781         $is_checked = get_option( $option_name, $default ) ? true : false;
    782 
    783         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 ) . ' />';
     855        $value = get_option( $option_name, $default );
     856
     857        echo '<input
     858            type="' . esc_attr( $type ) . '"
     859            class="termageddon-input' . ( ! empty( $label ) ? ' label-' . esc_attr( $label ) : '' ) . '"
     860            id="' . esc_attr( $option_name ) . '"
     861            name="' . esc_attr( $option_name ) . '"
     862            value="' . esc_attr( $value ) . '"
     863            ' . ( is_null( $min ) ? '' : 'min="' . esc_attr( $min ) . '"' ) . '
     864            ' . ( is_null( $max ) ? '' : 'max="' . esc_attr( $max ) . '"' ) . '
     865             />';
    784866
    785867        if ( $tip ) {
     
    791873
    792874    }
     875    /**
     876     * Helper method to easily generate a quick checkbox.
     877     *
     878     * @param string $area - The option name/location you are building the checkbox for.
     879     * @param string $prefix - The prefix to the option.
     880     * @param array  $args The arguments provided by the add_settings_field() method.
     881     * @return void
     882     */
     883    private static function generate_checkbox( string $area, string $prefix = 'show_in', array $args = array() ) {
     884        $option_name = 'termageddon_usercentrics_' . $prefix . '_' . $area;
     885
     886        // Options.
     887        $default     = ( isset( $args['default'] ) ? $args['default'] : false );
     888        $label       = ( isset( $args['label'] ) ? $args['label'] : '' );
     889        $tip         = ( isset( $args['tip'] ) ? $args['tip'] : null );
     890        $description = ( isset( $args['description'] ) ? $args['description'] : null );
     891
     892        // Is the option currently active?
     893        $is_checked = get_option( $option_name, $default ) ? true : false;
     894
     895        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 ) . ' />';
     896
     897        if ( $tip ) {
     898            echo '<b class="wntip" data-title="' . esc_attr( $tip ) . '"> ? </b>';
     899        }
     900        if ( $description ) {
     901            echo '<p>' . wp_kses_post( $description ) . '</p>';
     902        }
     903
     904    }
    793905
    794906    /**
     
    884996    public function psl_alternate_implementation( array $args ) {
    885997        self::generate_checkbox( 'alternate', 'psl', $args );
     998    }
     999    /**
     1000     * The HTML field for the disable troubleshooting checkbox.
     1001     *
     1002     * @param array $args The arguments provided by the add_settings_field() method.
     1003     * @return void
     1004     */
     1005    public function embed_priority_html( array $args ) {
     1006        $args['default'] = 1;
     1007        $args['min']     = 1;
     1008        $args['max']     = 10;
     1009        $args['type']    = 'number';
     1010
     1011        self::generate_input( 'embed_priority', $args );
    8861012    }
    8871013    /**
  • termageddon-usercentrics/trunk/includes/class-termageddon-usercentrics.php

    r3104855 r3126962  
    269269        if ( self::is_geoip_enabled() && ! self::is_ajax_mode_enabled() && ! wp_doing_cron() ) {
    270270            $this->loader->add_action( 'init', $this, 'lookup_ip_address' );
    271 
    272271        }
    273272        // If AJAX Mode is enabled, load geolocation ajax actions.
     
    275274        $this->loader->add_action( 'wp_ajax_nopriv_uc_geolocation_lookup', $this, 'geolocation_lookup_ajax' );
    276275
    277         $this->loader->add_action( 'wp_head', $plugin_public, 'build_termageddon_script', 1 );
     276        // Load the primary embed (or disabled) script in the head.
     277        $this->loader->add_action(
     278            'wp_head',
     279            $plugin_public,
     280            'build_termageddon_script',
     281            self::get_embed_priority()
     282        );
    278283    }
    279284
     
    938943
    939944
     945    /**
     946     * Returns a human readable version of the allowed html tags.
     947     *
     948     * @return string
     949     */
    940950    public static function get_allowed_html_kses(): string {
    941951        $allowed = wp_kses_allowed_html( self::ALLOWED_HTML );
    942         return json_encode( $allowed, JSON_PRETTY_PRINT );
    943     }
    944 
     952        return wp_json_encode( $allowed, JSON_PRETTY_PRINT );
     953    }
     954
     955    /**
     956     * Returns the script priority from 1-10.
     957     *
     958     * @return int
     959     */
     960    public static function get_embed_priority(): int {
     961        $priority = get_option( 'termageddon_usercentrics_embed_priority', 1 );
     962        $priority = intval( $priority );
     963        echo '<pre>' . json_encode( $priority ) . '</pre>';
     964        if ( $priority <= 10 && $priority >= 1 ) {
     965            return $priority;
     966        }
     967        return 1;
     968    }
    945969
    946970
     
    970994            return $enabled;
    971995        } else { // Otherwise, return new option value.
    972             return $enabled;
     996            return '1' === $enabled;
    973997        }
    974998    }
  • termageddon-usercentrics/trunk/languages/termageddon-usercentrics.pot

    r3115041 r3126962  
    44"Project-Id-Version: Termageddon + Usercentrics\n"
    55"Report-Msgid-Bugs-To: \n"
    6 "POT-Creation-Date: 2024-07-09 06:06+0000\n"
     6"POT-Creation-Date: 2024-07-29 01:53+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:344
     19#: admin/class-termageddon-usercentrics-admin.php:394
    2020msgid "Administrators"
    2121msgstr ""
     
    2929msgstr ""
    3030
    31 #: admin/class-termageddon-usercentrics-admin.php:1056
     31#: admin/class-termageddon-usercentrics-admin.php:1182
    3232msgid "along with page 1 of your Privacy Policy questionnaire within "
    3333msgstr ""
    3434
    35 #: admin/class-termageddon-usercentrics-admin.php:622
     35#: admin/class-termageddon-usercentrics-admin.php:694
    3636msgid "California (CPRA or CIPA)"
    3737msgstr ""
    3838
    39 #: admin/class-termageddon-usercentrics-admin.php:604
     39#: admin/class-termageddon-usercentrics-admin.php:676
    4040msgid "Canada (PIPEDA)"
    4141msgstr ""
    4242
    4343#. section ID.
    44 #: admin/class-termageddon-usercentrics-admin.php:714
     44#: admin/class-termageddon-usercentrics-admin.php:786
    4545msgid "Control Panel"
    4646msgstr ""
    4747
    48 #: admin/class-termageddon-usercentrics-admin.php:1016
     48#: admin/class-termageddon-usercentrics-admin.php:1142
    4949msgid "Cookie Policy and Consent Solution"
    5050msgstr ""
     
    5454msgstr ""
    5555
    56 #: admin/class-termageddon-usercentrics-admin.php:520
     56#: admin/class-termageddon-usercentrics-admin.php:592
    5757msgid "Disable for Troubleshooting"
    5858msgstr ""
    5959
    60 #: admin/class-termageddon-usercentrics-admin.php:455
     60#: admin/class-termageddon-usercentrics-admin.php:505
    6161msgid "Divi Video Player Integration"
    6262msgstr ""
     
    6868msgstr ""
    6969
    70 #: admin/class-termageddon-usercentrics-admin.php:362
     70#: admin/class-termageddon-usercentrics-admin.php:412
    7171msgid "Editors"
    7272msgstr ""
    7373
    74 #: admin/class-termageddon-usercentrics-admin.php:474
     74#: admin/class-termageddon-usercentrics-admin.php:524
    7575msgid "Elementor Video Player Integration"
    7676msgstr ""
    7777
    7878#: admin/class-termageddon-usercentrics-admin.php:170
    79 #: admin/class-termageddon-usercentrics-admin.php:307
     79#: admin/class-termageddon-usercentrics-admin.php:357
    8080msgid "Embed Code"
    8181msgstr ""
    8282
    83 #: admin/class-termageddon-usercentrics-admin.php:667
     83#: admin/class-termageddon-usercentrics-admin.php:570
     84msgid "Embed Code Priority"
     85msgstr ""
     86
     87#: admin/class-termageddon-usercentrics-admin.php:739
    8488msgid "Enable location logging"
    8589msgstr ""
    8690
    87 #: admin/class-termageddon-usercentrics-admin.php:687
     91#: admin/class-termageddon-usercentrics-admin.php:759
    8892msgid "Enable page caching support via AJAX"
    8993msgstr ""
    9094
    91 #: admin/class-termageddon-usercentrics-admin.php:728
     95#: admin/class-termageddon-usercentrics-admin.php:800
    9296msgid "Error Count"
    9397msgstr ""
     
    97101msgstr ""
    98102
    99 #: admin/class-termageddon-usercentrics-admin.php:746
     103#: admin/class-termageddon-usercentrics-admin.php:818
    100104msgid "Error List"
    101105msgstr ""
    102106
    103 #: admin/class-termageddon-usercentrics-admin.php:568
     107#: admin/class-termageddon-usercentrics-admin.php:640
    104108msgid "European Union & European Economic Area (GDPR)"
    105109msgstr ""
     
    109113msgstr ""
    110114
    111 #: admin/class-termageddon-usercentrics-admin.php:433
     115#: admin/class-termageddon-usercentrics-admin.php:483
    112116msgid ""
    113117"For some theme builders including Divi, the footer (bottom bar) does not "
     
    119123#. section ID.
    120124#: admin/class-termageddon-usercentrics-admin.php:172
    121 #: admin/class-termageddon-usercentrics-admin.php:548
     125#: admin/class-termageddon-usercentrics-admin.php:620
    122126msgid "Geo-Location"
    123127msgstr ""
    124128
    125129#: admin/class-termageddon-usercentrics-admin.php:143
    126 #: admin/class-termageddon-usercentrics-admin.php:1065
     130#: admin/class-termageddon-usercentrics-admin.php:1191
    127131msgid ""
    128132"Geo-Location is enabled, but no locations have been toggled on. This means "
     
    154158msgstr ""
    155159
    156 #: admin/class-termageddon-usercentrics-admin.php:408
     160#: admin/class-termageddon-usercentrics-admin.php:458
    157161msgid "Hide Privacy Settings Link when cookie consent tool is disabled"
    158162msgstr ""
     
    162166msgstr ""
    163167
    164 #: admin/class-termageddon-usercentrics-admin.php:1034
     168#: admin/class-termageddon-usercentrics-admin.php:1160
    165169msgid "If you are using the Divi theme"
    166170msgstr ""
    167171
    168 #: admin/class-termageddon-usercentrics-admin.php:1033
     172#: admin/class-termageddon-usercentrics-admin.php:1159
    169173msgid ""
    170174"If you would like to remove Usercentrics for logged in users such as admins, "
     
    180184msgstr ""
    181185
    182 #: admin/class-termageddon-usercentrics-admin.php:380
     186#: admin/class-termageddon-usercentrics-admin.php:430
    183187msgid "Logged-in Users"
    184188msgstr ""
    185189
    186 #: admin/class-termageddon-usercentrics-admin.php:1056
     190#: admin/class-termageddon-usercentrics-admin.php:1182
    187191msgid "Not sure what to select? Review"
     192msgstr ""
     193
     194#: admin/class-termageddon-usercentrics-admin.php:576
     195msgid ""
     196"Override the default priority of the embed code (Defaults to 1). By "
     197"adjusting this value (number between 1 and 10), you can change the priority "
     198"of the embed code. The higher the number, the sooner the embed code will be "
     199"rendered in the source code."
    188200msgstr ""
    189201
     
    194206msgstr ""
    195207
    196 #: admin/class-termageddon-usercentrics-admin.php:493
     208#: admin/class-termageddon-usercentrics-admin.php:543
    197209msgid "Presto Player"
    198210msgstr ""
    199211
    200 #: admin/class-termageddon-usercentrics-admin.php:427
     212#: admin/class-termageddon-usercentrics-admin.php:477
    201213msgid "Privacy Settings Link - Alternative Implementation"
    202214msgstr ""
    203215
    204216#. section ID.
    205 #: includes/class-termageddon-usercentrics.php:405
     217#: includes/class-termageddon-usercentrics.php:411
    206218#: admin/class-termageddon-usercentrics-admin.php:171
    207 #: admin/class-termageddon-usercentrics-admin.php:335
     219#: admin/class-termageddon-usercentrics-admin.php:385
    208220msgid "Settings"
    209221msgstr ""
     
    218230msgstr ""
    219231
    220 #: admin/class-termageddon-usercentrics-admin.php:1056
     232#: admin/class-termageddon-usercentrics-admin.php:1182
    221233msgid "this article"
    222234msgstr ""
     
    228240msgstr ""
    229241
    230 #: admin/class-termageddon-usercentrics-admin.php:456
     242#: admin/class-termageddon-usercentrics-admin.php:506
    231243msgid ""
    232244"This resolves and improves the cookie-consent implementation when using an "
     
    234246msgstr ""
    235247
    236 #: admin/class-termageddon-usercentrics-admin.php:475
     248#: admin/class-termageddon-usercentrics-admin.php:525
    237249msgid ""
    238250"This resolves and improves the cookie-consent implementation when using an "
     
    240252msgstr ""
    241253
    242 #: admin/class-termageddon-usercentrics-admin.php:1077
     254#: admin/class-termageddon-usercentrics-admin.php:1203
    243255msgid ""
    244256"To reset any of the backend variables, update the values below and save your "
     
    246258msgstr ""
    247259
    248 #: admin/class-termageddon-usercentrics-admin.php:586
     260#: admin/class-termageddon-usercentrics-admin.php:658
    249261msgid "United Kingdom (UK DPA)"
    250262msgstr ""
    251263
    252 #: admin/class-termageddon-usercentrics-admin.php:1015
     264#: admin/class-termageddon-usercentrics-admin.php:1141
    253265msgid "Upon generating your "
    254266msgstr ""
    255267
    256 #: admin/class-termageddon-usercentrics-admin.php:1001
     268#: admin/class-termageddon-usercentrics-admin.php:1127
    257269msgid "Upon saving, all previous errors in the log will be deleted."
    258270msgstr ""
    259271
    260 #: admin/class-termageddon-usercentrics-admin.php:640
     272#: admin/class-termageddon-usercentrics-admin.php:712
    261273msgid "Virginia (VCDPA)"
    262274msgstr ""
     
    269281msgstr ""
    270282
    271 #: admin/class-termageddon-usercentrics-admin.php:414
     283#: admin/class-termageddon-usercentrics-admin.php:464
    272284msgid ""
    273285"When enabled, the Privacy Settings link will be hidden from certain users, "
     
    282294msgstr ""
    283295
    284 #: admin/class-termageddon-usercentrics-admin.php:673
     296#: admin/class-termageddon-usercentrics-admin.php:745
    285297msgid ""
    286298"When enabled, the visitor's location can be viewed in the browser console, "
     
    288300msgstr ""
    289301
    290 #: admin/class-termageddon-usercentrics-admin.php:693
     302#: admin/class-termageddon-usercentrics-admin.php:765
    291303msgid ""
    292304"When enabled, the visitor's location is checked via javascript to allow "
     
    294306msgstr ""
    295307
    296 #: admin/class-termageddon-usercentrics-admin.php:526
     308#: admin/class-termageddon-usercentrics-admin.php:598
    297309msgid ""
    298310"When enabled, this feature allows you to turn off the consent tool for all "
     
    303315msgstr ""
    304316
    305 #: admin/class-termageddon-usercentrics-admin.php:1052
     317#: admin/class-termageddon-usercentrics-admin.php:1178
    306318msgid ""
    307319"When enabled, you will be collecting IP addresses for the purposes of "
     
    319331msgstr ""
    320332
    321 #: admin/class-termageddon-usercentrics-admin.php:1017
     333#: admin/class-termageddon-usercentrics-admin.php:1143
    322334msgid ""
    323335"within your Termageddon account, you will be brought to the \"View embed "
     
    326338msgstr ""
    327339
    328 #: admin/class-termageddon-usercentrics-admin.php:1035
     340#: admin/class-termageddon-usercentrics-admin.php:1161
    329341msgid ""
    330342"you will need to enable at least one of the settings below to ensure logged "
  • termageddon-usercentrics/trunk/termageddon-usercentrics.php

    r3115041 r3126962  
    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.4.2
     17 * Version:           1.4.3
    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.4.2' );
     36define( 'TERMAGEDDON_COOKIE_VERSION', '1.4.3' );
    3737
    3838define( 'TERMAGEDDON_COOKIE_PLUGIN_PATH', dirname( __FILE__ ) );// No trailing slash.
Note: See TracChangeset for help on using the changeset viewer.