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

🪝 new: Filter hook to the store URL getter method #2031

Merged
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
11 changes: 10 additions & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
* @return int
*/
function dokan_get_current_user_id() {
if ( current_user_can( 'vendor_staff' ) ) {

Check warning on line 49 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "vendor_staff" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
$staff_id = get_current_user_id();
$vendor_id = (int) get_user_meta( $staff_id, '_vendor_id', true );

Expand All @@ -68,7 +68,7 @@
* @return bool
*/
function dokan_is_user_seller( $user_id ) {
if ( ! user_can( $user_id, 'dokandar' ) ) {

Check warning on line 71 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "dokandar" in function call to user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return false;
}

Expand All @@ -83,7 +83,7 @@
* @return bool
*/
function dokan_is_user_customer( $user_id ) {
if ( ! user_can( $user_id, 'customer' ) ) {

Check warning on line 86 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "customer" in function call to user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return false;
}

Expand Down Expand Up @@ -300,7 +300,7 @@
SELECT tr.object_id FROM {$wpdb->prefix}terms AS t
LEFT JOIN {$wpdb->prefix}term_taxonomy AS tt ON t.term_id = tt.term_taxonomy_id
LEFT JOIN {$wpdb->prefix}term_relationships AS tr ON t.term_id = tr.term_taxonomy_id
WHERE tt.taxonomy = 'product_type' AND t.slug NOT IN ({$exclude_product_types_text})

Check failure on line 303 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Use placeholders and $wpdb->prepare(); found interpolated variable {$exclude_product_types_text} at WHERE tt.taxonomy = 'product_type' AND t.slug NOT IN ({$exclude_product_types_text})
)
GROUP BY p.post_status",
$post_type,
Expand Down Expand Up @@ -864,7 +864,7 @@
*
* @return string
*/
function dokan_posted_input( $key, $array = false ) {

Check warning on line 867 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $key is never used

Check warning on line 867 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $array is never used

Check warning on line 867 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

It is recommended not to use reserved keyword "array" as function parameter name. Found: $array
wc_deprecated_function( 'dokan_posted_input', '3.6.6' );

return '';
Expand All @@ -877,7 +877,7 @@
*
* @return string
*/
function dokan_posted_textarea( $key ) {

Check warning on line 880 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $key is never used
wc_deprecated_function( 'dokan_posted_textarea', '3.6.6' );

return '';
Expand Down Expand Up @@ -974,7 +974,7 @@
*
* @return string
*/
function dokan_locate_template( $template_name, $template_path = '', $default_path = '', $pro = false ) {

Check warning on line 977 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The method parameter $pro is never used
if ( ! $template_path ) {
$template_path = dokan()->template_path();
}
Expand Down Expand Up @@ -1099,8 +1099,8 @@
*
* @return mixed
*/
function dokan_get_option( $option, $section, $default = '' ) {

Check warning on line 1102 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

It is recommended not to use reserved keyword "default" as function parameter name. Found: $default
[ $option, $section ] = dokan_admin_settings_rearrange_map( $option, $section );

Check failure on line 1103 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The shorthand list syntax "[]" to destructure arrays is not available in PHP 7.0 or earlier.

$options = get_option( $section );

Expand Down Expand Up @@ -1178,7 +1178,16 @@
$user_nicename = ( false !== $userdata ) ? $userdata->user_nicename : '';
$custom_store_url = dokan_get_option( 'custom_store_url', 'dokan_general', 'store' );

return home_url( '/' . $custom_store_url . '/' . $user_nicename . '/' );
/**
* Filter hook for the store URL before returning.
*
* @since DOKAN_SINCE
*
* @param string $store_url The default store URL
* @param string $custom_store_url The custom store URL
* @param int $user_id The user ID for the store owner
*/
return apply_filters( 'dokan_get_store_url', home_url( '/' . $custom_store_url . '/' . $user_nicename . '/' ), $custom_store_url, $user_id );
}

/**
Expand Down Expand Up @@ -1232,7 +1241,7 @@
* @return array
*/
function dokan_media_uploader_restrict( $args ) {
if ( current_user_can( 'manage_woocommerce' ) ) {

Check warning on line 1244 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found unknown capability "manage_woocommerce" in function call to current_user_can(). Please check the spelling of the capability. If this is a custom capability, please verify the capability is registered with WordPress via a call to WP_Role(s)->add_cap(). Custom capabilities can be made known to this sniff by setting the "custom_capabilities" property in the PHPCS ruleset.
return $args;
}

Expand Down Expand Up @@ -2292,7 +2301,7 @@
global $wpdb;

$search_ids = [];
$terms = explode( ',', wc_clean( wp_unslash( $_GET['product_search_name'] ) ) );

Check failure on line 2304 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of a non-sanitized input variable: $_GET['product_search_name']

foreach ( $terms as $term ) {
if ( is_numeric( $term ) ) {
Expand Down Expand Up @@ -3939,7 +3948,7 @@
return $email;
}

[ $first, $last ] = explode( '@', $email );

Check failure on line 3951 in includes/functions.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

The shorthand list syntax "[]" to destructure arrays is not available in PHP 7.0 or earlier.
$first = str_replace( substr( $first, '1' ), str_repeat( '*', strlen( $first ) - 1 ), $first );
$last = explode( '.', $last );
$last_domain = str_replace( substr( $last['0'], '1' ), str_repeat( '*', strlen( $last['0'] ) - 1 ), $last['0'] );
Expand Down
Loading