From 80889f4ed08a1a1de7ce12303e81cc852ac3b648 Mon Sep 17 00:00:00 2001 From: James Hunt <10615884+thetwopct@users.noreply.github.com> Date: Tue, 14 Mar 2023 22:11:16 +0700 Subject: [PATCH] Fix code sniffs in MU plugin files Signed-off-by: James Hunt <10615884+thetwopct@users.noreply.github.com> --- .../lfevents/admin/class-lfevents-admin.php | 58 +++++++++---------- .../custom/lfevents/admin/partials/cpts.php | 2 +- .../lfevents/public/class-lfevents-public.php | 13 ++--- 3 files changed, 36 insertions(+), 37 deletions(-) diff --git a/web/wp-content/mu-plugins/custom/lfevents/admin/class-lfevents-admin.php b/web/wp-content/mu-plugins/custom/lfevents/admin/class-lfevents-admin.php index a56975acd..29d6f0b8c 100755 --- a/web/wp-content/mu-plugins/custom/lfevents/admin/class-lfevents-admin.php +++ b/web/wp-content/mu-plugins/custom/lfevents/admin/class-lfevents-admin.php @@ -344,7 +344,7 @@ public function reset_cache_check( $post_id ) { * @param int $post_id The post. * @return void */ - function staff_custom_column_data( $column, $post_id ) { + public function staff_custom_column_data( $column, $post_id ) { switch ( $column ) { case 'featured_image': the_post_thumbnail( 'thumbnail' ); @@ -357,7 +357,7 @@ function staff_custom_column_data( $column, $post_id ) { * * @param array $columns Column headers. */ - function staff_custom_column( $columns ) { + public function staff_custom_column( $columns ) { // take date column. $date = $columns['date']; // unset it so we can move it. @@ -373,17 +373,17 @@ function staff_custom_column( $columns ) { /** * Remove tags support from posts */ - function theme_unregister_tags() { + public function theme_unregister_tags() { unregister_taxonomy_for_object_type( 'post_tag', 'post' ); } /** * Removes unneeded admin menu items. */ - function custom_menu_page_removing() { + public function custom_menu_page_removing() { remove_menu_page( 'edit-comments.php' ); } - + /** * Sync KCDs from https://community.cncf.io/ to the commmunity events CPT. */ @@ -477,36 +477,36 @@ public function set_event_year( $post_id ) { } } -} - -/** - * Returns an array of all descendents of $post_id. - * Recursive function. - * - * @param int $post_id parent post. - */ -function get_kids( $post_id ) { - global $wpdb; + /** + * Returns an array of all descendents of $post_id. + * Recursive function. + * + * @param int $post_id parent post. + */ + private function get_kids( $post_id ) { + global $wpdb; - $kid_ids = array(); + $kid_ids = array(); - $kid_posts = $wpdb->get_results( - $wpdb->prepare( - "SELECT * FROM $wpdb->posts + $kid_posts = $wpdb->get_results( + $wpdb->prepare( + "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_status <> 'trash'", - $post_id - ) - ); + $post_id + ) + ); - if ( ! $kid_posts ) { - return array(); - } + if ( ! $kid_posts ) { + return array(); + } + + foreach ( $kid_posts as $kid ) { + $kid_ids[] = $kid->ID; + $kid_ids = array_merge( $kid_ids, get_kids( $kid->ID ) ); + } - foreach ( $kid_posts as $kid ) { - $kid_ids[] = $kid->ID; - $kid_ids = array_merge( $kid_ids, get_kids( $kid->ID ) ); + return $kid_ids; } - return $kid_ids; } diff --git a/web/wp-content/mu-plugins/custom/lfevents/admin/partials/cpts.php b/web/wp-content/mu-plugins/custom/lfevents/admin/partials/cpts.php index 2f9091bea..5c5f2b44a 100644 --- a/web/wp-content/mu-plugins/custom/lfevents/admin/partials/cpts.php +++ b/web/wp-content/mu-plugins/custom/lfevents/admin/partials/cpts.php @@ -122,4 +122,4 @@ 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'revisions', 'custom-fields', 'author' ), ); -register_post_type( 'lfe_community_event', $opts ); \ No newline at end of file +register_post_type( 'lfe_community_event', $opts ); diff --git a/web/wp-content/mu-plugins/custom/lfevents/public/class-lfevents-public.php b/web/wp-content/mu-plugins/custom/lfevents/public/class-lfevents-public.php index c28ae6cb0..d156d7e84 100755 --- a/web/wp-content/mu-plugins/custom/lfevents/public/class-lfevents-public.php +++ b/web/wp-content/mu-plugins/custom/lfevents/public/class-lfevents-public.php @@ -174,7 +174,7 @@ public function insert_event_styles() { * * @param string $url the URL. */ - function defer_parsing_of_js( $url ) { + public function defer_parsing_of_js( $url ) { // Stop if admin. if ( is_admin() ) { return $url; @@ -202,7 +202,7 @@ function defer_parsing_of_js( $url ) { * @param string $hints returns hints. * @param string $relation_type returns priority. */ - function change_to_preconnect_resource_hints( $hints, $relation_type ) { + public function change_to_preconnect_resource_hints( $hints, $relation_type ) { if ( 'preconnect' === $relation_type ) { $hints[] = array( @@ -222,7 +222,7 @@ function change_to_preconnect_resource_hints( $hints, $relation_type ) { * * @param string $more more text. */ - function new_excerpt_more( $more ) { + public function new_excerpt_more( $more ) { return ''; } @@ -231,7 +231,7 @@ function new_excerpt_more( $more ) { * * @param int $length Number of words. */ - function custom_excerpt_length( $length ) { + public function custom_excerpt_length( $length ) { return 18; } @@ -252,7 +252,7 @@ function custom_excerpt_length( $length ) { * May be (for example) 'breadcrumb' or 'article' for structured data. * @return array $params */ - function my_tsf_custom_image_generation_args( $params = array(), $args = null, $context = 'social' ) { + public function my_tsf_custom_image_generation_args( $params = array(), $args = null, $context = 'social' ) { // Let's not mess with non-social sharing images. if ( 'social' !== $context ) { @@ -318,7 +318,7 @@ public function disable_pingback( &$links ) { * @param string $urls array of urls. * @param string $relation_type returns priority. */ - function dns_prefetch_to_preconnect( $urls, $relation_type ) { + public function dns_prefetch_to_preconnect( $urls, $relation_type ) { global $wp_scripts, $wp_styles; $unique_urls = array(); @@ -439,5 +439,4 @@ public function add_year_to_archive_titles( $title ) { return $title; } - }