Version Description
Release Date - 04 March 2018
- Added support for YITH WooCommerce Product Add-Ons plugin
- Removed background checks for missed actions inside WooCommerce templates.
Release Date - 01 March 2018
- Fixed an issue with deprecated function create_function(); on PHP 7.2+
- Fixed an issue with duplicated products in Wishlist
- Fixed an issue with empty wishlists in database and added cleanup on plugin upgrade
- Fixed an issue when variable products were not removed from wishlist after adding to cart
- Fixed PHP undefined notices in Wishlist table
- Fixed warnings for non-existent products in Wishlist
- Added new option "Show button text" that allows displaying the only add to wishlist icon
- Added custom classes for buttons
- Added "nofollow" attribute for button links
- Improved compatibility with WP Multilang plugin
- Improved compatibility with WooCommerce Multilingual plugin
- Improved compatibility with Personalized Product Option Manager plugin
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.6.2 |
Comparing to | |
See all releases |
Code changes from version 1.6.1 to 1.6.2
- admin/tinvwl.class.php +473 -473
- readme.txt +7 -2
- ti-woocommerce-wishlist.php +2 -2
- tinv-wishlists-function-integration.php +113 -0
- tinv-wishlists-function.php +9 -3
admin/tinvwl.class.php
CHANGED
@@ -1,473 +1,473 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Admin pages class
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist\Admin
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Admin pages class
|
16 |
-
*/
|
17 |
-
class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Constructor
|
21 |
-
*
|
22 |
-
* @param string $plugin_name Plugin name.
|
23 |
-
* @param string $version Plugin version.
|
24 |
-
*/
|
25 |
-
function __construct( $plugin_name, $version ) {
|
26 |
-
$this->_n = $plugin_name;
|
27 |
-
$this->_v = $version;
|
28 |
-
}
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Load functions.
|
32 |
-
* Create Wishlist and Product class.
|
33 |
-
* Load settings classes.
|
34 |
-
*/
|
35 |
-
function load_function() {
|
36 |
-
TII18n();
|
37 |
-
TInvWL_Notice::instance()->add_notice( 'rating', '<p>' . __( 'Woo-Ha! It has been a month since the first wishlist was created with <strong>WooCommerce WishList plugin</strong>!', 'ti-woocommerce-wishlist' ) . '</p><p>' . __( 'What do you think about our plugin?', 'ti-woocommerce-wishlist' ) . '</p><p>' . __( 'Share your love with us.', 'ti-woocommerce-wishlist' ) . '</p>' )->add_trigger( 'admin_init', 'tinvwl_rating_notice_trigger_30' );
|
38 |
-
$this->load_settings();
|
39 |
-
|
40 |
-
$this->define_hooks();
|
41 |
-
}
|
42 |
-
|
43 |
-
/**
|
44 |
-
* Load settings classes.
|
45 |
-
*
|
46 |
-
* @return boolean
|
47 |
-
*/
|
48 |
-
function load_settings() {
|
49 |
-
$dir = TINVWL_PATH . 'admin/settings/';
|
50 |
-
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
$files = scandir( $dir );
|
54 |
-
foreach ( $files as $value ) {
|
55 |
-
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
56 |
-
$file = preg_replace( '/\.class\.php$/i', '', $value );
|
57 |
-
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
58 |
-
$settings = new $class( $this->_n, $this->_v );
|
59 |
-
}
|
60 |
-
}
|
61 |
-
|
62 |
-
return true;
|
63 |
-
}
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Define hooks
|
67 |
-
*/
|
68 |
-
function define_hooks() {
|
69 |
-
add_action( 'admin_menu', array( $this, 'action_menu' ) );
|
70 |
-
if ( 'skip' === filter_input( INPUT_GET, $this->_n . '-wizard' ) ) {
|
71 |
-
update_option( $this->_n . '_wizard', true );
|
72 |
-
}
|
73 |
-
if ( ! get_option( $this->_n . '_wizard' ) ) {
|
74 |
-
add_action( 'admin_notices', array( $this, 'wizard_run_admin_notice' ) );
|
75 |
-
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
76 |
-
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
77 |
-
}
|
78 |
-
add_action( 'woocommerce_system_status_report', array( $this, 'system_report_templates' ) );
|
79 |
-
|
80 |
-
add_action( 'switch_theme', array( $this, 'admin_notice_outdated_templates' ) );
|
81 |
-
add_action( 'tinvwl_updated', array( $this, 'admin_notice_outdated_templates' ) );
|
82 |
-
add_action( 'wp_ajax_' . $this->_n . '_checker_hook', array( $this, 'validation_template' ) );
|
83 |
-
add_action( 'switch_theme', array( $this, 'clear_notice_validation_template' ) );
|
84 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_validate_template' ) );
|
85 |
-
add_action( 'tinvwl_admin_promo_footer', array( $this, 'promo_footer' ) );
|
86 |
-
add_action( 'tinvwl_remove_without_author_wishlist', array( $this, 'remove_old_wishlists' ) );
|
87 |
-
$this->scheduled_remove_wishlist();
|
88 |
-
}
|
89 |
-
|
90 |
-
/**
|
91 |
-
* Error notice if wizard didn't run.
|
92 |
-
*/
|
93 |
-
function wizard_run_admin_notice() {
|
94 |
-
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
95 |
-
__( '<strong>Welcome to WooCommerce Wishlist Plugin<strong> – You‘re almost ready to start :)', 'ti-woocommerce-wishlist' ), // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
96 |
-
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
97 |
-
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' ),
|
98 |
-
esc_url( admin_url( 'index.php?page=' . $this->_n . '&' . $this->_n . '-wizard=skip' ) ),
|
99 |
-
esc_html__( 'Skip Setup', 'ti-woocommerce-wishlist' )
|
100 |
-
);
|
101 |
-
}
|
102 |
-
|
103 |
-
/**
|
104 |
-
* Error notice if wishlist page not set.
|
105 |
-
*/
|
106 |
-
function empty_page_admin_notice() {
|
107 |
-
printf( '<div class="notice notice-error is-dismissible" style="position: relative;"><p>%1$s <a href="%2$s">%3$s</a>%4$s<a href="%5$s">%6$s</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss' ) . '</span></button></div>', // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
108 |
-
esc_html__( 'Link to Wishlists does not work!', 'ti-woocommerce-wishlist' ),
|
109 |
-
esc_url( $this->admin_url( '' ) . '#general' ),
|
110 |
-
esc_html__( 'Please apply the Wishlist page', 'ti-woocommerce-wishlist' ),
|
111 |
-
esc_html__( ' or ', 'ti-woocommerce-wishlist' ),
|
112 |
-
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
113 |
-
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' )
|
114 |
-
);
|
115 |
-
}
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Creation mune and sub-menu
|
119 |
-
*/
|
120 |
-
function action_menu() {
|
121 |
-
$page = add_menu_page( 'TI Wishlist', 'TI Wishlist', 'manage_options', $this->_n, null, TINVWL_URL . 'asset/img/icon_menu.png', 56 );
|
122 |
-
add_action( "load-$page", array( $this, 'onload' ) );
|
123 |
-
$menu = apply_filters( $this->_n . '_admin_menu', array() );
|
124 |
-
foreach ( $menu as $item ) {
|
125 |
-
if ( ! array_key_exists( 'page_title', $item ) ) {
|
126 |
-
$item['page_title'] = $item['title'];
|
127 |
-
}
|
128 |
-
if ( ! array_key_exists( 'parent', $item ) ) {
|
129 |
-
$item['parent'] = $this->_n;
|
130 |
-
}
|
131 |
-
if ( ! array_key_exists( 'capability', $item ) ) {
|
132 |
-
$item['capability'] = 'manage_options';
|
133 |
-
}
|
134 |
-
$item['slug'] = implode( '-', array_filter( array( $this->_n, $item['slug'] ) ) );
|
135 |
-
|
136 |
-
$page = add_submenu_page( $item['parent'], $item['page_title'], $item['title'], $item['capability'], $item['slug'], $item['method'] );
|
137 |
-
add_action( "load-$page", array( $this, 'onload' ) );
|
138 |
-
}
|
139 |
-
}
|
140 |
-
|
141 |
-
/**
|
142 |
-
* Load style and javascript
|
143 |
-
*/
|
144 |
-
function onload() {
|
145 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
146 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
147 |
-
add_filter( 'admin_footer_text', array( $this, 'footer_admin' ) );
|
148 |
-
add_filter( 'screen_options_show_screen', array( $this, 'screen_options_hide_screen' ), 10, 2 );
|
149 |
-
|
150 |
-
add_filter( $this->_n . '_view_panelstatus', array( $this, 'status_panel' ), 9999 );
|
151 |
-
}
|
152 |
-
|
153 |
-
/**
|
154 |
-
* Load style
|
155 |
-
*/
|
156 |
-
function enqueue_styles() {
|
157 |
-
wp_enqueue_style( 'gfonts', ( is_ssl() ? 'https' : 'http' ) . '://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800', '', null, 'all' );
|
158 |
-
wp_enqueue_style( $this->_n, TINVWL_URL . 'asset/css/admin.css', array(), $this->_v, 'all' );
|
159 |
-
wp_enqueue_style( $this->_n . '-font-awesome', TINVWL_URL . 'asset/css/font-awesome.min.css', array(), $this->_v, 'all' );
|
160 |
-
wp_enqueue_style( $this->_n . '-form', TINVWL_URL . 'asset/css/admin-form.css', array(), $this->_v, 'all' );
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Load javascript
|
165 |
-
*/
|
166 |
-
function enqueue_scripts() {
|
167 |
-
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
168 |
-
wp_enqueue_script( $this->_n . '-bootstrap', TINVWL_URL . 'asset/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_v, 'all' );
|
169 |
-
wp_register_script( $this->_n, TINVWL_URL . 'asset/js/admin' . $suffix . '.js', array(
|
170 |
-
'jquery',
|
171 |
-
'wp-color-picker'
|
172 |
-
), $this->_v, 'all' );
|
173 |
-
wp_localize_script( $this->_n, 'tinvwl_comfirm', array(
|
174 |
-
'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
|
175 |
-
) );
|
176 |
-
wp_enqueue_script( $this->_n );
|
177 |
-
|
178 |
-
$user_id = get_current_user_id();
|
179 |
-
$user_info = get_userdata( $user_id );
|
180 |
-
|
181 |
-
wp_add_inline_script( $this->_n, 'window.intercomSettings = {
|
182 |
-
app_id: "zyh6v0pc",
|
183 |
-
email: "' . $user_info->user_email . '",
|
184 |
-
name: "' . $user_info->user_nicename . '",
|
185 |
-
"Website": "' . get_site_url() . '",
|
186 |
-
"Plugin name": "WooCommerce Wishlist Plugin",
|
187 |
-
"Plugin version":"' . TINVWL_FVERSION . '",
|
188 |
-
};
|
189 |
-
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic("reattach_activator");ic("update",intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement("script");s.type="text/javascript";s.async=true;s.src="https://widget.intercom.io/widget/zyh6v0pc";var x=d.getElementsByTagName("script")[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent("onload",l);}else{w.addEventListener("load",l,false);}}})()' );
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Add plugin footer copywriting
|
194 |
-
*/
|
195 |
-
function footer_admin() {
|
196 |
-
do_action( 'tinvwl_admin_promo_footer' );
|
197 |
-
}
|
198 |
-
|
199 |
-
/**
|
200 |
-
* Promo in footer for wishlist
|
201 |
-
*/
|
202 |
-
function promo_footer() {
|
203 |
-
echo 'Made with <i class="fa fa-heart"></i> by <a href="https://templateinvaders.com/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=made_by&partner=' . TINVWL_UTM_SOURCE . '">TemplateInvaders</a><br />If you like WooCommerce Wishlist Plugin please leave us a <a href="https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/#new-post"><span><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i></span></a> rating.'; // WPCS: xss ok.
|
204 |
-
}
|
205 |
-
|
206 |
-
/**
|
207 |
-
* Create Upgrade button
|
208 |
-
*
|
209 |
-
* @param array $panel Panel Button.
|
210 |
-
*
|
211 |
-
* @return array
|
212 |
-
*/
|
213 |
-
function status_panel( $panel ) {
|
214 |
-
array_unshift( $panel, sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="fa fa-star"></i><span class="tinvwl-txt">%s</span></a>', 'https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=header_upgrade&partner=' . TINVWL_UTM_SOURCE, __( 'Upgrade to Premium', 'ti-woocommerce-wishlist' ) ) );
|
215 |
-
|
216 |
-
return $panel;
|
217 |
-
}
|
218 |
-
|
219 |
-
/**
|
220 |
-
* Templates overriding status check.
|
221 |
-
*
|
222 |
-
* @param boolean $outdated Out date status.
|
223 |
-
*
|
224 |
-
* @return string
|
225 |
-
*/
|
226 |
-
function templates_status_check( $outdated = false ) {
|
227 |
-
|
228 |
-
$found_files = array();
|
229 |
-
|
230 |
-
$scanned_files = WC_Admin_Status::scan_template_files( TINVWL_PATH . '/templates/' );
|
231 |
-
|
232 |
-
foreach ( $scanned_files as $file ) {
|
233 |
-
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
234 |
-
$theme_file = get_stylesheet_directory() . '/' . $file;
|
235 |
-
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
|
236 |
-
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
|
237 |
-
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
238 |
-
$theme_file = get_template_directory() . '/' . $file;
|
239 |
-
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
|
240 |
-
$theme_file = get_template_directory() . '/woocommerce/' . $file;
|
241 |
-
} else {
|
242 |
-
$theme_file = false;
|
243 |
-
}
|
244 |
-
|
245 |
-
if ( ! empty( $theme_file ) ) {
|
246 |
-
$core_version = WC_Admin_Status::get_file_version( TINVWL_PATH . '/templates/' . $file );
|
247 |
-
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
|
248 |
-
|
249 |
-
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
250 |
-
if ( $outdated ) {
|
251 |
-
return 'outdated';
|
252 |
-
}
|
253 |
-
$found_files[] = sprintf( __( '<code>%1$s</code> version <strong style="color:red">%2$s</strong> is out of date. The core version is <strong style="color:red">%3$s</strong>', 'ti-woocommerce-wishlist' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
254 |
-
} else {
|
255 |
-
$found_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file );
|
256 |
-
}
|
257 |
-
}
|
258 |
-
}
|
259 |
-
|
260 |
-
return $found_files;
|
261 |
-
}
|
262 |
-
|
263 |
-
/**
|
264 |
-
* Templates overriding status for WooCommerce Status report page.
|
265 |
-
*/
|
266 |
-
function system_report_templates() {
|
267 |
-
|
268 |
-
TInvWL_View::view( 'templates-status', array( 'found_files' => $this->templates_status_check() ) );
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Outdated templates notice.
|
273 |
-
*/
|
274 |
-
function admin_notice_outdated_templates() {
|
275 |
-
if ( 'outdated' === $this->templates_status_check( true ) ) {
|
276 |
-
|
277 |
-
$theme = wp_get_theme();
|
278 |
-
|
279 |
-
$html = sprintf( __( '<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href="%2$s">system status page</a>.<br> If in doubt, check with the author of the theme.', 'ti-woocommerce-wishlist' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) );
|
280 |
-
|
281 |
-
WC_Admin_Notices::add_custom_notice( 'outdated_templates', $html );
|
282 |
-
} else {
|
283 |
-
WC_Admin_Notices::remove_notice( 'outdated_templates' );
|
284 |
-
}
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* Load javascript for validation templates
|
289 |
-
*/
|
290 |
-
function enqueue_scripts_validate_template() {
|
291 |
-
$theme = wp_get_theme();
|
292 |
-
$theme = $theme->get_template();
|
293 |
-
if ( tinv_get_option( 'template_checker', 'theme' ) !== $theme ) {
|
294 |
-
tinv_update_option( 'template_checker', '', array() );
|
295 |
-
tinv_update_option( 'template_checker', 'theme', $theme );
|
296 |
-
tinv_update_option( 'template_checker', 'checked', false );
|
297 |
-
tinv_update_option( 'template_checker', 'time', 0 );
|
298 |
-
}
|
299 |
-
if ( tinv_get_option( 'template_checker', 'checked' ) && absint( tinv_get_option( 'template_checker', 'time' ) ) + HOUR_IN_SECONDS > time() ) {
|
300 |
-
return;
|
301 |
-
}
|
302 |
-
$types = array_keys( wc_get_product_types() );
|
303 |
-
foreach ( $types as $type => $type_name ) {
|
304 |
-
if ( ! tinv_get_option( 'template_checker', 'missing_hook_' . $type ) ) {
|
305 |
-
$data = filter_input_array( INPUT_GET, array(
|
306 |
-
'wc-hide-notice' => FILTER_DEFAULT,
|
307 |
-
'_wc_notice_nonce' => FILTER_DEFAULT,
|
308 |
-
) );
|
309 |
-
if ( 'missing_hook_' . $type === $data['wc-hide-notice'] && wp_verify_nonce( $data['_wc_notice_nonce'], 'woocommerce_hide_notices_nonce' ) ) {
|
310 |
-
tinv_update_option( 'template_checker', 'missing_hook_' . $type, true );
|
311 |
-
}
|
312 |
-
}
|
313 |
-
}
|
314 |
-
if ( ! tinv_get_option( 'template_checker', 'hide_product_listing' ) ) {
|
315 |
-
$data = filter_input_array( INPUT_GET, array(
|
316 |
-
'wc-hide-notice' => FILTER_DEFAULT,
|
317 |
-
'_wc_notice_nonce' => FILTER_DEFAULT,
|
318 |
-
) );
|
319 |
-
if ( 'missing_hook_listing' === $data['wc-hide-notice'] && wp_verify_nonce( $data['_wc_notice_nonce'], 'woocommerce_hide_notices_nonce' ) ) {
|
320 |
-
tinv_update_option( 'template_checker', 'hide_product_listing', true );
|
321 |
-
}
|
322 |
-
}
|
323 |
-
|
324 |
-
wp_enqueue_script( $this->_n . '-checker', TINVWL_URL . 'asset/js/admin.checker.min.js', array( 'jquery' ), $this->_v, 'all' );
|
325 |
-
}
|
326 |
-
|
327 |
-
/**
|
328 |
-
* Validation templates hook from request remote page
|
329 |
-
*/
|
330 |
-
function validation_template() {
|
331 |
-
global $post, $product;
|
332 |
-
|
333 |
-
if ( tinv_get_option( 'template_checker', 'checked' ) ) {
|
334 |
-
return;
|
335 |
-
}
|
336 |
-
if ( absint( tinv_get_option( 'template_checker', 'time' ) ) + HOUR_IN_SECONDS > time() ) {
|
337 |
-
return;
|
338 |
-
}
|
339 |
-
tinv_update_option( 'template_checker', 'time', time() );
|
340 |
-
$tags = array(
|
341 |
-
'woocommerce_single_product_summary' => 'tinvwl_single_product_summary',
|
342 |
-
'woocommerce_before_add_to_cart_button' => 'tinvwl_before_add_to_cart_button',
|
343 |
-
'woocommerce_after_add_to_cart_button' => 'tinvwl_after_add_to_cart_button',
|
344 |
-
);
|
345 |
-
$tch = TInvWL_CheckerHook::instance();
|
346 |
-
$tch->add_action( $tags );
|
347 |
-
$tch->add_action( array_keys( $tags ) );
|
348 |
-
|
349 |
-
$types = wc_get_product_types();
|
350 |
-
|
351 |
-
$check = true;
|
352 |
-
foreach ( $types as $type => $type_name ) {
|
353 |
-
if ( tinv_get_option( 'template_checker', 'missing_hook_' . $type ) ) {
|
354 |
-
continue;
|
355 |
-
}
|
356 |
-
|
357 |
-
if ( function_exists( 'wc_get_products' ) ) {
|
358 |
-
$products = wc_get_products( array(
|
359 |
-
'status' => 'publish',
|
360 |
-
'type' => $type,
|
361 |
-
'limit' => 1,
|
362 |
-
) );
|
363 |
-
} else {
|
364 |
-
$products = array_map( 'wc_get_product', get_posts( array(
|
365 |
-
'post_type' => 'product',
|
366 |
-
'post_status' => 'publish',
|
367 |
-
'numberposts' => 1,
|
368 |
-
'tax_query' => array(
|
369 |
-
array(
|
370 |
-
'taxonomy' => 'product_type',
|
371 |
-
'field' => 'slug',
|
372 |
-
'terms' => $type,
|
373 |
-
),
|
374 |
-
),
|
375 |
-
) ) );
|
376 |
-
}
|
377 |
-
if ( ! empty( $products ) ) {
|
378 |
-
$product = array_shift( $products );
|
379 |
-
$post = get_post( $product->get_id() ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
|
380 |
-
$result = $tch->run( array(
|
381 |
-
'template' => array(
|
382 |
-
'content-single-product.php',
|
383 |
-
'single-product/add-to-cart/' . $type . '.php'
|
384 |
-
),
|
385 |
-
'template_args' => array(
|
386 |
-
'available_variations' => array( 1, 2, 3, 4, 5 ),
|
387 |
-
'attributes' => array(),
|
388 |
-
),
|
389 |
-
'url' => $product->get_permalink(),
|
390 |
-
) );
|
391 |
-
if ( ! empty( $result ) ) {
|
392 |
-
$result = array_keys( $result );
|
393 |
-
foreach ( $result as $key => $tag ) {
|
394 |
-
if ( array_key_exists( $tag, $tags ) ) {
|
395 |
-
$tags[ $tag ];
|
396 |
-
if ( ! array_key_exists( $tag, $tags ) ) {
|
397 |
-
unset( $result[ $key ] );
|
398 |
-
}
|
399 |
-
} else {
|
400 |
-
unset( $result[ $key ] );
|
401 |
-
}
|
402 |
-
}
|
403 |
-
if ( ! empty( $result ) ) {
|
404 |
-
WC_Admin_Notices::add_custom_notice( 'missing_hook_' . $type, sprintf( _n( 'The "Add to Wishlist" button may work improperly in a product type "%1$s" because the hook "%2$s" is missing.<br />Please, ask your theme developers to check the theme templates or <a href="https://templateinvaders.com/help/" target="_blank">contact us</a> for assistance.', 'The "Add to Wishlist" button may work improperly in a product type "%1$s" because the hooks "%2$s" are missing.<br />Please, ask your theme developers to check the theme templates or <a href="https://templateinvaders.com/help/" target="_blank">contact us</a> for assistance.', count( $result ), 'ti-woocommerce-wishlist' ), $type_name, '<strong>' . join( '</strong>, <strong>', $result ) . '</strong>' ) );
|
405 |
-
$check = false;
|
406 |
-
} else {
|
407 |
-
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
408 |
-
}
|
409 |
-
} else {
|
410 |
-
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
411 |
-
}
|
412 |
-
}
|
413 |
-
} // End foreach().
|
414 |
-
|
415 |
-
tinv_update_option( 'template_checker', 'checked', $check );
|
416 |
-
wp_die();
|
417 |
-
}
|
418 |
-
|
419 |
-
/**
|
420 |
-
* Clear notice validation template when theme switched
|
421 |
-
*/
|
422 |
-
function clear_notice_validation_template() {
|
423 |
-
WC_Admin_Notices::remove_notice( 'missing_hook_listing' );
|
424 |
-
$types = wc_get_product_types();
|
425 |
-
foreach ( $types as $type => $type_name ) {
|
426 |
-
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
427 |
-
}
|
428 |
-
tinv_update_option( 'template_checker', '', array() );
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Disable screen option on plugin pages
|
433 |
-
*
|
434 |
-
* @param boolean $show_screen Show screen.
|
435 |
-
* @param \WP_Screen $_this Screen option page.
|
436 |
-
*
|
437 |
-
* @return boolean
|
438 |
-
*/
|
439 |
-
function screen_options_hide_screen( $show_screen, $_this ) {
|
440 |
-
if ( $this->_n === $_this->parent_base || $this->_n === $_this->parent_file ) {
|
441 |
-
return false;
|
442 |
-
}
|
443 |
-
|
444 |
-
return $show_screen;
|
445 |
-
}
|
446 |
-
|
447 |
-
/**
|
448 |
-
* Check if there is a hook in the cron
|
449 |
-
*/
|
450 |
-
function scheduled_remove_wishlist() {
|
451 |
-
$timestamp = wp_next_scheduled( 'tinvwl_remove_without_author_wishlist' );
|
452 |
-
if ( ! $timestamp ) {
|
453 |
-
$time = strtotime( '00:00 today +1 HOURS' );
|
454 |
-
wp_schedule_event( $time, 'daily', 'tinvwl_remove_without_author_wishlist' );
|
455 |
-
}
|
456 |
-
}
|
457 |
-
|
458 |
-
/**
|
459 |
-
* Removing old wishlist without a user older than 34 days
|
460 |
-
*/
|
461 |
-
public function remove_old_wishlists() {
|
462 |
-
$wl = new TInvWL_Wishlist();
|
463 |
-
$wishlists = $wl->get( array(
|
464 |
-
'author' => 0,
|
465 |
-
'type' => 'default',
|
466 |
-
'sql' => 'SELECT * FROM {table} {where} AND `date` < DATE_SUB( CURDATE(), INTERVAL 34 DAY)',
|
467 |
-
) );
|
468 |
-
foreach ( $wishlists as $wishlist ) {
|
469 |
-
$wl->remove( $wishlist['ID'] );
|
470 |
-
}
|
471 |
-
}
|
472 |
-
|
473 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Admin pages class
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist\Admin
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Admin pages class
|
16 |
+
*/
|
17 |
+
class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Constructor
|
21 |
+
*
|
22 |
+
* @param string $plugin_name Plugin name.
|
23 |
+
* @param string $version Plugin version.
|
24 |
+
*/
|
25 |
+
function __construct( $plugin_name, $version ) {
|
26 |
+
$this->_n = $plugin_name;
|
27 |
+
$this->_v = $version;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load functions.
|
32 |
+
* Create Wishlist and Product class.
|
33 |
+
* Load settings classes.
|
34 |
+
*/
|
35 |
+
function load_function() {
|
36 |
+
TII18n();
|
37 |
+
TInvWL_Notice::instance()->add_notice( 'rating', '<p>' . __( 'Woo-Ha! It has been a month since the first wishlist was created with <strong>WooCommerce WishList plugin</strong>!', 'ti-woocommerce-wishlist' ) . '</p><p>' . __( 'What do you think about our plugin?', 'ti-woocommerce-wishlist' ) . '</p><p>' . __( 'Share your love with us.', 'ti-woocommerce-wishlist' ) . '</p>' )->add_trigger( 'admin_init', 'tinvwl_rating_notice_trigger_30' );
|
38 |
+
$this->load_settings();
|
39 |
+
|
40 |
+
$this->define_hooks();
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Load settings classes.
|
45 |
+
*
|
46 |
+
* @return boolean
|
47 |
+
*/
|
48 |
+
function load_settings() {
|
49 |
+
$dir = TINVWL_PATH . 'admin/settings/';
|
50 |
+
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
51 |
+
return false;
|
52 |
+
}
|
53 |
+
$files = scandir( $dir );
|
54 |
+
foreach ( $files as $value ) {
|
55 |
+
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
56 |
+
$file = preg_replace( '/\.class\.php$/i', '', $value );
|
57 |
+
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
58 |
+
$settings = new $class( $this->_n, $this->_v );
|
59 |
+
}
|
60 |
+
}
|
61 |
+
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Define hooks
|
67 |
+
*/
|
68 |
+
function define_hooks() {
|
69 |
+
add_action( 'admin_menu', array( $this, 'action_menu' ) );
|
70 |
+
if ( 'skip' === filter_input( INPUT_GET, $this->_n . '-wizard' ) ) {
|
71 |
+
update_option( $this->_n . '_wizard', true );
|
72 |
+
}
|
73 |
+
if ( ! get_option( $this->_n . '_wizard' ) ) {
|
74 |
+
add_action( 'admin_notices', array( $this, 'wizard_run_admin_notice' ) );
|
75 |
+
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
76 |
+
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
77 |
+
}
|
78 |
+
add_action( 'woocommerce_system_status_report', array( $this, 'system_report_templates' ) );
|
79 |
+
|
80 |
+
add_action( 'switch_theme', array( $this, 'admin_notice_outdated_templates' ) );
|
81 |
+
add_action( 'tinvwl_updated', array( $this, 'admin_notice_outdated_templates' ) );
|
82 |
+
// add_action( 'wp_ajax_' . $this->_n . '_checker_hook', array( $this, 'validation_template' ) );
|
83 |
+
add_action( 'switch_theme', array( $this, 'clear_notice_validation_template' ) );
|
84 |
+
// add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_validate_template' ) );
|
85 |
+
add_action( 'tinvwl_admin_promo_footer', array( $this, 'promo_footer' ) );
|
86 |
+
add_action( 'tinvwl_remove_without_author_wishlist', array( $this, 'remove_old_wishlists' ) );
|
87 |
+
$this->scheduled_remove_wishlist();
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Error notice if wizard didn't run.
|
92 |
+
*/
|
93 |
+
function wizard_run_admin_notice() {
|
94 |
+
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
95 |
+
__( '<strong>Welcome to WooCommerce Wishlist Plugin<strong> – You‘re almost ready to start :)', 'ti-woocommerce-wishlist' ), // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
96 |
+
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
97 |
+
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' ),
|
98 |
+
esc_url( admin_url( 'index.php?page=' . $this->_n . '&' . $this->_n . '-wizard=skip' ) ),
|
99 |
+
esc_html__( 'Skip Setup', 'ti-woocommerce-wishlist' )
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Error notice if wishlist page not set.
|
105 |
+
*/
|
106 |
+
function empty_page_admin_notice() {
|
107 |
+
printf( '<div class="notice notice-error is-dismissible" style="position: relative;"><p>%1$s <a href="%2$s">%3$s</a>%4$s<a href="%5$s">%6$s</a></p><button type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss' ) . '</span></button></div>', // @codingStandardsIgnoreLine WordPress.XSS.EscapeOutput.OutputNotEscaped
|
108 |
+
esc_html__( 'Link to Wishlists does not work!', 'ti-woocommerce-wishlist' ),
|
109 |
+
esc_url( $this->admin_url( '' ) . '#general' ),
|
110 |
+
esc_html__( 'Please apply the Wishlist page', 'ti-woocommerce-wishlist' ),
|
111 |
+
esc_html__( ' or ', 'ti-woocommerce-wishlist' ),
|
112 |
+
esc_url( admin_url( 'index.php?page=tinvwl-wizard' ) ),
|
113 |
+
esc_html__( 'Run the Setup Wizard', 'ti-woocommerce-wishlist' )
|
114 |
+
);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Creation mune and sub-menu
|
119 |
+
*/
|
120 |
+
function action_menu() {
|
121 |
+
$page = add_menu_page( 'TI Wishlist', 'TI Wishlist', 'manage_options', $this->_n, null, TINVWL_URL . 'asset/img/icon_menu.png', 56 );
|
122 |
+
add_action( "load-$page", array( $this, 'onload' ) );
|
123 |
+
$menu = apply_filters( $this->_n . '_admin_menu', array() );
|
124 |
+
foreach ( $menu as $item ) {
|
125 |
+
if ( ! array_key_exists( 'page_title', $item ) ) {
|
126 |
+
$item['page_title'] = $item['title'];
|
127 |
+
}
|
128 |
+
if ( ! array_key_exists( 'parent', $item ) ) {
|
129 |
+
$item['parent'] = $this->_n;
|
130 |
+
}
|
131 |
+
if ( ! array_key_exists( 'capability', $item ) ) {
|
132 |
+
$item['capability'] = 'manage_options';
|
133 |
+
}
|
134 |
+
$item['slug'] = implode( '-', array_filter( array( $this->_n, $item['slug'] ) ) );
|
135 |
+
|
136 |
+
$page = add_submenu_page( $item['parent'], $item['page_title'], $item['title'], $item['capability'], $item['slug'], $item['method'] );
|
137 |
+
add_action( "load-$page", array( $this, 'onload' ) );
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Load style and javascript
|
143 |
+
*/
|
144 |
+
function onload() {
|
145 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
146 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
147 |
+
add_filter( 'admin_footer_text', array( $this, 'footer_admin' ) );
|
148 |
+
add_filter( 'screen_options_show_screen', array( $this, 'screen_options_hide_screen' ), 10, 2 );
|
149 |
+
|
150 |
+
add_filter( $this->_n . '_view_panelstatus', array( $this, 'status_panel' ), 9999 );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Load style
|
155 |
+
*/
|
156 |
+
function enqueue_styles() {
|
157 |
+
wp_enqueue_style( 'gfonts', ( is_ssl() ? 'https' : 'http' ) . '://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800', '', null, 'all' );
|
158 |
+
wp_enqueue_style( $this->_n, TINVWL_URL . 'asset/css/admin.css', array(), $this->_v, 'all' );
|
159 |
+
wp_enqueue_style( $this->_n . '-font-awesome', TINVWL_URL . 'asset/css/font-awesome.min.css', array(), $this->_v, 'all' );
|
160 |
+
wp_enqueue_style( $this->_n . '-form', TINVWL_URL . 'asset/css/admin-form.css', array(), $this->_v, 'all' );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* Load javascript
|
165 |
+
*/
|
166 |
+
function enqueue_scripts() {
|
167 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
168 |
+
wp_enqueue_script( $this->_n . '-bootstrap', TINVWL_URL . 'asset/js/bootstrap' . $suffix . '.js', array( 'jquery' ), $this->_v, 'all' );
|
169 |
+
wp_register_script( $this->_n, TINVWL_URL . 'asset/js/admin' . $suffix . '.js', array(
|
170 |
+
'jquery',
|
171 |
+
'wp-color-picker'
|
172 |
+
), $this->_v, 'all' );
|
173 |
+
wp_localize_script( $this->_n, 'tinvwl_comfirm', array(
|
174 |
+
'text_comfirm_reset' => __( 'Are you sure you want to reset the settings?', 'ti-woocommerce-wishlist' ),
|
175 |
+
) );
|
176 |
+
wp_enqueue_script( $this->_n );
|
177 |
+
|
178 |
+
$user_id = get_current_user_id();
|
179 |
+
$user_info = get_userdata( $user_id );
|
180 |
+
|
181 |
+
wp_add_inline_script( $this->_n, 'window.intercomSettings = {
|
182 |
+
app_id: "zyh6v0pc",
|
183 |
+
email: "' . $user_info->user_email . '",
|
184 |
+
name: "' . $user_info->user_nicename . '",
|
185 |
+
"Website": "' . get_site_url() . '",
|
186 |
+
"Plugin name": "WooCommerce Wishlist Plugin",
|
187 |
+
"Plugin version":"' . TINVWL_FVERSION . '",
|
188 |
+
};
|
189 |
+
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic("reattach_activator");ic("update",intercomSettings);}else{var d=document;var i=function(){i.c(arguments)};i.q=[];i.c=function(args){i.q.push(args)};w.Intercom=i;function l(){var s=d.createElement("script");s.type="text/javascript";s.async=true;s.src="https://widget.intercom.io/widget/zyh6v0pc";var x=d.getElementsByTagName("script")[0];x.parentNode.insertBefore(s,x);}if(w.attachEvent){w.attachEvent("onload",l);}else{w.addEventListener("load",l,false);}}})()' );
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Add plugin footer copywriting
|
194 |
+
*/
|
195 |
+
function footer_admin() {
|
196 |
+
do_action( 'tinvwl_admin_promo_footer' );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* Promo in footer for wishlist
|
201 |
+
*/
|
202 |
+
function promo_footer() {
|
203 |
+
echo 'Made with <i class="fa fa-heart"></i> by <a href="https://templateinvaders.com/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=made_by&partner=' . TINVWL_UTM_SOURCE . '">TemplateInvaders</a><br />If you like WooCommerce Wishlist Plugin please leave us a <a href="https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/#new-post"><span><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i><i class="fa fa-star"></i></span></a> rating.'; // WPCS: xss ok.
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Create Upgrade button
|
208 |
+
*
|
209 |
+
* @param array $panel Panel Button.
|
210 |
+
*
|
211 |
+
* @return array
|
212 |
+
*/
|
213 |
+
function status_panel( $panel ) {
|
214 |
+
array_unshift( $panel, sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="fa fa-star"></i><span class="tinvwl-txt">%s</span></a>', 'https://templateinvaders.com/product/ti-woocommerce-wishlist-wordpress-plugin/?utm_source=' . TINVWL_UTM_SOURCE . '&utm_campaign=' . TINVWL_UTM_CAMPAIGN . '&utm_medium=' . TINVWL_UTM_MEDIUM . '&utm_content=header_upgrade&partner=' . TINVWL_UTM_SOURCE, __( 'Upgrade to Premium', 'ti-woocommerce-wishlist' ) ) );
|
215 |
+
|
216 |
+
return $panel;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Templates overriding status check.
|
221 |
+
*
|
222 |
+
* @param boolean $outdated Out date status.
|
223 |
+
*
|
224 |
+
* @return string
|
225 |
+
*/
|
226 |
+
function templates_status_check( $outdated = false ) {
|
227 |
+
|
228 |
+
$found_files = array();
|
229 |
+
|
230 |
+
$scanned_files = WC_Admin_Status::scan_template_files( TINVWL_PATH . '/templates/' );
|
231 |
+
|
232 |
+
foreach ( $scanned_files as $file ) {
|
233 |
+
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
234 |
+
$theme_file = get_stylesheet_directory() . '/' . $file;
|
235 |
+
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
|
236 |
+
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
|
237 |
+
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
238 |
+
$theme_file = get_template_directory() . '/' . $file;
|
239 |
+
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
|
240 |
+
$theme_file = get_template_directory() . '/woocommerce/' . $file;
|
241 |
+
} else {
|
242 |
+
$theme_file = false;
|
243 |
+
}
|
244 |
+
|
245 |
+
if ( ! empty( $theme_file ) ) {
|
246 |
+
$core_version = WC_Admin_Status::get_file_version( TINVWL_PATH . '/templates/' . $file );
|
247 |
+
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
|
248 |
+
|
249 |
+
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
250 |
+
if ( $outdated ) {
|
251 |
+
return 'outdated';
|
252 |
+
}
|
253 |
+
$found_files[] = sprintf( __( '<code>%1$s</code> version <strong style="color:red">%2$s</strong> is out of date. The core version is <strong style="color:red">%3$s</strong>', 'ti-woocommerce-wishlist' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
254 |
+
} else {
|
255 |
+
$found_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file );
|
256 |
+
}
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
return $found_files;
|
261 |
+
}
|
262 |
+
|
263 |
+
/**
|
264 |
+
* Templates overriding status for WooCommerce Status report page.
|
265 |
+
*/
|
266 |
+
function system_report_templates() {
|
267 |
+
|
268 |
+
TInvWL_View::view( 'templates-status', array( 'found_files' => $this->templates_status_check() ) );
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Outdated templates notice.
|
273 |
+
*/
|
274 |
+
function admin_notice_outdated_templates() {
|
275 |
+
if ( 'outdated' === $this->templates_status_check( true ) ) {
|
276 |
+
|
277 |
+
$theme = wp_get_theme();
|
278 |
+
|
279 |
+
$html = sprintf( __( '<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href="%2$s">system status page</a>.<br> If in doubt, check with the author of the theme.', 'ti-woocommerce-wishlist' ), esc_html( $theme['Name'] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) );
|
280 |
+
|
281 |
+
WC_Admin_Notices::add_custom_notice( 'outdated_templates', $html );
|
282 |
+
} else {
|
283 |
+
WC_Admin_Notices::remove_notice( 'outdated_templates' );
|
284 |
+
}
|
285 |
+
}
|
286 |
+
|
287 |
+
/**
|
288 |
+
* Load javascript for validation templates
|
289 |
+
*/
|
290 |
+
function enqueue_scripts_validate_template() {
|
291 |
+
$theme = wp_get_theme();
|
292 |
+
$theme = $theme->get_template();
|
293 |
+
if ( tinv_get_option( 'template_checker', 'theme' ) !== $theme ) {
|
294 |
+
tinv_update_option( 'template_checker', '', array() );
|
295 |
+
tinv_update_option( 'template_checker', 'theme', $theme );
|
296 |
+
tinv_update_option( 'template_checker', 'checked', false );
|
297 |
+
tinv_update_option( 'template_checker', 'time', 0 );
|
298 |
+
}
|
299 |
+
if ( tinv_get_option( 'template_checker', 'checked' ) && absint( tinv_get_option( 'template_checker', 'time' ) ) + HOUR_IN_SECONDS > time() ) {
|
300 |
+
return;
|
301 |
+
}
|
302 |
+
$types = array_keys( wc_get_product_types() );
|
303 |
+
foreach ( $types as $type => $type_name ) {
|
304 |
+
if ( ! tinv_get_option( 'template_checker', 'missing_hook_' . $type ) ) {
|
305 |
+
$data = filter_input_array( INPUT_GET, array(
|
306 |
+
'wc-hide-notice' => FILTER_DEFAULT,
|
307 |
+
'_wc_notice_nonce' => FILTER_DEFAULT,
|
308 |
+
) );
|
309 |
+
if ( 'missing_hook_' . $type === $data['wc-hide-notice'] && wp_verify_nonce( $data['_wc_notice_nonce'], 'woocommerce_hide_notices_nonce' ) ) {
|
310 |
+
tinv_update_option( 'template_checker', 'missing_hook_' . $type, true );
|
311 |
+
}
|
312 |
+
}
|
313 |
+
}
|
314 |
+
if ( ! tinv_get_option( 'template_checker', 'hide_product_listing' ) ) {
|
315 |
+
$data = filter_input_array( INPUT_GET, array(
|
316 |
+
'wc-hide-notice' => FILTER_DEFAULT,
|
317 |
+
'_wc_notice_nonce' => FILTER_DEFAULT,
|
318 |
+
) );
|
319 |
+
if ( 'missing_hook_listing' === $data['wc-hide-notice'] && wp_verify_nonce( $data['_wc_notice_nonce'], 'woocommerce_hide_notices_nonce' ) ) {
|
320 |
+
tinv_update_option( 'template_checker', 'hide_product_listing', true );
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
wp_enqueue_script( $this->_n . '-checker', TINVWL_URL . 'asset/js/admin.checker.min.js', array( 'jquery' ), $this->_v, 'all' );
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Validation templates hook from request remote page
|
329 |
+
*/
|
330 |
+
function validation_template() {
|
331 |
+
global $post, $product;
|
332 |
+
|
333 |
+
if ( tinv_get_option( 'template_checker', 'checked' ) ) {
|
334 |
+
return;
|
335 |
+
}
|
336 |
+
if ( absint( tinv_get_option( 'template_checker', 'time' ) ) + HOUR_IN_SECONDS > time() ) {
|
337 |
+
return;
|
338 |
+
}
|
339 |
+
tinv_update_option( 'template_checker', 'time', time() );
|
340 |
+
$tags = array(
|
341 |
+
'woocommerce_single_product_summary' => 'tinvwl_single_product_summary',
|
342 |
+
'woocommerce_before_add_to_cart_button' => 'tinvwl_before_add_to_cart_button',
|
343 |
+
'woocommerce_after_add_to_cart_button' => 'tinvwl_after_add_to_cart_button',
|
344 |
+
);
|
345 |
+
$tch = TInvWL_CheckerHook::instance();
|
346 |
+
$tch->add_action( $tags );
|
347 |
+
$tch->add_action( array_keys( $tags ) );
|
348 |
+
|
349 |
+
$types = wc_get_product_types();
|
350 |
+
|
351 |
+
$check = true;
|
352 |
+
foreach ( $types as $type => $type_name ) {
|
353 |
+
if ( tinv_get_option( 'template_checker', 'missing_hook_' . $type ) ) {
|
354 |
+
continue;
|
355 |
+
}
|
356 |
+
|
357 |
+
if ( function_exists( 'wc_get_products' ) ) {
|
358 |
+
$products = wc_get_products( array(
|
359 |
+
'status' => 'publish',
|
360 |
+
'type' => $type,
|
361 |
+
'limit' => 1,
|
362 |
+
) );
|
363 |
+
} else {
|
364 |
+
$products = array_map( 'wc_get_product', get_posts( array(
|
365 |
+
'post_type' => 'product',
|
366 |
+
'post_status' => 'publish',
|
367 |
+
'numberposts' => 1,
|
368 |
+
'tax_query' => array(
|
369 |
+
array(
|
370 |
+
'taxonomy' => 'product_type',
|
371 |
+
'field' => 'slug',
|
372 |
+
'terms' => $type,
|
373 |
+
),
|
374 |
+
),
|
375 |
+
) ) );
|
376 |
+
}
|
377 |
+
if ( ! empty( $products ) ) {
|
378 |
+
$product = array_shift( $products );
|
379 |
+
$post = get_post( $product->get_id() ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
|
380 |
+
$result = $tch->run( array(
|
381 |
+
'template' => array(
|
382 |
+
'content-single-product.php',
|
383 |
+
'single-product/add-to-cart/' . $type . '.php'
|
384 |
+
),
|
385 |
+
'template_args' => array(
|
386 |
+
'available_variations' => array( 1, 2, 3, 4, 5 ),
|
387 |
+
'attributes' => array(),
|
388 |
+
),
|
389 |
+
'url' => $product->get_permalink(),
|
390 |
+
) );
|
391 |
+
if ( ! empty( $result ) ) {
|
392 |
+
$result = array_keys( $result );
|
393 |
+
foreach ( $result as $key => $tag ) {
|
394 |
+
if ( array_key_exists( $tag, $tags ) ) {
|
395 |
+
$tags[ $tag ];
|
396 |
+
if ( ! array_key_exists( $tag, $tags ) ) {
|
397 |
+
unset( $result[ $key ] );
|
398 |
+
}
|
399 |
+
} else {
|
400 |
+
unset( $result[ $key ] );
|
401 |
+
}
|
402 |
+
}
|
403 |
+
if ( ! empty( $result ) ) {
|
404 |
+
WC_Admin_Notices::add_custom_notice( 'missing_hook_' . $type, sprintf( _n( 'The "Add to Wishlist" button may work improperly in a product type "%1$s" because the hook "%2$s" is missing.<br />Please, ask your theme developers to check the theme templates or <a href="https://templateinvaders.com/help/" target="_blank">contact us</a> for assistance.', 'The "Add to Wishlist" button may work improperly in a product type "%1$s" because the hooks "%2$s" are missing.<br />Please, ask your theme developers to check the theme templates or <a href="https://templateinvaders.com/help/" target="_blank">contact us</a> for assistance.', count( $result ), 'ti-woocommerce-wishlist' ), $type_name, '<strong>' . join( '</strong>, <strong>', $result ) . '</strong>' ) );
|
405 |
+
$check = false;
|
406 |
+
} else {
|
407 |
+
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
408 |
+
}
|
409 |
+
} else {
|
410 |
+
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
} // End foreach().
|
414 |
+
|
415 |
+
tinv_update_option( 'template_checker', 'checked', $check );
|
416 |
+
wp_die();
|
417 |
+
}
|
418 |
+
|
419 |
+
/**
|
420 |
+
* Clear notice validation template when theme switched
|
421 |
+
*/
|
422 |
+
function clear_notice_validation_template() {
|
423 |
+
WC_Admin_Notices::remove_notice( 'missing_hook_listing' );
|
424 |
+
$types = wc_get_product_types();
|
425 |
+
foreach ( $types as $type => $type_name ) {
|
426 |
+
WC_Admin_Notices::remove_notice( 'missing_hook_' . $type );
|
427 |
+
}
|
428 |
+
tinv_update_option( 'template_checker', '', array() );
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Disable screen option on plugin pages
|
433 |
+
*
|
434 |
+
* @param boolean $show_screen Show screen.
|
435 |
+
* @param \WP_Screen $_this Screen option page.
|
436 |
+
*
|
437 |
+
* @return boolean
|
438 |
+
*/
|
439 |
+
function screen_options_hide_screen( $show_screen, $_this ) {
|
440 |
+
if ( $this->_n === $_this->parent_base || $this->_n === $_this->parent_file ) {
|
441 |
+
return false;
|
442 |
+
}
|
443 |
+
|
444 |
+
return $show_screen;
|
445 |
+
}
|
446 |
+
|
447 |
+
/**
|
448 |
+
* Check if there is a hook in the cron
|
449 |
+
*/
|
450 |
+
function scheduled_remove_wishlist() {
|
451 |
+
$timestamp = wp_next_scheduled( 'tinvwl_remove_without_author_wishlist' );
|
452 |
+
if ( ! $timestamp ) {
|
453 |
+
$time = strtotime( '00:00 today +1 HOURS' );
|
454 |
+
wp_schedule_event( $time, 'daily', 'tinvwl_remove_without_author_wishlist' );
|
455 |
+
}
|
456 |
+
}
|
457 |
+
|
458 |
+
/**
|
459 |
+
* Removing old wishlist without a user older than 34 days
|
460 |
+
*/
|
461 |
+
public function remove_old_wishlists() {
|
462 |
+
$wl = new TInvWL_Wishlist();
|
463 |
+
$wishlists = $wl->get( array(
|
464 |
+
'author' => 0,
|
465 |
+
'type' => 'default',
|
466 |
+
'sql' => 'SELECT * FROM {table} {where} AND `date` < DATE_SUB( CURDATE(), INTERVAL 34 DAY)',
|
467 |
+
) );
|
468 |
+
foreach ( $wishlists as $wishlist ) {
|
469 |
+
$wl->remove( $wishlist['ID'] );
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://templateinvaders.com/?utm_source=wordpressorg&utm_content=d
|
|
4 |
Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, shop, ecommerce wishlist, shop wishlist, wishlist for Woocommerce
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.9
|
7 |
-
Stable tag: 1.6.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -129,7 +129,12 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
-
= 1.6.
|
|
|
|
|
|
|
|
|
|
|
133 |
*Release Date - 01 March 2018*
|
134 |
|
135 |
* Fixed an issue with deprecated function create_function(); on PHP 7.2+
|
4 |
Tags: wishlist, woocommerce, woocommerce wishlist, e-commerce, shop, ecommerce wishlist, shop wishlist, wishlist for Woocommerce
|
5 |
Requires at least: 4.5
|
6 |
Tested up to: 4.9
|
7 |
+
Stable tag: 1.6.2
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
129 |
|
130 |
== Changelog ==
|
131 |
|
132 |
+
= 1.6.2 =
|
133 |
+
*Release Date - 04 March 2018*
|
134 |
+
|
135 |
+
* Added support for [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/) plugin
|
136 |
+
* Removed background checks for missed actions inside WooCommerce templates.
|
137 |
+
|
138 |
*Release Date - 01 March 2018*
|
139 |
|
140 |
* Fixed an issue with deprecated function create_function(); on PHP 7.2+
|
ti-woocommerce-wishlist.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: WooCommerce Wishlist Plugin
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
-
* Version: 1.6.
|
8 |
* Requires at least: 4.5
|
9 |
* Tested up to: 4.9
|
10 |
* WC requires at least: 2.6
|
@@ -41,7 +41,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
-
define( 'TINVWL_FVERSION', '1.6.
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
4 |
* Plugin Name: WooCommerce Wishlist Plugin
|
5 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 1.6.2
|
8 |
* Requires at least: 4.5
|
9 |
* Tested up to: 4.9
|
10 |
* WC requires at least: 2.6
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
44 |
+
define( 'TINVWL_FVERSION', '1.6.2' );
|
45 |
}
|
46 |
|
47 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
tinv-wishlists-function-integration.php
CHANGED
@@ -1775,3 +1775,116 @@ if ( function_exists( 'wpm_translate_string' ) ) {
|
|
1775 |
add_filter( 'tinvwl-topline-text', 'wpm_translate_string' );
|
1776 |
|
1777 |
} // End if().
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1775 |
add_filter( 'tinvwl-topline-text', 'wpm_translate_string' );
|
1776 |
|
1777 |
} // End if().
|
1778 |
+
|
1779 |
+
|
1780 |
+
if ( ! function_exists( 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on' ) ) {
|
1781 |
+
|
1782 |
+
/**
|
1783 |
+
* Set descrition for meta YITH WooCommerce Product Add-on
|
1784 |
+
*
|
1785 |
+
* @param array $meta Meta array.
|
1786 |
+
* @param array $wl_product Wishlist Product.
|
1787 |
+
* @param \WC_Product $product Woocommerce Product.
|
1788 |
+
*
|
1789 |
+
* @return array
|
1790 |
+
*/
|
1791 |
+
function tinv_wishlist_item_meta_yith_woocommerce_product_add_on( $item_data, $product_id, $variation_id ) {
|
1792 |
+
|
1793 |
+
if ( isset( $item_data['yith_wapo_is_single'] ) && class_exists( 'YITH_WAPO' ) ) {
|
1794 |
+
unset( $item_data['yith_wapo_is_single'] );
|
1795 |
+
|
1796 |
+
$id = ( $variation_id ) ? $variation_id : $product_id;
|
1797 |
+
|
1798 |
+
$base_product = wc_get_product( $id );
|
1799 |
+
|
1800 |
+
if ( ( is_object( $base_product ) && get_option( 'yith_wapo_settings_show_product_price_cart' ) == 'yes' ) ) {
|
1801 |
+
|
1802 |
+
|
1803 |
+
$price = yit_get_display_price( $base_product );
|
1804 |
+
|
1805 |
+
|
1806 |
+
$price_html = wc_price( $price );
|
1807 |
+
|
1808 |
+
$item_data[] = array(
|
1809 |
+
'key' => __( 'Base price', 'yith-woocommerce-product-add-ons' ),
|
1810 |
+
'display' => $price_html,
|
1811 |
+
);
|
1812 |
+
|
1813 |
+
}
|
1814 |
+
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $id );
|
1815 |
+
|
1816 |
+
|
1817 |
+
foreach ( $type_list as $single_type ) {
|
1818 |
+
|
1819 |
+
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
1820 |
+
|
1821 |
+
$value = isset( $item_data[ $original_data ] ) ? $item_data[ $original_data ] : '';
|
1822 |
+
|
1823 |
+
if ( $value == '' ) {
|
1824 |
+
continue;
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
|
1828 |
+
$value = YITH_WAPO_Option::getOptionDataByValueKey( $single_type, '0', 'label' );
|
1829 |
+
|
1830 |
+
|
1831 |
+
unset( $item_data[ $original_data ] );
|
1832 |
+
$item_data[] = array(
|
1833 |
+
'key' => $single_type->label,
|
1834 |
+
'display' => $value,
|
1835 |
+
);
|
1836 |
+
|
1837 |
+
}
|
1838 |
+
|
1839 |
+
}
|
1840 |
+
|
1841 |
+
return $item_data;
|
1842 |
+
}
|
1843 |
+
|
1844 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_item_meta_yith_woocommerce_product_add_on', 10, 3 );
|
1845 |
+
} // End if().
|
1846 |
+
|
1847 |
+
if ( ! function_exists( 'tinvwl_item_price_yith_woocommerce_product_add_on' ) ) {
|
1848 |
+
|
1849 |
+
/**
|
1850 |
+
* Modify price for YITH WooCommerce product Addons.
|
1851 |
+
*
|
1852 |
+
* @param string $price Returned price.
|
1853 |
+
* @param array $wl_product Wishlist Product.
|
1854 |
+
* @param \WC_Product $product Woocommerce Product.
|
1855 |
+
*
|
1856 |
+
* @return string
|
1857 |
+
*/
|
1858 |
+
function tinvwl_item_price_yith_woocommerce_product_add_on( $price, $wl_product, $product ) {
|
1859 |
+
|
1860 |
+
if ( class_exists( 'YITH_WAPO' ) ) {
|
1861 |
+
|
1862 |
+
$type_list = YITH_WAPO_Type::getAllowedGroupTypes( $product->get_id() );
|
1863 |
+
|
1864 |
+
if ( $type_list ) {
|
1865 |
+
|
1866 |
+
|
1867 |
+
foreach ( $type_list as $single_type ) {
|
1868 |
+
|
1869 |
+
$original_data = 'ywapo_' . $single_type->type . '_' . $single_type->id;
|
1870 |
+
|
1871 |
+
$value = isset( $wl_product['meta'][ $original_data ] ) ? $wl_product['meta'][ $original_data ] : '';
|
1872 |
+
if ( $value == '' ) {
|
1873 |
+
continue;
|
1874 |
+
}
|
1875 |
+
|
1876 |
+
|
1877 |
+
$price += YITH_WAPO_Option::getOptionDataByValueKey( $single_type, '0', 'price' );
|
1878 |
+
|
1879 |
+
}
|
1880 |
+
|
1881 |
+
$price = wc_price( $product->get_price() + $price );
|
1882 |
+
}
|
1883 |
+
}
|
1884 |
+
|
1885 |
+
|
1886 |
+
return $price;
|
1887 |
+
}
|
1888 |
+
|
1889 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_yith_woocommerce_product_add_on', 10, 3 );
|
1890 |
+
} // End if().
|
tinv-wishlists-function.php
CHANGED
@@ -980,9 +980,15 @@ if ( ! function_exists( 'tinvwl_set_utm' ) ) {
|
|
980 |
*/
|
981 |
function tinvwl_set_utm() {
|
982 |
|
|
|
|
|
|
|
|
|
|
|
|
|
983 |
// Set a source.
|
984 |
$source = get_option( TINVWL_PREFIX . '_utm_source' );
|
985 |
-
if ( ! $source ) {
|
986 |
$source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
|
987 |
update_option( TINVWL_PREFIX . '_utm_source', $source );
|
988 |
}
|
@@ -991,7 +997,7 @@ if ( ! function_exists( 'tinvwl_set_utm' ) ) {
|
|
991 |
|
992 |
// Set a medium.
|
993 |
$medium = get_option( TINVWL_PREFIX . '_utm_medium' );
|
994 |
-
if ( ! $medium ) {
|
995 |
$medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
|
996 |
update_option( TINVWL_PREFIX . '_utm_medium', $medium );
|
997 |
}
|
@@ -1000,7 +1006,7 @@ if ( ! function_exists( 'tinvwl_set_utm' ) ) {
|
|
1000 |
|
1001 |
// Set a campaign.
|
1002 |
$campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
|
1003 |
-
if ( ! $campaign ) {
|
1004 |
$campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
|
1005 |
update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
|
1006 |
}
|
980 |
*/
|
981 |
function tinvwl_set_utm() {
|
982 |
|
983 |
+
// Forcing partners UTM.
|
984 |
+
if ( class_exists( 'Ocean_Extra' ) && ! defined( 'TINVWL_PARTNER' ) && ! defined( 'TINVWL_CAMPAIGN' ) ) {
|
985 |
+
define( 'TINVWL_PARTNER', 'oceanwporg' );
|
986 |
+
define( 'TINVWL_CAMPAIGN', 'oceanwp_theme' );
|
987 |
+
}
|
988 |
+
|
989 |
// Set a source.
|
990 |
$source = get_option( TINVWL_PREFIX . '_utm_source' );
|
991 |
+
if ( ! $source || $source !== defined( 'TINVWL_PARTNER' ) ) {
|
992 |
$source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
|
993 |
update_option( TINVWL_PREFIX . '_utm_source', $source );
|
994 |
}
|
997 |
|
998 |
// Set a medium.
|
999 |
$medium = get_option( TINVWL_PREFIX . '_utm_medium' );
|
1000 |
+
if ( ! $medium || ( 'organic' === $medium && defined( 'TINVWL_PARTNER' ) ) ) {
|
1001 |
$medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
|
1002 |
update_option( TINVWL_PREFIX . '_utm_medium', $medium );
|
1003 |
}
|
1006 |
|
1007 |
// Set a campaign.
|
1008 |
$campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
|
1009 |
+
if ( ! $campaign || $campaign !== defined( 'TINVWL_CAMPAIGN' ) ) {
|
1010 |
$campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
|
1011 |
update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
|
1012 |
}
|