PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.3.0
Gallery : FooGallery v3.3.0
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-force-https.php
foogallery / includes Last commit date
abilities 1 week ago admin 1 week ago compatibility 1 week ago extensions 1 week ago foopluginbase 1 week ago public 1 week ago thumbs 1 week ago asset-manifest.php 1 week ago class-attachment-filters.php 1 week ago class-command-palette.php 1 week ago class-foogallery-animated-gif-support.php 1 week ago class-foogallery-attachment-custom-class.php 1 week ago class-foogallery-attachment-filename.php 1 week ago class-foogallery-attachment-type.php 1 week ago class-foogallery-attachment.php 1 week ago class-foogallery-cache.php 1 week ago class-foogallery-common-fields.php 1 week ago class-foogallery-crop-position.php 1 week ago class-foogallery-datasource-media_library.php 1 week ago class-foogallery-debug.php 1 week ago class-foogallery-delayed-runtime-loader.php 1 week ago class-foogallery-extensions-compatibility.php 1 week ago class-foogallery-force-https.php 1 week ago class-foogallery-lazyload.php 1 week ago class-foogallery-license-constant-handler.php 1 week ago class-foogallery-lightbox.php 1 week ago class-foogallery-no-javascript-fallback.php 1 week ago class-foogallery-paging.php 1 week ago class-foogallery-password-protect.php 1 week ago class-foogallery-sitemaps.php 1 week ago class-foogallery-widget.php 1 week ago class-foogallery.php 1 week ago class-gallery-advanced-settings.php 1 week ago class-il8n.php 1 week ago class-override-thumbnail.php 1 week ago class-posttypes.php 1 week ago class-previews.php 1 week ago class-retina.php 1 week ago class-thumbnail-dimensions.php 1 week ago class-thumbnails.php 1 week ago class-version-check.php 1 week ago constants.php 1 week ago functions.php 1 week ago gallery-management-functions.php 1 week ago includes.php 1 week ago index.php 1 week ago render-functions.php 1 week ago
class-foogallery-force-https.php
98 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 /**
8 * Class used to force HTTPS for all FooGallery assets
9 * @since 1.6.18
10 */
11 if ( ! class_exists( 'FooGallery_ForceHttps' ) ) {
12
13 class FooGallery_ForceHttps {
14
15 function __construct() {
16 add_filter( 'foogallery_admin_settings_override', array($this, 'add_settings' ) );
17 add_action( 'plugins_loaded', array( $this, 'enable_force' ) );
18 }
19
20 /**
21 * Enables the force checks based on the setting. This is done here so that the setting is only checked once per page load, rather than multiple times
22 *
23 */
24 function enable_force() {
25 if ( 'on' === foogallery_get_setting( 'force_https' ) ) {
26 add_filter( 'foogallery_process_image_url', array( $this, 'force_images_to_https' ), 99 );
27 add_filter( 'foogallery_enqueue_style_src', array( $this, 'force_css_to_https'), 99, 2 );
28 add_filter( 'foogallery_core_gallery_script', array( $this, 'force_js_to_https'), 99 );
29 }
30 }
31
32 /**
33 * Add settings for Force Https
34 * @param $settings
35 *
36 * @return array
37 */
38 function add_settings( $settings ) {
39 $settings['settings'][] = array(
40 'id' => 'force_https',
41 'title' => __( 'Force HTTPS', 'foogallery' ),
42 'desc' => __( 'Convert gallery image, stylesheet, and script URLs from HTTP to HTTPS. This can help resolve mixed-content warnings after moving a site to HTTPS.', 'foogallery' ),
43 'type' => 'checkbox',
44 'tab' => 'advanced',
45 'section' => __( 'Gallery Loading & Compatibility', 'foogallery' ),
46 );
47 return $settings;
48 }
49
50 /**
51 * Helper function that does the replacement and forces Https
52 *
53 * @param $url
54 *
55 * @return string
56 */
57 function force_https( $url ) {
58 return str_replace( 'http://', 'https://', $url );
59 }
60
61 /**
62 * Force an image URL to Https
63 *
64 * @param $url
65 *
66 * @return string
67 */
68 function force_images_to_https( $url ) {
69 return $this->force_https( $url );
70 }
71
72 /**
73 * Force any CSS loaded using the foogallery_enqueue_style function to Https
74 *
75 * @param $src
76 * @param $handle
77 *
78 * @return string
79 */
80 function force_css_to_https( $src, $handle ) {
81 $src = $this->force_https( $src );
82 return $src;
83 }
84
85 /**
86 * Force the js loaded for the default gallery templates to Https
87 *
88 * @param $src
89 *
90 * @return string
91 */
92 function force_js_to_https( $src ) {
93 $src = $this->force_https( $src );
94 return $src;
95 }
96 }
97 }
98