forked from AesopInteractive/lasso
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lasso.php
executable file
·107 lines (80 loc) · 2.57 KB
/
lasso.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
*
*
* @package Editus
* @author Hyun Supul <[email protected]>, Nick Haskins <[email protected]>
* @link http://edituswp.com
* @copyright 2015-2017 Aesopinteractive
*
* Plugin Name: Editus
* Plugin URI: http://edituswp.com
* Description: Front-end editor and story builder.
* Version: 0.9.17.8
* Author: Aesopinteractive
* Author URI: http://aesopinteractive.com
* Text Domain: lasso
* Domain Path: /languages
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Set some constants
define( 'LASSO_VERSION', '0.9.17.8' );
define( 'LASSO_DIR', plugin_dir_path( __FILE__ ) );
define( 'LASSO_URL', plugins_url( '', __FILE__ ) );
define( 'LASSO_FILE', __FILE__ );
/**
* Load plugin if PHP version is 5.4 or later.
*/
if ( version_compare( PHP_VERSION, '5.4.0', '>=' ) ) {
include_once( LASSO_DIR . '/bootstrap.php' );
} else {
add_action('admin_head', 'lasso_fail_notice');
function lasso_fail_notice(){
printf('<div class="error"><p>Lasso requires PHP 5.4 or higher.</p></div>');
}
}
add_filter('register_post_type_args', 'lasso_show_in_rest', 10, 2);
function lasso_show_in_rest($args, $post_type){
$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( ) );
$allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
if (in_array( $post_type,$allowed_post_types)) {
$args['show_in_rest'] = true;
if ($post_type != 'post' && $post_type != 'page') {
$args['rest_base'] = $post_type;
}
}
return $args;
}
function lasso_editor_get_option( $option, $section, $default = '' ) {
if ( empty( $option ) )
return;
if ( function_exists( 'is_multisite' ) && is_multisite() ) {
$options = get_site_option( $section );
} else {
$options = get_option( $section );
}
if ( isset( $options[$option] ) ) {
return $options[$option];
}
return $default;
}
register_meta('user', 'lasso_hide_tour', array(
"type" => "string",
"show_in_rest" => true // this is the key part
));
/*function lasso_show_in_rest() {
global $wp_post_types;
$allowed_post_types = lasso_editor_get_option( 'allowed_post_types', 'lasso_editor', array( ) );
$allowed_post_types = apply_filters( 'lasso_allowed_post_types', $allowed_post_types );
foreach( $allowed_post_types as $key ) {
// If the post type doesn't exist, skip it
if( !$wp_post_types[$key] )
continue;
$wp_post_types[$key]->show_in_rest = true;
}
}
add_action( 'init', 'lasso_show_in_rest' );
*/