Plugin Directory

Changeset 2283017


Ignore:
Timestamp:
04/14/2020 09:54:03 AM (6 years ago)
Author:
zedna
Message:

added JS callback when user agree with consent

Location:
zedna-cookies-bar/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • zedna-cookies-bar/trunk/readme.txt

    r2282974 r2283017  
    2525
    2626== Changelog ==
     27= Version 1.4 =
     28Added JS callback
     29
    2730= Version 1.3 =
    2831Fixed showing button condition
  • zedna-cookies-bar/trunk/zedna-cookies-bar.php

    r2282974 r2283017  
    77Author: Radek Mezulanik
    88Author URI: https://www.mezulanik.cz
    9 Version: 1.3
     9Version: 1.4
    1010License: GPL3
    1111*/
     
    3232    $cookie_bar_custom_css = (get_option('zedna_cookies_bar_custom_css') != '') ? get_option('zedna_cookies_bar_custom_css') : '';
    3333    $cookies_bar_show_button = (get_option('zedna_cookies_bar_show_button') != '') ? get_option('zedna_cookies_bar_show_button') : 'yes';
     34    $cookie_bar_custom_js = (get_option('zedna_cookies_bar_custom_js') != '') ? get_option('zedna_cookies_bar_custom_js') : '';
    3435?>
    3536<script>
     
    121122        <th scope="row"><?php _e('Custom styles', 'zedna-cookies-bar'); ?></th>
    122123        <td>
    123                 <textarea name="zedna_cookies_bar_custom_css" class="zedna_cookies_bar_custom_css" rows="4" cols="50"><?php echo esc_attr( $cookie_bar_custom_css ); ?></textarea>
     124                <textarea name="zedna_cookies_bar_custom_css" class="zedna_cookies_bar_custom_css" rows="10" cols="50"><?php echo esc_attr( $cookie_bar_custom_css ); ?></textarea>
    124125                <small>Use identifier #zedna-cookies-bar</small>
     126                </td>
     127                </tr>
     128                <tr valign="top">
     129        <th scope="row"><?php _e('Custom javascript', 'zedna-cookies-bar'); ?></th>
     130        <td>
     131                    <table>
     132                        <tr>
     133                            <td>
     134                                <pre>function zednaAcceptCookies() {</pre>
     135                            </td>
     136                        </tr>
     137                        <tr>
     138                            <td>
     139                                <textarea name="zedna_cookies_bar_custom_js" class="zedna_cookies_bar_custom_js" rows="10" cols="50"><?php echo esc_attr( $cookie_bar_custom_js ); ?></textarea>
     140                                <small>Callback function is called when user agree with cookie consent.</small>
     141                            </td>
     142                        </tr>
     143                        <tr>
     144                            <td>
     145                                <pre>
     146                                    }
     147                                </pre>
     148                            </td>
     149                        </tr>
     150                    </table>
    125151                </td>
    126152                </tr>
     
    153179    register_setting( 'zedna-cookies-bar-settings', 'zedna_cookies_bar_close' );
    154180    register_setting( 'zedna-cookies-bar-settings', 'zedna_cookies_bar_close_color' );
     181    register_setting( 'zedna-cookies-bar-settings', 'zedna_cookies_bar_custom_js' );
    155182}
    156183add_action( 'admin_init', 'zedna_cookies_bar_settings' );
     
    169196        delete_option( 'zedna_cookies_bar_close' );
    170197        delete_option( 'zedna_cookies_bar_close_color' );
     198        delete_option( 'zedna_cookies_bar_custom_js' );
    171199}
    172200register_uninstall_hook( __FILE__, 'zedna_cookies_bar_uninstall' );
     
    199227$zedna_cookies_bar_button_output = esc_attr( get_option('zedna_cookies_bar_button') );
    200228$zedna_cookies_bar_close_output = esc_attr( get_option('zedna_cookies_bar_close') );
     229$zedna_cookies_bar_close_callback = htmlspecialchars_decode( get_option('zedna_cookies_bar_custom_js') );
    201230if ( empty( $zedna_cookies_bar_message_output ) ) $zedna_cookies_bar_message_output = "By browsing this website you are agreeing to our <a href='".get_home_url()."' target='_blank' rel='nofollow'>cookies policy</a>.";
    202231if ( empty( $zedna_cookies_bar_button_output ) ) $zedna_cookies_bar_button_output = "I Agree";
     
    216245    <?php endif;?>
    217246</style>
     247<script type="text/javascript">
     248function zednaAcceptCookiesCallback(){
     249<?php echo $zedna_cookies_bar_close_callback;?>
     250}
     251</script>
    218252<!-- End Cookies bar -->
    219253<?php
Note: See TracChangeset for help on using the changeset viewer.