%PDF- %PDF-
| Direktori : /var/www/projetos/stb.ind.br/wp-content/themes/stb_old/ |
| Current File : /var/www/projetos/stb.ind.br/wp-content/themes/stb_old/functions.php |
<?php
namespace STB_Theme;
if ( ! defined( 'ABSPATH' ) ) {
die( 'Not allowed' );
}
class STB_Theme {
public function __construct() {
add_action( 'init', array( __CLASS__, 'load_textdomain' ) );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ) );
add_action( 'template_redirect', array( __CLASS__, 'stb_disable_shop' ) );
add_action( 'woocommerce_before_shop_loop', array( __CLASS__, 'stb_rankmath_breadcrumbs' ), 20 );
add_action( 'woocommerce_before_single_product_summary', array( __CLASS__, 'stb_rankmath_breadcrumbs' ), 5 );
add_action( 'woocommerce_shop_loop_subcategory_title', array( __CLASS__, 'subcategory_button' ), 15 );
add_action( 'woocommerce_single_product_summary', array( __CLASS__, 'stb_excerpt_title' ), 15 );
add_action( 'woocommerce_after_single_product', array( __CLASS__, 'stb_product_back' ) );
add_filter( 'woocommerce_catalog_orderby', array( __CLASS__, 'remove_products_orderby' ) );
add_filter( 'single_product_archive_thumbnail_size', array( __CLASS__, 'stb_product_archive_image_size' ) );
add_filter( 'woocommerce_product_description_tab_title', array( __CLASS__, 'stb_product_description_tab' ) );
add_filter( 'woocommerce_page_title', array( __CLASS__, 'stb_products_title' ) );
remove_action( 'woocommerce_before_shop_loop', 'woocommerce_result_count', 20 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_rating', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_price', 10 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 40 );
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 50 );
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_meta', 10 );
self::includes();
}
static function includes() {
/**
* Include your custom classes below here
*/
require_once 'includes/class-stb-cases.php';
}
public static function load_textdomain() {
load_child_theme_textdomain( 'stb', get_stylesheet_directory() . '/languages' );
remove_action('woocommerce_shop_loop_item_title', 'maxbizz_change_products_title', 10 );
add_action( 'woocommerce_shop_loop_item_title','woocommerce_template_loop_product_title', 10 );
}
public static function enqueue_scripts() {
wp_enqueue_style( 'stb_style', get_stylesheet_directory_uri() . '/assets/css/stb.css', null, filemtime( get_stylesheet_directory() . '/assets/css/stb.css' ) );
wp_enqueue_script( 'stb_script', get_stylesheet_directory_uri() . '/assets/js/stb.js', array( 'jquery' ), filemtime( get_stylesheet_directory() . '/assets/js/stb.js' ) );
}
public static function stb_disable_shop() {
global $woocoomerce;
if ( is_cart() || is_checkout() ) {
wp_redirect( home_url() );
exit;
}
}
public static function stb_rankmath_breadcrumbs() {
if (function_exists('rank_math_the_breadcrumbs')) rank_math_the_breadcrumbs();
}
public static function subcategory_button( $category ) {
echo '<p class="subcategory-description">' . $category->description . '</p>';
echo '<div href="' . get_term_link( $category->term_id, 'product_cat' ) . '" class="subcategory-button">' . __( 'See more', 'stb' ) . '</div>';
}
public static function stb_excerpt_title() {
?>
<h6 class="product_excerpt_title">
<?php _e( "Product's description", 'stb' ) ?>
</h6>
<?php
}
public static function stb_product_back() {
global $product;
$category = get_the_terms( $product->get_id(), 'product_cat' )[0];
?>
<div class="stb-back-button">
<a href="<?php echo get_term_link( $category, 'product_cat' ) ?>" class="button back-button"><?php _e( 'Back', 'stb' ) ?></a>
</div>
<?php
}
public static function remove_products_orderby( $catalog ) {
unset( $catalog[ 'price' ] );
unset( $catalog[ 'price-desc' ] );
return $catalog;
}
public static function stb_product_archive_image_size() {
return array( 150, 250, false );
}
public static function stb_product_description_tab() {
return __( 'Technical features and specifications', 'stb' );
}
public static function stb_products_title( $page_title ) {
if ( 'product' === get_post_type() ) {
$page_title = __( 'Products', 'woocommerce' );
}
return $page_title;
}
}
new STB_Theme();