forked from getdokan/dokan
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
327 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/.wordpress-org | ||
/.git | ||
/.github | ||
/node_modules | ||
/src | ||
/tests | ||
/bin | ||
/docs | ||
/build | ||
/.idea | ||
/.vscode | ||
/assets/src | ||
|
||
.distignore | ||
.gitignore | ||
/**/.DS_Store | ||
/**/*.LICENCE.txt | ||
package.json | ||
package-lock.json | ||
composer.json | ||
composer.lock | ||
README.md | ||
CHANGELOG.md | ||
LICENSE | ||
phpcs.xml.dist | ||
phpunit.xml.dist | ||
phpunit.xml | ||
.editorconfig | ||
.eslintrc | ||
.php_cs | ||
.phpunit.result.cache | ||
.prettierrc.js | ||
appsero.json | ||
CONTRIBUTING.md | ||
DEVELOPER.md | ||
event.json | ||
postcss.config.js | ||
webpack.config.js | ||
tailwind.config.js | ||
/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Deploy and Release Plugin to WP.org | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
jobs: | ||
releaseToWPOrg: | ||
name: Release to WordPress.org | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Setup PHP 7.4 | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '7.4' | ||
coverage: none | ||
tools: composer:v2 | ||
- name: Build | ||
run: | | ||
composer install --no-dev | ||
npm install | ||
npm run build | ||
- name: Install SVN ( Subversion ) | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install subversion | ||
- name: WordPress Plugin Deploy | ||
id: deploy | ||
uses: 10up/action-wordpress-plugin-deploy@stable | ||
with: | ||
generate-zip: true | ||
dry-run: ${{ env.DRY_RUN }} | ||
env: | ||
SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | ||
SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | ||
SLUG: dokan-lite | ||
- name: Create GitHub release | ||
uses: softprops/action-gh-release@v2 | ||
with: | ||
files: ${{github.workspace}}/${{ github.event.repository.name }}.zip | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,3 +364,11 @@ | |
} | ||
} | ||
} | ||
|
||
|
||
|
||
// wp dokan logo styles | ||
|
||
#adminmenu #toplevel_page_dokan .wp-menu-image.svg { | ||
background-size: 17px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
namespace WeDevs\Dokan\Analytics\Reports; | ||
|
||
use WeDevs\Dokan\Contracts\Hookable; | ||
|
||
/** | ||
* Seller analytics data filter. | ||
* | ||
* @since DOKAN_SINCE | ||
*/ | ||
class CacheKeyModifier implements Hookable { | ||
|
||
/** | ||
* Report entities to modify. | ||
* | ||
* @since DOKAN_SINCE | ||
* | ||
* @var array | ||
*/ | ||
protected array $entities; | ||
|
||
/** | ||
* CacheKeyModifier constructor. | ||
* Registers the hooks on instantiation. | ||
*/ | ||
public function __construct() { | ||
$this->setup_entities(); | ||
$this->register_hooks(); | ||
} | ||
|
||
/** | ||
* Setup analytics entities | ||
* | ||
* @since DOKAN_SINCE | ||
* | ||
* WC apply filters from @see https://github.com/woocommerce/woocommerce/blob/be602de39d39878085e752f30ec1dabf16b0d642/plugins/woocommerce/src/Admin/API/Reports/GenericQuery.php#L77 | ||
* WC reports generation pattern @see https://github.com/woocommerce/woocommerce/blob/be602de39d39878085e752f30ec1dabf16b0d642/plugins/woocommerce/src/Admin/API/Reports/Products/Controller.php#L53 | ||
* | ||
* @return void | ||
*/ | ||
protected function setup_entities(): void { | ||
$this->entities = apply_filters( | ||
'dokan_analytics_entities_for_query_args', | ||
[ | ||
'categories', | ||
'coupons', | ||
'coupons_stats', | ||
'customers', | ||
'downloads', | ||
'downloads_stats', | ||
'orders', | ||
'orders_stats', | ||
'products', | ||
'products_stats', | ||
'revenue', | ||
'taxes', | ||
'taxes_stats', | ||
'variations', | ||
'variations_stats', | ||
] | ||
); | ||
} | ||
|
||
/** | ||
* Register necessary hooks. | ||
* | ||
* @since DOKAN_SINCE | ||
* | ||
* @return void | ||
*/ | ||
public function register_hooks(): void { | ||
foreach ( $this->entities as $entity ) { | ||
add_filter( "woocommerce_analytics_{$entity}_query_args", [ $this, 'apply_seller_filter' ] ); | ||
} | ||
} | ||
|
||
/** | ||
* Apply seller filter to query arguments. | ||
* | ||
* Customize the WooCommerce analytics stats datastore to override the $total_query and $interval_query properties. | ||
* This modification replaces the Automattic\WooCommerce\Admin\API\Reports\SqlQuery class with WeDevs\Dokan\Analytics\Reports\WcSqlQuery | ||
* to apply specific filters to queries. | ||
* | ||
* @see https://github.com/woocommerce/woocommerce/tree/trunk/plugins/woocommerce/src/Admin/API/Reports | ||
* | ||
* @param array $args An array of query arguments. | ||
* | ||
* @return array Modified array of query arguments. | ||
*/ | ||
public function apply_seller_filter( array $args ): array { | ||
$seller_id = (int) dokan()->get_container()->get( \WeDevs\Dokan\Analytics\Reports\Stock\QueryFilter::class )->get_vendor_id(); | ||
|
||
// If seller ID is not set, return the original arguments. | ||
if ( ! $this->is_valid_seller_id( $seller_id ) ) { | ||
return $args; | ||
} | ||
|
||
$args['seller_id'] = $seller_id; | ||
return $args; | ||
} | ||
|
||
/** | ||
* Check if report can be filtered. | ||
* | ||
* @param int $seller_id Seller ID. | ||
* | ||
* @since DOKAN_SINCE | ||
* | ||
* @return bool | ||
*/ | ||
protected function is_valid_seller_id( int $seller_id ): bool { | ||
return $seller_id > 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.