PluginProbe
Pdf Embed / trunk
Pdf Embed vtrunk
0.6.2 0.6.1 trunk 0.1.0 0.1.1 0.1.2 0.1.3 0.1.4 0.1.5 0.1.6 0.1.7 0.1.8 0.1.9 0.2.0 0.2.1 0.2.2 0.2.3 0.2.4 0.2.5 0.2.6 0.2.7 0.2.8 0.2.9 0.3.0 0.3.1 All 54 releases
pdf-embed / build / render.php

render.php in Pdf Embed trunk, at build/render.php

40 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * PHP file to use when rendering the block type on the server to show on the front end.
4 *
5 * The following variables are exposed to the file:
6 * $attributes (array): The block attributes.
7 * $content (string): The block default content.
8 * $block (WP_Block): The block instance.
9 *
10 * @see https://github.com/WordPress/gutenberg/blob/trunk/docs/reference-guides/block-api/block-metadata.md#render
11 */
12
13 // Generate unique id for aria-controls.
14 $unique_id = wp_unique_id( 'pdf-' );
15
16 $p = new WP_HTML_Tag_Processor( $content );
17
18 $options = get_option( 'pdf_embed' );
19
20 if ( $p->next_tag(
21 array(
22 'tag_name' => 'DIV',
23 'class_name' => 'wp-block-tropicalista-pdfembed',
24 )
25 ) ) {
26 $p->set_attribute( 'id', $unique_id );
27 $p->set_attribute( 'data-client-id', $options['apiKey'] );
28 if ( ! empty( $p->get_attribute( 'data-mediaurl' ) ) ) {
29 $p->set_attribute( 'data-media-url', $p->get_attribute( 'data-mediaurl' ) );
30 }
31 if ( ! empty( $p->get_attribute( 'data-filename' ) ) ) {
32 $p->set_attribute( 'data-file-name', $p->get_attribute( 'data-filename' ) );
33 }
34 if ( empty( $p->get_attribute( 'data-config' ) ) ) {
35 $p->set_attribute( 'data-config', wp_json_encode( $options ) );
36 }
37 }
38
39 echo $p->get_updated_html();
40