PluginProbe
My WP Customize Admin/Frontend / 1.16
My WP Customize Admin/Frontend v1.16
1.27.4 1.27.3 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10 1.10.1 1.10.2 1.11 1.12 1.12.1 1.12.2 1.13 1.13.1 1.13.2 1.14 1.15.0 1.16 1.17.0 All 76 releases
my-wp / shortcode / modules / mywp.shortcode.module.site.php

mywp.shortcode.module.site.php in My WP Customize Admin/Frontend 1.16, at shortcode/modules/mywp.shortcode.module.site.php

88 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if( ! class_exists( 'MywpShortcodeAbstractModule' ) ) {
8 return false;
9 }
10
11 if ( ! class_exists( 'MywpShortcodeModuleSite' ) ) :
12
13 final class MywpShortcodeModuleSite extends MywpShortcodeAbstractModule {
14
15 protected static $id = 'mywp_site';
16
17 public static function do_shortcode( $atts , $content = false , $tag ) {
18
19 if( empty( $atts['field'] ) ) {
20
21 MywpHelper::error_not_found_message( '$atts["field"]' , sprintf( '[%s] shortcode' , self::$id ) );
22
23 return $content;
24
25 }
26
27 $field = strip_tags( $atts['field'] );
28
29 $current_site_id = get_current_blog_id();
30
31 if( empty( $atts['site_id'] ) && empty( $atts['blog_id']) ) {
32
33 $site_id = get_current_blog_id();
34
35 } else {
36
37 if( ! empty( $atts['site_id'] ) ) {
38
39 $site_id = intval( $atts['site_id'] );
40
41 } elseif( ! empty( $atts['blog_id'] ) ) {
42
43 $site_id = intval( $atts['blog_id'] );
44
45 }
46
47 }
48
49 if( is_multisite() && $site_id !== $current_site_id ) {
50
51 switch_to_blog( $site_id );
52
53 }
54
55 if( $field === 'id' ) {
56
57 $content = $site_id;
58
59 } elseif( $field === 'name' ) {
60
61 $content = get_bloginfo( 'name' );
62
63 } else {
64
65 MywpHelper::error_not_found_message( '$atts["field"]' , sprintf( '[%s] shortcode' , self::$id ) );
66
67 return $content;
68
69 }
70
71 if( is_multisite() && $site_id !== $current_site_id ) {
72
73 restore_current_blog();
74
75 }
76
77 $content = apply_filters( 'mywp_shortcode_site' , $content , $atts );
78
79 return $content;
80
81 }
82
83 }
84
85 MywpShortcodeModuleSite::init();
86
87 endif;
88