PluginProbe
My WP Customize Admin/Frontend / trunk
My WP Customize Admin/Frontend vtrunk
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.theme.php

mywp.shortcode.module.theme.php in My WP Customize Admin/Frontend trunk, at shortcode/modules/mywp.shortcode.module.theme.php

90 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( 'MywpShortcodeModuleTheme' ) ) :
12
13 final class MywpShortcodeModuleTheme extends MywpShortcodeAbstractModule {
14
15 protected static $id = 'mywp_theme';
16
17 public static function do_shortcode( $atts = false , $content = false , $tag = false ) {
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 $theme_id = false;
30
31 $is_parent = false;
32
33 if( ! empty( $atts['parent'] ) ) {
34
35 $is_parent = true;
36
37 }
38
39 if( $is_parent ) {
40
41 $theme_id = get_template();
42
43 } else {
44
45 $theme_id = get_stylesheet();
46
47 }
48
49 if( empty( $theme_id ) ) {
50
51 MywpHelper::error_not_found_message( '$atts["theme"]' , sprintf( '[%s] shortcode' , self::$id ) );
52
53 return $content;
54
55 }
56
57 $theme = wp_get_theme( $theme_id );
58
59 if( $field === 'url' ) {
60
61 $content = MywpApi::get_theme_url( $is_parent );
62
63 } elseif( $field === 'path' ) {
64
65 $content = MywpApi::get_theme_path( $is_parent );
66
67 } elseif( $field === 'name' ) {
68
69 $content = $theme->get( 'Name' );
70
71 } else {
72
73 MywpHelper::error_not_found_message( '$atts["field"]' , sprintf( '[%s] shortcode' , self::$id ) );
74
75 return $content;
76
77 }
78
79 $content = apply_filters( 'mywp_shortcode_theme' , $content , $atts );
80
81 return $content;
82
83 }
84
85 }
86
87 MywpShortcodeModuleTheme::init();
88
89 endif;
90