Skip to content

Commit

Permalink
#1 Added Multi-Event Capability
Browse files Browse the repository at this point in the history
  • Loading branch information
jfwiebe committed Nov 8, 2017
1 parent 139aff6 commit 6b492bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ git clone https://github.com/jfwiebe/pretix-wp-plugin.git
Second, enable the `Wordpress Pretix Integration` plugin, which can now be found in your WordPress Admin Panel. Now, under "Settings -> Pretix Settings", set up the URLs of your pretix installation:
+ **CSS File Link** is the link to the CSS file, e.g. `https://pretixdemo.com/demo/democon/widget/v1.css`
+ **JS File Link** is the link to the JS file, e.g. `https://pretixdemo.com/widget/v1.en.js`
+ **Event Link** is the link to the events ticketshop, e.g. `https://pretixdemo.com/demo/democon/`

Of course, you have to adjust the URLs to your installation. The urls can be found in the code snippet that pretix generates on the "Widget" tab in your event's settings.

Third, insert the ticketshop somewhere on your page by typing `[pretix-widget]` into an article. The plugin will replace the placeholder with the ticketshop.
Third, insert the ticketshop somewhere on your page by typing `[pretix-widget eventurl="https://pretixdemo.com/demo/democon/"]` into an article. The plugin will replace the placeholder with the ticketshop.

# Contributing
Feel free to contribute improvements, bug-reports or bugfixes by creating an issue and/or a pull-request. If you have any further questions, please do not hesitate to ask!
Expand Down
16 changes: 7 additions & 9 deletions pretix-wp-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ function pretix_css() {
function pretix_admin_init() {
register_setting( 'pretix-settings-group', 'css-file-link' );
register_setting( 'pretix-settings-group', 'js-file-link' );
register_setting( 'pretix-settings-group', 'event-link' );
add_settings_section( 'url-section', 'General Config', 'general_config_callback', 'pretix-plugin' );
add_settings_field( 'css-file-link', 'CSS File Link', 'css_file_callback', 'pretix-plugin', 'url-section' );
add_settings_field( 'js-file-link', 'JS File Link', 'js_file_callback', 'pretix-plugin', 'url-section' );
add_settings_field( 'event-link', 'Event Link', 'event_callback', 'pretix-plugin', 'url-section' );
}

function general_config_callback() {
Expand All @@ -46,10 +44,6 @@ function js_file_callback() {
$setting = esc_attr( get_option( 'js-file-link' ) );
echo "<input type='text' name='js-file-link' value='$setting' />";
}
function event_callback() {
$setting = esc_attr( get_option( 'event-link' ) );
echo "<input type='text' name='event-link' value='$setting' />";
}

// Add Admin Interface

Expand All @@ -74,12 +68,16 @@ function pretix_options_page() {

// Use "pretix-widget" shortcode to be replaced by the widget code

function pretix_widget() {
return '<pretix-widget event="'. esc_attr( get_option('event-link') ) .'"></pretix-widget>
function pretix_widget($atts = [], $content = null, $tag = '') {
// handle tags
$atts = array_change_key_case((array)$atts, CASE_LOWER);
$pretix_atts = shortcode_atts(['eventurl' => 'https://pretix.eu/demo/democon/'], $atts, $tag);

return '<pretix-widget event="'. $pretix_atts['eventurl'] .'"></pretix-widget>
<noscript>
<div class="pretix-widget">
<div class="pretix-widget-info-message">
JavaScript is disabled. Please head over to our ticketing system <a target="_blank" href="'. esc_attr( get_option( 'event-link' ) ) .'">to buy a ticket</a>.
JavaScript is disabled. Please head over to our ticketing system <a target="_blank" href="'. $pretix_atts['eventurl'] .'">to buy a ticket</a>.
</div>
</div>
</noscript>';
Expand Down

0 comments on commit 6b492bd

Please sign in to comment.