Skip to content

Commit

Permalink
Support for text insertion after permalink for things like tracking c…
Browse files Browse the repository at this point in the history
…odes.
  • Loading branch information
PJ Hile committed Sep 29, 2014
1 parent 7901f3b commit afc4d4c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions admin/admin.php
Expand Up @@ -78,6 +78,7 @@ function crp_options() {
$crp_settings['after_list'] = wp_kses_post( $_POST['after_list'] );
$crp_settings['before_list_item'] = wp_kses_post( $_POST['before_list_item'] );
$crp_settings['after_list_item'] = wp_kses_post( $_POST['after_list_item'] );
$crp_settings['after_link'] = $_POST['after_link'];

$crp_settings['exclude_on_post_ids'] = $_POST['exclude_on_post_ids'] == '' ? '' : implode( ',', array_map( 'intval', explode( ",", $_POST['exclude_on_post_ids'] ) ) );
$crp_settings['exclude_post_ids'] = $_POST['exclude_post_ids'] == '' ? '' : implode( ',', array_map( 'intval', explode( ",", $_POST['exclude_post_ids'] ) ) );
Expand Down
6 changes: 6 additions & 0 deletions admin/options-output.php
Expand Up @@ -214,6 +214,12 @@
<tr><th scope="row"><label for="after_list"><?php _e( 'HTML to display after the list of posts: ', CRP_LOCAL_NAME ); ?></label></th>
<td><input type="textbox" name="after_list" id="after_list" value="<?php echo esc_attr( stripslashes( $crp_settings['after_list'] ) ); ?>" style="width:250px" /></td>
</tr>
<tr><th scope="row"><label for="after_link"><?php _e( 'Text to display after the post permalink: ', CRP_LOCAL_NAME ); ?></label></th>
<td>
<input type="textbox" name="after_link" id="after_link" value="<?php echo esc_attr( stripslashes( $crp_settings['after_link'] ) ); ?>" style="width:250px" />
<p class="description"><?php _e( 'Tracking code for example: ?utm_source=internal-link&utm_medium=related-top&utm_campaign=contextual-related', CRP_LOCAL_NAME ); ?></p>
</td>
</tr>

<?php
/**
Expand Down
7 changes: 4 additions & 3 deletions contextual-related-posts.php
Expand Up @@ -205,10 +205,10 @@ function ald_crp( $args = array() ) {
$title = apply_filters( 'crp_title', $title, $result );

if ( 'after' == $post_thumb_op ) {
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $rel_attribute . ' ' . $target_attribute . 'class="crp_title">' . $title . '</a>'; // Add title if post thumbnail is to be displayed after
$output .= '<a href="' . get_permalink( $result->ID ) . $after_link . '" ' . $rel_attribute . ' ' . $target_attribute . 'class="crp_title">' . $title . '</a>'; // Add title if post thumbnail is to be displayed after
}
if ( 'inline' == $post_thumb_op || 'after' == $post_thumb_op || 'thumbs_only' == $post_thumb_op ) {
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $rel_attribute . ' ' . $target_attribute . '>';
$output .= '<a href="' . get_permalink( $result->ID ) . $after_link . '" ' . $rel_attribute . ' ' . $target_attribute . '>';
$output .= crp_get_the_post_thumbnail( array(
'postid' => $result->ID,
'thumb_height' => $thumb_height,
Expand All @@ -226,7 +226,7 @@ function ald_crp( $args = array() ) {
$output .= '</a>';
}
if ( 'inline' == $post_thumb_op || 'text_only' == $post_thumb_op ) {
$output .= '<a href="' . get_permalink( $result->ID ) . '" ' . $rel_attribute . ' ' . $target_attribute . ' class="crp_title">' . $title . '</a>'; // Add title when required by settings
$output .= '<a href="' . get_permalink( $result->ID ) . $after_link . '" ' . $rel_attribute . ' ' . $target_attribute . ' class="crp_title">' . $title . '</a>'; // Add title when required by settings
}
if ( $show_author ) {
$author_info = get_userdata( $result->post_author );
Expand Down Expand Up @@ -889,6 +889,7 @@ function crp_default_options() {
'after_list' => '</ul>', // After the entire list
'before_list_item' => '<li>', // Before each list item
'after_list_item' => '</li>', // After each list item
'after_link' => '', // After each link

'exclude_categories' => '', // Exclude these categories
'exclude_cat_slugs' => '', // Exclude these categories (slugs)
Expand Down

0 comments on commit afc4d4c

Please sign in to comment.