<?php
/**
* Theme functions and definitions.
*/
add_action('elementor/widgets/widgets_registered', 'bookory_customs_widgets');
function bookory_customs_widgets($widgets_manager){
require_once (get_stylesheet_directory().'/all_publisher.php');
require_once (get_stylesheet_directory().'/all_editors.php');
require_once (get_stylesheet_directory().'/all_translaters.php');
require_once (get_stylesheet_directory().'/all_categories.php');
}
function bookory_get_book_publisher_taxonomy() {
return apply_filters( 'bookory_book_publisher_taxonomy', 'pa_publisher' );
}
function bookory_get_book_editors_taxonomy() {
return apply_filters( 'bookory_book_editors_taxonomy', 'pa_editor' );
}
function bookory_get_book_translator_taxonomy() {
return apply_filters( 'bookory_book_translator_taxonomy', 'pa_translator' );
}
function bookory_wc_get_product_attributes($pa_taxonomy) {
global $product;
$terms = get_the_terms( $product->get_id(), $pa_taxonomy );
$author_name = '';
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$author_name .= '<a href="'. esc_url( get_term_link( $term ) ) . '">' . $term->name . '</a>';
}
}
return $author_name;
}
if (!function_exists('bookory_woocommerce_single_author')) {
function bookory_woocommerce_single_author() {
$author_name = bookory_wc_get_product_author();
if ( ! empty ( $author_name ) ) : ?>
<div class="product-brand">
<?php echo esc_html__('লেখক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $author_name ) ); ?>
</div>
<?php endif;
}
}
function bookory_woocommerce_single_publisher() {
$pa_publisher = bookory_get_book_publisher_taxonomy();
$publisher = bookory_wc_get_product_attributes($pa_publisher);
if ( ! empty ( $publisher ) ) : ?>
<div class="product-brand">
<?php echo esc_html__('প্রকাশক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $publisher ) ); ?>
</div>
<?php endif;
}
function bookory_woocommerce_single_editor() {
$pa_editor = bookory_get_book_editors_taxonomy();
$editors = bookory_wc_get_product_attributes($pa_editor);
if ( ! empty ( $editors ) ) : ?>
<div class="product-brand">
<?php echo esc_html__('সম্পাদক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $editors ) ); ?>
</div>
<?php endif;
}
function bookory_woocommerce_single_translator() {
$pa_translator = bookory_get_book_translator_taxonomy();
$translator = bookory_wc_get_product_attributes($pa_translator);
if ( ! empty ( $translator ) ) : ?>
<div class="product-brand">
<?php echo esc_html__('অনুবাদক: ', 'bookory') . wp_kses_post( str_replace( '</a><a ', '</a>, <a ', $translator ) ); ?>
</div>
<?php endif;
}
function bookory_single_product_after_title() {
global $product;
?>
<div class="product_after_title">
<?php
bookory_woocommerce_single_author();
bookory_woocommerce_single_translator();
bookory_woocommerce_single_editor();
bookory_woocommerce_single_publisher();
echo wc_get_product_category_list( $product->get_id(), ', ', '<span class="posted_in">' . _n( 'বিষয়:', 'বিষয়সমূহ:', count( $product->get_category_ids() ), 'woocommerce' ) . ' ', '</span>' ); ?>
</div>
<?php
}
function bookory_mas_product_authors_list_terms_clauses($clauses, $taxonomies, $args) {
global $wpdb;
if (!isset($args['first_letter'])) {
return $clauses;
}
$clauses['where'] .= ' AND ' . $wpdb->prepare("t.name LIKE %s", $wpdb->esc_like($args['first_letter']) . '%');
return $clauses;
}
add_action('init', 'bookory_setup_woocommerce_set_sidebar', 999);
function bookory_setup_woocommerce_set_sidebar(){
add_filter('bookory_theme_sidebar', 'bookory_woocommerce_set_sidebar', 20);
add_filter('body_class', 'bookory_woocommerce_body_class');
}
function bookory_woocommerce_set_sidebar($name) {
if (is_product_taxonomy() || is_product_category()) {
$name = '';
}
return $name;
}
function bookory_woocommerce_body_class($classes){
if (is_product_taxonomy() || is_product_category()) {
$classes = array_diff($classes, array(
'bookory-sidebar-left',
'bookory-sidebar-right',
'shop_filter_canvas',
'shop_filter_dropdown'
));
$classes[] = 'bookory-full-width-content';
}
return $classes;
}
function bookory_woocommerce_deal_progress() {
global $product;
$limit = get_post_meta($product->get_id(), '_deal_quantity', true);
$sold = intval(get_post_meta($product->get_id(), '_deal_sales_counts', true));
if (empty($limit)) {
return;
}
?>
<div class="deal-sold">
<div class="deal-sold-text">
<span><?php echo esc_html__('Already sold: ', 'bookory'); ?></span><span class="value"><?php echo esc_html($sold); ?>/<?php echo esc_html($limit); ?></span>
</div>
<div class="deal-progress">
<div class="progress-bar">
<div class="progress-value" style="width: <?php echo trim($sold / $limit * 100) ?>%"></div>
</div>
</div>
</div>
<?php
}
add_action( 'woosq_product_summary', 'bookory_single_product_after_title', 5 );
add_action( 'init', 'my_remove_lightbox' );
function my_remove_lightbox() {
remove_theme_support( 'wc-product-gallery-lightbox' );
}
add_filter( 'woocommerce_single_product_zoom_enabled', '__return_false' );
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'custom_remove_product_link' );
function custom_remove_product_link( $html ) {
return strip_tags( $html, '<div><img>' );
}
Comments
0 B
|👍
/👎