-
Notifications
You must be signed in to change notification settings - Fork 31
Special offer #968
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
Merged
Merged
Special offer #968
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6d29a32
Add special offer
66ab957
Support callable value for compoments
a635111
Style special offer button
7be78a9
Update compiled assets
3c6e13b
Update wording
5c2cf75
Update styling for closed panel
d017ab4
Update compiled assets
bef8518
Update the submit a request URL
97c2d62
Update php/class-special-offer.php
pereirinha f0c9778
Escape the strings
b328f3a
Merge branch 'develop' into feature/29-offer
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| <?php | ||
| /** | ||
| * Special Offer Class. | ||
| * | ||
| * @package Cloudinary | ||
| */ | ||
|
|
||
| namespace Cloudinary; | ||
|
|
||
| /** | ||
| * Class Special_Offer | ||
| */ | ||
| class Special_Offer { | ||
| /** | ||
| * The plugin instance. | ||
| * | ||
| * @var Plugin | ||
| */ | ||
| protected $plugin; | ||
|
|
||
| /** | ||
| * Special_Offer constructor. | ||
| * | ||
| * @param Plugin $plugin The plugin instance. | ||
| */ | ||
| public function __construct( $plugin ) { | ||
| $this->plugin = $plugin; | ||
|
|
||
| $this->register_hooks(); | ||
| } | ||
|
|
||
| /** | ||
| * Register hooks for the Special Offer. | ||
| */ | ||
| public function register_hooks() { | ||
| add_filter( 'cloudinary_admin_sidebar', array( $this, 'filtered_settings' ) ); | ||
| } | ||
|
|
||
| /** | ||
| * Filter the settings. | ||
| * | ||
| * @param array $settings The settings. | ||
| * | ||
| * @return array | ||
| */ | ||
| public function filtered_settings( $settings ) { | ||
| if ( ! $this->is_special_offer_available() ) { | ||
| return $settings; | ||
| } | ||
|
|
||
| $settings[0][] = array( | ||
| array( | ||
| 'type' => 'tag', | ||
| 'element' => 'div', | ||
| 'content' => __( 'Special Offer', 'cloudinary' ), | ||
| 'attributes' => array( | ||
| 'class' => array( | ||
| 'cld-special-offer', | ||
| ), | ||
| ), | ||
| ), | ||
| array( | ||
| 'type' => 'panel', | ||
| 'title' => __( 'Get a small $29 plan', 'cloudinary' ), | ||
| 'description' => __( 'Contact us', 'cloudinary' ), | ||
| 'collapsible' => 'closed', | ||
| array( | ||
| 'type' => 'tag', | ||
| 'element' => 'div', | ||
| 'content' => $this->get_special_offer_content(), | ||
| ), | ||
| array( | ||
| 'type' => 'link', | ||
| 'content' => __( 'Get started', 'cloudinary' ), | ||
| 'url' => static function () { | ||
| $args = array( | ||
| 'tf_360017815680' => 'help_with_plans', | ||
| 'tf_subject' => esc_attr( __( 'Request to Purchase the Small Plan', 'cloudinary' ) ), | ||
| 'tf_description' => esc_attr( __( "Hello,<br><br>I'm interested in purchasing the Small plan for $29. Could you please provide me with the next steps to complete the purchase?<br><br>Thank you!", 'cloudinary' ) ), | ||
| ); | ||
| return Utils::get_support_link( $args ); | ||
| }, | ||
| 'target' => '_blank', | ||
| ), | ||
| ), | ||
| ); | ||
|
|
||
| return $settings; | ||
| } | ||
|
|
||
| /** | ||
| * Check if the user is eligible for the $29 offer. | ||
| * | ||
| * @return bool | ||
| */ | ||
| protected function is_special_offer_available() { | ||
| $last_usage = get_option( Connect::META_KEYS['last_usage'], array( 'plan' => '' ) ); | ||
|
|
||
| return 'free' === strtolower( $last_usage['plan'] ); | ||
| } | ||
|
|
||
| /** | ||
| * Get Special Offer content. | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function get_special_offer_content() { | ||
| ob_start(); | ||
| include $this->plugin->dir_path . 'php/templates/special-offer.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingVariable | ||
|
|
||
| return ob_get_clean(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
| /** | ||
| * The Special Offer contents. | ||
| * | ||
| * @package Cloudinary | ||
| */ | ||
|
|
||
| ?> | ||
|
|
||
| <p><?php esc_html_e( 'Running out of space on your free account? Upgrade for just $29 and supercharge your WordPress site with Cloudinary for unlimited awesomeness!', 'cloudinary' ); ?></p> | ||
|
|
||
| <p> | ||
| <?php esc_html_e( 'As a note:', 'cloudinary' ); ?> | ||
| <br> | ||
| <?php esc_html_e( 'This offer is exclusive to free users. Existing paying users will continue with their current plan and pricing.', 'cloudinary' ); ?> | ||
| </p> | ||
|
|
||
| <strong><?php esc_html_e( 'Includes:', 'cloudinary' ); ?></strong> | ||
| <ul> | ||
| <li><?php esc_html_e( '3 users', 'cloudinary' ); ?></li> | ||
| <li><?php esc_html_e( '1 product environment', 'cloudinary' ); ?></li> | ||
| <li><?php esc_html_e( '60 monthly credits', 'cloudinary' ); ?></li> | ||
| </ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -333,7 +333,12 @@ | |
| 'type' => 'tag', | ||
| 'element' => 'a', | ||
| 'attributes' => array( | ||
| 'href' => Utils::get_support_link( '-' ), | ||
| 'href' => static function () { | ||
| $args = array( | ||
| 'tf_360017815680' => '-', | ||
| ); | ||
| return Utils::get_support_link( $args ); | ||
| }, | ||
| 'target' => '_blank', | ||
| 'rel' => 'noopener noreferrer', | ||
| 'class' => array( | ||
|
|
@@ -451,12 +456,14 @@ | |
| 'type' => 'panel', | ||
| 'title' => __( "I'm having an incompatibility issue with a theme, plugin, or hosting environment, what can I do?", 'cloudinary' ), | ||
| 'collapsible' => 'closed', | ||
| 'content' => sprintf( | ||
| // translators: The HTML markup. | ||
| __( 'We’re compatible with most other plugins so we expect it to work absolutely fine. If you do have any issues, please %1$scontact our support team%2$s who will help resolve your issue.', 'cloudinary' ), | ||
| '<a href="' . Utils::get_support_link() . '" target="_blank" rel="noopener noreferrer">', | ||
| '</a>' | ||
| ), | ||
| 'content' => static function () { | ||
| return sprintf( | ||
| // translators: The HTML markup. | ||
| __( 'We’re compatible with most other plugins so we expect it to work absolutely fine. If you do have any issues, please %1$scontact our support team%2$s who will help resolve your issue.', 'cloudinary' ), | ||
| '<a href="' . Utils::get_support_link() . '" target="_blank" rel="noopener noreferrer">', | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🥜 nitpick |
||
| '</a>' | ||
| ); | ||
| }, | ||
| ), | ||
| array( | ||
| 'type' => 'panel', | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 praise
I like this approach!