Changeset 3103735
- Timestamp:
- 06/17/2024 07:51:01 PM (19 months ago)
- Location:
- hello-event/trunk
- Files:
-
- 2 added
- 3 edited
-
hello_event.php (modified) (14 diffs)
-
includes/hello-event-list-events.php (modified) (11 diffs)
-
languages/hello-event-nl_NL.mo (added)
-
languages/hello-event-nl_NL.po (added)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hello-event/trunk/hello_event.php
r3103734 r3103735 38 38 */ 39 39 40 // STILL NEED TO FIX: Backlink to event if custom event page!!! 41 // IDEA: Set this in the settings rather that as a parameter to the short code for listing events. 42 40 43 namespace Tekomatik\HelloEvent; 41 44 … … 109 112 add_shortcode('hello-id-of-event', array($this, 'id_of_event')); 110 113 add_shortcode('hello-link-to-event', array($this, 'link_to_event')); 114 add_shortcode('hello-title', array($this, 'event_title')); 115 add_shortcode('hello-thumbnail', array($this, 'event_thumbnail')); 111 116 add_shortcode('hello-start-date', array($this, 'event_start_date')); 112 117 add_shortcode('hello-start-time', array($this, 'event_start_time')); … … 116 121 add_shortcode('hello-end-date-and-time', array($this, 'event_end_date_and_time')); 117 122 add_shortcode('hello-location', array($this, 'event_location')); 123 add_shortcode('hello-content', array($this, 'event_content')); 124 add_shortcode('hello-excerpt', array($this, 'event_excerpt')); 125 118 126 119 127 // Make sure we have the necessary product category for WooCommerce … … 1292 1300 // ================== Shortcode handlers ========================================================= 1293 1301 // 1294 public function link_to_ticket ($args) {1302 public function link_to_ticket_OLD($args) { 1295 1303 // If the current post is an event and there are slots for sale, then return a link 1296 1304 // Process shortcode hello_event_link_to_ticket … … 1298 1306 global $post; 1299 1307 $html = ''; 1300 $html .= '<div style="border:1px solid red; color: orange; padding: 8px">DEBUG OUTPUT:<br/>';1301 1308 if ( $post->post_type == Hello_Event::EVENT_SLUG ) { 1302 $html .= "Post type correct. ID: ".get_the_ID()."<br/>";1303 1309 $a = shortcode_atts( array( 1304 1310 'text' => __("Tickets to participate are available in our shop", 'hello-event'), 1305 1311 ), $args ); 1306 $html .= $this->test_get_link_to_product(get_the_ID(), true) . '</div>';1307 1312 list($link, $rc) = $this->get_link_to_product(get_the_ID(), true); 1308 1313 if ($link) { 1309 1314 $html .= '<a href="'. $link . '">' . $a['text'] . '</a>'; 1310 1315 $html = apply_filters('hello_event_display_link_to_ticket', $html, get_the_ID(), $link); 1316 // Don't know why at some point we had a fourth parameter here 1317 // $html = apply_filters('hello_event_display_link_to_ticket', $html, get_the_ID(), $link, 'shortcode'); 1318 return $html . '</div>'; 1319 } 1320 else { return $html . $this->debug_msg(__("Tickets not fully configured", 'hello-event') . ". ". 1321 $this->ticket_config_error($rc)); } 1322 } 1323 else { return $html . $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1324 } 1325 1326 public function link_to_ticket($args) { 1327 // If the current post is an event and there are slots for sale, then return a link 1328 // Process shortcode hello_event_link_to_ticket 1329 $args = shortcode_atts( array( 1330 'id' => get_the_ID(), 1331 'text' => __("Tickets to participate are available in our shop", 'hello-event'), ), $args ); 1332 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1333 $id = $args['id']; 1334 $html = ''; 1335 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1336 list($link, $rc) = $this->get_link_to_product($args['id'], true); 1337 if ($link) { 1338 $html .= '<a href="'. $link . '">' . $args['text'] . '</a>'; 1339 $html = apply_filters('hello_event_display_link_to_ticket', $html, $args['id'], $link); 1311 1340 // Don't know why at some point we had a fourth parameter here 1312 1341 // $html = apply_filters('hello_event_display_link_to_ticket', $html, get_the_ID(), $link, 'shortcode'); … … 1401 1430 $args = shortcode_atts( array( 1402 1431 'id' => get_the_ID(), 1432 'format' => false, 1403 1433 ), $args ); 1434 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1404 1435 $id = $args['id']; 1405 1436 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1406 $html = $this->transform_iso_date(get_post_meta($id, 'start_date', true)); 1437 if ($args['format'] == 'iso') 1438 $html = get_post_meta($id, 'start_date', true); 1439 else 1440 $html = $this->transform_iso_date(get_post_meta($id, 'start_date', true)); 1407 1441 return $html; 1408 1442 } 1409 1443 else { return $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1410 1444 } 1445 1446 public function event_title($args) { 1447 $args = shortcode_atts( array( 1448 'id' => get_the_ID(), 1449 ), $args ); 1450 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1451 $id = $args['id']; 1452 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1453 return get_the_title($id); 1454 } 1455 else { return $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1456 } 1457 1458 public function event_thumbnail($args) { 1459 $args = shortcode_atts( array( 1460 'id' => get_the_ID(), 1461 ), $args ); 1462 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1463 $id = $args['id']; 1464 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1465 return get_the_post_thumbnail($id); 1466 } 1467 else { return $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1468 } 1469 1470 1471 public function event_content($args){ 1472 $args = shortcode_atts( array( 1473 'id' => get_the_ID(), 1474 ), $args ); 1475 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1476 $id = $args['id']; 1477 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1478 $html = get_post_field('post_content', $id); 1479 return $html; 1480 } 1481 else { return $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1482 } 1483 1484 public function event_excerpt($args){ 1485 $args = shortcode_atts( array( 1486 'id' => get_the_ID(), 1487 ), $args ); 1488 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1489 $id = $args['id']; 1490 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1491 $html = $this->real_or_computed_excerpt($id); 1492 return $html; 1493 } 1494 else { return $this->debug_msg(__("Shortcode can only be used when displaying events", 'hello-event')); } 1495 } 1496 1411 1497 1412 1498 public function event_start_time($args){ … … 1414 1500 'id' => get_the_ID(), 1415 1501 ), $args ); 1502 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1416 1503 $id = $args['id']; 1417 1504 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { … … 1434 1521 'id' => get_the_ID(), 1435 1522 ), $args ); 1523 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1436 1524 $id = $args['id']; 1437 1525 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { … … 1452 1540 'id' => get_the_ID(), 1453 1541 ), $args ); 1542 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1454 1543 $id = $args['id']; 1455 1544 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { … … 1470 1559 $args = shortcode_atts( array( 1471 1560 'id' => get_the_ID(), 1561 'format' => false, 1472 1562 ), $args ); 1563 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1473 1564 $id = $args['id']; 1474 1565 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { 1475 $html = $this->transform_iso_date(get_post_meta($id, 'end_date', true)); 1566 if ($args['format'] == 'iso') 1567 $html = get_post_meta($id, 'end_date', true); 1568 else 1569 $html = $this->transform_iso_date(get_post_meta($id, 'end_date', true)); 1476 1570 return $html; 1477 1571 } … … 1483 1577 'id' => get_the_ID(), 1484 1578 ), $args ); 1579 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1485 1580 $id = $args['id']; 1486 1581 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { … … 1495 1590 'id' => get_the_ID(), 1496 1591 ), $args ); 1592 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1497 1593 $id = $args['id']; 1498 1594 if (get_post_type($id) == Hello_Event::EVENT_SLUG) { … … 1507 1603 'id' => get_the_ID(), 1508 1604 ), $args ); 1605 $args['id'] = isset($_GET['event_id']) ? $_GET['event_id'] : $args['id']; 1509 1606 $id = $args['id']; 1510 1607 $btn_txt = __('Add to Calendar', 'hello-event'); … … 1681 1778 get_option( 'hello_event')['hello_field_autolink_to_product']=="on" ) { 1682 1779 list($link, $rc) = $this->get_link_to_product($post_id, true); 1780 if ($rc > 0) { 1781 $before .= $this->debug_msg(__("Tickets not fully configured", 'hello_event') . ". ". 1782 $this->ticket_config_error($rc)); 1783 } 1683 1784 if ($link) { 1684 1785 if ( isset(get_option( 'hello_event')['hello_field_ticket_visibility']) && 1685 1786 get_option( 'hello_event')['hello_field_ticket_visibility']=="on" && 1686 $this->event_end_date([ ]) < date("Y-m-d")) {1787 $this->event_end_date(['format' => 'iso']) < date("Y-m-d")) { 1687 1788 // Don't show any link to the ticket for past event 1688 1789 } -
hello-event/trunk/includes/hello-event-list-events.php
r2946985 r3103735 31 31 } 32 32 33 // =========================== Helpers ================================ 34 function permalink_by_slug($slug) { 35 $args = array( 36 'post_type' => 'page', 37 'name' => $slug, 38 'posts_per_page' => 1 39 ); 40 $pages = get_posts($args); 41 if ($pages) 42 return get_permalink($pages[0]); 43 else 44 return false; 45 // $query = new \WP_Query( $args ); 46 // if( $query->have_posts() ) { 47 // $query->the_post(); 48 // $permalink = get_permalink( get_the_ID() ); 49 // } 50 // wp_reset_postdata(); 51 // return $permalink; 52 } 53 54 55 function link_to_event_page($permalink, $event_id, $custom_page_slug) { 56 // If custom page is false the link returned = $permalink 57 // Otherwise the link is to the link returned = custom page URL with event id as parameter 58 if (!$custom_page_slug) 59 return $permalink; 60 $url = $this->permalink_by_slug($custom_page_slug); 61 if ($url) 62 return add_query_arg('event_id',$event_id, $url); 63 else 64 return $permalink; 65 } 66 33 67 function handle_shortcode_event_list($args0) { 34 68 $args = shortcode_atts( array( … … 38 72 'width' => false, // Optionally Used in widget show 39 73 'link_to_book' => false, // Do we want to display a "Book Now" button? 40 'language' => false, // Can be used in date presentations74 // 'language' => false, // Can be used in date presentations 41 75 'thumbnail' => "", // can be 'square', 'round' or both (sepaated by space) 76 'event_page' => false, // can be set to the slug of a custom page to show the events 42 77 43 78 ), $args0 ); … … 187 222 </div> 188 223 "; 189 224 190 225 switch ($args['show']) { 191 226 case 'minimal' : … … 193 228 $html .= ' <div class="start-date">'.$start_date.'</div>'; 194 229 $html .= ' <div class="event-title">'; 195 $html .= ' <a href="'. get_the_permalink().'" rel="bookmark" title="Permanent Link to '.get_the_title().'">';230 $html .= ' <a href="'.$this->link_to_event_page(get_the_permalink(), $id, $args['event_page']).'" rel="bookmark" title="Permanent Link to '.get_the_title().'">'; 196 231 $html .= get_the_title().'</a>'; 197 232 $html .= ' </div>'; … … 210 245 case 'gallery' : // xxx 211 246 $g_start_date = $start_date; 212 if ($args['language'] == "french") {213 $g_start_date = new \DateTime($start_date);214 $g_start_date = $g_start_date->format("d/m Y");215 }247 // if (false && $args['language'] == "french") { 248 // $g_start_date = new \DateTime($start_date); 249 // $g_start_date = $g_start_date->format("d/m Y"); 250 // } 216 251 $g_dates = '<i class="far fa-calendar"></i> ' . $g_start_date .'<br/>'; 217 252 $g_times = '<i class="far fa-clock"></i> ' . $start_time .'<br/>'; … … 232 267 $g_title = " 233 268 <div class='title'> 234 <a href='". get_the_permalink()."'269 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 235 270 rel='bookmark' 236 271 title='Permalink to ".get_the_title()."'>".get_the_title()." 237 272 </a> 238 273 </div>"; 274 275 276 239 277 $html .= " 240 278 <div class='hello-event style1 list gallery " . $event_type_class ."'> … … 260 298 <div class='description'> 261 299 <div class='title'> 262 <a href='". get_the_permalink()."'300 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 263 301 rel='bookmark' 264 302 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 286 324 </div> 287 325 <div class='title'> 288 <a href='". get_the_permalink()."'326 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 289 327 rel='bookmark' 290 328 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 314 352 <div class='intro'> 315 353 <div class='title'> 316 <a href='". get_the_permalink()."'354 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 317 355 rel='bookmark' 318 356 title='Permalink to ".get_the_title()."'>".get_the_title()." 319 357 </a> 320 358 </div> 359 321 360 <div class='thumbnail ".$args['thumbnail']."'>" . get_the_post_thumbnail($id, 'hello-event-widget-image') . "</div> 322 361 </div> … … 342 381 </div> 343 382 <div class='title'> 344 <a href='". get_the_permalink()."'383 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 345 384 rel='bookmark' 346 385 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 388 427 </div> 389 428 <div class='title'> 390 <a href='". get_the_permalink()."'429 <a href='".$this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 391 430 rel='bookmark' 392 431 title='Permalink to ".get_the_title()."'>".get_the_title()." -
hello-event/trunk/readme.txt
r3103734 r3103735 75 75 = 1.3.14 76 76 * More debug info when debug setting is switched on in the settings 77 * Added Dutch language - courtesy of Wim De Kelver 78 * Removed language parameter from shortcodes. This parameter only impacted how dates are shown, but this is already handled in the plugin settings 79 * Bug correction: when settings are positioned to use other date format than ISO (yyyy-mm-dd) the test to show the link to an event ticket only for future events failed. Has been corrected 77 80 = 1.3.13 78 81 * Better info about Demo site on Wordpress.org
Note: See TracChangeset
for help on using the changeset viewer.