Myagileprivacy Shortcodes

Below, you’ll find a detailed guide on how to add the Myagileprivacy Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Myagileprivacy Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Myagileprivacy Plugin and the shortcodes it provides:

Plugin Icon
My Agile Privacy – The only GDPR solution for WordPress that you can truly trust

"My Agile Privacy is the ultimate GDPR solution for WordPress users. Instill your visitors with confidence, knowing their data is securely managed and trustfully handled with this dependable plugin."

★★★★★ (4) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [myagileprivacy_cookie_accept]
  • [myagileprivacy_cookie_reject]
  • [myagileprivacy_cookie_customize]
  • [myagileprivacy_extra_info]
  • [myagileprivacy_fixed_text]
  • [myagileprivacy_link]
  • [myagileprivacy_showconsent]
  • [myagileprivacy_blocked_content_notification]

Myagileprivacy [myagileprivacy_cookie_accept] Shortcode

The MyAgilePrivacy shortcode is a customizable cookie acceptance button. It displays a consent button with adjustable colors, margins, and animation effects. It also allows for translation reloads, catering to a multilingual audience.

Shortcode: [myagileprivacy_cookie_accept]

Parameters

Here is a list of all possible myagileprivacy_cookie_accept shortcode parameters and attributes:

  • margin – Sets the space around the accept cookie button

Examples and Usage

Basic example – A simple usage of the shortcode to display the ‘Accept’ button with default settings.

[myagileprivacy_cookie_accept /]

Advanced examples

Using the shortcode to display the ‘Accept’ button with a custom margin. The margin parameter adjusts the space around the button.

[myagileprivacy_cookie_accept margin="10px" /]

Using the shortcode to display the ‘Accept’ button with a custom margin and a specific animation delay. The ‘margin’ parameter adjusts the space around the button, while the ‘accept_button_animation_delay’ parameter sets the delay time for the button’s animation effect.

[myagileprivacy_cookie_accept margin="10px" accept_button_animation_delay="500" /]
Please note that the advanced examples are illustrative and may not work as expected without additional modifications to the PHP function ‘myagileprivacy_cookie_accept_button’. Always ensure to test your code thoroughly before deploying it to a live website.

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_cookie_accept] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_cookie_accept', array( $this, 'myagileprivacy_cookie_accept_button' ));

Shortcode PHP function:

                    function myagileprivacy_cookie_accept_button( $atts )
	{
		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );

		$reload_translation = $this->check_if_to_reload_translation();
		extract( shortcode_atts(array(
			'margin' => '',
		), $atts ) );
		$margin_style = $margin != "" ? ' margin:'.$margin.'; ' : '';

		$the_text = stripslashes( $settings['button_accept_text'] );

		if( $reload_translation )
		{
			$the_text = __( 'Accept', 'myagileprivacy' );
		}

		$color_style = $settings['button_accept_link_color'] != "" ? ' color:'.$settings['button_accept_link_color'].'; ' : '';
		$background_style = $settings['button_accept_button_color'] != "" ? ' background-color:'.$settings['button_accept_button_color'].' ' : '';

		$border_radius_style = 'border-radius:'.$settings['elements_border_radius'].'px';

		$class = ' class="map-button map-button-style map-accept-button"';

		$animation_attrs = '';

		if( $settings['animate_accept_button'] )
		{
			$animation_effect = stripslashes( $settings['accept_button_animation_effect'] );
			$animation_delay = intval( $settings['accept_button_animation_delay'] );
			$animation_repeat = intval( $settings['accept_button_animation_repeat'] );

			$animation_attrs = 'data-animate="true" data-animation-effect="animate__'.$animation_effect.'" data-animation-delay="'.$animation_delay.'" data-animation-repeat="'.$animation_repeat.'"';
		}

		// colore icona = colore testo
		$icon_background_style = $settings['button_accept_link_color'] != "" ? ' background-color:'.$settings['button_accept_link_color'].'; ' : '';

		$link_tag = '<a role="button" data-map_action="accept" id="map-accept-button"'. $class.' style="'.esc_attr( $margin_style ).'; '. esc_attr( $color_style ).'; '.esc_attr( $background_style) .'; '.esc_attr( $border_radius_style ).';" '.esc_attr( $animation_attrs ).'>';

		if( $settings['show_buttons_icons'] ) $link_tag .= '<span style=" '.esc_attr( $icon_background_style ).';"></span>';
		$link_tag .= esc_html( $the_text ) . '</a>';

		return $link_tag;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_cookie_reject] Shortcode

The MyAgilePrivacy shortcode is a functional piece of PHP code that generates a customizable cookie rejection button on your WordPress site. This shortcode allows you to adjust the margin, text, color, and background of the button. This shortcode extracts the site’s default settings and applies them to the button. It checks if a translation reload is required, and if so, it changes the button text to ‘Refuse’. The button’s color, background, and border radius are also customizable. If the ‘show_buttons_icons’ setting is enabled, an icon will also be displayed on the button. The button is assigned the role of ‘button’, with a data action of ‘reject’. This makes it easy for users to opt out of cookies, enhancing your site’s privacy features.

Shortcode: [myagileprivacy_cookie_reject]

Parameters

Here is a list of all possible myagileprivacy_cookie_reject shortcode parameters and attributes:

  • margin – Defines the margin around the reject button

Examples and Usage

Basic example – Show the ‘Reject’ button with the default settings.

[myagileprivacy_cookie_reject /]

Advanced examples

Display the ‘Reject’ button with a specific margin. This shortcode will add a margin around the ‘Reject’ button. The margin value must be specified in CSS format (top right bottom left).

[myagileprivacy_cookie_reject margin="10px 20px 10px 20px" /]

Display the ‘Reject’ button with a different text. This shortcode will change the default ‘Refuse’ text to ‘Decline Cookies’.

[myagileprivacy_cookie_reject button_reject_text="Decline Cookies" /]

Display the ‘Reject’ button with a different color for the link and the button. This shortcode will change the default colors to the specified ones. The color values must be specified in CSS format.

[myagileprivacy_cookie_reject button_reject_link_color="#000000" button_reject_button_color="#ffffff" /]

Display the ‘Reject’ button with a different border radius. This shortcode will change the default border radius to the specified value. The value must be specified in pixels.

[myagileprivacy_cookie_reject elements_border_radius="10" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_cookie_reject] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_cookie_reject', array( $this, 'myagileprivacy_cookie_reject_button' ));

Shortcode PHP function:

                    function myagileprivacy_cookie_reject_button( $atts )
	{
		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );

		$reload_translation = $this->check_if_to_reload_translation();

		extract( shortcode_atts(array(
			'margin' => '',
		), $atts ) );
		$margin_style = $margin!="" ? ' margin:'.$margin.'; ' : '';

		$the_text = stripslashes( $settings['button_reject_text'] );

		if( $reload_translation )
		{
			$the_text = __( 'Refuse', 'myagileprivacy' );
		}

		$color_style = $settings['button_reject_link_color'] != "" ? ' color:'.$settings['button_reject_link_color'].'; ' : '';
		$background_style = $settings['button_reject_button_color'] != "" ? ' background-color:'.$settings['button_reject_button_color'].'; ' : '';

		$border_radius_style = 'border-radius:'.$settings['elements_border_radius'].'px';

		$class = ' class="map-button map-button-style map-reject-button"';

		// colore icona = colore testo
		$icon_background_style = $settings['button_reject_link_color'] != "" ? ' background-color:'.$settings['button_reject_link_color'].'; ' : '';

		$link_tag = '<a role="button" data-map_action="reject" id="map-reject-button"'. $class.' style="'.esc_attr( $margin_style ).'; '.esc_attr( $color_style) .'; '.esc_attr( $background_style ).'; '.esc_attr( $border_radius_style ).';">';

		if( $settings['show_buttons_icons'] )  $link_tag .= '<span style=" '.esc_attr( $icon_background_style ).';"></span>';
		$link_tag .= esc_html( $the_text ) . '</a>';

		return $link_tag;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_cookie_customize] Shortcode

The MyAgilePrivacy shortcode is designed to generate a customizable privacy button. This button allows users to modify their cookie settings on a WordPress site. The shortcode extracts attributes like margin, button text, color, background, and border radius from the plugin settings. It then applies these attributes to style the button. If icons are enabled in the settings, it also adds an icon to the button. The button’s action is set to “customize”, allowing users to adjust their privacy settings when clicked. The generated button is returned as a link tag, ready to be inserted into any part of the website.

Shortcode: [myagileprivacy_cookie_customize]

Parameters

Here is a list of all possible myagileprivacy_cookie_customize shortcode parameters and attributes:

  • margin – sets the margin around the cookie customization button

Examples and Usage

Basic example – In this basic example, we are using the ‘myagileprivacy_cookie_customize’ shortcode without any additional parameters. This will display the ‘Customize’ button with the default settings.

[myagileprivacy_cookie_customize /]

Advanced examples

Customizing the margin of the ‘Customize’ button. By specifying the ‘margin’ parameter, we can adjust the space around the button. The value should be a valid CSS margin value.

[myagileprivacy_cookie_customize margin="10px 20px" /]

Adding multiple parameters at once. In this advanced example, we are customizing both the margin and the color of the ‘Customize’ button. The ‘color’ parameter should be a valid CSS color value.

[myagileprivacy_cookie_customize margin="10px 20px" color="#ff0000" /]

Note: In the above examples, the ‘color’ parameter is not actually supported by the ‘myagileprivacy_cookie_customize’ shortcode. It is used here just as an example of how you might pass multiple parameters to a shortcode.

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_cookie_customize] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_cookie_customize', array( $this, 'myagileprivacy_cookie_customize_button' ));

Shortcode PHP function:

                    function myagileprivacy_cookie_customize_button( $atts )
	{
		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );

		$reload_translation = $this->check_if_to_reload_translation();

		extract( shortcode_atts(array(
			'margin' => '',
		), $atts ) );
		$margin_style = $margin!="" ? ' margin:'.$margin.'; ' : '';

		$the_text = stripslashes( $settings['button_customize_text'] );

		if( $reload_translation )
		{
			$the_text = __( 'Customize', 'myagileprivacy' );
		}

		extract( shortcode_atts(array(
			'margin' => '',
		), $atts ) );
		$margin_style = $margin!="" ? ' margin:'.$margin.'; ' : '';

		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );

		$color_style = $settings['button_customize_link_color'] != "" ? ' color:'.$settings['button_customize_link_color'].'; ' : '';
		$background_style = $settings['button_customize_button_color'] != "" ? ' background-color:'.$settings['button_customize_button_color'].'; ' : '';

		$border_radius_style = 'border-radius:'.$settings['elements_border_radius'].'px';

		$class = ' class="map-button map-button-style map-customize-button"';

		// colore icona = colore testo
		$icon_background_style = $settings['button_customize_link_color'] != "" ? ' background-color:'.$settings['button_customize_link_color'].'; ' : '';

		$link_tag = '<a role="button" data-map_action="customize" id="map-customize-button"'. $class.' style="'.esc_attr( $margin_style ).'; '.esc_attr( $color_style ) .'; '.esc_attr( $background_style ) .'; '.esc_attr( $border_radius_style ).';">';

		if( $settings['show_buttons_icons'] ) $link_tag .= '<span style=" '.esc_attr( $icon_background_style ).';"></span>';
		$link_tag .= esc_html( $the_text ) . '</a>';

		return $link_tag;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_extra_info] Shortcode

The ‘myagileprivacy_extra_info’ shortcode from MyAgilePrivacy plugin is designed to manage privacy settings on a WordPress site. It fetches default and user-specific settings, checks for translation reload, and verifies if WPML or Polylang is enabled. The shortcode then generates links to the cookie and personal data policies based on these settings. It checks if the policy is a URL or a page and retrieves the correct link accordingly. The shortcode also handles margins and checks for the presence of MAP_IAB_TCF, which indicates whether the site is compliant with the Interactive Advertising Bureau’s Transparency and Consent Framework. Finally, the shortcode generates an output text that includes information about active plugins, data protection compliance, and advertising preferences.

Shortcode: [myagileprivacy_extra_info]

Examples and Usage

Basic example – A simple usage of the shortcode to display additional privacy information with default settings.

[myagileprivacy_extra_info /]

Advanced examples

Utilizing the shortcode with a specified margin. This can help to better fit the privacy information within your page layout.

[myagileprivacy_extra_info margin="10px" /]

Using the shortcode with a larger margin and in combination with other elements. In this example, the shortcode is wrapped within a div tag with a custom class for additional styling.

<div class="custom-class">[myagileprivacy_extra_info margin="20px"]</div>
Please note that the ‘margin’ attribute in the shortcode only affects the margin around the privacy information. Other styling and layout aspects should be handled with additional HTML and CSS as needed.

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_extra_info] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_extra_info', array( $this, 'myagileprivacy_extra_info' ));

Shortcode PHP function:

                    function myagileprivacy_extra_info( $atts )
	{
		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );
		$rconfig = MyAgilePrivacy::get_rconfig();

		$reload_translation = $this->check_if_to_reload_translation();

		$is_polylang_enabled = $this->check_if_polylang_enabled();
		$is_wpml_enabled = $this->check_if_wpml_enabled();

		//bof policies link

		$cookie_policy_link = ( isset( $settings ) && isset( $settings['cookie_policy_link'] ) ) ? $settings['cookie_policy_link'] : null;
		$is_cookie_policy_url = ( isset( $settings ) && isset( $settings['is_cookie_policy_url'] ) ) ? $settings['is_cookie_policy_url'] : null;
		$cookie_policy_url = ( isset( $settings ) && isset( $settings['cookie_policy_url'] ) ) ? $settings['cookie_policy_url'] : null;
		$cookie_policy_page = ( isset( $settings ) && isset( $settings['cookie_policy_page'] ) ) ? $settings['cookie_policy_page'] : null;

		$the_cookie_policy_url = null;

		if( $is_cookie_policy_url && $cookie_policy_url )
		{
			$the_cookie_policy_url = $cookie_policy_url;
		}

		if( !$is_cookie_policy_url && $cookie_policy_page )
		{
			if( $is_wpml_enabled )
			{
				$the_cookie_policy_url = get_permalink( icl_object_id( $cookie_policy_page, 'page', true) );
			}
			elseif( $is_polylang_enabled )
			{
				$the_cookie_policy_url = get_permalink( pll_get_post( $cookie_policy_page ) );
			}
			else
			{
				$the_cookie_policy_url = get_permalink( $cookie_policy_page );
			}
		}


		$personal_data_policy_link = ( isset( $settings ) && isset( $settings['personal_data_policy_link'] ) ) ? $settings['personal_data_policy_link'] : null;
		$is_personal_data_policy_url = ( isset( $settings ) && isset( $settings['is_personal_data_policy_url'] ) ) ? $settings['is_personal_data_policy_url'] : null;
		$personal_data_policy_url = ( isset( $settings ) && isset( $settings['personal_data_policy_url'] ) ) ? $settings['personal_data_policy_url'] : null;
		$personal_data_policy_page = ( isset( $settings ) && isset( $settings['personal_data_policy_page'] ) ) ? $settings['personal_data_policy_page'] : null;


		$the_personal_data_policy_url = null;

		if( $is_personal_data_policy_url && $personal_data_policy_url )
		{
			$the_personal_data_policy_url = $personal_data_policy_url;
		}

		if( !$is_personal_data_policy_url && $personal_data_policy_page )
		{
			if( $is_wpml_enabled )
			{
				$the_personal_data_policy_url = get_permalink( icl_object_id( $personal_data_policy_page, 'page', true) );
			}
			elseif( $is_polylang_enabled )
			{
				$the_personal_data_policy_url = get_permalink( pll_get_post( $personal_data_policy_page ) );
			}
			else
			{
				$the_personal_data_policy_url = get_permalink( $personal_data_policy_page );
			}
		}

		//eof policies link


		extract( shortcode_atts(array(
			'margin' => '',
		), $atts ) );
		$margin_style = $margin != "" ? ' margin:'.$margin.'; ' : '';

		$iab_tcf_context = false;

		if(
			defined( 'MAP_IAB_TCF' ) && MAP_IAB_TCF &&
			$rconfig &&
			isset( $rconfig['allow_iab'] ) &&
			$rconfig['allow_iab'] == 1 &&
			$settings['enable_iab_tcf'] )
		{
			$iab_tcf_context = true;
		}

		$show_lpd = false;

		if( isset( $settings['display_lpd'] ) && $settings['display_lpd'] )
		{
			$show_lpd = true;
		}

		$output_text = "";

		if( !function_exists( 'is_plugin_active' ) )
		{
			include_once(ABSPATH . 'wp-admin/includes/plugin.php' );
		}

		if( is_plugin_active( 'myagilepixel/myagilepixel.php' ) )
		{
			$found_items = array();

			if( defined( 'MAPX_my_agile_pixel_ga_on' ) )
			{
				$found_items[] = __( 'Google Analytics in version 4 (GA4)', 'myagileprivacy' );
			}

			if( defined( 'MAPX_my_agile_pixel_fbq_on' ) )
			{
				$found_items[] = __( 'Facebook Remarketing', 'myagileprivacy' );
			}

			if( defined( 'MAPX_my_agile_pixel_tiktok_on' ) )
			{
				$found_items[] = __( 'TikTok Pixel', 'myagileprivacy' );
			}

			if( count( $found_items ) > 0 )
			{
				$found_items_string = implode( ', ', $found_items );

				$output_text .= ' '.__( 'In addition, this site installs', 'myagileprivacy' ).' '.$found_items_string.' '.__( 'with anonymous data transmission via proxy.', 'myagileprivacy' )." ".__( 'By giving your consent, the data will be sent anonymously, thus protecting your privacy.', 'myagileprivacy' );
				;
			}
		}

		if( $show_lpd )
		{
			$output_text .= '<br> '.__('This site complies with the Data Protection Act (LPD), Swiss Federal Law of September 25, 2020, and the GDPR, EU Regulation 2016/679, regarding the protection of personal data as well as the free movement of such data.', 'myagileprivacy' );
		}

		if( $iab_tcf_context )
		{
			$output_text .= ' '.__( 'We and our selected ad partners can store and/or access information on your device, such as cookies, unique identifiers, browsing data.', 'myagileprivacy').' '.__( 'You can always choose the specific purposes related to profiling by accessing the <a href="#" class="map-triggerGotoIABTCF">advertising preferences panel</a>, and you can always withdraw your consent at any time by clicking on "Manage consent" at the bottom of the page.', 'myagileprivacy' ).'<br><br>'.__( 'List of some possible advertising permissions', 'myagileprivacy' ).':<br><span id="map-vendor-stack-description"></span><br>';

			$output_text .= __( 'You can consult: our list of <span id="map-vendor-number-count"></span> <a href="#" class="map-triggerGotoIABTCFVendors">advertising partners</a>', 'myagileprivacy');

			if( $the_cookie_policy_url )
			{
				$output_text .= ', <a class="map-genericFirstLayerLink" target="blank" href="'.esc_url( $the_cookie_policy_url ).'">'.__( 'the Cookie Policy', 'myagileprivacy').'</a>';

				if( $the_personal_data_policy_url )
				{
					$output_text .= ' <a class="map-genericFirstLayerLink" target="blank" href="'.esc_url( $the_personal_data_policy_url ).'">'.__( 'and the Privacy Policy', 'myagileprivacy').'</a>.';
				}
				else
				{
					$output_text .= '.';
				}
			}
			else
			{
				$output_text .= '.';
			}
		}

		return $output_text;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_fixed_text] Shortcode

The myagileprivacy_fixed_text shortcode is designed to generate a fixed text for privacy settings. It extracts attributes for text and language, checks various privacy settings, and generates a customized privacy text.

Shortcode: [myagileprivacy_fixed_text]

Parameters

Here is a list of all possible myagileprivacy_fixed_text shortcode parameters and attributes:

  • text – The text that will be displayed on the site.
  • lang – This is used to specify the language in which the text will be displayed.

Examples and Usage

Basic example – The shortcode displays the fixed text of the myagileprivacy plugin. By default, it shows the ‘cookie_policy’ text.

[myagileprivacy_fixed_text /]

Advanced examples

Displays the ‘personal_data_policy’ text by specifying the ‘text’ parameter:

[myagileprivacy_fixed_text text='personal_data_policy' /]

Displays the ‘cookie_policy’ text in a specific language by specifying the ‘lang’ parameter. In this example, we’re displaying the text in Spanish:

[myagileprivacy_fixed_text text='cookie_policy' lang='es' /]

Combining both ‘text’ and ‘lang’ parameters to display the ‘personal_data_policy’ text in French:

[myagileprivacy_fixed_text text='personal_data_policy' lang='fr' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_fixed_text] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_fixed_text', array( $this, 'myagileprivacy_fixed_text' ));

Shortcode PHP function:

                    function myagileprivacy_fixed_text( $atts )
	{
		extract( shortcode_atts(array(
			'text' => '',
			'lang' => '',
		), $atts ) );

		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );
		$rconfig = MyAgilePrivacy::get_rconfig();

		$remove_dpo_text = true;
		$remove_dpo_other_text = true;
		$remove_ccpa_text = true;
		$remove_lpd_text = true;

		if( $settings['pa'] == 1 &&
			isset( $rconfig ) && $rconfig['allow_dpo_edit'] &&
			isset( $settings['display_dpo'] ) && $settings['display_dpo'] == 1 &&
			isset( $settings['dpo_email'] ) && $settings['dpo_email'] )
		{
			$remove_dpo_text = false;

			if(
				( isset( $settings['dpo_name'] ) && $settings['dpo_name'] ) ||
				( isset( $settings['dpo_address'] ) && $settings['dpo_address'] )
			)
			{
				$remove_dpo_other_text = false;
			}
		}

		if( $settings['pa'] == 1 &&
			isset( $rconfig ) && $rconfig['allow_ccpa_text'] &&
			isset( $settings['display_ccpa'] ) && $settings['display_ccpa'] == 1 )
		{
			$remove_ccpa_text = false;
		}

		if( $settings['pa'] == 1 &&
			isset( $rconfig ) && $rconfig['allow_lpd_text'] &&
			isset( $settings['display_lpd'] ) && $settings['display_lpd'] == 1 )
		{
			$remove_lpd_text = false;
		}


		$cookies_categories_data = $this->get_cookie_categories_description( 'publish' );
		$cookie_list_html = "";
		foreach( $cookies_categories_data as $k => $v )
		{
			foreach( $v as $key => $value )
			{
				$cookie_list_html .= "<p><b>".$value['post_data']->post_title."</b><br>";
				$cookie_list_html .= $value['post_data']->post_content."</p>";
			}
		}

		if( !$text )
		{
			$text = 'cookie_policy';
		}

		if( $lang )
		{
			global $locale;
			global $sitepress;
			$is_wpml_enabled = false;
			$is_polylang_enabled = false;
			$with_multilang = false;

			if( MAP_MULTILANG_SUPPORT )
			{
				if( function_exists( 'icl_object_id' ) && $sitepress )
				{
					$is_wpml_enabled = true;
					$with_multilang = true;

					$multilang_default_lang = $sitepress->get_default_language();
					$wpml_current_lang = ICL_LANGUAGE_CODE;
					$language_list = icl_get_languages();
					$language_list_codes = array();

					//if( defined( 'MAP_DEBUGGER' ) && MAP_DEBUGGER ) MyAgilePrivacy::write_log( $multilang_default_lang );
					//if( defined( 'MAP_DEBUGGER' ) && MAP_DEBUGGER ) MyAgilePrivacy::write_log( $wpml_current_lang );

					foreach( $language_list as $k => $v )
					{
						if( isset( $v['code'] ) )
						{
							$language_list_codes[] = $v['code'];
						}
						elseif( isset( $v['language_code'] ) )
						{
							$language_list_codes[] = $v['language_code'];
						}
					}
				}

				if( defined( 'POLYLANG_FILE' ) )
				{
					$is_polylang_enabled = true;
					$with_multilang = true;

					$multilang_default_lang = pll_default_language();
					$language_list_codes = pll_languages_list();

					$polylang_current_lang = pll_current_language();

					//if( defined( 'MAP_DEBUGGER' ) && MAP_DEBUGGER ) MyAgilePrivacy::write_log( $default );
					//if( defined( 'MAP_DEBUGGER' ) && MAP_DEBUGGER ) MyAgilePrivacy::write_log( $language_list_codes );
				}
			}
		}

		if( $lang && $is_wpml_enabled )
		{
			$sitepress->switch_lang( $lang );
		}

		//check if exists
		$cc_args = array(
			'posts_per_page'   => 	-1,
			'post_type'        =>	MAP_POST_TYPE_POLICY,
			'meta_key'         => 	'_map_remote_id',
			'meta_value'       => 	$text
		);

		if( $lang && $is_polylang_enabled )
		{
			$cc_args['lang'] = $lang;
		}

		wp_reset_query();
		$cc_query = new WP_Query( $cc_args );

		//wpml language reset
		if( $lang && $is_wpml_enabled )
		{
			$sitepress->switch_lang( $wpml_current_lang );
		}

		if ( $cc_query->have_posts() )
		{
			foreach ( $cc_query->get_posts() as $p )
			{
				$the_id = $p->ID;

				//if( defined( 'MAP_DEBUGGER' ) && MAP_DEBUGGER ) MyAgilePrivacy::write_log( $the_id );

				$content = get_post_field( 'post_content', $the_id );

				if( $text == 'personal_data_policy' )
				{
					$map_option1_ack = get_post_meta( $the_id, '_map_option1_ack', true );
					$map_option1_on = get_post_meta( $the_id, '_map_option1_on', true );

					if( $settings['pa'] == 1 )
					{
						if( $map_option1_ack == 1 && $map_option1_on == 1 )
						{
							//no action
						}
						else
						{
							$content = preg_replace( '#(<li class="map_marketing_consent">).*?(</li>)#', '' , $content );
							$content = preg_replace( '#(<p class="map_marketing_consent">).*?(</p>)#', '' , $content );
						}
					}
					else
					{
						$content = preg_replace( '#(<li class="map_marketing_consent">).*?(</li>)#', '' , $content );
						$content = preg_replace( '#(<p class="map_marketing_consent">).*?(</p>)#', '' , $content );
					}

				}

				if( $remove_dpo_text )
				{
					$content = preg_replace( '#(<p class="map_dpo_text">).*?(</p>)#', '' , $content );
				}
				else
				{
					$content = str_replace( 'MAP_DPO_MAIL', $settings['dpo_email'], $content );
				}

				if( $remove_dpo_other_text )
				{
					$content = preg_replace( '#(<p class="map_dpo_other_text">).*?(</p>)#', '' , $content );
				}
				else
				{
					if( $settings['dpo_name'] )
					{
						$content = str_replace( 'MAP_DPO_NAME', $settings['dpo_name'], $content );
					}
					else
					{
						$content = str_replace( 'MAP_DPO_NAME<br>', '', $content );
					}

					if( $settings['dpo_address'] )
					{
						$content = str_replace( 'MAP_DPO_ADDRESS', $settings['dpo_address'], $content );
					}
					else
					{
						$content = str_replace( 'MAP_DPO_ADDRESS<br>', '', $content );
					}
				}

				if( $remove_ccpa_text )
				{
					$content = preg_replace( '#(<p class="map_ccpa_text">).*?(</p>)#', '' , $content );
				}
				else
				{
					//no action
				}


				if( $remove_lpd_text )
				{
					$content = preg_replace( '#(<p class="map_lpd_text">).*?(</p>)#', '' , $content );
					$content = preg_replace( '#(<span class="map_lpd_text">).*?(</span>)#', '' , $content );
				}
				else
				{
					//no action
				}


				//block_the_content_filter mode
				if(
					(
						isset( $rconfig ) &&
						isset( $rconfig['block_the_content_filter'] ) &&
						$rconfig['block_the_content_filter'] == 1
					) ||
					(
						$settings['scanner_compatibility_mode']
					)
				)
				{
					//no action
				}
				else
				{
					//add paragraphs to text
					$content = apply_filters( 'the_content', $content );
				}

				$website_name = get_site_url();

				if( isset( $settings['website_name'] ) && $settings['website_name'] != '' )
				{
					$website_name = $settings['website_name'];

					//block_the_content_filter mode
					if(
						( isset( $rconfig ) &&
						isset( $rconfig['block_the_content_filter'] ) &&
						$rconfig['block_the_content_filter'] == 1 ) ||
						(
							$settings['scanner_compatibility_mode']
						)
					)
					{
						//no action
					}
					else
					{
						//add paragraphs to text
						$website_name = apply_filters( 'the_content', $website_name );
					}
				}

				$content = str_replace( '[website_name]', $website_name, $content );
				$content = str_replace( '[identity_name]', $settings['identity_name'], $content );
				$content = str_replace( '[identity_vat_id]', ( $settings['identity_vat_id'] ) ? __( 'Vat ID', 'myagileprivacy' ).': '.$settings['identity_vat_id'] : '', $content );
				$content = str_replace( '[identity_address]', $settings['identity_address'], $content );
				$content = str_replace( '[identity_email]', $settings['identity_email'], $content );
				$content = str_replace( '[cookie_list]', $cookie_list_html, $content );

				if( $settings['wrap_shortcodes'] )
				{
					$content = '<div id="myagileprivacy_text_wrapper" class="myagileprivacy_text_wrapper">'.$content.'</div>';
				}

				return $content;
			}
		}

		wp_reset_query();
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_link] Shortcode

The MyAgilePrivacy shortcode is used to generate privacy policy links. It extracts the ‘value’ and ‘text’ attributes and fetches the corresponding settings. Depending on the ‘value’, it creates a link to the Cookie Policy or Personal Data Policy. The ‘text’ attribute customizes the link text. If not provided, default texts are used.

Shortcode: [myagileprivacy_link]

Parameters

Here is a list of all possible myagileprivacy_link shortcode parameters and attributes:

  • value – determines the type of privacy policy link to display.
  • text – allows customization of the hyperlink text.

Examples and Usage

Basic example – Utilizing the shortcode to display a link to the Cookie Policy page on your website.

[myagileprivacy_link value="cookie_policy" /]

Advanced examples

Displaying a link to the Cookie Policy page with a custom text for the hyperlink.

[myagileprivacy_link value="cookie_policy" text="View our Cookie Policy here" /]

Displaying a link to the Personal Data Policy page on your website.

[myagileprivacy_link value="personal_data_policy" /]

Displaying a link to the Personal Data Policy page with a custom text for the hyperlink.

[myagileprivacy_link value="personal_data_policy" text="Learn about our Personal Data Policy" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_link', array( $this, 'myagileprivacy_link' ));

Shortcode PHP function:

                    function myagileprivacy_link( $atts )
	{
		extract( shortcode_atts(array(
			'value' => '',
			'text' => '',
		), $atts ) );

		$defaults = MyAgilePrivacy::get_default_settings();
		$settings = wp_parse_args( MyAgilePrivacy::get_settings(), $defaults );

		if( $value == 'cookie_policy' )
		{
			$is_cookie_policy_url = $settings['is_cookie_policy_url'];
			$cookie_policy_url = $settings['cookie_policy_url'];
			$cookie_policy_page = $settings['cookie_policy_page'];

			if( !$text )
			{
				$text = "Cookie Policy";
			}

			if( $is_cookie_policy_url && $cookie_policy_url )
			{
				$the_url = $cookie_policy_url;
			}

			if( !$is_cookie_policy_url && $cookie_policy_page )
			{
				if( defined( 'POLYLANG_FILE' ) )
				{
					$the_url = get_permalink( pll_get_post( $cookie_policy_page ) );
				}
				else
				{
					$the_url = get_permalink( $cookie_policy_page );
				}
			}

			if( isset( $the_url ) )
			{
				$html = '<a href="'.esc_url( $the_url ).'" target="blank">'.esc_html( $text ).'</a>';

				return $html;
			}
		}

		if( $value == 'personal_data_policy' )
		{
			$is_personal_data_policy_url = $settings['is_personal_data_policy_url'];
			$personal_data_policy_url = $settings['personal_data_policy_url'];
			$personal_data_policy_page = $settings['personal_data_policy_page'];

			if( !$text )
			{
				$text = "Personal Data Policy";
			}

			if( $is_personal_data_policy_url && $personal_data_policy_url )
			{
				$the_url = $personal_data_policy_url;
			}

			if( !$is_personal_data_policy_url && $personal_data_policy_page )
			{
				if( defined( 'POLYLANG_FILE' ) )
				{
					$the_url = get_permalink( pll_get_post( $personal_data_policy_page ) );
				}
				else
				{
					$the_url = get_permalink( $personal_data_policy_page );
				}
			}

			if( isset( $the_url ) )
			{
				$html = '<a href="'.esc_url( $the_url ).'" target="blank">'.esc_html( $text ).'</a>';

				return $html;
			}
		}
		return;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_showconsent] Shortcode

The ‘myagileprivacy_showconsent’ shortcode from the myagileprivacy plugin is a powerful tool for user privacy management. It generates a clickable button labeled ‘Manage consent’. Upon clicking, users can modify their privacy settings, ensuring compliance with data protection regulations.

Shortcode: [myagileprivacy_showconsent]

Examples and Usage

Basic example – The following shortcode displays a button that allows users to manage their consent settings. It doesn’t require any parameters to function.

[myagileprivacy_showconsent /]

Advanced examples

While the ‘myagileprivacy_showconsent’ shortcode does not support multiple parameters, you can manipulate the behavior of the button by using JavaScript or CSS. To illustrate, you may want to add a specific CSS class to the button to style it according to your website’s theme.

<style>
.showConsentAgain {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}
</style>
[myagileprivacy_showconsent /]

Note that the above example modifies the appearance of the button globally. If you want to style the button differently in various parts of your website, you will need to use a more advanced CSS selector or JavaScript to target the specific instances of the button.

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_showconsent] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_showconsent', array( $this, 'myagileprivacy_showconsent' ));

Shortcode PHP function:

                    function myagileprivacy_showconsent( $atts )
	{
		$html = '<a role="button" href="#" class="showConsentAgain">'.__( 'Manage consent', 'myagileprivacy' ).'</a>';

		return $html;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Myagileprivacy [myagileprivacy_blocked_content_notification] Shortcode

The MyAgilePrivacy shortcode is a tool that displays a customized notification when content is blocked due to user’s cookie preferences. It uses an API key to identify the blocked content and generates a message accordingly. The notification text is customizable and it also provides a link for users to review their cookie choices. If no text is provided, a default message is displayed. This shortcode ensures transparency and user control over privacy settings.

Shortcode: [myagileprivacy_blocked_content_notification]

Parameters

Here is a list of all possible myagileprivacy_blocked_content_notification shortcode parameters and attributes:

  • api_key – Used to identify the specific API.
  • text – Allows customization of the notification message.

Examples and Usage

Basic example – A simple usage of the shortcode to display a custom notification when the content is blocked due to privacy settings. The API key is required to specify which service’s content is blocked. Here, we are using ‘google_recaptcha’ as the API key.

[myagileprivacy_blocked_content_notification api_key='google_recaptcha' /]

Advanced examples

Customizing the notification text. In this example, we are using the shortcode to display a custom notification when the content is blocked. We are defining the API key as ‘google_recaptcha’ and also providing a custom text to be displayed when the content is blocked.

[myagileprivacy_blocked_content_notification api_key='google_recaptcha' text='Your content is blocked due to your privacy settings. Please review your settings.' /]

Using the shortcode without specifying the API key. In this case, the shortcode will not display any notification as the API key is not provided. This can be used when you want to conditionally display the notification based on certain conditions.

[myagileprivacy_blocked_content_notification /]

PHP Function Code

In case you have difficulties debugging what causing issues with [myagileprivacy_blocked_content_notification] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'myagileprivacy_blocked_content_notification', array( $this, 'myagileprivacy_blocked_content_notification' ));

Shortcode PHP function:

                    function myagileprivacy_blocked_content_notification( $atts )
	{
		extract( shortcode_atts(array(
			'api_key' => '',
			'text' => '',
		), $atts ) );

		if( $api_key )
		{
			if( !$text )
			{
				switch( $api_key )
				{
					case 'google_recaptcha':
						$text = __( 'Your cookie choices may not allow the form to be submitted. You can review your choices by <a role="button" href="#" class="showConsentAgain">clicking here</a>.', 'myagileprivacy' );
						break;
				}
			}

			$html = '<p class="map_custom_notify map_api_key_'.esc_attr( $api_key ).'">'.esc_html( $text ).'</p>';

			return wp_kses( $html, MyAgilePrivacy::allowed_html_tags() );;
		}

		return;
	}
                    

Code file location:

myagileprivacy/myagileprivacy/frontend/my-agile-privacy-frontend.php

Conclusion

Now that you’ve learned how to embed the Myagileprivacy Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *