Skip to content

Commit b0ada7e

Browse files
author
Marco Pereirinha
committed
Prevent using customer CNAME account on demo page
1 parent 858b3fc commit b0ada7e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

php/media/class-gallery.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Cloudinary\REST_API;
1414
use Cloudinary\Settings_Component;
1515
use Cloudinary\Utils;
16+
use WP_Screen;
1617

1718
/**
1819
* Class Gallery.
@@ -114,6 +115,11 @@ public function __construct( Plugin $plugin ) {
114115
* @return array
115116
*/
116117
public function get_config() {
118+
$screen = null;
119+
120+
if ( function_exists( 'get_current_screen' ) ) {
121+
$screen = get_current_screen();
122+
}
117123

118124
$config = ! empty( $this->settings->get_value( 'gallery_config' ) ) ?
119125
$this->settings->get_value( 'gallery_config' ) :
@@ -133,7 +139,11 @@ public function get_config() {
133139

134140
$credentials = $this->plugin->components['connect']->get_credentials();
135141

136-
if ( ! empty( $credentials['cname'] ) ) {
142+
// Do not use privateCdn and secureDistribution on gallery settings page.
143+
if (
144+
! empty( $credentials['cname'] )
145+
&& ( ! $screen instanceof WP_Screen || 'cloudinary_page_cloudinary_gallery' !== $screen->id )
146+
) {
137147
$config['secureDistribution'] = $credentials['cname'];
138148
$config['privateCdn'] = true;
139149
}

0 commit comments

Comments
 (0)