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

feat: segmentation criteria for subscriptions and memberships #1230

Merged
merged 4 commits into from
Oct 26, 2023
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
8 changes: 7 additions & 1 deletion includes/class-newspack-popups-inserter.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,14 @@ private static function is_memberships_restricted( $post_id = null ) {
* @param string $content The content of the post.
*/
public static function insert_popups_in_content( $content = '' ) {
$post = get_post();

if ( ! $post ) {
return $content;
}

$filtered_content = explode( "\n", $content );
$post_content = explode( "\n", get_post()->post_content );
$post_content = explode( "\n", $post->post_content );
if (
// Avoid duplicate execution.
true === self::$the_content_has_rendered
Expand Down
79 changes: 54 additions & 25 deletions src/criteria/default/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,29 @@
/**
* Reader Activity.
*/
'newsletter' => [
'name' => __( 'Newsletter', 'newspack-popups' ),
'user_account' => [
'name' => __( 'User Account', 'newspack-popups' ),
'category' => 'reader_activity',
'options' => [
[
'label' => __( 'All users', 'newspack-popups' ),
'value' => '',
],
[
'label' => __( 'Has user account', 'newspack-popups' ),
'value' => 'with-account',
],
[
'label' => __( 'Does not have user account', 'newspack-popups' ),
'value' => 'without-account',
],
],
],
'newsletter' => [
'name' => __( 'Newsletter', 'newspack-popups' ),
'description' => __( 'Subscriber status based on any newsletter list.', 'newspack-popups' ),
'category' => 'newsletter',
'options' => [
[
'label' => __( 'Subscribers and non-subscribers', 'newspack-popups' ),
'value' => '',
Expand All @@ -54,22 +73,22 @@
],
'subscribed_lists' => [
'name' => __( 'Subscribed to newsletter lists', 'newspack-popups' ),
'description' => __( 'Whether the reader subscribed to any of the selected newsletter lists', 'newspack-popups' ),
'category' => 'reader_activity',
'description' => __( 'If the reader is subscribed to any of the selected newsletter lists.', 'newspack-popups' ),
'category' => 'newsletter',
'matching_function' => 'list__in',
'matching_attribute' => 'newsletter_subscribed_lists',
],
'not_subscribed_lists' => [
'name' => __( 'Not subscribed to newsletter lists', 'newspack-popups' ),
'description' => __( 'Whether the reader is not subscribed to any of the selected newsletter lists', 'newspack-popups' ),
'category' => 'reader_activity',
'description' => __( 'If the reader is NOT subscribed to any of the selected newsletter lists.', 'newspack-popups' ),
'category' => 'newsletter',
'matching_function' => 'list__not_in',
'matching_attribute' => 'newsletter_subscribed_lists',
],
'donation' => [
'name' => __( 'Donation', 'newspack-popups' ),
'description' => __( '(if checkout happens on-site)', 'newspack-popups' ),
'category' => 'reader_activity',
'description' => __( 'If the reader has completed an onsite donation.', 'newspack-popups' ),
'category' => 'reader_revenue',
'options' => [
[
'label' => __( 'Donors and non-donors', 'newspack-popups' ),
Expand All @@ -89,23 +108,33 @@
],
],
],
'user_account' => [
'name' => __( 'User Account', 'newspack-popups' ),
'category' => 'reader_activity',
'options' => [
[
'label' => __( 'All users', 'newspack-popups' ),
'value' => '',
],
[
'label' => __( 'Has user account', 'newspack-popups' ),
'value' => 'with-account',
],
[
'label' => __( 'Does not have user account', 'newspack-popups' ),
'value' => 'without-account',
],
],
'active_subscriptions' => [
'name' => __( 'Has active subscription(s)', 'newspack-popups' ),
'description' => __( 'If the reader is an active subscriber to non-donation products.', 'newspack-popups' ),
'category' => 'reader_revenue',
'matching_function' => 'list__in',
'matching_attribute' => 'active_subscriptions',
],
'not_active_subscriptions' => [
'name' => __( 'Does not have active subscription(s)', 'newspack-popups' ),
'description' => __( 'If the reader is NOT an active subscriber to non-donation products.', 'newspack-popups' ),
'category' => 'reader_revenue',
'matching_function' => 'list__not_in',
'matching_attribute' => 'active_subscriptions',
],
'active_memberships' => [
'name' => __( 'Has active membership(s)', 'newspack-popups' ),
'description' => __( 'If the reader is a member of membership plans.', 'newspack-popups' ),
'category' => 'reader_revenue',
'matching_function' => 'list__in',
'matching_attribute' => 'active_memberships',
],
'not_active_memberships' => [
'name' => __( 'Does not have active membership(s)', 'newspack-popups' ),
'description' => __( 'If the reader is NOT a member of membership plans.', 'newspack-popups' ),
'category' => 'reader_revenue',
'matching_function' => 'list__not_in',
'matching_attribute' => 'active_memberships',
],
/**
* Referrer Sources.
Expand Down