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
16 changes: 15 additions & 1 deletion includes/blocks/class-convertkit-block-broadcasts.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function get_overview() {
// Shortcode: TinyMCE / QuickTags Modal Width and Height.
'modal' => array(
'width' => 650,
'height' => 405,
'height' => 455,
),

// Shortcode: Include a closing [/shortcode] tag when using TinyMCE or QuickTag Modals.
Expand Down Expand Up @@ -185,6 +185,10 @@ public function get_attributes() {
'type' => 'boolean',
'default' => $this->get_default_value( 'display_grid' ),
),
'display_order' => array(
'type' => 'string',
'default' => $this->get_default_value( 'display_order' ),
),
'date_format' => array(
'type' => 'string',
'default' => $this->get_default_value( 'date_format' ),
Expand Down Expand Up @@ -286,6 +290,14 @@ public function get_fields() {
'type' => 'toggle',
'description' => __( 'If enabled, displays broadcasts in a grid, instead of a list.', 'convertkit' ),
),
'display_order' => array(
'label' => __( 'Display order', 'convertkit' ),
'type' => 'select',
'values' => array(
'date-broadcast' => __( 'Date, Broadcast', 'convertkit' ),
'broadcast-date' => __( 'Broadcast, Date', 'convertkit' ),
),
),
'date_format' => array(
'label' => __( 'Date format', 'convertkit' ),
'type' => 'select',
Expand Down Expand Up @@ -373,6 +385,7 @@ public function get_panels() {
'label' => __( 'General', 'convertkit' ),
'fields' => array(
'display_grid',
'display_order',
'date_format',
'display_image',
'display_description',
Expand Down Expand Up @@ -412,6 +425,7 @@ public function get_default_values() {

return array(
'display_grid' => false,
'display_order' => 'date-broadcast',
'date_format' => 'F j, Y',
'display_image' => false,
'display_description' => false,
Expand Down
20 changes: 20 additions & 0 deletions resources/frontend/css/broadcasts.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
grid-template-columns: 150px auto;
grid-column-gap: 20px;
}
.convertkit-broadcasts[data-display-order="broadcast-date"] .convertkit-broadcasts-list li {
grid-template-areas:
"title date"
"text image";
grid-template-columns: auto 150px;
}
@media screen and (max-width: 478px) {
.convertkit-broadcasts-list li {
grid-template-areas:
Expand Down Expand Up @@ -59,6 +65,14 @@
grid-template-columns: none;
grid-row-gap: 10px;
}
.convertkit-broadcasts[data-display-grid="1"][data-display-order="broadcast-date"] .convertkit-broadcasts-list li {
grid-template-areas:
"image"
"title"
"text"
"date";
}

.convertkit-broadcasts[data-display-grid="1"] .convertkit-broadcasts-list li .convertkit-broadcast-read-more {
margin: 10px 0 0 0;
}
Expand All @@ -85,6 +99,12 @@
display: inline-block;
grid-area: date;
}
.convertkit-broadcasts[data-display-grid="1"][data-display-order="broadcast-date"] .convertkit-broadcasts-list li time {
text-align: left;
}
.convertkit-broadcasts[data-display-order="broadcast-date"] .convertkit-broadcasts-list li time {
text-align: right;
}
.convertkit-broadcasts-list li .convertkit-broadcast-title {
display: inline-block;
grid-area: title;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,48 @@ public function testBroadcastsBlockWithDisplayGridParameter(EndToEndTester $I)
);
}

/**
* Test the Broadcasts block's "Display order" parameter works.
*
* @since 2.8.3
*
* @param EndToEndTester $I Tester.
*/
public function testBroadcastsBlockWithDisplayOrderParameter(EndToEndTester $I)
{
// Setup Plugin and enable debug log.
$I->setupKitPlugin($I);
$I->setupKitPluginResources($I);

// Add a Page using the Gutenberg editor.
$I->addGutenbergPage(
$I,
title: 'Kit: Page: Broadcasts: Display Order'
);

// Add block to Page, setting the date format.
$I->addGutenbergBlock(
$I,
blockName: 'Kit Broadcasts',
blockProgrammaticName: 'convertkit-broadcasts',
blockConfiguration: [
'display_order' => [ 'select', 'broadcast-date' ],
]
);

// Publish and view the Page on the frontend site.
$I->publishAndViewGutenbergPage($I);

// Confirm that the block displays correctly with the expected number of Broadcasts in the grid format.
$I->seeBroadcastsOutput(
$I,
[
'number_posts' => $_ENV['CONVERTKIT_API_BROADCAST_COUNT'],
'see_display_order' => 'broadcast-date',
]
);
}

/**
* Test the Broadcasts block's date format parameter works.
*
Expand Down
Loading