non-sshare-styles
1 month ago
class-hustle-decorator-non-sshare.php
3 months ago
class-hustle-decorator-sshare.php
3 months ago
class-hustle-decorator_abstract.php
3 years ago
class-hustle-module-preview.php
1 year ago
hustle-module-front-ajax.php
4 days ago
hustle-module-front.php
4 days ago
hustle-module-inline-style-queue.php
3 months ago
hustle-module-renderer.php
1 month ago
hustle-renderer-abstract.php
3 months ago
hustle-renderer-sshare.php
4 days ago
class-hustle-decorator-sshare.php
392 lines
| 1 | <?php |
| 2 | /** |
| 3 | * File for Hustle_Decorator_Sshare class. |
| 4 | * |
| 5 | * @package Hustle |
| 6 | * @since 4.3.0 |
| 7 | */ |
| 8 | |
| 9 | /** |
| 10 | * Class Hustle_Decorator_Sshare. |
| 11 | * Handles the styling for the Social Sharing modules. |
| 12 | * |
| 13 | * @since 4.3.0 |
| 14 | */ |
| 15 | class Hustle_Decorator_Sshare extends Hustle_Decorator_Abstract { |
| 16 | |
| 17 | /** |
| 18 | * Get styles |
| 19 | * |
| 20 | * @return string |
| 21 | */ |
| 22 | protected function get_styles() { |
| 23 | $prefix = '.hustle-ui[data-id="' . $this->module->module_id . '"]'; |
| 24 | |
| 25 | $styles = ''; |
| 26 | |
| 27 | $module_id = $this->module->id; |
| 28 | |
| 29 | $content = (array) $this->module->content; |
| 30 | $display = (array) $this->module->display; |
| 31 | $design = $this->design; |
| 32 | |
| 33 | /** |
| 34 | * Floating Social |
| 35 | * |
| 36 | * @since 1.0 |
| 37 | */ |
| 38 | if ( (bool) $display['float_desktop_enabled'] || (bool) $display['float_mobile_enabled'] ) { |
| 39 | |
| 40 | $box_shadow = sprintf( |
| 41 | '%spx %spx %spx %spx %s', |
| 42 | $design['floating_drop_shadow_x'], |
| 43 | $design['floating_drop_shadow_y'], |
| 44 | $design['floating_drop_shadow_blur'], |
| 45 | $design['floating_drop_shadow_spread'], |
| 46 | $design['floating_drop_shadow_color'] |
| 47 | ); |
| 48 | |
| 49 | // Custom position for desktops. |
| 50 | if ( (bool) $display['float_desktop_enabled'] ) { |
| 51 | |
| 52 | $desktop_x_offset = ( ! empty( $display['float_desktop_offset_x'] ) ) ? $display['float_desktop_offset_x'] : '0'; |
| 53 | $desktop_y_offset = ( ! empty( $display['float_desktop_offset_y'] ) ) ? $display['float_desktop_offset_y'] : '0'; |
| 54 | |
| 55 | $styles .= '@media screen and (min-width: ' . esc_attr( $this->bp_desktop ) . 'px) {'; |
| 56 | |
| 57 | if ( 'center' !== $display['float_desktop_position'] ) { |
| 58 | |
| 59 | $styles .= sprintf( |
| 60 | $prefix . '.hustle-float.hustle-displaying-in-large[data-desktop="true"][data-desktop-positionx="%1$s"] { %1$s: %2$spx !important }', |
| 61 | esc_html( $display['float_desktop_position'] ), |
| 62 | esc_attr( $desktop_x_offset ) |
| 63 | ); |
| 64 | } |
| 65 | |
| 66 | $styles .= sprintf( |
| 67 | $prefix . '.hustle-float.hustle-displaying-in-large[data-desktop="true"][data-desktop-positiony="%1$s"] { %1$s: %2$spx !important }', |
| 68 | esc_html( $display['float_desktop_position_y'] ), |
| 69 | esc_attr( $desktop_y_offset ) |
| 70 | ); |
| 71 | |
| 72 | $styles .= '}'; |
| 73 | } |
| 74 | |
| 75 | // Custom position for mobiles. |
| 76 | if ( (bool) $display['float_mobile_enabled'] ) { |
| 77 | |
| 78 | $mobile_x_offset = ( ! empty( $display['float_mobile_offset_x'] ) ) ? $display['float_mobile_offset_x'] : '0'; |
| 79 | $mobile_y_offset = ( ! empty( $display['float_mobile_offset_y'] ) ) ? $display['float_mobile_offset_y'] : '0'; |
| 80 | |
| 81 | $styles .= '@media screen and (max-width: ' . esc_attr( $this->bp_mobile ) . 'px) {'; |
| 82 | |
| 83 | if ( 'center' !== $display['float_mobile_position'] ) { |
| 84 | |
| 85 | $styles .= sprintf( |
| 86 | $prefix . '.hustle-float.hustle-displaying-in-small[data-mobiles="true"][data-mobiles-positionx="%1$s"] { %1$s: %2$spx !important }', |
| 87 | esc_html( $display['float_mobile_position'] ), |
| 88 | esc_attr( $mobile_x_offset ) |
| 89 | ); |
| 90 | } |
| 91 | |
| 92 | $styles .= sprintf( |
| 93 | $prefix . '.hustle-float.hustle-displaying-in-small[data-mobiles="true"][data-mobiles-positiony="%1$s"] { %1$s: %2$spx !important }', |
| 94 | esc_html( $display['float_mobile_position_y'] ), |
| 95 | esc_attr( $mobile_y_offset ) |
| 96 | ); |
| 97 | |
| 98 | $styles .= '}'; |
| 99 | } |
| 100 | |
| 101 | // Main background. |
| 102 | $styles .= sprintf( |
| 103 | $prefix . '.hustle-float .hustle-social { background-color: %s; }', |
| 104 | $design['floating_bg_color'] |
| 105 | ); |
| 106 | |
| 107 | // Container shadow. |
| 108 | if ( (bool) $design['floating_drop_shadow'] ) { |
| 109 | |
| 110 | $styles .= sprintf( |
| 111 | $prefix . '.hustle-float .hustle-social { box-shadow: %s; -moz-box-shadow: %s; -webkit-box-shadow: %s; }', |
| 112 | $box_shadow, |
| 113 | $box_shadow, |
| 114 | $box_shadow |
| 115 | ); |
| 116 | } |
| 117 | |
| 118 | // Counter colors. |
| 119 | if ( (bool) $content['counter_enabled'] ) { |
| 120 | |
| 121 | // Counter text. |
| 122 | $styles .= sprintf( |
| 123 | $prefix . '.hustle-float .hustle-social .hustle-counter { color: %s; }', |
| 124 | $design['floating_counter_color'] |
| 125 | ); |
| 126 | |
| 127 | // DESIGN: Default. |
| 128 | if ( 'flat' === $design['icon_style'] ) { |
| 129 | |
| 130 | // Counter border. |
| 131 | $styles .= sprintf( |
| 132 | $prefix . '.hustle-float .hustle-social.hustle-social--default[data-custom="true"] ul:not(.hustle-counter--none) a[class*="hustle-share-"] { border-color: %s; }', |
| 133 | $design['floating_counter_border'] |
| 134 | ); |
| 135 | } |
| 136 | |
| 137 | // DESIGN: Rounded. |
| 138 | if ( 'rounded' === $design['icon_style'] ) { |
| 139 | |
| 140 | // Counter border. |
| 141 | $styles .= sprintf( |
| 142 | $prefix . '.hustle-float .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 143 | $design['floating_counter_border'] |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | // DESIGN: Squared. |
| 148 | if ( 'squared' === $design['icon_style'] ) { |
| 149 | |
| 150 | // Counter border. |
| 151 | $styles .= sprintf( |
| 152 | $prefix . '.hustle-float .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 153 | $design['floating_counter_border'] |
| 154 | ); |
| 155 | } |
| 156 | } elseif ( (bool) $design['floating_customize_colors'] ) { // Icons custom color. |
| 157 | |
| 158 | // DESIGN: Default. |
| 159 | if ( 'flat' === $design['icon_style'] ) { |
| 160 | |
| 161 | // Element border. |
| 162 | $styles .= sprintf( |
| 163 | $prefix . '.hustle-float .hustle-social.hustle-social--default[data-custom="true"] ul.hustle-counter--none a[class*="hustle-share-"] { border-color: %s; }', |
| 164 | 'transparent' |
| 165 | ); |
| 166 | } |
| 167 | |
| 168 | // DESIGN: Rounded. |
| 169 | if ( 'rounded' === $design['icon_style'] ) { |
| 170 | |
| 171 | // Element border. |
| 172 | $styles .= sprintf( |
| 173 | $prefix . '.hustle-float .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 174 | $design['floating_icon_bg_color'] |
| 175 | ); |
| 176 | } |
| 177 | |
| 178 | // DESIGN: Squared. |
| 179 | if ( 'squared' === $design['icon_style'] ) { |
| 180 | |
| 181 | // Element border. |
| 182 | $styles .= sprintf( |
| 183 | $prefix . '.hustle-float .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 184 | $design['floating_icon_bg_color'] |
| 185 | ); |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | // Icons custom color. |
| 190 | if ( (bool) $design['floating_customize_colors'] ) { |
| 191 | |
| 192 | // DESIGN: Default. |
| 193 | if ( 'flat' === $design['icon_style'] ) { |
| 194 | |
| 195 | $styles .= sprintf( |
| 196 | $prefix . '.hustle-float .hustle-social.hustle-social--default[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { color: %s; }', |
| 197 | $design['floating_icon_color'] |
| 198 | ); |
| 199 | } |
| 200 | |
| 201 | // DESIGN: Outlined. |
| 202 | if ( 'outline' === $design['icon_style'] ) { |
| 203 | |
| 204 | $styles .= sprintf( |
| 205 | $prefix . '.hustle-float .hustle-social.hustle-social--outlined[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 206 | $design['floating_counter_border'] |
| 207 | ); |
| 208 | |
| 209 | $styles .= sprintf( |
| 210 | $prefix . '.hustle-float .hustle-social.hustle-social--outlined[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { color: %s; }', |
| 211 | $design['floating_icon_color'] |
| 212 | ); |
| 213 | } |
| 214 | |
| 215 | // DESIGN: Rounded. |
| 216 | if ( 'rounded' === $design['icon_style'] ) { |
| 217 | |
| 218 | $styles .= sprintf( |
| 219 | $prefix . '.hustle-float .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { background-color: %s; color: %s; }', |
| 220 | $design['floating_icon_bg_color'], |
| 221 | $design['floating_icon_color'] |
| 222 | ); |
| 223 | } |
| 224 | |
| 225 | // DESIGN: Squared. |
| 226 | if ( 'squared' === $design['icon_style'] ) { |
| 227 | |
| 228 | $styles .= sprintf( |
| 229 | $prefix . '.hustle-float .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { background-color: %s; color: %s; }', |
| 230 | $design['floating_icon_bg_color'], |
| 231 | $design['floating_icon_color'] |
| 232 | ); |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Inline Social |
| 239 | * |
| 240 | * @since 1.0 |
| 241 | */ |
| 242 | if ( (bool) $display['inline_enabled'] || (bool) $display['widget_enabled'] || (bool) $display['shortcode_enabled'] ) { |
| 243 | |
| 244 | $box_shadow = sprintf( |
| 245 | '%spx %spx %spx %spx %s', |
| 246 | $design['widget_drop_shadow_x'], |
| 247 | $design['widget_drop_shadow_y'], |
| 248 | $design['widget_drop_shadow_blur'], |
| 249 | $design['widget_drop_shadow_spread'], |
| 250 | $design['widget_drop_shadow_color'] |
| 251 | ); |
| 252 | |
| 253 | // Main background. |
| 254 | $styles .= sprintf( |
| 255 | $prefix . '.hustle-inline .hustle-social { background-color: %s; }', |
| 256 | $design['widget_bg_color'] |
| 257 | ); |
| 258 | |
| 259 | // Container shadow. |
| 260 | if ( (bool) $design['widget_drop_shadow'] ) { |
| 261 | |
| 262 | $styles .= sprintf( |
| 263 | $prefix . '.hustle-inline .hustle-social { box-shadow: %s; -moz-box-shadow: %s; -webkit-box-shadow: %s; }', |
| 264 | $box_shadow, |
| 265 | $box_shadow, |
| 266 | $box_shadow |
| 267 | ); |
| 268 | } |
| 269 | |
| 270 | // Counter colors. |
| 271 | if ( (bool) $content['counter_enabled'] ) { |
| 272 | |
| 273 | // Counter text. |
| 274 | $styles .= sprintf( |
| 275 | $prefix . '.hustle-inline .hustle-social .hustle-counter { color: %s; }', |
| 276 | $design['widget_counter_color'] |
| 277 | ); |
| 278 | |
| 279 | // DESIGN: Default. |
| 280 | if ( 'flat' === $design['icon_style'] ) { |
| 281 | |
| 282 | // Counter border. |
| 283 | $styles .= sprintf( |
| 284 | $prefix . '.hustle-inline .hustle-social.hustle-social--default[data-custom="true"] ul:not(.hustle-counter--none) a[class*="hustle-share-"] { border-color: %s; }', |
| 285 | $design['widget_counter_border'] |
| 286 | ); |
| 287 | } |
| 288 | |
| 289 | // DESIGN: Rounded. |
| 290 | if ( 'rounded' === $design['icon_style'] ) { |
| 291 | |
| 292 | // Counter border. |
| 293 | $styles .= sprintf( |
| 294 | $prefix . '.hustle-inline .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 295 | $design['widget_counter_border'] |
| 296 | ); |
| 297 | } |
| 298 | |
| 299 | // DESIGN: Squared. |
| 300 | if ( 'squared' === $design['icon_style'] ) { |
| 301 | |
| 302 | // Counter border. |
| 303 | $styles .= sprintf( |
| 304 | $prefix . '.hustle-inline .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 305 | $design['widget_counter_border'] |
| 306 | ); |
| 307 | } |
| 308 | } elseif ( (bool) $design['widget_customize_colors'] ) { // Icons custom color. |
| 309 | |
| 310 | // DESIGN: Default. |
| 311 | if ( 'flat' === $design['icon_style'] ) { |
| 312 | |
| 313 | // Element border. |
| 314 | $styles .= sprintf( |
| 315 | $prefix . '.hustle-inline .hustle-social.hustle-social--default[data-custom="true"] ul.hustle-counter--none a[class*="hustle-share-"] { border-color: %s; }', |
| 316 | 'transparent' |
| 317 | ); |
| 318 | } |
| 319 | |
| 320 | // DESIGN: Rounded. |
| 321 | if ( 'rounded' === $design['icon_style'] ) { |
| 322 | |
| 323 | // Element border. |
| 324 | $styles .= sprintf( |
| 325 | $prefix . '.hustle-inline .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 326 | $design['widget_icon_bg_color'] |
| 327 | ); |
| 328 | } |
| 329 | |
| 330 | // DESIGN: Squared. |
| 331 | if ( 'squared' === $design['icon_style'] ) { |
| 332 | |
| 333 | // Element border. |
| 334 | $styles .= sprintf( |
| 335 | $prefix . '.hustle-inline .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 336 | $design['widget_icon_bg_color'] |
| 337 | ); |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | // Icons custom color. |
| 342 | if ( (bool) $design['widget_customize_colors'] ) { |
| 343 | |
| 344 | // DESIGN: Default. |
| 345 | if ( 'flat' === $design['icon_style'] ) { |
| 346 | |
| 347 | $styles .= sprintf( |
| 348 | $prefix . '.hustle-inline .hustle-social.hustle-social--default[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { color: %s; }', |
| 349 | $design['widget_icon_color'] |
| 350 | ); |
| 351 | } |
| 352 | |
| 353 | // DESIGN: Outlined. |
| 354 | if ( 'outline' === $design['icon_style'] ) { |
| 355 | |
| 356 | $styles .= sprintf( |
| 357 | $prefix . '.hustle-inline .hustle-social.hustle-social--outlined[data-custom="true"] a[class*="hustle-share-"] { border-color: %s; }', |
| 358 | $design['widget_counter_border'] |
| 359 | ); |
| 360 | |
| 361 | $styles .= sprintf( |
| 362 | $prefix . '.hustle-inline .hustle-social.hustle-social--outlined[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { color: %s; }', |
| 363 | $design['widget_icon_color'] |
| 364 | ); |
| 365 | } |
| 366 | |
| 367 | // DESIGN: Rounded. |
| 368 | if ( 'rounded' === $design['icon_style'] ) { |
| 369 | |
| 370 | $styles .= sprintf( |
| 371 | $prefix . '.hustle-inline .hustle-social.hustle-social--rounded[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { background-color: %s; color: %s; }', |
| 372 | $design['widget_icon_bg_color'], |
| 373 | $design['widget_icon_color'] |
| 374 | ); |
| 375 | } |
| 376 | |
| 377 | // DESIGN: Squared. |
| 378 | if ( 'squared' === $design['icon_style'] ) { |
| 379 | |
| 380 | $styles .= sprintf( |
| 381 | $prefix . '.hustle-inline .hustle-social.hustle-social--squared[data-custom="true"] a[class*="hustle-share-"] [class*="hustle-icon-social-"] { background-color: %s; color: %s; }', |
| 382 | $design['widget_icon_bg_color'], |
| 383 | $design['widget_icon_color'] |
| 384 | ); |
| 385 | } |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | return $styles; |
| 390 | } |
| 391 | } |
| 392 |