protection_method && 'page' === $restriction->replacement_type && is_page( $restriction->replacement_page ) ) || ( 'replace_archive_page' === $restriction->archive_handling && is_page( $restriction->archive_replacement_page ) ) ) { return $content; } $message = \ContentControl\get_default_denial_message(); /** * If the restriction has a custom message, use it. * * We could check $restriction->replacement_type, but we need a safe default for * all cases. Further we do content filtering for all sub queries and currently * don't offer a way to override the message for those. * * In this way currently users can change to content replacement, set the override * message, then change back to page replacement and the override message will still * be used for the post in sub queries. */ if ( $restriction->override_message ) { $message = $restriction->get_message(); } /** * Filter the message to display when a post is restricted. * * @param string $message Message to display. * @param object $restriction Restriction object. * * @return string */ return apply_filters( $filter_name, // If the default message is empty, show a generic message. ! empty( $message ) ? $message : __( 'This content is restricted.', 'content-control' ), $restriction ); } /** * Filter post excerpt when needed. * * @param string $post_excerpt The post excerpt. * @param \WP_Post $post Post object. * * @return string */ public function filter_the_excerpt_if_restricted( $post_excerpt, $post = null ) { $filter_name = 'content_control/restricted_post_excerpt'; if ( doing_filter( $filter_name ) ) { return $post_excerpt; } // If this isn't a post type that can be restricted, bail. if ( protection_is_disabled() ) { return $post_excerpt; } if ( ! content_is_restricted( $post->ID ) ) { return $post_excerpt; } $restriction = get_applicable_restriction(); /** * Filter the excerpt to display when a post is restricted. * * @param string $message Message to display. * @param object $restriction Restriction object. * * @return string */ return apply_filters( $filter_name, $restriction->get_message(), $restriction ); } }