-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: allow to use this theme an old php version #737
Conversation
inc/actions.php
Outdated
@@ -224,7 +224,8 @@ function dsi_eventi_filters( $query ) { | |||
*/ | |||
function dsi_schede_progetti_filters( WP_Query $query ) { | |||
|
|||
if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || (get_queried_object()?->taxonomy ?? null) == "tipologia-progetto") ) { | |||
if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || (get_queried_object() && isset(get_queried_object()->taxonomy) && get_queried_object()->taxonomy == "tipologia-progetto")) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Segnalo che WP ha anche una funzione is_tax(), che è più compatta e "idiomatica" e svolge già tutti i controlli su get_queried_object().
if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || (get_queried_object() && isset(get_queried_object()->taxonomy) && get_queried_object()->taxonomy == "tipologia-progetto")) ) { | |
if ( ! is_admin() && $query->is_main_query() && (is_post_type_archive("scheda_progetto") || is_tax("tipologia-progetto")) ) { |
[v. #691]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
qui si è modificata la linea precedente, in quanto la versione presente andava in conflitto con versioni di PHP precedenti all'8.0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sì, infatti: è l'operatore nullsafe ?->
, che non è supportato.
Ma di tutta la sequenza delle verifiche su get_queried_object->taxonomy
credo che se ne potrebbe fare a meno, perché quello è proprio il mestiere di is_tax()
.
@@ -641,7 +641,7 @@ protected function add_term_archive_items() { | |||
if ( false !== $taxonomy->rewrite ) { | |||
|
|||
// If 'with_front' is true, dd $wp_rewrite->front to the trail. | |||
if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) | |||
if ( array_key_exists('with_front', $taxonomy->rewrite) && $taxonomy->rewrite['with_front'] && $wp_rewrite->front ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Se deve essere controllata l'esistenza, perché non semplicemente ! empty()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ci potrebbero essere dei casi in cui with_font non era valorizzata, ecco perche questo check in più
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sì; intendevo che ! empty($taxonomy->rewrite['with_front'])
ha lo stesso effetto ed è più leggibile e conciso.
Co-authored-by: enrimk <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cosa intendi con versioni antecedenti alla 8, PHP?
7.3 e 7.4 |
@@ -1112,7 +1112,7 @@ protected function get_post_types_by_slug( $slug ) { | |||
|
|||
foreach ( $post_types as $type ) { | |||
|
|||
if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) ) | |||
if ( $slug === $type->has_archive || ( true === $type->has_archive && is_array($type->rewrite) && isset($type->rewrite['slug']) && $slug === $type->rewrite['slug'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non è un'eventualità piuttosto remota?
Cioè, mi pare che rewrite['slug'] qui possa risultare non definito solo nel caso di un post_type con has_archive === true
e rewrite === false
contemporaneamente (con archivio, ma senza permalink). È così? È un caso che si verifica nell'app?
Co-authored-by: enrimk <[email protected]>
Descrizione
le modifiche fatte consentono di far funzionare il tema anche su versioni antecedenti alla 8.
Modificate alcune funzioni
Aggiunta una funziona prima che sia deprecata l'originale