| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Main AstraSupport class Only Work for astra theme. |
| 5 |
* |
| 6 |
* @package RadiusTheme\SB |
| 7 |
*/ |
| 8 |
|
| 9 |
namespace RadiusTheme\SB\Controllers\ThemesSupport\Astra; |
| 10 |
|
| 11 |
use Astra_Woocommerce; |
| 12 |
use RadiusTheme\SB\Helpers\BuilderFns; |
| 13 |
use RadiusTheme\SB\Traits\SingletonTrait; |
| 14 |
|
| 15 |
// Do not allow directly accessing this file. |
| 16 |
if ( ! defined( 'ABSPATH' ) ) { |
| 17 |
exit( 'This script cannot be accessed directly.' ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Product Description class |
| 22 |
*/ |
| 23 |
class ThemeSupport { |
| 24 |
/** |
| 25 |
* Singleton |
| 26 |
*/ |
| 27 |
use SingletonTrait; |
| 28 |
|
| 29 |
/** |
| 30 |
* Construct function |
| 31 |
*/ |
| 32 |
private function __construct() { |
| 33 |
add_filter( 'astra_dynamic_post_structure_posttypes', [ __CLASS__, 'astra_post_types' ], 15 ); |
| 34 |
add_filter( 'rtsb/elementor/archive/products_per_page', [ __CLASS__, 'astra_products_per_page' ] ); |
| 35 |
} |
| 36 |
/** |
| 37 |
* Get class instance. |
| 38 |
* |
| 39 |
* @return object Instance. |
| 40 |
*/ |
| 41 |
public static function init() { |
| 42 |
if ( ! self::$instance ) { |
| 43 |
self::$instance = new self(); |
| 44 |
} |
| 45 |
return self::$instance; |
| 46 |
} |
| 47 |
|
| 48 |
public static function astra_post_types( $post_types ) { |
| 49 |
$position = array_search( 'rtsb_builder', $post_types ); |
| 50 |
unset( $post_types[ $position ] ); |
| 51 |
return $post_types; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Astra products per page. |
| 56 |
* |
| 57 |
* @return int |
| 58 |
*/ |
| 59 |
public static function astra_products_per_page() { |
| 60 |
if ( function_exists( 'astra_get_option' ) ) { |
| 61 |
$per_page = astra_get_option( 'shop-no-of-products' ); |
| 62 |
|
| 63 |
return ! empty( $per_page ) ? absint( $per_page ) : 12; |
| 64 |
} |
| 65 |
} |
| 66 |
} |
| 67 |
|