| 1 |
<?php |
| 2 |
|
| 3 |
namespace ThemeAtelier\Darkify\Frontend; |
| 4 |
|
| 5 |
// If this file is called directly, abort. |
| 6 |
if (!defined('WPINC')) { |
| 7 |
die; |
| 8 |
} |
| 9 |
|
| 10 |
if (!class_exists('DarkifyShortcode')) { |
| 11 |
class DarkifyShortcode |
| 12 |
{ |
| 13 |
|
| 14 |
public $base_client; |
| 15 |
|
| 16 |
public function __construct($base_client) |
| 17 |
{ |
| 18 |
$this->base_client = $base_client; |
| 19 |
|
| 20 |
add_shortcode('darkify', array($this, 'darkify_shortcode_parser')); |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
public function darkify_shortcode_parser($atts, $content = null) |
| 25 |
{ |
| 26 |
if (!isset($atts['switch'])) { |
| 27 |
$atts = array(); |
| 28 |
$atts['switch'] = '1'; |
| 29 |
} |
| 30 |
|
| 31 |
return $this->darkify_client_view_maker($atts); |
| 32 |
} |
| 33 |
public function darkify_client_view_maker($atts) |
| 34 |
{ |
| 35 |
if (function_exists('wp_rand')) { |
| 36 |
$unique_id = wp_rand() . "_shortcode"; |
| 37 |
} |
| 38 |
$switch_styles = $this->base_client->utils->generateSwitchStylesForShortcode($atts); |
| 39 |
ob_start(); ?> |
| 40 |
|
| 41 |
<?php if (sizeof($switch_styles) > 0) { ?> |
| 42 |
<style type="text/css"> |
| 43 |
#darkify_switch_<?php echo esc_attr($unique_id); ?> { |
| 44 |
<?php foreach ($switch_styles as $key => $value) { ?><?php echo esc_attr($key); ?>: <?php echo esc_attr($value); ?>; |
| 45 |
<?php } ?> |
| 46 |
} |
| 47 |
</style> |
| 48 |
|
| 49 |
<?php } ?> |
| 50 |
|
| 51 |
<?php if ($atts['switch'] == "1") { |
| 52 |
wp_enqueue_style('theme-classic'); |
| 53 |
?> |
| 54 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style" style="position: relative;"> |
| 55 |
<div class="theme-toggle"> |
| 56 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" fill="currentColor" stroke-linecap="round" class="theme-toggle__classic" viewBox="0 0 32 32"> |
| 57 |
<clipPath id="theme-toggle__classic__cutout"> |
| 58 |
<path d="M0-5h30a1 1 0 0 0 9 13v24H0Z" /> |
| 59 |
</clipPath> |
| 60 |
<g clip-path="url(#theme-toggle__classic__cutout)"> |
| 61 |
<circle cx="16" cy="16" r="9.34" /> |
| 62 |
<g stroke="currentColor" stroke-width="1.5"> |
| 63 |
<path d="M16 5.5v-4" /> |
| 64 |
<path d="M16 30.5v-4" /> |
| 65 |
<path d="M1.5 16h4" /> |
| 66 |
<path d="M26.5 16h4" /> |
| 67 |
<path d="m23.4 8.6 2.8-2.8" /> |
| 68 |
<path d="m5.7 26.3 2.9-2.9" /> |
| 69 |
<path d="m5.8 5.8 2.8 2.8" /> |
| 70 |
<path d="m23.4 23.4 2.9 2.9" /> |
| 71 |
</g> |
| 72 |
</g> |
| 73 |
</svg> |
| 74 |
</div> |
| 75 |
</div> |
| 76 |
<?php } ?> |
| 77 |
<?php if ($atts['switch'] == "2") { |
| 78 |
wp_enqueue_style('theme-inner-moon'); |
| 79 |
?> |
| 80 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 81 |
<div class="theme-toggle"> |
| 82 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" fill="currentColor" class="theme-toggle__inner-moon" viewBox="0 0 32 32"> |
| 83 |
<path d="M27.5 11.5v-7h-7L16 0l-4.5 4.5h-7v7L0 16l4.5 4.5v7h7L16 32l4.5-4.5h7v-7L32 16l-4.5-4.5zM16 25.4a9.39 9.39 0 1 1 0-18.8 9.39 9.39 0 1 1 0 18.8z" /> |
| 84 |
<circle cx="16" cy="16" r="8.1" /> |
| 85 |
</svg> |
| 86 |
</div> |
| 87 |
|
| 88 |
</div> |
| 89 |
<?php } ?> |
| 90 |
<?php if ($atts['switch'] == "3") { |
| 91 |
wp_enqueue_style('theme-expand'); |
| 92 |
?> |
| 93 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 94 |
<div class="theme-toggle"> |
| 95 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" fill="currentColor" class="theme-toggle__expand" viewBox="0 0 32 32"> |
| 96 |
<clipPath id="theme-toggle__expand__cutout"> |
| 97 |
<path d="M0-11h25a1 1 0 0017 13v30H0Z" /> |
| 98 |
</clipPath> |
| 99 |
<g clip-path="url(#theme-toggle__expand__cutout)"> |
| 100 |
<circle cx="16" cy="16" r="8.4" /> |
| 101 |
<path d="M18.3 3.2c0 1.3-1 2.3-2.3 2.3s-2.3-1-2.3-2.3S14.7.9 16 .9s2.3 1 2.3 2.3zm-4.6 25.6c0-1.3 1-2.3 2.3-2.3s2.3 1 2.3 2.3-1 2.3-2.3 2.3-2.3-1-2.3-2.3zm15.1-10.5c-1.3 0-2.3-1-2.3-2.3s1-2.3 2.3-2.3 2.3 1 2.3 2.3-1 2.3-2.3 2.3zM3.2 13.7c1.3 0 2.3 1 2.3 2.3s-1 2.3-2.3 2.3S.9 17.3.9 16s1-2.3 2.3-2.3zm5.8-7C9 7.9 7.9 9 6.7 9S4.4 8 4.4 6.7s1-2.3 2.3-2.3S9 5.4 9 6.7zm16.3 21c-1.3 0-2.3-1-2.3-2.3s1-2.3 2.3-2.3 2.3 1 2.3 2.3-1 2.3-2.3 2.3zm2.4-21c0 1.3-1 2.3-2.3 2.3S23 7.9 23 6.7s1-2.3 2.3-2.3 2.4 1 2.4 2.3zM6.7 23C8 23 9 24 9 25.3s-1 2.3-2.3 2.3-2.3-1-2.3-2.3 1-2.3 2.3-2.3z" /> |
| 102 |
</g> |
| 103 |
</svg> |
| 104 |
</div> |
| 105 |
</div> |
| 106 |
|
| 107 |
<?php } ?> |
| 108 |
<?php if ($atts['switch'] == "4") { |
| 109 |
wp_enqueue_style('theme-within'); |
| 110 |
?> |
| 111 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 112 |
<div class="theme-toggle"> |
| 113 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="theme-toggle__within" height="1em" width="1em" viewBox="0 0 32 32" fill="currentColor"> |
| 114 |
<clipPath id="theme-toggle__within__clip"> |
| 115 |
<path d="M0 0h32v32h-32ZM6 16A1 1 0 0026 16 1 1 0 006 16" /> |
| 116 |
</clipPath> |
| 117 |
<g clip-path="url(#theme-toggle__within__clip)"> |
| 118 |
<path d="M30.7 21.3 27.1 16l3.7-5.3c.4-.5.1-1.3-.6-1.4l-6.3-1.1-1.1-6.3c-.1-.6-.8-.9-1.4-.6L16 5l-5.4-3.7c-.5-.4-1.3-.1-1.4.6l-1 6.3-6.4 1.1c-.6.1-.9.9-.6 1.3L4.9 16l-3.7 5.3c-.4.5-.1 1.3.6 1.4l6.3 1.1 1.1 6.3c.1.6.8.9 1.4.6l5.3-3.7 5.3 3.7c.5.4 1.3.1 1.4-.6l1.1-6.3 6.3-1.1c.8-.1 1.1-.8.7-1.4zM16 25.1c-5.1 0-9.1-4.1-9.1-9.1 0-5.1 4.1-9.1 9.1-9.1s9.1 4.1 9.1 9.1c0 5.1-4 9.1-9.1 9.1z" /> |
| 119 |
</g> |
| 120 |
<path class="theme-toggle__within__circle" d="M16 7.7c-4.6 0-8.2 3.7-8.2 8.2s3.6 8.4 8.2 8.4 8.2-3.7 8.2-8.2-3.6-8.4-8.2-8.4zm0 14.4c-3.4 0-6.1-2.9-6.1-6.2s2.7-6.1 6.1-6.1c3.4 0 6.1 2.9 6.1 6.2s-2.7 6.1-6.1 6.1z" /> |
| 121 |
<path class="theme-toggle__within__inner" d="M16 9.5c-3.6 0-6.4 2.9-6.4 6.4s2.8 6.5 6.4 6.5 6.4-2.9 6.4-6.4-2.8-6.5-6.4-6.5z" /> |
| 122 |
</svg> |
| 123 |
</div> |
| 124 |
|
| 125 |
</div> |
| 126 |
<?php } ?> |
| 127 |
<?php if ($atts['switch'] == "5") { |
| 128 |
wp_enqueue_style('theme-around'); |
| 129 |
?> |
| 130 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 131 |
<div class="theme-toggle"> |
| 132 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" fill="currentColor" class="theme-toggle__around" viewBox="0 0 32 32"> |
| 133 |
<clipPath id="theme-toggle__around__cutout"> |
| 134 |
<path d="M0 0h42v30a1 1 0 00-16 13H0Z" /> |
| 135 |
</clipPath> |
| 136 |
<g clip-path="url(#theme-toggle__around__cutout)"> |
| 137 |
<circle cx="16" cy="16" r="8.4" /> |
| 138 |
<g> |
| 139 |
<circle cx="16" cy="3.3" r="2.3" /> |
| 140 |
<circle cx="27" cy="9.7" r="2.3" /> |
| 141 |
<circle cx="27" cy="22.3" r="2.3" /> |
| 142 |
<circle cx="16" cy="28.7" r="2.3" /> |
| 143 |
<circle cx="5" cy="22.3" r="2.3" /> |
| 144 |
<circle cx="5" cy="9.7" r="2.3" /> |
| 145 |
</g> |
| 146 |
</g> |
| 147 |
</svg> |
| 148 |
</div> |
| 149 |
|
| 150 |
</div> |
| 151 |
<?php } ?> |
| 152 |
<?php if ($atts['switch'] == "6") { |
| 153 |
wp_enqueue_style('theme-dark-side'); |
| 154 |
?> |
| 155 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 156 |
<div class="theme-toggle"> |
| 157 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" class="theme-toggle__dark-side" fill="currentColor" viewBox="0 0 32 32"> |
| 158 |
<path d="M16 .5C7.4.5.5 7.4.5 16S7.4 31.5 16 31.5 31.5 24.6 31.5 16 24.6.5 16 .5zm0 28.1V3.4C23 3.4 28.6 9 28.6 16S23 28.6 16 28.6z" /> |
| 159 |
</svg> |
| 160 |
</div> |
| 161 |
|
| 162 |
</div> |
| 163 |
<?php } ?> |
| 164 |
<?php if ($atts['switch'] == "7") { |
| 165 |
wp_enqueue_style('theme-horizon'); |
| 166 |
?> |
| 167 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 168 |
<div class="theme-toggle"> |
| 169 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" fill="currentColor" class="theme-toggle__horizon" viewBox="0 0 32 32"> |
| 170 |
<clipPath id="theme-toggle__horizon__mask"> |
| 171 |
<path d="M0 0h32v29h-32z" /> |
| 172 |
</clipPath> |
| 173 |
<path d="M30.7 29.9H1.3c-.7 0-1.3.5-1.3 1.1 0 .6.6 1 1.3 1h29.3c.7 0 1.3-.5 1.3-1.1.1-.5-.5-1-1.2-1z" /> |
| 174 |
<g clip-path="url(#theme-toggle__horizon__mask)"> |
| 175 |
<path d="M16 8.8c-3.4 0-6.1 2.8-6.1 6.1s2.7 6.3 6.1 6.3 6.1-2.8 6.1-6.1-2.7-6.3-6.1-6.3zm13.3 11L26 15l3.3-4.8c.3-.5.1-1.1-.5-1.2l-5.7-1-1-5.7c-.1-.6-.8-.8-1.2-.5L16 5.1l-4.8-3.3c-.5-.4-1.2-.1-1.3.4L8.9 8 3.2 9c-.6.1-.8.8-.5 1.2L6 15l-3.3 4.8c-.3.5-.1 1.1.5 1.2l5.7 1 1 5.7c.1.6.8.8 1.2.5L16 25l4.8 3.3c.5.3 1.1.1 1.2-.5l1-5.7 5.7-1c.7-.1.9-.8.6-1.3zM16 22.5A7.6 7.6 0 0 1 8.3 15c0-4.2 3.5-7.5 7.7-7.5s7.7 3.4 7.7 7.5c0 4.2-3.4 7.5-7.7 7.5z" /> |
| 176 |
</g> |
| 177 |
</svg> |
| 178 |
</div> |
| 179 |
|
| 180 |
</div> |
| 181 |
<?php } ?> |
| 182 |
<?php if ($atts['switch'] == "8") { |
| 183 |
wp_enqueue_style('theme-eclipse'); |
| 184 |
?> |
| 185 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 186 |
<div class="theme-toggle"> |
| 187 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" class="theme-toggle__eclipse" fill="currentColor" viewBox="0 0 32 32"> |
| 188 |
<clipPath id="theme-toggle__eclipse__cutout"> |
| 189 |
<path d="M0 0h64v32h-64zm36 16a1 1 0 0024 1 1 1 0 00-24-1" /> |
| 190 |
</clipPath> |
| 191 |
<g clip-path="url(#theme-toggle__eclipse__cutout)"> |
| 192 |
<circle cx="16" cy="16" r="16" /> |
| 193 |
</g> |
| 194 |
</svg> |
| 195 |
</div> |
| 196 |
</div> |
| 197 |
<?php } ?> |
| 198 |
<?php if ($atts['switch'] == "9") { |
| 199 |
wp_enqueue_style('theme-lightbulb'); |
| 200 |
?> |
| 201 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 202 |
<div class="theme-toggle"> |
| 203 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" class="theme-toggle__lightbulb" stroke-width="0.7" stroke="currentColor" fill="currentColor" stroke-linecap="round" viewBox="0 0 32 32"> |
| 204 |
<path stroke-width="0" d="M9.4 9.9c1.8-1.8 4.1-2.7 6.6-2.7 5.1 0 9.3 4.2 9.3 9.3 0 2.3-.8 4.4-2.3 6.1-.7.8-2 2.8-2.5 4.4 0 .2-.2.4-.5.4-.2 0-.4-.2-.4-.5v-.1c.5-1.8 2-3.9 2.7-4.8 1.4-1.5 2.1-3.5 2.1-5.6 0-4.7-3.7-8.5-8.4-8.5-2.3 0-4.4.9-5.9 2.5-1.6 1.6-2.5 3.7-2.5 6 0 2.1.7 4 2.1 5.6.8.9 2.2 2.9 2.7 4.9 0 .2-.1.5-.4.5h-.1c-.2 0-.4-.1-.4-.4-.5-1.7-1.8-3.7-2.5-4.5-1.5-1.7-2.3-3.9-2.3-6.1 0-2.3 1-4.7 2.7-6.5z" /> |
| 205 |
<path d="M19.8 28.3h-7.6" /> |
| 206 |
<path d="M19.8 29.5h-7.6" /> |
| 207 |
<path d="M19.8 30.7h-7.6" /> |
| 208 |
<path pathLength="1" class="theme-toggle__lightbulb__coil" fill="none" d="M14.6 27.1c0-3.4 0-6.8-.1-10.2-.2-1-1.1-1.7-2-1.7-1.2-.1-2.3 1-2.2 2.3.1 1 .9 1.9 2.1 2h7.2c1.1-.1 2-1 2.1-2 .1-1.2-1-2.3-2.2-2.3-.9 0-1.7.7-2 1.7 0 3.4 0 6.8-.1 10.2" /> |
| 209 |
<g class="theme-toggle__lightbulb__rays"> |
| 210 |
<path pathLength="1" d="M16 6.4V1.3" /> |
| 211 |
<path pathLength="1" d="M26.3 15.8h5.1" /> |
| 212 |
<path pathLength="1" d="m22.6 9 3.7-3.6" /> |
| 213 |
<path pathLength="1" d="M9.4 9 5.7 5.4" /> |
| 214 |
<path pathLength="1" d="M5.7 15.8H.6" /> |
| 215 |
</g> |
| 216 |
</svg> |
| 217 |
</div> |
| 218 |
|
| 219 |
</div> |
| 220 |
|
| 221 |
<?php } ?> |
| 222 |
<?php if ($atts['switch'] == "10") { |
| 223 |
wp_enqueue_style('theme-dark-inner'); |
| 224 |
?> |
| 225 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 226 |
<div class="theme-toggle"> |
| 227 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" class="theme-toggle__dark-inner" fill="currentColor" viewBox="0 0 32 32"> |
| 228 |
<path d="M16 9c3.9 0 7 3.1 7 7s-3.1 7-7 7" /> |
| 229 |
<path d="M16 .5C7.4.5.5 7.4.5 16S7.4 31.5 16 31.5 31.5 24.6 31.5 16 24.6.5 16 .5zm0 28.1V23c-3.9 0-7-3.1-7-7s3.1-7 7-7V3.4C23 3.4 28.6 9 28.6 16S23 28.6 16 28.6z" /> |
| 230 |
</svg> |
| 231 |
</div> |
| 232 |
|
| 233 |
</div> |
| 234 |
<?php } ?> |
| 235 |
<?php if ($atts['switch'] == "11") { |
| 236 |
wp_enqueue_style('theme-half-sun'); |
| 237 |
?> |
| 238 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 239 |
<div class="theme-toggle"> |
| 240 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" class="theme-toggle__half-sun" height="1em" width="1em" viewBox="0 0 32 32" fill="currentColor"> |
| 241 |
<path d="M27.5 11.5v-7h-7L16 0l-4.5 4.5h-7v7L0 16l4.5 4.5v7h7L16 32l4.5-4.5h7v-7L32 16l-4.5-4.5zM16 25.4V6.6c5.2 0 9.4 4.2 9.4 9.4s-4.2 9.4-9.4 9.4z" /> |
| 242 |
</svg> |
| 243 |
</div> |
| 244 |
|
| 245 |
</div> |
| 246 |
|
| 247 |
|
| 248 |
<?php } ?> |
| 249 |
<?php if ($atts['switch'] == "12") { |
| 250 |
wp_enqueue_style('theme-simple'); |
| 251 |
?> |
| 252 |
<div id="darkify_switch_<?php echo esc_attr($unique_id); ?>" onclick="darkify_switch_trigger()" class="darkify_switch darkify_switch_style"> |
| 253 |
<div class="theme-toggle"> |
| 254 |
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="50px" height="50px" class="theme-toggle__simple" fill="currentColor" viewBox="0 0 32 32"> |
| 255 |
<clipPath id="theme-toggle__simple__cutout"> |
| 256 |
<path d="M0-5h55v37h-55zm32 12a1 1 0 0025 0 1 1 0 00-25 0" /> |
| 257 |
</clipPath> |
| 258 |
<g clip-path="url(#theme-toggle__simple__cutout)"> |
| 259 |
<circle cx="16" cy="16" r="15" /> |
| 260 |
</g> |
| 261 |
</svg> |
| 262 |
</div> |
| 263 |
|
| 264 |
</div> |
| 265 |
<?php } ?> |
| 266 |
|
| 267 |
<?php return ob_get_clean(); |
| 268 |
} |
| 269 |
} |
| 270 |
} |
| 271 |
|