From 2c752912c5b3ae97378f72579aa7c50a4b324622 Mon Sep 17 00:00:00 2001 From: lesion Date: Mon, 17 Jan 2022 12:03:54 +0100 Subject: [PATCH] add webcomponent / shortcode and allow gancio-event[s] tag to wordpress plugin --- wp-plugin/gancio.php | 2 +- wp-plugin/wc.php | 65 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 wp-plugin/wc.php diff --git a/wp-plugin/gancio.php b/wp-plugin/gancio.php index 60ea1e42..9a5e79d3 100644 --- a/wp-plugin/gancio.php +++ b/wp-plugin/gancio.php @@ -21,7 +21,7 @@ along with (WPGancio). If not, see (https://www.gnu.org/licenses/agpl-3.0.html). defined( 'ABSPATH' ) or die( 'Nope, not accessing this' ); require_once('settings.php'); - +require_once('wc.php'); require_once('oauth.php'); diff --git a/wp-plugin/wc.php b/wp-plugin/wc.php new file mode 100644 index 00000000..c326df63 --- /dev/null +++ b/wp-plugin/wc.php @@ -0,0 +1,65 @@ + true, 'places' => true, 'theme' => true, 'id' => true, 'baseurl' => true); + $the_allowed_tags['gancio-event'] = array('id' => true, 'url' => true); + return $the_allowed_tags; +} +add_filter('wp_kses_allowed_html', 'add_gancio_events_to_kses_allowed', 10, 1); + +function tinymce_init( $init ) { + $ext = 'gancio-event[id,url],gancio-events[baseurl,places,tags,theme,max]'; + if ( isset( $init['extended_valid_elements'] ) ) { + $init['extended_valid_elements'] .= ',' . $ext; + } else { + $init['extended_valid_elements'] = $ext; + } + return $init; +} +add_filter('tiny_mce_before_init', 'tinymce_init'); + +/** ADD SHORTCODES */ +function gancio_event_handler_function( $atts, $content, $tag) { + var_dump('asdfaoisdfo iajsdofij'); + $a = shortcode_atts( array( + 'baseurl' => 'https://demo.gancio.org', + 'id' => 0 + ), $atts); + return ''; +}; + +function gancio_events_handler_function( $atts, $content, $tag) { + $a = shortcode_atts( array( + 'baseurl' => 'https://demo.gancio.org', + 'places' => '', + 'tags' => '', + 'theme' => 'dark', + 'max' => NULL + ), $atts); + return ''; +}; + +add_action( 'init', function () { + global $allowedposttags; + $allowedposttags['gancio-event'] = array( + 'id' => array(), + 'baseurl' => array(), + 'theme' => array() + ); + add_shortcode('gancio-event', 'gancio_event_handler_function'); + add_shortcode('gancio-events', 'gancio_events_handler_function'); +}); + + +/** ADD WEB COMPONENT SCRIPT */ +add_action('wp_enqueue_scripts', 'add_gancio_custom_js'); +function add_gancio_custom_js() { + wp_enqueue_script('gancio-wc', plugins_url('/js/gancio-events.es.js', __FILE__)); +} +