Make WordPress Core

Ticket #35770: 35770.2.php

File 35770.2.php, 1.7 KB (added by aaroncampbell, 11 years ago)

MU plugin for testing

Line 
1<?php
2class test35770 {
3 private $_counter = 0;
4 public function __construct() {
5 add_action( 'init', array( $this, 'init' ) );
6 add_action( 'admin_notices', array( $this, 'admin_notices' ) );
7 }
8
9 public function init() {
10 add_shortcode( 'content_with_image', function( $atts, $shortcode_content = '' ){
11
12 $options = shortcode_atts( array(
13 'image_position' => 'left',
14 'image_size' => 'medium',
15 'image_id' => '',
16 'image_link' => '',
17 'content_margin_top' => '0',
18 'title' => '',
19 'title_tag' => 'h3',
20 'allow_content_below_image' => 'no',
21 'margin' => '40px 0',
22 ), $atts );
23
24 return 'shortcode content';
25
26 });
27
28 add_shortcode( 'content', function( $atts, $shortcode_content = '' ) {
29 return $shortcode_content;
30 } );
31
32 add_shortcode( 'content-do-shortcode', function( $atts, $shortcode_content = '' ) {
33 return do_shortcode( $shortcode_content );
34 } );
35 }
36
37 public function admin_notices() {
38 echo '<div class="notice notice-success"><h2>Testing 35770</h2><p>';
39 $image_shortcode = '[content_with_image image_position="left" image_id="198" content_margin_top="0" title="EXPERIENCED GUIDES" allow_content_below_image="no"]
40
41 Shortcode content
42
43 [/content_with_image]';
44 echo '<h2>Image Shortcode</h2>';
45 echo do_shortcode( $image_shortcode );
46 echo '<br><br>' . PHP_EOL;
47 echo '<h2>Image Shortcode in content shortcode</h2>';
48 echo do_shortcode( '[content]' . $image_shortcode . '[/content]' );
49 echo '<br><br>' . PHP_EOL;
50 echo '<h2>Image Shortcode in content shortcode using do_shortcode()</h2>';
51 echo do_shortcode( '[content-do-shortcode]' . $image_shortcode . '[/content-do-shortcode]' );
52 echo '</p></div>';
53 }
54}
55
56new test35770;