PluginProbe ʕ •ᴥ•ʔ
Remove Add to Cart Button for WooCommerce / 1.0.1
Remove Add to Cart Button for WooCommerce v1.0.1
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9
remove-add-to-cart-button-for-woocommerce / includes / class-remove-add-to-cart-button-woocommerce.php
remove-add-to-cart-button-for-woocommerce / includes Last commit date
freemius 5 years ago class-remove-add-to-cart-button-woocommerce-activator.php 5 years ago class-remove-add-to-cart-button-woocommerce-deactivator.php 5 years ago class-remove-add-to-cart-button-woocommerce-i18n.php 5 years ago class-remove-add-to-cart-button-woocommerce-loader.php 5 years ago class-remove-add-to-cart-button-woocommerce.php 5 years ago index.php 5 years ago
class-remove-add-to-cart-button-woocommerce.php
257 lines
1 <?php
2
3 /**
4 * The file that defines the core plugin class
5 *
6 * A class definition that includes attributes and functions used across both the
7 * public-facing side of the site and the admin area.
8 *
9 * @link https://wpartisan.net/
10 * @since 1.0.0
11 *
12 * @package Remove_Add_To_Cart_Button_Woocommerce
13 * @subpackage Remove_Add_To_Cart_Button_Woocommerce/includes
14 */
15 /**
16 * The core plugin class.
17 *
18 * This is used to define internationalization, admin-specific hooks, and
19 * public-facing site hooks.
20 *
21 * Also maintains the unique identifier of this plugin as well as the current
22 * version of the plugin.
23 *
24 * @since 1.0.0
25 * @package Remove_Add_To_Cart_Button_Woocommerce
26 * @subpackage Remove_Add_To_Cart_Button_Woocommerce/includes
27 * @author wpArtisan <md.assaduzzaman.khan@gmail.com>
28 */
29 class Remove_Add_To_Cart_Button_Woocommerce
30 {
31 /**
32 * The loader that's responsible for maintaining and registering all hooks that power
33 * the plugin.
34 *
35 * @since 1.0.0
36 * @access protected
37 * @var Remove_Add_To_Cart_Button_Woocommerce_Loader $loader Maintains and registers all hooks for the plugin.
38 */
39 protected $loader ;
40 /**
41 * The unique identifier of this plugin.
42 *
43 * @since 1.0.0
44 * @access protected
45 * @var string $plugin_name The string used to uniquely identify this plugin.
46 */
47 protected $plugin_name ;
48 /**
49 * The current version of the plugin.
50 *
51 * @since 1.0.0
52 * @access protected
53 * @var string $version The current version of the plugin.
54 */
55 protected $version ;
56 /**
57 * Define the core functionality of the plugin.
58 *
59 * Set the plugin name and the plugin version that can be used throughout the plugin.
60 * Load the dependencies, define the locale, and set the hooks for the admin area and
61 * the public-facing side of the site.
62 *
63 * @since 1.0.0
64 */
65 public function __construct()
66 {
67
68 if ( defined( 'REMOVE_ADD_TO_CART_BUTTON_WOOCOMMERCE_VERSION' ) ) {
69 $this->version = REMOVE_ADD_TO_CART_BUTTON_WOOCOMMERCE_VERSION;
70 } else {
71 $this->version = '1.0.0';
72 }
73
74 $this->plugin_name = 'remove-add-to-cart-button-woocommerce';
75 $this->ratcw_load_dependencies();
76 $this->ratcw_set_locale();
77 $this->ratcw_define_admin_hooks();
78 $this->ratcw_define_public_hooks();
79 }
80
81 /**
82 * Load the required dependencies for this plugin.
83 *
84 * Include the following files that make up the plugin:
85 *
86 * - Remove_Add_To_Cart_Button_Woocommerce_Loader. Orchestrates the hooks of the plugin.
87 * - Remove_Add_To_Cart_Button_Woocommerce_i18n. Defines internationalization functionality.
88 * - Remove_Add_To_Cart_Button_Woocommerce_Admin. Defines all hooks for the admin area.
89 * - Remove_Add_To_Cart_Button_Woocommerce_Public. Defines all hooks for the public side of the site.
90 *
91 * Create an instance of the loader which will be used to register the hooks
92 * with WordPress.
93 *
94 * @since 1.0.0
95 * @access private
96 */
97 private function ratcw_load_dependencies()
98 {
99 /**
100 * The class responsible for orchestrating the actions and filters of the
101 * core plugin.
102 */
103 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-remove-add-to-cart-button-woocommerce-loader.php';
104 /**
105 * The class responsible for defining internationalization functionality
106 * of the plugin.
107 */
108 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-remove-add-to-cart-button-woocommerce-i18n.php';
109 /**
110 * The class responsible for defining all actions that occur in the admin area.
111 */
112 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-remove-add-to-cart-button-woocommerce-admin.php';
113 /**
114 * The class responsible for defining all actions that occur in the public-facing
115 * side of the site.
116 */
117 require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-remove-add-to-cart-button-woocommerce-public.php';
118 $this->loader = new Remove_Add_To_Cart_Button_Woocommerce_Loader();
119 }
120
121 /**
122 * Define the locale for this plugin for internationalization.
123 *
124 * Uses the Remove_Add_To_Cart_Button_Woocommerce_i18n class in order to set the domain and to register the hook
125 * with WordPress.
126 *
127 * @since 1.0.0
128 * @access private
129 */
130 private function ratcw_set_locale()
131 {
132 $plugin_i18n = new Remove_Add_To_Cart_Button_Woocommerce_i18n();
133 $this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'ratcw_load_plugin_textdomain' );
134 }
135
136 /**
137 * Register all of the hooks related to the admin area functionality
138 * of the plugin.
139 *
140 * @since 1.0.0
141 * @access private
142 */
143 private function ratcw_define_admin_hooks()
144 {
145 $plugin_admin = new Remove_Add_To_Cart_Button_Woocommerce_Admin( $this->ratcw_get_plugin_name(), $this->ratcw_get_version() );
146 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'ratcw_enqueue_styles' );
147 $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'ratcw_enqueue_scripts' );
148 //custom tab in woocommerce product data panel
149 $this->loader->add_filter( 'woocommerce_product_data_tabs', $plugin_admin, 'ratcw_remove_add_to_cart_button_data_tab' );
150 $this->loader->add_action( 'admin_head', $plugin_admin, 'ratcw_custom_style' );
151 $this->loader->add_action( 'woocommerce_product_data_panels', $plugin_admin, 'ratcw_remove_add_to_cart_button_product_data_fields' );
152 $this->loader->add_action(
153 'woocommerce_process_product_meta',
154 $plugin_admin,
155 'ratcw_save_fields',
156 10,
157 2
158 );
159 //plugin settions options
160 $this->loader->add_action(
161 'woocommerce_settings_tabs_array',
162 $plugin_admin,
163 'ratcw_add_settings_tab',
164 50
165 );
166 $this->loader->add_action( 'woocommerce_settings_tabs_remove-add-to-cart-button-settings', $plugin_admin, 'ratcw_settings_tab' );
167 $this->loader->add_action(
168 'woocommerce_update_options_remove-add-to-cart-button-settings',
169 $plugin_admin,
170 'ratcw_update_settings',
171 10,
172 2
173 );
174 }
175
176 /**
177 * Register all of the hooks related to the public-facing functionality
178 * of the plugin.
179 *
180 * @since 1.0.0
181 * @access private
182 */
183 private function ratcw_define_public_hooks()
184 {
185 $plugin_public = new Remove_Add_To_Cart_Button_Woocommerce_Public( $this->ratcw_get_plugin_name(), $this->ratcw_get_version() );
186 // hide product price
187 $this->loader->add_action(
188 'woocommerce_get_price_html',
189 $plugin_public,
190 'ratcw_hide_price_for_product',
191 10,
192 2
193 );
194 $this->loader->add_filter(
195 'woocommerce_cart_item_price',
196 $plugin_public,
197 'ratcw_hide_cart_item_price',
198 10,
199 3
200 );
201 $this->loader->add_filter(
202 'woocommerce_cart_item_subtotal',
203 $plugin_public,
204 'ratcw_hide_cart_item_subtotal',
205 10,
206 3
207 );
208 //remove add to cart button
209 $this->loader->add_action( 'woocommerce_before_shop_loop_item', $plugin_public, 'ratcw_remove_archive_add_to_cart_button' );
210 $this->loader->add_action( 'woocommerce_single_product_summary', $plugin_public, 'ratcw_remove_add_to_cart_button_from_single_product' );
211 }
212
213 /**
214 * Run the loader to execute all of the hooks with WordPress.
215 *
216 * @since 1.0.0
217 */
218 public function ratcw_run()
219 {
220 $this->loader->ratcw_run_loader();
221 }
222
223 /**
224 * The name of the plugin used to uniquely identify it within the context of
225 * WordPress and to define internationalization functionality.
226 *
227 * @since 1.0.0
228 * @return string The name of the plugin.
229 */
230 public function ratcw_get_plugin_name()
231 {
232 return $this->plugin_name;
233 }
234
235 /**
236 * The reference to the class that orchestrates the hooks with the plugin.
237 *
238 * @since 1.0.0
239 * @return Remove_Add_To_Cart_Button_Woocommerce_Loader Orchestrates the hooks of the plugin.
240 */
241 public function get_loader()
242 {
243 return $this->loader;
244 }
245
246 /**
247 * Retrieve the version number of the plugin.
248 *
249 * @since 1.0.0
250 * @return string The version number of the plugin.
251 */
252 public function ratcw_get_version()
253 {
254 return $this->version;
255 }
256
257 }