/**
* Prepare banner config for migration.
*
* @param array $config Banner config.
* @return array
*/
public function prepare_config( $config = array() ) {
$settings = $this->settings;
$current_type = isset( $settings['cookie_bar_as'] ) ? sanitize_text_field( $settings['cookie_bar_as'] ) : 'banner';
$position = isset( $settings['notify_position_vertical'] ) ? sanitize_text_field( $settings['notify_position_vertical'] ) : 'bottom-left';
$heading = isset( $settings['bar_heading_text'] ) ? $settings['bar_heading_text'] : '';
$type = 'banner';
if ( 'popup' === $current_type || 'widget' === $current_type ) {
$type = 'box';
$position = isset( $settings['widget_position'] ) ? sanitize_text_field( $settings['widget_position'] ) : 'left';
$position = "bottom-{$position}";
}
$config['settings']['type'] = $type;
$config['settings']['theme'] = 'custom';
$config['settings']['position'] = $position;
$background_color = isset( $settings['background'] ) ? cky_sanitize_color( $settings['background'] ) : $config['config']['notice']['styles']['background-color'];
$border_color = isset( $settings['border'] ) ? cky_sanitize_color( $settings['border'] ) : $config['config']['notice']['styles']['border-color'];
$color = isset( $settings['text'] ) ? cky_sanitize_color( $settings['text'] ) : $config['config']['notice']['styles']['color'];
$config['config']['notice']['styles']['background-color'] = $background_color;
$config['config']['notice']['styles']['border-color'] = $border_color;
$config['config']['notice']['elements']['title']['styles']['color'] = $color;
$config['config']['notice']['elements']['description']['styles']['color'] = $color;
$config['config']['preferenceCenter']['styles']['background-color'] = $background_color;
$config['config']['preferenceCenter']['styles']['border-color'] = $border_color;
$buttons_config = isset( $config['config']['notice']['elements']['buttons']['elements'] ) ? $config['config']['notice']['elements']['buttons']['elements'] : array();
if ( ! empty( $buttons_config ) ) {
$accept_button = has_shortcode( $settings['notify_message'], 'cookie_accept_all' ) ? 'button_7' : 'button_1';
$buttons_config['accept'] = isset( $buttons_config['accept'] ) ? $this->prepare_buttons( $accept_button, $buttons_config['accept'] ) : array();
$buttons_config['reject'] = isset( $buttons_config['reject'] ) ? $this->prepare_buttons( 'button_3', $buttons_config['reject'] ) : array();
$buttons_config['settings'] = isset( $buttons_config['settings'] ) ? $this->prepare_buttons( 'button_4', $buttons_config['settings'] ) : array();
$buttons_config['donotSell'] = isset( $buttons_config['donotSell'] ) ? $this->prepare_buttons( 'button_6', $buttons_config['donotSell'] ) : array();
$buttons_config['readMore'] = isset( $buttons_config['readMore'] ) ? $this->prepare_buttons( 'button_2', $buttons_config['readMore'] ) : array();
$buttons_config['readMore'] = $this->prepare_readmore( $buttons_config['readMore'] );
$config['config']['notice']['elements']['buttons']['elements'] = $buttons_config;
$preference_center = isset( $config['config']['preferenceCenter'] ) ? $config['config']['preferenceCenter'] : array();
$preference_buttons = isset( $preference_center['elements']['buttons']['elements'] ) ? $preference_center['elements']['buttons']['elements'] : array();
$preference_buttons['accept']['styles'] = isset( $buttons_config['accept']['styles'] ) ? $buttons_config['accept']['styles'] : array();
$preference_buttons['reject']['styles'] = isset( $buttons_config['reject']['styles'] ) ? $buttons_config['reject']['styles'] : array();
$preference_buttons['save']['styles'] = isset( $buttons_config['settings']['styles'] ) ? $buttons_config['settings']['styles'] : array();
$config['config']['preferenceCenter']['elements']['buttons']['elements'] = $preference_buttons;
}
$revisit_options = isset( $config['config']['revisitConsent'] ) ? $config['config']['revisitConsent'] : array();
$config['config']['revisitConsent'] = $this->get_revisit_options( $revisit_options );
return $config;
}
/**
* Prepare the buttons for migration.
*
* @param string $button Button slug as of old settings.
* @param array $config Existing config.
* @return array
*/
public function prepare_buttons( $button = 'button_1', $config = array() ) {
$settings = $this->settings;
$shortcode = $this->get_shortcode( $button );
if ( false === $this->skip ) {
$config['status'] = has_shortcode( $settings['notify_message'], $shortcode );
}
if ( 'ccpa' === $this->law && 'button_6' !== $button || 'gdpr' === $this->law && 'button_6' === $button ) {
$config['status'] = false;
}
$config['styles']['background-color'] = isset( $settings[ "{$button}_button_colour" ] ) ? $settings[ "{$button}_button_colour" ] : '';
$config['styles']['color'] = isset( $settings[ "{$button}_link_colour" ] ) ? $settings[ "{$button}_link_colour" ] : '';
$config['styles']['border-color'] = $config['styles']['background-color'];
return $config;
}
/**
* Set background and border color transparent.
*
* @param array $config Existing config.
* @return array
*/
public function prepare_readmore( $config = array() ) {
$config['styles']['background-color'] = 'transparent';
$config['styles']['border-color'] = 'transparent';
return $config;
}
/**
* Prepare banner contents for migration.
*
* @param array $contents Existing contents.
* @param string $language Language slug.
* @return array
*/
public function prepare_contents( $contents, $language ) {
$settings = $this->settings;
$notice = isset( $contents['notice']['elements'] ) ? $contents['notice']['elements'] : array();
$notice['title'] = isset( $settings['bar_heading_text'] ) ? cky_i18n_translate_string( $settings['bar_heading_text'], 'bar_heading_text', $language ) : '';
$notice['description'] = isset( $settings['notify_message'] ) ? wp_strip_all_tags( strip_shortcodes( cky_i18n_translate_string( $settings['notify_message'], 'notify_message', $language ) ) ) : '';
$notice['privacyLink'] = $this->get_readmore_link();
$accept_button = has_shortcode( $settings['notify_message'], 'cookie_accept_all' ) ? 'button_7' : 'button_1';
$notice['buttons']['elements']['accept'] = $this->get_button_text( $accept_button, $language );
$notice['buttons']['elements']['reject'] = $this->get_button_text( 'button_3', $language );
$notice['buttons']['elements']['settings'] = $this->get_button_text( 'button_4', $language );
$notice['buttons']['elements']['readMore'] = $this->get_button_text( 'button_2', $language );
$contents['notice']['elements'] = $notice;
// Preference center.
$preference = isset( $contents['preferenceCenter']['elements'] ) ? $contents['preferenceCenter']['elements'] : array();
$existing = $this->get_preference_center_texts();
$preference['title'] = cky_i18n_translate_string( $existing['title'], 'privacy_overview_title', $language, 'cookielawinfo_privacy_overview_content_settings' );
$preference['description'] = cky_i18n_translate_string( $existing['description'], 'privacy_overview_content', $language, 'cookielawinfo_privacy_overview_content_settings' );
$preference['buttons']['elements']['accept'] = $this->get_button_text( $accept_button, $language );
$preference['buttons']['elements']['reject'] = $this->get_button_text( 'button_3', $language );
$contents['preferenceCenter']['elements'] = $preference;
$contents['revisitConsent']['elements']['title'] = cky_i18n_translate_string( $existing['title'], 'title', $language );
return $contents;
}
/**
* Get button text based on language
*
* @param string $button Button slug.
* @param string $language Language code.
* @return string
*/
public function get_button_text( $button = 'button_1', $language = 'en' ) {
$settings = $this->settings;
return isset( $settings[ "{$button}_text" ] ) ? cky_i18n_translate_string( $settings[ "{$button}_text" ], "{$button}_text", $language ) : '';
}
/**
* Return preference center options
*
* @return array
*/
public function get_preference_center_texts() {
$overview = get_option( 'cookielawinfo_privacy_overview_content_settings' );
$title = sanitize_text_field( stripslashes( isset( $overview['privacy_overview_title'] ) ? $overview['privacy_overview_title'] : '' ) );
$description = wp_kses_post( isset( $overview['privacy_overview_content'] ) ? $overview['privacy_overview_content'] : '' );
return array(
'title' => $title,
'description' => $description,
);
}
/**
* Migrate revisit consent option.
*
* @param array $options Array of options.
* @return array
*/
public function get_revisit_options( $options = array() ) {
$settings = $this->settings;
$status = isset( $settings['showagain_tab'] ) ? (bool) $settings['showagain_tab'] : false;
$position = isset( $settings['notify_position_horizontal'] ) && 'right' === $settings['notify_position_horizontal'] ? 'bottom-right' : 'bottom-left';
$options['status'] = $status;
$options['position'] = $position;
return $options;
}
/**
* Map shortcodes to corresponding buttons.
*
* @param string $button Button slug.
* @return string
*/
public function get_shortcode( $button ) {
switch ( $button ) {
case 'button_1':
return 'cookie_button';
case 'button_2':
return 'cookie_link';
case 'button_3':
return 'cookie_reject';
case 'button_4':
return 'cookie_settings';
case 'button_6':
return 'wt_cli_ccpa_optout';
case 'button_7':
return 'cookie_accept_all';
default:
return 'cookie_button';
}
}
/**
* Reorder the terms based on the priority.
*
* @param array $terms Terms array.
* @param string $order Sorting order.
* @return array
*/
public function order_term_by_key( $terms, $order = 'DESC' ) {
$sort_order = SORT_DESC;
$meta_values = array();
if ( 'ASC' === $order ) {
$sort_order = SORT_ASC;
}
if ( ! empty( $terms ) && is_array( $terms ) ) {
foreach ( $terms as $key => $term ) {
$priority = get_term_meta( $term->term_id, 'CLIpriority' );
$meta_values[] = isset( $priority ) ? absint( $priority ) : 0;
}
if ( ! empty( $meta_values ) && is_array( $meta_values ) ) {
array_multisort( $meta_values, $sort_order, $terms );
}
}
return $terms;
}
/**
* Add a migration notice which allows to revert back to the legacy UI.
*
* @return void
*/
public function add_migration_notice() {
$options = get_option( 'cky_migration_options', array() );
$status = isset( $options['status'] ) ? $options['status'] : false;
$expiry = isset( $options['expiry'] ) ? $options['expiry'] : 0;
if ( ! $status || ( 0 !== $expiry && time() > $expiry ) ) {
return;
}
if ( true === $status ) {
add_filter(
'cky_admin_scripts_global',
function( $config ) {
$config['legacyURL'] = esc_attr( wp_nonce_url( add_query_arg( 'revert', 'true', admin_url( 'admin.php?page=cookie-law-info' ) ), 'revert', '_wpnonce' ) );
return $config;
}
);
$date = date_i18n( 'M d,Y', $expiry );
$notice = Notice::get_instance();
$notice->add(
'migration_notice',
array( // translators: %s: Migration notice expiry notice.
'message' => sprintf( __( 'Not satisfied with the New UI and related changes? You can switch back to the old UI at any time until %s.', 'cookie-law-info' ), esc_html( $date ) ),
'type' => 'info',
)
);
}
}
/**
* Return the readmore link
*
* @return string
*/
private function get_readmore_link() {
if ( $this->settings['button_2_url_type'] == 'url' ) {
return isset( $this->settings['button_2_url'] ) ? $this->settings['button_2_url'] : '';
} else {
$page = isset( $this->settings['button_2_page'] ) ? intval( $this->settings['button_2_page'] ) : false;
$privacy = '';
if ( ! $page ) {
return '';
}
$post = get_post( $page );
if ( $post instanceof \WP_Post ) {
if ( 'publish' === $post->post_status ) {
$privacy = get_page_link( $post );
}
}
return $privacy;
}
}
/**
* Revert plugin to legacy UI
*
* @return void
*/
public function revert() {
if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['_wpnonce'] ) ), 'revert' ) || ! current_user_can( 'manage_options' ) ) {
return;
}
if ( ! isset( $_GET['revert'] ) && 'true' === sanitize_text_field( wp_unslash( $_GET['revert'] ) ) ) {
return;
}
$settings = new Settings();
$options = $settings->get();
$options['api']['token'] = '';
$options['account']['connected'] = false;
$settings->update( $options );
delete_option( 'cky_cookie_consent_lite_db_version' );
wp_safe_redirect( admin_url( 'edit.php?post_type=cookielawinfo&page=cookie-law-info' ) );
}
}
Fatal error: require_once(): Failed opening required '/var/www/html/helitower.com.br/web/wp-content/plugins/js_composer/include/autoload/params/vc_grid_item.php' (include_path='.:/usr/share/pear') in /var/www/html/helitower.com.br/web/wp-content/plugins/js_composer/include/classes/core/class-vc-manager.php on line 323