Plugin Directory

Changeset 3812974


Ignore:
Timestamp:
11/20/2026 05:07:27 AM (less than one hour ago)
Author:
themifyme
Message:
  • Fix: Event meta info show on password protected post
Location:
themify-event-post
Files:
89 added
8 edited

Legend:

Unmodified
Added
Removed
  • themify-event-post/trunk/includes/functions.php

    r3634833 r3812974  
    101101}
    102102
     103if ( ! function_exists( 'themify_event_post_hide_protected_meta' ) ) :
     104/**
     105 * Password-protected events keep venue, ticket, and schedule details
     106 * private until the visitor unlocks the post, same as the post content.
     107 *
     108 * Admin screens still show the details so the events list stays usable.
     109 *
     110 * @param int|WP_Post|null $post Post ID or object. Defaults to the current post.
     111 * @return bool
     112 */
     113function themify_event_post_hide_protected_meta( $post = null ) {
     114        if ( is_admin() && ! wp_doing_ajax() ) {
     115                return false;
     116        }
     117
     118        $post = get_post( $post );
     119
     120        return $post instanceof WP_Post && post_password_required( $post );
     121}
     122endif;
     123
    103124if ( ! function_exists( 'themify_event_post_date' ) ) :
    104125/**
    … …  
    108129 */
    109130function themify_event_post_date( $date_format = null, $time_format = null ) {
     131    if ( themify_event_post_hide_protected_meta() ) {
     132        return;
     133    }
    110134    if(get_post_meta( get_the_id(), 'to_be_announced', true )==='on'){
    111135        echo '<time class="tep_date"><span class="event-start-date">'.__('To be announced','themify-event-post').'</span></time>';
    … …  
    164188     */
    165189    function themify_event_type() {
     190        if ( themify_event_post_hide_protected_meta() ) {
     191            return;
     192        }
    166193        $post_id = get_the_ID();
    167194        $e_type=get_post_meta( $post_id, 'event_attendance', true );
    … …  
    180207     */
    181208    function themify_event_organizer() {
     209        if ( themify_event_post_hide_protected_meta() ) {
     210            return;
     211        }
    182212        $post_id = get_the_ID();
    183213        $name=get_post_meta( $post_id, 'organizer_name', true );
    … …  
    209239     */
    210240    function themify_event_performer() {
     241        if ( themify_event_post_hide_protected_meta() ) {
     242            return;
     243        }
    211244        $post_id = get_the_ID();
    212245        $name=get_post_meta( $post_id, 'performer_name', true );
    … …  
    334367 */
    335368function themify_event_post_get_image( $args = array() ) {
    336         if ( ! has_post_thumbnail() ) {
     369        if ( themify_event_post_hide_protected_meta() || ! has_post_thumbnail() ) {
    337370                return '';
    338371        }
    … …  
    713746         */
    714747        function themify_event_post_json_ld_generator( $args = array() ) {
     748                if ( themify_event_post_hide_protected_meta() ) {
     749                        return '';
     750                }
     751
    715752                $schema = array(
    716753                        '@context'=>'https://schema.org',
    … …  
    10161053function themify_event_post_get_price( $post = null, $before = '', $after = '' ) {
    10171054        $post = get_post( $post );
     1055        if ( ! ( $post instanceof WP_Post ) || themify_event_post_hide_protected_meta( $post ) ) {
     1056                return '';
     1057        }
    10181058        $price = get_post_meta( $post->ID, 'buy_tickets_price', true );
    10191059        if ( empty( $price ) ) {
    … …  
    10561096function themify_event_get_buy_ticket( $post = null ) : string {
    10571097    $post = get_post( $post );
     1098    if ( ! ( $post instanceof WP_Post ) || themify_event_post_hide_protected_meta( $post ) ) {
     1099        return '';
     1100    }
    10581101    $output = '';
    10591102    if ( $buy_ticket = get_post_meta( $post->ID, 'buy_tickets', true ) ) {
  • themify-event-post/trunk/includes/system.php

    r3634833 r3812974  
    7676                        ( is_singular( 'event' ) || is_tax( [ 'event-category', 'event-tag' ] ) )
    7777                ) {
     78
     79                        if ( is_singular( 'event' ) ) {
     80                                add_filter( 'comments_open', array( $this, 'close_protected_event_comments' ), 99, 2 );
     81                                add_filter( 'pings_open', array( $this, 'close_protected_event_comments' ), 99, 2 );
     82                                add_filter( 'comments_array', array( $this, 'hide_protected_event_comments' ), 99, 2 );
     83                                add_filter( 'get_comments_number', array( $this, 'hide_protected_event_comment_count' ), 99, 2 );
     84                                add_filter( 'comments_template', array( $this, 'protected_event_comments_template' ), 999 );
     85                        }
    7886
    7987                        if ( class_exists( 'Tbp_Public' ,false) ) {
    … …  
    131139        }
    132140
     141        /**
     142         * Keep the comment form closed until a password-protected event is unlocked.
     143         *
     144         * @param bool $open
     145         * @param int  $post_id
     146         * @return bool
     147         */
     148        function close_protected_event_comments( $open, $post_id ) {
     149                if ( themify_event_post_hide_protected_meta( $post_id ) ) {
     150                        return false;
     151                }
     152
     153                return $open;
     154        }
     155
     156        /**
     157         * @param array $comments
     158         * @param int   $post_id
     159         * @return array
     160         */
     161        function hide_protected_event_comments( $comments, $post_id ) {
     162                if ( themify_event_post_hide_protected_meta( $post_id ) ) {
     163                        return array();
     164                }
     165
     166                return $comments;
     167        }
     168
     169        /**
     170         * @param int|string $count
     171         * @param int        $post_id
     172         * @return int|string
     173         */
     174        function hide_protected_event_comment_count( $count, $post_id ) {
     175                if ( themify_event_post_hide_protected_meta( $post_id ) ) {
     176                        return 0;
     177                }
     178
     179                return $count;
     180        }
     181
     182        /**
     183         * Replace the theme comments template so the form is not rendered.
     184         *
     185         * @param string $template
     186         * @return string
     187         */
     188        function protected_event_comments_template( $template ) {
     189                if ( themify_event_post_hide_protected_meta() ) {
     190                        return $this->get_template_dir() . '/comments-protected.php';
     191                }
     192
     193                return $template;
     194        }
     195
    133196        function archive_template( $content ) {
    134197                if ( get_post_type() === 'event' ) {
  • themify-event-post/trunk/readme.txt

    r3634833 r3812974  
    44Tags: event, post, date, post-type
    55Requires at least: 5.2
    6 Tested up to: 7.0.2
    7 Stable tag: 1.3.7
     6Tested up to: 7.1.5
     7Stable tag: 1.3.8
    88License: GPL v2
    99License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    … …  
    3131
    3232The changelog is located at: https://themify.org/changelogs/themify-event-post.txt
     33
     34== Frequently Asked Questions ==
     35= Where do I report security bugs found in this plugin? =
     36
     37Please report security bugs found in the source code of the Themify Event Post plugin through the [Patchstack Vulnerability Disclosure  Program](https://patchstack.com/database/vdp/9e5fbdbd-9f41-431a-b198-cfa0c3ac0aef). The Patchstack team will assist you with verification, CVE assignment, and notify the developers of this plugin.
  • themify-event-post/trunk/templates/content.php

    r3634833 r3812974  
    2525$thumb = '';
    2626$map_address = '';
     27$location = '';
     28$hide_protected_meta = themify_event_post_hide_protected_meta( $post_id );
    2729?>
    2830<article id="post-<?php the_id(); ?>" <?php post_class( 'themify_event_post post tf_clearfix event-post' ); ?>>
    2931
    30         <?php if ( $image === 'yes' && has_post_thumbnail() ) : ?>
     32        <?php if ( ! $hide_protected_meta && $image === 'yes' && has_post_thumbnail() ) : ?>
    3133                <?php
    3234                echo themify_event_post_get_image( array(
    … …  
    7274            <?php endif; ?>
    7375
    74                         <?php if ( ( $location = get_post_meta( $post_id, 'location', true ) ) && $hide_event_location === 'no' ) : ?>
     76                        <?php if ( ! $hide_protected_meta && ( $location = get_post_meta( $post_id, 'location', true ) ) && $hide_event_location === 'no' ) : ?>
    7577                                        <div>
    7678                                                <span class="tep_location">
    … …  
    105107
    106108                </div><!-- /.tep_content -->
    107                 <?php
     109                <?php
     110                        if ( ! $hide_protected_meta ) :
    108111                        $metadata = get_post_meta($post_id);
    109112                        echo themify_event_post_json_ld_generator(array(
    … …  
    129132                                'performer'=>isset($metadata['event_performer'])?$metadata['event_performer'][0]:'',
    130133                                'performer_name'=>isset($metadata['performer_name'])?$metadata['performer_name'][0]:'',
    131                         )); ?>
     134                        ));
     135                        endif; ?>
    132136        </div><!-- .tep_post_content -->
    133137
  • themify-event-post/trunk/templates/single.php

    r3634833 r3812974  
    88 */
    99$post_id = get_the_id();
     10$hide_protected_meta = themify_event_post_hide_protected_meta( $post_id );
     11$map_address = '';
     12$location = '';
    1013?>
    1114<div <?php post_class( 'themify_event_post' ); ?>>
    1215
    1316        <?php
    14         echo themify_event_post_get_image();
    15         $image = get_the_post_thumbnail_url($post_id);
     17        if ( ! $hide_protected_meta ) {
     18                echo themify_event_post_get_image();
     19                $image = get_the_post_thumbnail_url( $post_id );
     20        } else {
     21                $image = '';
     22        }
    1623        ?>
    1724
    18         <?php if ( $map_address = get_post_meta( $post_id, 'map_address', true ) ) : ?>
     25        <?php if ( ! $hide_protected_meta && ( $map_address = get_post_meta( $post_id, 'map_address', true ) ) ) : ?>
    1926                <div class="tep_event_map">
    2027                        <?php echo themify_event_post_map( array(
    … …  
    4350                <?php themify_event_performer(); ?>
    4451
    45                 <?php if ( $location = get_post_meta( $post_id, 'location', true ) ) : ?>
     52                <?php if ( ! $hide_protected_meta && ( $location = get_post_meta( $post_id, 'location', true ) ) ) : ?>
    4653                                <div>
    4754                                        <span class="tep_location">
    … …  
    6673        </div><!-- /.tep_content -->
    6774
    68     <?php
     75    <?php
     76        if ( ! $hide_protected_meta ) :
    6977        $metadata = get_post_meta($post_id);
    7078        echo themify_event_post_json_ld_generator(array(
    … …  
    9199        'performer'=>isset($metadata['event_performer'])?$metadata['event_performer'][0]:'',
    92100        'performer_name'=>isset($metadata['performer_name'])?$metadata['performer_name'][0]:'',
    93     )); ?>
     101    ));
     102        endif; ?>
    94103</div><!-- / .themify_event_post -->
  • themify-event-post/trunk/themify-event-post.php

    r3634833 r3812974  
    33Plugin Name:  Themify Event Post
    44Plugin URI:   https://themify.me/event-post
    5 Version:      1.3.7
     5Version:      1.3.8
    66Author:       Themify
    77Author URI:   https://themify.me
    … …  
    4545                'url' => trailingslashit( plugin_dir_url( __FILE__ ) ),
    4646                'dir' => trailingslashit( plugin_dir_path( __FILE__ ) ),
    47                 'version' => '1.3.7'
     47                'version' => '1.3.8'
    4848        ) );
    4949}
Note: See TracChangeset for help on using the changeset viewer.