Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions themes/marianaerato/app/Hooks/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,45 @@ public function acf_include_fields(): void
'placeholder' => __('Compra este post por %s', APP_THEME_DOMAIN),
'new_lines' => '',
],
[
'key' => 'field_67aa4906412378',
'label' => __('Pages', APP_THEME_DOMAIN),
'name' => '',
'aria-label' => '',
'type' => 'tab',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => [
'width' => '',
'class' => '',
'id' => '',
],
'wpml_cf_preferences' => 1,
'placement' => 'left',
'endpoint' => 0,
'selected' => 0,
],
[
'key' => 'field_2938472939834',
'label' => __('Purchased page', APP_THEME_DOMAIN),
'name' => 'field_purchased_page',
'aria-label' => '',
'type' => 'post_object',
'post_type' => [
0 => 'page',
],
],
[
'key' => 'field_2938474395',
'label' => __('Exclusive content page', APP_THEME_DOMAIN),
'name' => 'field_exclusive_content_page',
'aria-label' => '',
'type' => 'post_object',
'post_type' => [
0 => 'page',
],
],
[
'key' => 'field_67aa490641f4b',
'label' => __('Blog', APP_THEME_DOMAIN),
Expand Down
6 changes: 2 additions & 4 deletions themes/marianaerato/app/Hooks/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ public function filter_private_galleries($query): void {
$private_tag = get_field('private_gallery_post_tag', 'option');
$bts_post_tag = get_field('bts_post_tag', 'option');

if (!$private_tag && $bts_post_tag) {
return;
}
$terms = array_filter(array($private_tag ?? false, $bts_post_tag ?? false));

$has_access = current_user_can('administrator');

if (!$has_access) {
if (!$has_access && count($terms) > 0) {
$tax_query = (array) $query->get('tax_query');
$tax_query[] = array(
'taxonomy' => 'post_tag',
Expand Down
4 changes: 2 additions & 2 deletions themes/marianaerato/src/scss/woocommerce/_pay-per-post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
&-purchased {
padding: 1rem;

.mm-purchased__list {
&__list {
display: grid;
grid-template-columns: 1fr;
gap: 1rem;
Expand All @@ -87,7 +87,7 @@
grid-template-columns: repeat(5, 1fr);
}

.mm-purchased__list__item {
&__item {
width: 100%;
height: 150px;
position: relative;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,81 @@
//Sort by last purchase date
//usort($purchased, fn($a, $b) => strcmp($a->last_purchase_date, $b->last_purchase_date));


// Purchased
use Elementor\Core\Files\CSS\Post;
use Elementor\Plugin;

$private_gallery_post_tag = get_field('private_gallery_post_tag', 'option');
$bts_post_tag = get_field('bts_post_tag', 'option');
$field_purchased_page = get_field('field_purchased_page', 'option', false);
$field_exclusive_content_page = get_field('field_exclusive_content_page', 'option', false);
$css_file = new Post($template_id);
$css_file->enqueue();
?>
<div class="mm-purchased">
<?php if (count($purchased) > 0):
$language = apply_filters('wpml_current_language', null);
$posts = array_values(array_filter($purchased, function (WP_Post $item) use ($language) {
$lang_info = apply_filters('wpml_post_language_details', null, $item->ID);
return get_post_type($item->ID) === 'post' &&
(array_key_exists('language_code', $lang_info ?? array()) && $language === $lang_info['language_code']);
}));
unset($item);
?>
<h3><?php _e('Purchased Content');?></h3>
<div class='mm-purchased__list'>
<?php foreach ($posts as $post):
$permalink = get_permalink($post->ID); ?>
<div class='mm-purchased__list__item <?php echo get_post_type($post->ID);?>'>
<?php $post_thumbnail = get_the_post_thumbnail_url($post->ID);?>
<div class='thumbnail' style='background-image: url(<?php echo $post_thumbnail?>);'>
<?php
if (count($purchased) > 0):
$page_id = get_the_ID();
$posts = array_filter($purchased, function ($post) use ($private_gallery_post_tag, $bts_post_tag, $page_id,
$field_purchased_page, $field_exclusive_content_page) {
$id = (is_int($post)) ? $post : $post->ID;
if($page_id === (int)$field_purchased_page) {
if ( has_term($private_gallery_post_tag, 'post_tag', $id) ||
has_term($bts_post_tag, 'post_tag', $id) ) {
return false;
}
} else if($page_id === (int)$field_exclusive_content_page) {
if ( !has_term($private_gallery_post_tag, 'post_tag', $id) &&
!has_term($bts_post_tag, 'post_tag', $id) ) {
return false;
}
}
return true;
});
$classname = $posts ? 'mm-purchased__list' : ''; ?>
<h3>
<?php _e(
sprintf('%s Content', $field_exclusive_content_page === $page_id ? 'Exclusive' : 'Purchased'),
APP_THEME_DOMAIN
); ?>
</h3>
<div class='<?php echo $classname;?>'>
<?php
if ($posts):
foreach ($posts as $post):
$permalink = get_permalink($post->ID); ?>
<div class='mm-purchased__list__item <?php
echo get_post_type($post->ID); ?>'>
<?php
$post_thumbnail = get_the_post_thumbnail_url($post->ID); ?>
<div class='thumbnail' style='background-image: url(<?php
echo $post_thumbnail ?>);'>
</div>
<div class='info'>
<a href="<?php echo $permalink; ?>">
<?php echo esc_html($post->post_title); ?>
<a href="<?php
echo $permalink; ?>">
<?php
echo esc_html($post->post_title); ?>
</a>
</div>
</div>
<?php
endforeach; ?>
endforeach;
else:
$product_template = get_field('pay_per_post_product_template', 'option');
if ($product_template && did_action('elementor/loaded')) {
echo Plugin::instance()->frontend->get_builder_content_for_display($product_template);
}?>
<?php endif; ?>
</div>
<?php else: ?>
<p><?php
/** @noinspection PhpVoidFunctionResultUsedInspection */
apply_filters(
'wc_pay_per_post_shortcode_purchased_no_posts',
_e('You have not purchased any protected posts.', 'wc_pay_per_post'),
);
?></p>
<?php
else:
$product_template = get_field('pay_per_post_product_template', 'option');
if ($product_template && did_action('elementor/loaded')) {
echo Plugin::instance()->frontend->get_builder_content_for_display($product_template);
}?>
<?php
endif;
?>
?>
</div>