[
'icon' => 'facebook-f',
'title' => __( 'Facebook', 'ayyash' ),
],
'twitter' => [
'icon' => 'twitter',
'title' => __( 'Twitter', 'ayyash' ),
],
'pinterest' => [
'icon' => 'pinterest-p',
'title' => __( 'Pinterest', 'ayyash' ),
],
'linkedin' => [
'icon' => 'linkedin-in',
'title' => __( 'LinkedIn', 'ayyash' ),
],
'youtube' => [
'icon' => 'youtube',
'title' => __( 'Youtube', 'ayyash' ),
],
'instagram' => [
'icon' => 'instagram',
'title' => __( 'Instagram', 'ayyash' ),
],
'flickr' => [
'icon' => 'flickr',
'title' => __( 'Flickr', 'ayyash' ),
],
];
return $fields;
}
}
if ( ! function_exists( 'ayyash_dokan_vendor_list' ) ) {
function ayyash_dokan_vendor_list() {
if ( ! class_exists( WeDevs_Dokan::class ) ) {
return;
}
if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'ayyash-nonce' ) ) {
die( 'Permission error.' );
}
$dokan_seller_search = '';
if ( isset( $_REQUEST['nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_REQUEST['nonce'] ) ), 'ayyash-nonce' ) ) {
$dokan_seller_search = isset( $_REQUEST['search'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['search'] ) ) : $dokan_seller_search;
$featured = ( isset( $_REQUEST['featured'] ) && ( 1 == $_REQUEST['featured'] ) ) ? 'yes' : 'no';
$open_now = ( isset( $_REQUEST['open_now'] ) && ( 1 == $_REQUEST['open_now'] ) ) ? 'yes' : 'no';
$rating = ( isset( $_REQUEST['rating'] ) ) ?? sanitize_text_field( wp_unslash( $_REQUEST['rating'] ) );
}
$seller_args = array(
'number' => - 1,
'order' => 'DESC',
);
// if search is enabled, perform a search
if ( ! empty( $dokan_seller_search ) ) {
$seller_args['meta_query'] = [ // phpcs:ignore
[
'key' => 'dokan_store_name',
'value' => $dokan_seller_search,
'compare' => 'LIKE',
],
];
}
if ( 'yes' === $featured ) {
$seller_args['featured'] = 'yes';
}
if ( 'yes' === $open_now ) {
$seller_args['open_now'] = 'yes';
}
if ( ! empty( $rating ) ) {
$seller_args['rating'] = intval( $rating );
}
$sellers = dokan_get_sellers( $seller_args );
$template_args = apply_filters(
'dokan_store_list_args', [
'sellers' => $sellers,
'search' => 'yes',
'dokan_seller_search' => $dokan_seller_search,
]
);
dokan_get_template_part( 'store-lists', false, $template_args );
die;
}
}
if ( ! function_exists( 'ayyash_dokan_page_navi' ) ) {
function ayyash_dokan_page_navi( $before, $after, $wp_query ) {
if ( ! ( $wp_query instanceof WP_Query ) ) {
return;
}
$posts_per_page = intval( get_query_var( 'posts_per_page' ) );
$paged = intval( get_query_var( 'paged' ) );
$numposts = $wp_query->found_posts;
$max_page = $wp_query->max_num_pages;
if ( $numposts <= $posts_per_page ) {
return;
}
//phpcs:disable
if ( empty( $paged ) || $paged === 0 ) {
$paged = 1;
}
//phpcs:disable
$pages_to_show = 7;
$pages_to_show_minus_1 = $pages_to_show - 1;
$half_page_start = floor( $pages_to_show_minus_1 / 2 );
$half_page_end = ceil( $pages_to_show_minus_1 / 2 );
$start_page = $paged - $half_page_start;
if ( $start_page <= 0 ) {
$start_page = 1;
}
$end_page = $paged + $half_page_end;
if ( ( $end_page - $start_page ) !== $pages_to_show_minus_1 ) {
$end_page = $start_page + $pages_to_show_minus_1;
}
if ( $end_page > $max_page ) {
$start_page = $max_page - $pages_to_show_minus_1;
$end_page = $max_page;
}
if ( $start_page <= 0 ) {
$start_page = 1;
}
echo wp_kses_post( $before ) . '' . wp_kses_post( $after );
}
}
if ( ! function_exists( 'ayyash_dokan_content_nav' ) ) {
/**
* Display navigation to next/previous pages when applicable
*/
function ayyash_dokan_content_nav( $nav_id, $query = null ) {
global $wp_query, $post;
if ( $query ) {
$wp_query = $query; //phpcs:ignore
}
// Don't print empty markup on single pages if there's nowhere to navigate.
if ( is_single() ) {
$previous = ( is_attachment() ) ? get_post( $post->post_parent ) : get_adjacent_post( false, '', true );
$next = get_adjacent_post( false, '', false );
if ( ! $next && ! $previous ) {
return;
}
}
// Don't print empty markup in archives if there's only one page.
if ( $wp_query->max_num_pages < 2 && ( is_home() || is_archive() || is_search() ) ) {
return;
}
$nav_class = 'site-navigation paging-navigation';
if ( is_single() ) {
$nav_class = 'site-navigation post-navigation';
}
?>