├── .gitattributes ├── consent-api-example-plugin.php ├── main.js ├── main.min.js └── readme.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /consent-api-example-plugin.php: -------------------------------------------------------------------------------- 1 | 'Version' ), false ); 15 | define( 'CONSENT_API_EXAMPLE_PLUGIN_VERSION', $plugin_data['Version'] );$plugin = plugin_basename(__FILE__); 16 | 17 | /** 18 | * Tell the consent API we're following the api 19 | */ 20 | add_filter("wp_consent_api_registered_$plugin", function(){return true;}); 21 | 22 | add_action( 'wp_enqueue_scripts', 'example_plugin_enqueue_assets' ); 23 | function example_plugin_enqueue_assets( $hook ) { 24 | wp_enqueue_script( 'example-plugin', plugin_dir_url(__FILE__) . "main.js", array('jquery'), CONSENT_API_EXAMPLE_PLUGIN_VERSION, true ); 25 | } 26 | 27 | add_shortcode('example-plugin-shortcode', 'example_plugin_load_document'); 28 | function example_plugin_load_document($atts = [], $content = null, $tag = '') 29 | { 30 | $atts = array_change_key_case((array)$atts, CASE_LOWER); 31 | ob_start(); 32 | 33 | // override default attributes with user attributes 34 | $atts = shortcode_atts(array('category' => 'marketing'), $atts, $tag); 35 | //default 36 | $category = 'marketing'; 37 | if (function_exists('wp_validate_consent_category')){ 38 | $category = wp_validate_consent_category($atts['category']); 39 | } 40 | 41 | ?> 42 |