diff --git a/.github/workflows/lint-check-php.yml b/.github/workflows/lint-check-php.yml new file mode 100644 index 0000000..ab539d6 --- /dev/null +++ b/.github/workflows/lint-check-php.yml @@ -0,0 +1,64 @@ +name: 'Lint Checker: PHP' +on: + push: + paths: + - '**.php' + - '!build/**/*.php' + pull_request: + types: [opened, edited, reopened, ready_for_review] + paths: + - '**.php' + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} + cancel-in-progress: true + +jobs: + phpcs: + name: Run PHP Code Sniffer + runs-on: ubuntu-latest + steps: + + - name: Checkout + uses: actions/checkout@v3 + + # User PHP 7.4 here for compatibility with the WordPress codesniffer rules. + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.1' + coverage: none + tools: composer, cs2pr + + - uses: technote-space/get-diff-action@v6 + with: + PATTERNS: | + **/*.php + !build/**/*.php + + - name: Get Composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + if: "!! env.GIT_DIFF" + + - name: Cache Composer vendor directory + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-composer- + if: "!! env.GIT_DIFF" + + - name: Validate composer.json and composer.lock + run: composer validate + if: "!! env.GIT_DIFF" + + - name: Install dependencies + run: composer install --no-progress --optimize-autoloader --prefer-dist + if: "!! env.GIT_DIFF" + + - name: Detecting PHP Code Standards Violations + run: vendor/bin/phpcs --standard=phpcs.xml -s ${{ env.GIT_DIFF }} + if: "!! env.GIT_DIFF" diff --git a/includes/Data.php b/includes/Data.php index 6d2c8fc..650a781 100644 --- a/includes/Data.php +++ b/includes/Data.php @@ -69,6 +69,21 @@ public static function current_plan() { ); } + $current_flow = Flows::get_flow_from_top_priority(); + if ( 'ecommerce' === $current_flow ) { + return array( + 'flow' => 'ecommerce', + 'subtype' => 'wc_priority', + 'type' => null, + ); + } elseif ( Flows::get_default_flow() === $current_flow ) { + return array( + 'flow' => $current_flow, + 'subtype' => null, + 'type' => null, + ); + } + $current_flow = Flows::get_flow_from_plugins(); if ( false !== $current_flow ) { switch ( $current_flow ) { @@ -81,15 +96,6 @@ public static function current_plan() { } } - $current_flow = Flows::get_flow_from_top_priority(); - if ( false !== $current_flow ) { - return array( - 'flow' => 'ecommerce', - 'subtype' => 'wc_priority', - 'type' => null, - ); - } - return array( 'flow' => Flows::get_default_flow(), 'subtype' => null, diff --git a/includes/Flows/Flows.php b/includes/Flows/Flows.php index c40adae..d9f6158 100644 --- a/includes/Flows/Flows.php +++ b/includes/Flows/Flows.php @@ -56,7 +56,7 @@ final class Flows { // Any manual fixes or modification made to topPriority shall also be made in FlowServices::update_default_data_for_ecommerce() // Enums: `publishing`, `designing`, `selling`, 'migrating', 'regenerate' and 'skip' 'topPriority' => array( - 'priority1' => 'publishing', + 'priority1' => '', ), // This data will map to WordPress default 'blogname' @@ -276,9 +276,14 @@ public static function get_flow_from_plan_subtype( $plan_subtype ) { */ public static function get_flow_from_top_priority() { $flow_data = FlowService::read_data_from_wp_option(); - if ( $flow_data && isset( $flow_data['data']['topPriority']['priority1'] ) && 'selling' === $flow_data['data']['topPriority']['priority1'] ) { + if ( ! ( $flow_data && isset( $flow_data['data']['topPriority']['priority1'] ) ) ) { + return false; + } + + if ( 'selling' === $flow_data['data']['topPriority']['priority1'] ) { return true === self::get_flows()['ecommerce'] ? 'ecommerce' : false; } - return false; + + return self::get_default_flow(); } } diff --git a/includes/Patterns.php b/includes/Patterns.php index 305ff84..11015ad 100644 --- a/includes/Patterns.php +++ b/includes/Patterns.php @@ -359,6 +359,8 @@ public static function get_theme_step_patterns_from_step( $step, $squash = false $pattern_slugs = self::get_theme_step_patterns()[ $active_theme ][ $step ]; + $block_patterns = $squash ? '' : array(); + foreach ( array_keys( $pattern_slugs ) as $pattern_slug ) { if ( true !== $pattern_slugs[ $pattern_slug ]['active'] ) { continue; diff --git a/includes/Services/FlowService.php b/includes/Services/FlowService.php index 4662574..8cf5544 100644 --- a/includes/Services/FlowService.php +++ b/includes/Services/FlowService.php @@ -372,7 +372,9 @@ private static function update_data_for_ecommerce( $data ) { $flow_type = Data::current_flow(); if ( 'ecommerce' === $flow_type ) { // update default data with ecommerce data - $data['data']['topPriority']['priority1'] = 'selling'; + if ( empty( $data['data']['topPriority']['priority1'] ) ) { + $data['data']['topPriority']['priority1'] = 'selling'; + } if ( empty( $data['data']['siteType']['primary']['value'] ) ) { $data['data']['siteType']['primary']['refers'] = 'slug'; $data['data']['siteType']['primary']['value'] = 'business'; diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..ad881d3 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,6 @@ + + + + + +