Changeset 3196946
- Timestamp:
- 11/25/2024 10:50:35 PM (16 months ago)
- Location:
- headless
- Files:
-
- 2 added
- 3 deleted
- 33 edited
- 61 copied
-
tags/2.5.0 (copied) (copied from headless/trunk)
-
tags/2.5.0/LICENSE (copied) (copied from headless/trunk/LICENSE)
-
tags/2.5.0/README.txt (copied) (copied from headless/trunk/README.txt) (2 diffs)
-
tags/2.5.0/classes (copied) (copied from headless/trunk/classes)
-
tags/2.5.0/classes/Ajax.php (copied) (copied from headless/trunk/classes/Ajax.php) (1 diff)
-
tags/2.5.0/classes/BlockPreparations/CoreEmbedBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/CoreEmbedBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/EmbedBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/EmbedBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/FreeFormBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/FreeFormBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/GalleryBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/GalleryBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/ImageBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/ImageBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/ParagraphBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/ParagraphBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/ReferenceBlockPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/ReferenceBlockPreparation.php)
-
tags/2.5.0/classes/BlockPreparations/TagCloudPreparation.php (copied) (copied from headless/trunk/classes/BlockPreparations/TagCloudPreparation.php)
-
tags/2.5.0/classes/Components/Assets.php (copied) (copied from headless/trunk/classes/Components/Assets.php) (3 diffs)
-
tags/2.5.0/classes/Components/Component.php (modified) (2 diffs)
-
tags/2.5.0/classes/Components/Database.php (copied) (copied from headless/trunk/classes/Components/Database.php) (2 diffs)
-
tags/2.5.0/classes/Components/Plugin.php (modified) (5 diffs)
-
tags/2.5.0/classes/Dashboard.php (copied) (copied from headless/trunk/classes/Dashboard.php) (2 diffs)
-
tags/2.5.0/classes/Extensions.php (copied) (copied from headless/trunk/classes/Extensions.php) (1 diff)
-
tags/2.5.0/classes/Extensions/CommentAuthorUser.php (copied) (copied from headless/trunk/classes/Extensions/CommentAuthorUser.php)
-
tags/2.5.0/classes/Extensions/ContentBlocks.php (copied) (copied from headless/trunk/classes/Extensions/ContentBlocks.php)
-
tags/2.5.0/classes/Extensions/FeaturedMedia.php (copied) (copied from headless/trunk/classes/Extensions/FeaturedMedia.php)
-
tags/2.5.0/classes/Extensions/Taxonomies.php (copied) (copied from headless/trunk/classes/Extensions/Taxonomies.php)
-
tags/2.5.0/classes/Headers.php (copied) (copied from headless/trunk/classes/Headers.php) (1 diff)
-
tags/2.5.0/classes/Headquarter.php (copied) (copied from headless/trunk/classes/Headquarter.php)
-
tags/2.5.0/classes/Interfaces/IBlockPreparation.php (copied) (copied from headless/trunk/classes/Interfaces/IBlockPreparation.php)
-
tags/2.5.0/classes/Interfaces/ICommentRouteExtension.php (copied) (copied from headless/trunk/classes/Interfaces/ICommentRouteExtension.php)
-
tags/2.5.0/classes/Interfaces/ITermRouteExtension.php (copied) (copied from headless/trunk/classes/Interfaces/ITermRouteExtension.php)
-
tags/2.5.0/classes/Interfaces/IUserRouteExtension.php (copied) (copied from headless/trunk/classes/Interfaces/IUserRouteExtension.php)
-
tags/2.5.0/classes/Links.php (deleted)
-
tags/2.5.0/classes/Log.php (copied) (copied from headless/trunk/classes/Log.php) (1 diff)
-
tags/2.5.0/classes/Migration.php (copied) (copied from headless/trunk/classes/Migration.php) (2 diffs)
-
tags/2.5.0/classes/Model/CommentRouteExtensions.php (copied) (copied from headless/trunk/classes/Model/CommentRouteExtensions.php)
-
tags/2.5.0/classes/Model/Frontend.php (copied) (copied from headless/trunk/classes/Model/Frontend.php)
-
tags/2.5.0/classes/Model/TermRouteExtensions.php (copied) (copied from headless/trunk/classes/Model/TermRouteExtensions.php)
-
tags/2.5.0/classes/Model/UserRouteExtensions.php (copied) (copied from headless/trunk/classes/Model/UserRouteExtensions.php)
-
tags/2.5.0/classes/PluginAssets.php (copied) (copied from headless/trunk/classes/PluginAssets.php) (3 diffs)
-
tags/2.5.0/classes/Post.php (copied) (copied from headless/trunk/classes/Post.php) (1 diff)
-
tags/2.5.0/classes/Preview.php (copied) (copied from headless/trunk/classes/Preview.php) (3 diffs)
-
tags/2.5.0/classes/Query.php (copied) (copied from headless/trunk/classes/Query.php) (1 diff)
-
tags/2.5.0/classes/Revalidate.php (copied) (copied from headless/trunk/classes/Revalidate.php) (10 diffs)
-
tags/2.5.0/classes/Routes.php (modified) (1 diff)
-
tags/2.5.0/classes/Routes/Menus.php (modified) (1 diff)
-
tags/2.5.0/classes/Routes/Settings.php (modified) (2 diffs)
-
tags/2.5.0/classes/Schedule.php (copied) (copied from headless/trunk/classes/Schedule.php) (3 diffs)
-
tags/2.5.0/classes/Security.php (copied) (copied from headless/trunk/classes/Security.php) (1 diff)
-
tags/2.5.0/classes/Store (copied) (copied from headless/trunk/classes/Store)
-
tags/2.5.0/classes/Store/RevalidationDatabase.php (copied) (copied from headless/trunk/classes/Store/RevalidationDatabase.php) (4 diffs)
-
tags/2.5.0/dist (copied) (copied from headless/trunk/dist)
-
tags/2.5.0/dist/admin.asset.php (copied) (copied from headless/trunk/dist/admin.asset.php) (1 diff)
-
tags/2.5.0/dist/admin.js (copied) (copied from headless/trunk/dist/admin.js) (1 diff)
-
tags/2.5.0/dist/gutenberg-rtl.css (added)
-
tags/2.5.0/dist/gutenberg.asset.php (copied) (copied from headless/trunk/dist/gutenberg.asset.php) (1 diff)
-
tags/2.5.0/dist/gutenberg.css (copied) (copied from headless/trunk/dist/gutenberg.css)
-
tags/2.5.0/dist/gutenberg.js (copied) (copied from headless/trunk/dist/gutenberg.js) (1 diff)
-
tags/2.5.0/dist/gutenberg.ts.asset.php (deleted)
-
tags/2.5.0/dist/gutenberg.ts.js (deleted)
-
tags/2.5.0/headless.php (copied) (copied from headless/trunk/headless.php) (4 diffs)
-
tags/2.5.0/public-functions.php (copied) (copied from headless/trunk/public-functions.php)
-
tags/2.5.0/vendor (copied) (copied from headless/trunk/vendor)
-
tags/2.5.0/vendor/autoload.php (copied) (copied from headless/trunk/vendor/autoload.php)
-
tags/2.5.0/vendor/composer/ClassLoader.php (copied) (copied from headless/trunk/vendor/composer/ClassLoader.php)
-
tags/2.5.0/vendor/composer/InstalledVersions.php (copied) (copied from headless/trunk/vendor/composer/InstalledVersions.php)
-
tags/2.5.0/vendor/composer/autoload_classmap.php (copied) (copied from headless/trunk/vendor/composer/autoload_classmap.php)
-
tags/2.5.0/vendor/composer/autoload_namespaces.php (copied) (copied from headless/trunk/vendor/composer/autoload_namespaces.php)
-
tags/2.5.0/vendor/composer/autoload_psr4.php (copied) (copied from headless/trunk/vendor/composer/autoload_psr4.php)
-
tags/2.5.0/vendor/composer/autoload_real.php (copied) (copied from headless/trunk/vendor/composer/autoload_real.php)
-
tags/2.5.0/vendor/composer/autoload_static.php (copied) (copied from headless/trunk/vendor/composer/autoload_static.php)
-
tags/2.5.0/vendor/composer/installed.json (copied) (copied from headless/trunk/vendor/composer/installed.json)
-
tags/2.5.0/vendor/composer/installed.php (copied) (copied from headless/trunk/vendor/composer/installed.php) (2 diffs)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/classes/Ajax.php (modified) (1 diff)
-
trunk/classes/Components/Assets.php (modified) (3 diffs)
-
trunk/classes/Components/Component.php (modified) (2 diffs)
-
trunk/classes/Components/Database.php (modified) (2 diffs)
-
trunk/classes/Components/Plugin.php (modified) (5 diffs)
-
trunk/classes/Dashboard.php (modified) (2 diffs)
-
trunk/classes/Extensions.php (modified) (1 diff)
-
trunk/classes/Headers.php (modified) (1 diff)
-
trunk/classes/Log.php (modified) (1 diff)
-
trunk/classes/Migration.php (modified) (2 diffs)
-
trunk/classes/PluginAssets.php (modified) (3 diffs)
-
trunk/classes/Post.php (modified) (1 diff)
-
trunk/classes/Preview.php (modified) (3 diffs)
-
trunk/classes/Query.php (modified) (1 diff)
-
trunk/classes/Revalidate.php (modified) (10 diffs)
-
trunk/classes/Routes.php (modified) (1 diff)
-
trunk/classes/Routes/Menus.php (modified) (1 diff)
-
trunk/classes/Routes/Settings.php (modified) (2 diffs)
-
trunk/classes/Schedule.php (modified) (3 diffs)
-
trunk/classes/Security.php (modified) (1 diff)
-
trunk/classes/Store/RevalidationDatabase.php (modified) (4 diffs)
-
trunk/dist/admin.asset.php (modified) (1 diff)
-
trunk/dist/admin.js (modified) (1 diff)
-
trunk/dist/gutenberg-rtl.css (added)
-
trunk/dist/gutenberg.asset.php (modified) (1 diff)
-
trunk/dist/gutenberg.js (modified) (1 diff)
-
trunk/headless.php (modified) (4 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
headless/tags/2.5.0/README.txt
r3072776 r3196946 4 4 Tags: gutenberg, block, developer, utils 5 5 Requires at least: 5.0 6 Tested up to: 6. 5.26 Tested up to: 6.6.2 7 7 Requires PHP: 8.0 8 8 Stable tag: 2.2.4 … … 27 27 28 28 == Changelog == 29 30 = 2.3.0 = 31 * Feature: Revalidate feature can be deactivated via hook 32 * Feature: Preview feature can be deactivated via hook 33 * Update: NPM Packages 29 34 30 35 = 2.2.4 = -
headless/tags/2.5.0/classes/Ajax.php
r3060628 r3196946 13 13 const GET_POST_ID = "post_id"; 14 14 15 public function onCreate() {15 public function onCreate(): void { 16 16 parent::onCreate(); 17 17 add_action('wp_ajax_'.self::GET_ACTION, [$this, 'revalidate']); -
headless/tags/2.5.0/classes/Components/Assets.php
r2766747 r3196946 4 4 namespace Palasthotel\WordPress\Headless\Components; 5 5 6 /**7 * Class Assets8 * @property Plugin plugin9 * @version 0.1.210 */11 6 class Assets { 12 7 13 public function __construct( Plugin $plugin ) { 8 private Plugin $plugin; 9 10 public function __construct(Plugin $plugin) { 14 11 $this->plugin = $plugin; 15 12 } 16 13 17 public function registerStyle( string $handle, string $pluginPathToFile, array $dependencies = [], string $media = 'all'): bool {14 public function registerStyle(string $handle, string $pluginPathToFile, array $dependencies = [], string $media = 'all'): bool { 18 15 $filePath = $this->plugin->path . $pluginPathToFile; 19 $fileUrl = $this->plugin->url . $pluginPathToFile;20 if ( ! file_exists( $filePath )) {21 error_log( "Style file does not exist: $filePath");16 $fileUrl = $this->plugin->url . $pluginPathToFile; 17 if (!file_exists($filePath)) { 18 error_log("Style file does not exist: $filePath"); 22 19 23 20 return false; 24 21 } 25 22 26 return wp_register_style( $handle, $fileUrl, $dependencies, filemtime( $filePath ), $media);23 return wp_register_style($handle, $fileUrl, $dependencies, filemtime($filePath), $media); 27 24 28 25 } 29 26 30 public function registerScript( string $handle, string $pluginPathToFile, array $dependencies = [], bool $footer = true): bool {27 public function registerScript(string $handle, string $pluginPathToFile, array $dependencies = [], bool $footer = true): bool { 31 28 $filePath = $this->plugin->path . $pluginPathToFile; 32 if ( ! file_exists( $filePath )) {33 error_log( "Script file does not exist: $filePath");29 if (!file_exists($filePath)) { 30 error_log("Script file does not exist: $filePath"); 34 31 35 32 return false; 36 33 } 37 34 $assetsFilePath = ""; 38 if ( $this->endsWithJS( $filePath )) {39 $assetsFilePath = str_replace( ".js", ".asset.php", $filePath);35 if ($this->endsWithJS($filePath)) { 36 $assetsFilePath = str_replace(".js", ".asset.php", $filePath); 40 37 } 41 if ( ! empty( $assetsFilePath ) && file_exists( $assetsFilePath )) {38 if (!empty($assetsFilePath) && file_exists($assetsFilePath)) { 42 39 $info = include $assetsFilePath; 43 40 } else { 44 41 $info["dependencies"] = []; 45 $info["version"] = filemtime( $filePath);42 $info["version"] = filemtime($filePath); 46 43 } 47 44 … … 49 46 $handle, 50 47 $this->plugin->url . $pluginPathToFile, 51 array_merge( $info["dependencies"], $dependencies),48 array_merge($info["dependencies"], $dependencies), 52 49 $info["version"], 53 50 $footer … … 56 53 } 57 54 58 private function endsWithJS( $haystack): bool {59 $length = strlen( ".js");60 if ( ! $length) {55 private function endsWithJS($haystack): bool { 56 $length = strlen(".js"); 57 if (!$length) { 61 58 return true; 62 59 } 63 60 64 return substr( $haystack, - $length) === ".js";61 return substr($haystack, -$length) === ".js"; 65 62 } 66 63 } -
headless/tags/2.5.0/classes/Components/Component.php
r2730402 r3196946 4 4 namespace Palasthotel\WordPress\Headless\Components; 5 5 6 /**7 * Class Component8 *9 * @property \Palasthotel\WordPress\Headless\Plugin plugin10 *11 * @package Palasthotel\WordPress12 * @version 0.1.213 */14 6 abstract class Component { 15 /** 16 * _Component constructor. 17 * 18 * @param \Palasthotel\WordPress\Headless\Plugin $plugin 19 */ 20 public function __construct(Plugin $plugin) { 21 $this->plugin = $plugin; 7 8 public function __construct( 9 public \Palasthotel\WordPress\Headless\Plugin $plugin 10 ) { 22 11 $this->onCreate(); 23 12 } … … 26 15 * overwrite this method in component implementations 27 16 */ 28 public function onCreate() {17 public function onCreate(): void { 29 18 // init your hooks and stuff 30 19 } -
headless/tags/2.5.0/classes/Components/Database.php
r2766747 r3196946 6 6 use wpdb; 7 7 8 /**9 * @property wpdb wpdb10 * @version 0.1.111 */12 8 abstract class Database { 9 10 protected wpdb $wpdb; 13 11 14 12 public function __construct() { … … 21 19 * initialize table names and other properties 22 20 */ 23 abstract function init() ;24 25 public function createTables() {21 abstract function init(): void; 22 23 public function createTables(): void { 26 24 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 27 25 } -
headless/tags/2.5.0/classes/Components/Plugin.php
r2730402 r3196946 6 6 use ReflectionException; 7 7 8 /**9 * @property string path10 * @property string url11 * @property string basename12 * @version 0.1.313 */14 8 abstract class Plugin { 15 9 … … 18 12 */ 19 13 private $ref; 20 21 14 private $tooLateForTextdomain; 15 public $path; 16 public $url; 17 public $basename; 22 18 23 19 /** … … 34 30 $this->tooLateForTextdomain = true; 35 31 36 register_activation_hook( $this->ref->getFileName(), array( $this, "onActivation" ));37 register_deactivation_hook( $this->ref->getFileName(), array( $this, "onDeactivation" ));32 register_activation_hook( $this->ref->getFileName(), [$this, "onActivation"]); 33 register_deactivation_hook( $this->ref->getFileName(), [$this, "onDeactivation"]); 38 34 39 35 } … … 80 76 $domain, 81 77 false, 82 dirname( plugin_basename( $this->ref->getFileName() ) ) . "/" . $relativeLanguagesPath78 dirname(plugin_basename($this->ref->getFileName())) . "Plugin.php/" . $relativeLanguagesPath 83 79 ); 84 80 } ); … … 88 84 if ( function_exists( 'is_multisite' ) && is_multisite() ) { 89 85 $network_site = get_network()->site_id; 90 $args = array( 'fields' => 'ids' );86 $args = ['fields' => 'ids']; 91 87 $site_ids = get_sites( $args ); 92 88 -
headless/tags/2.5.0/classes/Dashboard.php
r3060628 r3196946 4 4 5 5 class Dashboard extends Components\Component { 6 public function onCreate() {6 public function onCreate(): void { 7 7 parent::onCreate(); 8 8 add_action('wp_dashboard_setup', [$this, 'setup']); … … 12 12 if(!current_user_can('edit_posts')) return; 13 13 14 wp_add_dashboard_widget( 15 Plugin::DOMAIN, 16 __("Headless", Plugin::DOMAIN), 17 array($this, 'render') 18 ); 14 if($this->plugin->revalidate->isRevalidationActive()){ 15 wp_add_dashboard_widget( 16 Plugin::DOMAIN, 17 __("Headless", Plugin::DOMAIN), 18 array($this, 'render') 19 ); 20 } 19 21 } 20 22 -
headless/tags/2.5.0/classes/Extensions.php
r2791162 r3196946 33 33 private TermRouteExtensions $termRouteExtensions; 34 34 35 public function onCreate() {35 public function onCreate(): void { 36 36 parent::onCreate(); 37 37 -
headless/tags/2.5.0/classes/Headers.php
r2791162 r3196946 4 4 5 5 class Headers extends Components\Component { 6 public function onCreate() {6 public function onCreate(): void { 7 7 parent::onCreate(); 8 8 add_filter('rest_post_dispatch', [$this, 'rest_post_dispatch']); -
headless/tags/2.5.0/classes/Log.php
r2901812 r3196946 9 9 private $log; 10 10 11 public function onCreate() {11 public function onCreate(): void { 12 12 parent::onCreate(); 13 13 add_action("cron_logger_init", function(\CronLogger\Plugin $logger){ -
headless/tags/2.5.0/classes/Migration.php
r2977228 r3196946 14 14 } 15 15 16 public function onCreate() {16 public function onCreate(): void { 17 17 parent::onCreate(); 18 18 … … 20 20 // drop every table that was created before version 3 21 21 $tableName = $this->plugin->dbRevalidation->table; 22 $this->plugin->dbRevalidation->wpdb->query("DROP TABLE IF EXISTS $tableName"); 22 global $wpdb; 23 $wpdb->query("DROP TABLE IF EXISTS $tableName"); 23 24 $this->plugin->dbRevalidation->createTables(); 24 25 $this->setSchemaVersion(3); -
headless/tags/2.5.0/classes/PluginAssets.php
r2901812 r3196946 6 6 use Palasthotel\WordPress\Headless\Components\Component; 7 7 8 /**9 * @property Assets $assets10 */11 8 class PluginAssets extends Component { 12 9 … … 15 12 const HANDLE_GUTENBERG_STYLE = "headless_gutenberg_styles"; 16 13 17 public function onCreate() { 14 public Assets $assets; 15 16 public function onCreate(): void { 18 17 parent::onCreate(); 19 18 … … 60 59 "HeadlessAdmin", 61 60 [ 61 "revalidate_is_active" => $this->plugin->revalidate->isRevalidationActive(), 62 "preview_is_active" => $this->plugin->preview->isPreviewActive(), 62 63 "preview_path" => $this->plugin->preview->getHeadlessPreviewPath(), 63 64 "frontends" => array_map(function($frontend){ -
headless/tags/2.5.0/classes/Post.php
r2868064 r3196946 8 8 9 9 class Post extends Component { 10 public function onCreate() {10 public function onCreate(): void { 11 11 parent::onCreate(); 12 12 add_filter( Plugin::FILTER_PREPARE_POST, [ $this, 'prepare_post' ], 10, 2 ); -
headless/tags/2.5.0/classes/Preview.php
r2901812 r3196946 10 10 const POST_ID_PLACEHOLDER = "{{post_id}}"; 11 11 12 public function onCreate() {12 public function onCreate(): void { 13 13 parent::onCreate(); 14 14 … … 16 16 add_action( 'wp_ajax_headless_preview', [ $this, 'admin_preview' ] ); 17 17 add_action( 'wp_ajax_nopriv_headless_preview', [ $this, 'no_permission' ] ); 18 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); 18 19 } 20 21 19 22 20 23 public function getRedirectLink( $id ) { … … 81 84 } 82 85 86 public function plugins_loaded() { 87 remove_filter( 'preview_post_link', [ $this, 'preview_post_link' ] ); 88 remove_action( 'wp_ajax_headless_preview', [ $this, 'admin_preview' ] ); 89 remove_action( 'wp_ajax_nopriv_headless_preview', [ $this, 'no_permission' ] ); 90 } 91 92 function isPreviewInactive() { 93 return !$this->isPreviewActive(); 94 } 95 function isPreviewActive() { 96 return apply_filters(Plugin::FILTER_PREVIEW_IS_ACTIVE, true); 97 } 83 98 84 99 } -
headless/tags/2.5.0/classes/Query.php
r3060647 r3196946 15 15 const POST_TYPE = "hl_post_type"; 16 16 17 public function onCreate() {17 public function onCreate(): void { 18 18 parent::onCreate(); 19 19 -
headless/tags/2.5.0/classes/Revalidate.php
r3060628 r3196946 8 8 class Revalidate extends Component { 9 9 10 public function onCreate() {10 public function onCreate(): void { 11 11 parent::onCreate(); 12 12 add_action('save_post', [$this, 'on_post_change']); … … 16 16 17 17 public function on_post_change($post_id){ 18 if($this->isRevalidationInactive()) return; 18 19 if(wp_is_post_revision($post_id)) return; 19 20 $this->plugin->dbRevalidation->addPost($post_id); … … 21 22 22 23 public function on_comment_change($comment_id){ 24 if($this->isRevalidationInactive()) return; 23 25 $comment = get_comment($comment_id); 24 26 $this->plugin->dbRevalidation->addPost($comment->comment_post_ID); … … 27 29 28 30 function revalidateComments($post_id){ 31 32 if($this->isRevalidationInactive()) return[]; 33 29 34 $frontends = $this->plugin->headquarter->getFrontends(); 30 35 $results = []; … … 44 49 */ 45 50 function revalidatePost($post_id) { 51 52 if($this->isRevalidationInactive()) return []; 53 46 54 $frontends = $this->plugin->headquarter->getFrontends(); 47 55 $results = []; … … 54 62 55 63 function revalidateByPathByPostId(Frontend $frontend, $post_id) { 64 65 if($this->isRevalidationInactive()) return []; 66 56 67 $permalink = get_permalink($post_id); 57 68 $path = parse_url($permalink, PHP_URL_PATH); … … 63 74 64 75 function revalidateByPath(Frontend $frontend, $path){ 76 77 if($this->isRevalidationInactive()) return []; 78 65 79 $baseUrl = $frontend->getBaseUrl(); 66 80 $url = untrailingslashit($baseUrl)."/api/revalidate?secret_token=".HEADLESS_SECRET_TOKEN."&path=".urlencode($path); … … 71 85 72 86 function revalidateByTag(Frontend $frontend, string $tag) { 87 88 if($this->isRevalidationInactive()) return []; 89 73 90 $baseUrl = $frontend->getBaseUrl(); 74 91 $url = untrailingslashit($baseUrl)."/api/revalidate?secret_token=".HEADLESS_SECRET_TOKEN."&tag=".urlencode($tag); … … 79 96 80 97 private function executeRavalidation($finalUrl){ 98 81 99 $url = add_query_arg('invalidate___cache', time(), $finalUrl); 82 100 … … 94 112 } 95 113 114 function isRevalidationInactive() { 115 return !$this->isRevalidationActive(); 116 } 117 function isRevalidationActive() { 118 return apply_filters(Plugin::FILTER_REVALIDATE_IS_ACTIVE, true); 119 } 120 96 121 97 122 } -
headless/tags/2.5.0/classes/Routes.php
r2730402 r3196946 7 7 use Palasthotel\WordPress\Headless\Routes\Settings; 8 8 9 /**10 * @property Menus $menus11 * @property Settings $settings12 */13 9 class Routes extends Components\Component { 14 10 15 public function onCreate() { 11 public Menus $menus; 12 public Settings $settings; 13 14 public function onCreate(): void { 16 15 parent::onCreate(); 17 16 add_action( 'rest_api_init', [ $this, 'rest_api_init' ] ); -
headless/tags/2.5.0/classes/Routes/Menus.php
r2730402 r3196946 8 8 class Menus extends Component { 9 9 10 private $menu;10 private array|false $menu; 11 11 12 12 public function init(){ -
headless/tags/2.5.0/classes/Routes/Settings.php
r2730402 r3196946 8 8 class Settings extends Component { 9 9 10 public function init() {10 public function init(): void { 11 11 register_rest_route( Plugin::REST_NAMESPACE, '/settings', array( 12 12 'methods' => \WP_REST_Server::READABLE, … … 19 19 } 20 20 21 public function get_settings() {21 public function get_settings(): array { 22 22 return [ 23 23 "front_page" => get_option( 'show_on_front' ), 24 "page_on_front" => get_option( 'page_on_front'),24 "page_on_front" => intval(get_option( 'page_on_front' )), 25 25 "home_url" => home_url(), 26 26 ]; -
headless/tags/2.5.0/classes/Schedule.php
r3060628 r3196946 7 7 class Schedule extends Component { 8 8 9 public function onCreate() {9 public function onCreate(): void { 10 10 parent::onCreate(); 11 11 … … 15 15 16 16 public function init(){ 17 if($this->plugin->revalidate->isRevalidationInactive()){ 18 $next = $this->getNextSchedule(); 19 if($next){ 20 wp_unschedule_event($next, Plugin::SCHEDULE_REVALIDATE); 21 } 22 return; 23 } 17 24 if(!wp_next_scheduled(Plugin::SCHEDULE_REVALIDATE)){ 18 25 wp_schedule_event(time(), 'hourly', Plugin::SCHEDULE_REVALIDATE); … … 33 40 34 41 public function revalidate(){ 42 43 if($this->plugin->revalidate->isRevalidationInactive()) return; 44 35 45 $lastRun = $this->getLastRevalidationRun(); 36 46 $now = time(); -
headless/tags/2.5.0/classes/Security.php
r3020918 r3196946 7 7 class Security extends Component { 8 8 9 public function onCreate() {9 public function onCreate(): void { 10 10 parent::onCreate(); 11 11 add_filter('wp_is_application_passwords_available', '__return_true'); -
headless/tags/2.5.0/classes/Store/RevalidationDatabase.php
r3060628 r3196946 7 7 use Palasthotel\WordPress\Headless\Components\Database; 8 8 9 /**10 * @property string $table11 */12 9 class RevalidationDatabase extends Database { 13 10 … … 15 12 const TYPE_COMMENT = "comment"; 16 13 17 function init() { 14 public string $table; 15 16 function init(): void { 18 17 $this->table = $this->wpdb->prefix . "headless_revalidate"; 19 18 } … … 104 103 } 105 104 106 public function createTables() {105 public function createTables(): void { 107 106 parent::createTables(); 108 107 \dbDelta("CREATE TABLE IF NOT EXISTS $this->table … … 112 111 content_type varchar(40) NOT NULL, 113 112 revalidation_state varchar(30), 114 revalidated_at TIMESTAMP default null,113 revalidated_at TIMESTAMP NULL default null, 115 114 primary key (id), 116 115 key (content_id), -
headless/tags/2.5.0/dist/admin.asset.php
r3072776 r3196946 1 <?php return array('dependencies' => array(), 'version' => ' ecdaf49b7e3ddff3eb2a');1 <?php return array('dependencies' => array(), 'version' => '8241f02c6df14b01c628'); -
headless/tags/2.5.0/dist/admin.js
r3072776 r3196946 1 !function(){"use strict";window.addEventListener("DOMContentLoaded",(async()=>{await Promise.all(window.HeadlessAdmin.frontends.map((e=>e+window.HeadlessAdmin.preview_path)).map((e=>fetch(e,{credentials:"include"}).then((e=>e.json())))))}))}();1 (()=>{"use strict";window.addEventListener("DOMContentLoaded",(async()=>{window.HeadlessAdmin.preview_is_active&&await Promise.all(window.HeadlessAdmin.frontends.map((e=>e+window.HeadlessAdmin.preview_path)).map((e=>fetch(e,{credentials:"include"}).then((e=>e.json())))))}))})(); -
headless/tags/2.5.0/dist/gutenberg.asset.php
r3072776 r3196946 1 <?php return array('dependencies' => array('react ', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins'), 'version' => 'a2d2fb477c2bc904a66b');1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins'), 'version' => 'f64387f5a68638e1237e'); -
headless/tags/2.5.0/dist/gutenberg.js
r3072776 r3196946 1 !function(){"use strict";var t=window.wp.plugins,e=window.React,n=window.wp.editPost,s=window.wp.components;var a=window.wp.data,i=window.wp.element;const r=()=>(0,a.useSelect)((t=>t("core/editor").getCurrentPost()),[]),o=({index:t,baseUrl:n,controller:s,onStateChanged:a})=>{const{state:o,reload:l}=(t=>{const[e,n]=(0,i.useState)("idle"),s=r(),a=(0,i.useMemo)((()=>s?.link?new URL(s?.link).pathname:""),[s.link]);return{state:e,reload:()=>{n("loading"),(async()=>{try{const e=await fetch(((t,e)=>window.Headless.ajax+`?action=${window.Headless.actions.revalidate}&frontend=${t}&path=${e}`)(t,a)),s=await e.json();s.success?n("success"):(console.error(s),n("error"))}catch(t){n("error")}})()}}})(t),c=r(),d=(0,i.useMemo)((()=>{const t=c.link,e=new URL(t);return n.replace(/^\/|\/$/g,"")+e.pathname}),[c.link]);return(0,i.useEffect)((()=>{s.add(t,l)}),[t]),(0,i.useEffect)((()=>{a(t,o)}),[o]),(0,e.createElement)("div",{title:d},(0,e.createElement)("a",{href:d,target:"_blank"},"Frontend ",t),"loading"==o&&(0,e.createElement)(e.Fragment,null," 🧹"),"success"==o&&(0,e.createElement)(e.Fragment,null," ✅"),"error"==o&&(0,e.createElement)(e.Fragment,null," 🚨"))};(0,t.registerPlugin)("headless-plugin",{icon:()=>null,render:function(){const t=window.Headless.frontends,a=(0,i.useMemo)((()=>(()=>{const t=new Map;return{add:(e,n)=>{t.set(e,n)},run:()=>{t.forEach((t=>{t()}))}}})()),[]),[l,c]=(0,i.useState)({}),d="publish"==r().status,p=Object.values(l).find((t=>1==t));return(0,e.createElement)(n.PluginDocumentSettingPanel,{title:"Headless"},d?(0,e.createElement)(e.Fragment,null,(0,e.createElement)("ol",null,t.map(((t,n)=>(0,e.createElement)("li",{key:n},(0,e.createElement)(o,{baseUrl:t,index:n,controller:a,onStateChanged:(t,e)=>{c((n=>{const s={...n};return s[t]="loading"==e,s}))}}))))),(0,e.createElement)(s.Button,{variant:"secondary",disabled:p||!d,onClick:()=>{a.run()}},"Revalidate cache")):(0,e.createElement)("p",{className:"description"},"Only published contents can be revalidated."))}}),document.addEventListener("DOMContentLoaded",(function(){const t=(0,a.select)("core/editor"),e=t.getCurrentPostId,n=t.isSavingPost,s=(0,a.dispatch)("core/editor"),i=s.autosave,r=s.savePost,o=document.createElement("a");o.className="components-button",o.addEventListener("click",(e=>{if(e.preventDefault(),n())return;const s=window.open("about:blank",o.target);!function(t){let e="";e+='\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t',e+='\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n ',t.write('\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n '),t.close()}(s.document),((()=>{const e=t.getCurrentPost().status;return"draft"==e||"auto-draft"==e})()?r:i)().then((()=>{s.location=o.href}))})),(0,a.subscribe)((()=>{n()?o.classList.add("is-disabled"):o.classList.remove("is-disabled")})),setInterval((function(){const t=e(),n=(t=>window.Headless.preview_url.replace(window.Headless.post_id_placeholder,`${t}`))(t),s=document.querySelectorAll("[target^=wp-preview-]");s&&s.length&&s.forEach((t=>{t.setAttribute("href",n)})),document.querySelectorAll(".components-snackbar-list .components-snackbar__content a.components-button").forEach((e=>{(e.href.includes("?post="+t)||e.href.includes("?page_id="+t)||e.href.includes("?p="+t))&&(e.href=n,e.target="wp-preview-"+t)}));const a=document.querySelectorAll(".components-menu-group");let i=null;if(a.forEach((t=>{t.querySelector(".editor-preview-dropdown__button-external")&&(i=t)})),!i)return;const r="headless-preview-link";if(i.querySelector("#"+r))return;const l=i.querySelector(".editor-preview-dropdown__button-external"),c=l.querySelector("svg"),d=l.getAttribute("target");o.text=l.textContent,o.append(c),o.target=d,o.href=n,o.id=r,l.style.display="none",i.querySelector('[role="group"]').append(o)}),300)}))}();1 (()=>{"use strict";const t=window.wp.plugins,e=window.wp.editPost,n=window.wp.components,s=window.wp.data,i=window.wp.element,a=()=>(0,s.useSelect)((t=>t("core/editor").getCurrentPost()),[]),r=window.ReactJSXRuntime,o=({index:t,baseUrl:e,controller:n,onStateChanged:s})=>{const{state:o,reload:l}=(t=>{const[e,n]=(0,i.useState)("idle"),s=a(),r=(0,i.useMemo)((()=>s?.link?new URL(s?.link).pathname:""),[s.link]);return{state:e,reload:()=>{n("loading"),(async()=>{try{const e=await fetch(((t,e)=>window.Headless.ajax+`?action=${window.Headless.actions.revalidate}&frontend=${t}&path=${e}`)(t,r)),s=await e.json();s.success?n("success"):(console.error(s),n("error"))}catch(t){n("error")}})()}}})(t),c=a(),d=(0,i.useMemo)((()=>{const t=c.link,n=new URL(t);return e.replace(/^\/|\/$/g,"")+n.pathname}),[c.link]);return(0,i.useEffect)((()=>{n.add(t,l)}),[t]),(0,i.useEffect)((()=>{s(t,o)}),[o]),(0,r.jsxs)("div",{title:d,children:[(0,r.jsxs)("a",{href:d,target:"_blank",children:["Frontend ",t]}),"loading"==o&&(0,r.jsx)(r.Fragment,{children:" 🧹"}),"success"==o&&(0,r.jsx)(r.Fragment,{children:" ✅"}),"error"==o&&(0,r.jsx)(r.Fragment,{children:" 🚨"})]})};window.HeadlessAdmin.revalidate_is_active&&(0,t.registerPlugin)("headless-plugin",{icon:()=>null,render:function(){const t=window.Headless.frontends,s=(0,i.useMemo)((()=>(()=>{const t=new Map;return{add:(e,n)=>{t.set(e,n)},run:()=>{t.forEach((t=>{t()}))}}})()),[]),[l,c]=(0,i.useState)({}),d="publish"==a().status,p=Object.values(l).find((t=>1==t));return(0,r.jsx)(e.PluginDocumentSettingPanel,{title:"Headless",children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("ol",{children:t.map(((t,e)=>(0,r.jsx)("li",{children:(0,r.jsx)(o,{baseUrl:t,index:e,controller:s,onStateChanged:(t,e)=>{c((n=>{const s={...n};return s[t]="loading"==e,s}))}})},e)))}),(0,r.jsx)(n.Button,{variant:"secondary",disabled:p||!d,onClick:()=>{s.run()},children:"Revalidate cache"})]}):(0,r.jsx)("p",{className:"description",children:"Only published contents can be revalidated."})})}}),document.addEventListener("DOMContentLoaded",(function(){if(!window.HeadlessAdmin.preview_is_active)return;const t=(0,s.select)("core/editor"),e=t.getCurrentPostId,n=t.isSavingPost,i=(0,s.dispatch)("core/editor"),a=i.autosave,r=i.savePost,o=document.createElement("a");o.className="components-button",o.addEventListener("click",(e=>{if(e.preventDefault(),n())return;const s=window.open("about:blank",o.target);!function(t){let e="";e+='\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t',e+='\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n ',t.write('\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n '),t.close()}(s.document),((()=>{const e=t.getCurrentPost().status;return"draft"==e||"auto-draft"==e})()?r:a)().then((()=>{s.location=o.href}))})),(0,s.subscribe)((()=>{n()?o.classList.add("is-disabled"):o.classList.remove("is-disabled")})),setInterval((function(){const t=e(),n=(t=>window.Headless.preview_url.replace(window.Headless.post_id_placeholder,`${t}`))(t),s=document.querySelectorAll("[target^=wp-preview-]");s&&s.length&&s.forEach((t=>{t.setAttribute("href",n)})),document.querySelectorAll(".components-snackbar-list .components-snackbar__content a.components-button").forEach((e=>{(e.href.includes("?post="+t)||e.href.includes("?page_id="+t)||e.href.includes("?p="+t))&&(e.href=n,e.target="wp-preview-"+t)}));const i=document.querySelectorAll(".components-menu-group");let a=null;if(i.forEach((t=>{t.querySelector(".editor-preview-dropdown__button-external")&&(a=t)})),!a)return;const r="headless-preview-link";if(a.querySelector("#"+r))return;const l=a.querySelector(".editor-preview-dropdown__button-external"),c=l.querySelector("svg"),d=l.getAttribute("target");o.text=l.textContent,o.append(c),o.target=d,o.href=n,o.id=r,l.style.display="none",a.querySelector('[role="group"]').append(o)}),300)}))})(); -
headless/tags/2.5.0/headless.php
r3072776 r3196946 5 5 * Plugin URI: https://github.com/palasthotel/headless 6 6 * Description: Adds features to use WordPress as headless CMS 7 * Version: 2. 2.47 * Version: 2.5.0 8 8 * Author: Palasthotel (Edward Bock) <edward.bock@palasthotel.de> 9 9 * Author URI: http://www.palasthotel.de 10 10 * Requires at least: 5.0 11 * Tested up to: 6. 5.211 * Tested up to: 6.7.1 12 12 * Requires PHP: 8.0 13 13 * Text Domain: headless … … 53 53 require_once __DIR__ . "/vendor/autoload.php"; 54 54 55 /**56 * @property Routes $routes57 * @property Extensions $extensions58 * @property Security $security59 * @property Preview $preview60 * @property Query $query61 * @property Revalidate $revalidate62 * @property RevalidationDatabase $dbRevalidation63 * @property Schedule $schedule64 * @property PluginAssets $gutenberg65 * @property Headers $headers66 * @property Post $post67 * @property Dashboard $dashboard68 * @property Headquarter $headquarter69 * @property Ajax $ajax70 * @property Log $log71 */72 55 class Plugin extends Components\Plugin { 73 56 … … 77 60 const FILTER_IS_HEADLESS_POST_TYPE = "headless_is_headless_post_type"; 78 61 62 const FILTER_PREVIEW_IS_ACTIVE = "headless_preview_is_active"; 63 79 64 const FILTER_PREVIEW_REDIRECT_URL = "headless_preview_redirect_url"; 80 65 const FILTER_PREVIEW_URL = "headless_preview_url"; 66 const FILTER_REVALIDATE_IS_ACTIVE = "headless_revalidate_is_active"; 81 67 82 68 const ACTION_REGISTER_BLOCK_PREPARATION_EXTENSIONS = "headless_register_block_preparation_extensions"; … … 104 90 const OPTION_SCHEMA_VERSION = "headless_schema_version"; 105 91 92 public Routes $routes; 93 public Extensions $extensions; 94 public Security $security; 95 public Preview $preview; 96 public Query $query; 97 public Revalidate $revalidate; 98 public RevalidationDatabase $dbRevalidation; 99 public Schedule $schedule; 100 public PluginAssets $gutenberg; 101 public Headers $headers; 102 public Post $post; 103 public Dashboard $dashboard; 104 public Headquarter $headquarter; 105 public Ajax $ajax; 106 public Log $log; 106 107 107 function onCreate() {108 function onCreate(): void { 108 109 109 110 $this->dbRevalidation = new RevalidationDatabase(); -
headless/tags/2.5.0/vendor/composer/installed.php
r3072776 r3196946 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 54dd1eeef2a9fb154922d1ca2caee4fa7eaf4491',6 'reference' => 'f1c7c9a53894452db42cd6f4ee7b86eb879816f1', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 54dd1eeef2a9fb154922d1ca2caee4fa7eaf4491',16 'reference' => 'f1c7c9a53894452db42cd6f4ee7b86eb879816f1', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
headless/trunk/README.txt
r3072776 r3196946 4 4 Tags: gutenberg, block, developer, utils 5 5 Requires at least: 5.0 6 Tested up to: 6. 5.26 Tested up to: 6.6.2 7 7 Requires PHP: 8.0 8 8 Stable tag: 2.2.4 … … 27 27 28 28 == Changelog == 29 30 = 2.3.0 = 31 * Feature: Revalidate feature can be deactivated via hook 32 * Feature: Preview feature can be deactivated via hook 33 * Update: NPM Packages 29 34 30 35 = 2.2.4 = -
headless/trunk/classes/Ajax.php
r3060628 r3196946 13 13 const GET_POST_ID = "post_id"; 14 14 15 public function onCreate() {15 public function onCreate(): void { 16 16 parent::onCreate(); 17 17 add_action('wp_ajax_'.self::GET_ACTION, [$this, 'revalidate']); -
headless/trunk/classes/Components/Assets.php
r2766747 r3196946 4 4 namespace Palasthotel\WordPress\Headless\Components; 5 5 6 /**7 * Class Assets8 * @property Plugin plugin9 * @version 0.1.210 */11 6 class Assets { 12 7 13 public function __construct( Plugin $plugin ) { 8 private Plugin $plugin; 9 10 public function __construct(Plugin $plugin) { 14 11 $this->plugin = $plugin; 15 12 } 16 13 17 public function registerStyle( string $handle, string $pluginPathToFile, array $dependencies = [], string $media = 'all'): bool {14 public function registerStyle(string $handle, string $pluginPathToFile, array $dependencies = [], string $media = 'all'): bool { 18 15 $filePath = $this->plugin->path . $pluginPathToFile; 19 $fileUrl = $this->plugin->url . $pluginPathToFile;20 if ( ! file_exists( $filePath )) {21 error_log( "Style file does not exist: $filePath");16 $fileUrl = $this->plugin->url . $pluginPathToFile; 17 if (!file_exists($filePath)) { 18 error_log("Style file does not exist: $filePath"); 22 19 23 20 return false; 24 21 } 25 22 26 return wp_register_style( $handle, $fileUrl, $dependencies, filemtime( $filePath ), $media);23 return wp_register_style($handle, $fileUrl, $dependencies, filemtime($filePath), $media); 27 24 28 25 } 29 26 30 public function registerScript( string $handle, string $pluginPathToFile, array $dependencies = [], bool $footer = true): bool {27 public function registerScript(string $handle, string $pluginPathToFile, array $dependencies = [], bool $footer = true): bool { 31 28 $filePath = $this->plugin->path . $pluginPathToFile; 32 if ( ! file_exists( $filePath )) {33 error_log( "Script file does not exist: $filePath");29 if (!file_exists($filePath)) { 30 error_log("Script file does not exist: $filePath"); 34 31 35 32 return false; 36 33 } 37 34 $assetsFilePath = ""; 38 if ( $this->endsWithJS( $filePath )) {39 $assetsFilePath = str_replace( ".js", ".asset.php", $filePath);35 if ($this->endsWithJS($filePath)) { 36 $assetsFilePath = str_replace(".js", ".asset.php", $filePath); 40 37 } 41 if ( ! empty( $assetsFilePath ) && file_exists( $assetsFilePath )) {38 if (!empty($assetsFilePath) && file_exists($assetsFilePath)) { 42 39 $info = include $assetsFilePath; 43 40 } else { 44 41 $info["dependencies"] = []; 45 $info["version"] = filemtime( $filePath);42 $info["version"] = filemtime($filePath); 46 43 } 47 44 … … 49 46 $handle, 50 47 $this->plugin->url . $pluginPathToFile, 51 array_merge( $info["dependencies"], $dependencies),48 array_merge($info["dependencies"], $dependencies), 52 49 $info["version"], 53 50 $footer … … 56 53 } 57 54 58 private function endsWithJS( $haystack): bool {59 $length = strlen( ".js");60 if ( ! $length) {55 private function endsWithJS($haystack): bool { 56 $length = strlen(".js"); 57 if (!$length) { 61 58 return true; 62 59 } 63 60 64 return substr( $haystack, - $length) === ".js";61 return substr($haystack, -$length) === ".js"; 65 62 } 66 63 } -
headless/trunk/classes/Components/Component.php
r2730402 r3196946 4 4 namespace Palasthotel\WordPress\Headless\Components; 5 5 6 /**7 * Class Component8 *9 * @property \Palasthotel\WordPress\Headless\Plugin plugin10 *11 * @package Palasthotel\WordPress12 * @version 0.1.213 */14 6 abstract class Component { 15 /** 16 * _Component constructor. 17 * 18 * @param \Palasthotel\WordPress\Headless\Plugin $plugin 19 */ 20 public function __construct(Plugin $plugin) { 21 $this->plugin = $plugin; 7 8 public function __construct( 9 public \Palasthotel\WordPress\Headless\Plugin $plugin 10 ) { 22 11 $this->onCreate(); 23 12 } … … 26 15 * overwrite this method in component implementations 27 16 */ 28 public function onCreate() {17 public function onCreate(): void { 29 18 // init your hooks and stuff 30 19 } -
headless/trunk/classes/Components/Database.php
r2766747 r3196946 6 6 use wpdb; 7 7 8 /**9 * @property wpdb wpdb10 * @version 0.1.111 */12 8 abstract class Database { 9 10 protected wpdb $wpdb; 13 11 14 12 public function __construct() { … … 21 19 * initialize table names and other properties 22 20 */ 23 abstract function init() ;24 25 public function createTables() {21 abstract function init(): void; 22 23 public function createTables(): void { 26 24 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 27 25 } -
headless/trunk/classes/Components/Plugin.php
r2730402 r3196946 6 6 use ReflectionException; 7 7 8 /**9 * @property string path10 * @property string url11 * @property string basename12 * @version 0.1.313 */14 8 abstract class Plugin { 15 9 … … 18 12 */ 19 13 private $ref; 20 21 14 private $tooLateForTextdomain; 15 public $path; 16 public $url; 17 public $basename; 22 18 23 19 /** … … 34 30 $this->tooLateForTextdomain = true; 35 31 36 register_activation_hook( $this->ref->getFileName(), array( $this, "onActivation" ));37 register_deactivation_hook( $this->ref->getFileName(), array( $this, "onDeactivation" ));32 register_activation_hook( $this->ref->getFileName(), [$this, "onActivation"]); 33 register_deactivation_hook( $this->ref->getFileName(), [$this, "onDeactivation"]); 38 34 39 35 } … … 80 76 $domain, 81 77 false, 82 dirname( plugin_basename( $this->ref->getFileName() ) ) . "/" . $relativeLanguagesPath78 dirname(plugin_basename($this->ref->getFileName())) . "Plugin.php/" . $relativeLanguagesPath 83 79 ); 84 80 } ); … … 88 84 if ( function_exists( 'is_multisite' ) && is_multisite() ) { 89 85 $network_site = get_network()->site_id; 90 $args = array( 'fields' => 'ids' );86 $args = ['fields' => 'ids']; 91 87 $site_ids = get_sites( $args ); 92 88 -
headless/trunk/classes/Dashboard.php
r3060628 r3196946 4 4 5 5 class Dashboard extends Components\Component { 6 public function onCreate() {6 public function onCreate(): void { 7 7 parent::onCreate(); 8 8 add_action('wp_dashboard_setup', [$this, 'setup']); … … 12 12 if(!current_user_can('edit_posts')) return; 13 13 14 wp_add_dashboard_widget( 15 Plugin::DOMAIN, 16 __("Headless", Plugin::DOMAIN), 17 array($this, 'render') 18 ); 14 if($this->plugin->revalidate->isRevalidationActive()){ 15 wp_add_dashboard_widget( 16 Plugin::DOMAIN, 17 __("Headless", Plugin::DOMAIN), 18 array($this, 'render') 19 ); 20 } 19 21 } 20 22 -
headless/trunk/classes/Extensions.php
r2791162 r3196946 33 33 private TermRouteExtensions $termRouteExtensions; 34 34 35 public function onCreate() {35 public function onCreate(): void { 36 36 parent::onCreate(); 37 37 -
headless/trunk/classes/Headers.php
r2791162 r3196946 4 4 5 5 class Headers extends Components\Component { 6 public function onCreate() {6 public function onCreate(): void { 7 7 parent::onCreate(); 8 8 add_filter('rest_post_dispatch', [$this, 'rest_post_dispatch']); -
headless/trunk/classes/Log.php
r2901812 r3196946 9 9 private $log; 10 10 11 public function onCreate() {11 public function onCreate(): void { 12 12 parent::onCreate(); 13 13 add_action("cron_logger_init", function(\CronLogger\Plugin $logger){ -
headless/trunk/classes/Migration.php
r2977228 r3196946 14 14 } 15 15 16 public function onCreate() {16 public function onCreate(): void { 17 17 parent::onCreate(); 18 18 … … 20 20 // drop every table that was created before version 3 21 21 $tableName = $this->plugin->dbRevalidation->table; 22 $this->plugin->dbRevalidation->wpdb->query("DROP TABLE IF EXISTS $tableName"); 22 global $wpdb; 23 $wpdb->query("DROP TABLE IF EXISTS $tableName"); 23 24 $this->plugin->dbRevalidation->createTables(); 24 25 $this->setSchemaVersion(3); -
headless/trunk/classes/PluginAssets.php
r2901812 r3196946 6 6 use Palasthotel\WordPress\Headless\Components\Component; 7 7 8 /**9 * @property Assets $assets10 */11 8 class PluginAssets extends Component { 12 9 … … 15 12 const HANDLE_GUTENBERG_STYLE = "headless_gutenberg_styles"; 16 13 17 public function onCreate() { 14 public Assets $assets; 15 16 public function onCreate(): void { 18 17 parent::onCreate(); 19 18 … … 60 59 "HeadlessAdmin", 61 60 [ 61 "revalidate_is_active" => $this->plugin->revalidate->isRevalidationActive(), 62 "preview_is_active" => $this->plugin->preview->isPreviewActive(), 62 63 "preview_path" => $this->plugin->preview->getHeadlessPreviewPath(), 63 64 "frontends" => array_map(function($frontend){ -
headless/trunk/classes/Post.php
r2868064 r3196946 8 8 9 9 class Post extends Component { 10 public function onCreate() {10 public function onCreate(): void { 11 11 parent::onCreate(); 12 12 add_filter( Plugin::FILTER_PREPARE_POST, [ $this, 'prepare_post' ], 10, 2 ); -
headless/trunk/classes/Preview.php
r2901812 r3196946 10 10 const POST_ID_PLACEHOLDER = "{{post_id}}"; 11 11 12 public function onCreate() {12 public function onCreate(): void { 13 13 parent::onCreate(); 14 14 … … 16 16 add_action( 'wp_ajax_headless_preview', [ $this, 'admin_preview' ] ); 17 17 add_action( 'wp_ajax_nopriv_headless_preview', [ $this, 'no_permission' ] ); 18 add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ] ); 18 19 } 20 21 19 22 20 23 public function getRedirectLink( $id ) { … … 81 84 } 82 85 86 public function plugins_loaded() { 87 remove_filter( 'preview_post_link', [ $this, 'preview_post_link' ] ); 88 remove_action( 'wp_ajax_headless_preview', [ $this, 'admin_preview' ] ); 89 remove_action( 'wp_ajax_nopriv_headless_preview', [ $this, 'no_permission' ] ); 90 } 91 92 function isPreviewInactive() { 93 return !$this->isPreviewActive(); 94 } 95 function isPreviewActive() { 96 return apply_filters(Plugin::FILTER_PREVIEW_IS_ACTIVE, true); 97 } 83 98 84 99 } -
headless/trunk/classes/Query.php
r3060647 r3196946 15 15 const POST_TYPE = "hl_post_type"; 16 16 17 public function onCreate() {17 public function onCreate(): void { 18 18 parent::onCreate(); 19 19 -
headless/trunk/classes/Revalidate.php
r3060628 r3196946 8 8 class Revalidate extends Component { 9 9 10 public function onCreate() {10 public function onCreate(): void { 11 11 parent::onCreate(); 12 12 add_action('save_post', [$this, 'on_post_change']); … … 16 16 17 17 public function on_post_change($post_id){ 18 if($this->isRevalidationInactive()) return; 18 19 if(wp_is_post_revision($post_id)) return; 19 20 $this->plugin->dbRevalidation->addPost($post_id); … … 21 22 22 23 public function on_comment_change($comment_id){ 24 if($this->isRevalidationInactive()) return; 23 25 $comment = get_comment($comment_id); 24 26 $this->plugin->dbRevalidation->addPost($comment->comment_post_ID); … … 27 29 28 30 function revalidateComments($post_id){ 31 32 if($this->isRevalidationInactive()) return[]; 33 29 34 $frontends = $this->plugin->headquarter->getFrontends(); 30 35 $results = []; … … 44 49 */ 45 50 function revalidatePost($post_id) { 51 52 if($this->isRevalidationInactive()) return []; 53 46 54 $frontends = $this->plugin->headquarter->getFrontends(); 47 55 $results = []; … … 54 62 55 63 function revalidateByPathByPostId(Frontend $frontend, $post_id) { 64 65 if($this->isRevalidationInactive()) return []; 66 56 67 $permalink = get_permalink($post_id); 57 68 $path = parse_url($permalink, PHP_URL_PATH); … … 63 74 64 75 function revalidateByPath(Frontend $frontend, $path){ 76 77 if($this->isRevalidationInactive()) return []; 78 65 79 $baseUrl = $frontend->getBaseUrl(); 66 80 $url = untrailingslashit($baseUrl)."/api/revalidate?secret_token=".HEADLESS_SECRET_TOKEN."&path=".urlencode($path); … … 71 85 72 86 function revalidateByTag(Frontend $frontend, string $tag) { 87 88 if($this->isRevalidationInactive()) return []; 89 73 90 $baseUrl = $frontend->getBaseUrl(); 74 91 $url = untrailingslashit($baseUrl)."/api/revalidate?secret_token=".HEADLESS_SECRET_TOKEN."&tag=".urlencode($tag); … … 79 96 80 97 private function executeRavalidation($finalUrl){ 98 81 99 $url = add_query_arg('invalidate___cache', time(), $finalUrl); 82 100 … … 94 112 } 95 113 114 function isRevalidationInactive() { 115 return !$this->isRevalidationActive(); 116 } 117 function isRevalidationActive() { 118 return apply_filters(Plugin::FILTER_REVALIDATE_IS_ACTIVE, true); 119 } 120 96 121 97 122 } -
headless/trunk/classes/Routes.php
r2730402 r3196946 7 7 use Palasthotel\WordPress\Headless\Routes\Settings; 8 8 9 /**10 * @property Menus $menus11 * @property Settings $settings12 */13 9 class Routes extends Components\Component { 14 10 15 public function onCreate() { 11 public Menus $menus; 12 public Settings $settings; 13 14 public function onCreate(): void { 16 15 parent::onCreate(); 17 16 add_action( 'rest_api_init', [ $this, 'rest_api_init' ] ); -
headless/trunk/classes/Routes/Menus.php
r2730402 r3196946 8 8 class Menus extends Component { 9 9 10 private $menu;10 private array|false $menu; 11 11 12 12 public function init(){ -
headless/trunk/classes/Routes/Settings.php
r2730402 r3196946 8 8 class Settings extends Component { 9 9 10 public function init() {10 public function init(): void { 11 11 register_rest_route( Plugin::REST_NAMESPACE, '/settings', array( 12 12 'methods' => \WP_REST_Server::READABLE, … … 19 19 } 20 20 21 public function get_settings() {21 public function get_settings(): array { 22 22 return [ 23 23 "front_page" => get_option( 'show_on_front' ), 24 "page_on_front" => get_option( 'page_on_front'),24 "page_on_front" => intval(get_option( 'page_on_front' )), 25 25 "home_url" => home_url(), 26 26 ]; -
headless/trunk/classes/Schedule.php
r3060628 r3196946 7 7 class Schedule extends Component { 8 8 9 public function onCreate() {9 public function onCreate(): void { 10 10 parent::onCreate(); 11 11 … … 15 15 16 16 public function init(){ 17 if($this->plugin->revalidate->isRevalidationInactive()){ 18 $next = $this->getNextSchedule(); 19 if($next){ 20 wp_unschedule_event($next, Plugin::SCHEDULE_REVALIDATE); 21 } 22 return; 23 } 17 24 if(!wp_next_scheduled(Plugin::SCHEDULE_REVALIDATE)){ 18 25 wp_schedule_event(time(), 'hourly', Plugin::SCHEDULE_REVALIDATE); … … 33 40 34 41 public function revalidate(){ 42 43 if($this->plugin->revalidate->isRevalidationInactive()) return; 44 35 45 $lastRun = $this->getLastRevalidationRun(); 36 46 $now = time(); -
headless/trunk/classes/Security.php
r3020918 r3196946 7 7 class Security extends Component { 8 8 9 public function onCreate() {9 public function onCreate(): void { 10 10 parent::onCreate(); 11 11 add_filter('wp_is_application_passwords_available', '__return_true'); -
headless/trunk/classes/Store/RevalidationDatabase.php
r3060628 r3196946 7 7 use Palasthotel\WordPress\Headless\Components\Database; 8 8 9 /**10 * @property string $table11 */12 9 class RevalidationDatabase extends Database { 13 10 … … 15 12 const TYPE_COMMENT = "comment"; 16 13 17 function init() { 14 public string $table; 15 16 function init(): void { 18 17 $this->table = $this->wpdb->prefix . "headless_revalidate"; 19 18 } … … 104 103 } 105 104 106 public function createTables() {105 public function createTables(): void { 107 106 parent::createTables(); 108 107 \dbDelta("CREATE TABLE IF NOT EXISTS $this->table … … 112 111 content_type varchar(40) NOT NULL, 113 112 revalidation_state varchar(30), 114 revalidated_at TIMESTAMP default null,113 revalidated_at TIMESTAMP NULL default null, 115 114 primary key (id), 116 115 key (content_id), -
headless/trunk/dist/admin.asset.php
r3072776 r3196946 1 <?php return array('dependencies' => array(), 'version' => ' ecdaf49b7e3ddff3eb2a');1 <?php return array('dependencies' => array(), 'version' => '8241f02c6df14b01c628'); -
headless/trunk/dist/admin.js
r3072776 r3196946 1 !function(){"use strict";window.addEventListener("DOMContentLoaded",(async()=>{await Promise.all(window.HeadlessAdmin.frontends.map((e=>e+window.HeadlessAdmin.preview_path)).map((e=>fetch(e,{credentials:"include"}).then((e=>e.json())))))}))}();1 (()=>{"use strict";window.addEventListener("DOMContentLoaded",(async()=>{window.HeadlessAdmin.preview_is_active&&await Promise.all(window.HeadlessAdmin.frontends.map((e=>e+window.HeadlessAdmin.preview_path)).map((e=>fetch(e,{credentials:"include"}).then((e=>e.json())))))}))})(); -
headless/trunk/dist/gutenberg.asset.php
r3072776 r3196946 1 <?php return array('dependencies' => array('react ', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins'), 'version' => 'a2d2fb477c2bc904a66b');1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-element', 'wp-plugins'), 'version' => 'f64387f5a68638e1237e'); -
headless/trunk/dist/gutenberg.js
r3072776 r3196946 1 !function(){"use strict";var t=window.wp.plugins,e=window.React,n=window.wp.editPost,s=window.wp.components;var a=window.wp.data,i=window.wp.element;const r=()=>(0,a.useSelect)((t=>t("core/editor").getCurrentPost()),[]),o=({index:t,baseUrl:n,controller:s,onStateChanged:a})=>{const{state:o,reload:l}=(t=>{const[e,n]=(0,i.useState)("idle"),s=r(),a=(0,i.useMemo)((()=>s?.link?new URL(s?.link).pathname:""),[s.link]);return{state:e,reload:()=>{n("loading"),(async()=>{try{const e=await fetch(((t,e)=>window.Headless.ajax+`?action=${window.Headless.actions.revalidate}&frontend=${t}&path=${e}`)(t,a)),s=await e.json();s.success?n("success"):(console.error(s),n("error"))}catch(t){n("error")}})()}}})(t),c=r(),d=(0,i.useMemo)((()=>{const t=c.link,e=new URL(t);return n.replace(/^\/|\/$/g,"")+e.pathname}),[c.link]);return(0,i.useEffect)((()=>{s.add(t,l)}),[t]),(0,i.useEffect)((()=>{a(t,o)}),[o]),(0,e.createElement)("div",{title:d},(0,e.createElement)("a",{href:d,target:"_blank"},"Frontend ",t),"loading"==o&&(0,e.createElement)(e.Fragment,null," 🧹"),"success"==o&&(0,e.createElement)(e.Fragment,null," ✅"),"error"==o&&(0,e.createElement)(e.Fragment,null," 🚨"))};(0,t.registerPlugin)("headless-plugin",{icon:()=>null,render:function(){const t=window.Headless.frontends,a=(0,i.useMemo)((()=>(()=>{const t=new Map;return{add:(e,n)=>{t.set(e,n)},run:()=>{t.forEach((t=>{t()}))}}})()),[]),[l,c]=(0,i.useState)({}),d="publish"==r().status,p=Object.values(l).find((t=>1==t));return(0,e.createElement)(n.PluginDocumentSettingPanel,{title:"Headless"},d?(0,e.createElement)(e.Fragment,null,(0,e.createElement)("ol",null,t.map(((t,n)=>(0,e.createElement)("li",{key:n},(0,e.createElement)(o,{baseUrl:t,index:n,controller:a,onStateChanged:(t,e)=>{c((n=>{const s={...n};return s[t]="loading"==e,s}))}}))))),(0,e.createElement)(s.Button,{variant:"secondary",disabled:p||!d,onClick:()=>{a.run()}},"Revalidate cache")):(0,e.createElement)("p",{className:"description"},"Only published contents can be revalidated."))}}),document.addEventListener("DOMContentLoaded",(function(){const t=(0,a.select)("core/editor"),e=t.getCurrentPostId,n=t.isSavingPost,s=(0,a.dispatch)("core/editor"),i=s.autosave,r=s.savePost,o=document.createElement("a");o.className="components-button",o.addEventListener("click",(e=>{if(e.preventDefault(),n())return;const s=window.open("about:blank",o.target);!function(t){let e="";e+='\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t',e+='\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n ',t.write('\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n '),t.close()}(s.document),((()=>{const e=t.getCurrentPost().status;return"draft"==e||"auto-draft"==e})()?r:i)().then((()=>{s.location=o.href}))})),(0,a.subscribe)((()=>{n()?o.classList.add("is-disabled"):o.classList.remove("is-disabled")})),setInterval((function(){const t=e(),n=(t=>window.Headless.preview_url.replace(window.Headless.post_id_placeholder,`${t}`))(t),s=document.querySelectorAll("[target^=wp-preview-]");s&&s.length&&s.forEach((t=>{t.setAttribute("href",n)})),document.querySelectorAll(".components-snackbar-list .components-snackbar__content a.components-button").forEach((e=>{(e.href.includes("?post="+t)||e.href.includes("?page_id="+t)||e.href.includes("?p="+t))&&(e.href=n,e.target="wp-preview-"+t)}));const a=document.querySelectorAll(".components-menu-group");let i=null;if(a.forEach((t=>{t.querySelector(".editor-preview-dropdown__button-external")&&(i=t)})),!i)return;const r="headless-preview-link";if(i.querySelector("#"+r))return;const l=i.querySelector(".editor-preview-dropdown__button-external"),c=l.querySelector("svg"),d=l.getAttribute("target");o.text=l.textContent,o.append(c),o.target=d,o.href=n,o.id=r,l.style.display="none",i.querySelector('[role="group"]').append(o)}),300)}))}();1 (()=>{"use strict";const t=window.wp.plugins,e=window.wp.editPost,n=window.wp.components,s=window.wp.data,i=window.wp.element,a=()=>(0,s.useSelect)((t=>t("core/editor").getCurrentPost()),[]),r=window.ReactJSXRuntime,o=({index:t,baseUrl:e,controller:n,onStateChanged:s})=>{const{state:o,reload:l}=(t=>{const[e,n]=(0,i.useState)("idle"),s=a(),r=(0,i.useMemo)((()=>s?.link?new URL(s?.link).pathname:""),[s.link]);return{state:e,reload:()=>{n("loading"),(async()=>{try{const e=await fetch(((t,e)=>window.Headless.ajax+`?action=${window.Headless.actions.revalidate}&frontend=${t}&path=${e}`)(t,r)),s=await e.json();s.success?n("success"):(console.error(s),n("error"))}catch(t){n("error")}})()}}})(t),c=a(),d=(0,i.useMemo)((()=>{const t=c.link,n=new URL(t);return e.replace(/^\/|\/$/g,"")+n.pathname}),[c.link]);return(0,i.useEffect)((()=>{n.add(t,l)}),[t]),(0,i.useEffect)((()=>{s(t,o)}),[o]),(0,r.jsxs)("div",{title:d,children:[(0,r.jsxs)("a",{href:d,target:"_blank",children:["Frontend ",t]}),"loading"==o&&(0,r.jsx)(r.Fragment,{children:" 🧹"}),"success"==o&&(0,r.jsx)(r.Fragment,{children:" ✅"}),"error"==o&&(0,r.jsx)(r.Fragment,{children:" 🚨"})]})};window.HeadlessAdmin.revalidate_is_active&&(0,t.registerPlugin)("headless-plugin",{icon:()=>null,render:function(){const t=window.Headless.frontends,s=(0,i.useMemo)((()=>(()=>{const t=new Map;return{add:(e,n)=>{t.set(e,n)},run:()=>{t.forEach((t=>{t()}))}}})()),[]),[l,c]=(0,i.useState)({}),d="publish"==a().status,p=Object.values(l).find((t=>1==t));return(0,r.jsx)(e.PluginDocumentSettingPanel,{title:"Headless",children:d?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("ol",{children:t.map(((t,e)=>(0,r.jsx)("li",{children:(0,r.jsx)(o,{baseUrl:t,index:e,controller:s,onStateChanged:(t,e)=>{c((n=>{const s={...n};return s[t]="loading"==e,s}))}})},e)))}),(0,r.jsx)(n.Button,{variant:"secondary",disabled:p||!d,onClick:()=>{s.run()},children:"Revalidate cache"})]}):(0,r.jsx)("p",{className:"description",children:"Only published contents can be revalidated."})})}}),document.addEventListener("DOMContentLoaded",(function(){if(!window.HeadlessAdmin.preview_is_active)return;const t=(0,s.select)("core/editor"),e=t.getCurrentPostId,n=t.isSavingPost,i=(0,s.dispatch)("core/editor"),a=i.autosave,r=i.savePost,o=document.createElement("a");o.className="components-button",o.addEventListener("click",(e=>{if(e.preventDefault(),n())return;const s=window.open("about:blank",o.target);!function(t){let e="";e+='\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t',e+='\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n ',t.write('\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n\t\t\t}\n\t\t</style>\n\t\n <div class="editor-post-preview-button__interstitial-message">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96">\n <path class="outer" d="M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36" fill="none" />\n <path class="inner" d="M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z" fill="none" />\n </svg>\n <p>Generating preview…</p>\n </div>\n '),t.close()}(s.document),((()=>{const e=t.getCurrentPost().status;return"draft"==e||"auto-draft"==e})()?r:a)().then((()=>{s.location=o.href}))})),(0,s.subscribe)((()=>{n()?o.classList.add("is-disabled"):o.classList.remove("is-disabled")})),setInterval((function(){const t=e(),n=(t=>window.Headless.preview_url.replace(window.Headless.post_id_placeholder,`${t}`))(t),s=document.querySelectorAll("[target^=wp-preview-]");s&&s.length&&s.forEach((t=>{t.setAttribute("href",n)})),document.querySelectorAll(".components-snackbar-list .components-snackbar__content a.components-button").forEach((e=>{(e.href.includes("?post="+t)||e.href.includes("?page_id="+t)||e.href.includes("?p="+t))&&(e.href=n,e.target="wp-preview-"+t)}));const i=document.querySelectorAll(".components-menu-group");let a=null;if(i.forEach((t=>{t.querySelector(".editor-preview-dropdown__button-external")&&(a=t)})),!a)return;const r="headless-preview-link";if(a.querySelector("#"+r))return;const l=a.querySelector(".editor-preview-dropdown__button-external"),c=l.querySelector("svg"),d=l.getAttribute("target");o.text=l.textContent,o.append(c),o.target=d,o.href=n,o.id=r,l.style.display="none",a.querySelector('[role="group"]').append(o)}),300)}))})(); -
headless/trunk/headless.php
r3072776 r3196946 5 5 * Plugin URI: https://github.com/palasthotel/headless 6 6 * Description: Adds features to use WordPress as headless CMS 7 * Version: 2. 2.47 * Version: 2.5.0 8 8 * Author: Palasthotel (Edward Bock) <edward.bock@palasthotel.de> 9 9 * Author URI: http://www.palasthotel.de 10 10 * Requires at least: 5.0 11 * Tested up to: 6. 5.211 * Tested up to: 6.7.1 12 12 * Requires PHP: 8.0 13 13 * Text Domain: headless … … 53 53 require_once __DIR__ . "/vendor/autoload.php"; 54 54 55 /**56 * @property Routes $routes57 * @property Extensions $extensions58 * @property Security $security59 * @property Preview $preview60 * @property Query $query61 * @property Revalidate $revalidate62 * @property RevalidationDatabase $dbRevalidation63 * @property Schedule $schedule64 * @property PluginAssets $gutenberg65 * @property Headers $headers66 * @property Post $post67 * @property Dashboard $dashboard68 * @property Headquarter $headquarter69 * @property Ajax $ajax70 * @property Log $log71 */72 55 class Plugin extends Components\Plugin { 73 56 … … 77 60 const FILTER_IS_HEADLESS_POST_TYPE = "headless_is_headless_post_type"; 78 61 62 const FILTER_PREVIEW_IS_ACTIVE = "headless_preview_is_active"; 63 79 64 const FILTER_PREVIEW_REDIRECT_URL = "headless_preview_redirect_url"; 80 65 const FILTER_PREVIEW_URL = "headless_preview_url"; 66 const FILTER_REVALIDATE_IS_ACTIVE = "headless_revalidate_is_active"; 81 67 82 68 const ACTION_REGISTER_BLOCK_PREPARATION_EXTENSIONS = "headless_register_block_preparation_extensions"; … … 104 90 const OPTION_SCHEMA_VERSION = "headless_schema_version"; 105 91 92 public Routes $routes; 93 public Extensions $extensions; 94 public Security $security; 95 public Preview $preview; 96 public Query $query; 97 public Revalidate $revalidate; 98 public RevalidationDatabase $dbRevalidation; 99 public Schedule $schedule; 100 public PluginAssets $gutenberg; 101 public Headers $headers; 102 public Post $post; 103 public Dashboard $dashboard; 104 public Headquarter $headquarter; 105 public Ajax $ajax; 106 public Log $log; 106 107 107 function onCreate() {108 function onCreate(): void { 108 109 109 110 $this->dbRevalidation = new RevalidationDatabase(); -
headless/trunk/vendor/composer/installed.php
r3072776 r3196946 4 4 'pretty_version' => 'dev-main', 5 5 'version' => 'dev-main', 6 'reference' => ' 54dd1eeef2a9fb154922d1ca2caee4fa7eaf4491',6 'reference' => 'f1c7c9a53894452db42cd6f4ee7b86eb879816f1', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 14 14 'pretty_version' => 'dev-main', 15 15 'version' => 'dev-main', 16 'reference' => ' 54dd1eeef2a9fb154922d1ca2caee4fa7eaf4491',16 'reference' => 'f1c7c9a53894452db42cd6f4ee7b86eb879816f1', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.