PluginProbe
Team Members Showcase / trunk
Team Members Showcase vtrunk
4.1.3 4.1.2 4.1.1 4.1.0 4.0.1 4.0.0 trunk 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.8 2.9.9 3.0.0 3.1.0 3.1.1 3.1.5 3.2.3 3.3.0 3.3.1 3.3.2 3.3.4 All 41 releases
wps-team / includes / shortcode.php

shortcode.php in Team Members Showcase trunk, at includes/shortcode.php

63 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 namespace WPSpeedo_Team;
4
5 if ( ! defined('ABSPATH') ) exit;
6
7 class Shortcode {
8
9 public function __construct() {
10 add_shortcode( 'wpspeedo-team', [ $this, 'shortcode'] );
11 }
12
13 public function load_settings( $sc_id ) {
14 $settings = plugin()->api->fetch_shortcode( $sc_id );
15 if ( empty($settings) ) return [];
16 return $settings['settings'];
17 }
18
19 public function shortcode( $args ) {
20
21 if ( empty($args['id']) ) return sprintf( '<h3>%s</h3>', esc_html__( 'Please provide a valid Team Shortcode ID.', 'wps-team' ) );
22
23 global $wps_team_id;
24
25 $wps_team_id = $args['id'];
26
27 $settings = (array) $this->load_settings( $args['id'] );
28
29 if ( empty( $settings ) ) {
30 return sprintf( '<h3>%s</h3>', sprintf(
31 /* translators: %s: shortcode ID */
32 __( 'Team Shortcode <strong>%s</strong> not found', 'wps-team' ),
33 esc_html( $args['id'] )
34 ));
35 }
36
37 ob_start();
38
39 global $shortcode_loader;
40
41 global $wps_team_is_builder;
42
43 $mode = 'public';
44
45 if ( $wps_team_is_builder ) {
46 $mode = 'builder';
47 }
48
49 $shortcode_loader = new Shortcode_Loader([
50 'id' => $args['id'],
51 'settings' => $settings,
52 'mode' => $mode
53 ]);
54
55 $shortcode_loader->load_template();
56
57 unset( $wps_team_id );
58
59 return ob_get_clean();
60
61 }
62
63 }