Commit 3e1f3c89 authored by Antonio's avatar Antonio 🇪🇺

event tinymce and more fields

parent 2bffc608
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -280,6 +280,8 @@ class StructuredContent_Shortcodes {
static public function event( $atts, $content = null ) {
var_dump($atts);
$merged_atts = shortcode_atts(
array(
'css_class' => '',
......@@ -290,20 +292,25 @@ class StructuredContent_Shortcodes {
if ( $merged_atts['elements'] === '' ) {
$single_atts = shortcode_atts(
[
'html' => 'true',
'title' => '',
'description' => $content,
'start_date' => '',
'end_date' => '',
'event_location' => '',
'street_address' => '',
'address_locality' => '',
'address_region' => '',
'postal_code' => '',
'address_country' => '',
'currency_code' => '',
'price' => '',
'image_id' => '',
'html' => 'true',
'title' => '',
'description' => $content,
'start_date' => '',
'end_date' => '',
'event_location' => '',
'street_address' => '',
'address_locality' => '',
'address_region' => '',
'postal_code' => '',
'address_country' => '',
'currency_code' => '',
'price' => '',
'image_id' => '',
'performer' => '',
'performer_name' => '',
'offer_availability' => '',
'offer_url' => '',
'offer_valid_from' => '',
], $atts
);
$single_atts['visible'] = $single_atts['html'] === 'true' ? true : false;
......
......@@ -116,7 +116,56 @@ foreach ( $atts['elements'] as $element ) {
</div>
</div>
</div>
<?php if ( $element['currency_code'] && $element['price'] ) : ?>
</div>
</div>
<div class="sc_row w-100">
<?php if ( $element['currency_code'] && $element['price'] && $element['offer_valid_from'] && $element['offer_availability'] && $element['offer_url'] ) : ?>
<div class="sc_grey-box">
<div class="sc_box-label">
<?php echo __( 'PERFORMER', 'structured-content' ) ?>
</div>
<div class="sc_input-group">
<div class="sc_input-label">
<?php echo __( 'Type', 'structured-content' ) ?>
</div>
<div class="wp-block-structured-content-event__offer_availability">
<?php echo $element['performer'] ?>
</div>
</div>
<div class="sc_input-group">
<div class="sc_input-label">
<?php echo __( 'Name', 'structured-content' ) ?>
</div>
<div class="wp-block-structured-content-event__offer_url">
<?php echo $element['performer_name'] ?>
</div>
</div>
</div>
<?php endif; ?>
<?php if ( $element['currency_code'] && $element['price'] && $element['offer_valid_from'] && $element['offer_availability'] && $element['offer_url'] ) : ?>
<div class="sc_grey-box">
<div class="sc_box-label">
<?php echo __( 'Offer', 'structured-content' ) ?>
</div>
<div class="sc_row">
<div class="sc_input-group">
<div class="sc_input-label">
<?php echo __( 'Availability', 'structured-content' ) ?>
</div>
<div class="wp-block-structured-content-event__offer_availability">
<?php echo $element['offer_availability'] ?>
</div>
</div>
<div class="sc_input-group">
<div class="sc_input-label">
<?php echo __( 'Ticket Website', 'structured-content' ) ?>
</div>
<div class="wp-block-structured-content-event__offer_url">
<a href="<?php echo $element['offer_url'] ?>"><?php echo $element['offer_url'] ?></a>
</div>
</div>
</div>
<div class="sc_row">
<div class="sc_input-group">
<div class="sc_input-label">
......@@ -135,8 +184,16 @@ foreach ( $atts['elements'] as $element ) {
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="sc_input-group">
<div class="sc_input-label">
<?php echo __( 'Valid From', 'structured-content' ) ?>
</div>
<div class="wp-block-structured-content-event__valid_from">
<?php echo date( 'd.m.Y h:i', strtotime( $element['offer_valid_from'] ) ); ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
</section>
<?php endif;
......@@ -164,14 +221,30 @@ foreach ( $atts['elements'] as $element ) { ?>
<?php if ( ! empty( $element['image_id'] ) ): ?>
"image" : ["<?php echo wp_get_attachment_url( $element['image_id'] ) ?>"],
<?php endif; ?>
<?php if ( $element['currency_code'] && $element['price'] ) : ?>
<?php if ( $element['currency_code'] && $element['price'] && $element['offer_valid_from'] && $element['offer_availability'] && $element['offer_url'] ) : ?>
"offers": {
"@type": "Offer",
"url": "<?php echo $element['offer_url'] ?>",
"price": "<?php echo number_format( $element['price'], 2, '.', '' ) ?>",
"priceCurrency": "<?php echo $element['currency_code'] ?>"
"priceCurrency": "<?php echo $element['currency_code'] ?>",
"availability": "https://schema.org/<?php echo $element['offer_availability'] ?>",
"validFrom": "<?php echo $element['offer_valid_from'] ?>"
},
<?php endif; ?>
"description": "<?php echo str_replace( '"', '\"', $element['description']); ?>"
<?php if ( $element['performer_name'] && $element['performer'] ) : ?>
"performer": {
"@type": "<?php echo $element['performer'] ?>",
"name": "<?php echo $element['performer_name'] ?>"
},
<?php endif; ?>
"description": "<?php echo str_replace( '"', '\"', $element['description'] ); ?>"
}
</script>
<?php } ?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
......@@ -62,3 +62,8 @@ jQuery(document).ready(function ($) {
customUploader.open();
}
});
window.datetimeLocalSupported = function () {
let input = document.createElement( 'input' );
input.setAttribute( 'type', 'datetime-local' );
return input.type === 'datetime-local';
};
\ No newline at end of file
export default function ( editor ) {
export default function (editor) {
let postfixDateLabel;
let minWidth = 500;
if ( !datetimeLocalSupported() ) {
postfixDateLabel = '(Format: 2019-08-22T10:25)';
minWidth = 800;
if (!datetimeLocalSupported()) {
postfixDateLabel = '(Format: 2019-08-22T10:25)';
minWidth = 800;
}
return {
text : 'Event',
tooltip: 'Adds a Event block to the page.',
onclick: () => {
editor.windowManager.open( {
editor.windowManager.open({
title : 'Featured Snippet Event',
minWidth : minWidth,
height : 500,
......@@ -27,12 +27,12 @@ export default function ( editor ) {
name : 'titleTag',
label : 'Headline-Tag',
values: [
{ text: 'h2', value: 'h2' },
{ text: 'h3', value: 'h3' },
{ text: 'h4', value: 'h4' },
{ text: 'h5', value: 'h5' },
{ text: 'h6', value: 'h6' },
{ text: 'p', value: 'p' },
{text: 'h2', value: 'h2'},
{text: 'h3', value: 'h3'},
{text: 'h4', value: 'h4'},
{text: 'h5', value: 'h5'},
{text: 'h6', value: 'h6'},
{text: 'p', value: 'p'},
],
value : 'h2', // Sets the default
},
......@@ -53,6 +53,20 @@ export default function ( editor ) {
multiline : true,
minHeight : 100,
},
{
type : 'textbox',
name : 'image_id',
label : 'Image',
value : '',
classes: 'image',
},
{
type : 'button',
name : 'select_image',
label : ' ',
text : 'Select Image',
classes: 'select_image',
}, // new stuff!
{
type : 'container',
name : 'container',
......@@ -120,6 +134,78 @@ export default function ( editor ) {
value : '',
placeholder: 'CA',
},
{
type : 'container',
name : 'container',
label: '',
html : '<h1 style="font-weight: bold;">Performer</h1>'
},
{
type : 'listbox',
name : 'performer',
label : 'Performer Type',
values: [
{text: 'Person', value: 'PerformingGroup'},
{text: 'PerformingGroup', value: 'Person'}
]
},
{
type : 'textbox',
name : 'performerName',
label : 'Performer',
value : '',
placeholder: 'John Doe',
},
{
type : 'container',
name : 'container',
label: '',
html : '<h1 style="font-weight: bold;">Offer</h1>'
},
{
type : 'listbox',
name : 'offerAvailability',
label : 'Availability',
values: [
{text: 'In Stock', value: 'InStock'},
{text: 'Sold Out', value: 'SoldOut'},
{text: 'Pre Order', value: 'PreOrder'}
]
},
{
type : 'textbox',
name : 'offerUrl',
label : 'Ticket Website',
value : '',
placeholder: 'https://your-website.com',
multiline : false,
},
{
type : 'textbox',
name : 'currencyCode',
label : 'Currency ISO Code',
value : '',
placeholder: 'USD',
},
{
type : 'textbox',
name : 'price',
label : 'Price',
value : '',
placeholder: '40.00',
},
{
type : 'textbox',
name : 'offerValidFrom',
label : 'Valid From',
classes: 'sc_valid_from',
},
{
type : 'container',
name : 'container',
label: '',
html : '<h1 style="font-weight: bold;">Additional</h1>'
},
{
type : 'textbox',
name : 'cssClass',
......@@ -130,33 +216,38 @@ export default function ( editor ) {
onsubmit : e => {
editor.insertContent(
`[sc_fs_event
html="${ e.data.giveHTML }"
title="${ e.data.title }"
title_tag="${ e.data.titleTag }"
event_location="${ e.data.eventLocation }"
start_date="${ e.data.startDate }"
end_date="${ e.data.endDate }"
street_address="${ e.data.streetAddress }"
address_locality="${ e.data.addressLocality }"
address_region="${ e.data.addressRegion }"
postal_code="${ e.data.postalCode }"
address_country="${ e.data.addressCountry }"
css_class="${ e.data.cssClass }"
html="${e.data.giveHTML}"
title="${e.data.title}"
title_tag="${e.data.titleTag}"
event_location="${e.data.eventLocation}"
start_date="${e.data.startDate}"
end_date="${e.data.endDate}"
street_address="${e.data.streetAddress}"
address_locality="${e.data.addressLocality}"
address_region="${e.data.addressRegion}"
postal_code="${e.data.postalCode}"
address_country="${e.data.addressCountry}"
image_id="${e.data.image_id}"
performer="${e.data.performer}"
performer_name="${e.data.performerName}"
offer_availability="${e.data.offerAvailability}"
offer_url="${e.data.offerUrl}"
currency_code="${e.data.currencyCode}"
price="${e.data.price}"
offer_valid_from="${e.data.offerValidFrom}"
css_class="${e.data.cssClass}"
]
${ e.data.description }
${e.data.description}
[/sc_fs_event]`
);
},
} );
if ( datetimeLocalSupported() ) {
$( '.mce-sc_start_date' ).prop( 'type', 'datetime-local' );
$( '.mce-sc_end_date' ).prop( 'type', 'datetime-local' );
}
,
});
if (datetimeLocalSupported()) {
$('.mce-sc_start_date').prop('type', 'datetime-local');
$('.mce-sc_end_date').prop('type', 'datetime-local');
$('.mce-sc_valid_from').prop('type', 'datetime-local');
}
},
}
};
window.datetimeLocalSupported = function () {
let input = document.createElement( 'input' );
input.setAttribute( 'type', 'datetime-local' );
return input.type === 'datetime-local';
};
\ No newline at end of file
......@@ -47,7 +47,6 @@ export default function ( editor ) {
multiline : true,
minHeight : 100,
},
{
type : 'textbox',
name : 'sc_img',
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment