2021-02-23 02:09:46 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds Tainacan repository and term items list to settings on customizer.
|
|
|
|
*/
|
2021-05-28 01:51:51 +00:00
|
|
|
|
2021-04-14 17:40:23 +00:00
|
|
|
if ( !function_exists('tainacan_blocksy_add_repository_and_terms_items_options_panel') ) {
|
|
|
|
function tainacan_blocksy_add_repository_and_terms_items_options_panel($options) {
|
2021-02-23 02:09:46 +00:00
|
|
|
|
2021-03-07 21:43:57 +00:00
|
|
|
$options['tainacan_repository_items_list'] = blc_call_fnc(
|
2021-02-23 02:09:46 +00:00
|
|
|
[
|
2021-03-07 21:43:57 +00:00
|
|
|
'fnc' => 'blocksy_get_options',
|
2021-02-23 02:09:46 +00:00
|
|
|
'default' => 'array'
|
|
|
|
],
|
2021-04-14 17:40:23 +00:00
|
|
|
TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archives/tainacan-repository-items.php',
|
2021-02-23 02:09:46 +00:00
|
|
|
[], false
|
|
|
|
);
|
|
|
|
|
2021-03-07 21:43:57 +00:00
|
|
|
$options['tainacan_terms_items_list'] = blc_call_fnc(
|
2021-02-23 02:09:46 +00:00
|
|
|
[
|
2021-03-07 21:43:57 +00:00
|
|
|
'fnc' => 'blocksy_get_options',
|
2021-02-23 02:09:46 +00:00
|
|
|
'default' => 'array'
|
|
|
|
],
|
2021-04-14 17:40:23 +00:00
|
|
|
TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/archives/tainacan-terms-items.php',
|
2021-02-23 02:09:46 +00:00
|
|
|
[], false
|
|
|
|
);
|
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|
2021-05-20 14:59:18 +00:00
|
|
|
add_filter( 'blocksy_extensions_customizer_options', 'tainacan_blocksy_add_repository_and_terms_items_options_panel' );
|
|
|
|
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds extra customizer options to items single page template
|
|
|
|
*/
|
2021-04-14 17:40:23 +00:00
|
|
|
if ( !function_exists('tainacan_blocksy_custom_post_types_single_options') ) {
|
|
|
|
function tainacan_blocksy_custom_post_types_single_options( $options, $post_type, $post_type_object ) {
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
// This should only happen if we have Tainacan plugin installed
|
|
|
|
if ( defined ('TAINACAN_VERSION') ) {
|
|
|
|
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
|
|
|
|
|
|
|
|
if ( in_array($post_type, $collections_post_types) ) {
|
|
|
|
|
|
|
|
// Change the section title in the customizer
|
|
|
|
$options['title'] = sprintf(
|
2021-04-14 17:40:23 +00:00
|
|
|
__('Item from %s', 'tainacan-blocksy'),
|
2021-02-23 02:09:46 +00:00
|
|
|
$post_type_object->labels->name
|
|
|
|
);
|
|
|
|
|
|
|
|
// Extra options to the single item template
|
2021-04-14 17:40:23 +00:00
|
|
|
$item_extra_options = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/posts/tainacan-item-single.php', [
|
2021-02-23 02:09:46 +00:00
|
|
|
'post_type' => $post_type_object,
|
|
|
|
'is_general_cpt' => true
|
|
|
|
], false);
|
|
|
|
|
|
|
|
if ( is_array($item_extra_options) ) {
|
|
|
|
array_splice(
|
|
|
|
$options['options'][$post_type . '_single_section_options']['inner-options'][0],
|
|
|
|
1,
|
|
|
|
0,
|
|
|
|
$item_extra_options
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 17:40:23 +00:00
|
|
|
add_filter( 'blocksy:custom_post_types:single-options', 'tainacan_blocksy_custom_post_types_single_options', 10, 3 );
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds extra customizer options to items single page template
|
|
|
|
*/
|
2021-04-14 17:40:23 +00:00
|
|
|
if ( !function_exists('tainacan_blocksy_custom_post_types_archive_options') ) {
|
|
|
|
function tainacan_blocksy_custom_post_types_archive_options( $options, $post_type, $post_type_object ) {
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
// This should only happen if we have Tainacan plugin installed
|
|
|
|
if ( defined ('TAINACAN_VERSION') ) {
|
|
|
|
$collections_post_types = \Tainacan\Repositories\Repository::get_collections_db_identifiers();
|
|
|
|
|
|
|
|
if ( in_array($post_type, $collections_post_types) ) {
|
|
|
|
|
|
|
|
// Change the section title in the customizer
|
|
|
|
$options['title'] = sprintf(
|
2021-04-14 17:40:23 +00:00
|
|
|
__('Items list from %s', 'tainacan-blocksy'),
|
2021-02-23 02:09:46 +00:00
|
|
|
$post_type_object->labels->name
|
|
|
|
);
|
|
|
|
|
|
|
|
// Extra options to the archive items list
|
2021-04-14 17:40:23 +00:00
|
|
|
$items_extra_options = blocksy_get_options(TAINACAN_BLOCKSY_PLUGIN_DIR_PATH . '/inc/options/posts/tainacan-item-archive.php', [
|
2021-02-23 02:09:46 +00:00
|
|
|
'prefix' => $post_type_object->name,
|
|
|
|
'is_general_cpt' => true
|
|
|
|
], false);
|
|
|
|
|
|
|
|
if ( is_array($items_extra_options) ) {
|
|
|
|
$options['options'][$post_type . '_section_options']['inner-options'] = $items_extra_options;
|
|
|
|
}
|
2021-07-13 22:28:10 +00:00
|
|
|
|
|
|
|
// We also do some changes on the Collections
|
|
|
|
} else if ( $post_type == 'tainacan-collection' ) {
|
|
|
|
|
|
|
|
// Change the section title in the customizer
|
|
|
|
$options['title'] = __('Tainacan collections list', 'tainacan-blocksy');
|
|
|
|
|
|
|
|
return $options;
|
|
|
|
|
|
|
|
// And taxonomies
|
|
|
|
} else if ( $post_type == 'tainacan-taxonomy' ) {
|
|
|
|
|
|
|
|
// Change the section title in the customizer
|
|
|
|
$options['title'] = __('Tainacan taxonomies list', 'tainacan-blocksy');
|
|
|
|
|
|
|
|
return $options;
|
2021-02-23 02:09:46 +00:00
|
|
|
}
|
|
|
|
}
|
2021-05-28 01:51:51 +00:00
|
|
|
|
2021-02-23 02:09:46 +00:00
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 17:40:23 +00:00
|
|
|
add_filter( 'blocksy:custom_post_types:archive-options', 'tainacan_blocksy_custom_post_types_archive_options', 10, 3 );
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes tainacan metadatum and filters from the custom metadata options in the customizer controller.
|
|
|
|
*/
|
2021-04-14 17:40:23 +00:00
|
|
|
if ( !function_exists('tainacan_blocksy_custom_post_types_supported_list') ) {
|
|
|
|
function tainacan_blocksy_custom_post_types_supported_list( $potential_post_types ) {
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
// This should only happen if we have Tainacan plugin installed
|
|
|
|
if ( defined ('TAINACAN_VERSION') ) {
|
|
|
|
return array_filter( $potential_post_types, function($post_type) {
|
|
|
|
return !in_array($post_type, [ 'tainacan-metadatum', 'tainacan-filter' ]);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return $potential_post_types;
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 17:40:23 +00:00
|
|
|
add_filter( 'blocksy:custom_post_types:supported_list', 'tainacan_blocksy_custom_post_types_supported_list', 10 );
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
/**
|
2021-11-20 15:54:06 +00:00
|
|
|
* Renders the single item page with a custom template that will use most of Blocksy features
|
2021-02-23 02:09:46 +00:00
|
|
|
*/
|
2021-04-14 17:40:23 +00:00
|
|
|
if ( !function_exists('tainacan_blocksy_the_content_for_items') ) {
|
|
|
|
function tainacan_blocksy_the_content_for_items( $content ) {
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
// 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();
|
|
|
|
|
|
|
|
// Check if we're inside the main loop in a single Post.
|
2021-04-29 20:13:03 +00:00
|
|
|
if ( in_array($post_type, $collections_post_types) && is_singular() && in_the_loop() && is_main_query() ) {
|
2021-04-14 17:40:23 +00:00
|
|
|
return tainacan_blocksy_get_template_part( 'tainacan/item-single-page' );
|
2021-02-23 02:09:46 +00:00
|
|
|
}
|
2021-06-25 01:08:34 +00:00
|
|
|
}
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
}
|
2021-04-14 17:40:23 +00:00
|
|
|
add_filter( 'the_content', 'tainacan_blocksy_the_content_for_items', 11);
|
2021-02-23 02:09:46 +00:00
|
|
|
|
|
|
|
?>
|