Skip to content

Commit 7e5548d

Browse files
authored
Merge pull request #18 from threadi/feature/addGitHubAction
Feature/add GitHub action
2 parents 8119eb7 + dadec84 commit 7e5548d

File tree

4 files changed

+40
-20
lines changed

4 files changed

+40
-20
lines changed

.github/workflows/build-zip.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ jobs:
2222
composer update
2323
2424
- name: Run WordPress Coding Standard fixes
25-
run: vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/*,*/gettext-helper.php,*/classes/multilingual-plugins/easy-language/pagebuilder/divi/build/,*/classes/multilingual-plugins/easy-language/blocks/*/build/,*translatepress* --standard=ruleset.xml .
25+
run: vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .
2626

2727
- name: Run WordPress Coding Standard checks
28-
run: vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/*,*/gettext-helper.php,*/classes/multilingual-plugins/easy-language/pagebuilder/divi/build/,*/classes/multilingual-plugins/easy-language/blocks/*/build/,*translatepress* --standard=ruleset.xml .
28+
run: vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .
2929

3030
- name: Set version number 1
3131
uses: richardrigutins/replace-in-files@v2
@@ -47,8 +47,8 @@ jobs:
4747
rm -fr build
4848
rm -fr releases
4949
rm -fr languages
50-
rm -fr changelog.md
5150
rm -fr svn
51+
rm changelog.md
5252
rm readme.md
5353
cd ..
5454
zip -r -q ${{ github.event.repository.name }}_${{ github.ref_name }}.zip ${{ github.event.repository.name }}/* -x "*/.git/*" "*/.github/*" "*/blocks/*/src/*" "*/doc/*" "*/phpcs.xml" "*/composer.json" "*/composer.lock" "*/package.json" "*/package-lock.json" "*/.gitignore" "*/vendor/*" "*/node_modules/*" "/.editorconfig"

auto-category-for-posts.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,22 @@ function auto_category_save_post( int $post_id, WP_Post $post, bool $update ): v
8484
* @return array
8585
*/
8686
function auto_category_add_term_action( array $actions, WP_Term $tag ): array {
87-
// bail if it is not the category taxonomy.
87+
// bail if it is not the category taxonomy.
8888
if ( 'category' !== $tag->taxonomy ) {
89-
return $actions;
90-
}
91-
92-
// get taxonomy as object.
93-
$tax = get_taxonomy('category');
94-
if (current_user_can($tax->cap->manage_terms)) {
95-
$text = __('Set as default', 'auto-category-for-posts');
96-
$value = '';
97-
if (absint(get_option(AUTOCATEGORY_OPTIONNAME)) === $tag->term_id) {
98-
$text = __('Default category', 'auto-category-for-posts');
99-
$value = ' class="default_category"';
100-
}
101-
$actions['auto_category'] = '<a href="#"' . $value . ' data-termid="' . $tag->term_id . '" data-nonce="' . wp_create_nonce('auto_category_change_state') . '">' . esc_html( $text ) . '</a>';
102-
}
89+
return $actions;
90+
}
91+
92+
// get taxonomy as object.
93+
$tax = get_taxonomy( 'category' );
94+
if ( current_user_can( $tax->cap->manage_terms ) ) {
95+
$text = __( 'Set as default', 'auto-category-for-posts' );
96+
$value = '';
97+
if ( absint( get_option( AUTOCATEGORY_OPTIONNAME ) ) === $tag->term_id ) {
98+
$text = __( 'Default category', 'auto-category-for-posts' );
99+
$value = ' class="default_category"';
100+
}
101+
$actions['auto_category'] = '<a href="#"' . $value . ' data-termid="' . $tag->term_id . '" data-nonce="' . wp_create_nonce( 'auto_category_change_state' ) . '">' . esc_html( $text ) . '</a>';
102+
}
103103
return $actions;
104104
}
105105
add_filter( 'tag_row_actions', 'auto_category_add_term_action', 10, 2 );

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ OR use ant in build/-directory: `ant json-translations`
5050

5151
### Run
5252

53-
`vendor/bin/phpcs --standard=WordPress file`
53+
`vendor/bin/phpcs --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .`
5454

5555
### Repair
5656

57-
`vendor/bin/phpcbf --standard=WordPress file`
57+
`vendor/bin/phpcbf --extensions=php --ignore=*/vendor/*,*/doc/*,*/svn/*,*/node_modules/* --standard=ruleset.xml .`

ruleset.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0"?>
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="AutoCategoryForPosts" namespace="AutoCategoryForPosts\AutoCategoryForPosts" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd">
3+
4+
<description>Auto Category For Posts Coding Standards</description>
5+
6+
<rule ref="WordPress-Docs"/>
7+
<rule ref="WordPress-Extra"/>
8+
<rule ref="WordPress">
9+
<!-- Excluded in favour to match PSR-4-namings of classes. -->
10+
<exclude name="WordPress.Files.FileName"/>
11+
<!-- Exclude slow query -->
12+
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_query"/>
13+
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_meta_key"/>
14+
<exclude name="WordPress.DB.SlowDBQuery.slow_db_query_tax_query"/>
15+
<!-- Exclude override of globals -->
16+
<exclude name="WordPress.WP.GlobalVariablesOverride"/>
17+
<!-- Exclude direkt db query warnings -->
18+
<exclude name="WordPress.DB.DirectDatabaseQuery"/>
19+
</rule>
20+
</ruleset>

0 commit comments

Comments
 (0)