-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathembedx.php
59 lines (55 loc) · 1.41 KB
/
embedx.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Plugin Name: EmbedX
* Plugin URI: https://jeweltheme.com/embedx
* Description: Embed anything using iframe on WordPress
* Version: 1.0.0
* Author: Jewel Theme
* Author URI: https://jeweltheme.com
* Text Domain: embedx
* Domain Path: languages/
* License: GPLv3 or later
* License URI: https://www.gnu.org/licenses/gpl-3.0.html
*
* @package embedx
*/
/*
* don't call the file directly
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
//register shortcode
add_shortcode('embedx', 'embedx_iframe_shortcoe');
function embedx_iframe_shortcoe( $atts, $content=null ){
//validing all attribute
$atts = shortcode_atts(
array(
'login' => false,
'src' => '',
'width' => '',
'height' => '',
'class' => '',
'style' => '',
),$atts);
$login = $atts['login'];
//removing login attr
unset($atts['login']);
if (isset($atts['src']) && !empty($atts['src'])) {
$attr='';
foreach ($atts as $name => $value) {
if (isset($value) && !empty($value)) {
$attr .= $name.'="'.$value.'" ';
}
}
$html = "<iframe $attr></iframe>";
}
//checking need log in or not
if ($login !== false) {
if ( is_user_logged_in()) {
return $html;
}
return ;
}
else{
return $html;
}
}