Sets plugin as default mode. Fixes excerpt loading on attachments.

This commit is contained in:
mateuswetah 2021-04-02 12:42:39 -03:00
parent c0870b996b
commit 7bcf64bdc2
8 changed files with 38 additions and 39 deletions

View File

@ -2,48 +2,46 @@
## What is this about?
This project contains the source code necessary for integrating Tainacan pages to Blocksy theme. It allows you to choose betweent two strategies: either having a child theme or a plugin that does the job.
This project contains the source code necessary for integrating Tainacan pages to Blocksy theme. It allows you to choose between two strategies: either having a child theme or a plugin that does the job.
### But wait, what is Tainacan?
Tainacan is an open-source, flexible and powerful tool for creating digital repositories on WordPress. It allows you to create and manage collections with a variety of metadata types, rich search and filtering of items and much more. You can learn about it in our official website:
Tainacan is an open-source, flexible and powerful tool for creating digital repositories on WordPress. It allows you to create and manage collections with a variety of metadata types, rich search and filtering of items and much more. You can learn about it on our official website:
https://tainacan.org
### And how about Blocksy?
Blocksy is one of the many WordPress themes available outhere. But it is not just another theme, it offers rich controls to customize your site with so many features that you won't miss a page builder. This projects uses their customizer controls to offer options to set different layout settings to Tainacan pages such as the collection itens list and the items page.
Blocksy is one of the many WordPress themes available out there. But it is not just another theme, it offers rich controls to customize your site with so many features that you won't miss a page builder:
## After all, a Child Theme or a Plugin?
https://creativethemes.com/blocksy/
While the most traditional strategy for creating themes compatible to Tainacan is to add some pages to the theme directly or using a child theme, this project offers another option, which is to use it as plugin. The reason is clear: developers might prefer to create child themes of Blocksy by their own, without creating forks of this project. It is althougt a not very canonical approach, so you might be more confortable using it as child theme.
This project uses their customizer controls to offer options for setting different layouts to Tainacan pages such as the collection items list and the items page.
## After all, a Plugin or a Child Theme?
By default, it is a plugin. While the most traditional strategy for creating themes compatible to Tainacan is to add some pages to the theme directly or using a child theme, this project goes the other way, which is to use it as plugin. The reason is clear: developers might prefer to create child themes of Blocksy by their own, without creating forks of this project. It is although a not-very-canonical approach, so you might be more comfortable using it as child theme.
## How to use it?
### As a plugin:
Just move all files to a folder inside WordPress plugins folder (`wp-content/plugins`);
Download and activate the Blocksy. And Tainacan, of course;
Then you just have to enable Blocksy theme and have fun ;)
### As a child theme:
Just go to `functions.php` file and set the constant as you prefer:
```php
const BLOCKSY_TAINACAN_IS_PLUGIN = false;
const BLOCKSY_TAINACAN_IS_CHILD_THEME = true;
```
Then move all files to a folder inside WordPress themes folder (`wp-content/themes`);
Donwload the parent theme Blocksy;
Download the Blocksy parent theme. And Tainacan, of course;
Go ahead, enable the child theme and have fun ;)
### As a plugin:
Just go to `functions.php` file and set the constant as you prefer:
```php
const BLOCKSY_TAINACAN_IS_PLUGIN = true;
```
Then move all files to a folder inside WordPress plugins folder (`wp-content/plugins`);
Download and activate the theme Blocksy;
Then you just have to enable Blocksy theme and have fun ;)

View File

@ -16,7 +16,7 @@ if (! defined('WP_DEBUG') ) {
/** Theme/plugin version */
const BLOCKSY_TAINACAN_VERSION = '0.1.0';
const BLOCKSY_TAINACAN_IS_PLUGIN = false;
const BLOCKSY_TAINACAN_IS_CHILD_THEME = false;
/* Tools to define our next constants */
require 'utils.php';
@ -30,14 +30,14 @@ define('BLOCKSY_TAINACAN_PLUGIN_DIR_PATH', $plugin_root_dir);
$blocksy_tainacan_is_blocksy_activated = blocksy_tainacan_is_blocksy_activated();
define('BLOCKSY_TAINACAN_IS_BLOCKSY_ACTIVATED', $blocksy_tainacan_is_blocksy_activated);
/* This should only be used if in the child theme or if is a plugin and blocksy theme is installed */
if (!BLOCKSY_TAINACAN_IS_PLUGIN || (BLOCKSY_TAINACAN_IS_BLOCKSY_ACTIVATED && BLOCKSY_TAINACAN_IS_PLUGIN) ) {
/* This should only be used if we're in the child theme or if is a plugin and blocksy theme is installed */
if ( BLOCKSY_TAINACAN_IS_CHILD_THEME || ( BLOCKSY_TAINACAN_IS_BLOCKSY_ACTIVATED && !BLOCKSY_TAINACAN_IS_CHILD_THEME ) ) {
/* Basic styles and script enqueues */
require BLOCKSY_TAINACAN_PLUGIN_DIR_PATH . '/inc/enqueues.php';
/* Template redirection necessary only if in a plugin */
if ( BLOCKSY_TAINACAN_IS_PLUGIN ) {
if ( !BLOCKSY_TAINACAN_IS_CHILD_THEME ) {
require BLOCKSY_TAINACAN_PLUGIN_DIR_PATH . '/inc/plugin.php';
}

View File

@ -7,13 +7,13 @@
function blocksy_tainacan_enqueue_scripts() {
// First, we enqueue parent theme styles
if ( !BLOCKSY_TAINACAN_IS_PLUGIN )
if ( BLOCKSY_TAINACAN_IS_CHILD_THEME )
wp_enqueue_style( 'blocksy-parent-style', get_template_directory_uri() . '/style.css' );
// Then, this child theme styles
wp_enqueue_style( 'tainacan-blocksy-style',
BLOCKSY_TAINACAN_PLUGIN_URL_PATH . '/style.min.css',
BLOCKSY_TAINACAN_IS_PLUGIN ? array() : array( 'blocksy-parent-style' ),
!BLOCKSY_TAINACAN_IS_CHILD_THEME ? array() : array( 'blocksy-parent-style' ),
BLOCKSY_TAINACAN_VERSION
);

View File

@ -321,7 +321,7 @@ if ( !function_exists('blocksy_tainacan_item_navigation') ) {
* has already declared the function in the plugin lifecycle, somehting that
* is not necessary if on a child theme.
*/
if (BLOCKSY_TAINACAN_IS_PLUGIN) {
if (!BLOCKSY_TAINACAN_IS_CHILD_THEME) {
function blocksy_tainacan_after_theme_setup() {
/**

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -11,8 +11,8 @@
$hide_download_button = get_theme_mod( $prefix . '_hide_download_button', 'no' ) == 'yes';
global $post;
if ( function_exists('tainacan_the_media_component') && (!empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) ) {
if ( function_exists('tainacan_the_media_component') && ( empty( $attachments ) || ( $is_gallery_mode && tainacan_has_document() ) ) ) {
?>
<section class="tainacan-item-section tainacan-item-section--<?php echo ((!$is_gallery_mode ? 'attachments' : 'gallery')) ?>">
<?php if ( (get_theme_mod($prefix . '_display_section_labels', 'yes') == 'yes') && (!$is_gallery_mode) && get_theme_mod($prefix . '_section_attachments_label', __( 'Attachments', 'blocksy-tainacan' )) != '' ) : ?>
@ -40,9 +40,10 @@
$class_slide_metadata .= ' hide-description';
if ($hide_file_caption_main)
$class_slide_metadata .= ' hide-caption';
if ( tainacan_has_document() ) {
$is_document_type_attachment = tainacan_get_the_document_type() === 'attachment';
$media_items_main[] =
tainacan_get_the_media_component_slide(array(
'after_slide_metadata' => (( !$hide_download_button && tainacan_the_item_document_download_link() != '' ) ?
@ -52,7 +53,7 @@
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? get_the_excerpt(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => $class_slide_metadata
));
@ -87,7 +88,7 @@
'media_content_full' => $is_document_type_attachment ? tainacan_get_the_document(0, 'full') : ('<div class="attachment-without-image">' . tainacan_get_the_document(0, 'full') . '</div>'),
'media_title' => $is_document_type_attachment ? get_the_title(tainacan_get_the_document_raw()) : '',
'media_description' => $is_document_type_attachment ? get_the_content(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? get_the_excerpt(tainacan_get_the_document_raw()) : '',
'media_caption' => $is_document_type_attachment ? wp_get_attachment_caption(tainacan_get_the_document_raw()) : '',
'media_type' => tainacan_get_the_document_type(),
'class_slide_metadata' => 'hide-caption hide-description ' . ( $hide_file_name ? 'hide-name' : '' )
));

View File

@ -25,7 +25,7 @@ if ( !function_exists('blocksy_tainacan_is_blocksy_activated') ) {
*/
if ( !function_exists('blocksy_tainacan_get_plugin_dir_url') ) {
function blocksy_tainacan_get_plugin_dir_url() {
return BLOCKSY_TAINACAN_IS_PLUGIN ? plugin_dir_url(__FILE__) : get_stylesheet_directory_uri();
return !BLOCKSY_TAINACAN_IS_CHILD_THEME ? plugin_dir_url(__FILE__) : get_stylesheet_directory_uri();
}
}
@ -34,7 +34,7 @@ if ( !function_exists('blocksy_tainacan_get_plugin_dir_url') ) {
*/
if ( !function_exists('blocksy_tainacan_get_plugin_dir_path') ) {
function blocksy_tainacan_get_plugin_dir_path() {
return BLOCKSY_TAINACAN_IS_PLUGIN ? plugin_dir_path(__FILE__) : get_stylesheet_directory();
return !BLOCKSY_TAINACAN_IS_CHILD_THEME ? plugin_dir_path(__FILE__) : get_stylesheet_directory();
}
}
@ -43,6 +43,6 @@ if ( !function_exists('blocksy_tainacan_get_plugin_dir_path') ) {
*/
if ( !function_exists('blocksy_tainacan_get_template_part') ) {
function blocksy_tainacan_get_template_part($path) {
return BLOCKSY_TAINACAN_IS_PLUGIN ? include(BLOCKSY_TAINACAN_PLUGIN_DIR_PATH . '/' . $path . '.php') : get_template_part($path);
return !BLOCKSY_TAINACAN_IS_CHILD_THEME ? include(BLOCKSY_TAINACAN_PLUGIN_DIR_PATH . '/' . $path . '.php') : get_template_part($path);
}
}