| @@ -42,9 +42,30 @@ | ||
| 42 | 42 | { |
| 43 | 43 | return esc_html__('Next Step', 'wpfnl'); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | + /** | |
| 47 | + * Get WordPress user roles for display condition control. | |
| 48 | + * | |
| 49 | + * @return array | |
| 50 | + * @since 3.1.0 | |
| 51 | + */ | |
| 52 | + protected function get_wp_user_roles() | |
| 53 | + { | |
| 54 | + $roles = [ 'none' => esc_html__( 'None', 'wpfnl' ) ]; | |
| 46 | 55 | |
| 56 | + if ( ! function_exists( 'get_editable_roles' ) ) { | |
| 57 | + require_once ABSPATH . 'wp-admin/includes/user.php'; | |
| 58 | + } | |
| 59 | + | |
| 60 | + foreach ( get_editable_roles() as $role_key => $role_info ) { | |
| 61 | + $roles[ $role_key ] = $role_info['name']; | |
| 62 | + } | |
| 63 | + | |
| 64 | + return $roles; | |
| 65 | + } | |
| 66 | + | |
| 67 | + | |
| 47 | 68 | /** |
| 48 | 69 | * Set builder controls |
| 49 | 70 | * |
| 50 | 71 | * @since 3.1.0 |
| @@ -96,8 +117,59 @@ | ||
| 96 | 117 | 'default' => esc_html__( 'Next Step', 'wpfnl' ), |
| 97 | 118 | 'placeholder' => esc_html__( 'Next Step', 'wpfnl' ), |
| 98 | 119 | ]; |
| 99 | 120 | |
| 121 | + // Subtitle | |
| 122 | + $this->controls['subtitleSeparator'] = [ | |
| 123 | + 'type' => 'separator', | |
| 124 | + 'label' => esc_html__( 'Subtitle', 'wpfnl' ), | |
| 125 | + ]; | |
| 126 | + | |
| 127 | + $this->controls['enable_subtitle'] = [ | |
| 128 | + 'tab' => 'content', | |
| 129 | + 'label' => esc_html__( 'Enable Subtitle', 'wpfnl' ), | |
| 130 | + 'type' => 'checkbox', | |
| 131 | + 'default' => false, | |
| 132 | + ]; | |
| 133 | + | |
| 134 | + $this->controls['subtitle_text'] = [ | |
| 135 | + 'tab' => 'content', | |
| 136 | + 'label' => esc_html__( 'Subtitle Text', 'wpfnl' ), | |
| 137 | + 'type' => 'text', | |
| 138 | + 'default' => esc_html__( 'Click to continue', 'wpfnl' ), | |
| 139 | + 'placeholder' => esc_html__( 'Enter subtitle text', 'wpfnl' ), | |
| 140 | + 'required' => [ 'enable_subtitle', '=', true ], | |
| 141 | + ]; | |
| 142 | + | |
| 143 | + $this->controls['subtitleTypography'] = [ | |
| 144 | + 'tab' => 'content', | |
| 145 | + 'label' => esc_html__( 'Subtitle Typography', 'wpfnl' ), | |
| 146 | + 'type' => 'typography', | |
| 147 | + 'css' => [ | |
| 148 | + [ | |
| 149 | + 'property' => 'font', | |
| 150 | + 'selector' => '.wpfnl-button-subtitle', | |
| 151 | + ], | |
| 152 | + ], | |
| 153 | + 'exclude' => [ 'text-align', 'text-decoration', 'line-height' ], | |
| 154 | + 'required' => [ 'enable_subtitle', '=', true ], | |
| 155 | + ]; | |
| 156 | + | |
| 157 | + $this->controls['subtitleSpacing'] = [ | |
| 158 | + 'tab' => 'content', | |
| 159 | + 'label' => esc_html__( 'Subtitle Spacing Top', 'wpfnl' ), | |
| 160 | + 'type' => 'number', | |
| 161 | + 'units' => true, | |
| 162 | + 'css' => [ | |
| 163 | + [ | |
| 164 | + 'property' => 'margin-top', | |
| 165 | + 'selector' => '.wpfnl-button-subtitle', | |
| 166 | + ], | |
| 167 | + ], | |
| 168 | + 'default' => '2px', | |
| 169 | + 'required' => [ 'enable_subtitle', '=', true ], | |
| 170 | + ]; | |
| 171 | + | |
| 100 | 172 | $this->controls['size'] = [ |
| 101 | 173 | 'label' => esc_html__( 'Size', 'wpfnl' ), |
| 102 | 174 | 'type' => 'select', |
| 103 | 175 | 'options' => $this->control_options['buttonSizes'], |
| @@ -169,31 +241,201 @@ | ||
| 169 | 241 | 'placeholder' => esc_html__( 'Right', 'wpfnl' ), |
| 170 | 242 | 'required' => [ 'icon', '!=', '' ], |
| 171 | 243 | ]; |
| 172 | 244 | |
| 173 | - $this->controls['iconGap'] = [ | |
| 174 | - 'label' => esc_html__( 'Gap', 'wpfnl' ), | |
| 175 | - 'type' => 'number', | |
| 176 | - 'units' => true, | |
| 177 | - 'css' => [ | |
| 178 | - [ | |
| 179 | - 'property' => 'gap', | |
| 180 | - ], | |
| 245 | + // Responsive Display | |
| 246 | + $this->controls['responsiveSeparator'] = [ | |
| 247 | + 'label' => esc_html__( 'Responsive Display', 'wpfnl' ), | |
| 248 | + 'type' => 'separator', | |
| 249 | + ]; | |
| 250 | + | |
| 251 | + $this->controls['hide_on_desktop'] = [ | |
| 252 | + 'tab' => 'content', | |
| 253 | + 'label' => esc_html__( 'Hide on Desktop (≥ 1200px)', 'wpfnl' ), | |
| 254 | + 'type' => 'checkbox', | |
| 255 | + 'default' => false, | |
| 256 | + 'description' => esc_html__( 'Hide button on desktop devices (window width >= 1200px)', 'wpfnl' ), | |
| 257 | + ]; | |
| 258 | + | |
| 259 | + $this->controls['hide_on_tablet'] = [ | |
| 260 | + 'tab' => 'content', | |
| 261 | + 'label' => esc_html__( 'Hide on Tablet (768px – 1199px)', 'wpfnl' ), | |
| 262 | + 'type' => 'checkbox', | |
| 263 | + 'default' => false, | |
| 264 | + 'description' => esc_html__( 'Hide button on tablet devices (window width 768px - 1199px)', 'wpfnl' ), | |
| 265 | + ]; | |
| 266 | + | |
| 267 | + $this->controls['hide_on_mobile'] = [ | |
| 268 | + 'tab' => 'content', | |
| 269 | + 'label' => esc_html__( 'Hide on Mobile (≤ 767px)', 'wpfnl' ), | |
| 270 | + 'type' => 'checkbox', | |
| 271 | + 'default' => false, | |
| 272 | + 'description' => esc_html__( 'Hide button on mobile devices (window width <= 767px)', 'wpfnl' ), | |
| 273 | + ]; | |
| 274 | + | |
| 275 | + // Display Conditions | |
| 276 | + $this->controls['displayConditionSeparator'] = [ | |
| 277 | + 'label' => esc_html__( 'Display Conditions', 'wpfnl' ), | |
| 278 | + 'type' => 'separator', | |
| 279 | + ]; | |
| 280 | + | |
| 281 | + $this->controls['display_condition_type'] = [ | |
| 282 | + 'tab' => 'content', | |
| 283 | + 'label' => esc_html__( 'Display Condition', 'wpfnl' ), | |
| 284 | + 'type' => 'select', | |
| 285 | + 'options' => [ | |
| 286 | + 'none' => esc_html__( 'None', 'wpfnl' ), | |
| 287 | + 'user_state' => esc_html__( 'User State', 'wpfnl' ), | |
| 288 | + 'user_role' => esc_html__( 'User Role', 'wpfnl' ), | |
| 289 | + 'browser' => esc_html__( 'Browser', 'wpfnl' ), | |
| 290 | + 'operating_system' => esc_html__( 'Operating System', 'wpfnl' ), | |
| 291 | + 'day' => esc_html__( 'Day', 'wpfnl' ), | |
| 181 | 292 | ], |
| 182 | - 'required' => [ 'icon', '!=', '' ], | |
| 293 | + 'inline' => false, | |
| 294 | + 'default' => 'none', | |
| 183 | 295 | ]; |
| 184 | 296 | |
| 185 | - $this->controls['iconSpace'] = [ | |
| 186 | - 'label' => esc_html__( 'Space between', 'wpfnl' ), | |
| 297 | + // User State | |
| 298 | + $this->controls['hide_from_logged_in'] = [ | |
| 299 | + 'tab' => 'content', | |
| 300 | + 'label' => esc_html__( 'Hide From Logged In User', 'wpfnl' ), | |
| 187 | 301 | 'type' => 'checkbox', |
| 188 | - 'css' => [ | |
| 189 | - [ | |
| 190 | - 'property' => 'justify-content', | |
| 191 | - 'value' => 'space-between', | |
| 192 | - ], | |
| 302 | + 'default' => false, | |
| 303 | + 'required' => [ 'display_condition_type', '=', 'user_state' ], | |
| 304 | + ]; | |
| 305 | + | |
| 306 | + $this->controls['hide_from_logged_out'] = [ | |
| 307 | + 'tab' => 'content', | |
| 308 | + 'label' => esc_html__( 'Hide From Logged Out User', 'wpfnl' ), | |
| 309 | + 'type' => 'checkbox', | |
| 310 | + 'default' => false, | |
| 311 | + 'required' => [ 'display_condition_type', '=', 'user_state' ], | |
| 312 | + ]; | |
| 313 | + | |
| 314 | + // User Role | |
| 315 | + $this->controls['hide_for_user_role'] = [ | |
| 316 | + 'tab' => 'content', | |
| 317 | + 'label' => esc_html__( 'Hide For User Role', 'wpfnl' ), | |
| 318 | + 'type' => 'select', | |
| 319 | + 'options' => $this->get_wp_user_roles(), | |
| 320 | + 'default' => 'none', | |
| 321 | + 'required' => [ 'display_condition_type', '=', 'user_role' ], | |
| 322 | + ]; | |
| 323 | + | |
| 324 | + // Browser | |
| 325 | + $this->controls['hide_on_browser'] = [ | |
| 326 | + 'tab' => 'content', | |
| 327 | + 'label' => esc_html__( 'Hide On Browser', 'wpfnl' ), | |
| 328 | + 'type' => 'select', | |
| 329 | + 'options' => [ | |
| 330 | + 'none' => esc_html__( 'None', 'wpfnl' ), | |
| 331 | + 'mozilla' => esc_html__( 'Mozilla Firefox', 'wpfnl' ), | |
| 332 | + 'chrome' => esc_html__( 'Google Chrome', 'wpfnl' ), | |
| 333 | + 'opera_mini' => esc_html__( 'Opera Mini', 'wpfnl' ), | |
| 334 | + 'safari' => esc_html__( 'Safari', 'wpfnl' ), | |
| 335 | + 'edge' => esc_html__( 'Microsoft Edge', 'wpfnl' ), | |
| 193 | 336 | ], |
| 194 | - 'required' => [ 'icon', '!=', '' ], | |
| 337 | + 'default' => 'none', | |
| 338 | + 'required' => [ 'display_condition_type', '=', 'browser' ], | |
| 195 | 339 | ]; |
| 340 | + | |
| 341 | + // Operating System | |
| 342 | + $this->controls['hide_on_os'] = [ | |
| 343 | + 'tab' => 'content', | |
| 344 | + 'label' => esc_html__( 'Hide On Operating System', 'wpfnl' ), | |
| 345 | + 'type' => 'select', | |
| 346 | + 'options' => [ | |
| 347 | + 'none' => esc_html__( 'None', 'wpfnl' ), | |
| 348 | + 'ios' => esc_html__( 'iOS', 'wpfnl' ), | |
| 349 | + 'android' => esc_html__( 'Android', 'wpfnl' ), | |
| 350 | + 'windows' => esc_html__( 'Windows', 'wpfnl' ), | |
| 351 | + 'macos' => esc_html__( 'MacOS', 'wpfnl' ), | |
| 352 | + 'linux' => esc_html__( 'Linux', 'wpfnl' ), | |
| 353 | + 'sunos' => esc_html__( 'SunOS', 'wpfnl' ), | |
| 354 | + 'openbsd' => esc_html__( 'OpenBSD', 'wpfnl' ), | |
| 355 | + ], | |
| 356 | + 'default' => 'none', | |
| 357 | + 'required' => [ 'display_condition_type', '=', 'operating_system' ], | |
| 358 | + ]; | |
| 359 | + | |
| 360 | + // Day | |
| 361 | + $this->controls['disable_on_days'] = [ | |
| 362 | + 'tab' => 'content', | |
| 363 | + 'label' => esc_html__( 'Select Days You Want To Disable', 'wpfnl' ), | |
| 364 | + 'type' => 'select', | |
| 365 | + 'multiple' => true, | |
| 366 | + 'options' => [ | |
| 367 | + 'monday' => esc_html__( 'Monday', 'wpfnl' ), | |
| 368 | + 'tuesday' => esc_html__( 'Tuesday', 'wpfnl' ), | |
| 369 | + 'wednesday' => esc_html__( 'Wednesday', 'wpfnl' ), | |
| 370 | + 'thursday' => esc_html__( 'Thursday', 'wpfnl' ), | |
| 371 | + 'friday' => esc_html__( 'Friday', 'wpfnl' ), | |
| 372 | + 'saturday' => esc_html__( 'Saturday', 'wpfnl' ), | |
| 373 | + 'sunday' => esc_html__( 'Sunday', 'wpfnl' ), | |
| 374 | + ], | |
| 375 | + 'default' => [], | |
| 376 | + 'required' => [ 'display_condition_type', '=', 'day' ], | |
| 377 | + ]; | |
| 378 | + | |
| 379 | + // Animation | |
| 380 | + $this->controls['animationSeparator'] = [ | |
| 381 | + 'label' => esc_html__( 'Animation', 'wpfnl' ), | |
| 382 | + 'type' => 'separator', | |
| 383 | + ]; | |
| 384 | + | |
| 385 | + $this->controls['entrance_animation'] = [ | |
| 386 | + 'tab' => 'content', | |
| 387 | + 'label' => esc_html__( 'Entrance Animation', 'wpfnl' ), | |
| 388 | + 'type' => 'select', | |
| 389 | + 'options' => [ | |
| 390 | + '' => esc_html__( 'None', 'wpfnl' ), | |
| 391 | + 'fadeIn' => esc_html__( 'Fade In', 'wpfnl' ), | |
| 392 | + 'fadeInUp' => esc_html__( 'Fade In Up', 'wpfnl' ), | |
| 393 | + 'fadeInDown' => esc_html__( 'Fade In Down', 'wpfnl' ), | |
| 394 | + 'fadeInLeft' => esc_html__( 'Fade In Left', 'wpfnl' ), | |
| 395 | + 'fadeInRight'=> esc_html__( 'Fade In Right', 'wpfnl' ), | |
| 396 | + 'zoomIn' => esc_html__( 'Zoom In', 'wpfnl' ), | |
| 397 | + 'zoomInUp' => esc_html__( 'Zoom In Up', 'wpfnl' ), | |
| 398 | + 'bounceIn' => esc_html__( 'Bounce In', 'wpfnl' ), | |
| 399 | + 'bounceInUp' => esc_html__( 'Bounce In Up', 'wpfnl' ), | |
| 400 | + 'slideInUp' => esc_html__( 'Slide In Up', 'wpfnl' ), | |
| 401 | + 'slideInLeft'=> esc_html__( 'Slide In Left', 'wpfnl' ), | |
| 402 | + 'slideInRight'=> esc_html__( 'Slide In Right', 'wpfnl' ), | |
| 403 | + 'flipInX' => esc_html__( 'Flip In X', 'wpfnl' ), | |
| 404 | + 'flipInY' => esc_html__( 'Flip In Y', 'wpfnl' ), | |
| 405 | + 'pulse' => esc_html__( 'Pulse', 'wpfnl' ), | |
| 406 | + 'tada' => esc_html__( 'Tada', 'wpfnl' ), | |
| 407 | + 'wobble' => esc_html__( 'Wobble', 'wpfnl' ), | |
| 408 | + ], | |
| 409 | + 'inline' => false, | |
| 410 | + 'placeholder' => esc_html__( 'None', 'wpfnl' ), | |
| 411 | + 'default' => '', | |
| 412 | + 'description' => esc_html__( 'Animation plays when the button enters the viewport on the live page.', 'wpfnl' ), | |
| 413 | + ]; | |
| 414 | + | |
| 415 | + // $this->controls['iconGap'] = [ | |
| 416 | + // 'label' => esc_html__( 'Gap', 'wpfnl' ), | |
| 417 | + // 'type' => 'number', | |
| 418 | + // 'units' => true, | |
| 419 | + // 'css' => [ | |
| 420 | + // [ | |
| 421 | + // 'property' => 'gap', | |
| 422 | + // ], | |
| 423 | + // ], | |
| 424 | + // 'required' => [ 'icon', '!=', '' ], | |
| 425 | + // ]; | |
| 426 | + | |
| 427 | + // $this->controls['iconSpace'] = [ | |
| 428 | + // 'label' => esc_html__( 'Space between', 'wpfnl' ), | |
| 429 | + // 'type' => 'checkbox', | |
| 430 | + // 'css' => [ | |
| 431 | + // [ | |
| 432 | + // 'property' => 'justify-content', | |
| 433 | + // 'value' => 'space-between', | |
| 434 | + // ], | |
| 435 | + // ], | |
| 436 | + // 'required' => [ 'icon', '!=', '' ], | |
| 437 | + // ]; | |
| 196 | 438 | } |
| 197 | 439 | |
| 198 | 440 | |
| 199 | 441 | /** |
| @@ -207,10 +449,109 @@ | ||
| 207 | 449 | */ |
| 208 | 450 | public function render() { |
| 209 | 451 | $settings = $this->settings; |
| 210 | 452 | |
| 211 | - $this->set_attribute( '_root', 'class', 'bricks-button' ); | |
| 453 | + // ---- Display Conditions ---------------------------------------- | |
| 454 | + $display_condition = ! empty( $settings['display_condition_type'] ) ? $settings['display_condition_type'] : 'none'; | |
| 212 | 455 | |
| 456 | + if ( $display_condition === 'user_state' ) { | |
| 457 | + $hide_logged_in = ! empty( $settings['hide_from_logged_in'] ); | |
| 458 | + $hide_logged_out = ! empty( $settings['hide_from_logged_out'] ); | |
| 459 | + | |
| 460 | + if ( $hide_logged_in && is_user_logged_in() ) { | |
| 461 | + return; | |
| 462 | + } | |
| 463 | + if ( $hide_logged_out && ! is_user_logged_in() ) { | |
| 464 | + return; | |
| 465 | + } | |
| 466 | + | |
| 467 | + } elseif ( $display_condition === 'user_role' ) { | |
| 468 | + $hide_for_user_role = ! empty( $settings['hide_for_user_role'] ) ? $settings['hide_for_user_role'] : 'none'; | |
| 469 | + | |
| 470 | + if ( $hide_for_user_role !== 'none' && is_user_logged_in() ) { | |
| 471 | + $user = wp_get_current_user(); | |
| 472 | + if ( in_array( $hide_for_user_role, $user->roles ) ) { | |
| 473 | + return; | |
| 474 | + } | |
| 475 | + } | |
| 476 | + | |
| 477 | + } elseif ( $display_condition === 'day' ) { | |
| 478 | + $disable_on_days = ! empty( $settings['disable_on_days'] ) ? $settings['disable_on_days'] : []; | |
| 479 | + | |
| 480 | + if ( ! empty( $disable_on_days ) && is_array( $disable_on_days ) ) { | |
| 481 | + $current_day = strtolower( date( 'l' ) ); // e.g., 'monday' | |
| 482 | + if ( in_array( $current_day, $disable_on_days ) ) { | |
| 483 | + return; | |
| 484 | + } | |
| 485 | + } | |
| 486 | + | |
| 487 | + } elseif ( $display_condition === 'browser' ) { | |
| 488 | + $hide_on_browser = ! empty( $settings['hide_on_browser'] ) ? $settings['hide_on_browser'] : 'none'; | |
| 489 | + | |
| 490 | + if ( $hide_on_browser !== 'none' ) { | |
| 491 | + $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; | |
| 492 | + $current_browser = ''; | |
| 493 | + | |
| 494 | + if ( strpos( $user_agent, 'edg' ) !== false ) { | |
| 495 | + $current_browser = 'edge'; | |
| 496 | + } elseif ( strpos( $user_agent, 'opr' ) !== false || strpos( $user_agent, 'opera' ) !== false ) { | |
| 497 | + $current_browser = 'opera_mini'; | |
| 498 | + } elseif ( strpos( $user_agent, 'chrome' ) !== false ) { | |
| 499 | + $current_browser = 'chrome'; | |
| 500 | + } elseif ( strpos( $user_agent, 'safari' ) !== false ) { | |
| 501 | + $current_browser = 'safari'; | |
| 502 | + } elseif ( strpos( $user_agent, 'firefox' ) !== false ) { | |
| 503 | + $current_browser = 'mozilla'; | |
| 504 | + } | |
| 505 | + | |
| 506 | + if ( $current_browser === $hide_on_browser ) { | |
| 507 | + return; | |
| 508 | + } | |
| 509 | + } | |
| 510 | + | |
| 511 | + } elseif ( $display_condition === 'operating_system' ) { | |
| 512 | + $hide_on_os = ! empty( $settings['hide_on_os'] ) ? $settings['hide_on_os'] : 'none'; | |
| 513 | + | |
| 514 | + if ( $hide_on_os !== 'none' ) { | |
| 515 | + $user_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? strtolower( $_SERVER['HTTP_USER_AGENT'] ) : ''; | |
| 516 | + $current_os = ''; | |
| 517 | + | |
| 518 | + if ( strpos( $user_agent, 'windows' ) !== false || strpos( $user_agent, 'win32' ) !== false || strpos( $user_agent, 'win64' ) !== false ) { | |
| 519 | + $current_os = 'windows'; | |
| 520 | + } elseif ( strpos( $user_agent, 'macintosh' ) !== false || strpos( $user_agent, 'mac os x' ) !== false ) { | |
| 521 | + $current_os = 'macos'; | |
| 522 | + } elseif ( strpos( $user_agent, 'linux' ) !== false && strpos( $user_agent, 'android' ) === false ) { | |
| 523 | + $current_os = 'linux'; | |
| 524 | + } elseif ( strpos( $user_agent, 'android' ) !== false ) { | |
| 525 | + $current_os = 'android'; | |
| 526 | + } elseif ( strpos( $user_agent, 'iphone' ) !== false || strpos( $user_agent, 'ipad' ) !== false || strpos( $user_agent, 'ipod' ) !== false ) { | |
| 527 | + $current_os = 'ios'; | |
| 528 | + } elseif ( strpos( $user_agent, 'sunos' ) !== false ) { | |
| 529 | + $current_os = 'sunos'; | |
| 530 | + } elseif ( strpos( $user_agent, 'openbsd' ) !== false ) { | |
| 531 | + $current_os = 'openbsd'; | |
| 532 | + } | |
| 533 | + | |
| 534 | + if ( $current_os === $hide_on_os ) { | |
| 535 | + return; | |
| 536 | + } | |
| 537 | + } | |
| 538 | + } | |
| 539 | + // ---- End Display Conditions ------------------------------------ | |
| 540 | + | |
| 541 | + $animation = ! empty( $settings['entrance_animation'] ) ? $settings['entrance_animation'] : ''; | |
| 542 | + $animation_class = $animation ? ' wpfnl-animation ' . esc_attr( $animation ) : ''; | |
| 543 | + | |
| 544 | + $is_bricks_editor = isset( $_GET['bricks'] ) && 'run' === $_GET['bricks']; | |
| 545 | + $active_editor_class = ''; | |
| 546 | + if ( $is_bricks_editor ) { | |
| 547 | + $bricks_editor_class = 'bricks-editor-active'; | |
| 548 | + }else { | |
| 549 | + $bricks_editor_class = ''; | |
| 550 | + } | |
| 551 | + | |
| 552 | + $this->set_attribute( '_root', 'class', 'bricks-button '.$animation_class.'' ); | |
| 553 | + | |
| 213 | 554 | if ( ! empty( $settings['size'] ) ) { |
| 214 | 555 | $this->set_attribute( '_root', 'class', $settings['size'] ); |
| 215 | 556 | } |
| 216 | 557 | |
| @@ -234,27 +575,63 @@ | ||
| 234 | 575 | |
| 235 | 576 | if ( isset( $settings['block'] ) ) { |
| 236 | 577 | $this->set_attribute( '_root', 'class', 'block' ); |
| 237 | 578 | } |
| 579 | + | |
| 238 | 580 | |
| 239 | - $output = "<a href='#' class='wpfnl-next-step-button' id='wpfunnels_next_step_controller' role='button'><span {$this->render_attributes( '_root' )} >"; | |
| 581 | + $icon = ! empty( $settings['icon'] ) ? self::render_icon( $settings['icon'] ) : false; | |
| 582 | + $icon_position = ! empty( $settings['iconPosition'] ) ? $settings['iconPosition'] : 'right'; | |
| 240 | 583 | |
| 241 | - $icon = ! empty( $settings['icon'] ) ? self::render_icon( $settings['icon'] ) : false; | |
| 242 | - $icon_position = ! empty( $settings['iconPosition'] ) ? $settings['iconPosition'] : 'right'; | |
| 584 | + $enable_subtitle = ! empty( $settings['enable_subtitle'] ); | |
| 585 | + $subtitle_text = ! empty( $settings['subtitle_text'] ) ? $settings['subtitle_text'] : ''; | |
| 243 | 586 | |
| 244 | - if ( $icon && $icon_position === 'left' ) { | |
| 245 | - $output .= $icon; | |
| 246 | - } | |
| 587 | + // Responsive display classes | |
| 588 | + $responsive_classes = ''; | |
| 589 | + if ( ! empty( $settings['hide_on_desktop'] ) ) { | |
| 590 | + $responsive_classes .= ' wpfnl-hide-desktop'; | |
| 591 | + } | |
| 592 | + if ( ! empty( $settings['hide_on_tablet'] ) ) { | |
| 593 | + $responsive_classes .= ' wpfnl-hide-tablet'; | |
| 594 | + } | |
| 595 | + if ( ! empty( $settings['hide_on_mobile'] ) ) { | |
| 596 | + $responsive_classes .= ' wpfnl-hide-mobile'; | |
| 597 | + } | |
| 247 | 598 | |
| 248 | - if ( ! empty( $settings['text'] ) ) { | |
| 249 | - $output .= trim( $settings['text'] ); | |
| 250 | - } | |
| 599 | + $output .= "<a href='#' class='wpfnl-next-step-button".' '.$responsive_classes.' '.$bricks_editor_class. ( $enable_subtitle && $subtitle_text ? ' wpfnl-has-subtitle' : '' ) . "' id='wpfunnels_next_step_controller' role='button'><span {$this->render_attributes( '_root' )} >"; | |
| 251 | 600 | |
| 252 | - if ( $icon && $icon_position === 'right' ) { | |
| 253 | - $output .= $icon; | |
| 254 | - } | |
| 601 | + if ( $enable_subtitle && $subtitle_text ) { | |
| 602 | + $output .= "<span class='icon-wrapper'>"; | |
| 603 | + if ( $icon && $icon_position === 'left' ) { | |
| 604 | + $output .= $icon; | |
| 605 | + } | |
| 255 | 606 | |
| 256 | - $output .= "</span></a>"; | |
| 607 | + if ( ! empty( $settings['text'] ) ) { | |
| 608 | + $output .= trim( $settings['text'] ); | |
| 609 | + } | |
| 610 | + | |
| 611 | + if ( $icon && $icon_position === 'right' ) { | |
| 612 | + $output .= $icon; | |
| 613 | + } | |
| 614 | + $output .= "</span>"; | |
| 615 | + $output .= '<small class="wpfnl-button-subtitle">' . esc_html( $subtitle_text ) . '</small>'; | |
| 616 | + | |
| 617 | + }else { | |
| 618 | + if ( $icon && $icon_position === 'left' ) { | |
| 619 | + $output .= $icon; | |
| 620 | + } | |
| 621 | + | |
| 622 | + if ( ! empty( $settings['text'] ) ) { | |
| 623 | + $output .= trim( $settings['text'] ); | |
| 624 | + } | |
| 625 | + | |
| 626 | + if ( $icon && $icon_position === 'right' ) { | |
| 627 | + $output .= $icon; | |
| 628 | + } | |
| 629 | + } | |
| 630 | + | |
| 631 | + $output .= "</span>"; | |
| 632 | + | |
| 633 | + $output .= "</a>"; | |
| 257 | 634 | |
| 258 | 635 | echo $output; |
| 259 | 636 | } |
| 260 | 637 | |