Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Marketing Notices for Black Friday. #2225

Merged
merged 58 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
834bc5c
Remove Marketing and Promo folder from images
bordoni Oct 10, 2024
e163c74
Fully deprecate the Marketing Class
bordoni Oct 10, 2024
bb50481
Update Strauss version
bordoni Oct 11, 2024
2ea5987
Fix one problem with changelogger
bordoni Oct 11, 2024
798dbd8
Clean bad files
bordoni Oct 11, 2024
6ffbb00
Actually remove most of these classes. They are not being used by def…
bordoni Oct 11, 2024
2955ac0
Move some classes and remove unused notice templates
bordoni Oct 11, 2024
2790e31
Simplify and prevent warning from removed methods
bordoni Oct 11, 2024
3800071
Resolve all the edge-cases related to the types of banner and include…
bordoni Oct 11, 2024
b8c45b6
Fix some code sniffer problems
bordoni Oct 11, 2024
08efbc1
Avoid spaces...
bordoni Oct 11, 2024
2740084
Docblock
bordoni Oct 11, 2024
4201ac5
Tabs, PHPStorm unlearned how to auto convert now...
bordoni Oct 11, 2024
21c009d
Tabs, PHPStorm unlearned how to auto convert now...
bordoni Oct 11, 2024
11ea932
Fix the should display to ensure we have the correct filters/constant…
bordoni Oct 11, 2024
65a55c2
Ignore one more docblock print
bordoni Oct 11, 2024
55d63fb
Fix some translations Code Sniff
bordoni Oct 11, 2024
a4b1b4d
Fix some translations Code Sniff
bordoni Oct 11, 2024
44fe9dd
Fix some translations Code Sniff
bordoni Oct 11, 2024
0cc425c
Correct the docblock for a self return
bordoni Oct 11, 2024
d76111e
Updated the code to match some of the docblock code standards
bordoni Oct 12, 2024
557415b
Fix a couple more things Jeremy mentioned
bordoni Oct 12, 2024
fdab5a4
Fix spacing
bordoni Oct 12, 2024
b239fee
Avoid fully qualified name
bordoni Oct 12, 2024
8235425
Weird usage of spaces
bordoni Oct 12, 2024
5ba54c4
Remove unwanted tests.
bordoni Oct 12, 2024
37ab593
Remove associated snapshots
bordoni Oct 12, 2024
3cfd0ec
Remove more marketing tests
bordoni Oct 12, 2024
b676cb2
Clean the Script to avoid problems with bad GHA php versions
bordoni Oct 14, 2024
6a053ab
Test ZIP.
bordoni Oct 14, 2024
6c5b0b7
put back the strauss scripts
bordoni Oct 14, 2024
3ca07a3
Apply suggestions from code review
bordoni Oct 14, 2024
db9d4ee
Bad replacement
bordoni Oct 14, 2024
6612db7
Merge branch 'fix/marketing-notices' of github.com:the-events-calenda…
bordoni Oct 14, 2024
86a55bd
Include conditional content JS
bordoni Oct 14, 2024
2d84873
Correct usage of Tribe__Main
bordoni Oct 14, 2024
fae268d
Fix the loading time for assets
bordoni Oct 14, 2024
85b2add
Include a Dismissable Trait for conditional content, allowing certain…
bordoni Oct 15, 2024
fdbda1a
Update src/Common/Admin/Entities/Link.php
bordoni Oct 15, 2024
216664c
Update src/Common/Admin/Settings_Sidebar_Section.php
bordoni Oct 15, 2024
951bf72
Modify methods based on feedback from Jeremy
bordoni Oct 15, 2024
5bbc440
Fix a couple alignment problems
bordoni Oct 15, 2024
13c2d9d
Clean up the Link entity
bordoni Oct 15, 2024
afcde72
Clean up the Link entity
bordoni Oct 15, 2024
189ce37
Modify dates and remove forced conditional
bordoni Oct 15, 2024
6cc1963
Resolve problems with Code Standards
bordoni Oct 15, 2024
5c9c8ce
Improve translation usage
bordoni Oct 15, 2024
ce54952
Spacing
bordoni Oct 15, 2024
95d8431
Use slug on the check
bordoni Oct 15, 2024
4fb9615
Apply suggestions from code review
bordoni Oct 15, 2024
e6182b4
Re-include deprecated classes properly.
bordoni Oct 15, 2024
c498e72
Re-include deprecated classes properly.
bordoni Oct 15, 2024
110cc02
Apply suggestions from code review
bordoni Oct 15, 2024
7c6cf49
Last few changes
bordoni Oct 15, 2024
3edd0e2
Last few changes from code reviews
bordoni Oct 15, 2024
027f5c0
Remove slug to avoid complications
bordoni Oct 15, 2024
95d8f9a
Fixes Mobile sidebar for settings and resolve last conflicts
bordoni Oct 15, 2024
65c5f20
Remove the always displayh
bordoni Oct 15, 2024
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
1 change: 0 additions & 1 deletion .phpstorm.meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
'callback' => \Tribe__Utils__Callback::class,
'pue.notices' => \Tribe__PUE__Notices::class,
'admin.notice.php.version' => \Tribe__Admin__Notice__Php_Version::class,
'admin.notice.marketing' => \Tribe__Admin__Notice__Marketing::class,

// Custom alias with tribe namespace.
'tooltip.view' => \Tribe\Tooltip\View::class,
Expand Down
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@

### [5.1.2] 2023-06-22

* Fix - Lock our container usage(s) to the new Service_Provider contract in tribe-common. This prevents conflicts and potential fatals with other plugins that use a di52 container.
* Fix - Lock our container usage(s) to the new Controller contract in tribe-common. This prevents conflicts and potential fatals with other plugins that use a di52 container.

### [5.1.1.2] 2023-06-21

Expand Down
4 changes: 4 additions & 0 deletions changelog/deprecate-marketing-classes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be another of these? This only covers the deprecations.

Type: deprecated

Removed deprecated classes: `Tribe\Admin\Notice\Marketing`, `Tribe\Admin\Notice\Marketing\Black_Friday`, `Tribe\Admin\Notice\Marketing\End_Of_Year_Sale`, `Tribe\Admin\Notice\Marketing\Stellar_Sale`, `Tribe\Admin\Notice\Conditional_Content\`, `Tribe\Admin\Notice\Marketing\Black_Friday`, `Tribe\Admin\Notice\Marketing\End_Of_Year_Sale`, `Tribe\Admin\Notice\Marketing\Stellar_Sale`
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,13 @@
}
},
"scripts": {
"clean-strauss-static-function-autoload": "@php -d display_errors=on -r '$files = [\"vendor/composer/autoload_files.php\", \"vendor/composer/autoload_static.php\"]; $search = \"symfony/deprecation-contracts/function.php\"; foreach ($files as $file) { file_put_contents($file, implode(\"\", array_filter(file($file), fn($line) => strpos($line, $search) === false))); }'",
"strauss": [
"test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/download/0.19.2/strauss.phar",
"test -f ./bin/strauss.phar || curl -o bin/strauss.phar -L -C - https://github.com/BrianHenryIE/strauss/releases/download/0.19.4/strauss.phar",
"vendor/stellarwp/installer/bin/set-domain domain=tribe-common",
"@php bin/strauss.phar"
"@php -d display_errors=on bin/strauss.phar",
"@composer dump-autoload",
"@clean-strauss-static-function-autoload"
],
"post-install-cmd": [
"@strauss"
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tribe-common",
"version": "6.1.0",
"version": "6.2.0",
Camwyn marked this conversation as resolved.
Show resolved Hide resolved
"repository": "[email protected]:the-events-calendar/tribe-common.git",
"_resourcepath": "src/resources",
"_domainPath": "lang",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@

= [5.1.2] 2023-06-22 =

* Fix - Lock our container usage(s) to the new Service_Provider contract in tribe-common. This prevents conflicts and potential fatals with other plugins that use a di52 container.
* Fix - Lock our container usage(s) to the new Controller contract in tribe-common. This prevents conflicts and potential fatals with other plugins that use a di52 container.
bordoni marked this conversation as resolved.
Show resolved Hide resolved

= [5.1.1.2] 2023-06-21 =

Expand Down
177 changes: 177 additions & 0 deletions src/Common/Admin/Conditional_Content/Black_Friday.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
<?php
bordoni marked this conversation as resolved.
Show resolved Hide resolved
namespace TEC\Common\Admin\Conditional_Content;

use TEC\Common\Admin\Settings_Sidebar;
use Tribe\Utils\Element_Attributes as Attributes;
use TEC\Common\Admin\Entities\Link;
use TEC\Common\Admin\Entities\Image;
use TEC\Common\Admin\Settings_Section;
use Tribe\Utils\Date_I18n;

/**
* Set up for Black Friday promo.
*
* @since TBD
*/
class Black_Friday extends Datetime_Conditional_Abstract {
/**
* @inheritdoc
*/
bordoni marked this conversation as resolved.
Show resolved Hide resolved
protected string $slug = 'black_friday';

/**
* @inheritdoc
*/
bordoni marked this conversation as resolved.
Show resolved Hide resolved
protected string $start_date = 'fourth Thursday of November';

/**
* @inheritdoc
*/
bordoni marked this conversation as resolved.
Show resolved Hide resolved
protected string $end_date = 'November 30th';

/**
* @inheritdoc
*/
public function hook(): void {
add_action( 'tec_settings_sidebar_start', [ $this, 'include_sidebar_section' ] );
add_action( 'tribe_settings_below_tabs', [ $this, 'include_tickets_settings_section' ] );
}

/**
* @inheritdoc
*/
protected function get_start_time(): ?Date_I18n {
$date = parent::get_start_time();
if ( null === $date ) {
return null;
}

$date = $date->modify( '-3 days' );

return $date;
}

protected function should_display(): bool {
return true;
}
bordoni marked this conversation as resolved.
Show resolved Hide resolved

/**
* Gets the content for the Black Friday promo.
*
* @since TBD
*
* @return string
*/
protected function get_wide_banner_html(): string {
$template_args = [
'image_src' => tribe_resource_url( 'images/hero-section-wide.jpg', false, null, \Tribe__Main::instance() ),
'link' => 'https://evnt.is/tec-bf-2024',
];

return $this->get_template()->template( 'black-friday', $template_args, false );
}

/**
* Render the wide banner HTML.
*
* @since TBD
*
* @return void
*/
public function render_wide_banner_html(): void {
if ( ! $this->should_display() ) {
return;
}
echo $this->get_wide_banner_html();
}

/**
* Gets the content for the Black Friday promo.
*
* @since TBD
*
* @return string
*/
protected function get_narrow_banner_html(): string {
$template_args = [
'image_src' => tribe_resource_url( 'images/hero-section-narrow.jpg', false, null, \Tribe__Main::instance() ),
'link' => 'https://evnt.is/tec-bf-2024',
'is_narrow' => true,
];

return $this->get_template()->template( 'black-friday', $template_args, false );
}

/**
* Render the narrow banner HTML.
*
* @since TBD
*
* @return void
*/
public function render_narrow_banner_html(): void {
if ( ! $this->should_display() ) {
return;
}
echo $this->get_narrow_banner_html();
}

public function include_tickets_settings_section(): void {
if ( ! $this->should_display() ) {
return;
}

$page = tribe_get_request_var( 'page' );
if ( $page !== 'tec-tickets-settings' ) {
return;
}

$this->render_narrow_banner_html();
}

/**
* Replace the opening markup for the general settings info box.
*
* @since TBD
*
* @param Settings_Sidebar $sidebar Sidebar instance.
*
* @return void
*/
public function include_sidebar_section( $sidebar ): void {
// Check if the content should currently be displayed.
if ( ! $this->should_display() ) {
return;
}

$year = date_i18n( 'Y' );

$sidebar->prepend_section(
( new Settings_Section() )
->add_elements(
[
new Link(
'https://evnt.is/tec-bf-2024',
new Image(
tribe_resource_url( 'images/hero-section-settings-sidebar.jpg', false, null, \Tribe__Main::instance() ),
new Attributes(
[
'alt' => sprintf( esc_attr_x( '%1$s Black Friday Sale for The Events Calendar plugins, add-ons and bundles.', 'Alt text for the Black Friday Ad', 'tribe-common' ), $year ),
'role' => 'presentation',
]
)
),
null,
new Attributes(
[
'title' => sprintf( esc_attr_x( '%1$s Black Friday Sale for The Events Calendar plugins, add-ons and bundles.', 'Alt text for the Black Friday Ad', 'tribe-common' ), $year ),
'target' => '_blank',
'rel' => 'noopener nofollow',
]
)
),
]
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,31 @@
* @package Tribe\Admin\Conditional_Content;
*/

namespace Tribe\Admin\Conditional_Content;
namespace TEC\Common\Admin\Conditional_Content;

use TEC\Common\Contracts\Service_Provider as Provider_Contract;

/**
* Conditional Content Provider.
* Conditional Content Controller.
*
* @since 4.14.7
* @since TBD
*/
class Service_Provider extends Provider_Contract {
Camwyn marked this conversation as resolved.
Show resolved Hide resolved
class Controller extends Provider_Contract {


/**
* Registers the required objects and filters.
*
* @since 4.14.7
* @since TBD
*/
public function register() {
// This is specifically for the admin, bail if we're not in the admin.
if ( ! is_admin() ) {
return;
}

$this->container->singleton( Black_Friday::class, Black_Friday::class, [ 'hook' ] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[phpcs] reported by reviewdog 🐶
PEAR.Functions.FunctionCallSignature.SpaceAfterOpenBracket
Expected 1 spaces after opening parenthesis; 2 found

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$this->container->singleton( Black_Friday::class, Black_Friday::class, [ 'hook' ] );
$this->container->singleton( Black_Friday::class, Black_Friday::class, [ 'hook' ] );

// EOY Sale disabled for 2022
// $this->container->singleton( End_Of_Year_Sale::class, End_Of_Year_Sale::class, [ 'hook' ] );

$this->hooks();
}

Expand All @@ -35,18 +39,16 @@ public function register() {
*
* @since 4.14.7
*/
protected function hooks() {
protected function hooks(): void {
add_action( 'tribe_plugins_loaded', [ $this, 'plugins_loaded' ] );
}

/**
* Setup for things that require plugins loaded first.
*
* @since 4.14.7
* @since TBD
*/
public function plugins_loaded() {
$this->container->make( Black_Friday::class );
// EOY Sale disabled for 2022
// $this->container->make( End_Of_Year_Sale::class );
}
}
Loading
Loading