Version Description
Download this release
Release Info
Developer | ramonopoly |
Plugin | Full Site Editing |
Version | 3.4070 |
Comparing to | |
See all releases |
Code changes from version 3.4003 to 3.4070
- block-patterns/class-block-patterns-utils.php +89 -0
- full-site-editing-plugin.php +2 -2
- readme.txt +1 -1
block-patterns/class-block-patterns-utils.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Block Patterns Utils.
|
4 |
+
*
|
5 |
+
* @package A8C\FSE
|
6 |
+
*/
|
7 |
+
|
8 |
+
namespace A8C\FSE;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Block_Patterns_Utils
|
12 |
+
*/
|
13 |
+
class Block_Patterns_Utils {
|
14 |
+
/**
|
15 |
+
* Make remote get requests.
|
16 |
+
*
|
17 |
+
* @param string $request_url The request URL.
|
18 |
+
* @return array The response.
|
19 |
+
*/
|
20 |
+
public function remote_get( $request_url ) {
|
21 |
+
$args = array( 'timeout' => 20 );
|
22 |
+
|
23 |
+
if ( function_exists( 'wpcom_json_api_get' ) ) {
|
24 |
+
$response = wpcom_json_api_get( $request_url, $args );
|
25 |
+
} else {
|
26 |
+
$response = wp_remote_get( $request_url, $args );
|
27 |
+
}
|
28 |
+
|
29 |
+
if ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
30 |
+
return array();
|
31 |
+
}
|
32 |
+
return json_decode( wp_remote_retrieve_body( $response ), true );
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* A wrapper for wp_cache_add.
|
37 |
+
*
|
38 |
+
* @param int|string $key The cache key to use for retrieval later.
|
39 |
+
* @param mixed $data The data to add to the cache.
|
40 |
+
* @param string $group The group to add the cache to. Enables the same key to be used across groups. Default empty.
|
41 |
+
* @param int $expire When the cache data should expire, in seconds.
|
42 |
+
* Default 0 (no expiration).
|
43 |
+
* @return bool True on success, false if cache key and group already exist.
|
44 |
+
*/
|
45 |
+
public function cache_add( $key, $data, $group, $expire ) {
|
46 |
+
return wp_cache_add( $key, $data, $group, $expire );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* A wrapper for wp_cache_get.
|
51 |
+
*
|
52 |
+
* @param int|string $key The key under which the cache contents are stored.
|
53 |
+
* @param string $group Where the cache contents are grouped. Default empty.
|
54 |
+
* @return mixed|false The cache contents on success, false on failure to retrieve contents.
|
55 |
+
*/
|
56 |
+
public function cache_get( $key, $group ) {
|
57 |
+
return wp_cache_get( $key, $group );
|
58 |
+
}
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Returns the sha1 hash of a concatenated string to use as a cache key.
|
62 |
+
*
|
63 |
+
* @param string $patterns_slug A slug for a patterns source site, e.g., `block_patterns`.
|
64 |
+
* @return string locale slug
|
65 |
+
*/
|
66 |
+
public function get_patterns_cache_key( $patterns_slug ) {
|
67 |
+
return sha1(
|
68 |
+
implode(
|
69 |
+
'_',
|
70 |
+
array(
|
71 |
+
$patterns_slug,
|
72 |
+
A8C_ETK_PLUGIN_VERSION,
|
73 |
+
$this->get_block_patterns_locale(),
|
74 |
+
)
|
75 |
+
)
|
76 |
+
);
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Get the locale to be used for fetching block patterns
|
81 |
+
*
|
82 |
+
* @return string locale slug
|
83 |
+
*/
|
84 |
+
public function get_block_patterns_locale() {
|
85 |
+
// Make sure to get blog locale, not user locale.
|
86 |
+
$language = function_exists( 'get_blog_lang_code' ) ? get_blog_lang_code() : get_locale();
|
87 |
+
return \A8C\FSE\Common\get_iso_639_locale( $language );
|
88 |
+
}
|
89 |
+
}
|
full-site-editing-plugin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* Plugin Name: WordPress.com Editing Toolkit
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
-
* Version: 3.
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
@@ -42,7 +42,7 @@ namespace A8C\FSE;
|
|
42 |
*
|
43 |
* @var string
|
44 |
*/
|
45 |
-
define( 'A8C_ETK_PLUGIN_VERSION', '3.
|
46 |
|
47 |
// Always include these helper files for dotcom FSE.
|
48 |
require_once __DIR__ . '/dotcom-fse/helpers.php';
|
2 |
/**
|
3 |
* Plugin Name: WordPress.com Editing Toolkit
|
4 |
* Description: Enhances your page creation workflow within the Block Editor.
|
5 |
+
* Version: 3.4070
|
6 |
* Author: Automattic
|
7 |
* Author URI: https://automattic.com/wordpress-plugins/
|
8 |
* License: GPLv2 or later
|
42 |
*
|
43 |
* @var string
|
44 |
*/
|
45 |
+
define( 'A8C_ETK_PLUGIN_VERSION', '3.4070' );
|
46 |
|
47 |
// Always include these helper files for dotcom FSE.
|
48 |
require_once __DIR__ . '/dotcom-fse/helpers.php';
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: automattic
|
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.5
|
5 |
Tested up to: 5.6
|
6 |
-
Stable tag: 3.
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
3 |
Tags: block, blocks, editor, gutenberg, page
|
4 |
Requires at least: 5.5
|
5 |
Tested up to: 5.6
|
6 |
+
Stable tag: 3.4070
|
7 |
Requires PHP: 5.6.20
|
8 |
License: GPLv2 or later
|
9 |
License URI: https://www.gnu.org/licenses/gpl-2.0.html
|