Skip to content

Commit

Permalink
Merge pull request #42 from brainstormforce/wp-59-compatibility
Browse files Browse the repository at this point in the history
PHPCS setup
  • Loading branch information
premanshup authored Jan 28, 2022
2 parents f28fedd + 1ea3b48 commit b955d21
Show file tree
Hide file tree
Showing 10 changed files with 424 additions and 23 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: PHP_CodeSniffer

on: pull_request

jobs:
phpcs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.0'
coverage: none
tools: composer

- name: Install dependencies
run: composer install --prefer-dist --no-suggest --no-progress

- name: Detect coding standard violations
run: vendor/bin/phpcs
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ node_modules/
*.sql
*.tar.gz
*.zip
.github
.wordpress-org
.wordpress-org
vendor/
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
**Requires at least:** 4.4
**Requires PHP:** 5.3
**Tested up to:** 5.9
**Stable tag:** 1.0.2
**Stable tag:** 1.0.3
**License:** GPLv2 or later
**License URI:** https://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -43,6 +43,9 @@ This plugin currently works best with the <a href="https://wpastra.com/?utm_sour

## Changelog ##

### 1.0.3 ###
- Fix: Code updated according to coding standard.

### 1.0.2 ###
- Fixed: PHP Notice when the Custom Template is selected to None from the course.

Expand Down
8 changes: 4 additions & 4 deletions admin/class-ctlearndash-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function course_settings_fields( $fields ) {

$atts = array(
'post_type' => 'ld-custom-template',
'posts_per_page' => 500,
'posts_per_page' => 500, //phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page
'fields' => 'ids',
'post_status' => 'publish',
);
Expand Down Expand Up @@ -211,8 +211,8 @@ public function active_admin_menu() {
global $parent_file, $current_screen, $submenu_file, $pagenow;

if ( ( 'post-new.php' === $pagenow || 'post.php' === $pagenow ) && 'ld-custom-template' === $current_screen->post_type ) :
$submenu_file = 'edit.php?post_type=ld-custom-template'; // WPCS: OVERRIDE OK.
$parent_file = 'learndash-lms'; // WPCS: OVERRIDE OK.
$submenu_file = 'edit.php?post_type=ld-custom-template'; // phpcs:ignore OVERRIDE OK.
$parent_file = 'learndash-lms'; // phpcs:ignore OVERRIDE OK.
endif;

return $parent_file;
Expand Down Expand Up @@ -315,7 +315,7 @@ public function bb_builder_compatibility( $value ) {
*/
public function save_course_landing_page( $post_id ) {

$landing_page_id = ( isset( $_POST['course_template'] ) ) ? absint( $_POST['course_template'] ) : '';
$landing_page_id = ( isset( $_POST['course_template'] ) ) ? absint( $_POST['course_template'] ) : ''; //phpcs:ignore WordPress.CSRF.NonceVerification.NoNonceVerification

update_post_meta( $post_id, 'course_template', $landing_page_id );
}
Expand Down
10 changes: 5 additions & 5 deletions classes/class-ctlearndash.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public function get_action_content( $post_id ) {

global $post;
$current_post = $post;
$post = get_post( $post_id, OBJECT ); // WPCS: OVERRIDE OK.
$post = get_post( $post_id, OBJECT ); // phpcs:ignore OVERRIDE OK.
setup_postdata( $post );

if ( class_exists( 'FLBuilderModel' ) ) {
Expand All @@ -319,7 +319,7 @@ public function get_action_content( $post_id ) {

ob_start();
if ( is_callable( 'FLBuilderShortcodes::insert_layout' ) ) {
echo FLBuilderShortcodes::insert_layout( // WPCS: XSS OK.
echo FLBuilderShortcodes::insert_layout( // phpcs:ignore XSS OK.
array(
'id' => $post_id,
)
Expand All @@ -333,10 +333,10 @@ public function get_action_content( $post_id ) {
if ( self::is_elementor_activated( $post_id ) ) {

// set post to glabal post.
$post = $current_post; // WPCS: OVERRIDE OK.
$post = $current_post; // phpcs:ignore OVERRIDE OK.
$elementor_instance = Elementor\Plugin::instance();
ob_start();
echo $elementor_instance->frontend->get_builder_content_for_display( $post_id ); // WPCS: XSS OK.
echo $elementor_instance->frontend->get_builder_content_for_display( $post_id ); // phpcs:ignore XSS OK.
wp_reset_postdata();
return ob_get_clean();
}
Expand All @@ -350,7 +350,7 @@ public function get_action_content( $post_id ) {
// Add custom support for the Thrive Architect.
if ( self::is_tve_activated( $post_id ) ) {
ob_start();
echo apply_filters( 'the_content', $post->post_content ); // WPCS: XSS OK.
echo apply_filters( 'the_content', $post->post_content ); // phpcs:ignore XSS OK.
wp_reset_postdata();
return ob_get_clean();
}
Expand Down
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"squizlabs/php_codesniffer": "^3.2",
"wimg/php-compatibility": "^9.0",
"wp-coding-standards/wpcs": "^2.0.0"
"name": "brainstormforce/custom-template-learndash",
"description": "Custom Template Learndash in Astra Theme",
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"wp-coding-standards/wpcs": "dev-master",
"phpcompatibility/phpcompatibility-wp": "*"
},
"require": {
"scripts": {
"format": "phpcbf --standard=phpcs.xml.dist --report-summary --report-source",
"lint": "phpcs --standard=phpcs.xml.dist --report-summary --report-source"
}
}
Loading

0 comments on commit b955d21

Please sign in to comment.