From eec01920773c7fe9a88632f5bee90679755a3c14 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:23:50 +0200 Subject: [PATCH 01/28] refactor: remove return values, as `autonomie_save_post` is hooked into action and return value is not used --- includes/featured-image.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/includes/featured-image.php b/includes/featured-image.php index 48fb33c..a2796ed 100644 --- a/includes/featured-image.php +++ b/includes/featured-image.php @@ -104,29 +104,31 @@ function autonomie_featured_image_meta( $content, $post_id ) { * Safe the Post Covers * * @param int $post_id The ID of the post being saved. + * + * @return void */ function autonomie_save_post( $post_id ) { // if this is an autosave, our form has not been submitted, so we don't want to do anything. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { - return $post_id; + return; } if ( ! array_key_exists( 'full_width_featured_image', $_POST ) ) { - return $post_id; + return; } if ( ! array_key_exists( 'post_type', $_POST ) ) { - return $post_id; + return; } // check the user's permissions. if ( 'page' === $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { - return $post_id; + return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { - return $post_id; + return; } } From ba9cf2fff5843f2807c3d696ac6db964adb7d9b9 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:25:50 +0200 Subject: [PATCH 02/28] refactor: simplify unset calls for query variables in compat.php --- includes/compat.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/compat.php b/includes/compat.php index 94fecc2..d69e3cf 100644 --- a/includes/compat.php +++ b/includes/compat.php @@ -64,9 +64,11 @@ function autonomie_query_format_standard( $query ) { } $query->is_tax = null; - unset( $query->query_vars['post_format'] ); - unset( $query->query_vars['taxonomy'] ); - unset( $query->query_vars['term'] ); + unset( + $query->query_vars['post_format'], + $query->query_vars['taxonomy'], + $query->query_vars['term'] + ); $query->set( 'tax_query', From 3aeee73398896e4f8cc743cee62590d4c3fc7d4a Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:28:55 +0200 Subject: [PATCH 03/28] refactor: fix phpdoc return types for post format functions in feed.php and template-functions.php --- includes/feed.php | 9 +++++++-- includes/template-functions.php | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/includes/feed.php b/includes/feed.php index 8264572..c7a8988 100644 --- a/includes/feed.php +++ b/includes/feed.php @@ -12,7 +12,7 @@ * * @param string $post_format the post format slug * - * @return void + * @return string|false */ function autonomie_get_post_format_archive_feed_link( $post_format, $feed = '' ) { $default_feed = get_default_feed(); @@ -138,7 +138,12 @@ function autonomie_extend_singular_feed_discovery( $args = array() ) { foreach ( $feeds as $feed ) { if ( array_key_exists( 'href', $feed ) && array_key_exists( 'title', $feed ) ) { - printf( '', esc_attr( feed_content_type() ), esc_attr( $feed['title'] ), esc_url( $feed['href'] ) ); + printf( + '', + esc_attr( feed_content_type() ), + esc_attr( $feed['title'] ), + esc_url( $feed['href'] ) + ); echo PHP_EOL; } } diff --git a/includes/template-functions.php b/includes/template-functions.php index 3ab4a9f..f4891e6 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -209,7 +209,7 @@ function autonomie_get_post_format_string() { * * @param string $post_format * - * @return void + * @return string */ function autonomie_get_post_format_link( $post_format ) { if ( in_array( get_post_type(), array( 'page', 'attachment' ), true ) ) { From 976f1cba401cd9e264ac6b3cba605a6c09855012 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:29:25 +0200 Subject: [PATCH 04/28] refactor: reorder condition for post format feed discovery in feed.php --- includes/feed.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/feed.php b/includes/feed.php index c7a8988..de3ee4d 100644 --- a/includes/feed.php +++ b/includes/feed.php @@ -126,9 +126,9 @@ function autonomie_extend_singular_feed_discovery( $args = array() ) { // Add "standard" post-format feed discovery global $wp_query; if ( - is_archive() && isset( $wp_query->query['post_format'] ) && - 'post-format-standard' === $wp_query->query['post_format'] + 'post-format-standard' === $wp_query->query['post_format'] && + is_archive() ) { $feeds[] = array( 'title' => sprintf( $args['posttypetitle'], get_bloginfo( 'name' ), $args['separator'], get_post_format_string( 'standard' ) ), From 5daf2a4129a10c232f728c21e50a5df85c43d4a8 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:29:59 +0200 Subject: [PATCH 05/28] refactor: update comments for clarity in customizer.php and featured-image.php --- includes/customizer.php | 2 +- includes/featured-image.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/customizer.php b/includes/customizer.php index 8e9af16..56f0d90 100644 --- a/includes/customizer.php +++ b/includes/customizer.php @@ -10,7 +10,7 @@ function autonomie_customize_register( $wp_customize ) { 'autonomie_settings_section', array( 'title' => __( 'Advanced Settings', 'autonomie' ), - 'description' => __( 'Enable/Disable some advanced Autonomie features.', 'autonomie' ), //Descriptive tooltip + 'description' => __( 'Enable/Disable some advanced Autonomie features.', 'autonomie' ), //Descriptive tooltip. 'priority' => 35, ) ); diff --git a/includes/featured-image.php b/includes/featured-image.php index a2796ed..b8e5b01 100644 --- a/includes/featured-image.php +++ b/includes/featured-image.php @@ -157,7 +157,7 @@ function autonomie_has_full_width_featured_image() { $full_width_featured_image = get_post_meta( get_the_ID(), 'full_width_featured_image', true ); - // If Use featured image as Post Cover has been checked in the Featured Image meta box, return true. + // If "Use featured image as Post Cover" has been checked in the Featured Image meta box, return true. if ( '1' === $full_width_featured_image ) { return true; } From 6bf8f11a0a0a6fede6da2cf7ca7ced42bea7005d Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:35:16 +0200 Subject: [PATCH 06/28] refactor: update phpdoc for parameters and return types in compat.php --- includes/compat.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/compat.php b/includes/compat.php index d69e3cf..e37a071 100644 --- a/includes/compat.php +++ b/includes/compat.php @@ -19,8 +19,8 @@ /** * Adds the new input types to the comment-form * - * @param string $form - * @return string + * @param array $fields The comment form fields. + * @return array */ function autonomie_comment_autocomplete( $fields ) { $fields['author'] = preg_replace( '/ Date: Sat, 5 Apr 2025 08:43:45 +0200 Subject: [PATCH 07/28] refactor: improve code clarity and consistency in semantics.php --- includes/semantics.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/includes/semantics.php b/includes/semantics.php index a9c3f34..872e80b 100644 --- a/includes/semantics.php +++ b/includes/semantics.php @@ -52,9 +52,9 @@ function autonomie_post_classes( $classes ) { if ( ! is_singular() ) { return autonomie_get_post_classes( $classes ); - } else { - return $classes; } + + return $classes; } add_filter( 'post_class', 'autonomie_post_classes', 99 ); @@ -120,6 +120,7 @@ function autonomie_pre_get_avatar_data( $args, $id_or_email ) { $username = get_the_author_meta( 'display_name', $id_or_email ); if ( $username ) { + // translators: %s: username $args['alt'] = sprintf( __( 'User Avatar of %s' ), $username ); } else { $args['alt'] = __( 'User Avatar' ); @@ -133,7 +134,7 @@ function autonomie_pre_get_avatar_data( $args, $id_or_email ) { /** * Add rel-prev attribute to previous_image_link. * - * @param string a-tag + * @param string $link The a-tag to filter. * * @return string */ @@ -145,7 +146,7 @@ function autonomie_semantic_previous_image_link( $link ) { /** * Add rel-next attribute to next_image_link. * - * @param string a-tag + * @param string $link The a-tag to filter. * * @return string */ @@ -157,7 +158,7 @@ function autonomie_semantic_next_image_link( $link ) { /** * Add rel-prev attribute to next_posts_link_attributes. * - * @param string Attributes + * @param string $attr Attributes. * * @return string */ @@ -169,7 +170,7 @@ function autonomie_next_posts_link_attributes( $attr ) { /** * Add rel-next attribute to previous_posts_link. * - * @param string Attributes + * @param string $attr Attributes. * * @return string */ @@ -277,13 +278,13 @@ function autonomie_get_the_semantics( $id ) { $classes = autonomie_get_semantics( $id ); if ( ! $classes ) { - return; + return ''; } $class = ''; foreach ( $classes as $key => $value ) { - $class .= ' ' . esc_attr( $key ) . '="' . esc_attr( join( ' ', $value ) ) . '"'; + $class .= ' ' . esc_attr( $key ) . '="' . esc_attr( implode( ' ', $value ) ) . '"'; } return $class; @@ -302,7 +303,7 @@ function autonomie_semantics( $id ) { } foreach ( $classes as $key => $value ) { - echo ' ' . esc_attr( $key ) . '="' . esc_attr( join( ' ', $value ) ) . '"'; + echo ' ' . esc_attr( $key ) . '="' . esc_attr( implode( ' ', $value ) ) . '"'; } } @@ -325,7 +326,7 @@ function autonomie_term_links_tag( $links ) { } if ( empty( $terms ) ) { - return false; + return array(); } $links = array(); From fbe89bee6a3e1d14de093c5812423f7a77ffa4cd Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:44:23 +0200 Subject: [PATCH 08/28] refactor: improve comment clarity in featured-image.php --- includes/featured-image.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/featured-image.php b/includes/featured-image.php index b8e5b01..65ebbf5 100644 --- a/includes/featured-image.php +++ b/includes/featured-image.php @@ -150,7 +150,7 @@ function autonomie_save_post( $post_id ) { * or none of the above conditions are true. */ function autonomie_has_full_width_featured_image() { - // If this isn't a Single post type or we don't have a Featured Image set + // If this isn't a Single post type, or we don't have a Featured Image set. if ( ! ( is_single() || is_page() ) || ! has_post_thumbnail() ) { return false; } From c8b735ef7a7b1fabd544ed11ac1b6bd58ec8b978 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 08:50:10 +0200 Subject: [PATCH 09/28] chore: update PHP version requirement to 7.4 and configure plugin allowance in composer.json --- .gitignore | 1 + composer.json | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2f94dbf..ca7e11a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ /node_modules/ /vendor/ .DS_Store +.idea _build composer.lock package-lock.json diff --git a/composer.json b/composer.json index 2ba1671..931945e 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "pfefferle/wordpress-autonomie", "description": "Pure Zen", "require": { - "php": ">=5.6.0", + "php": ">=7.4.0", "composer/installers": "~2.2" }, "type": "wordpress-theme", @@ -15,5 +15,10 @@ ], "extra": { "installer-name": "autonomie" + }, + "config": { + "allow-plugins": { + "composer/installers": true + } } } From 979168ade6ca9f2f9bfd808dd2e213e5b023a073 Mon Sep 17 00:00:00 2001 From: Christoph Daum Date: Sat, 5 Apr 2025 09:05:32 +0200 Subject: [PATCH 10/28] refactor: enhance code clarity and consistency in template-functions.php removed unused globals fixed code style fixed phpdoc --- includes/template-functions.php | 92 +++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 33 deletions(-) diff --git a/includes/template-functions.php b/includes/template-functions.php index f4891e6..36912db 100644 --- a/includes/template-functions.php +++ b/includes/template-functions.php @@ -6,7 +6,6 @@ * @since Autonomie 1.0.0 */ function autonomie_content_nav( $nav_id ) { - global $wp_query; ?>