From 2706a5693ee43768e023e80f0d3cb985c81da8af Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Tue, 27 Apr 2021 14:19:14 -0300 Subject: [PATCH] fix: refactor php --- tainacan-blocksy/inc/enqueues.php | 5 +-- tainacan-blocksy/inc/integration.php | 35 ++++++++------- tainacan-blocksy/inc/navigation.php | 65 +++++++++++++--------------- 3 files changed, 48 insertions(+), 57 deletions(-) diff --git a/tainacan-blocksy/inc/enqueues.php b/tainacan-blocksy/inc/enqueues.php index 887e903..395a500 100644 --- a/tainacan-blocksy/inc/enqueues.php +++ b/tainacan-blocksy/inc/enqueues.php @@ -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 ); } } diff --git a/tainacan-blocksy/inc/integration.php b/tainacan-blocksy/inc/integration.php index 11edffa..dfcb6ee 100644 --- a/tainacan-blocksy/inc/integration.php +++ b/tainacan-blocksy/inc/integration.php @@ -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); + } } /** diff --git a/tainacan-blocksy/inc/navigation.php b/tainacan-blocksy/inc/navigation.php index 11c75d0..7aaf551 100644 --- a/tainacan-blocksy/inc/navigation.php +++ b/tainacan-blocksy/inc/navigation.php @@ -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 = '' . $post_slug . ''; @@ -188,14 +186,14 @@ if ( !function_exists('blocksy_default_post_navigation') ) { ?> @@ -296,23 +292,20 @@ if ( !function_exists('tainacan_blocksy_item_navigation') ) { $next = $adjacent_links['next']; } - ?> - - - - '; + if ( $previous !== '' ) { + echo $previous; + } else { + echo ''; + } + if ( $next !== '' ) { + echo $next; + } else { + echo ''; + } + echo ''; + }; } }