PluginProbe
LIQUID BLOCKS – Slider, Carousel, Accordion / 1.3.2
LIQUID BLOCKS – Slider, Carousel, Accordion v1.3.2
1.3.7 1.3.6 trunk 1.0 1.0.2 1.0.3 1.0.4 1.0.5 1.0.8 1.0.9 1.1.1 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5
liquid-blocks / liquid-blocks.php

liquid-blocks.php in LIQUID BLOCKS – Slider, Carousel, Accordion 1.3.2, at liquid-blocks.php

594 lines 24.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: LIQUID BLOCKS
4 Plugin URI: https://lqd.jp/wp/plugin.html
5 Description: A magic tool to master WordPress blocks.
6 Author: LIQUID DESIGN Ltd.
7 Author URI: https://lqd.jp/wp/
8 License: GPLv2
9 License URI: https://www.gnu.org/licenses/gpl-2.0.html
10 Text Domain: liquid-blocks
11 Version: 1.3.2
12 */
13 /* Copyright 2019 LIQUID DESIGN Ltd. (email : info@lqd.jp)
14
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License, version 2, as
17 published by the Free Software Foundation.
18
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 */
27
28 // ------------------------------------
29 // Plugin
30 // ------------------------------------
31 $liquid_blocks_data = get_file_data( __FILE__, array( 'version' => 'Version'));
32
33 // api
34 if ( is_admin() ) {
35 $liquid_blocks_api = require_once 'inc/api.php';
36 $liquid_blocks_json = $liquid_blocks_api('https://lqd.jp/wp/data/p/liquid-blocks.json', 'liquid_blocks_json');
37 }
38
39 // notices
40 function liquid_blocks_admin_notices() {
41 global $liquid_blocks_json;
42 if( !empty($liquid_blocks_json) ) {
43 if ( isset( $_GET['liquid_admin_notices_dismissed'] ) ) {
44 set_transient( 'liquid_admin_notices', 'dismissed', 60*60*24*30 );
45 }
46 if ( isset( $_GET['liquid_admin_offer_dismissed'] ) ) {
47 set_transient( 'liquid_admin_offer', 'dismissed', 60*60*24*30 );
48 }
49 if( !empty($liquid_blocks_json['news']) && get_transient( 'liquid_admin_notices' ) != 'dismissed' ){
50 echo '<div class="notice notice-info" style="position: relative;"><p>'.$liquid_blocks_json['news'].'</p><a href="?liquid_admin_notices_dismissed" style="position: absolute; right: 10px; top: 10px;">&times;</a></div>';
51 }
52 if( !empty($liquid_blocks_json['offer']) && get_transient( 'liquid_admin_offer' ) != 'dismissed' ){
53 echo '<div class="notice notice-info" style="position: relative;"><p>'.$liquid_blocks_json['offer'].'</p><a href="?liquid_admin_offer_dismissed" style="position: absolute; right: 10px; top: 10px;">&times;</a></div>';
54 }
55 }
56 }
57 add_action( 'admin_notices', 'liquid_blocks_admin_notices' );
58
59 // get_option
60 $liquid_blocks_toggle = get_option( 'liquid_blocks_toggle' );
61 $liquid_blocks_no = get_option( 'liquid_blocks_no' ) ? get_option( 'liquid_blocks_no' ) : [];
62 $liquid_blocks_type = get_option( 'liquid_blocks_type' ) ? get_option( 'liquid_blocks_type' ) : [];
63 $liquid_blocks_name = get_option( 'liquid_blocks_name' ) ? get_option( 'liquid_blocks_name' ) : [];
64 $liquid_blocks_clean = get_option( 'liquid_blocks_clean' ) ? get_option( 'liquid_blocks_clean' ) : [];
65 if( empty( $liquid_blocks_toggle ) ){
66 add_action( 'init', 'liquid_blocks_init' );
67 add_action( 'enqueue_block_assets', 'liquid_blocks_assets' );
68 add_action( 'enqueue_block_editor_assets', 'liquid_blocks_enqueue_block_editor_assets' );
69 add_action( 'admin_footer', 'liquid_blocks_admin_footer' );
70 }
71
72 // plugin_action_links
73 function liquid_blocks_plugin_action_links( $links ) {
74 $mylinks = '<a href="'.admin_url( 'options-general.php?page=liquid-blocks' ).'">'.__( 'Settings', 'liquid-blocks' ).'</a>';
75 array_unshift( $links, $mylinks);
76 return $links;
77 }
78 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), 'liquid_blocks_plugin_action_links' );
79
80 function liquid_blocks_assets() {
81 global $liquid_blocks_data;
82 wp_enqueue_style( 'liquid-blocks', plugins_url( 'css/block.css' , __FILE__ ), array( 'swiper' ), $liquid_blocks_data['version'] );
83 // slider
84 wp_enqueue_style( 'swiper', plugins_url( 'css/swiper-bundle.min.css' , __FILE__ ), array() );
85 wp_enqueue_script( 'swiper', plugins_url( 'lib/swiper-bundle.min.js' , __FILE__ ), array() );
86 wp_enqueue_script( 'liquid-blocks', plugins_url( 'lib/liquid-blocks.js' , __FILE__ ), array( 'swiper' ) );
87 }
88
89 function liquid_blocks_enqueue_block_editor_assets(){
90 global $liquid_blocks_data, $liquid_blocks_no, $liquid_blocks_type, $liquid_blocks_name;
91 wp_enqueue_script( 'clipboard' );
92 wp_enqueue_script( 'liquid-blocks-template', plugins_url( 'lib/template.js', __FILE__ ), array(), $liquid_blocks_data['version'] );
93 wp_enqueue_script( 'liquid-blocks', plugins_url( 'lib/block.js', __FILE__ ), array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-plugins', 'wp-edit-post', 'wp-components', 'liquid-blocks-template', 'clipboard' ), $liquid_blocks_data['version'] );
94 wp_enqueue_script( 'liquid-blocks-cards', plugins_url( 'lib/block-cards.js', __FILE__ ), array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-components' ) );
95 wp_set_script_translations( 'liquid-blocks', 'liquid-blocks', plugin_dir_path( __FILE__ ) . 'languages' );
96 wp_set_script_translations( 'liquid-blocks-cards', 'liquid-blocks', plugin_dir_path( __FILE__ ) . 'languages' );
97 wp_localize_script( 'liquid-blocks-template', 'liquid_blocks_imgurl', array( plugins_url( 'images/', __FILE__ ) ) );
98 wp_localize_script( 'liquid-blocks', 'liquid_blocks_imgurl', array( plugins_url( 'images/', __FILE__ ) ) );
99 wp_localize_script( 'liquid-blocks', 'liquid_blocks_no', $liquid_blocks_no );
100 wp_localize_script( 'liquid-blocks', 'liquid_blocks_type', $liquid_blocks_type );
101 wp_localize_script( 'liquid-blocks', 'liquid_blocks_name', $liquid_blocks_name );
102 wp_enqueue_style( 'liquid-blocks', plugins_url( 'css/block.css' , __FILE__ ), array(), $liquid_blocks_data['version'] );
103 wp_enqueue_style( 'liquid-blocks-editor', plugins_url( 'css/block-editor.css' , __FILE__ ), array(), $liquid_blocks_data['version'] );
104 }
105
106 function liquid_blocks_admin_footer() {
107 global $pagenow, $post;
108 if( $pagenow == 'post.php' || $pagenow == 'post-new.php' ){
109 if ( apply_filters( 'replace_editor', false, $post ) !== true ) {
110 if ( use_block_editor_for_post( $post ) ) {
111 ?>
112 <!-- Gallery -->
113 <div id="liquid_blocks_modal" class="liquid_blocks_modal" style="display:none;">
114 <div class="liquid_blocks_modal_gallery">
115
116 <?php
117 $args = array(
118 'post_type' => array( 'liquid_block' ),
119 'post_status' => array( 'publish' ),
120 'posts_per_page' => -1,
121 'order' => 'ASC',
122 );
123 $the_query = new WP_Query( $args );
124 if ( $the_query->have_posts() ) {
125 $i = 0;
126 echo '<h3>'.__( 'Block Patterns', 'liquid-blocks' ).' <small>Patterns</small></h3>';
127 echo '<script>LiquidGallery[\'Patterns\'] = []</script>';
128 while ( $the_query->have_posts() ) {
129 $j = $i + 1;
130 $the_query->the_post();
131 $pattern_title = get_the_title();
132 if( !$pattern_title ){
133 $pattern_title = __( 'Untitled block', 'liquid-blocks' );
134 }
135 $pattern_content = get_the_content();
136 $pattern_categories = array();
137 $terms = get_the_terms( 0, 'liquid_patterns' );
138 if( !empty( $terms ) && !is_wp_error( $terms ) ){
139 foreach( $terms as $term ){
140 $pattern_categories[] = $term->slug;
141 }
142 }
143 if( has_post_thumbnail() ) {
144 $thumbnail_id = get_post_thumbnail_id();
145 $src_info = wp_get_attachment_image_src($thumbnail_id, $size = array(600,400));
146 $src = $src_info[0];
147 $class = '';
148 } else {
149 $src = plugins_url( 'images/noimage.png', __FILE__ );
150 $class = 'liquid_noimage';
151 }
152 if( $pattern_content ){
153 $pattern_content = str_replace( array("\r", "\n"), '', $pattern_content );
154 echo '<script>LiquidGallery[\'Patterns\']['.$i.'] = \''.addslashes($pattern_content).'\';</script>';
155 echo '<a onclick="LiquidGalleryButton(LiquidGallery[\'Patterns\']['.$i.'], this)" class="liquid_blocks_img '.$class.'"><img src="'.$src.'" alt=""><span>'.$j.': '.$pattern_title.'</span></a>';
156 $i++;
157 }
158 }
159 wp_reset_postdata();
160 }
161 ?>
162
163 <h3><?php _e( 'Headlines', 'liquid-blocks' ); ?> <small>Headlines</small></h3>
164 <script>LiquidGalleryList('Headlines');</script>
165 <h3><?php _e( 'Layouts', 'liquid-blocks' ); ?> <small>Layouts</small></h3>
166 <script>LiquidGalleryList('Layouts');</script>
167 <h3><?php _e( 'Price list', 'liquid-blocks' ); ?> <small>Price</small></h3>
168 <script>LiquidGalleryList('Price');</script>
169 <h3><?php _e( 'CTA: Call To Action', 'liquid-blocks' ); ?> <small>CTA</small></h3>
170 <script>LiquidGalleryList('CTA');</script>
171 <h3><?php _e( 'Landing pages', 'liquid-blocks' ); ?> <small>Landing</small></h3>
172 <script>LiquidGalleryList('Landing');</script>
173 <h3><?php _e( 'Recommended Plugins', 'liquid-blocks' ); ?></h3>
174 <a href="https://wordpress.org/plugins/liquid-speech-balloon/" target="_blank"><img src="<?php echo plugins_url( 'images/Recommend/liquid-speech-balloon.png', __FILE__ ); ?>" alt=""></a>
175 </div>
176 </div>
177 <!-- Multiple -->
178 <div id="liquid_blocks_buttons" class="liquid_blocks_buttons">
179 <a id="liquid_blocks_copy" class="liquid_blocks_copy liquid_blocks_btn none"><?php _e( 'Copy', 'liquid-blocks' ); ?></a><script>LiquidGalleryCopy();</script>
180 <a id="liquid_blocks_insert" onclick="LiquidGalleryInsert()" class="liquid_blocks_btn none"><?php _e( 'Insert', 'liquid-blocks' ); ?><span id="liquid_blocks_count"></span></a>
181 <a id="liquid_blocks_multiple" onclick="LiquidGalleryMultiple()" class="liquid_blocks_btn"><?php _e( 'Select', 'liquid-blocks' ); ?></a>
182 <a id="liquid_blocks_cancel" onclick="LiquidGalleryCancel()" class="liquid_blocks_btn none"><?php _e( 'Cancel', 'liquid-blocks' ); ?></a>
183 <a id="liquid_blocks_close" onclick="LiquidGalleryClose()" class="liquid_blocks_btn"><?php _e( 'Close', 'liquid-blocks' ); ?></a>
184 </div>
185 <?php
186 }
187 }
188 }
189 }
190
191 // ------------------------------------
192 // init
193 // ------------------------------------
194
195 // block_categories
196 function liquid_block_categories($categories, $post) {
197 return array_merge(
198 $categories,
199 array(
200 array(
201 'slug' => 'liquid',
202 'title' => 'LIQUID',
203 ),
204 )
205 );
206 }
207 add_filter('block_categories_all', 'liquid_block_categories', 10, 2);
208
209 function liquid_blocks_init(){
210 global $liquid_blocks_clean;
211
212 // pattern_category
213 register_block_pattern_category(
214 'liquid_headlines',
215 array( 'label' => __( 'Headlines', 'liquid-blocks' ) )
216 );
217 // img_path
218 $path = plugins_url( 'images/', __FILE__ );
219
220 // TODO: register_block_pattern
221 // $pattern_name = 'liquid/pattern1';
222 // $pattern_properties = array(
223 // 'title' => 'Simple image',
224 // 'content' => '<!-- wp:image --><figure class="wp-block-image"><img src="'.$path.'bear.png" alt=""/></figure><!-- /wp:image --><!-- wp:heading {"align":"center"} --><h2 style="text-align:center">Lorem ipsum dolor sit amet</h2><!-- /wp:heading -->',
225 // 'categories' => array( 'liquid_headlines' ),
226 // 'keywords' => array( 'images' ),
227 // 'description'=> 'A simple text and image pattern.',
228 // );
229 // register_block_pattern( $pattern_name, $pattern_properties );
230
231 // translations
232 load_plugin_textdomain( 'liquid-blocks', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
233
234 // slider
235 register_block_type( 'liquid/slider', array(
236 'editor_script' => 'liquid-blocks-slider',
237 'editor_style' => 'liquid-blocks-editor',
238 'attributes' => array(
239 'fields' => array(
240 'type' => 'array',
241 ),
242 'delay' => array(
243 'type' => 'number',
244 ),
245 'slidesPerView' => array(
246 'type' => 'number',
247 ),
248 'animationType' => array(
249 'type' => 'string',
250 ),
251 ),
252 ) );
253 wp_register_script(
254 'liquid-blocks-slider',
255 plugins_url( 'lib/block-slider.js', __FILE__ ),
256 array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-components' )
257 );
258 wp_set_script_translations(
259 'liquid-blocks-slider',
260 'liquid-blocks',
261 plugin_dir_path( __FILE__ ) . 'languages'
262 );
263
264 // カスタムフィールド
265 register_block_type('liquid/custom-field', array(
266 'editor_script' => 'liquid-blocks-custom-field',
267 'render_callback' => 'liquid_blocks_render_custom_field',
268 ));
269 wp_register_script(
270 'liquid-blocks-custom-field',
271 plugin_dir_url(__FILE__) . 'lib/block-custom-field.js',
272 array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-block-editor', 'wp-components')
273 );
274 wp_set_script_translations(
275 'liquid-blocks-custom-field',
276 'liquid-blocks',
277 plugin_dir_path( __FILE__ ) . 'languages'
278 );
279
280 // unregister_block_pattern
281 if( !empty($liquid_blocks_clean) ){
282 unregister_block_pattern( 'core/heading-paragraph' );
283 unregister_block_pattern( 'core/large-header' );
284 unregister_block_pattern( 'core/large-header-button' );
285 unregister_block_pattern( 'core/quote' );
286 unregister_block_pattern( 'core/text-two-columns' );
287 unregister_block_pattern( 'core/text-two-columns-with-images' );
288 unregister_block_pattern( 'core/text-three-columns-buttons' );
289 unregister_block_pattern( 'core/three-buttons' );
290 unregister_block_pattern( 'core/two-buttons' );
291 unregister_block_pattern( 'core/two-images' );
292 }
293
294 // register_post_type
295 register_post_type(
296 'liquid_block',
297 array(
298 'public' => true,
299 'description' => __( 'Block Pattern Manager', 'liquid-blocks' ),
300 'hierarchical' => false,
301 'has_archive' => false,
302 'labels' => array(
303 'name' => __( 'Block Pattern', 'liquid-blocks' ),
304 'menu_name' => __( 'Block Pattern', 'liquid-blocks' ),
305 'singular_name' => __( 'Block Pattern', 'liquid-blocks' ),
306 'all_items' => __( 'Block Pattern List', 'liquid-blocks' ),
307 'add_new' => __( 'Add New', 'liquid-blocks' ),
308 'add_new_item' => __( 'Add New', 'liquid-blocks' ),
309 'edit_item' => __( 'Edit', 'liquid-blocks' ),
310 ),
311 'publicly_queryable' => false,
312 'show_ui' => true,
313 'show_in_menu' => false,
314 'show_in_nav_menus' => false,
315 'show_in_admin_bar' => true,
316 'capability_type' => 'post',
317 'menu_position' => 9,
318 'query_var' => false,
319 'exclude_from_search' => true,
320 'publicly_queryable' => false,
321 'supports' => array(
322 'title',
323 'editor',
324 'author',
325 'thumbnail',
326 ),
327 'taxonomies' => array('liquid_block'),
328 'show_in_rest' => true,
329 )
330 );
331 register_taxonomy(
332 'liquid_patterns',
333 'liquid_block',
334 array(
335 'label' => __( 'Block Pattern Category', 'liquid-blocks' ),
336 'hierarchical' => false,
337 'public' => false,
338 'show_ui' => true,
339 'show_in_rest' => true,
340 'show_tagcloud' => false,
341 'labels' => array(
342 'singular_name' => __( 'Block Pattern Category', 'liquid-blocks' ),
343 'add_new_item' => __( 'Add New', 'liquid-blocks' ),
344 'separate_items_with_commas' => __( 'Press the Enter key.', 'liquid-blocks' ),
345 ),
346 )
347 );
348
349 $terms = get_terms( array( 'taxonomy' => 'liquid_patterns', 'get'=>'all' ) );
350 if( !empty( $terms ) && !is_wp_error( $terms ) ){
351 foreach( $terms as $term ){
352 register_block_pattern_category(
353 $term->slug,
354 array( 'label' => $term->name )
355 );
356 }
357 }
358
359 // register_block_pattern self-made
360 $args = array(
361 'post_type' => array( 'liquid_block' ),
362 'post_status' => array( 'publish' ),
363 'posts_per_page' => -1,
364 'order' => 'ASC',
365 );
366 $the_query = new WP_Query( $args );
367 if ( $the_query->have_posts() ) {
368 $i = 0;
369 while ( $the_query->have_posts() ) {
370 $the_query->the_post();
371 $pattern_title = get_the_title();
372 if( !$pattern_title ){
373 $pattern_title = __( 'Untitled block', 'liquid-blocks' );
374 }
375 $pattern_content = get_the_content();
376 $pattern_categories = array();
377 $terms = get_the_terms( 0, 'liquid_patterns' );
378 if( !empty( $terms ) && !is_wp_error( $terms ) ){
379 foreach( $terms as $term ){
380 $pattern_categories[] = $term->slug;
381 }
382 }
383 if( $pattern_content ){
384 register_block_pattern(
385 'liquid/liquid_pattern_' . $i,
386 array(
387 'title' => $pattern_title,
388 'content' => $pattern_content,
389 'categories' => $pattern_categories,
390 )
391 );
392 $i++;
393 }
394 }
395 wp_reset_postdata();
396 }
397 }
398
399 // カスタムフィールドブロックのレンダリング
400 function liquid_blocks_render_custom_field($attributes) {
401 // カスタムフィールドキーと投稿IDの取得
402 $fieldKey = isset($attributes['fieldKey']) ? $attributes['fieldKey'] : '';
403 $postId = isset($attributes['postId']) && !empty($attributes['postId']) ? intval($attributes['postId']) : get_the_ID();
404
405 // フィールドタイプを取得(テキストか画像か)
406 $fieldType = isset($attributes['fieldType']) ? $attributes['fieldType'] : 'text';
407
408 // デフォルトの alignment を設定
409 $alignment = isset($attributes['alignment']) ? $attributes['alignment'] : 'left';
410
411 // 追加CSSクラスを取得
412 $customClass = isset($attributes['className']) ? $attributes['className'] : '';
413
414 // スタイル属性を構築
415 $style = 'text-align:' . esc_attr($alignment) . ';';
416
417 // カスタムフィールドデータの取得
418 if (!empty($fieldKey)) {
419 $fieldValue = get_post_meta($postId, $fieldKey, true);
420
421 // フィールドタイプに基づいて処理を分ける
422 if ($fieldType === 'image') {
423 // 画像の場合
424 if (is_array($fieldValue)) {
425 // 繰り返し画像フィールドの場合の処理
426 $output = '<div class="liquid_custom_field_repeatable">';
427 foreach ($fieldValue as $mediaId) {
428 $image_url = wp_get_attachment_url($mediaId);
429 if ($image_url) {
430 $output .= '<div class="liquid_custom_field_item"><img src="' . esc_url($image_url) . '" alt="" /></div>';
431 }
432 }
433 $output .= '</div>';
434 } else {
435 // 単一画像フィールドの場合
436 $image_url = wp_get_attachment_url($fieldValue);
437 if ($image_url) {
438 $output = '<div class="liquid_custom_field_item"><img src="' . esc_url($image_url) . '" alt="" /></div>';
439 }
440 }
441 } else {
442 // テキストの場合
443 if (is_array($fieldValue)) {
444 // 繰り返しテキストフィールドの場合の処理
445 $output = '<div class="liquid_custom_field_repeatable">';
446 foreach ($fieldValue as $value) {
447 $output .= '<div class="liquid_custom_field_item">' . esc_html($value) . '</div>';
448 }
449 $output .= '</div>';
450 } else {
451 // 単一テキストフィールドの場合の処理
452 $output = '<div class="liquid_custom_field_item">' . esc_html($fieldValue) . '</div>';
453 }
454 }
455
456 // 追加CSSクラスを適用してカスタムフィールドの�
457 容をスタイル付きのdivでラップ
458 return '<div class="liquid_custom_field ' . esc_attr($customClass) . '" style="' . esc_attr($style) . '">' . $output . '</div>';
459 } else {
460 return '<div class="liquid_custom_field ' . esc_attr($customClass) . '">' . __('No custom field selected.', 'liquid-blocks') . '</div>';
461 }
462 }
463
464 // ------------------------------------
465 // Admin
466 // ------------------------------------
467 function liquid_blocks_admin() {
468 add_options_page(
469 'LIQUID BLOCKS',
470 'LIQUID BLOCKS',
471 'administrator',
472 'liquid-blocks',
473 'liquid_blocks_admin_page'
474 );
475 add_theme_page(
476 __( 'Patterns', 'liquid-blocks' ),
477 __( 'Patterns', 'liquid-blocks' ),
478 'administrator',
479 'edit.php?post_type=liquid_block'
480 );
481 register_setting(
482 'liquid_blocks_group',
483 'liquid_blocks_toggle',
484 'liquid_blocks_toggle_validation'
485 );
486 register_setting(
487 'liquid_blocks_group',
488 'liquid_blocks_no'
489 );
490 register_setting(
491 'liquid_blocks_group',
492 'liquid_blocks_type'
493 );
494 register_setting(
495 'liquid_blocks_group',
496 'liquid_blocks_name'
497 );
498 register_setting(
499 'liquid_blocks_group',
500 'liquid_blocks_clean'
501 );
502 }
503 add_action( 'admin_menu', 'liquid_blocks_admin' );
504
505 function liquid_blocks_toggle_validation( $input ) {
506 $input = (int) $input;
507 if ( $input === 0 || $input === 1 ) {
508 return $input;
509 } else {
510 add_settings_error(
511 'liquid_blocks_toggle',
512 'liquid_blocks_toggle_validation_error',
513 __( 'illegal data', 'liquid-blocks' ),
514 'error'
515 );
516 }
517 }
518
519 function liquid_blocks_admin_page() {
520 global $liquid_blocks_json, $liquid_blocks_toggle, $liquid_blocks_no, $liquid_blocks_type, $liquid_blocks_name, $liquid_blocks_clean;
521 if( empty( $liquid_blocks_toggle ) ){
522 $toggle_on = 'checked="checked"';
523 $toggle_off = '';
524 } else {
525 $toggle_on = '';
526 $toggle_off = 'checked="checked"';
527 }
528 if( empty( $liquid_blocks_clean ) ){
529 $clean_on = 'checked="checked"';
530 $clean_off = '';
531 } else {
532 $clean_on = '';
533 $clean_off = 'checked="checked"';
534 }
535 ?>
536 <div class="wrap">
537 <h1>LIQUID BLOCKS</h1>
538
539 <div id="poststuff">
540
541 <!-- Recommend -->
542 <?php if( !empty($liquid_blocks_json) && !empty($liquid_blocks_json['recommend']) ){ ?>
543 <div class="postbox">
544 <h2 style="border-bottom: 1px solid #eee;"><?php _e( 'Recommend', 'liquid-blocks' ); ?></h2>
545 <div class="inside"><?php echo $liquid_blocks_json['recommend']; ?></div>
546 </div>
547 <?php } ?>
548
549 <!-- Settings -->
550 <div class="postbox">
551 <h2 style="border-bottom: 1px solid #eee;"><?php _e( 'Settings', 'liquid-blocks' ); ?></h2>
552 <div class="inside">
553 <form method="post" action="options.php">
554 <?php
555 settings_fields( 'liquid_blocks_group' );
556 do_settings_sections( 'default' );
557 ?>
558 <?php if ( function_exists('register_block_pattern') ) { ?>
559 <h3><?php _e( 'Block Pattern Manager', 'liquid-blocks' ); ?></h3>
560 <a href="edit.php?post_type=liquid_block" class="button button-primary"><?php _e( 'Block Pattern Manager', 'liquid-blocks' ); ?></a>
561 <p><?php _e( 'Featured Image', 'liquid-blocks' ); ?>: w600 x h400px</p>
562 <h3><?php _e( 'Enable default block pattern', 'liquid-blocks' ); ?></h3>
563 <p>
564 <label for="liquid_blocks_clean_on"><input type="radio" id="liquid_blocks_clean_on" name="liquid_blocks_clean" value="0" <?php echo $clean_on; ?>>On</label>
565 <label for="liquid_blocks_clean_off"><input type="radio" id="liquid_blocks_clean_off" name="liquid_blocks_clean" value="1" <?php echo $clean_off; ?>>Off</label>
566 </p>
567 <?php } ?>
568 <h3><?php _e( 'Shortcuts', 'liquid-blocks' ); ?></h3>
569 <p><?php _e( 'Sidebar shortcut button settings.', 'liquid-blocks' ); ?><br><?php _e( 'Enter any name, gallery category name, and number.', 'liquid-blocks' ); ?></p>
570 <?php
571 for ($i=0; $i<10; $i++) {
572 $j = $i + 1;
573 $no = !empty($liquid_blocks_no[$i]) ? $liquid_blocks_no[$i] : "";
574 $type = !empty($liquid_blocks_type[$i]) ? $liquid_blocks_type[$i] : "";
575 $name = !empty($liquid_blocks_name[$i]) ? $liquid_blocks_name[$i] : "";
576 echo '<p>'.$j.' Name:<input type="text" name="liquid_blocks_name['.$i.']" value="'.esc_html($name).'" placeholder="intro"> ';
577 echo 'Type:<input type="text" name="liquid_blocks_type['.$i.']" value="'.esc_html($type).'" placeholder="Headlines"> ';
578 echo 'No:<input type="number" name="liquid_blocks_no['.$i.']" value="'.esc_html($no).'"></p>';
579 }
580 ?>
581 <h3><?php _e( 'Enable', 'liquid-blocks' ); ?> LIQUID BLOCKS</h3>
582 <p>
583 <label for="liquid_blocks_toggle_on"><input type="radio" id="liquid_blocks_toggle_on" name="liquid_blocks_toggle" value="0" <?php echo $toggle_on; ?>>On</label>
584 <label for="liquid_blocks_toggle_off"><input type="radio" id="liquid_blocks_toggle_off" name="liquid_blocks_toggle" value="1" <?php echo $toggle_off; ?>>Off</label>
585 </p>
586 <?php submit_button(); ?>
587 </form>
588 </div>
589 </div>
590
591 </div><!-- /poststuff -->
592 <hr><a href="https://lqd.jp/wp/" target="_blank">LIQUID PRESS</a>
593 </div><!-- /wrap -->
594 <?php } ?>