PluginProbe ʕ •ᴥ•ʔ
Gallery : FooGallery / 3.2.6
Gallery : FooGallery v3.2.6
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 4 weeks ago admin 4 weeks ago compatibility 4 weeks ago extensions 4 weeks ago foopluginbase 4 weeks ago public 4 weeks ago thumbs 4 weeks ago asset-manifest.php 4 weeks ago class-attachment-filters.php 4 weeks ago class-command-palette.php 4 weeks ago class-foogallery-animated-gif-support.php 4 weeks ago class-foogallery-attachment-custom-class.php 4 weeks ago class-foogallery-attachment-filename.php 4 weeks ago class-foogallery-attachment-type.php 4 weeks ago class-foogallery-attachment.php 4 weeks ago class-foogallery-cache.php 4 weeks ago class-foogallery-common-fields.php 4 weeks ago class-foogallery-crop-position.php 4 weeks ago class-foogallery-datasource-media_library.php 4 weeks ago class-foogallery-debug.php 4 weeks ago class-foogallery-delayed-runtime-loader.php 4 weeks ago class-foogallery-extensions-compatibility.php 4 weeks ago class-foogallery-force-https.php 4 weeks ago class-foogallery-lazyload.php 4 weeks ago class-foogallery-license-constant-handler.php 4 weeks ago class-foogallery-lightbox.php 4 weeks ago class-foogallery-paging.php 4 weeks ago class-foogallery-password-protect.php 4 weeks ago class-foogallery-sitemaps.php 4 weeks ago class-foogallery-widget.php 4 weeks ago class-foogallery.php 4 weeks ago class-gallery-advanced-settings.php 4 weeks ago class-il8n.php 4 weeks ago class-override-thumbnail.php 4 weeks ago class-posttypes.php 4 weeks ago class-previews.php 4 weeks ago class-retina.php 4 weeks ago class-thumbnail-dimensions.php 4 weeks ago class-thumbnails.php 4 weeks ago class-version-check.php 4 weeks ago constants.php 4 weeks ago functions.php 4 weeks ago gallery-management-functions.php 4 weeks ago includes.php 4 weeks ago index.php 4 weeks ago render-functions.php 4 weeks ago
class-foogallery-force-https.php
97 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' => __( 'Force all assets (thumbnails, javascript, css) to load over the HTTPS protocol. This can help overcome some issues when moving your site across to HTTPS and you get mixed content errors.', 'foogallery' ),
43 'type' => 'checkbox',
44 'tab' => 'advanced'
45 );
46 return $settings;
47 }
48
49 /**
50 * Helper function that does the replacement and forces Https
51 *
52 * @param $url
53 *
54 * @return string
55 */
56 function force_https( $url ) {
57 return str_replace( 'http://', 'https://', $url );
58 }
59
60 /**
61 * Force an image URL to Https
62 *
63 * @param $url
64 *
65 * @return string
66 */
67 function force_images_to_https( $url ) {
68 return $this->force_https( $url );
69 }
70
71 /**
72 * Force any CSS loaded using the foogallery_enqueue_style function to Https
73 *
74 * @param $src
75 * @param $handle
76 *
77 * @return string
78 */
79 function force_css_to_https( $src, $handle ) {
80 $src = $this->force_https( $src );
81 return $src;
82 }
83
84 /**
85 * Force the js loaded for the default gallery templates to Https
86 *
87 * @param $src
88 *
89 * @return string
90 */
91 function force_js_to_https( $src ) {
92 $src = $this->force_https( $src );
93 return $src;
94 }
95 }
96 }
97