-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjoomdev-wpc-shortcodes.php
152 lines (129 loc) · 4.71 KB
/
joomdev-wpc-shortcodes.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<?php
// add_action('the_content', 'do_shortcode', 10);
// add_filter('the_content', 'do_shortcode', 10);
add_shortcode('joomdev-wpc-pros-cons', 'joomdev_wpc_pros_cons');
function joomdev_wpc_pros_cons($atts, $content){
global $JoomDev_wpc_options;
$default = array(
'disable_title' => 'no',
'title' => 'Title Here',
'pros_title' => 'Pros',
'cons_title' => 'Cons',
'button_text' => 'Get it now',
'verdict_text' => '',
'disable_button' => 'no',
'button_link' => '',
'button_link_target' => '_SELF',
'button_rel_attr' => 'nofollow',
'wpc_style' => 'wppc-view1',
'title_tag' => 'H3',
);
$atts = shortcode_atts(
$default,
$atts,
'joomdev-wpc-pros-cons'
);
extract($atts);
// get pros and cons
$p1 = get_shortcode_regex(array('joomdev-wpc-pros'));
$p2 = get_shortcode_regex(array('joomdev-wpc-cons'));
$pros = '';
if ( preg_match_all( '/'. $p1 .'/s', $content, $m1 ) && array_key_exists( 2, $m1 ) && in_array( 'joomdev-wpc-pros', $m1[2] )) {
$pros = $m1[5][0];
}
$cons = '';
if ( preg_match_all( '/'. $p2 .'/s', $content, $m2 ) && array_key_exists( 2, $m2 ) && in_array( 'joomdev-wpc-cons', $m2[2] )){
$cons = $m2[5][0];
}
ob_start();
?>
<style type="text/css">
.wp-classic-pros-cons {
background: <?php echo $JoomDev_wpc_options['box_background_color'];
?>;
<?php if($JoomDev_wpc_options['disable_box_border']=='yes') {
echo 'border: none;';
}
else {
?>border: <?php echo $JoomDev_wpc_options['box_border_style'] . " ". $JoomDev_wpc_options['box_border_width'] . "px " . $JoomDev_wpc_options['box_border_color'];
?>;
<?php
}
?>
}
.wp-classic-pros-cons .wppc-btn-wrapper .jd-wppc-btn {
color: <?php echo $JoomDev_wpc_options['button_text_color']; ?>;
background: <?php echo $JoomDev_wpc_options['button_color']; ?>;
}
.wp-classic-pros-cons .wppc-btn-wrapper .jd-wppc-btn {
border-radius: <?php echo $JoomDev_wpc_options['button_shape'] . "px"; ?>;
}
.wp-classic-pros-cons .wppc-verdict-wrapper {
color: <?php echo $JoomDev_wpc_options['verdict_text_color']; ?>;
font-size: <?php echo $JoomDev_wpc_options['verdict_font_size'] . "px"; ?>;
}
.wp-classic-pros-cons .wppc-header .wppc-box-symbol img {
width: <?php echo $JoomDev_wpc_options['icons_font_size'] . "px"; ?>;
}
</style>
<div class="wp-classic-pros-cons <?php echo $wpc_style; ?>">
<?php
if($disable_title == 'yes'){
// do nothing
}
else {
echo "<$title_tag class='wppc-pros-cons-heading'>$title</$title_tag>";
}
?>
<div class="wppc-boxs">
<div class="wppc-box pros-content">
<div class="wppc-header">
<?php if ( ! ($wpc_style == 'wppc-view2' || $wpc_style == 'wppc-view3') ) { ?>
<div class="wppc-box-symbol">
<img src="<?php echo plugins_url( JOOMDEV_WPC_DIR . "/assets/icons/thumbs-up-regular.svg" ); ?>">
</div>
<?php } ?>
<h4 class="wppc-content-title cons-title"><?php echo $pros_title; ?></h4>
</div>
<?php echo $pros; ?>
</div>
<div class="wppc-box cons-content">
<div class="wppc-header">
<?php if ( ! ($wpc_style == 'wppc-view2' || $wpc_style == 'wppc-view3') ) { ?>
<div class="wppc-box-symbol">
<img src="<?php echo plugins_url( JOOMDEV_WPC_DIR . "/assets/icons/thumbs-down-regular.svg" ); ?>">
</div>
<?php } ?>
<h4 class="wppc-content-title cons-title"><?php echo $cons_title; ?></h4>
</div>
<?php echo $cons; ?>
</div>
</div>
<?php if ( ! empty($verdict_text) ) { ?>
<div class="wppc-verdict-wrapper">
<?php echo html_entity_decode($verdict_text); ?>
</div>
<?php } ?>
<?php
if($disable_button == 'yes') {
// do nothing
}
else {
?>
<div class="wppc-btn-wrapper">
<a href="<?php echo $button_link; ?>" target="<?php echo $button_link_target; ?>" rel="<?php echo $button_rel_attr; ?>" class="jd-wppc-btn wp-block-button__link">
<?php echo $button_text; ?>
</a>
</div>
<?php } ?>
</div>
<?php
return ob_get_clean();
}
// add_shortcode('joomdev-wpc-pros', 'joomdev_wpc_pros');
function joomdev_wpc_pros($atts, $content){
}
// add_shortcode('joomdev-wpc-cons', 'joomdev_wpc_cons');
function joomdev_wpc_cons($atts, $content){
}
// file ends here...