-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcodetoblock.php
52 lines (49 loc) · 1.51 KB
/
shortcodetoblock.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
<?php
/**
* Plugin Name: Shortcode To Blocks
*
* @package sctob
**/
// Shortcode: Mi querido shortcode.
add_shortcode( 'mis_queridos_shortcodes', 'mis_queridos_shortcodes' );
/**
* Normal shortcode that print some div.
*
* @param array $atts atributos del shortcode.
* @param string $content contenido del shortcode.
*
* @return string shortcodes
*/
function mis_queridos_shortcodes( $atts, $content ) {
$atts = shortcode_atts(
array(
'align' => 'left',
'bgcolor' => '#FFF',
'title' => 'Estos son mis shortcode',
'attribute' => 'h2',
'content' => '',
),
$atts
);
$return = '<div style="text-align:' . esc_html( $atts['align'] ) . ';background-color:' . esc_html( $atts['bgcolor'] ) . '">';
$return .= '<' . esc_attr( $atts['attribute'] ) . '>' . esc_html( $atts['title'] ) . '</' . esc_attr( $atts['attribute'] ) . '>';
$return .= esc_html( $content );
$return .= '</div>';
return $return;
}
/**
* Print the same output that shortcode.
*
* @param array $atts atributos del shortcode.
*
* @return string shortcodes
*/
function print_this_block_output( $atts ) {
$return = '<div style="text-align:' . esc_html( $atts['align'] ) . ';background-color:' . esc_html( $atts['bgcolor'] ) . '">';
$return .= '<' . esc_attr( $atts['heading'] ) . '>' . esc_html( $atts['title'] ) . '</' . esc_attr( $atts['heading'] ) . '>';
$return .= esc_html( $atts['content'] );
$return .= '</div>';
return $return;
}
require 'fromphp/shortcodetoblock.php';
// require 'alljs/shortcodetoblock.php';