PluginProbe ʕ •ᴥ•ʔ
WP Job Manager / 2.4.7
WP Job Manager v2.4.7
2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.1.3 1.10.0 1.11.0 1.11.1 1.12.0 1.12.1 1.13.0 1.14.0 1.15.0 1.16.0 1.16.1 1.17.0 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.21.0 1.21.1 1.21.2 1.21.3 1.21.4 1.22.0 1.22.1 1.22.2 1.22.3 1.23.0 1.23.1 1.23.10 1.23.11 1.23.12 1.23.13 1.23.2 1.23.3 1.23.4 1.23.5 1.23.6 1.23.7 1.23.8 1.23.9 1.24.0 1.24.0.1 1.25.0 1.25.0.1 1.25.1 1.25.1.1 1.25.2 1.25.2.1 1.25.3 1.25.3.1 1.26.0 1.26.0.1 1.26.1 1.26.1.1 1.26.2 1.26.2.1 1.27.0 1.27.0.1 1.28.0 1.28.0.1 1.29.0 1.29.0.1 1.29.1 1.29.1.1 1.29.2 1.29.2.1 1.29.3 1.29.3.1 1.3.0 1.3.1 1.30.0 1.30.0.1 1.30.1 1.30.1.1 1.30.2 1.30.2.1 1.31.0 1.31.0.1 1.31.1 1.31.1.1 1.31.2 1.31.3 1.32.0 1.32.1 1.32.2 1.32.3 1.33.0 1.33.1 1.33.2 1.33.3 1.33.4 1.33.5 1.34.0 1.34.1 1.34.2 1.34.3 1.34.4 1.34.5 1.35.0 1.35.1 1.35.2 1.35.3 1.36.0 1.36.1 1.36.2 1.37.0 1.38.0 1.38.1 1.39.0 1.4.0 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 1.9.2 1.9.3 2.0.0 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.4.1
wp-job-manager / includes / class-wp-job-manager-blocks.php
wp-job-manager / includes Last commit date
3rd-party 3 days ago abstracts 3 months ago admin 2 weeks ago emails 2 weeks ago forms 3 days ago helper 3 months ago promoted-jobs 3 days ago ui 2 weeks ago widgets 2 weeks ago class-access-token.php 2 years ago class-dev-tools.php 2 years ago class-guest-session.php 2 years ago class-guest-user.php 2 years ago class-job-dashboard-shortcode.php 6 months ago class-job-listing-stats.php 2 years ago class-job-overlay.php 2 years ago class-stats-dashboard.php 2 years ago class-stats-script.php 3 months ago class-stats.php 3 months ago class-wp-job-manager-ajax.php 2 months ago class-wp-job-manager-api.php 6 years ago class-wp-job-manager-blocks.php 2 weeks ago class-wp-job-manager-cache-helper.php 3 months ago class-wp-job-manager-category-walker.php 6 years ago class-wp-job-manager-com-api.php 2 years ago class-wp-job-manager-data-cleaner.php 2 years ago class-wp-job-manager-data-exporter.php 3 months ago class-wp-job-manager-dependency-checker.php 2 years ago class-wp-job-manager-email-notifications.php 2 years ago class-wp-job-manager-forms.php 5 years ago class-wp-job-manager-geocode.php 2 weeks ago class-wp-job-manager-install.php 2 years ago class-wp-job-manager-post-types.php 3 days ago class-wp-job-manager-recaptcha.php 6 months ago class-wp-job-manager-rest-api.php 2 months ago class-wp-job-manager-shortcodes.php 2 weeks ago class-wp-job-manager-usage-tracking-data.php 2 years ago class-wp-job-manager-usage-tracking.php 2 years ago class-wp-job-manager-widget.php 2 weeks ago class-wp-job-manager.php 3 months ago trait-singleton.php 2 years ago
class-wp-job-manager-blocks.php
111 lines
1 <?php
2 /**
3 * Handles Job Manager's Gutenberg Blocks.
4 *
5 * @package wp-job-manager
6 * @since 1.32.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit; // Exit if accessed directly.
11 }
12
13 /**
14 * Class WP_Job_Manager_Blocks.
15 */
16 class WP_Job_Manager_Blocks {
17 /**
18 * The static instance of the WP_Job_Manager_Blocks
19 *
20 * @var self
21 */
22 private static $instance = null;
23
24 /**
25 * Singleton instance getter
26 *
27 * @return self
28 */
29 public static function get_instance() {
30 if ( ! self::$instance ) {
31 self::$instance = new WP_Job_Manager_Blocks();
32 }
33
34 return self::$instance;
35 }
36
37 /**
38 * Instance constructor
39 */
40 private function __construct() {
41 if ( ! function_exists( 'register_block_type' ) ) {
42 return;
43 }
44
45 add_action( 'init', [ $this, 'register_blocks' ] );
46 add_action( 'enqueue_block_editor_assets', [ $this, 'enable_legacy_widget_block' ] );
47 }
48
49 /**
50 * Register all Gutenblocks
51 */
52 public function register_blocks() {
53 // Add script includes for gutenblocks.
54 }
55
56 /**
57 * Enable the core Legacy Widget block in the Site Editor.
58 *
59 * On a block theme there is no classic Widgets screen, and the Site Editor
60 * does not expose the Legacy Widget block by default, so there is no UI to
61 * insert the plugin's classic widgets (Recent Jobs, Featured Jobs). Opting
62 * the block in here restores that path. Scoped to the Site Editor screen so
63 * the post/page editor is left untouched.
64 *
65 * The Site Editor registers `core/legacy-widget` itself with
66 * `supports.inserter: false`, so calling `registerLegacyWidgetBlock()` here
67 * would be a duplicate registration and log "Block core/legacy-widget is
68 * already registered". Instead, flip the inserter support flag on core's own
69 * registration via the `blocks.registerBlockType` filter.
70 *
71 * @see https://developer.wordpress.org/block-editor/how-to-guides/widgets/legacy-widget-block/
72 * @see https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/
73 */
74 public function enable_legacy_widget_block() {
75 if ( ! function_exists( 'get_current_screen' ) ) {
76 return;
77 }
78
79 $screen = get_current_screen();
80
81 if ( ! $screen || 'site-editor' !== $screen->id ) {
82 return;
83 }
84
85 if ( ! wp_script_is( 'wp-widgets', 'registered' ) ) {
86 return;
87 }
88
89 // `wp-widgets` loads before `wp-edit-site`, so the filter is in place
90 // before the Site Editor registers the block.
91 wp_enqueue_script( 'wp-widgets' );
92 wp_add_inline_script(
93 'wp-widgets',
94 'wp.hooks.addFilter(
95 "blocks.registerBlockType",
96 "wp-job-manager/enable-legacy-widget-inserter",
97 function ( settings, name ) {
98 if ( "core/legacy-widget" !== name ) {
99 return settings;
100 }
101 return Object.assign( {}, settings, {
102 supports: Object.assign( {}, settings.supports, { inserter: true } ),
103 } );
104 }
105 );'
106 );
107 }
108 }
109
110 WP_Job_Manager_Blocks::get_instance();
111