PluginProbe
Toggle Content / trunk
Toggle Content 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.2.6 1.2.8 1.3.0
toggle-content / includes / post-meta.php

post-meta.php in Toggle Content trunk, at includes/post-meta.php

43 lines 795 B
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 Toggle_Post_Meta
9 {
10 public function __construct()
11 {
12 add_action('init', array($this, 'register_meta'));
13 }
14
15 /**
16 * Register meta
17 */
18 public function register_meta()
19 {
20 register_meta(
21 'post',
22 '_eb_attr',
23 array(
24 'show_in_rest' => true,
25 'single' => true,
26 'auth_callback' => [$this, 'auth_callback'],
27 )
28 );
29 }
30
31 /**
32 * Determine if the current user can edit posts
33 *
34 * @return bool True when can edit posts, else false.
35 */
36 public function auth_callback()
37 {
38 return current_user_can('edit_posts');
39 }
40 }
41
42 new Toggle_Post_Meta();
43