Pass only needed flags to views

This commit is contained in:
Amine Ben hammou
2019-03-18 16:56:00 +01:00
committed by M. Shull
parent 22fc3089e6
commit f208a25f9a
2 changed files with 9 additions and 6 deletions

View File

@ -611,7 +611,6 @@ class Menu {
}); });
$data['segments'] = $segments; $data['segments'] = $segments;
$data['settings'] = $this->settings->getAll(); $data['settings'] = $this->settings->getAll();
$data['user_flags'] = $this->user_flags->getAll();
$data['current_wp_user'] = WPFunctions::get()->wpGetCurrentUser()->to_array(); $data['current_wp_user'] = WPFunctions::get()->wpGetCurrentUser()->to_array();
$data['current_wp_user_firstname'] = WPFunctions::get()->wpGetCurrentUser()->user_firstname; $data['current_wp_user_firstname'] = WPFunctions::get()->wpGetCurrentUser()->user_firstname;
$data['site_url'] = WPFunctions::get()->siteUrl(); $data['site_url'] = WPFunctions::get()->siteUrl();
@ -637,9 +636,13 @@ class Menu {
$data['is_woocommerce_active'] = $this->woocommerce_helper->isWooCommerceActive(); $data['is_woocommerce_active'] = $this->woocommerce_helper->isWooCommerceActive();
$user_id = $data['current_wp_user']['ID']; $user_id = $data['current_wp_user']['ID'];
$data['feature_announcement_has_news'] = empty($data['user_flags']['last_announcement_seen'])
|| $data['user_flags']['last_announcement_seen'] < strtotime(self::LAST_ANNOUNCEMENT_DATE); $last_announcement_seen = $this->user_flags->get('last_announcement_seen');
$data['last_announcement_seen'] = $data['user_flags']['last_announcement_seen']; $data['feature_announcement_has_news'] = (
empty($last_announcement_seen) ||
$last_announcement_seen < strtotime(self::LAST_ANNOUNCEMENT_DATE)
);
$data['last_announcement_seen'] = $last_announcement_seen;
$data['automatic_emails'] = array( $data['automatic_emails'] = array(
array( array(
@ -707,7 +710,7 @@ class Menu {
$data = array( $data = array(
'shortcodes' => ShortcodesHelper::getShortcodes(), 'shortcodes' => ShortcodesHelper::getShortcodes(),
'settings' => $this->settings->getAll(), 'settings' => $this->settings->getAll(),
'user_flags' => $this->user_flags->getAll(), 'editor_tutorial_seen' => $this->user_flags->get('editor_tutorial_seen'),
'current_wp_user' => array_merge($subscriber_data, WPFunctions::get()->wpGetCurrentUser()->to_array()), 'current_wp_user' => array_merge($subscriber_data, WPFunctions::get()->wpGetCurrentUser()->to_array()),
'sub_menu' => self::MAIN_PAGE_SLUG, 'sub_menu' => self::MAIN_PAGE_SLUG,
'mss_active' => Bridge::isMPSendingServiceEnabled() 'mss_active' => Bridge::isMPSendingServiceEnabled()

View File

@ -1412,7 +1412,7 @@
}, },
dragDemoUrl: '<%= cdn_url('newsletter-editor/editor-drag-demo.20190226-1505.mp4') %>', dragDemoUrl: '<%= cdn_url('newsletter-editor/editor-drag-demo.20190226-1505.mp4') %>',
currentUserId: '<%= current_wp_user.wp_user_id %>', currentUserId: '<%= current_wp_user.wp_user_id %>',
dragDemoUrlSettings: '<%= user_flags["editor_tutorial_seen"] %>', dragDemoUrlSettings: '<%= editor_tutorial_seen %>',
installedAt: '<%= settings["installed_at"] %>', installedAt: '<%= settings["installed_at"] %>',
mtaMethod: '<%= settings["mta"]["method"] %>', mtaMethod: '<%= settings["mta"]["method"] %>',
displayWcProductsWidget: '<%= settings["display_wc_products_widget"] %>', displayWcProductsWidget: '<%= settings["display_wc_products_widget"] %>',