Making WordPress.org

Changeset 12410


Ignore:
Timestamp:
02/21/2023 05:48:06 AM (3 years ago)
Author:
dd32
Message:

Support Forums: Setup the Directory_Compat classes in the context of the topic when processing email subscriptions for pending/delayed topics.

See #6786.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r12347 r12410  
    1919        abstract protected function name();
    2020        abstract protected function parse_query();
     21        abstract protected function for_slug( $slug );
    2122        abstract protected function do_view_sidebar();
    2223        abstract protected function do_topic_sidebar();
     
    6869
    6970                }
     71        }
     72
     73        /**
     74         * Maybe load the data for this compat directory class.
     75         *
     76         * @param int $topic_id The topic ID that we should initialize in the context of.
     77         */
     78        public function init_for_topic( $topic_id ) {
     79                $forum_id = bbp_get_topic_forum_id( $topic_id );
     80                if ( $forum_id != $this->forum_id() ) {
     81                        return;
     82                }
     83
     84                $terms = get_the_terms( $topic_id, $this->taxonomy() );
     85                if ( ! $terms ) {
     86                        return;
     87                }
     88
     89                $this->for_slug( $terms[0]->slug );
    7090        }
    7191
     
    828848                // Note: Not using $this->title() here so as to filter other terms of this taxonomy correctly.
    829849
    830                 $term->name = $this->get_object( $term->slug )->post_title ?? $term->name;
     850                if ( ! is_admin() ) {
     851                        $term->name = $this->get_object( $term->slug )->post_title ?? $term->name;
     852                }
    831853
    832854                return $term;
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-emails.php

    r12273 r12410  
    169169                $topic_author = bbp_get_topic_author_id( $topic_id );
    170170
     171                // Setup the forum compat classes, as used by email filters for subject changes.
     172                $forums = Plugin::get_instance();
     173                if ( $forums->plugins ) {
     174                        $forums->plugins->init_for_topic( $topic_id );
     175                        $forums->themes->init_for_topic( $topic_id );
     176                }
     177
    171178                // For performance reasons, we've removed the bbPress bbp_update_topic() method, and replaced it with our slightly altered variant.
    172179                $bbp_update_topic = [ Plugin::get_instance()->dropin, 'bbp_update_topic' ];
     
    203210                }
    204211
     212                // Setup the forum compat classes, as used by email filters for subject changes.
     213                $forums = Plugin::get_instance();
     214                if ( $forums->plugins ) {
     215                        $forums->plugins->init_for_topic( $topic_id );
     216                        $forums->themes->init_for_topic( $topic_id );
     217                }
     218
    205219                // For performance reasons, we've removed the bbPress bbp_update_reply() method, and replaced it with our slightly altered variant.
    206220                $bbp_update_reply = [ Plugin::get_instance()->dropin, 'bbp_update_reply' ];
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php

    r11563 r12410  
    9191                }
    9292
     93                if ( ! $this->for_slug( $slug ) ) {
     94                        status_header( 404 );
     95                }
     96        }
     97
     98        /**
     99         * Set the directory instance to the slugs data.
     100         *
     101         * @param string $slug The plugin slug.
     102         */
     103        public function for_slug( $slug ) {
    93104                $plugin = $this->get_object( $slug );
    94105                if ( ! $plugin ) {
    95                         status_header( 404 );
    96                         return;
     106                        return false;
    97107                }
    98108
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php

    r10819 r12410  
    9191                }
    9292
     93                if ( ! $this->for_slug( $slug ) ) {
     94                        status_header( 404 );
     95                }
     96        }
     97
     98        /**
     99         * Set the directory instance to the slugs data.
     100         *
     101         * @param string $slug The theme slug.
     102         */
     103        public function for_slug( $slug ) {
    93104                $theme = $this->get_object( $slug );
    94105                if ( ! $theme ) {
    95                         status_header( 404 );
    96                         return;
     106                        return false;
    97107                }
    98108
Note: See TracChangeset for help on using the changeset viewer.