Changeset 1372
- Timestamp:
- 03/04/2015 12:57:21 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php
r1371 r1372 734 734 * Returns an anchor permalink for a Speaker or Session 735 735 * 736 * If the speakers page is rendered with the [speakers] shortcode, it will 737 * contain IDs that can be used as anchors. This function will attempt to find 738 * a speakers page and link to the appropriate anchor. 739 * 740 * @param $post_id int The speaker/session's post ID. 736 * Any page with the [speakers | sessions] shortcode will contain IDs that can be used as anchors. 737 * 738 * If the current page contains the corresponding shortcode, we'll assume the user wants to link there. 739 * Otherwise, we'll attempt to find another page that contains the shortcode. 740 * 741 * @param $target_id int The speaker/session's post ID. 741 742 * 742 743 * @return string 743 744 */ 744 function get_wcpt_anchor_permalink( $post_id ) { 745 $post = get_post( $post_id ); 746 747 if ( 'publish' != $post->post_status ) { 745 function get_wcpt_anchor_permalink( $target_id ) { 746 global $post; 747 $anchor_target = get_post( $target_id ); 748 749 if ( 'publish' != $anchor_target->post_status ) { 748 750 return ''; 749 751 } 750 752 751 switch( $ post->post_type ) {753 switch( $anchor_target->post_type ) { 752 754 case 'wcb_speaker': 753 $permalink = $this->get_wcpt_permalink( 'speakers' );754 $anchor_id = $ post->post_name;755 $permalink = has_shortcode( $post->post_content, 'speakers' ) ? get_permalink( $post->id ) : $this->get_wcpt_permalink( 'speakers' ); 756 $anchor_id = $anchor_target->post_name; 755 757 break; 756 758 757 759 case 'wcb_session': 758 $permalink = $this->get_wcpt_permalink( 'sessions' );759 $anchor_id = $ post->ID;760 $permalink = has_shortcode( $post->post_content, 'sessions' ) ? get_permalink( $post->id ) : $this->get_wcpt_permalink( 'sessions' ); 761 $anchor_id = $anchor_target->ID; 760 762 break; 761 763 … … 772 774 '%s#wcorg-%s-%s', 773 775 $permalink, 774 str_replace( 'wcb_', '', $ post->post_type ),776 str_replace( 'wcb_', '', $anchor_target->post_type ), 775 777 sanitize_html_class( $anchor_id ) 776 778 ); … … 852 854 853 855 if ( ! in_array( $attr['speaker_link'], array( 'anchor', 'wporg', 'permalink', 'none' ) ) ) 854 $attr['speaker_link'] = 'anchor'; 856 $attr['speaker_link'] = 'anchor'; // todo this is inconsistent with the values passed to shortcode_atts, and probably not needed if the default above is changed to 'anchor' 855 857 856 858 $attr['orderby'] = ( in_array( $attr['orderby'], array( 'date', 'title', 'rand' ) ) ) ? $attr['orderby'] : 'date';
Note: See TracChangeset
for help on using the changeset viewer.