Skip to content

Commit

Permalink
fix: dokan_is_store_listing function so that it returns correct value…
Browse files Browse the repository at this point in the history
… when shortcode is found (#731)

* fix: dokan_is_store_listing function so that it returns correct value when shortcode is found

* feat: add option to set store listing page

* refactor: dokan_is_store_listing_function
  • Loading branch information
saimonh3 authored and sabbir1991 committed Jan 14, 2020
1 parent 14633dc commit 1cc4f5d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions includes/admin/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ function get_settings_fields() {
'placeholder' => __( 'Select page', 'dokan-lite' ),
'options' => $pages_array,
),
'store_listing' => array(
'name' => 'store_listing',
'label' => __( 'Store Listing', 'dokan-lite' ),
'desc' => __( 'Select a page to show all Stores', 'dokan-lite' ),
'type' => 'select',
'placeholder' => __( 'Select page', 'dokan-lite' ),
'options' => $pages_array,
),
'reg_tc_page' => array(
'name' => 'reg_tc_page',
'label' => __( 'Terms and Conditions Page', 'dokan-lite' ),
Expand Down
17 changes: 16 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3423,7 +3423,22 @@ function dokan_get_permalink( $page_id ) {
* @return boolean
*/
function dokan_is_store_listing() {
return get_the_ID() === intval( dokan_get_option( 'store_listing', 'dokan_pages' ) );
$page_id = get_the_ID();
$found = false;

if ( $page_id === intval( dokan_get_option( 'store_listing', 'dokan_pages' ) ) ) {
$found = true;
}

if ( ! $found ) {
$post = get_post( $page_id );

if ( $post && false !== strpos( $post->post_content, '[dokan-stores]' ) ) {
$found = true;
}
}

return apply_filters( 'dokan_is_store_listing', $found, $page_id );
}

/**
Expand Down

0 comments on commit 1cc4f5d

Please sign in to comment.