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 / remove-add-to-cart-button-woocommerce.php
remove-add-to-cart-button-for-woocommerce Last commit date
admin 5 years ago assets 5 years ago includes 5 years ago languages 5 years ago public 5 years ago LICENSE.txt 5 years ago README.txt 5 years ago index.php 5 years ago remove-add-to-cart-button-woocommerce.php 5 years ago uninstall.php 5 years ago
remove-add-to-cart-button-woocommerce.php
223 lines
1 <?php
2
3 /**
4 * The plugin bootstrap file
5 *
6 * This file is read by WordPress to generate the plugin information in the plugin
7 * admin area. This file also includes all of the dependencies used by the plugin,
8 * registers the activation and deactivation functions, and defines a function
9 * that starts the plugin.
10 *
11 * @link https://wpartisan.net/
12 * @since 1.0.0
13 * @package Remove_Add_To_Cart_Button_Woocommerce
14 *
15 * @wordpress-plugin
16 * Plugin Name: Remove Add to Cart Button for WooCommerce
17 * Plugin URI: https://wordpress.org/plugins/remove-add-to-cart-button-for-woocommerce
18 * Description: Remove Add to Cart Button for WooCommerce Plugin gives you a really easy interface to hide/remove product Add to Cart button for all users or only for the visitors. It has a option to hide product price also.
19 * Version: 1.0.1
20 * Author: wpArtisan
21 * Author URI: https://wpartisan.net/
22 * License: GPL-2.0+
23 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
24 * Text Domain: remove-add-to-cart-button-woocommerce
25 * Domain Path: /languages
26 */
27 // If this file is called directly, abort.
28 if ( !defined( 'WPINC' ) ) {
29 die;
30 }
31
32 if ( function_exists( 'ratcbw_fs' ) ) {
33 ratcbw_fs()->set_basename( false, __FILE__ );
34 } else {
35
36 if ( !function_exists( 'ratcbw_fs' ) ) {
37 // Create a helper function for easy SDK access.
38 function ratcbw_fs()
39 {
40 global $ratcbw_fs ;
41
42 if ( !isset( $ratcbw_fs ) ) {
43 // Include Freemius SDK.
44 require_once dirname( __FILE__ ) . '/includes/freemius/start.php';
45 $ratcbw_fs = fs_dynamic_init( array(
46 'id' => '6639',
47 'slug' => 'remove-add-to-cart-button-for-woocommerce',
48 'type' => 'plugin',
49 'public_key' => 'pk_c0490aef508bc341e97b0c1e0448f',
50 'is_premium' => false,
51 'premium_suffix' => 'Premium',
52 'has_addons' => false,
53 'has_paid_plans' => true,
54 'menu' => array(
55 'first-path' => 'plugins.php',
56 'support' => false,
57 ),
58 'is_live' => true,
59 ) );
60 }
61
62 return $ratcbw_fs;
63 }
64
65 // Init Freemius.
66 ratcbw_fs();
67 // Signal that SDK was initiated.
68 do_action( 'ratcbw_fs_loaded' );
69 }
70
71 /**
72 * Currently plugin version.
73 * Start at version 1.0.0 and use SemVer - https://semver.org
74 * Rename this for your plugin and update it as you release new versions.
75 */
76 define( 'REMOVE_ADD_TO_CART_BUTTON_WOOCOMMERCE_VERSION', '1.0.1' );
77 if ( !function_exists( 'ratcw_remove_add_to_cart_button_admin_notice' ) ) {
78 /**
79 * Show an admin notice if WooCommerce is not activated
80 *
81 */
82 function ratcw_remove_add_to_cart_button_admin_notice()
83 {
84 ?>
85 <div class="error">
86 <p><?php
87 esc_html_e( 'Remove Add to Cart Button for WooCommerce Plugin is enabled but not effective. In order to work it requires WooCommerce.', 'remove-add-to-cart-button-woocommerce' );
88 ?></p>
89 </div>
90 <?php
91 }
92
93 }
94 add_action( 'plugins_loaded', 'ratcw_remove_add_to_cart_button_install', 12 );
95 /**
96 * Add plugin page settings link.
97 * @since 1.0.0
98 */
99 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'ratcw_add_plugin_page_settings_link' );
100 function ratcw_add_plugin_page_settings_link( $links )
101 {
102 $links[] = '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=remove-add-to-cart-button-settings' ) . '">' . esc_html__( 'Settings', 'remove-add-to-cart-button-woocommerce' ) . '</a>';
103 return $links;
104 }
105
106 /**
107 * The code that runs during plugin activation.
108 * This action is documented in includes/class-remove-add-to-cart-button-woocommerce-activator.php
109 */
110 function ratcw_activate_plugin()
111 {
112 require_once plugin_dir_path( __FILE__ ) . 'includes/class-remove-add-to-cart-button-woocommerce-activator.php';
113 Remove_Add_To_Cart_Button_Woocommerce_Activator::ratcw_activate();
114 }
115
116 /**
117 * The code that runs during plugin deactivation.
118 * This action is documented in includes/class-remove-add-to-cart-button-woocommerce-deactivator.php
119 */
120 function ratcw_deactivate_plugin()
121 {
122 require_once plugin_dir_path( __FILE__ ) . 'includes/class-remove-add-to-cart-button-woocommerce-deactivator.php';
123 Remove_Add_To_Cart_Button_Woocommerce_Deactivator::ratcw_deactivate();
124 }
125
126 register_activation_hook( __FILE__, 'ratcw_activate_plugin' );
127 register_deactivation_hook( __FILE__, 'ratcw_deactivate_plugin' );
128 /**
129 * Add admin notice.
130 * @since 1.0.0
131 */
132 add_action( 'admin_notices', 'ratcw_admin_notice' );
133 function ratcw_admin_notice()
134 {
135 global $current_user ;
136
137 if ( isset( $_SERVER['HTTPS'] ) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
138 $protocol = 'https://';
139 } else {
140 $protocol = 'http://';
141 }
142
143 $current_url = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
144 $parse_url = parse_url( $current_url );
145
146 if ( isset( $parse_url['query'] ) && !empty($parse_url['query']) ) {
147 $current_url = $current_url . '&ratcw_igne_noti=1';
148 } else {
149 $current_url = $current_url . '?ratcw_igne_noti=1';
150 }
151
152 $user_id = $current_user->ID;
153 if ( !get_user_meta( $user_id, 'ratcw_igne_noti' ) ) {
154
155 if ( ratcbw_fs()->is_not_paying() ) {
156 echo '<div class="updated"><p>' ;
157 echo '<h3>' . esc_html__( 'Awesome Premium Features in Remove Add to Cart Button for WooCommerce Plugin', 'remove-add-to-cart-button-woocommerce' ) . '</h3>' ;
158 echo '<ul>' ;
159 echo '<li><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Remove Add to Cart Button Based on User Rules', 'remove-add-to-cart-button-woocommerce' ) . '</li>' ;
160 echo '<li><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Remove Add to Cart Button Based on Countries', 'remove-add-to-cart-button-woocommerce' ) . '</li>' ;
161 echo '<li><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Set Category Wise Remove Add to Cart Button Conditions', 'remove-add-to-cart-button-woocommerce' ) . '</li>' ;
162 echo '<li><span class="dashicons dashicons-yes"></span> ' . esc_html__( 'Priority email support', 'remove-add-to-cart-button-woocommerce' ) . '</li>' ;
163 echo '</ul>' ;
164 echo '<a href="' . ratcbw_fs()->get_upgrade_url() . '" class="upgradebtn">' . esc_html__( 'Upgrade Now!', 'remove-add-to-cart-button-woocommerce' ) . '</a>&nbsp;&nbsp;' ;
165 echo '<a href="' . $current_url . '" class="hidebtn">' . esc_html__( 'Hide Notice', 'remove-add-to-cart-button-woocommerce' ) . '</a>' ;
166 echo "</p></div>" ;
167 }
168
169 }
170 }
171
172 /**
173 * Ignore admin notice.
174 * @since 1.0.0
175 */
176 add_action( 'admin_init', 'ratcw_ignore_notice' );
177 function ratcw_ignore_notice()
178 {
179 global $current_user ;
180 $user_id = $current_user->ID;
181 if ( isset( $_GET['ratcw_igne_noti'] ) && 1 == $_GET['ratcw_igne_noti'] ) {
182 add_user_meta(
183 $user_id,
184 'ratcw_igne_noti',
185 'true',
186 true
187 );
188 }
189 }
190
191 /**
192 * The core plugin class that is used to define internationalization,
193 * admin-specific hooks, and public-facing site hooks.
194 */
195 require plugin_dir_path( __FILE__ ) . 'includes/class-remove-add-to-cart-button-woocommerce.php';
196 /**
197 * Begins execution of the plugin.
198 *
199 * Since everything within the plugin is registered via hooks,
200 * then kicking off the plugin from this point in the file does
201 * not affect the page life cycle.
202 *
203 * @since 1.0.0
204 */
205 function ratcw_run_remove_add_to_cart_button_woocommerce()
206 {
207 $plugin = new Remove_Add_To_Cart_Button_Woocommerce();
208 $plugin->ratcw_run();
209 }
210
211 function ratcw_remove_add_to_cart_button_install()
212 {
213
214 if ( !function_exists( 'WC' ) ) {
215 add_action( 'admin_notices', 'ratcw_remove_add_to_cart_button_admin_notice' );
216 } else {
217 ratcw_run_remove_add_to_cart_button_woocommerce();
218 }
219
220 }
221
222 }
223