Plugin Directory

Changeset 2042954


Ignore:
Timestamp:
03/02/2019 07:35:59 PM (7 years ago)
Author:
guyfisher
Message:

Replaced post ID global variable with get_the_ID function

Location:
striptease/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • striptease/trunk/readme.txt

    r1311935 r2042954  
    44Tags: anchor, excerpt, filter, more-link, navigation, permalink, quicktag, read-more, teaser
    55Requires at least: 2.8
    6 Tested up to: 4.4
     6Tested up to: 5.1
    77Stable tag: trunk
    88
     
    4242== Changelog ==
    4343
     44= 2.1 =
     45
     46* Replaced post ID global variable with `get_the_ID` function
     47
    4448= 2.0 =
    4549
  • striptease/trunk/striptease.php

    r854903 r2042954  
    11<?php
     2/**
     3 * A WordPress plugin that strips the #more fragments from the end of Read More teaser links.
     4 *
     5 * @author Guy Fisher
     6 * @copyright Copyright © 2019 Guy M. Fisher
     7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License
     8 * @link https://wordpress.org/plugins/striptease/
     9 * @package StripTease
     10 * @version 2.1
     11 *
     12 * @wordpress-plugin
     13 * Author: Guy Fisher
     14 * Author URI: https://profiles.wordpress.org/guyfisher/
     15 * Description: Strips the #more fragments from the end of Read More teaser links
     16 * License: GNU General Public License
     17 * License URI: http://www.gnu.org/licenses/gpl-2.0.html
     18 * Plugin Name: StripTease
     19 * Version: 2.1
     20 */
    221
    322/**
    4  * A WordPress plugin that strips the #more fragments from the end of Read More
    5  * teaser links.
     23 * Strips fragments from Read More teaser links
    624 *
    7  * @package StripTease
    8  * @link http://guyfisher.com/builder/striptease/
    9  * @author Guy Fisher
    10  * @version 2.0
    11  * @copyright Copyright © 2010 Guy M. Fisher
    12  * @license http://www.gnu.org/licenses/gpl-2.0.html
    13  */
    14 
    15 /*
    16 
    17 Plugin Name: StripTease
    18 Plugin URI: http://guyfisher.com/builder/striptease/
    19 Description: Strips the #more fragments from the end of Read More teaser links.
    20 Author: Guy Fisher
    21 Author URI: http://guyfisher.com/
    22 Version: 2.0
    23 
    24 Copyright © 2010 Guy M. Fisher
    25 
    26 This program is free software; you can redistribute it and/or modify it under
    27 the terms of the GNU General Public License as published by the Free Software
    28 Foundation; either version 2 of the License, or (at your option) any
    29 later version.
    30 
    31 This program is distributed in the hope that it will be useful, but WITHOUT ANY
    32 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
    33 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    34 
    35 http://www.gnu.org/licenses/gpl-2.0.html
    36 
    37 */
    38 
    39 /**
    40  * Strips the #more-$id fragments from the end of Read More teaser links.
     25 * Filters the HTML markup passed from `the_content_more_link` filter in the `get_the_content` function.
    4126 *
    42  * Filters the HTML string passed from the_content_more_link filter in the
    43  * get_the_content function.
     27 * @link https://developer.wordpress.org/reference/hooks/the_content_more_link/
    4428 *
    4529 * @since 2.0
    4630 *
    47  * @global int Post ID
    48  * @param string $more_link HTML markup for teaser link
    49  * @return string HTML markup with #more-$id fragment stripped off
     31 * @param string $more_link_element HTML markup for teaser link
     32 * @return string HTML markup with stripped teaser link
    5033 */
    51 function striptease_more_link( $more_link ) {
    52     global $id;
    53     return str_replace( "#more-$id", '', $more_link );
     34function striptease_more_link( $more_link_element ) {
     35    $the_id = get_the_ID();
     36    if ( $the_id ) {
     37        $more_link_element = str_replace( "#more-$the_id", '', $more_link_element );
     38    }
     39    return $more_link_element;
    5440}
     41
    5542add_filter( 'the_content_more_link', 'striptease_more_link' );
    5643
Note: See TracChangeset for help on using the changeset viewer.