Add public keyword to methods
[MAILPOET-2413]
This commit is contained in:
@@ -16,11 +16,11 @@ class AutomaticEmails {
|
||||
'WooCommerce',
|
||||
];
|
||||
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->wp = new WPFunctions;
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
foreach ($this->available_groups as $group) {
|
||||
$group_class = sprintf(
|
||||
'%1$s\%2$s\%2$s',
|
||||
@@ -44,7 +44,7 @@ class AutomaticEmails {
|
||||
}
|
||||
}
|
||||
|
||||
function getAutomaticEmails() {
|
||||
public function getAutomaticEmails() {
|
||||
global $wp_filter;
|
||||
|
||||
$registered_groups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wp_filter));
|
||||
@@ -70,7 +70,7 @@ class AutomaticEmails {
|
||||
return $automatic_emails;
|
||||
}
|
||||
|
||||
function getAutomaticEmailBySlug($email_slug) {
|
||||
public function getAutomaticEmailBySlug($email_slug) {
|
||||
$automatic_emails = $this->getAutomaticEmails();
|
||||
|
||||
if (empty($automatic_emails)) return null;
|
||||
@@ -82,7 +82,7 @@ class AutomaticEmails {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getAutomaticEmailEventBySlug($email_slug, $event_slug) {
|
||||
public function getAutomaticEmailEventBySlug($email_slug, $event_slug) {
|
||||
$automatic_email = $this->getAutomaticEmailBySlug($email_slug);
|
||||
|
||||
if (empty($automatic_email)) return null;
|
||||
@@ -94,7 +94,7 @@ class AutomaticEmails {
|
||||
return null;
|
||||
}
|
||||
|
||||
function validateAutomaticEmailDataFields(array $automatic_email) {
|
||||
public function validateAutomaticEmailDataFields(array $automatic_email) {
|
||||
$required_fields = [
|
||||
'slug',
|
||||
'title',
|
||||
@@ -109,7 +109,7 @@ class AutomaticEmails {
|
||||
return true;
|
||||
}
|
||||
|
||||
function validateAutomaticEmailEventsDataFields(array $automatic_email_events) {
|
||||
public function validateAutomaticEmailEventsDataFields(array $automatic_email_events) {
|
||||
$required_fields = [
|
||||
'slug',
|
||||
'title',
|
||||
@@ -125,7 +125,7 @@ class AutomaticEmails {
|
||||
return true;
|
||||
}
|
||||
|
||||
function unregisterAutomaticEmails() {
|
||||
public function unregisterAutomaticEmails() {
|
||||
global $wp_filter;
|
||||
|
||||
$registered_groups = preg_grep('!^' . self::FILTER_PREFIX . '(.*?)$!', array_keys($wp_filter));
|
||||
|
@@ -29,7 +29,7 @@ class AbandonedCart {
|
||||
/** @var AutomaticEmailScheduler */
|
||||
private $scheduler;
|
||||
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->wp = WPFunctions::get();
|
||||
$this->woo_commerce_helper = new WooCommerceHelper();
|
||||
$this->cookies = new Cookies();
|
||||
@@ -37,7 +37,7 @@ class AbandonedCart {
|
||||
$this->scheduler = new AutomaticEmailScheduler();
|
||||
}
|
||||
|
||||
function getEventDetails() {
|
||||
public function getEventDetails() {
|
||||
return [
|
||||
'slug' => self::SLUG,
|
||||
'title' => WPFunctions::get()->_x('Abandoned Shopping Cart', 'This is the name of a type of automatic email for ecommerce. Those emails are sent automatically when a customer adds product to his shopping cart but never complete the checkout process.', 'mailpoet'),
|
||||
@@ -73,7 +73,7 @@ class AbandonedCart {
|
||||
];
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
if (!$this->woo_commerce_helper->isWooCommerceActive()) {
|
||||
return;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ class AbandonedCart {
|
||||
);
|
||||
}
|
||||
|
||||
function handleCartChange() {
|
||||
public function handleCartChange() {
|
||||
$cart = $this->woo_commerce_helper->WC()->cart;
|
||||
if ($cart && !$cart->is_empty()) {
|
||||
$this->scheduleAbandonedCartEmail();
|
||||
@@ -137,7 +137,7 @@ class AbandonedCart {
|
||||
}
|
||||
}
|
||||
|
||||
function trackPageVisit() {
|
||||
public function trackPageVisit() {
|
||||
// on page visit reschedule all currently scheduled (not yet sent) emails for given subscriber
|
||||
// (it tracks at most once per minute to avoid processing many calls at the same time, i.e. AJAX)
|
||||
$this->page_visit_tracker->trackVisit(function () {
|
||||
|
@@ -20,17 +20,17 @@ class AbandonedCartPageVisitTracker {
|
||||
/** @var Cookies */
|
||||
private $cookies;
|
||||
|
||||
function __construct(WPFunctions $wp, WooCommerceHelper $woo_commerce_helper, Cookies $cookies) {
|
||||
public function __construct(WPFunctions $wp, WooCommerceHelper $woo_commerce_helper, Cookies $cookies) {
|
||||
$this->wp = $wp;
|
||||
$this->woo_commerce_helper = $woo_commerce_helper;
|
||||
$this->cookies = $cookies;
|
||||
}
|
||||
|
||||
function startTracking() {
|
||||
public function startTracking() {
|
||||
$this->saveLastVisitTimestamp();
|
||||
}
|
||||
|
||||
function trackVisit(callable $onTrackCallback = null) {
|
||||
public function trackVisit(callable $onTrackCallback = null) {
|
||||
// track at most once per minute to avoid processing many calls at the same time, i.e. AJAX
|
||||
$last_visit_timestamp = $this->loadLastVisitTimestamp();
|
||||
$minute_ago_timestamp = Carbon::now()->getTimestamp() - 60;
|
||||
@@ -42,7 +42,7 @@ class AbandonedCartPageVisitTracker {
|
||||
}
|
||||
}
|
||||
|
||||
function stopTracking() {
|
||||
public function stopTracking() {
|
||||
$this->removeLastVisitTimestamp();
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ class FirstPurchase {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function __construct(WCHelper $helper = null) {
|
||||
public function __construct(WCHelper $helper = null) {
|
||||
if ($helper === null) {
|
||||
$helper = new WCHelper();
|
||||
}
|
||||
@@ -35,7 +35,7 @@ class FirstPurchase {
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
WPFunctions::get()->addFilter('mailpoet_newsletter_shortcode', [
|
||||
$this,
|
||||
'handleOrderTotalShortcode',
|
||||
@@ -56,7 +56,7 @@ class FirstPurchase {
|
||||
}
|
||||
}
|
||||
|
||||
function getEventDetails() {
|
||||
public function getEventDetails() {
|
||||
return [
|
||||
'slug' => self::SLUG,
|
||||
'title' => WPFunctions::get()->__('First Purchase', 'mailpoet'),
|
||||
@@ -79,7 +79,7 @@ class FirstPurchase {
|
||||
];
|
||||
}
|
||||
|
||||
function handleOrderDateShortcode($shortcode, $newsletter, $subscriber, $queue) {
|
||||
public function handleOrderDateShortcode($shortcode, $newsletter, $subscriber, $queue) {
|
||||
$result = $shortcode;
|
||||
if ($shortcode === self::ORDER_DATE_SHORTCODE) {
|
||||
$default_value = WPFunctions::get()->dateI18n(get_option('date_format'));
|
||||
@@ -102,7 +102,7 @@ class FirstPurchase {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function handleOrderTotalShortcode($shortcode, $newsletter, $subscriber, $queue) {
|
||||
public function handleOrderTotalShortcode($shortcode, $newsletter, $subscriber, $queue) {
|
||||
$result = $shortcode;
|
||||
if ($shortcode === self::ORDER_TOTAL_SHORTCODE) {
|
||||
$default_value = $this->helper->wcPrice(0);
|
||||
@@ -125,7 +125,7 @@ class FirstPurchase {
|
||||
return $result;
|
||||
}
|
||||
|
||||
function scheduleEmailWhenOrderIsPlaced($order_id) {
|
||||
public function scheduleEmailWhenOrderIsPlaced($order_id) {
|
||||
$order_details = $this->helper->wcGetOrder($order_id);
|
||||
if (!$order_details || !$order_details->get_billing_email()) {
|
||||
$this->logger_factory->getLogger(self::SLUG)->addInfo(
|
||||
@@ -178,7 +178,7 @@ class FirstPurchase {
|
||||
$this->scheduler->scheduleAutomaticEmail(WooCommerce::SLUG, self::SLUG, $check_email_was_not_scheduled, $subscriber->id, $meta);
|
||||
}
|
||||
|
||||
function getCustomerOrderCount($customer_email) {
|
||||
public function getCustomerOrderCount($customer_email) {
|
||||
// registered user
|
||||
$user = WPFunctions::get()->getUserBy('email', $customer_email);
|
||||
if ($user) {
|
||||
|
@@ -23,7 +23,7 @@ class PurchasedInCategory {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function __construct(WCHelper $woocommerce_helper = null) {
|
||||
public function __construct(WCHelper $woocommerce_helper = null) {
|
||||
if ($woocommerce_helper === null) {
|
||||
$woocommerce_helper = new WCHelper();
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class PurchasedInCategory {
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function getEventDetails() {
|
||||
public function getEventDetails() {
|
||||
return [
|
||||
'slug' => self::SLUG,
|
||||
'title' => _x('Purchased In This Category', 'This is the name of a type for automatic email for ecommerce. Those emails are sent automatically every time a customer buys for the first time a product in a given category', 'mailpoet'),
|
||||
@@ -49,7 +49,7 @@ class PurchasedInCategory {
|
||||
];
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
WPFunctions::get()->removeAllFilters('woocommerce_product_purchased_get_categories');
|
||||
WPFunctions::get()->addFilter(
|
||||
'woocommerce_product_purchased_get_categories',
|
||||
@@ -67,7 +67,7 @@ class PurchasedInCategory {
|
||||
}
|
||||
}
|
||||
|
||||
function getCategories($search_query) {
|
||||
public function getCategories($search_query) {
|
||||
$args = [
|
||||
'taxonomy' => 'product_cat',
|
||||
'search' => $search_query,
|
||||
@@ -86,7 +86,7 @@ class PurchasedInCategory {
|
||||
}, $all_categories);
|
||||
}
|
||||
|
||||
function scheduleEmail($order_id) {
|
||||
public function scheduleEmail($order_id) {
|
||||
$order_details = $this->woocommerce_helper->wcGetOrder($order_id);
|
||||
if (!$order_details || !$order_details->get_billing_email()) {
|
||||
$this->logger_factory->getLogger(self::SLUG)->addInfo(
|
||||
|
@@ -24,7 +24,7 @@ class PurchasedProduct {
|
||||
/** @var LoggerFactory */
|
||||
private $logger_factory;
|
||||
|
||||
function __construct(WCHelper $helper = null) {
|
||||
public function __construct(WCHelper $helper = null) {
|
||||
if ($helper === null) {
|
||||
$helper = new WCHelper();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ class PurchasedProduct {
|
||||
$this->logger_factory = LoggerFactory::getInstance();
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
WPFunctions::get()->removeAllFilters('woocommerce_product_purchased_get_products');
|
||||
WPFunctions::get()->addFilter(
|
||||
'woocommerce_product_purchased_get_products',
|
||||
@@ -53,7 +53,7 @@ class PurchasedProduct {
|
||||
}
|
||||
}
|
||||
|
||||
function getEventDetails() {
|
||||
public function getEventDetails() {
|
||||
return [
|
||||
'slug' => self::SLUG,
|
||||
'title' => WPFunctions::get()->__('Purchased This Product', 'mailpoet'),
|
||||
@@ -70,7 +70,7 @@ class PurchasedProduct {
|
||||
];
|
||||
}
|
||||
|
||||
function getProducts($product_search_query) {
|
||||
public function getProducts($product_search_query) {
|
||||
$args = [
|
||||
'post_type' => 'product',
|
||||
'post_status' => 'publish',
|
||||
@@ -96,7 +96,7 @@ class PurchasedProduct {
|
||||
return $woocommerce_products;
|
||||
}
|
||||
|
||||
function scheduleEmailWhenProductIsPurchased($order_id) {
|
||||
public function scheduleEmailWhenProductIsPurchased($order_id) {
|
||||
$order_details = $this->helper->wcGetOrder($order_id);
|
||||
if (!$order_details || !$order_details->get_billing_email()) {
|
||||
$this->logger_factory->getLogger(self::SLUG)->addInfo(
|
||||
|
@@ -23,13 +23,13 @@ class WooCommerce {
|
||||
private $_woocommerce_enabled;
|
||||
private $wp;
|
||||
|
||||
function __construct() {
|
||||
public function __construct() {
|
||||
$this->wp = new WPFunctions;
|
||||
$this->woocommerce_helper = new WooCommerceHelper();
|
||||
$this->_woocommerce_enabled = $this->isWoocommerceEnabled();
|
||||
}
|
||||
|
||||
function init() {
|
||||
public function init() {
|
||||
$this->wp->addFilter(
|
||||
AutomaticEmails::FILTER_PREFIX . self::SLUG,
|
||||
[
|
||||
@@ -46,7 +46,7 @@ class WooCommerce {
|
||||
);
|
||||
}
|
||||
|
||||
function setupGroup() {
|
||||
public function setupGroup() {
|
||||
return [
|
||||
'slug' => self::SLUG,
|
||||
'title' => WPFunctions::get()->__('WooCommerce', 'mailpoet'),
|
||||
@@ -55,7 +55,7 @@ class WooCommerce {
|
||||
];
|
||||
}
|
||||
|
||||
function setupEvents($events) {
|
||||
public function setupEvents($events) {
|
||||
$custom_event_details = (!$this->_woocommerce_enabled) ? [
|
||||
'actionButtonTitle' => WPFunctions::get()->__('WooCommerce is required', 'mailpoet'),
|
||||
'actionButtonLink' => 'https://wordpress.org/plugins/woocommerce/',
|
||||
@@ -94,7 +94,7 @@ class WooCommerce {
|
||||
return $events;
|
||||
}
|
||||
|
||||
function isWoocommerceEnabled() {
|
||||
public function isWoocommerceEnabled() {
|
||||
return $this->woocommerce_helper->isWooCommerceActive();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user