PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 3.18.0
YITH WooCommerce Wishlist v3.18.0
trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / includes / class-yith-wcwl-admin.php
yith-woocommerce-wishlist / includes Last commit date
data-stores 3 years ago legacy 4 years ago widgets 3 years ago class-yith-wcwl-admin.php 3 years ago class-yith-wcwl-ajax-handler.php 3 years ago class-yith-wcwl-cron.php 3 years ago class-yith-wcwl-exception.php 4 years ago class-yith-wcwl-form-handler.php 3 years ago class-yith-wcwl-frontend.php 3 years ago class-yith-wcwl-install.php 4 years ago class-yith-wcwl-privacy.php 3 years ago class-yith-wcwl-session.php 3 years ago class-yith-wcwl-shortcode.php 3 years ago class-yith-wcwl-wishlist-factory.php 3 years ago class-yith-wcwl-wishlist-item.php 3 years ago class-yith-wcwl-wishlist.php 3 years ago class-yith-wcwl.php 3 years ago functions-yith-wcwl.php 3 years ago
class-yith-wcwl-admin.php
386 lines
1 <?php
2 /**
3 * Admin init class
4 *
5 * @author YITH
6 * @package YITH\Wishlist\Classes
7 * @version 3.0.0
8 */
9
10 if ( ! defined( 'YITH_WCWL' ) ) {
11 exit;
12 } // Exit if accessed directly
13
14 if ( ! class_exists( 'YITH_WCWL_Admin' ) ) {
15 /**
16 * Initiator class. Create and populate admin views.
17 *
18 * @since 1.0.0
19 */
20 class YITH_WCWL_Admin {
21
22 /**
23 * Single instance of the class
24 *
25 * @var \YITH_WCWL_Admin
26 * @since 2.0.0
27 */
28 protected static $instance;
29
30 /**
31 * Wishlist panel
32 *
33 * @var string Panel hookname
34 * @since 2.0.0
35 */
36 protected $panel = null;
37
38 /**
39 * Link to landing page on yithemes.com
40 *
41 * @var string
42 * @since 2.0.0
43 */
44 public $premium_landing_url = 'https://yithemes.com/themes/plugins/yith-woocommerce-wishlist/';
45
46 /**
47 * Tab name
48 *
49 * @var string
50 * @since 1.0.0
51 */
52 public $tab;
53
54 /**
55 * Plugin options
56 *
57 * @var array
58 * @since 1.0.0
59 */
60 public $options;
61
62 /**
63 * List of available tab for wishlist panel
64 *
65 * @var array
66 * @access public
67 * @since 2.0.0
68 */
69 public $available_tabs = array();
70
71 /**
72 * Returns single instance of the class
73 *
74 * @return \YITH_WCWL_Admin
75 * @since 2.0.0
76 */
77 public static function get_instance() {
78 if ( is_null( static::$instance ) ) {
79 static::$instance = new static();
80 }
81
82 return static::$instance;
83 }
84
85 /**
86 * Constructor of the class
87 *
88 * @since 2.0.0
89 */
90 public function __construct() {
91 // install plugin, or update from older versions.
92 add_action( 'init', array( $this, 'install' ) );
93
94 // init admin processing.
95 add_action( 'init', array( $this, 'init' ) );
96
97 // enqueue scripts.
98 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 20 );
99
100 // plugin panel options.
101 add_filter( 'yith_plugin_fw_panel_wc_extra_row_classes', array( $this, 'mark_options_disabled' ), 10, 23 );
102
103 // add plugin links.
104 add_filter( 'plugin_action_links_' . plugin_basename( YITH_WCWL_DIR . 'init.php' ), array( $this, 'action_links' ) );
105 add_filter( 'yith_show_plugin_row_meta', array( $this, 'add_plugin_meta' ), 10, 5 );
106
107 // register wishlist panel.
108 add_action( 'admin_menu', array( $this, 'register_panel' ), 5 );
109
110 // add a post display state for special WC pages.
111 add_filter( 'display_post_states', array( $this, 'add_display_post_states' ), 10, 2 );
112 }
113
114 /* === ADMIN GENERAL === */
115
116 /**
117 * Add a post display state for special WC pages in the page list table.
118 *
119 * @param array $post_states An array of post display states.
120 * @param WP_Post $post The current post object.
121 */
122 public function add_display_post_states( $post_states, $post ) {
123 if ( (int) get_option( 'yith_wcwl_wishlist_page_id' ) === $post->ID ) {
124 $post_states['yith_wcwl_page_for_wishlist'] = __( 'Wishlist Page', 'yith-woocommerce-wishlist' );
125 }
126
127 return $post_states;
128 }
129
130 /* === INITIALIZATION SECTION === */
131
132 /**
133 * Initiator method. Initiate properties.
134 *
135 * @return void
136 * @access private
137 * @since 1.0.0
138 */
139 public function init() {
140 $prefix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? 'unminified/' : '';
141 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
142
143 /**
144 * APPLY_FILTERS: yith_wcwl_available_admin_tabs
145 *
146 * Filter the available tabs in the plugin panel.
147 *
148 * @param array $tabs Admin tabs
149 *
150 * @return array
151 */
152 $this->available_tabs = apply_filters(
153 'yith_wcwl_available_admin_tabs',
154 array(
155 'settings' => __( 'General settings', 'yith-woocommerce-wishlist' ),
156 'add_to_wishlist' => __( 'Add to wishlist options', 'yith-woocommerce-wishlist' ),
157 'wishlist_page' => __( 'Wishlist page options', 'yith-woocommerce-wishlist' ),
158 )
159 );
160
161 wp_register_style( 'yith-wcwl-font-awesome', YITH_WCWL_URL . 'assets/css/font-awesome.min.css', array(), '4.7.0' );
162 wp_register_style( 'yith-wcwl-material-icons', 'https://fonts.googleapis.com/icon?family=Material+Icons', array(), '3.0.1' );
163 wp_register_style( 'yith-wcwl-admin', YITH_WCWL_URL . 'assets/css/admin.css', array( 'yith-wcwl-font-awesome' ), YITH_WCWL_Frontend()->version );
164 wp_register_script( 'yith-wcwl-admin', YITH_WCWL_URL . 'assets/js/' . $prefix . 'admin/yith-wcwl' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ), YITH_WCWL_Frontend()->version, true );
165 }
166
167 /**
168 * Run the installation
169 *
170 * @return void
171 * @since 1.0.0
172 */
173 public function install() {
174 if ( wp_doing_ajax() ) {
175 return;
176 }
177
178 $stored_db_version = get_option( 'yith_wcwl_db_version' );
179
180 if ( ! $stored_db_version || ! YITH_WCWL_Install()->is_installed() ) {
181 // fresh installation.
182 YITH_WCWL_Install()->init();
183 } elseif ( version_compare( $stored_db_version, YITH_WCWL_DB_VERSION, '<' ) ) {
184 // update database.
185 YITH_WCWL_Install()->update( $stored_db_version );
186 /**
187 * DO_ACTION: yith_wcwl_updated
188 *
189 * Allows to fire some action when the plugin database is updated.
190 */
191 do_action( 'yith_wcwl_updated' );
192 }
193
194 // Plugin installed.
195 /**
196 * DO_ACTION: yith_wcwl_installed
197 *
198 * Allows to fire some action when the plugin database is installed.
199 */
200 do_action( 'yith_wcwl_installed' );
201 }
202
203 /**
204 * Adds plugin actions link
205 *
206 * @param mixed $links Available action links.
207 * @return array
208 */
209 public function action_links( $links ) {
210 $links = yith_add_action_links( $links, 'yith_wcwl_panel', defined( 'YITH_WCWL_PREMIUM' ), YITH_WCWL_SLUG );
211 return $links;
212 }
213
214 /**
215 * Adds plugin row meta
216 *
217 * @param array $new_row_meta_args Array of meta for current plugin.
218 * @param array $plugin_meta Not in use.
219 * @param string $plugin_file Current plugin iit file path.
220 * @param array $plugin_data Plugin info.
221 * @param string $status Plugin status.
222 * @param string $init_file Wishlist plugin init file.
223 * @return array
224 * @since 2.0.0
225 */
226 public function add_plugin_meta( $new_row_meta_args, $plugin_meta, $plugin_file, $plugin_data, $status, $init_file = 'YITH_WCWL_INIT' ) {
227 if ( ! defined( $init_file ) || constant( $init_file ) !== $plugin_file ) {
228 return $new_row_meta_args;
229 }
230
231 $new_row_meta_args['slug'] = 'yith-woocommerce-wishlist';
232 $new_row_meta_args['is_premium'] = defined( 'YITH_WCWL_PREMIUM' );
233 $new_row_meta_args['is_extended'] = defined( 'YITH_WCWL_EXTENDED' );
234
235 return $new_row_meta_args;
236 }
237
238 /* === WISHLIST SUBPANEL SECTION === */
239
240 /**
241 * Register wishlist panel
242 *
243 * @return void
244 * @since 2.0.0
245 */
246 public function register_panel() {
247
248 $args = array(
249 'create_menu_page' => true,
250 'parent_slug' => '',
251 'page_title' => 'YITH WooCommerce Wishlist',
252 'menu_title' => 'Wishlist',
253 'plugin_slug' => YITH_WCWL_SLUG,
254 'is_extended' => defined( 'YITH_WCWL_EXTENDED' ),
255 'is_premium' => defined( 'YITH_WCWL_PREMIUM' ),
256 'plugin_description' => __( 'Allows your customers to create and share lists of products that they want to purchase on your e-commerce.', 'yith-woocommerce-wishlist' ),
257 /**
258 * APPLY_FILTERS: yith_wcwl_settings_panel_capability
259 *
260 * Filter the capability used to access the plugin panel.
261 *
262 * @param string $capability Capability
263 *
264 * @return string
265 */
266 'capability' => apply_filters( 'yith_wcwl_settings_panel_capability', 'manage_options' ),
267 'parent' => '',
268 'class' => function_exists( 'yith_set_wrapper_class' ) ? yith_set_wrapper_class() : '',
269 'parent_page' => 'yith_plugin_panel',
270 'page' => 'yith_wcwl_panel',
271 'admin-tabs' => $this->available_tabs,
272 'options-path' => YITH_WCWL_DIR . 'plugin-options',
273 'help_tab' => array(
274 'main_video' => array(
275 'desc' => _x( 'Check this video to learn how to <b>configure wishlist and customize options:</b>', '[HELP TAB] Video title', 'yith-woocommerce-wishlist' ),
276 'url' => array(
277 'en' => 'https://www.youtube.com/embed/oMnfyHo819M',
278 'it' => 'https://www.youtube.com/embed/9hM9PgBVNTg',
279 'es' => 'https://www.youtube.com/embed/GwQkNrrHFs4',
280 ),
281 ),
282 'playlists' => array(
283 'en' => 'https://www.youtube.com/watch?v=oMnfyHo819M&list=PLDriKG-6905lyNLO9kQ7GCsldGt7u-4Pa',
284 'it' => 'https://www.youtube.com/watch?v=zpwlE60H6YM&list=PL9c19edGMs09kk40S7FEiXjKKppjS-CAK',
285 'es' => 'https://www.youtube.com/watch?v=5Ftr4_v0s5I&list=PL9Ka3j92PYJMMYXecDH8FB5cxTfTbF4jJ',
286 ),
287 'hc_url' => 'https://support.yithemes.com/hc/en-us/categories/360003468437-YITH-WOOCOMMERCE-WISHLIST',
288 ),
289 );
290
291 // registers premium tab.
292 if ( ! defined( 'YITH_WCWL_PREMIUM' ) ) {
293 $args['premium_tab'] = array(
294 'landing_page_url' => $this->get_premium_landing_uri(),
295 'premium_features' => array(
296 __( 'Enable the wishlist feature for all users or <b>only for registered users</b>', 'yith-woocommerce-wishlist' ),
297 __( 'Allow users to create <b>multiple wishlists</b> (Ex: Christmas, Birthday, etc.) <br>Users can choose the wishlist from a dropdown menu when they click on "Add to wishlist"', 'yith-woocommerce-wishlist' ),
298 __( 'Allow users to set <b>visibility options for each wishlist</b>, by making them either public (visible to everyone), private or shared (visible only to people it has been shared with)', 'yith-woocommerce-wishlist' ),
299 __( 'Choose between <b>different layouts</b> for the wishlist page and for the wishlist content', 'yith-woocommerce-wishlist' ),
300 __( '<b>Allow users to manage their wishlists:</b> rename and delete wishlists, move a product from one wishlist to another, change order of items, quantity, etc.', 'yith-woocommerce-wishlist' ),
301 __( 'Enable an <b>"Ask for an estimate" button</b> to let customers send the content of their wishlist to the admin and get a custom quote', 'yith-woocommerce-wishlist' ),
302 __( '<b>Show a wishlist widget</b> that lists all the products in the wishlists (available also with "mini-cart" style for the header)', 'yith-woocommerce-wishlist' ),
303 __( '<b>Send promotional emails to users</b> who have added specific products to their wishlist', 'yith-woocommerce-wishlist' ),
304 __( '<b>Send an automatic email to the wishlist owner</b> whenever a product in the list is back in stock or on sale', 'yith-woocommerce-wishlist' ),
305 '<b>' . __( 'Regular updates, Translations and Premium Support', 'yith-woocommerce-wishlist' ) . '</b>',
306 ),
307 'main_image_url' => YITH_WCWL_URL . 'assets/images/premium/get-premium-wishlist.jpg',
308 );
309 }
310
311 /* === Fixed: not updated theme === */
312 if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
313 require_once YITH_WCWL_DIR . 'plugin-fw/lib/yit-plugin-panel-wc.php';
314 }
315
316 $this->panel = new YIT_Plugin_Panel_WooCommerce( $args );
317 }
318
319 /**
320 * Adds yith-disabled class
321 * Adds class to fields when required, and when disabled state cannot be achieved any other way (eg. by dependencies)
322 *
323 * @param array $classes Array of field extra classes.
324 * @param array $field Array of field data.
325 *
326 * @return array Filtered array of extra classes
327 */
328 public function mark_options_disabled( $classes, $field ) {
329 if ( isset( $field['id'] ) && 'yith_wfbt_enable_integration' === $field['id'] && ! ( defined( 'YITH_WFBT' ) && YITH_WFBT ) ) {
330 $classes[] = 'yith-disabled';
331 }
332
333 return $classes;
334 }
335
336 /**
337 * Load admin style.
338 *
339 * @return void
340 * @since 1.0.0
341 */
342 public function enqueue() {
343 global $woocommerce, $pagenow;
344
345 if ( 'admin.php' === $pagenow && isset( $_GET['page'] ) && 'yith_wcwl_panel' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
346 wp_enqueue_style( 'yith-wcwl-admin' );
347 wp_enqueue_script( 'yith-wcwl-admin' );
348
349 if ( isset( $_GET['tab'] ) && 'popular' === $_GET['tab'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
350 wp_enqueue_style( 'yith-wcwl-material-icons' );
351 wp_enqueue_editor();
352 }
353 }
354 }
355
356 /**
357 * Get the premium landing uri
358 *
359 * @since 1.0.0
360 * @author Andrea Grillo <andrea.grillo@yithemes.com>
361 * @return string The premium landing link
362 */
363 public function get_premium_landing_uri() {
364 return $this->premium_landing_url;
365 }
366 }
367 }
368
369 /**
370 * Unique access to instance of YITH_WCWL_Admin class
371 *
372 * @return \YITH_WCWL_Admin
373 * @since 2.0.0
374 */
375 function YITH_WCWL_Admin() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
376 if ( defined( 'YITH_WCWL_PREMIUM' ) ) {
377 $instance = YITH_WCWL_Admin_Premium::get_instance();
378 } elseif ( defined( 'YITH_WCWL_EXTENDED' ) ) {
379 $instance = YITH_WCWL_Admin_Extended::get_instance();
380 } else {
381 $instance = YITH_WCWL_Admin::get_instance();
382 }
383
384 return $instance;
385 }
386