*/ private static $pending = array(); /** * Stamped rules from a report. * * @param array $report Report from process_content(). * @return array */ public static function stamped_values( array $report ) { $out = array(); foreach ( $report as $row ) { if ( isset( $row['value'] ) && is_array( $row['value'] ) ) { $out[] = $row['value']; } } return $out; } /** * After the post is written: queue gtfg_rule_saved for the rules stamped in it. * * @param int $post_id Post ID. * @param \WP_Post $post Post. */ public static function after_insert( $post_id, $post ) { $pending = self::$pending; self::$pending = array(); if ( ! $post instanceof \WP_Post || 'revision' === $post->post_type ) { return; } foreach ( $pending as $rule ) { Saved_Rules::queue( $rule, 'block', 'post:' . (int) $post_id ); } } /** * Before core's kses pass (content_save_pre, priority 10): re-encode the * attributes of blocks whose rule text contains angle brackets, the way the * block editor serializes them (as \u003c and \u003e). A client that wrote * raw brackets inside a block comment would otherwise have the whole block * comment entity-encoded by kses for users without unfiltered_html, which * turns the block (and its rule) into plain text. Only the encoding changes; * kses still runs afterwards on the result. Data arrives slashed. * * @param string $content Slashed content. * @return string */ public static function encode_before_kses( $content ) { if ( ! is_string( $content ) || ! self::has_rules( $content ) || current_user_can( 'unfiltered_html' ) ) { return $content; } $raw = wp_unslash( $content ); if ( ! preg_match( '/