'error', 'information' => 'notice-warning', ); public function __construct($message_handler, $importer, $dbl) { $this->message_handler = $message_handler; $this->importer = $importer; $this->dbl = &$dbl; $this->settings = get_option('arlo_settings'); } public function global_notices() { $messages = array_merge($this->message_handler->get_messages('import_error', true), $this->message_handler->get_messages('error', true), $this->message_handler->get_messages('review', true)); foreach ($messages as $message) { echo $this->create_notice($message); } } public function arlo_notices() { $messages = $this->message_handler->get_messages(null, false); foreach ($messages as $message) { echo $this->create_notice($message); } } public function create_notice($message) { $notice_type = (!empty($message->type) && isset(self::$message_notice_types[$message->type]) ? self::$message_notice_types[$message->type] : (!empty($message->type) ? $message->type : 'error')); $global_message = ''; if (!empty($message->global)) { $global_message = '
Your site is currently using demo event, presenter, and venue data. Start an Arlo trial to load your own events!
Get started with free Arlo trial Connect existing Arlo platform
' . __('Learn how to use Arlo for WordPress or visit www.arlo.co to find out more about Arlo.', 'arlo-for-wordpress' ) . '
'; echo $this->create_notice($message); } $message = new \stdClass(); $message->type = 'notice'; $message->class = 'arlo-connected-message'; $message->message = 'Arlo is connected to ' . $this->settings['platform_name'] . ' Last synchronized: ' . $this->importer->get_last_import_date() . ' UTC ' . (get_option('arlo_import_disabled', '0') != '1' ? 'Synchronize now' : '') . '
'; echo $this->create_notice($message); } public function permalink_notice() { $message_obj = $this->create_message_object( __("Permalink setting change required.", 'arlo-for-wordpress' ), '' . sprintf(__('Arlo for WordPress requires Permalinks to be set to "Post name".', 'arlo-for-wordpress' ), admin_url('options-permalink.php')) . '
', 'error notice'); echo $this->create_notice($message_obj); } public function plugin_disabled() { $message = '' . sprintf(__('The Arlo for WordPress plugin has been disabled, please check the System Requirements page'), '?page=arlo-for-wordpress#systemrequirements', 'arlo-pages-systemrequirements') . '
'; $message_obj = $this->create_message_object( __('Plugin disabled', 'arlo-for-wordpress'), $message, 'error', true, false); echo $this->create_notice($message_obj); } public function import_disabled() { $message = '' . sprintf(__('The import for the Arlo for WordPress plugin has been disabled, but the current existing data is still available. Please check the System Requirements page'), '?page=arlo-for-wordpress#systemrequirements', 'arlo-pages-systemrequirements') . '
'; $message_obj = $this->create_message_object( __('Import disabled', 'arlo-for-wordpress'), $message, 'error', true, false); echo $this->create_notice($message_obj); } public function posttype_notice() { $message_obj = $this->create_message_object( __("Page setup required", 'arlo-for-wordpress' ), '' . __('Arlo for WordPress requires you to setup the pages which will host event information.', 'arlo-for-wordpress' ) .' '. sprintf(__('Setup pages', 'arlo-for-wordpress' ), admin_url('admin.php?page=arlo-for-wordpress#pages/events')) . '
' . sprintf(__('View documentation for more information.', 'arlo-for-wordpress' ), 'http://developer.arlo.co/doc/wordpress/index#pages-and-post-types') . '
', 'error notice', false, true); echo $this->create_user_notice('pagesetup', $message_obj); } public function welcome_notice() { $this->load_demo_notice(!empty($_SESSION['arlo-demo']) ? $_SESSION['arlo-demo'] : []); $this->webinar_notice(); $this->developer_notice(); unset($_SESSION['arlo-import']); } public function developer_notice() { $message = '' . __('Become an Arlo reseller and receive a ', 'arlo-for-wordpress' ) . ' ' . sprintf('%s %s', __('20%', 'arlo-for-wordpress' ), __('sales commission', 'arlo-for-wordpress' )) . ' ' . sprintf(__('Contact us to become an Arlo partner', 'arlo-for-wordpress' ), 'https://www.arlo.co/contact') . '
'; $message_obj = $this->create_message_object( null, $message, 'notice', false, true); echo $this->create_user_notice('developer', $message_obj); } public function webinar_notice() { $message = '' . __('Watch overview video', 'arlo-for-wordpress' ) .' ' . __('Join Arlo for WordPress Getting started webinar on ', 'arlo-for-wordpress' ) . ' ' . __('Register now! or view more times', 'arlo-for-wordpress' ) . '
'; $message_obj = $this->create_message_object( null, $message, 'notice', false, true); echo $this->create_user_notice('webinar', $message_obj); } public function load_demo_notice($error = []) { $import_id = $this->importer->get_current_import_id(); $events = arlo_get_post_by_name('events', 'page'); $schedule = arlo_get_post_by_name('schedule', 'page'); $upcoming = arlo_get_post_by_name('upcoming', 'page'); $presenters = arlo_get_post_by_name('presenters', 'page'); $venues = arlo_get_post_by_name('venues', 'page'); if (count($error)) { echo $this->create_user_notice('newpages', $this->create_message_object( null, '' . sprintf(__('Couldn\'t set the following post types: %s', 'arlo-for-wordpress' ), implode(', ', $error)) . '
', 'error notice', false, true) ); } else { $notice_id = \Arlo_For_Wordpress::$dismissible_notices['newpages']; $user = wp_get_current_user(); $meta = get_user_meta($user->ID, $notice_id, true); if ($meta !== '0') { if (!empty($this->settings['platform_name']) && $events !== false && $schedule !== false && $upcoming !== false && $presenters !== false && $venues !== false && !empty($import_id)) { //Get the first event template wich has event $sql = " SELECT ID FROM {$this->dbl->prefix}arlo_events AS e LEFT JOIN {$this->dbl->prefix}arlo_eventtemplates AS et ON e.et_arlo_id = et.et_arlo_id AND e.import_id = " . $import_id ." LEFT JOIN {$this->dbl->prefix}posts ON et_post_id = ID AND post_status = 'publish' WHERE et.import_id = " . $import_id ." LIMIT 1 "; $event = $this->dbl->get_results($sql, ARRAY_A); $event_link = ''; if (count($event)) { $event_link = sprintf('%s,', get_post_permalink($event[0]['ID']), __('Event', 'arlo-for-wordpress' )); } //Get the first presenter $sql = " SELECT ID FROM {$this->dbl->prefix}arlo_presenters AS p LEFT JOIN {$this->dbl->prefix}posts ON p_post_id = ID AND post_status = 'publish' WHERE p.import_id = " . $import_id ." LIMIT 1 "; $presenter = $this->dbl->get_results($sql, ARRAY_A); $presenter_link = ''; if (count($event) && count($presenter)) { $presenter_link = sprintf('%s,', get_post_permalink($presenter[0]['ID']), __('Presenter profile', 'arlo-for-wordpress' )); } //Get the first venue $sql = " SELECT ID FROM {$this->dbl->prefix}arlo_venues AS v LEFT JOIN {$this->dbl->prefix}posts ON v_post_id = ID AND post_status = 'publish' WHERE v.import_id = " . $import_id ." LIMIT 1 "; $venue = $this->dbl->get_results($sql, ARRAY_A); $venue_link = ''; if (count($event)) { $venue_link = sprintf('%s,', get_post_permalink($venue[0]['ID']), __('Venue information', 'arlo-for-wordpress' )); } echo $this->create_user_notice('newpages', $this->create_message_object( __('Start editing your new pages', 'arlo-for-wordpress' ), ''.sprintf(__('View %s %s, %s, %s, %s %s %s or %s pages', 'arlo-for-wordpress' ), $event_link, $events->guid, __('Catalogue', 'arlo-for-wordpress' ), $schedule->guid, __('Schedule', 'arlo-for-wordpress' ), $upcoming->guid, $upcoming->post_title, $presenter_link, $presenters->guid, __('Presenters list', 'arlo-for-wordpress' ), $venue_link, $venues->guid, __('Venues list', 'arlo-for-wordpress' ) ) . '
' . __('Edit the page templates for each of these websites pages below.') . '
', 'notice', false, true) ); unset($_SESSION['arlo-demo']); } } } } }