Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jan 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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