PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more / 3.7.0
EmbedPress – PDF Embedder, Embed PDF viewer, YouTube Videos, 3D FlipBook, Social feeds & more v3.7.0
4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / Gutenberg / block-backend / block-embedpress.php
embedpress / Gutenberg / block-backend Last commit date
block-embedpress.php 3 years ago block-wistia.php 5 years ago block-youtube.php 3 years ago
block-embedpress.php
232 lines
1 <?php
2
3 use EmbedPress\Includes\Classes\Helper;
4
5 // Exit if accessed directly.
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9 /**
10 * It renders gutenberg block of embedpress on the frontend
11 * @param array $attributes
12 */
13
14 if(!function_exists('lock_content_form_handler')){
15 add_action('wp_ajax_lock_content_form_handler', 'lock_content_form_handler');
16 add_action('wp_ajax_nopriv_lock_content_form_handler', 'lock_content_form_handler');
17
18 function lock_content_form_handler() {
19 // print_r($embedHTML);
20
21 $client_id = isset($_POST['client_id']) ? $_POST['client_id'] : '';
22 $password = isset($_POST['password']) ? $_POST['password'] : '';
23 $epbase64 = isset($_POST['epbase']) ? $_POST['epbase'] : '';
24 $hash_key = isset($_POST['hash_key']) ? $_POST['hash_key'] : '';
25
26 // echo $client_id;
27
28
29 // Set the decryption key and initialization vector (IV)
30 $key = "g72@QKgEcANy8%D7xq8%@n%#";
31 $iv = "^ZCC$93vsbyYjz01";
32
33 // Decode the base64 encoded cipher
34 $cipher = base64_decode($epbase64);
35 // Decrypt the cipher using AES-128-CBC encryption
36
37 $wp_pass_key = hash('sha256', wp_salt(32) . md5($password));
38 if ($wp_pass_key === $hash_key) {
39 setcookie("password_correct_", $password, time()+3600);
40
41 $embed = openssl_decrypt($cipher, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $iv) . '<script>
42 var now = new Date();
43 var time = now.getTime();
44 var expireTime = time + 1000 * 60 * 60 * 24 * 30;
45 now.setTime(expireTime);
46 document.cookie = "password_correct_'.$client_id.'='.$hash_key.'; expires=" + now.toUTCString() + "; path=/";
47 </script>';
48
49 }
50 else{
51 $embed = 0;
52 }
53
54 // Process the form data and return a response
55 $response = array(
56 'success' => true,
57 'password' => $password,
58 'embedHtml' => $embed
59 );
60
61 echo json_encode($response);
62
63 wp_die();
64 }
65 }
66
67
68 function embedpress_render_block($attributes)
69 {
70 $client_id = !empty($attributes['clientId']) ? md5($attributes['clientId']) : '';
71 $pass_hash_key = isset($attributes['contentPassword']) ? md5($attributes['contentPassword']): '';
72
73 if (!empty($attributes['embedHTML'])) {
74 $embed = apply_filters('embedpress_gutenberg_embed', $attributes['embedHTML'], $attributes);
75
76 $content_share_class = '';
77 $share_position_class = '';
78 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
79
80 if(!empty($attributes['contentShare'])) {
81 $content_share_class = 'ep-content-share-enabled';
82 $share_position_class = 'ep-share-position-'.$share_position;
83 }
84 $content_protection_class = '';
85 if(!empty($attributes['lockContent']) && !empty($attributes['contentPassword'])) {
86 $content_protection_class = 'ep-content-protection-enabled';
87 }
88
89 $aligns = [
90 'left' => 'alignleft',
91 'right' => 'alignright',
92 'wide' => 'alignwide',
93 'full' => 'alignfull',
94 'center' => 'aligncenter',
95 ];
96 if (isset($attributes['align'])) {
97 $alignment = isset($aligns[$attributes['align']]) ? $aligns[$attributes['align']] . ' clear' : '';
98 } else {
99 $alignment = 'aligncenter'; // default alignment is center in js, so keeping same here
100 }
101 $embed = Helper::customLogo($embed, $attributes);
102 $url = !empty($attributes['href']) ? $attributes['href'] : '';
103
104 ob_start();
105 ?>
106 <div class="embedpress-gutenberg-wrapper <?php echo esc_attr( $alignment.' '.$content_share_class.' '.$share_position_class.' '.$content_protection_class); ?>" id="<?php echo esc_attr($client_id); ?>">
107 <?php
108 $share_position = isset($attributes['sharePosition']) ? $attributes['sharePosition'] : 'right';
109 $custom_thumbnail = isset($attributes['customThumbnail']) ? $attributes['customThumbnail'] : '';
110 ?>
111 <div class="wp-block-embed__wrapper <?php if(!empty($attributes['contentShare'])) echo esc_attr( 'position-'.$share_position.'-wraper'); ?> <?php if($attributes['videosize'] == 'responsive') echo esc_attr( 'ep-video-responsive' ); ?>">
112 <div id="ep-gutenberg-content-<?php echo esc_attr( $client_id )?>" class="ep-gutenberg-content">
113 <div class="ep-embed-content-wraper">
114 <?php
115 $hash_pass = hash('sha256', wp_salt(32) . md5($attributes['contentPassword']));
116 $password_correct = isset($_COOKIE['password_correct_'.$client_id]) ? $_COOKIE['password_correct_'.$client_id] : '';
117 if(empty($attributes['lockContent']) || empty($attributes['contentPassword']) || (!empty(Helper::is_password_correct($client_id)) && ($hash_pass === $password_correct)) ){
118
119 if(!empty($attributes['contentShare'])) {
120 $content_id = $attributes['clientId'];
121 $embed .= Helper::embed_content_share($content_id, $attributes);
122 }
123 echo $embed;
124 } else {
125 if(!empty($attributes['contentShare'])) {
126 $content_id = $attributes['clientId'];
127 $embed .= Helper::embed_content_share($content_id, $attributes);
128 }
129 Helper::display_password_form($client_id, $embed, $pass_hash_key, $attributes);
130 }
131 ?>
132 </div>
133 </div>
134 </div>
135 </div>
136 <?php
137
138 echo embedpress_render_block_style($attributes);
139
140
141 return ob_get_clean();
142
143
144 }
145 }
146
147 /**
148 * Make style function for embedpress render block
149 */
150
151 function embedpress_render_block_style($attributes)
152 {
153
154 $uniqid = !empty($attributes['url']) ? '.ose-uid-' . md5($attributes['url']) : '';
155
156 $_iscustomlogo = '';
157
158 if(!empty($attributes['customlogo'])){
159 $_iscustomlogo = $uniqid.' img.watermark.ep-custom-logo {
160 display: block !important;
161 }';
162 }
163 $youtubeStyles = '<style>
164 ' . esc_attr($uniqid) . ' {
165 width: ' . esc_attr($attributes['width']) . 'px !important;
166 height: ' . esc_attr($attributes['height']) . 'px;
167 max-width: 100%;
168 }
169
170 ' . esc_attr($uniqid) . '>iframe {
171 height: ' . esc_attr($attributes['height']) . 'px !important;
172 max-height: ' . esc_attr($attributes['height']) . 'px !important;
173 width: 100%;
174 }
175
176 ' . esc_attr($uniqid) . ' .wistia_embed {
177 max-width: 100%;
178 }
179
180 .alignright .ose-wistia' . esc_attr($uniqid) .'{
181 margin-left: auto;
182 }
183 .alignleft .ose-wistia' . esc_attr($uniqid) .'{
184 margin-right: auto;
185 }
186 .aligncenter .ose-wistia' . esc_attr($uniqid) .'{
187 margin: auto;
188 }
189 '.$uniqid.' img.watermark{
190 display: none;
191 }
192 '.$_iscustomlogo.'
193 </style>';
194
195 if($attributes['videosize'] == 'responsive') {
196 $youtubeStyles = '<style>
197 ' . esc_attr($uniqid) . ' {
198 position: relative;
199 width: ' . esc_attr($attributes['width']) . 'px !important;
200 height: 0;
201 padding-top: 56.25%;
202 max-width: 100%;
203 }
204
205 .ose-wistia{
206 height: auto !important;
207 padding-top: 0;
208 }
209
210 ' . esc_attr($uniqid) . ' > iframe {
211 position: absolute;
212 top: 0;
213 left: 0;
214 width: 100%;
215 height: 100%;
216 max-height:100%!important;
217 }
218
219 .ep-video-responsive{
220 display: inline-block!important;
221 max-width: 100%;
222 }
223 '.$uniqid.' img.watermark{
224 display: none;
225 }
226 '.$_iscustomlogo.'
227 </style>';
228 }
229
230 return $youtubeStyles;
231 }
232 ?>