-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
a1e6aaf
commit 40afbcd
Showing
7 changed files
with
95 additions
and
25 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 |
---|---|---|
|
@@ -21,15 +21,15 @@ pipelines: | |
script: | ||
- composer install --no-interaction --no-progress --prefer-dist --ignore-platform-reqs | ||
- ./vendor/bin/phpunit --testsuite "Unit Test Suite" | ||
- step: | ||
name: Deploy docs to production | ||
caches: | ||
- composer | ||
- vendor-directory | ||
deployment: production | ||
script: | ||
- apt-get update && apt-get install -y rsync | ||
- ssh [email protected] mkdir -p /data/www/docs.openwebconcept.nl/htdocs/plugins/openpub && rsync -avH ./docs/* -e "ssh" [email protected]:/data/www/docs.openwebconcept.nl/htdocs/plugins/openpub | ||
# - step: | ||
# name: Deploy docs to production | ||
# caches: | ||
# - composer | ||
# - vendor-directory | ||
# deployment: production | ||
# script: | ||
# - apt-get update && apt-get install -y rsync | ||
# - ssh [email protected] mkdir -p /data/www/docs.openwebconcept.nl/htdocs/plugins/openpub && rsync -avH ./docs/* -e "ssh" [email protected]:/data/www/docs.openwebconcept.nl/htdocs/plugins/openpub | ||
|
||
definitions: | ||
caches: | ||
|
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 |
---|---|---|
|
@@ -3,9 +3,9 @@ | |
"description": "OpenPub base plugin", | ||
"authors": [ | ||
{ | ||
"name": "Yard Internet", | ||
"name": "Yard Digital Agency", | ||
"email": "[email protected]", | ||
"homepage": "https://www.yardinternet.nl" | ||
"homepage": "https://www.yard.nl" | ||
} | ||
], | ||
"type": "wordpress-plugin", | ||
|
@@ -24,6 +24,7 @@ | |
"phpunit/phpunit": "~8.0", | ||
"10up/wp_mock": "dev-master", | ||
"friendsofphp/php-cs-fixer": "^2.0", | ||
"phpstan/phpstan": "^0.12", | ||
"szepeviktor/phpstan-wordpress": "^0.6.0" | ||
}, | ||
"autoload": { | ||
|
@@ -37,14 +38,13 @@ | |
} | ||
}, | ||
"scripts": { | ||
"unit": "clear && ./vendor/bin/phpunit --stderr --testsuite 'Unit Test Suite' --colors=always", | ||
"unit-coverage": "clear && ./vendor/bin/phpunit --stderr --testsuite 'Unit Test Suite' --prepend tests/xdebug-filter.php --colors=always --coverage-html ./tests/coverage", | ||
"integration": "clear && ./vendor/bin/phpunit --stderr --testsuite 'Integration Test Suite' --colors=always", | ||
"cs": "./vendor/bin/php-cs-fixer fix", | ||
"docs": "./vendor/bin/phpdoc -d ./src/Base -t ./docs", | ||
"stan": "./vendor/bin/phpstan analyse src tests", | ||
"test": [ | ||
"@unit", | ||
"@integration" | ||
"@unit" | ||
], | ||
"cs": "./vendor/bin/php-cs-fixer fix", | ||
"phpstan": "./vendor/bin/phpstan analyse --no-progress" | ||
"unit": "clear && ./vendor/bin/phpunit --testsuite 'Unit Test Suite' --colors=always", | ||
"unit-coverage": "clear && ./vendor/bin/phpunit --testsuite 'Unit Test Suite' --colors=always --coverage-html ./tests/coverage" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,57 @@ | ||
<?php | ||
|
||
namespace OWC\OpenPub\Base\RestAPI\ItemFields; | ||
|
||
class CommentField extends \OWC\OpenPub\Base\Support\CreatesFields | ||
{ | ||
/** | ||
* Creates an array of comments. | ||
* | ||
* @param \WP_Post $post | ||
* | ||
* @return array | ||
*/ | ||
public function create(\WP_Post $post): array | ||
{ | ||
$result = []; | ||
$result['count'] = (int) $post->comment_count; | ||
$result['status'] = $post->comment_status; | ||
$result['items'] = []; | ||
|
||
if (!in_array($post->comment_status, ['open'])) { | ||
return $result; | ||
} | ||
|
||
$result['items'] = $this->getComments($post->ID); | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Get comment items of a post. | ||
* | ||
* @param int $postID | ||
* | ||
* @return array | ||
*/ | ||
protected function getComments(int $postID): array | ||
{ | ||
$comments = get_comments([ | ||
'post_id' => $postID, | ||
'status' => 'approve' | ||
]); | ||
|
||
if (! $comments) { | ||
return []; | ||
} | ||
|
||
return array_map(function (\WP_Comment $comment) { | ||
return [ | ||
'id' => $comment->comment_ID, | ||
'author' => $comment->comment_author, | ||
'content' => $comment->comment_content, | ||
'date' => $comment->comment_date | ||
]; | ||
}, $comments); | ||
} | ||
} |
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