From 69045acba4a37435eb7a67bafc618fc9acc3eeb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9sz=C3=A1ros=20R=C3=B3bert?= <6097856+meszarosrob@users.noreply.github.com> Date: Thu, 22 Jun 2023 01:45:35 +0300 Subject: [PATCH] Add WP PHPCS and apply auto fixable changes (#1) --- .gitignore | 2 ++ comment-saver.php | 36 ++++++++++++++++++------------------ composer.json | 28 ++++++++++++++++++++++++++++ phpcs.xml | 11 +++++++++++ 4 files changed, 59 insertions(+), 18 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 phpcs.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3a9875b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +composer.lock diff --git a/comment-saver.php b/comment-saver.php index 915e39b..3d1d0a0 100644 --- a/comment-saver.php +++ b/comment-saver.php @@ -10,37 +10,37 @@ */ -add_action('comment_form', 'comment_saver_form'); -add_filter('comment_post_redirect', 'comment_saver_cleanup', 10, 2); -add_action('wp', 'comment_saver_js'); +add_action( 'comment_form', 'comment_saver_form' ); +add_filter( 'comment_post_redirect', 'comment_saver_cleanup', 10, 2 ); +add_action( 'wp', 'comment_saver_js' ); -/** - * Get path for comment saver cookie. +/** + * Get path for comment saver cookie. */ function comment_saver_cookie_path() { - $parts = parse_url(get_option('home')); - $path = array_key_exists('path', $parts) ? $parts['path'] : '/'; + $parts = parse_url( get_option( 'home' ) ); + $path = array_key_exists( 'path', $parts ) ? $parts['path'] : '/'; return $path; } -/** - * Setup require javascript. +/** + * Setup require javascript. */ function comment_saver_js() { - if (is_single() || is_comments_popup()) { - wp_enqueue_script('jquery.cookie', plugins_url('comment-saver/jquery.cookie.min.js'), array('jquery'), false, true); + if ( is_single() || is_comments_popup() ) { + wp_enqueue_script( 'jquery.cookie', plugins_url( 'comment-saver/jquery.cookie.min.js' ), array( 'jquery' ), false, true ); } } -/** - * Add jQuery actions to save and restore comment. +/** + * Add jQuery actions to save and restore comment. */ -function comment_saver_form($id) { +function comment_saver_form( $id ) { $cookieName = 'comment_saver_post' . $id; - $path = comment_saver_cookie_path(); + $path = comment_saver_cookie_path(); echo '