PluginProbe
Flipbox / trunk
Flipbox vtrunk
trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.4.0
flipbox / includes / post-meta.php

post-meta.php in Flipbox trunk, at includes/post-meta.php

46 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if (!defined('ABSPATH')) {
5 exit;
6 }
7
8 class Flipbox_Post_Meta
9 {
10 public function __construct()
11 {
12 // `init` is an action, not a filter. add_filter() happened to work because both
13 // share one callback registry, but the callback returns null and would blank the
14 // value for anything that ever treats `init` as a filter.
15 add_action('init', array($this, 'register_meta'));
16 }
17
18 /**
19 * Register meta
20 */
21 public function register_meta()
22 {
23 register_meta(
24 'post',
25 '_eb_attr',
26 array(
27 'show_in_rest' => true,
28 'single' => true,
29 'auth_callback' => [$this, 'auth_callback'],
30 )
31 );
32 }
33
34 /**
35 * Determine if the current user can edit posts
36 *
37 * @return bool True when can edit posts, else false.
38 */
39 public function auth_callback()
40 {
41 return current_user_can('edit_posts');
42 }
43 }
44
45 new Flipbox_Post_Meta();
46