/home/techb158/public_html/wp-content/plugins/wpforms-lite/src/Admin/Education/Builder
Edit: /home/techb158/public_html/wp-content/plugins/wpforms-lite/src/Admin/Education/Builder/Gdpr.php (2677B)
hooks();
}
/**
* Register hooks.
*
* @since 2.0.0
*/
private function hooks() {
add_action( 'wpforms_field_options_bottom_basic-options', [ $this, 'maybe_render_notice' ], 10, 1 );
add_action( 'wpforms_builder_enqueues', [ $this, 'enqueue_assets' ] );
}
/**
* Whether the WPConsent notice should render.
*
* @since 2.0.0
*
* @return bool
*/
private function should_render(): bool {
return ! WPConsent::is_activated() && wpforms_can_install( 'plugin' );
}
/**
* Render the "Set Up Privacy Compliance" notice below Description for the
* GDPR Agreement field only.
*
* @since 2.0.0
*
* @param array $field Field data.
*/
public function maybe_render_notice( $field ) {
if ( ! isset( $field['type'] ) || $field['type'] !== 'gdpr-checkbox' || ! $this->should_render() ) {
return;
}
$data = WPConsent::get_install_button_data();
$attrs_html = '';
foreach ( $data['attrs'] as $key => $value ) {
$attrs_html .= sprintf( ' %s="%s"', esc_attr( $key ), esc_attr( $value ) );
}
printf(
'
',
esc_html__( 'Set Up Privacy Compliance', 'wpforms-lite' ),
esc_html__( 'Improve GDPR, CCPA, and privacy compliance with cookie banner and consent records.', 'wpforms-lite' ),
esc_url( WPConsent::get_setup_url() ),
esc_attr__( 'Set Up WPConsent', 'wpforms-lite' ),
$attrs_html, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- each attr key/value escaped above.
esc_html__( 'Install WPConsent', 'wpforms-lite' )
);
}
/**
* Enqueue the inline install handler in the builder.
*
* @since 2.0.0
*/
public function enqueue_assets() {
if ( ! $this->should_render() ) {
return;
}
$min = wpforms_get_min_suffix();
wp_enqueue_script(
'wpforms-wpconsent-install',
WPFORMS_PLUGIN_URL . "assets/js/admin/education/wpconsent-install{$min}.js",
[ 'jquery' ],
WPFORMS_VERSION,
true
);
wp_localize_script(
'wpforms-wpconsent-install',
'wpforms_wpconsent_install',
[ 'ajax_url' => admin_url( 'admin-ajax.php' ) ]
);
}
}