开发者 |
Erik Bernskiold
annlickander bernskioldmedia |
---|---|
更新时间 | 2024年2月4日 21:44 |
PHP版本: | 7.2 及以上 |
WordPress版本: | 6.4 |
版权: | GPLv2 or later |
版权网址: | 版权信息 |
ilmenite-cookie-consent
to the /wp-content/plugins/
directory.You can set the URL to the cookie policy page in the customizer under the "Cookie Banner" section, or use the filter ilcc_policy_url
to return your own link.
Out of the box, the plugin includes a lightweight stylesheet with two placement options (top & overlay). If you don't want to use our default coloring, you can easily prevent us from including the styles.
Just define the following filter somewhere in your code, such as the theme functions.php file:
add_filter( 'ilcc_load_stylesheet', '__return_false' );
Additionally, for quick theming to your theme's custom colors, we support a series of CSS variables set on body.has-ilcc-banner
like so:
body.has-ilcc-banner {
--ilcc-background-color: #282b2d;
--ilcc-text-color: #ccc;
--ilcc-link-color: #ccc;
--ilcc-link-color-hover: #fff;
--ilcc-banner-spacing: 1.4rem 0;
--ilcc-close-button: #474d50;
--ilcc-close-button-hover: #666;
--ilcc-close-button-text: white;
--ilcc-close-button-hover-text: white;
--ilcc-button-radius: 4px;
}
If you would like to add your own style in addition to the two offered, you can override the style setting with the ilcc_style
filter. This would let you style outside the two core positions.
You can change the the two lines of text and the button label from the customizer under the "Cookie Banner" section. Alternatively you can use a set of filters to return values before rendering.
Modiyfing the title: ilcc_consent_title
Modiyfing the text info: ilcc_consent_text
Modiyfing the accept button label: ilcc_accept_text
Just set their value somewhere in your code, such as in the functions.php file of your theme:
function ilcc_modify_consent_text( $text ) {
$text = __( 'This is my custom text about how we use cookies.', 'YOURTEXTDOMAIN' );
return $text;
}
add_filter( 'ilcc_consent_text', 'ilcc_modify_consent_text' );
function ilcc_modify_accept_text( $text ) {
$text = __( 'I Accept', 'YOURTEXTDOMAIN' );
return $text;
}
add_filter( 'ilcc_accept_text', 'ilcc_modify_accept_text' );
ilcc_loaded
- Runs on constructor.
before_ilcc_init
- Runs before we have run any init actions.
ilcc_init
- Runs when all init hooks have run.
ilcc_has_user_consented
- Specifiy if the user has accepted or not. True or false value. Has arguments $cookie_name and $cookie_value.
ilcc_cookie_active_value
- Set which value is "active" for the cookie, ie. consented. Defaults to 1.
ilcc_cookie_name
- Set the name of the cookie. Defaults to 'EUConsentCookie'.
ilcc_accept_text
- Set the accept button text.
ilcc_consent_text
- Set the consent text. Has $policy_url as argument.
ilcc_policy_url
- Allows you to modify the Policy URL. Has the url from the options as argument.
ilcc_style
- Allows you to set your own style name.
ilcc_edit_text_capability
- Allows you to modify which capability is required for editing the cookie banner text (below the title) in the customizer. Defaults to edit_theme_options
.
ilcc_edit_title_capability
- Allows you to modify which capability is required for editing the cookie banner title in the customizer. Defaults to edit_theme_options
.
ilcc_edit_button_capability
- Allows you to modify which capability is required for editing the cookie banner button label in the customizer. Defaults to edit_theme_options
.
ilcc_edit_policy_url_capability
- Allows you to modify which capability is required for editing the policy URL in the customizer. Defaults to edit_theme_options
.
ilcc_edit_style_capability
- Allows you to modify which capability is required for editing the cookie banner style in the customizer. Defaults to edit_theme_options
.
ilcc_load_stylesheets
- (bool) Set if you want the stylesheets to be loaded or not. Defaults to true.
ilcc_enable_customizer
- Return false to disable all the customizer settings, if you'd like to prevent any user from changing any of the settings.
ilcc_preferences_cookie_name
- The name of the cookie that stores if a visitor has set their cookie preferences.
ilcc_categories_cookie_name
- The name of the cookie that stores the categories the visitor has opted in to.
ilcc_tracker_settings_enabled
- Return false to disable the tracker customization settings screen.
ilcc_is_active_on_page
- Return false to hide the banner from loading. Can be used to prevent the banner from loading on certain pages or templates.
ilcc_preferences_cookie_name
filter to replace the now removed ilcc_cookie_name
filter.ilcc_categories_cookie_name
filter.ilcc_remember_duration
filter.ilcc_tracker_settings_enabled
filter.ilcc_has_user_consented
filter.ilcc_cookie_active_value
filter.ilcc_edit_text_capability
, ilcc_edit_title_capability
, ilcc_edit_button_capability
and ilcc_edit_policy_url_capability
with a simpler ilcc_edit_texts_capability
that takes the setting as an argument.<a>
tag for the acceptance button, to a more proper button
.