Skip to content

Commit

Permalink
add opensource toolikng and fix CS issues
Browse files Browse the repository at this point in the history
  • Loading branch information
petitphp committed Dec 2, 2024
1 parent f8f5b9d commit ca99e6e
Show file tree
Hide file tree
Showing 14 changed files with 5,293 additions and 138 deletions.
24 changes: 24 additions & 0 deletions .distignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/.git
/.github
/.wordpress-org
/node_modules

.distignore
.editorconfig
.gitattributes
.gitignore
.plugin-data
.wp-env.json
CHANGELOG.md
composer.json
composer.lock
grumphp.yml
LICENSE.md
package.json
package-lock.json
phpcs.xml.dist
phpunit.xml.dist
psalm.xml.dist
README.md
webpack.config.js
yarn.lock
22 changes: 22 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/.git export-ignore
/.github export-ignore
/vendor/ export-ignore -diff
/node_modules export-ignore

/.distignore export-ignore
/.editorconfig export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.plugin-data export-ignore
/.wp-env.json export-ignore
/composer.json export-ignore
/composer.lock export-ignore -diff
/grumphp.yml export-ignore
/LICENSE.md export-ignore
/package.json export-ignore
/package-lock.json export-ignore -diff
/phpcs.xml.dist export-ignore
/psalm.xml.dist export-ignore
/README.md export-ignore
/webpack.config.js export-ignore
/yarn.lock export-ignore
38 changes: 38 additions & 0 deletions .github/workflows/pull-request-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Check plugin version and tags"
on:
pull_request:
branches:
- main

jobs:
version-check:
name: "Check version doesn't not already exists."
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- id: set-vars
name: "Set variables from .plugin-data file"
run: |
# Get all data from .plugin-data file
content=`cat ./.plugin-data`
# the following lines are only required for multi line json
content="${content//'%'/'%25'}"
content="${content//$'\n'/'%0A'}"
content="${content//$'\r'/'%0D'}"
# end of optional handling for multi line json
echo "::set-output name=pluginData::$content"
- id: version-check
name: "Check version in .plugin-data is not existing"
run: |
# Check version from .plugin-data
VERSION=${{fromJson(steps.set-vars.outputs.pluginData).version}}
if git rev-parse "$VERSION" >/dev/null 2>&1; then
echo "Tag aleady exists please update the .plugin-data file to good version";
exit 1;
fi
38 changes: 38 additions & 0 deletions .github/workflows/quality-php.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: PHP Quality Checks

on:
pull_request:
push:
branches:
- main

# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

jobs:
checks:
name: Lint PHP
runs-on: ubuntu-latest

steps:
- name: Checkout project
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4
extensions: mbstring, intl

- name: Validate composer file
run: composer validate

- name: Install composer dependencies
run: composer install

- name: Run codesniffer
run: composer cs
164 changes: 110 additions & 54 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,58 +1,114 @@
# folders and files to be ignored by git

############
## IDEs
############

*.pydevproject
.project
.metadata
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
.externalToolBuilders/
*.launch
.cproject
.buildpath
nbproject/
node_modules/*
premium/node_modules/*
package-lock.json

############
## OSes
############

[Tt]humbs.db
[Dd]esktop.ini
*.DS_store
.DS_store?

############
## Misc
############

bin/
tmp/
*.tmp
*.bak
*.log
*.[Cc]ache
*.cpr
*.orig
*.php.in
.idea/
temp/
### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp
*.exe

### OSX ###
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear on external disk
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*

### VS Code ###
.vscode/

### SublimeText ###
# workspace files are user-specific
*.sublime-workspace

# project files should be checked into the repository, unless a significant
# proportion of contributors will probably not be using SublimeText
*.sublime-project

sftp-config.json
sftp-config-alt.json

### PhpStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode

## Directory-based project format
.idea/
# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml

## File-based project format
*.ipr
*.iws
*.iml

## Additional for IntelliJ
out/

# generated by mpeltonen/sbt-idea plugin
.idea_modules/

### NodeJS ###
node_modules/
styleguide/
bower_components/

### Composer ###
/vendor/

### Google ###
google*.html

# Logs
*.log

.svn
# Dotenv
.env
.env.*

############
## Composer
############
vendor/
composer.phar
# Others
*.sql
*.sql.gz
4 changes: 4 additions & 0 deletions .plugin-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "2.1.3",
"slug": "acf-svg-icon"
}
61 changes: 30 additions & 31 deletions acf-svg-icon.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
<?php
/*
Plugin Name: Advanced Custom Fields: SVG Icon
Version: 2.1.3
Plugin URI: http://www.beapi.fr
Description: Add an ACF SVG icon selector.
Author: BE API Technical team
Author URI: https://www.beapi.fr
Domain Path: languages
Text Domain: acf-svg-icon
----
Copyright 2017 BE API Technical team ([email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Plugin Name: Advanced Custom Fields: SVG Icon
Version: 2.1.3
Plugin URI: http://www.beapi.fr
Description: Add an ACF SVG icon selector.
Author: BE API Technical team
Author URI: https://www.beapi.fr
Domain Path: languages
Text Domain: acf-svg-icon
----
Copyright 2017 BE API Technical team ([email protected])
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

if ( ! defined( 'ABSPATH' ) ) {
Expand All @@ -36,7 +36,7 @@
define( 'ACF_SVG_ICON_URL', plugin_dir_url( __FILE__ ) );
define( 'ACF_SVG_ICON_DIR', plugin_dir_path( __FILE__ ) );

class acf_field_svg_icon_plugin {
class Acf_Field_Svg_Icon_Plugin {

/**
* Constructor.
Expand All @@ -46,10 +46,10 @@ class acf_field_svg_icon_plugin {
* @since 1.0.0
*/
public function __construct() {
add_action( 'init', array( __CLASS__, 'load_translation' ), 1 );
add_action( 'init', [ __CLASS__, 'load_translation' ], 1 );

// Register ACF fields
add_action( 'acf/include_field_types', array( __CLASS__, 'register_field_v5' ) );
add_action( 'acf/include_field_types', [ __CLASS__, 'register_field_v5' ] );
}

/**
Expand Down Expand Up @@ -90,8 +90,7 @@ public static function register_field_v5() {
* @since 1.0.0
*/
function acf_field_svg_icon() {
new acf_field_svg_icon_plugin();
new Acf_Field_Svg_Icon_Plugin();
}

add_action( 'plugins_loaded', 'acf_field_svg_icon' );

Loading

0 comments on commit ca99e6e

Please sign in to comment.