Changeset 3103736
- Timestamp:
- 06/17/2024 07:51:13 PM (19 months ago)
- Location:
- hello-event/trunk
- Files:
-
- 4 edited
-
hello_event.php (modified) (4 diffs)
-
includes/hello-event-list-events.php (modified) (8 diffs)
-
includes/hello-event-settings.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
hello-event/trunk/hello_event.php
r3103735 r3103736 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 41 namespace Tekomatik\HelloEvent; … … 656 654 } 657 655 656 // =========================== Helpers ================================ 657 function permalink_by_slug($slug) { 658 $args = array( 659 'post_type' => 'page', 660 'name' => $slug, 661 'posts_per_page' => 1 662 ); 663 $pages = get_posts($args); 664 if ($pages) 665 return get_permalink($pages[0]); 666 else 667 return false; 668 } 669 670 671 function link_to_event_page($permalink, $event_id, $custom_page_slug) { 672 // A custom page slug can be given as parameter. 673 // If not defined or empty we will look in the settings for a custom page slug 674 // If a custom page slug is found and the page exists the link returned = custom page URL with event id as parameter 675 // Otherwise the $permalink is returned 676 if (isset(get_option( 'hello_event')['hello_field_custom_event_page'])) 677 $custom_page_in_settings = get_option( 'hello_event')['hello_field_custom_event_page']; 678 $custom_page_slug = $custom_page_slug ? $custom_page_slug : $custom_page_in_settings; 679 if (!$custom_page_slug) 680 return $permalink; 681 $url = $this->permalink_by_slug($custom_page_slug); 682 if ($url) 683 return add_query_arg('event_id',$event_id, $url); 684 else 685 return $permalink; 686 } 658 687 659 688 … … 856 885 list($event_id, $rc) = $this->get_id_of_event($prod_id); 857 886 if ($event_id) { 858 $backlink = get_permalink( $event_id);887 $backlink = $this->link_to_event_page(get_permalink($event_id), $event_id, false); 859 888 $html = '<a href="' . $backlink .'">' . __("Goto the event", 'hello-event') . '</a><br/><br/>'; 860 889 $html = apply_filters('hello_event_display_link_to_event', $html, $prod_id, $event_id); … … 1412 1441 list($event_id, $rc) = $this->get_id_of_event($prod_id); 1413 1442 if ($event_id) { 1414 $backlink = get_permalink( $event_id);1443 $backlink = $this->link_to_event_page(get_permalink($event_id), $event_id, false); 1415 1444 $html = '<a href="' . $backlink .'">' . $a['text'] . '</a><br/>'; 1416 1445 $html = apply_filters('hello_event_display_link_to_event', $html, $prod_id, $event_id); -
hello-event/trunk/includes/hello-event-list-events.php
r3103735 r3103736 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' => 139 );40 $pages = get_posts($args);41 if ($pages)42 return get_permalink($pages[0]);43 else44 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 = $permalink57 // Otherwise the link is to the link returned = custom page URL with event id as parameter58 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 else64 return $permalink;65 }66 33 67 34 function handle_shortcode_event_list($args0) { … … 228 195 $html .= ' <div class="start-date">'.$start_date.'</div>'; 229 196 $html .= ' <div class="event-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().'">';197 $html .= ' <a href="'.$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page']).'" rel="bookmark" title="Permanent Link to '.get_the_title().'">'; 231 198 $html .= get_the_title().'</a>'; 232 199 $html .= ' </div>'; … … 267 234 $g_title = " 268 235 <div class='title'> 269 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'236 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 270 237 rel='bookmark' 271 238 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 298 265 <div class='description'> 299 266 <div class='title'> 300 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'267 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 301 268 rel='bookmark' 302 269 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 324 291 </div> 325 292 <div class='title'> 326 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'293 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 327 294 rel='bookmark' 328 295 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 352 319 <div class='intro'> 353 320 <div class='title'> 354 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'321 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 355 322 rel='bookmark' 356 323 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 381 348 </div> 382 349 <div class='title'> 383 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'350 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 384 351 rel='bookmark' 385 352 title='Permalink to ".get_the_title()."'>".get_the_title()." … … 427 394 </div> 428 395 <div class='title'> 429 <a href='".$ this->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."'396 <a href='".$hello_event_object->link_to_event_page(get_the_permalink(), $id, $args['event_page'])."' 430 397 rel='bookmark' 431 398 title='Permalink to ".get_the_title()."'>".get_the_title()." -
hello-event/trunk/includes/hello-event-settings.php
r2946985 r3103736 70 70 ); 71 71 72 // New section for custom event page 73 add_settings_section( 74 'hello_section_6a', 75 __('Custom event page', 'hello-event'), 76 array($this, 'hello_section_6a_intro'), 77 'hello_event' 78 ); 79 72 80 add_settings_section( 73 81 'hello_section_6', … … 194 202 ); 195 203 204 // New field for custom event page 205 add_settings_field( 206 'hello_field_select_map_api', 207 __( 'Slug for custom event page', 'hello-event' ), 208 array($this, 'hello_field_custom_event_page_cb'), 209 'hello_event', 210 'hello_section_6a', 211 [ 212 'label_for' => 'hello_field_custom_event_page', 213 'class' => 'hello_row', 214 'hello_custom_data' => 'custom', 215 ] 216 ); 196 217 197 218 add_settings_field( … … 410 431 } 411 432 433 function hello_section_6a_intro( $args ) { 434 $html = ""; 435 $html .= "<p>" . __("It is possible to create a custom page used to display the events.", 'hello-event') . "<br/>"; 436 $html .= __("If no custom page is defined, events will be displayed using the standard page template of the theme, and in the settings below", 'hello-event') .", <i>". __("Auto inserted content", "hello-event") .",</i> " . __("you can decide what information should be automatically inserted", "hello-event") . "<br/>"; 437 $html .= __("When using a custom event page you must use shortcodes to show the event information.", 'hello-event') . "</p>"; 438 echo $html; 439 } 440 412 441 function hello_section_6_intro( $args ) { 413 442 $html = ""; … … 588 617 $html .= __('this page', 'hello-event') . '</a></p>'; 589 618 echo $html; 590 619 } 620 621 function hello_field_custom_event_page_cb($args) { 622 $options = get_option( 'hello_event' ); 623 //print_r($options); 624 ?> 625 <input type="text" 626 id="<?php echo esc_attr( $args['label_for'] ); ?>" 627 data-custom="<?php echo esc_attr( $args['hello_custom_data'] ); ?>" 628 name="hello_event[<?php echo esc_attr( $args['label_for'] ); ?>]" 629 value="<?php echo isset($options[ $args['label_for'] ]) ? $options[ $args['label_for'] ] : '' ; ?>"/> 630 <?php 631 $html = '<p class="description">' . __("Fill in the slug of the custom event page, or leave blank for default.", 'hello-event') . '<br/>'; 632 $html .= __("If the page does not exist the default will be used.", 'hello-event') . '</p>'; 633 echo $html; 634 591 635 } 592 636 -
hello-event/trunk/readme.txt
r3103735 r3103736 74 74 == Changelog == 75 75 = 1.3.14 76 * Added possibility to display the event using a custom page 76 77 * More debug info when debug setting is switched on in the settings 77 78 * Added Dutch language - courtesy of Wim De Kelver
Note: See TracChangeset
for help on using the changeset viewer.