fix: refactor php

This commit is contained in:
vnmedeiros 2021-04-27 14:19:14 -03:00
parent 408ac263eb
commit 2706a5693e
3 changed files with 48 additions and 57 deletions

View File

@ -28,9 +28,8 @@ function tainacan_blocksy_enqueue_scripts() {
// This should only happen if we have Tainacan plugin installed
if ( defined ('TAINACAN_VERSION') ) {
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
$post_type = get_post_type();
// $collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
// $post_type = get_post_type();
wp_enqueue_script( 'tainacan-blocksy-scripts', TAINACAN_BLOCKSY_PLUGIN_URL_PATH . '/js/scripts.js', array(), TAINACAN_BLOCKSY_VERSION, true );
}
}

View File

@ -6,27 +6,26 @@
* I renamed the usage from 'fn' to 'fnc' to avoid future conflicts
*/
if (! function_exists('blc_call_fnc')) {
function blc_call_fnc($args = [], ...$params) {
$args = wp_parse_args(
$args,
[
'fnc' => null,
function blc_call_fnc($args = [], ...$params) {
$args = wp_parse_args(
$args,
[
'fnc' => null,
// string | null | array
'default' => ''
]
);
// string | null | array
'default' => ''
]
);
if (! $args['fnc']) {
throw new Error('$fnc must be specified!');
}
if (! $args['fnc']) {
throw new Error('$fnc must be specified!');
}
if (! function_exists($args['fnc'])) {
return $args['default'];
}
if (! function_exists($args['fnc'])) {
return $args['default'];
}
return call_user_func($args['fnc'], ...$params);
}
return call_user_func($args['fnc'], ...$params);
}
}
/**

View File

@ -134,8 +134,6 @@ if ( !function_exists('blocksy_default_post_navigation') ) {
]
));
$home_page_url = get_home_url();
$post_slug = get_post_type() === 'post' ? __( 'Post', 'blocksy' ) : get_post_type_object( get_post_type() )->labels->singular_name;
$post_slug = '<span>' . $post_slug . '</span>';
@ -188,14 +186,14 @@ if ( !function_exists('blocksy_default_post_navigation') ) {
?>
<nav class="<?php echo esc_attr( $container_class ); ?>">
<?php if ($next_post) { ?>
<?php if ($next_post): ?>
<a href="<?php echo esc_url(get_permalink($next_post)); ?>" class="nav-item-prev">
<?php if ($has_thumb) { ?>
<?php if ($has_thumb): ?>
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $next_post_image_output;
?>
<?php } ?>
<?php endif; ?>
<div class="item-content">
<span class="item-label">
@ -208,19 +206,19 @@ if ( !function_exists('blocksy_default_post_navigation') ) {
?>
</span>
<?php if ( ! empty( $next_title ) ) { ?>
<?php if ( ! empty( $next_title ) ): ?>
<span class="item-title">
<?php echo wp_kses_post($next_title); ?>
</span>
<?php } ?>
<?php endif; ?>
</div>
</a>
<?php } else { ?>
<?php else: ?>
<div class="nav-item-prev"></div>
<?php } ?>
<?php endif; ?>
<?php if ( $previous_post ) { ?>
<?php if ( $previous_post ) : ?>
<a href="<?php echo esc_url( get_permalink( $previous_post ) ); ?>" class="nav-item-next">
<div class="item-content">
<span class="item-label">
@ -233,22 +231,20 @@ if ( !function_exists('blocksy_default_post_navigation') ) {
?>
</span>
<?php if ( ! empty( $previous_title ) ) { ?>
<?php if ( ! empty( $previous_title ) ) : ?>
<span class="item-title">
<?php echo wp_kses_post($previous_title); ?>
</span>
<?php } ?>
<?php endif; ?>
</div>
<?php if ($has_thumb) { ?>
<?php
echo $previous_post_image_output;
?>
<?php } ?>
<?php if ($has_thumb) : ?>
<?php echo $previous_post_image_output; ?>
<?php endif; ?>
</a>
<?php } else { ?>
<?php else : ?>
<div class="nav-item-next"></div>
<?php } ?>
<?php endif; ?>
</nav>
@ -296,23 +292,20 @@ if ( !function_exists('tainacan_blocksy_item_navigation') ) {
$next = $adjacent_links['next'];
}
?>
<?php if ($previous !== '' || $next !== '') : ?>
<nav class="<?php echo esc_attr( $container_class ); ?>">
<?php if ( $previous !== '' ) {
echo $previous;
} else { ?>
<div class="nav-item-prev"></div>
<?php } ?>
<?php if ( $next !== '' ) {
echo $next;
} else { ?>
<div class="nav-item-next"></div>
<?php } ?>
</nav>
<?php endif; ?>
<?
if ($previous !== '' || $next !== '') {
echo '<nav class="' . esc_attr( $container_class ) . '">';
if ( $previous !== '' ) {
echo $previous;
} else {
echo '<div class="nav-item-prev"></div>';
}
if ( $next !== '' ) {
echo $next;
} else {
echo '<div class="nav-item-next"></div>';
}
echo '</nav>';
};
}
}