-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproca.php
58 lines (52 loc) · 1.82 KB
/
proca.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* Proca: Progressive Campaigning
*
* @package Proca
* @author Xavier Dutoit
* @copyright 2020 Proca.foundation
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Proca: progressive campaigning
* Plugin URI: https://github.com/TechToThePeople/proca-wordpress
* Description: Add a petition signature form to your website
* Version: 1.0.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Proca foundation
* Author URI: https://proca.foundation
* Text Domain: plugin-slug
* License: GPL v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
add_shortcode('proca', 'proca_widget');
add_action( 'init', 'proca_register_block' );
function proca_register_block() {
// automatically load dependencies and version
$asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php');
wp_register_script(
'proca_block',
plugins_url( 'build/index.js', __FILE__ ),
$asset_file['dependencies'],
$asset_file['version']
);
register_block_type( 'proca/action', array(
'editor_script' => 'proca_block',
) );
}
function proca_widget( $atts = [], $content = null) {
$params ="";
$errors ="";
$url = "https://widget.proca.foundation/d/";
$attributes = shortcode_atts(array('action' => 'demo','debug' => false),$atts,'proca');
$url .= urlencode($attributes['action']);
if ($attributes['debug']) {
$url = "http://localhost:3000/static/js/bundle.js";
}
unset($atts['action']);
unset($atts['debug']);
foreach ($atts as $key => $value)
$params .= "data-".$key.'="'.$value.'"';
return '<div class="proca-widget" '.$params.'>Loading...</div><script id="proca" src="'.$url.'" '. $params . '></script>';
}