| ' . __( 'Cookie', 'cookie-law-info' ) . ' | '; } if ( in_array( 'type', $columns ) ) { $ret .= '' . __( 'Type', 'cookie-law-info' ) . ' | '; } if ( in_array( 'duration', $columns ) ) { $ret .= '' . __( 'Duration', 'cookie-law-info' ) . ' | '; } if ( in_array( 'description', $columns ) ) { $ret .= '' . __( 'Description', 'cookie-law-info' ) . ' | '; } $ret = apply_filters( 'cli_new_columns_to_audit_table', $ret ); $ret .= '
|---|---|---|---|
| ' . esc_html( $atts['not_shown_message'] ) . ' | |||
| ' . esc_html( sanitize_text_field( $post->post_title ) ) . ' | '; } if ( in_array( 'type', $columns ) ) { $ret .= '' . esc_html( $cookie_type ) . ' | '; } if ( in_array( 'duration', $columns ) ) { $ret .= '' . esc_html( $cookie_duration ) . ' | '; } if ( in_array( 'description', $columns ) ) { $ret .= '' . wp_kses_post( $post->post_content ) . ' | '; } $ret = apply_filters( 'cli_new_column_values_to_audit_table', $ret, $custom ); $ret .= '
' . esc_html( __( $atts['heading'], 'cookie-law-info' ) ) . '
' . $ret; // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText } } if ( '' === $atts['not_shown_message'] && empty( $posts ) ) { $ret = ''; } return $ret; } /** * Returns HTML for a standard (green, medium sized) 'Accept' button */ public function cookielawinfo_shortcode_accept_button( $atts ) { $atts = shortcode_atts( array( 'colour' => 'green', 'margin' => '', ), $atts, 'cookie_accept' ); $defaults = Cookie_Law_Info::get_default_settings( 'button_1_text' ); $settings = wp_parse_args( Cookie_Law_Info::get_settings(), $defaults ); $button_1_text = __( $settings['button_1_text'], 'cookie-law-info' ); // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText $margin_style = $atts['margin'] != '' ? ' style="margin:' . esc_attr( $atts['margin'] ) . ';" ' : ''; return '' . esc_html( stripslashes( $button_1_text ) ) . ''; } /** Returns HTML for a standard (green, medium sized) 'Reject' button */ public function cookielawinfo_shortcode_reject_button( $atts ) { $atts = shortcode_atts( array( 'margin' => '', ), $atts, 'cookie_reject' ); $margin_style = $atts['margin'] != '' ? ' style="margin:' . esc_attr( $atts['margin'] ) . ';" ' : ''; $defaults = Cookie_Law_Info::get_default_settings(); $settings = wp_parse_args( Cookie_Law_Info::get_settings(), $defaults ); $classr = ''; if ( $settings['button_3_as_button'] ) { $classr = ' class="' . esc_attr( $settings['button_3_button_size'] ) . ' cli-plugin-button cli-plugin-main-button cookie_action_close_header_reject cli_action_button wt-cli-reject-btn"'; } else { $classr = ' class="cookie_action_close_header_reject cli_action_button wt-cli-reject-btn" '; } $url_reject = ( $settings['button_3_action'] == 'CONSTANT_OPEN_URL' && $settings['button_3_url'] != '#' ) ? 'href="' . esc_url( $settings['button_3_url'] ) . '"' : "role='button' tabindex='0'"; $link_tag = ''; $link_tag .= '' . esc_html( stripslashes( __( $settings['button_3_text'], 'cookie-law-info' ) ) ) . ''; // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText return $link_tag; } /* * Cookie Settings Button Shortcode * @since 1.7.7 */ public function cookielawinfo_shortcode_settings_button( $atts ) { $atts = shortcode_atts( array( 'margin' => '', ), $atts, 'cookie_settings' ); $margin_style = $atts['margin'] != '' ? ' style="margin:' . esc_attr( $atts['margin'] ) . ';" ' : ''; $defaults = Cookie_Law_Info::get_default_settings(); $settings = wp_parse_args( Cookie_Law_Info::get_settings(), $defaults ); $settings['button_4_url'] = '#'; $settings['button_4_action'] = '#cookie_action_settings'; $settings['button_4_new_win'] = false; $classr = ''; if ( $settings['button_4_as_button'] ) { $classr = ' class="' . esc_attr( $settings['button_4_button_size'] ) . ' cli-plugin-button cli-plugin-main-button cli_settings_button"'; } else { $classr = ' class="cli_settings_button"'; } // adding custom style $url_s = ( $settings['button_4_action'] == 'CONSTANT_OPEN_URL' && $settings['button_4_url'] != '#' ) ? 'href="' . esc_url( $settings['button_4_url'] ) . '"' : "role='button' tabindex='0'"; $link_tag = ''; $link_tag .= '' . esc_html( stripslashes( $settings['button_4_text'] ) ) . ''; return $link_tag; } /** Returns HTML for a generic button */ public function cookielawinfo_shortcode_more_link( $atts ) { return $this->cookielawinfo_shortcode_button_DRY_code( 'button_2', $atts ); } /** Returns HTML for a generic button */ public function cookielawinfo_shortcode_main_button( $atts ) { $atts = shortcode_atts( array( 'margin' => '', ), $atts, 'cookie_button' ); $margin_style = $atts['margin'] != '' ? ' margin:' . esc_attr( $atts['margin'] ) . '; ' : ''; $defaults = Cookie_Law_Info::get_default_settings(); $settings = wp_parse_args( Cookie_Law_Info::get_settings(), $defaults ); $class = ''; if ( $settings['button_1_as_button'] ) { $class = ' class="' . esc_attr( $settings['button_1_button_size'] ) . ' cli-plugin-button cli-plugin-main-button cookie_action_close_header cli_action_button wt-cli-accept-btn"'; } else { $class = ' class="cli-plugin-main-button cookie_action_close_header cli_action_button wt-cli-accept-btn" '; } // If is action not URL then don't use URL! $url = ( $settings['button_1_action'] == 'CONSTANT_OPEN_URL' && $settings['button_1_url'] != '#' ) ? 'href="' . esc_url( $settings['button_1_url'] ) . '"' : "role='button' tabindex='0'"; $link_tag = '' . esc_html( stripslashes( __( $settings['button_1_text'], 'cookie-law-info' ) ) ) . ''; // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText return $link_tag; } /** Returns HTML for a generic button */ public function cookielawinfo_shortcode_button_DRY_code( $name, $atts = array() ) { $atts = shortcode_atts( array( 'margin' => '', ), $atts, 'cookie_link' ); $margin_style = $atts['margin'] != '' ? ' margin:' . esc_attr( $atts['margin'] ) . '; ' : ''; $arr = Cookie_Law_Info::get_settings(); $settings = array(); $class_name = ''; if ( $name == 'button_1' ) { $settings = array( 'button_x_text' => stripslashes( $arr['button_1_text'] ), 'button_x_url' => $arr['button_1_url'], 'button_x_action' => $arr['button_1_action'], 'button_x_link_colour' => $arr['button_1_link_colour'], 'button_x_new_win' => $arr['button_1_new_win'], 'button_x_as_button' => $arr['button_1_as_button'], 'button_x_button_colour' => $arr['button_1_button_colour'], 'button_x_button_size' => $arr['button_1_button_size'], ); $class_name = 'cli-plugin-main-button'; } elseif ( $name == 'button_2' ) { $settings = array( 'button_x_text' => stripslashes( $arr['button_2_text'] ), 'button_x_action' => $arr['button_2_action'], 'button_x_link_colour' => $arr['button_2_link_colour'], 'button_x_new_win' => $arr['button_2_new_win'], 'button_x_as_button' => $arr['button_2_as_button'], 'button_x_button_colour' => $arr['button_2_button_colour'], 'button_x_button_size' => $arr['button_2_button_size'], ); $class_name = 'cli-plugin-main-link'; if ( $arr['button_2_url_type'] == 'url' ) { $settings['button_x_url'] = $arr['button_2_url']; /* * @since 1.7.4 * Checks if user enabled minify bar in the current page */ if ( $arr['button_2_hidebar'] === true ) { global $wp; $current_url = home_url( add_query_arg( array(), $wp->request ) ); $btn2_url = $current_url[ strlen( $current_url ) - 1 ] == '/' ? substr( $current_url, 0, -1 ) : $current_url; $btn2_url = $arr['button_2_url'][ strlen( $arr['button_2_url'] ) - 1 ] == '/' ? substr( $arr['button_2_url'], 0, -1 ) : $arr['button_2_url']; if ( strpos( $btn2_url, $current_url ) !== false ) { if ( $btn2_url != $current_url ) { $qry_var_arr = explode( '?', $current_url ); $hash_var_arr = explode( '#', $current_url ); if ( $qry_var_arr[0] == $btn2_url || $hash_var_arr[0] == $btn2_url ) { $class_name .= ' cli-minimize-bar'; } } else { $class_name .= ' cli-minimize-bar'; } } } } else { $privacy_page_exists = 0; if ( $arr['button_2_page'] > 0 ) { $privacy_policy_page = get_post( $arr['button_2_page'] ); if ( $privacy_policy_page instanceof WP_Post ) { if ( $privacy_policy_page->post_status === 'publish' ) { $privacy_page_exists = 1; $settings['button_x_url'] = get_page_link( $privacy_policy_page ); /* * @since 1.7.4 * Checks if user enabled minify bar in the current page */ if ( $arr['button_2_hidebar'] === true ) { if ( is_page( $arr['button_2_page'] ) ) { $class_name .= ' cli-minimize-bar'; } } } } } if ( $privacy_page_exists == 0 ) { return ''; } } } $settings = apply_filters( 'wt_readmore_link_settings', $settings ); $class = ''; if ( $settings['button_x_as_button'] ) { $class .= ' class="' . esc_attr( $settings['button_x_button_size'] ) . ' cli-plugin-button ' . esc_attr( $class_name ) . '"'; } else { $class .= ' class="' . esc_attr( $class_name ) . '" '; } // If is action not URL then don't use URL! $url = ( $settings['button_x_action'] == 'CONSTANT_OPEN_URL' && $settings['button_x_url'] != '#' ) ? 'href="' . esc_url( $settings['button_x_url'] ) . '"' : "role='button' tabindex='0'"; $link_tag = '' . esc_html( $settings['button_x_text'] ) . ''; return $link_tag; } /** * Shortcode for adding close button * * @since 1.8.9 * @return string */ public function cookielawinfo_shortcode_close_button() { $styles = ''; return '×'; } /** * Add a link that allows the user the revisit their consent * * @since 1.9.4 * @access public * @return string */ public function manage_consent() { if ( ! $this->cookie_options ) { $this->cookie_options = Cookie_Law_Info::get_settings(); } $manage_consent_link = ''; $manage_consent_text = ( isset( $this->cookie_options['showagain_text'] ) ? $this->cookie_options['showagain_text'] : '' ); $manage_consent_link = '' . esc_html( $manage_consent_text ) . ''; return $manage_consent_link; } /** * Creates accept all button * * @return void */ public function accept_all_button() { $defaults = Cookie_Law_Info::get_default_settings(); $settings = wp_parse_args( Cookie_Law_Info::get_settings(), $defaults ); $class = ''; if ( $settings['button_7_as_button'] ) { $class = ' class="wt-cli-element' . ' ' . esc_attr( $settings['button_7_button_size'] ) . ' cli-plugin-button wt-cli-accept-all-btn cookie_action_close_header cli_action_button"'; } else { $class = ' class="wt-cli-element cli-plugin-main-button wt-cli-accept-all-btn cookie_action_close_header cli_action_button" '; } $url = ( $settings['button_7_action'] == 'CONSTANT_OPEN_URL' && $settings['button_7_url'] != '#' ) ? 'href="' . esc_url( $settings['button_7_url'] ) . '"' : "role='button'"; $link_tag = '' . esc_html( stripslashes( $settings['button_7_text'] ) ) . ''; return $link_tag; } } new Cookie_Law_Info_Shortcode( $this );