PluginProbe
Document Embedder – let visitors read files without downloading / 1.8.6
Document Embedder – let visitors read files without downloading v1.8.6
2.3.1 2.3.0 2.2.1 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.3 1.7.4 1.7.6 1.7.9 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 All 30 releases
document-emberdder / blocks.php

blocks.php in Document Embedder – let visitors read files without downloading 1.8.6, at blocks.php

55 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if(!defined('ABSPATH')) {
3 return;
4 }
5
6 if(!class_exists('PPV_Block')){
7 class PPV_Block{
8 function __construct(){
9 // add_action('init', [$this, 'enqueue_block_css_js']);
10 add_action('init', [$this, 'enqueue_script']);
11 }
12
13 function enqueue_script(){
14 wp_register_script( 'ppv-blocks', plugin_dir_url( __FILE__ ).'dist/editor.js', array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'jquery' ), PPV_VER, true );
15
16 // wp_register_style( 'ppv-blocks', plugin_dir_url( __FILE__ ). 'dist/editor.css' , array(), PPV_VER );
17
18 wp_localize_script('ppv-blocks', 'ppvBlocks', [
19 'siteUrl' => site_url(),
20 'ajaxUrl' => admin_url('admin-ajax.php'),
21 'ppv_nonce' => wp_create_nonce( 'ppv_secret_nonce' )
22 ]);
23
24 register_block_type('meta-box/document-embedder', array(
25 'editor_script' => 'ppv-blocks',
26 // 'style' => 'ppv-blocks',
27 'render_callback' => function($attr, $content){
28 ob_start();
29
30 if(isset($attr['selected'])){
31 echo do_shortcode("[doc id=".esc_attr($attr['selected'])."]");
32 }else if(isset($attr['data']['tringle_text'])){
33 echo do_shortcode("[doc id=".esc_attr($attr['data']['tringle_text'])."]");
34 }
35 return ob_get_clean();
36 }
37 ));
38
39 register_block_type('kahf-kit/kahf-banner-k27f', array(
40 'editor_script' => 'ppv-blocks',
41 // 'style' => 'ppv-blocks',
42 'render_callback' => function($attr, $content){
43 return wpautop( $content );
44 }
45 ));
46
47
48 }
49
50 }
51
52 new PPV_Block();
53 }
54
55