asked on
<?php
/**
* Dokan Dashboard Template
*
* Dokan Dahsboard Announcement widget template
*
* @since 2.4
*
* @package dokan
*/
?>
<div class="dashboard-widget dokan-announcement-widget">
<div class="widget-title">
<?php _e( 'Latest Notifications', 'dokan' ); ?>
</div>
<?php
?>
<?php if ( $notices ): ?>
<ul class="list-unstyled">
<?php foreach (array_slice($notices, 0, 2) as $notice ): ?>
<?php
$notice_url = trailingslashit( dokan_get_navigation_url( 'single-announcement' ).''.$notice->ID );
?>
<li>
<div class="dokan-dashboard-announce-date <?php echo ( $notice->status == 'unread' ) ? 'dokan-dashboard-announce-unread' : 'dokan-dashboard-announce-read'; ?>">
<span class="announce-day"><?php echo date_i18n( 'd', strtotime( $notice->post_date ) ); ?></span>
<span class="announce-month"><?php echo date_i18n( 'M', strtotime( $notice->post_date ) ); ?></span>
<span class="announce-year"><?php echo date_i18n( 'Y', strtotime( $notice->post_date ) ); ?></span>
</div>
<div class="dokan-dashboard-announce-content">
<a href="<?php echo $notice_url; ?>"><h3><?php echo $notice->post_title; ?></h3></a>
<p><?php echo wp_trim_words( $notice->post_content, 8, '...' ); ?></p>
</div>
<div class="dokan-clearfix"></div>
</li>
<?php endforeach ?>
</ul>
<a class="btn-vendor-primary mb-0" href="<?php echo $announcement_url; ?>"><?php _e( 'See All Notifications', 'dokan' ); ?></a>
<?php else: ?>
<div class="dokan-no-announcement">
<div class="annoument-no-wrapper">
<img class="dokan-announcement-icon" src="<?PHP echo get_template_directory_uri();?>/inc/images/icons/bell-thin.svg" alt="Bell"/>
<p><?php _e( 'No notifications', 'dokan' ) ?></p>
</div>
</div>
<?php endif ?>
</div> <!-- .products -->
ASKER
<?php
$template_notice = dokan_pro()->notice;
$query = $template_notice->get_announcement_by_users(apply_filters('dokan_announcement_list_number', 3));
$announcement_url = dokan_get_navigation_url( 'announcement/single-announcement' )."$post_id/";
$args = array(
'post_type' => 'dokan_announcement',
'post_status' => 'unread',
'orderby' => 'post_date',
'order' => 'DESC',
'meta_key' => '_announcement_type',
'meta_value' => 'all_seller',
);
$template_notice->add_query_filter();
$all_seller_posts = new \WP_Query($args);
$template_notice->remove_query_filter();
$notices = array_merge($all_seller_posts->posts, $query->posts);
$numUnread = 0;
?>
<?php
global $user_login, $current_user;
if (is_user_logged_in()) {
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
if (in_array('vendor', $user_info->roles) || in_array('administrator', $user_info->roles)) { ?>
<?php if ($notices): ?>
<?php foreach ($notices as $notice): ?>
<?php if ($notice->status == 'unread') $numUnread++; ?>
<?php
$notice_url = trailingslashit(dokan_get_navigation_url('single-announcement') . '' . $notice->ID);
?>
<?php endforeach ?>
<a href="<?php echo $announcement_url; ?>"><?php echo $numUnread; ?></a>
<?php else: ?>
<div class="dokan-no-announcement">
<div class="annoument-no-wrapper">
<img class="dokan-announcement-icon"
src="<?php echo get_template_directory_uri(); ?>/inc/images/icons/bell-thin.svg" alt="Bell"/>
<p><?php _e('No notifications', 'dokan') ?></p>
</div>
</div>
<?php endif ?>
<?php
}
}
?>
Thanks Michal for your help.PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
ASKER
Open in new window
When I try this it tells me a statement is expected.Also, I only want to display this if the user has a role type of vendor