register-settings.php
76 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Core\Wc_Customizer; |
| 4 | |
| 5 | use ShopEngine\Traits\Singleton; |
| 6 | |
| 7 | defined('ABSPATH') || exit; |
| 8 | |
| 9 | /** |
| 10 | * Description: this class will register option in wordpress default customizer |
| 11 | * |
| 12 | * @package ShopEngine |
| 13 | * @subpackage ShopEngine/Core/Wc_Customizer |
| 14 | * @since 4.5.0 |
| 15 | */ |
| 16 | class Register_Settings |
| 17 | { |
| 18 | use Singleton; |
| 19 | |
| 20 | /** |
| 21 | * will int the class |
| 22 | * |
| 23 | * @since 4.5.0 |
| 24 | * @access public |
| 25 | * @return void |
| 26 | */ |
| 27 | public function init(){ |
| 28 | add_action('customize_register', [$this, 'shopengine_add_customizer_options']); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Add customizer options |
| 33 | * |
| 34 | * This is a callback function for customize_register action. It'll add a customizer option in the Customizer > WooCommerce > Product Catalog section |
| 35 | * @since 4.5.0 |
| 36 | * @access public |
| 37 | * @param object $wp_customize |
| 38 | * @return void |
| 39 | */ |
| 40 | public function shopengine_add_customizer_options( $wp_customize ) { |
| 41 | |
| 42 | $wp_customize->add_setting('shopengine_product_per_page_mobile', array( |
| 43 | 'default' => '2', |
| 44 | 'sanitize_callback' => 'sanitize_text_field', |
| 45 | )); |
| 46 | |
| 47 | $wp_customize->add_control('shopengine_product_per_page_mobile', array( |
| 48 | 'label' => __('Products per row in mobile', 'shopengine'), |
| 49 | 'section' => 'woocommerce_product_catalog', |
| 50 | 'type' => 'number', |
| 51 | 'priority' => 11, |
| 52 | 'input_attrs' => array( |
| 53 | 'min' => 1, |
| 54 | 'step' => 1, |
| 55 | ), |
| 56 | )); |
| 57 | |
| 58 | $wp_customize->add_setting('shopengine_product_per_page_tablet', array( |
| 59 | 'default' => '2', |
| 60 | 'sanitize_callback' => 'sanitize_text_field', |
| 61 | )); |
| 62 | |
| 63 | $wp_customize->add_control('shopengine_product_per_page_tablet', array( |
| 64 | 'label' => __('Products per row in tablet', 'shopengine'), |
| 65 | 'section' => 'woocommerce_product_catalog', |
| 66 | 'type' => 'number', |
| 67 | 'priority' => 11, |
| 68 | 'input_attrs' => array( |
| 69 | 'min' => 1, |
| 70 | 'step' => 1, |
| 71 | ), |
| 72 | )); |
| 73 | } |
| 74 | |
| 75 | } |
| 76 |