Advertisement
BaapJaan

Function

Apr 14th, 2022
1,005
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.96 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Theme functions and definitions.
  4.  */
  5.  
  6. add_action('elementor/widgets/widgets_registered', 'bookory_customs_widgets');
  7. function bookory_customs_widgets($widgets_manager){
  8.     require_once (get_stylesheet_directory().'/all_publisher.php');
  9.     require_once (get_stylesheet_directory().'/all_editors.php');
  10.     require_once (get_stylesheet_directory().'/all_translaters.php');
  11.     require_once (get_stylesheet_directory().'/all_categories.php');
  12. }
  13.  
  14. function bookory_get_book_publisher_taxonomy() {
  15.     return apply_filters( 'bookory_book_publisher_taxonomy', 'pa_publisher' );
  16. }
  17.  
  18. function bookory_get_book_editors_taxonomy() {
  19.     return apply_filters( 'bookory_book_editors_taxonomy', 'pa_editor' );
  20. }
  21.  
  22. function bookory_get_book_translator_taxonomy() {
  23.     return apply_filters( 'bookory_book_translator_taxonomy', 'pa_translator' );
  24. }
  25.  
  26. function bookory_wc_get_product_attributes($pa_taxonomy) {
  27.     global $product;
  28.     $terms       = get_the_terms( $product->get_id(), $pa_taxonomy );
  29.     $author_name = '';
  30.  
  31.     if ( $terms && ! is_wp_error( $terms ) ) {
  32.         foreach ( $terms as $term ) {
  33.             $author_name .= '<a href="'. esc_url( get_term_link( $term ) ) . '">' . $term->name . '</a>';
  34.         }
  35.     }
  36.  
  37.     return $author_name;
  38. }
  39.  
  40. function bookory_woocommerce_single_publisher() {
  41.     $pa_publisher = bookory_get_book_publisher_taxonomy();
  42.     $publisher = bookory_wc_get_product_attributes($pa_publisher);
  43.     if ( ! empty ( $publisher ) ) : ?>
  44.     <div class="product-brand">
  45.         <?php echo esc_html__('প্রকাশক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $publisher ) ); ?>
  46.     </div>
  47. <?php endif;
  48. }
  49.  
  50. function bookory_woocommerce_single_editor() {
  51.     $pa_editor = bookory_get_book_editors_taxonomy();
  52.     $editors = bookory_wc_get_product_attributes($pa_editor);
  53.     if ( ! empty ( $editors ) ) : ?>
  54.     <div class="product-brand">
  55.         <?php echo esc_html__('সম্পাদক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $editors ) ); ?>
  56.     </div>
  57. <?php endif;
  58. }
  59.  
  60. function bookory_woocommerce_single_translator() {
  61.     $pa_translator = bookory_get_book_translator_taxonomy();
  62.     $translator = bookory_wc_get_product_attributes($pa_translator);
  63.     if ( ! empty ( $translator ) ) : ?>
  64.     <div class="product-brand">
  65.         <?php echo esc_html__('অনুবাদক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $translator ) ); ?>
  66.     </div>
  67. <?php endif;
  68. }
  69.  
  70. function bookory_single_product_after_title() {
  71.     global $product;
  72. ?>
  73. <div class="product_after_title">
  74.     <?php
  75.         bookory_woocommerce_single_author();
  76.         bookory_woocommerce_single_translator();
  77.         bookory_woocommerce_single_editor();
  78.         bookory_woocommerce_single_publisher();
  79.         echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'Category:', 'বিষয়:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>
  80. </div>
  81. <?php
  82. }
  83.  
  84. function bookory_mas_product_authors_list_terms_clauses($clauses, $taxonomies, $args) {
  85.     global $wpdb;
  86.  
  87.     if (!isset($args['first_letter'])) {
  88.         return $clauses;
  89.     }
  90.     $clauses['where'] .= ' AND ' . $wpdb->prepare("t.name LIKE %s", $wpdb->esc_like($args['first_letter']) . '%');
  91.  
  92.     return $clauses;
  93. }
  94.  
  95. // add_action('init', 'bookory_setup_woocommerce_set_sidebar', 999);
  96. // function bookory_setup_woocommerce_set_sidebar(){
  97. //  add_filter('bookory_theme_sidebar', 'bookory_woocommerce_set_sidebar', 20);
  98. //  add_filter('body_class', 'bookory_woocommerce_body_class');
  99. // }
  100.  
  101. // function bookory_woocommerce_set_sidebar() {
  102. //  if (bookory_is_product_archive()) {
  103. //      return '';
  104. //  }
  105. // }
  106.  
  107. function bookory_woocommerce_body_class($classes){
  108.     if (bookory_is_product_archive()) {
  109.         $classes   = array_diff($classes, array(
  110.                     'bookory-sidebar-left',
  111.                     'bookory-sidebar-right',
  112.                     'shop_filter_canvas',
  113.                     'shop_filter_dropdown'
  114.                 ));
  115.         $classes[] = 'bookory-full-width-content';
  116.     }
  117.     return $classes;
  118. }
  119.  
  120.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement