Admin
2 years ago
Frontend
2 years ago
classes
2 years ago
extra.php
2 years ago
filters.php
2 years ago
extra.php
765 lines
| 1 | <?php |
| 2 | // Exit if accessed directly |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | add_image_size( 'spe_270x152', 270, 152, true ); // Video Playlist Thumb |
| 8 | add_image_size( 'spe_120x70', 120, 70, true ); // Fullscreen slider Thumb 01 |
| 9 | |
| 10 | /** |
| 11 | * Constants for widgets badge |
| 12 | */ |
| 13 | if ( ! defined( 'SPEL_TEXT_BADGE' ) ) { |
| 14 | define('SPEL_TEXT_BADGE', |
| 15 | '<span class="spe-text-badge-control">' . esc_html__( 'SPIDER', 'spider-elements' ) . '</span>' |
| 16 | ); |
| 17 | } |
| 18 | |
| 19 | |
| 20 | /** |
| 21 | * @return bool |
| 22 | * Elementor is edit mode |
| 23 | */ |
| 24 | function spider_elements_is_edit() { |
| 25 | return \Elementor\Plugin::$instance->editor->is_edit_mode(); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * @return bool |
| 30 | * Elementor is preview mode |
| 31 | */ |
| 32 | function spider_elements_is_preview() { |
| 33 | return \Elementor\Plugin::$instance->preview->is_preview_mode(); |
| 34 | } |
| 35 | |
| 36 | |
| 37 | /** |
| 38 | * Elementor Title tags |
| 39 | */ |
| 40 | if ( ! function_exists( 'spel_get_title_tags' ) ) { |
| 41 | function spel_get_title_tags() { |
| 42 | return [ |
| 43 | 'h1' => esc_html__( 'H1', 'spider-elements' ), |
| 44 | 'h2' => esc_html__( 'H2', 'spider-elements' ), |
| 45 | 'h3' => esc_html__( 'H3', 'spider-elements' ), |
| 46 | 'h4' => esc_html__( 'H4', 'spider-elements' ), |
| 47 | 'h5' => esc_html__( 'H5', 'spider-elements' ), |
| 48 | 'h6' => esc_html__( 'H6', 'spider-elements' ), |
| 49 | 'div' => esc_html__( 'Div', 'spider-elements' ), |
| 50 | 'span' => esc_html__( 'Span', 'spider-elements' ), |
| 51 | 'p' => esc_html__( 'Paragraph', 'spider-elements' ), |
| 52 | ]; |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | |
| 57 | /** |
| 58 | * Echo button link attributes. |
| 59 | * |
| 60 | * @param array $settings_key |
| 61 | * @param bool $is_echo |
| 62 | */ |
| 63 | if ( ! function_exists( 'spel_button_link' ) ) { |
| 64 | function spel_button_link( $settings_key, $is_echo = true ) { |
| 65 | if ( $is_echo ) { |
| 66 | echo ! empty( $settings_key['url'] ) ? 'href="' . esc_url( $settings_key['url'] ) . '"' : ''; |
| 67 | echo $settings_key['is_external'] ? ' target="_blank"' : ''; |
| 68 | echo $settings_key['nofollow'] ? ' rel="nofollow"' : ''; |
| 69 | |
| 70 | if ( ! empty( $settings_key['custom_attributes'] ) ) { |
| 71 | $attrs = explode( ',', $settings_key['custom_attributes'] ); |
| 72 | |
| 73 | if ( is_array( $attrs ) ) { |
| 74 | foreach ( $attrs as $data ) { |
| 75 | $data_attrs = explode( '|', $data ); |
| 76 | echo ' ' . esc_attr( $data_attrs[0] ) . '="' . esc_attr( $data_attrs[1] ) . '"'; |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * Category IDs |
| 86 | * @return array |
| 87 | */ |
| 88 | if ( ! function_exists( 'spel_cat_ids') ) { |
| 89 | function spel_cat_ids() { |
| 90 | |
| 91 | $taxonomys = get_terms( array( |
| 92 | 'taxonomy' => 'category', |
| 93 | 'hide_empty' => true, |
| 94 | ) ); |
| 95 | $taxonomy = []; |
| 96 | if ( is_array( $taxonomys ) ) { |
| 97 | foreach ( $taxonomys as $cat_id ) { |
| 98 | $taxonomy[ $cat_id->term_id ] = $cat_id->name; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return $taxonomy; |
| 103 | |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | |
| 108 | |
| 109 | /** |
| 110 | * Day link to archive page |
| 111 | **/ |
| 112 | if ( ! function_exists( 'spel_day_link' ) ) { |
| 113 | function spel_day_link() { |
| 114 | $archive_year = get_the_time( 'Y' ); |
| 115 | $archive_month = get_the_time( 'm' ); |
| 116 | $archive_day = get_the_time( 'd' ); |
| 117 | echo esc_url( get_day_link( $archive_year, $archive_month, $archive_day ) ); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | |
| 122 | /** |
| 123 | * Get title excerpt length |
| 124 | * |
| 125 | * @param $settings |
| 126 | * @param $settings_key |
| 127 | * @param int $default |
| 128 | * |
| 129 | * @return string|void |
| 130 | */ |
| 131 | if ( ! function_exists( 'spel_get_title_length' ) ) { |
| 132 | function spel_get_title_length( $settings, $settings_key, $default = 10 ) { |
| 133 | |
| 134 | $title_length = ! empty( $settings[ $settings_key ] ) ? $settings[ $settings_key ] : $default; |
| 135 | $title = get_the_title() ? wp_trim_words( get_the_title(), $title_length, '' ) : the_title(); |
| 136 | |
| 137 | return $title; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | /** |
| 145 | * Post's excerpt text |
| 146 | * |
| 147 | * @param $settings_key |
| 148 | * @param bool $echo |
| 149 | * |
| 150 | * @return string |
| 151 | **/ |
| 152 | if ( ! function_exists( 'spel_get_excerpt_length' ) ) { |
| 153 | function spel_get_excerpt_length( $settings, $settings_key, $default = 10 ) { |
| 154 | |
| 155 | $excerpt_length = ! empty( $settings[ $settings_key ] ) ? $settings[ $settings_key ] : $default; |
| 156 | $excerpt = get_the_excerpt() ? wp_trim_words( |
| 157 | get_the_excerpt(), |
| 158 | $excerpt_length, |
| 159 | '...' |
| 160 | ) : wp_trim_words( get_the_content(), $excerpt_length, '...' ); |
| 161 | |
| 162 | return $excerpt; |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | |
| 167 | /** |
| 168 | * Get the first category name |
| 169 | * |
| 170 | * @param string $term |
| 171 | * |
| 172 | * @return string |
| 173 | */ |
| 174 | if ( ! function_exists( 'spel_get_first_taxonomy' ) ) { |
| 175 | function spel_get_first_taxonomy( $term = 'category' ) { |
| 176 | $cats = get_the_terms( get_the_ID(), $term ); |
| 177 | $cat = is_array( $cats ) ? $cats[0]->name : ''; |
| 178 | |
| 179 | return esc_html( $cat ); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | |
| 184 | /** |
| 185 | * Get the first category link |
| 186 | * |
| 187 | * @param string $term |
| 188 | * |
| 189 | * @return string |
| 190 | */ |
| 191 | if ( ! function_exists( 'spel_get_first_taxonomy_link' ) ) { |
| 192 | function spel_get_first_taxonomy_link( $term = 'category' ) { |
| 193 | |
| 194 | $cats = get_the_terms( get_the_ID(), $term ); |
| 195 | $cat = is_array( $cats ) ? get_category_link( $cats[0]->term_id ) : ''; |
| 196 | |
| 197 | return esc_url( $cat ); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | |
| 202 | /** |
| 203 | * Get categories array |
| 204 | * |
| 205 | * @param string $term |
| 206 | * |
| 207 | * @return array |
| 208 | */ |
| 209 | if ( ! function_exists( 'spel_get_categories' ) ) { |
| 210 | function spel_get_categories( $term = 'category' ) { |
| 211 | |
| 212 | $cats = get_terms( array( |
| 213 | 'taxonomy' => $term, |
| 214 | 'hide_empty' => true |
| 215 | ) ); |
| 216 | |
| 217 | $cat_array = []; |
| 218 | $cat_array['all'] = esc_html__( 'All', 'spider-elements' ); |
| 219 | |
| 220 | if ( is_array( $cats ) ) { |
| 221 | foreach ( $cats as $cat ) { |
| 222 | $cat_array[ $cat->term_id ] = $cat->name; |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | return $cat_array; |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | |
| 231 | /** |
| 232 | * Get categories list |
| 233 | * |
| 234 | * @param string $term |
| 235 | * |
| 236 | * @return string |
| 237 | */ |
| 238 | if ( ! function_exists( 'spel_get_post_category_list' ) ) { |
| 239 | function spel_get_post_category_list() { |
| 240 | $categories = get_categories(); |
| 241 | |
| 242 | if ( ! empty( $categories ) ) { |
| 243 | echo '<span class="blog-category">'; |
| 244 | |
| 245 | $category_names = array(); |
| 246 | |
| 247 | if ( is_array( $categories ) ) { |
| 248 | foreach ( $categories as $category ) { |
| 249 | $category_link = get_category_link( $category->term_id ); |
| 250 | $category_names[] = '<a href="' . esc_url( $category_link ) . '">' . esc_html( $category->name ) . '</a>'; |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | echo esc_html( implode( ', ', $category_names ) ); |
| 255 | |
| 256 | echo '</span>'; |
| 257 | } else { |
| 258 | echo esc_html__( 'No categories found.', 'spider-elements' ); |
| 259 | } |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | |
| 264 | /** |
| 265 | * Get author name array |
| 266 | * |
| 267 | * @param string $term |
| 268 | * |
| 269 | * @return array |
| 270 | */ |
| 271 | if ( ! function_exists( 'spel_get_post_author_name' ) ) { |
| 272 | function spel_get_post_author_name() { |
| 273 | global $post; |
| 274 | $byline = sprintf( |
| 275 | /* translators: %s: post author. */ |
| 276 | esc_html_x( 'By: %s', 'post author', 'spider-elements' ), |
| 277 | '<span class="author"><a class="url fn n" href="' . esc_url( get_author_posts_url( $post->post_author ) ) . '">' . esc_html( get_the_author_meta( |
| 278 | 'display_name', |
| 279 | $post->post_author |
| 280 | ) ) . '</a></span>' |
| 281 | ); |
| 282 | |
| 283 | echo wp_kses_post( $byline ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | /** |
| 288 | * Get Default Image Elementor |
| 289 | * |
| 290 | * @param $settins_key |
| 291 | * @param string $class |
| 292 | * @param string $alt |
| 293 | */ |
| 294 | if ( ! function_exists( 'spel_el_image' ) ) { |
| 295 | function spel_el_image( $settings_key = '', $alt = '', $class = '', $atts = [] ) { |
| 296 | if ( ! empty( $settings_key['id'] ) ) { |
| 297 | echo wp_get_attachment_image( $settings_key['id'], 'full', '', array( 'class' => $class ) ); |
| 298 | } elseif ( ! empty( $settings_key['url'] ) && empty( $settings_key['id'] ) ) { |
| 299 | $class = ! empty( $class ) ? "class='$class'" : ''; |
| 300 | $attss = ''; |
| 301 | if ( ! empty( $atts ) ) { |
| 302 | foreach ( $atts as $k => $att ) { |
| 303 | $attss .= "$k=" . "'$att'"; |
| 304 | } |
| 305 | } |
| 306 | echo "<img src='{$settings_key['url']}' $class alt='$alt' $attss>"; |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | |
| 312 | /** |
| 313 | * Get Default Image Elementor |
| 314 | * |
| 315 | * @param $settins_key |
| 316 | * @param string $class |
| 317 | * @param string $alt |
| 318 | */ |
| 319 | if ( ! function_exists( 'spel_el_image_caption' ) ) { |
| 320 | function spel_el_image_caption( $image_id = '' ) { |
| 321 | $img_attachment = get_post( $image_id ); |
| 322 | |
| 323 | return array( |
| 324 | 'alt' => get_post_meta( $img_attachment->ID, '_wp_attachment_image_alt', true ), |
| 325 | 'caption' => $img_attachment->post_excerpt, |
| 326 | 'href' => get_permalink( $img_attachment->ID ), |
| 327 | 'src' => $img_attachment->guid, |
| 328 | 'title' => $img_attachment->post_title |
| 329 | ); |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | |
| 334 | /** |
| 335 | * @param string $content Text content to filter. |
| 336 | * |
| 337 | * @return string Filtered content containing only the allowed HTML. |
| 338 | */ |
| 339 | if ( ! function_exists( 'spel_kses_post' ) ) { |
| 340 | function spel_kses_post( $content ) { |
| 341 | $allowed_tag = array( |
| 342 | 'strong' => [], |
| 343 | 'br' => [], |
| 344 | 'p' => [ |
| 345 | 'class' => [], |
| 346 | 'style' => [], |
| 347 | ], |
| 348 | 'i' => [ |
| 349 | 'class' => [], |
| 350 | 'style' => [], |
| 351 | ], |
| 352 | 'ul' => [ |
| 353 | 'class' => [], |
| 354 | 'style' => [], |
| 355 | ], |
| 356 | 'li' => [ |
| 357 | 'class' => [], |
| 358 | 'style' => [], |
| 359 | ], |
| 360 | 'span' => [ |
| 361 | 'class' => [], |
| 362 | 'style' => [], |
| 363 | ], |
| 364 | 'a' => [ |
| 365 | 'href' => [], |
| 366 | 'class' => [], |
| 367 | 'title' => [] |
| 368 | ], |
| 369 | 'div' => [ |
| 370 | 'class' => [], |
| 371 | 'style' => [], |
| 372 | ], |
| 373 | 'h1' => [ |
| 374 | 'class' => [], |
| 375 | 'style' => [] |
| 376 | ], |
| 377 | 'h2' => [ |
| 378 | 'class' => [], |
| 379 | 'style' => [] |
| 380 | ], |
| 381 | 'h3' => [ |
| 382 | 'class' => [], |
| 383 | 'style' => [] |
| 384 | ], |
| 385 | 'h4' => [ |
| 386 | 'class' => [], |
| 387 | 'style' => [] |
| 388 | ], |
| 389 | 'h5' => [ |
| 390 | 'class' => [], |
| 391 | 'style' => [] |
| 392 | ], |
| 393 | 'h6' => [ |
| 394 | 'class' => [], |
| 395 | 'style' => [] |
| 396 | ], |
| 397 | 'img' => [ |
| 398 | 'class' => [], |
| 399 | 'style' => [], |
| 400 | 'height' => [], |
| 401 | 'width' => [], |
| 402 | 'src' => [], |
| 403 | 'srcset' => [], |
| 404 | 'alt' => [], |
| 405 | ], |
| 406 | |
| 407 | ); |
| 408 | |
| 409 | return wp_kses( $content, $allowed_tag ); |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | |
| 414 | /** |
| 415 | * Tab data |
| 416 | * |
| 417 | * @param $getCats |
| 418 | * @param $schedule_cats |
| 419 | * |
| 420 | * @return array |
| 421 | */ |
| 422 | if ( ! function_exists( 'spel_get_tab_data' ) ) { |
| 423 | function spel_get_tab_data( $getCats, $schedule_cats ) { |
| 424 | $tab_data = []; |
| 425 | |
| 426 | foreach ( $getCats as $val ) { |
| 427 | $matching_data = []; |
| 428 | |
| 429 | foreach ( $schedule_cats as $data ) { |
| 430 | if ( $data['tab_title'] == $val ) { |
| 431 | $matching_data[] = $data; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | $tab_data[ $val ] = $matching_data; |
| 436 | } |
| 437 | |
| 438 | return $tab_data; |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | |
| 443 | /** |
| 444 | * Get reading time |
| 445 | * |
| 446 | * @param string $term |
| 447 | * |
| 448 | * @return string |
| 449 | */ |
| 450 | if ( ! function_exists( 'spel_get_reading_time' ) ) { |
| 451 | function spel_get_reading_time( $words_per_minute = 200 ) { |
| 452 | $content = get_post_field( 'post_content', get_the_ID() ); |
| 453 | $word_count = str_word_count( wp_strip_all_tags( $content ) ); |
| 454 | $reading_time = ceil( $word_count / $words_per_minute ); |
| 455 | $timer = _n( 'minute', 'minutes', $reading_time, 'spider-elements' ); |
| 456 | |
| 457 | return sprintf( '%d %s', $reading_time, $timer ); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | /** |
| 462 | * Render Dynamic Image |
| 463 | * @param $key |
| 464 | * @param $class |
| 465 | * @return void |
| 466 | */ |
| 467 | if ( ! function_exists( 'spel_dynamic_image' ) ) { |
| 468 | function spel_dynamic_image( $key, $size = 'full', $atts = [] ) { |
| 469 | $image = wp_get_attachment_image( $key['id'], $size, '', $atts ); |
| 470 | echo wp_kses( $image, [ |
| 471 | 'img' => [ |
| 472 | 'class' => [], |
| 473 | 'style' => [], |
| 474 | 'height' => [], |
| 475 | 'width' => [], |
| 476 | 'src' => [], |
| 477 | 'srcset' => [], |
| 478 | 'alt' => [], |
| 479 | ], |
| 480 | ]); |
| 481 | } |
| 482 | } |
| 483 | |
| 484 | |
| 485 | |
| 486 | /** |
| 487 | * Retrieve a list of posts based on specified parameters. |
| 488 | * |
| 489 | * @param string $post_type The post-type to query. |
| 490 | * @param int $limit The maximum number of posts to retrieve. |
| 491 | * @param string $search The search term for post-titles. |
| 492 | * |
| 493 | * @return array An associative array with post-IDs as keys and post-titles as values. |
| 494 | */ |
| 495 | if ( ! function_exists( 'spel_get_query_post_list' ) ) { |
| 496 | function spel_get_query_post_list( $post_type = 'any', $limit = -1, $search = '' ) { |
| 497 | $args = [ |
| 498 | 'post_type' => $post_type, |
| 499 | 'post_status' => 'publish', |
| 500 | 'posts_per_page' => $limit, |
| 501 | 's' => $search, // Search term |
| 502 | ]; |
| 503 | |
| 504 | $query = new WP_Query( $args ); |
| 505 | |
| 506 | $data = []; |
| 507 | if ( $query->have_posts() ) { |
| 508 | while ( $query->have_posts() ) { |
| 509 | $query->the_post(); |
| 510 | $data[ get_the_ID() ] = get_the_title(); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | wp_reset_postdata(); // Reset post data after custom query |
| 515 | |
| 516 | return $data; |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | |
| 521 | /** |
| 522 | * Get all elementor page templates |
| 523 | * |
| 524 | * @param null $type |
| 525 | * |
| 526 | * @return array |
| 527 | */ |
| 528 | if ( ! function_exists( 'spel_get_el_templates' ) ) { |
| 529 | function spel_get_el_templates( $type = null ) { |
| 530 | $options = []; |
| 531 | |
| 532 | if ( $type ) { |
| 533 | $args = [ |
| 534 | 'post_type' => 'elementor_library', |
| 535 | 'posts_per_page' => -1, |
| 536 | ]; |
| 537 | $args['tax_query'] = [ |
| 538 | [ |
| 539 | 'taxonomy' => 'elementor_library_type', |
| 540 | 'field' => 'slug', |
| 541 | 'terms' => $type, |
| 542 | ], |
| 543 | ]; |
| 544 | |
| 545 | $page_templates = get_posts( $args ); |
| 546 | |
| 547 | if ( ! empty( $page_templates ) && ! is_wp_error( $page_templates ) ) { |
| 548 | foreach ( $page_templates as $post ) { |
| 549 | $options[ $post->ID ] = $post->post_title; |
| 550 | } |
| 551 | } |
| 552 | } else { |
| 553 | $options = spel_get_query_post_list( 'elementor_library' ); |
| 554 | } |
| 555 | |
| 556 | return $options; |
| 557 | } |
| 558 | } |
| 559 | |
| 560 | |
| 561 | add_action( 'admin_init', function () { |
| 562 | |
| 563 | if ( isset( $_POST['elements-submit'] ) ) { |
| 564 | |
| 565 | // Retrieve the field values from the form |
| 566 | $accordion = isset( $_POST['docy_accordion'] ) ? sanitize_text_field( $_POST['docy_accordion'] ) : ''; |
| 567 | $alerts_box = isset( $_POST['docly_alerts_box'] ) ? sanitize_text_field( $_POST['docly_alerts_box'] ) : ''; |
| 568 | $animated_heading = isset( $_POST['spe_animated_heading'] ) ? sanitize_text_field( $_POST['spe_animated_heading'] ) : ''; |
| 569 | $after_before_widget = isset( $_POST['spe_after_before_widget'] ) ? sanitize_text_field( $_POST['spe_after_before_widget'] ) : ''; |
| 570 | $docy_blog_grid = isset( $_POST['docy_blog_grid'] ) ? sanitize_text_field( $_POST['docy_blog_grid'] ) : ''; |
| 571 | $spe_buttons = isset( $_POST['spe_buttons'] ) ? sanitize_text_field( $_POST['spe_buttons'] ) : ''; |
| 572 | $docly_cheatsheet = isset( $_POST['docly_cheatsheet'] ) ? sanitize_text_field( $_POST['docly_cheatsheet'] ) : ''; |
| 573 | $spe_counter = isset( $_POST['spe_counter'] ) ? sanitize_text_field( $_POST['spe_counter'] ) : ''; |
| 574 | $spe_instagram = isset( $_POST['spe_instagram'] ) ? sanitize_text_field( $_POST['spe_instagram'] ) : ''; |
| 575 | $docy_integrations = isset( $_POST['docy_integrations'] ) ? sanitize_text_field( $_POST['docy_integrations'] ) : ''; |
| 576 | $docly_list_item = isset( $_POST['docly_list_item'] ) ? sanitize_text_field( $_POST['docly_list_item'] ) : ''; |
| 577 | $spe_marquee_slides = isset( $_POST['spe_marquee_slides'] ) ? sanitize_text_field( $_POST['spe_marquee_slides'] ) : ''; |
| 578 | $landpagy_pricing_table_switcher = isset( $_POST['landpagy_pricing_table_switcher'] ) ? sanitize_text_field( $_POST['landpagy_pricing_table_switcher'] ) : ''; |
| 579 | $landpagy_pricing_table_tabs = isset( $_POST['landpagy_pricing_table_tabs'] ) ? sanitize_text_field( $_POST['landpagy_pricing_table_tabs'] ) : ''; |
| 580 | $spe_skill_showcase_widget = isset( $_POST['spe_skill_showcase_widget'] ) ? sanitize_text_field( $_POST['spe_skill_showcase_widget'] ) : ''; |
| 581 | $docy_tabs = isset( $_POST['docy_tabs'] ) ? sanitize_text_field( $_POST['docy_tabs'] ) : ''; |
| 582 | $docy_team_carousel = isset( $_POST['docy_team_carousel'] ) ? sanitize_text_field( $_POST['docy_team_carousel'] ) : ''; |
| 583 | $docy_testimonial = isset( $_POST['docy_testimonial'] ) ? sanitize_text_field( $_POST['docy_testimonial'] ) : ''; |
| 584 | $spe_timeline_widget = isset( $_POST['spe_timeline_widget'] ) ? sanitize_text_field( $_POST['spe_timeline_widget'] ) : ''; |
| 585 | $docy_videos_playlist = isset( $_POST['docy_videos_playlist'] ) ? sanitize_text_field( $_POST['docy_videos_playlist'] ) : ''; |
| 586 | $docy_video_popup = isset( $_POST['docy_video_popup'] ) ? sanitize_text_field( $_POST['docy_video_popup'] ) : ''; |
| 587 | $dual_button = isset( $_POST['spel_dual_button'] ) ? sanitize_text_field( $_POST['spel_dual_button'] ) : ''; |
| 588 | $icon_box = isset( $_POST['spel_icon_box'] ) ? sanitize_text_field( $_POST['spel_icon_box'] ) : ''; |
| 589 | $spe_global_switcher = isset( $_POST['spe_global_switcher'] ) ? sanitize_text_field( $_POST['spe_global_switcher'] ) : ''; |
| 590 | |
| 591 | // Create an array to store the field values |
| 592 | $data = array( |
| 593 | 'docy_accordion' => $accordion, |
| 594 | 'docly_alerts_box' => $alerts_box, |
| 595 | 'spe_animated_heading' => $animated_heading, |
| 596 | 'spe_after_before_widget' => $after_before_widget, |
| 597 | 'docy_blog_grid' => $docy_blog_grid, |
| 598 | 'spe_buttons' => $spe_buttons, |
| 599 | 'docly_cheatsheet' => $docly_cheatsheet, |
| 600 | 'spe_counter' => $spe_counter, |
| 601 | 'spe_instagram' => $spe_instagram, |
| 602 | 'docy_integrations' => $docy_integrations, |
| 603 | 'docly_list_item' => $docly_list_item, |
| 604 | 'spe_marquee_slides' => $spe_marquee_slides, |
| 605 | 'landpagy_pricing_table_switcher' => $landpagy_pricing_table_switcher, |
| 606 | 'landpagy_pricing_table_tabs' => $landpagy_pricing_table_tabs, |
| 607 | 'spe_skill_showcase_widget' => $spe_skill_showcase_widget, |
| 608 | 'docy_tabs' => $docy_tabs, |
| 609 | 'docy_team_carousel' => $docy_team_carousel, |
| 610 | 'docy_testimonial' => $docy_testimonial, |
| 611 | 'spe_timeline_widget' => $spe_timeline_widget, |
| 612 | 'docy_videos_playlist' => $docy_videos_playlist, |
| 613 | 'docy_video_popup' => $docy_video_popup, |
| 614 | 'spel_icon_box' => $icon_box, |
| 615 | 'spe_global_switcher' => $spe_global_switcher, |
| 616 | ); |
| 617 | |
| 618 | // Save the data in the options table using update_option |
| 619 | update_option( 'spe_widget_settings', $data ); |
| 620 | |
| 621 | } |
| 622 | |
| 623 | } ); |
| 624 | |
| 625 | |
| 626 | |
| 627 | // Dashboard Features Setting Save Data |
| 628 | add_action( 'admin_init', function () { |
| 629 | |
| 630 | if ( isset( $_POST['features-submit'] ) ) { |
| 631 | |
| 632 | // Retrieve the field values from the form |
| 633 | $smooth_animation = isset( $_POST['spel_smooth_animation'] ) ? sanitize_text_field( $_POST['spel_smooth_animation'] ) : ''; |
| 634 | $badge = isset( $_POST['spel_badge'] ) ? sanitize_text_field( $_POST['spel_badge'] ) : ''; |
| 635 | $reveal_animation = isset( $_POST['spel_reveal_animation'] ) ? sanitize_text_field( $_POST['spel_reveal_animation'] ) : ''; |
| 636 | |
| 637 | // Create an array to store the field values |
| 638 | $data = array( |
| 639 | 'spel_smooth_animation' => $smooth_animation, |
| 640 | 'spel_badge' => $badge, |
| 641 | 'spel_reveal_animation' => $reveal_animation, |
| 642 | ); |
| 643 | |
| 644 | // Save the data in the options table using update_option |
| 645 | update_option( 'spel_features_settings', $data ); |
| 646 | |
| 647 | } |
| 648 | |
| 649 | } ); |
| 650 | |
| 651 | |
| 652 | /** |
| 653 | * Get information about the server environment. |
| 654 | * |
| 655 | * @return array Server environment information. |
| 656 | */ |
| 657 | if ( ! function_exists( 'spel_get_environment_info' ) ) { |
| 658 | function spel_get_environment_info() { |
| 659 | |
| 660 | // Figure out cURL version, if installed. |
| 661 | $curl_version = ''; |
| 662 | if ( function_exists( 'curl_version' ) ) { |
| 663 | $curl_version = curl_version(); |
| 664 | $curl_version = $curl_version['version'] . ', ' . $curl_version['ssl_version']; |
| 665 | } |
| 666 | |
| 667 | // WP memory limit. |
| 668 | $wp_memory_limit = spel_readable_number(WP_MEMORY_LIMIT); |
| 669 | if ( function_exists( 'memory_get_usage' ) ) { |
| 670 | $wp_memory_limit = max( $wp_memory_limit, spel_readable_number( @ini_get( 'memory_limit' ) ) ); |
| 671 | } |
| 672 | |
| 673 | return array( |
| 674 | 'home_url' => get_option( 'home' ), |
| 675 | 'site_url' => get_option( 'siteurl' ), |
| 676 | 'version' => SPEL_VERSION, |
| 677 | 'wp_version' => get_bloginfo( 'version' ), |
| 678 | 'wp_multisite' => is_multisite(), |
| 679 | 'wp_memory_limit' => $wp_memory_limit, |
| 680 | 'wp_debug_mode' => ( defined( 'WP_DEBUG' ) && WP_DEBUG ), |
| 681 | 'wp_cron' => ! ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ), |
| 682 | 'language' => get_locale(), |
| 683 | 'external_object_cache' => wp_using_ext_object_cache(), |
| 684 | 'server_info' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? wp_unslash( $_SERVER['SERVER_SOFTWARE'] ) : '', |
| 685 | 'php_version' => phpversion(), |
| 686 | 'php_post_max_size' => spel_readable_number( ini_get( 'post_max_size' ) ), |
| 687 | 'php_max_execution_time' => ini_get( 'max_execution_time' ), |
| 688 | 'php_max_input_vars' => ini_get( 'max_input_vars' ), |
| 689 | 'curl_version' => $curl_version, |
| 690 | 'suhosin_installed' => extension_loaded( 'suhosin' ), |
| 691 | 'max_upload_size' => wp_max_upload_size(), |
| 692 | 'default_timezone' => date_default_timezone_get(), |
| 693 | 'fsockopen_or_curl_enabled' => ( function_exists( 'fsockopen' ) || function_exists( 'curl_init' ) ), |
| 694 | 'soapclient_enabled' => class_exists( 'SoapClient' ), |
| 695 | 'domdocument_enabled' => class_exists( 'DOMDocument' ), |
| 696 | 'gzip_enabled' => is_callable( 'gzopen' ), |
| 697 | 'mbstring_enabled' => extension_loaded( 'mbstring' ), |
| 698 | ); |
| 699 | |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | |
| 704 | /** |
| 705 | * Convert a human-readable file size into bytes. |
| 706 | * |
| 707 | * @param string $size The size string (e.g., "1M", "2G", "500K"). |
| 708 | * @return int The equivalent size in bytes. |
| 709 | */ |
| 710 | if ( ! function_exists( 'spel_readable_number' ) ) { |
| 711 | function spel_readable_number($size) |
| 712 | { |
| 713 | |
| 714 | // Get the last character of the size string |
| 715 | $suffix = substr($size, -1); |
| 716 | |
| 717 | // Remove the last character from the size string |
| 718 | $value = substr($size, 0, -1); |
| 719 | |
| 720 | // Convert suffix to lowercase for case-insensitive comparison |
| 721 | $suffix = strtolower($suffix); |
| 722 | |
| 723 | $multipliers = [ |
| 724 | 'p' => 1024, |
| 725 | 't' => 1024, |
| 726 | 'g' => 1024, |
| 727 | 'm' => 1024, |
| 728 | 'k' => 1024, |
| 729 | ]; |
| 730 | |
| 731 | // Check if the suffix is a valid multiplier |
| 732 | if (array_key_exists($suffix, $multipliers)) { |
| 733 | $value *= $multipliers[$suffix]; |
| 734 | } |
| 735 | |
| 736 | // Return the result |
| 737 | return (int)$value; |
| 738 | |
| 739 | } |
| 740 | } |
| 741 | |
| 742 | |
| 743 | if (!function_exists('spel_pagination')) { |
| 744 | function spel_pagination($query, $class = 'spel-pagination', $prev = '', $next = '') { |
| 745 | $default_prev = '<img src="' . esc_url(SPEL_IMG . '/icons/prev.svg') . '" alt="' . esc_attr__('arrow-left', 'jobly') . '" class="me-2" />' . esc_html__('Prev', 'jobly'); |
| 746 | $default_next = esc_html__('Next', 'jobly') . '<img src="' . esc_url(SPEL_IMG . '/icons/next.svg') . '" alt="' . esc_attr__('arrow-right', 'jobly') . '" class="ms-2" />'; |
| 747 | |
| 748 | $prev_text = !empty($prev) ? $prev : $default_prev; |
| 749 | $next_text = !empty($next) ? $next : $default_next; |
| 750 | |
| 751 | echo '<ul class="' . esc_attr($class) . '">'; |
| 752 | |
| 753 | $big = 999999999; // need an unlikely integer |
| 754 | echo paginate_links(array( |
| 755 | 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
| 756 | 'format' => '?paged=%#%', |
| 757 | 'current' => max(1, get_query_var('paged')), |
| 758 | 'total' => $query->max_num_pages, |
| 759 | 'prev_text' => $prev_text, |
| 760 | 'next_text' => $next_text, |
| 761 | )); |
| 762 | |
| 763 | echo '</ul>'; |
| 764 | } |
| 765 | } |