Skip to content

Commit

Permalink
fix #1437
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Sep 20, 2024
1 parent 5f1089b commit 3b3c1e1
Show file tree
Hide file tree
Showing 26 changed files with 260 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
$custom_post_type . '-entries-display-item-author',
array(
'label' => __( 'Display the author for each item in the entries', 'snow-monkey' ),
'priority' => 142,
'priority' => 180,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
use Framework\Helper;

$custom_post_types = Helper::get_custom_post_types();

foreach ( $custom_post_types as $custom_post_type ) {
Framework::control(
'checkbox',
$custom_post_type . '-entries-display-item-date-icon',
array(
'label' => __( 'Display the modified date for each item in the entries', 'snow-monkey' ),
'priority' => 210,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
if ( 'post' === $archive_view ) {
return false;
}

$display_published_date = get_theme_mod( $custom_post_type . '-entries-display-item-published' );
$display_modified_date = get_theme_mod( $custom_post_type . '-entries-display-item-modified' );

return $display_published_date || $display_modified_date;
},
'sanitize_callback' => function ( $value ) use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
if ( 'post' === $archive_view ) {
return '';
}

return $value;
},
)
);
}

if ( ! is_customize_preview() ) {
return;
}

$panel = Framework::get_panel( 'design' );

foreach ( $custom_post_types as $custom_post_type ) {
$section = Framework::get_section( 'design-' . $custom_post_type . '-archive' );
$control = Framework::get_control( $custom_post_type . '-entries-display-item-date-icon' );
$control->join( $section )->join( $panel );
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
$custom_post_type . '-entries-display-item-excerpt',
array(
'label' => __( 'Display the excerpt for each item in the entries', 'snow-monkey' ),
'priority' => 145,
'priority' => 220,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
use Framework\Helper;

$custom_post_types = Helper::get_custom_post_types();

foreach ( $custom_post_types as $custom_post_type ) {
Framework::control(
'checkbox',
$custom_post_type . '-entries-display-item-modified',
array(
'label' => __( 'Display the modified date for each item in the entries', 'snow-monkey' ),
'priority' => 200,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
if ( 'post' === $archive_view ) {
return false;
}

return true;
},
'sanitize_callback' => function ( $value ) use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
if ( 'post' === $archive_view ) {
return '';
}

return $value;
},
)
);
}

if ( ! is_customize_preview() ) {
return;
}

$panel = Framework::get_panel( 'design' );

foreach ( $custom_post_types as $custom_post_type ) {
$section = Framework::get_section( 'design-' . $custom_post_type . '-archive' );
$control = Framework::get_control( $custom_post_type . '-entries-display-item-modified' );
$control->join( $section )->join( $panel );
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
$custom_post_type . '-entries-display-item-published',
array(
'label' => __( 'Display the published date for each item in the entries', 'snow-monkey' ),
'priority' => 143,
'priority' => 190,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$archive_view = get_theme_mod( $custom_post_type . '-archive-view' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 20.1.1
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -21,7 +21,7 @@
$custom_post_type . '-entries-gap',
array(
'label' => __( 'The gap between each item in the entries', 'snow-monkey' ),
'priority' => 141,
'priority' => 160,
'default' => '',
'choices' => array(
'' => __( 'Default', 'snow-monkey' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
$custom_post_type . '-entries-layout-sm-1col',
array(
'label' => __( 'Make the entries one column on mobile device', 'snow-monkey' ),
'priority' => 145,
'priority' => 170,
'default' => false,
'active_callback' => function () use ( $custom_post_type ) {
$is_multi_cols_pattern = in_array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
$custom_post_type . '-entries-layout',
array(
'label' => __( 'Entries layout', 'snow-monkey' ),
'priority' => 140,
'priority' => 150,
'default' => 'rich-media',
'choices' => array(
'rich-media' => __( 'Rich media', 'snow-monkey' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;
Expand All @@ -17,7 +17,7 @@
'archive-' . $custom_post_type . '-page-header-align',
array(
'label' => __( 'Page header alignment', 'snow-monkey' ),
'priority' => 131,
'priority' => 140,
'default' => 'center',
'choices' => Helper::page_header_align_choices(),
'active_callback' => function () use ( $custom_post_type ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
/**
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;

Framework::control(
'checkbox',
'post-entries-display-item-date-icon',
array(
'label' => __( 'Display the icons for each item in the entries publish date / modified date', 'snow-monkey' ),
'priority' => 150,
'default' => false,
'active_callback' => function () {
$display_published_date = get_theme_mod( 'post-entries-display-item-published' );
$display_modified_date = get_theme_mod( 'post-entries-display-item-modified' );

return $display_published_date || $display_modified_date;
},
)
);

if ( ! is_customize_preview() ) {
return;
}

$panel = Framework::get_panel( 'design' );
$section = Framework::get_section( 'entries' );
$control = Framework::get_control( 'post-entries-display-item-date-icon' );
$control->join( $section )->join( $panel );
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*
* renamed: app/customizer/design/sections/base-design/controls/entries-display-item-excerpt.php
*/
Expand All @@ -22,7 +22,7 @@
'post-entries-display-item-excerpt',
array(
'label' => __( 'Display the excerpt for each item in the entries', 'snow-monkey' ),
'priority' => 140,
'priority' => 160,
'default' => $default,
'active_callback' => function () {
$is_display_item_excerpt = in_array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
/**
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.2.0
*/

use Inc2734\WP_Customizer_Framework\Framework;

Framework::control(
'checkbox',
'post-entries-display-item-modified',
array(
'label' => __( 'Display the modified date for each item in the entries', 'snow-monkey' ),
'priority' => 140,
'default' => false,
)
);

if ( ! is_customize_preview() ) {
return;
}

$panel = Framework::get_panel( 'design' );
$section = Framework::get_section( 'entries' );
$control = Framework::get_control( 'post-entries-display-item-modified' );
$control->join( $section )->join( $panel );
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 25.4.6
* @version 27.2.0
*
* renamed: app/customizer/design/sections/base-design/controls/entries-layout-sm-1col.php
*/
Expand All @@ -15,7 +15,7 @@
'post-entries-layout-sm-1col',
array(
'label' => __( 'Make the entries one column on mobile device', 'snow-monkey' ),
'priority' => 150,
'priority' => 170,
'default' => false,
'active_callback' => function () {
$is_multi_cols_pattern = in_array( get_theme_mod( 'post-entries-layout' ), array( 'rich-media', 'panel' ), true );
Expand Down
7 changes: 6 additions & 1 deletion app/widget/snow-monkey-recent-posts/_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.1.0
* @version 27.2.0
*/

use Framework\Helper;
Expand Down Expand Up @@ -91,6 +91,10 @@
? $instance['display-item-meta'] && $instance['display-item-modified']
: false;

$display_item_date_icon = isset( $instance['display-item-date-icon'] )
? ( $display_item_published || $display_item_modified ) && $instance['display-item-date-icon']
: false;

$display_item_excerpt = isset( $instance['display-item-excerpt'] )
? $instance['display-item-excerpt']
: in_array( $instance['layout'], array( 'rich-media', 'simple', 'caroucel' ), true );
Expand All @@ -113,6 +117,7 @@
'_display_item_author' => $display_item_author,
'_display_item_published' => $display_item_published,
'_display_item_modified' => $display_item_modified,
'_display_item_date_icon' => $display_item_date_icon,
'_display_item_terms' => $instance['display-item-terms'],
'_display_item_excerpt' => $display_item_excerpt,
'_link_text' => $instance['link-text'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @package snow-monkey
* @author inc2734
* @license GPL-2.0+
* @version 27.1.0
* @version 27.2.0
*/

use Inc2734\WP_Awesome_Widgets\App\Contract\Widget as Abstract_Widget;
Expand Down Expand Up @@ -95,13 +95,18 @@ public function widget( $widget_args, $instance ) {
? $instance['display-item-meta'] && $instance['display-item-modified']
: false;

$display_item_date_icon = isset( $instance['display-item-date-icon'] )
? ( $display_item_published || $display_item_modified ) && $instance['display-item-date-icon']
: false;

$display_item_excerpt = isset( $instance['display-item-excerpt'] )
? $instance['display-item-excerpt']
: in_array( $instance['layout'], array( 'rich-media', 'simple', 'caroucel' ), true );

$instance['display-item-author'] = $display_item_author;
$instance['display-item-published'] = $display_item_published;
$instance['display-item-modified'] = $display_item_modified;
$instance['display-item-date-icon'] = $display_item_date_icon;
$instance['display-item-excerpt'] = $display_item_excerpt;

parent::widget( $widget_args, $instance );
Expand Down
Loading

0 comments on commit 3b3c1e1

Please sign in to comment.