PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.3
Gallery : FooGallery v3.3.3
3.3.2 3.3.3 3.3.0 3.1.31 3.1.32 3.1.34 3.1.36 3.2.0 3.2.6 trunk 1.10.3 2.0.24 2.1.34 2.2.44 2.3.3 2.4.32 3.0.6 3.1.11 3.1.12 3.1.13 3.1.20 3.1.25 3.1.26 3.1.26.1 3.1.26.2
foogallery / includes / class-foogallery-password-protect.php
foogallery / includes Last commit date
abilities 3 days ago admin 3 days ago compatibility 3 days ago extensions 3 days ago foopluginbase 3 days ago public 3 days ago thumbs 3 days ago asset-manifest.php 3 days ago class-attachment-filters.php 3 days ago class-command-palette.php 3 days ago class-foogallery-animated-gif-support.php 3 days ago class-foogallery-attachment-custom-class.php 3 days ago class-foogallery-attachment-filename.php 3 days ago class-foogallery-attachment-type.php 3 days ago class-foogallery-attachment.php 3 days ago class-foogallery-cache.php 3 days ago class-foogallery-common-fields.php 3 days ago class-foogallery-crop-position.php 3 days ago class-foogallery-datasource-media_library.php 3 days ago class-foogallery-debug.php 3 days ago class-foogallery-delayed-runtime-loader.php 3 days ago class-foogallery-extensions-compatibility.php 3 days ago class-foogallery-force-https.php 3 days ago class-foogallery-lazyload.php 3 days ago class-foogallery-license-constant-handler.php 3 days ago class-foogallery-lightbox.php 3 days ago class-foogallery-no-javascript-fallback.php 3 days ago class-foogallery-paging.php 3 days ago class-foogallery-password-protect.php 3 days ago class-foogallery-sitemaps.php 3 days ago class-foogallery-widget.php 3 days ago class-foogallery.php 3 days ago class-gallery-advanced-settings.php 3 days ago class-il8n.php 3 days ago class-override-thumbnail.php 3 days ago class-posttypes.php 3 days ago class-previews.php 3 days ago class-retina.php 3 days ago class-thumbnail-dimensions.php 3 days ago class-thumbnails.php 3 days ago class-version-check.php 3 days ago constants.php 3 days ago functions.php 3 days ago gallery-management-functions.php 3 days ago includes.php 3 days ago index.php 3 days ago render-functions.php 3 days ago
class-foogallery-password-protect.php
62 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Class used to handle password protected galleries.
9 */
10 if ( ! class_exists( 'FooGallery_Password_Protect' ) ) {
11
12 class FooGallery_Password_Protect {
13
14 function __construct() {
15 add_filter( 'the_password_form', array( $this, 'customize_password_form_for_galleries' ), 10, 3 );
16 }
17
18 /**
19 * Customize the password form when used for a gallery.
20 *
21 * @param string $output The default password form HTML
22 * @param WP_Post $post The post object
23 * @param string $invalid_password The invalid password message
24 * @return string Modified password form HTML
25 */
26 public function customize_password_form_for_galleries( $output, $post, $invalid_password = '') {
27 global $current_foogallery;
28
29 if ( empty( $current_foogallery ) ) {
30 return $output;
31 }
32
33 // Check if we're in gallery context
34 $gallery = foogallery::get( $post );
35
36 if ( !empty( $gallery ) && $current_foogallery->ID === $gallery->ID ) {
37 // Get current URL for form action
38 $current_url = '';
39 if ( isset( $_SERVER['REQUEST_URI'] ) ) {
40 $current_url = esc_url_raw( $_SERVER['REQUEST_URI'] );
41 }
42
43 // Replace the redirect_to hidden input value with current URL
44 $output = preg_replace(
45 '/<input type="hidden" name="redirect_to" value="[^"]*" \/>/',
46 '<input type="hidden" name="redirect_to" value="' . esc_attr( $current_url ) . '" />',
47 $output
48 );
49
50 // Replace the default text with gallery-specific text
51 $output = str_replace(
52 __( 'This content is password protected. To view it please enter your password below:' ), // phpcs:ignore WordPress.WP.I18n.MissingArgDomain
53 __( 'This gallery is password protected. To view it please enter your password below:', 'foogallery' ),
54 $output
55 );
56 }
57
58 return $output;
59 }
60 }
61 }
62