-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathlasso.php
More file actions
executable file
·228 lines (173 loc) · 6.69 KB
/
lasso.php
File metadata and controls
executable file
·228 lines (173 loc) · 6.69 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<?php
/**
*
*
* @package Editus
* @author Hyun Supul <hyun@aesopinteractive.com>, Nick Haskins <nick@aesopinteractive.com>
* @link http://edituswp.com
* @copyright 2015-2021 Aesopinteractive
*
* Plugin Name: Editus
* Plugin URI: http://edituswp.com
* Description: Front-end editor and story builder.
* Version: 1.7.0
* 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', '1.7.0' );
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>Editus 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
));
// Gutenberg
if( function_exists( 'is_gutenberg_page' ) ) {
function add_raw_to_post( $response, $post, $request ) {
$response_data = $response->get_data();
if ( is_array( $response_data['content'] )) {
$response_data['content']['raw'] = $post->post_content ;
$response->set_data( $response_data );
}
return $response;
}
add_filter( "rest_prepare_post", 'add_raw_to_post', 10, 3 );
}
//table codes to be added
class editus_table {
public function __construct(){
$add_table = lasso_editor_get_option('add_table', 'lasso_editor', false);
if ($add_table) {
add_action('wp_enqueue_scripts', array($this,'scripts'));
}
}
function scripts()
{
add_action('lasso_editor_controls_after_outside', array($this,'editus_table_edit_menu'));
add_filter('lasso_components',array($this,'editus_components_add_table'),10,1);
add_action( 'lasso_toolbar_components', array($this,'editus_toolbar_components_add_table'), 10 );
wp_enqueue_style( 'editus-table-style', LASSO_URL. '/public/assets/css/editus-table-edit-public.css', LASSO_VERSION, true );
wp_enqueue_script( 'editus_table', LASSO_URL. '/public/assets/js/editus-table-edit-public.js', array( 'jquery' ), LASSO_VERSION, true );
}
function editus_table_edit_menu()
{ ?>
<ul class='editus-table-menu'>
<li data-action="insertcol"><?php echo __('Insert Column','lasso')?></li>
<li data-action="insertrow"><?php echo __('Insert Row','lasso')?></li>
<li data-action="delcol"><?php echo __('Delete Column','lasso')?></li>
<li data-action="delrow"><?php echo __('Delete Row','lasso')?></li>
<li data-action="deltable"><?php echo __('Delete Table','lasso')?></li
</ul>
<?php
}
function editus_html_table()
{
return '<figure class="wp-block-table"><table><tr><th>Cell 1</th><th>Cell 2</th></tr><tr><td>Cell 3</td><td>Cell 4</td></tr></table></figure><p><br></p>';
}
function editus_components_add_table( $array ){
$custom = array(
'htmltable' => array(
'name' => __('HTML Table','lasso'),
'content' => self::editus_html_table(),
)
);
return array_merge( $array, $custom );
}
function editus_toolbar_components_add_table( ) {
?>
<li data-type="htmltable" title="<?php esc_attr_e( 'HTML Table', 'lasso' );?>" class="quote lasso-toolbar--component__htmltable dashicons dashicons-grid-view"></li>
<?php
}
}
new editus_table();
//table codes to be added
class editus_paragraph {
public function __construct(){
$add_paragraph = lasso_editor_get_option('add_paragraph', 'lasso_editor', false);
if ($add_paragraph) {
add_action('wp_enqueue_scripts', array($this,'scripts'));
}
}
function scripts()
{
add_action('lasso_editor_controls_after_outside', array($this,'editus_paragraph_style'));
add_filter('lasso_components',array($this,'editus_components_add_paragraph'),10,1);
add_action( 'lasso_toolbar_components', array($this,'editus_toolbar_components_add_paragraph'), 10 );
//wp_enqueue_style( 'editus-table-style', LASSO_URL. '/public/assets/css/editus-table-edit-public.css', LASSO_VERSION, true );
//wp_enqueue_script( 'editus_table', LASSO_URL. '/public/assets/js/editus-table-edit-public.js', array( 'jquery' ), LASSO_VERSION, true );
}
function editus_components_add_paragraph( $array ){
$custom = array(
'htmlparagraph' => array(
'name' => __('HTML Paragraph','lasso'),
'content' => self::editus_html_paragraph(),
)
);
return array_merge( $array, $custom );
}
function editus_html_paragraph()
{
return '<p contenteditable="true"><br></p>';
}
function editus_paragraph_style()
{ ?>
<style>
#lasso-toolbar--components__list .lasso-toolbar--component__htmlparagraph:before
{
content: "\f476";
font-family: 'dashicons' !important;
}
</style>
<?php
}
function editus_toolbar_components_add_paragraph( ) {
?>
<li data-type="htmlparagraph" title="<?php esc_attr_e( 'HTML Paragraph', 'lasso' );?>" class="quote lasso-toolbar--component__htmlparagraph dashicons dashicons-editor-paragraph"></li>
<?php
}
}
new editus_paragraph();