Skip to content

Commit da9edea

Browse files
committed
Revert "feat(content-gate): add countdown block (#4176)"
This reverts commit f8fe757.
1 parent 4204a21 commit da9edea

File tree

13 files changed

+16
-540
lines changed

13 files changed

+16
-540
lines changed

includes/class-blocks.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
defined( 'ABSPATH' ) || exit;
1111

1212
use Newspack\Optional_Modules\Collections;
13-
use Newspack\Memberships;
14-
use Newspack\Memberships\Metering;
1513

1614
/**
1715
* Newspack Blocks Class.
@@ -22,7 +20,6 @@ final class Blocks {
2220
*/
2321
public static function init() {
2422
require_once NEWSPACK_ABSPATH . 'src/blocks/reader-registration/index.php';
25-
require_once NEWSPACK_ABSPATH . 'src/blocks/content-gate-countdown/class-content-gate-countdown-block.php';
2623

2724
if ( wp_is_block_theme() && class_exists( 'Newspack\Corrections' ) ) {
2825
require_once NEWSPACK_ABSPATH . 'src/blocks/correction-box/class-correction-box-block.php';
@@ -52,32 +49,22 @@ public static function enqueue_block_editor_assets() {
5249
NEWSPACK_PLUGIN_VERSION,
5350
true
5451
);
55-
$script_data = [
56-
'has_newsletters' => class_exists( 'Newspack_Newsletters_Subscription' ),
57-
'has_reader_activation' => Reader_Activation::is_enabled(),
58-
'newsletters_url' => Wizards::get_wizard( 'newsletters' )->newsletters_settings_url(),
59-
'has_google_oauth' => Google_OAuth::is_oauth_configured(),
60-
'google_logo_svg' => \Newspack\Newspack_UI_Icons::get_svg( 'google' ),
61-
'reader_activation_terms' => Reader_Activation::get_setting( 'terms_text' ),
62-
'reader_activation_url' => Reader_Activation::get_setting( 'terms_url' ),
63-
'has_recaptcha' => Recaptcha::can_use_captcha(),
64-
'recaptcha_url' => admin_url( 'admin.php?page=newspack-settings' ),
65-
'corrections_enabled' => wp_is_block_theme() && class_exists( 'Newspack\Corrections' ),
66-
'collections_enabled' => Collections::is_module_active(),
67-
'has_memberships' => Memberships::is_active(),
68-
];
69-
if ( $script_data['has_memberships'] ) {
70-
$script_data['content_gate_data'] = [
71-
'anonymous_metered_views' => Metering::get_total_metered_views( false ),
72-
'loggedin_metered_views' => Metering::get_total_metered_views( true ),
73-
'metered_views' => Metering::get_metered_views(),
74-
'metering_period' => Metering::get_metering_period(),
75-
];
76-
}
7752
\wp_localize_script(
7853
'newspack-blocks',
7954
'newspack_blocks',
80-
$script_data
55+
[
56+
'has_newsletters' => class_exists( 'Newspack_Newsletters_Subscription' ),
57+
'has_reader_activation' => Reader_Activation::is_enabled(),
58+
'newsletters_url' => Wizards::get_wizard( 'newsletters' )->newsletters_settings_url(),
59+
'has_google_oauth' => Google_OAuth::is_oauth_configured(),
60+
'google_logo_svg' => \Newspack\Newspack_UI_Icons::get_svg( 'google' ),
61+
'reader_activation_terms' => Reader_Activation::get_setting( 'terms_text' ),
62+
'reader_activation_url' => Reader_Activation::get_setting( 'terms_url' ),
63+
'has_recaptcha' => Recaptcha::can_use_captcha(),
64+
'recaptcha_url' => admin_url( 'admin.php?page=newspack-settings' ),
65+
'corrections_enabled' => wp_is_block_theme() && class_exists( 'Newspack\Corrections' ),
66+
'collections_enabled' => Collections::is_module_active(),
67+
]
8168
);
8269
\wp_enqueue_style(
8370
'newspack-blocks',

includes/plugins/wc-memberships/class-memberships.php

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -686,29 +686,6 @@ public static function get_restricted_post_excerpt( $post ) {
686686
$content = explode( '<!--more-->', $content )[0];
687687
} else {
688688
$count = (int) get_post_meta( $gate_post_id, 'visible_paragraphs', true );
689-
// Remove all spaces.
690-
$content = preg_replace( '/\s+/', ' ', $content );
691-
/**
692-
* Filter the list of blocks to exclude from the excerpt.
693-
*
694-
* @param array $excluded_blocks Array of blocks to exclude. i.e. [ 'core/image', 'newspack/content-gate-countdown' ].
695-
*
696-
* @return array
697-
*/
698-
$excluded_blocks = apply_filters( 'newspack_memberships_excerpt_excluded_blocks', [ 'newspack/content-gate-countdown' ] );
699-
// Remove unwanted blocks from the content.
700-
foreach ( $excluded_blocks as $block ) {
701-
[ $category, $name ] = explode( '/', $block );
702-
if ( ! $category || ! $name ) {
703-
continue;
704-
}
705-
if ( 'core' === $category ) {
706-
$regex = $name;
707-
} else {
708-
$regex = "$category\/$name";
709-
}
710-
$content = preg_replace( "/<!-- wp:$regex {?.*?}? -->.*?<!-- \/wp:$regex -->/s", '', $content );
711-
}
712689
// Split into paragraphs.
713690
$content = explode( '</p>', $content );
714691
// Extract the first $x paragraphs only.

includes/plugins/wc-memberships/class-metering.php

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -298,65 +298,5 @@ public static function get_article_view( $activity ) {
298298
self::$article_view = $activity;
299299
return $activity;
300300
}
301-
302-
/**
303-
* Get the metering period for a post.
304-
*
305-
* @param int|null $post_id Post ID. Default is current post.
306-
*
307-
* @return string Metered period (day, week, month).
308-
*/
309-
public static function get_metering_period( $post_id = null ) {
310-
if ( ! $post_id ) {
311-
$post_id = get_the_ID();
312-
}
313-
$gate_post_id = Memberships::get_gate_post_id( $post_id );
314-
return \get_post_meta( $gate_post_id, 'metering_period', true );
315-
}
316-
317-
/**
318-
* Get number of metered views for the user.
319-
*
320-
* @param int|null $user_id User ID. Default is current user.
321-
*
322-
* @return int Number of metered views.
323-
*/
324-
public static function get_metered_views( $user_id = null ) {
325-
if ( ! $user_id ) {
326-
$user_id = get_current_user_id();
327-
}
328-
// For anonymous users, return the anonymous count.
329-
if ( ! $user_id ) {
330-
$gate_post_id = Memberships::get_gate_post_id();
331-
return (int) \get_post_meta( $gate_post_id, 'metering_anonymous_count', true );
332-
}
333-
334-
// For logged-in users, calculate the remaining views based on their metering data.
335-
$gate_post_id = Memberships::get_gate_post_id();
336-
$user_meta_key = self::METERING_META_KEY . '_' . $gate_post_id;
337-
$user_metering_data = \get_user_meta( $user_id, $user_meta_key, true );
338-
if ( ! is_array( $user_metering_data ) || ! isset( $user_metering_data['content'] ) ) {
339-
return $count;
340-
}
341-
return count( $user_metering_data['content'] );
342-
}
343-
344-
/**
345-
* Get total number of metered views for current post.
346-
*
347-
* @param boolean $is_logged_in Whether to check for logged-in or anonymous users. Default is false (anonymous).
348-
*
349-
* @return int|boolean Total number of metered views if metering is enabled, otherwise false.
350-
*/
351-
public static function get_total_metered_views( $is_logged_in = false ) {
352-
$gate_post_id = Memberships::get_gate_post_id( get_the_ID() );
353-
if ( ! $gate_post_id ) {
354-
return false;
355-
}
356-
if ( ! $is_logged_in ) {
357-
return (int) \get_post_meta( $gate_post_id, 'metering_anonymous_count', true );
358-
}
359-
return (int) \get_post_meta( $gate_post_id, 'metering_registered_count', true );
360-
}
361301
}
362302
Metering::init();

packages/icons/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,3 @@ export { default as searchEmpty } from './src/search-empty';
3333
export { default as tabItem } from './src/tab-item';
3434
export { default as tabs } from './src/tabs';
3535
export { default as theme } from './src/theme';
36-
export { default as countdown } from './src/content-gate-countdown';

packages/icons/src/content-gate-countdown.js

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/blocks/content-gate-countdown/block.json

Lines changed: 0 additions & 39 deletions
This file was deleted.

src/blocks/content-gate-countdown/class-content-gate-countdown-block.php

Lines changed: 0 additions & 110 deletions
This file was deleted.

0 commit comments

Comments
 (0)