@automattic/newspack-blocks 4.3.1 → 4.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [4.3.2](https://github.com/Automattic/newspack-blocks/compare/v4.3.1...v4.3.2) (2024-10-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * dont cache blocks for staff ([2d30450](https://github.com/Automattic/newspack-blocks/commit/2d30450aa4047e92275e5d78c8ccb31ca96b345e))
7
+
1
8
  ## [4.3.1](https://github.com/Automattic/newspack-blocks/compare/v4.3.0...v4.3.1) (2024-10-28)
2
9
 
3
10
 
@@ -35,12 +35,21 @@ class Newspack_Blocks_Caching {
35
35
  * Add hooks and filters.
36
36
  */
37
37
  public static function init() {
38
- add_action( 'template_redirect', [ __CLASS__, 'check_all_blocks_cache_status' ] );
39
- add_filter( 'pre_render_block', [ __CLASS__, 'maybe_serve_cached_block' ], 10, 2 );
40
- add_filter( 'render_block', [ __CLASS__, 'maybe_cache_block' ], 9999, 2 );
38
+ add_action( 'init', [ __CLASS__, 'setup_block_caching' ] );
39
+ }
41
40
 
42
- if ( ! defined( 'NEWSPACK_BLOCKS_CACHE_BLOCKS_TIME' ) ) {
43
- define( 'NEWSPACK_BLOCKS_CACHE_BLOCKS_TIME', 300 );
41
+ /**
42
+ * Initialize block caching if needed.
43
+ */
44
+ public static function setup_block_caching() {
45
+ if ( ! is_user_logged_in() || ! current_user_can( 'edit_posts' ) ) {
46
+ add_action( 'template_redirect', [ __CLASS__, 'check_all_blocks_cache_status' ] );
47
+ add_filter( 'pre_render_block', [ __CLASS__, 'maybe_serve_cached_block' ], 10, 2 );
48
+ add_filter( 'render_block', [ __CLASS__, 'maybe_cache_block' ], 9999, 2 );
49
+
50
+ if ( ! defined( 'NEWSPACK_BLOCKS_CACHE_BLOCKS_TIME' ) ) {
51
+ define( 'NEWSPACK_BLOCKS_CACHE_BLOCKS_TIME', 300 );
52
+ }
44
53
  }
45
54
  }
46
55
 
@@ -7,7 +7,7 @@
7
7
  * Author URI: https://newspack.com/
8
8
  * Text Domain: newspack-blocks
9
9
  * Domain Path: /languages
10
- * Version: 4.3.1
10
+ * Version: 4.3.2
11
11
  *
12
12
  * @package Newspack_Blocks
13
13
  */
@@ -15,7 +15,7 @@
15
15
  define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
16
16
  define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
17
17
  define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
18
- define( 'NEWSPACK_BLOCKS__VERSION', '4.3.1' );
18
+ define( 'NEWSPACK_BLOCKS__VERSION', '4.3.2' );
19
19
 
20
20
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
21
21
  require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/newspack-blocks",
3
- "version": "4.3.1",
3
+ "version": "4.3.2",
4
4
  "author": "Automattic",
5
5
  "devDependencies": {
6
6
  "@rushstack/eslint-patch": "^1.10.4",
@@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
22
22
 
23
23
  require_once __DIR__ . '/composer/autoload_real.php';
24
24
 
25
- return ComposerAutoloaderInit5b5cb5ab61624c9bfb805aa977df4c7d::getLoader();
25
+ return ComposerAutoloaderInit35c3a51d6927e3d9cc4006b63ff43f08::getLoader();
@@ -2,7 +2,7 @@
2
2
 
3
3
  // autoload_real.php @generated by Composer
4
4
 
5
- class ComposerAutoloaderInit5b5cb5ab61624c9bfb805aa977df4c7d
5
+ class ComposerAutoloaderInit35c3a51d6927e3d9cc4006b63ff43f08
6
6
  {
7
7
  private static $loader;
8
8
 
@@ -22,12 +22,12 @@ class ComposerAutoloaderInit5b5cb5ab61624c9bfb805aa977df4c7d
22
22
  return self::$loader;
23
23
  }
24
24
 
25
- spl_autoload_register(array('ComposerAutoloaderInit5b5cb5ab61624c9bfb805aa977df4c7d', 'loadClassLoader'), true, true);
25
+ spl_autoload_register(array('ComposerAutoloaderInit35c3a51d6927e3d9cc4006b63ff43f08', 'loadClassLoader'), true, true);
26
26
  self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
27
- spl_autoload_unregister(array('ComposerAutoloaderInit5b5cb5ab61624c9bfb805aa977df4c7d', 'loadClassLoader'));
27
+ spl_autoload_unregister(array('ComposerAutoloaderInit35c3a51d6927e3d9cc4006b63ff43f08', 'loadClassLoader'));
28
28
 
29
29
  require __DIR__ . '/autoload_static.php';
30
- call_user_func(\Composer\Autoload\ComposerStaticInit5b5cb5ab61624c9bfb805aa977df4c7d::getInitializer($loader));
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit35c3a51d6927e3d9cc4006b63ff43f08::getInitializer($loader));
31
31
 
32
32
  $loader->register(true);
33
33
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  namespace Composer\Autoload;
6
6
 
7
- class ComposerStaticInit5b5cb5ab61624c9bfb805aa977df4c7d
7
+ class ComposerStaticInit35c3a51d6927e3d9cc4006b63ff43f08
8
8
  {
9
9
  public static $classMap = array (
10
10
  'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php',
@@ -13,7 +13,7 @@ class ComposerStaticInit5b5cb5ab61624c9bfb805aa977df4c7d
13
13
  public static function getInitializer(ClassLoader $loader)
14
14
  {
15
15
  return \Closure::bind(function () use ($loader) {
16
- $loader->classMap = ComposerStaticInit5b5cb5ab61624c9bfb805aa977df4c7d::$classMap;
16
+ $loader->classMap = ComposerStaticInit35c3a51d6927e3d9cc4006b63ff43f08::$classMap;
17
17
 
18
18
  }, null, ClassLoader::class);
19
19
  }
@@ -3,7 +3,7 @@
3
3
  'name' => 'automattic/newspack-blocks',
4
4
  'pretty_version' => 'dev-trunk',
5
5
  'version' => 'dev-trunk',
6
- 'reference' => '0b5eda3a0516ff74974cc7cee590ff42f449b46b',
6
+ 'reference' => '816332d9aa83ecc81fc65cd7573ed9b86d5c1f65',
7
7
  'type' => 'wordpress-plugin',
8
8
  'install_path' => __DIR__ . '/../../',
9
9
  'aliases' => array(),
@@ -13,7 +13,7 @@
13
13
  'automattic/newspack-blocks' => array(
14
14
  'pretty_version' => 'dev-trunk',
15
15
  'version' => 'dev-trunk',
16
- 'reference' => '0b5eda3a0516ff74974cc7cee590ff42f449b46b',
16
+ 'reference' => '816332d9aa83ecc81fc65cd7573ed9b86d5c1f65',
17
17
  'type' => 'wordpress-plugin',
18
18
  'install_path' => __DIR__ . '/../../',
19
19
  'aliases' => array(),