Completed
Push — develop ( 88124f...45d990 )
by David
02:45 queued 02:45
created
src/public/class-wordlift-chord-shortcode.php 2 patches
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -16,89 +16,89 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Wordlift_Chord_Shortcode extends Wordlift_Shortcode {
18 18
 
19
-	/**
20
-	 * {@inheritdoc}
21
-	 */
22
-	const SHORTCODE = 'wl_chord';
23
-
24
-	/**
25
-	 * Create a {@link Wordlift_Chord_Shortcode} instance.
26
-	 *
27
-	 * @since      3.5.4
28
-	 */
29
-	public function __construct() {
30
-		parent::__construct();
31
-
32
-		// Hook to the `amp_post_template_css` to hide ourselves when in AMP
33
-		// rendering.
34
-		add_action( 'amp_post_template_css', array(
35
-			$this,
36
-			'amp_post_template_css',
37
-		) );
38
-
39
-	}
40
-
41
-	/**
42
-	 * {@inheritdoc}
43
-	 */
44
-	public function render( $atts ) {
45
-
46
-		//extract attributes and set default values
47
-		$chord_atts = shortcode_atts( array(
48
-			'width'      => '100%',
49
-			'height'     => '500px',
50
-			'main_color' => '000',
51
-			'depth'      => 2,
52
-			'global'     => false,
53
-		), $atts );
54
-
55
-		if ( $chord_atts['global'] ) {
56
-
57
-			if ( null === $post_id = wl_shortcode_chord_most_referenced_entity_id() ) {
58
-				return "WordLift Chord: no entities found.";
59
-			}
60
-
61
-			$widget_id = 'wl_chord_global';
62
-
63
-			// Use the provided height if any, otherwise use a default of 200px.
64
-			//
65
-			// See https://github.com/insideout10/wordlift-plugin/issues/443
66
-			$chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
67
-
68
-		} else {
69
-
70
-			$post_id   = get_the_ID();
71
-			$widget_id = 'wl_chord_' . $post_id;
72
-
73
-		}
74
-
75
-		// Adding css
76
-		wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
77
-
78
-		// Adding javascript code
79
-		wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
80
-
81
-		$this->enqueue_scripts();
82
-
83
-		wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
84
-				'ajax_url' => admin_url( 'admin-ajax.php' ),
85
-				'action'   => 'wl_chord',
86
-			)
87
-		);
88
-
89
-		// Escaping atts.
90
-		$esc_class  = esc_attr( 'wl-chord' );
91
-		$esc_id     = esc_attr( $widget_id );
92
-		$esc_width  = esc_attr( $chord_atts['width'] );
93
-		$esc_height = esc_attr( $chord_atts['height'] );
94
-
95
-		$esc_post_id    = esc_attr( $post_id );
96
-		$esc_depth      = esc_attr( $chord_atts['depth'] );
97
-		$esc_main_color = esc_attr( $chord_atts['main_color'] );
98
-
99
-		// Building template.
100
-		// TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
101
-		return <<<EOF
19
+    /**
20
+     * {@inheritdoc}
21
+     */
22
+    const SHORTCODE = 'wl_chord';
23
+
24
+    /**
25
+     * Create a {@link Wordlift_Chord_Shortcode} instance.
26
+     *
27
+     * @since      3.5.4
28
+     */
29
+    public function __construct() {
30
+        parent::__construct();
31
+
32
+        // Hook to the `amp_post_template_css` to hide ourselves when in AMP
33
+        // rendering.
34
+        add_action( 'amp_post_template_css', array(
35
+            $this,
36
+            'amp_post_template_css',
37
+        ) );
38
+
39
+    }
40
+
41
+    /**
42
+     * {@inheritdoc}
43
+     */
44
+    public function render( $atts ) {
45
+
46
+        //extract attributes and set default values
47
+        $chord_atts = shortcode_atts( array(
48
+            'width'      => '100%',
49
+            'height'     => '500px',
50
+            'main_color' => '000',
51
+            'depth'      => 2,
52
+            'global'     => false,
53
+        ), $atts );
54
+
55
+        if ( $chord_atts['global'] ) {
56
+
57
+            if ( null === $post_id = wl_shortcode_chord_most_referenced_entity_id() ) {
58
+                return "WordLift Chord: no entities found.";
59
+            }
60
+
61
+            $widget_id = 'wl_chord_global';
62
+
63
+            // Use the provided height if any, otherwise use a default of 200px.
64
+            //
65
+            // See https://github.com/insideout10/wordlift-plugin/issues/443
66
+            $chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
67
+
68
+        } else {
69
+
70
+            $post_id   = get_the_ID();
71
+            $widget_id = 'wl_chord_' . $post_id;
72
+
73
+        }
74
+
75
+        // Adding css
76
+        wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
77
+
78
+        // Adding javascript code
79
+        wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
80
+
81
+        $this->enqueue_scripts();
82
+
83
+        wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
84
+                'ajax_url' => admin_url( 'admin-ajax.php' ),
85
+                'action'   => 'wl_chord',
86
+            )
87
+        );
88
+
89
+        // Escaping atts.
90
+        $esc_class  = esc_attr( 'wl-chord' );
91
+        $esc_id     = esc_attr( $widget_id );
92
+        $esc_width  = esc_attr( $chord_atts['width'] );
93
+        $esc_height = esc_attr( $chord_atts['height'] );
94
+
95
+        $esc_post_id    = esc_attr( $post_id );
96
+        $esc_depth      = esc_attr( $chord_atts['depth'] );
97
+        $esc_main_color = esc_attr( $chord_atts['main_color'] );
98
+
99
+        // Building template.
100
+        // TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
101
+        return <<<EOF
102 102
 <div class="$esc_class" 
103 103
 	id="$esc_id"
104 104
 	data-post-id="$esc_post_id"
@@ -111,23 +111,23 @@  discard block
 block discarded – undo
111 111
         margin-bottom:10px">
112 112
 </div>
113 113
 EOF;
114
-	}
115
-
116
-	/**
117
-	 * Customize the CSS when in AMP.
118
-	 *
119
-	 * See https://github.com/Automattic/amp-wp/blob/master/readme.md#custom-css
120
-	 *
121
-	 * @since 3.14.0
122
-	 *
123
-	 * @param object $amp_template The template.
124
-	 */
125
-	public function amp_post_template_css( $amp_template ) {
126
-
127
-		// Hide the `wl-chord` when in AMP.
128
-		?>
114
+    }
115
+
116
+    /**
117
+     * Customize the CSS when in AMP.
118
+     *
119
+     * See https://github.com/Automattic/amp-wp/blob/master/readme.md#custom-css
120
+     *
121
+     * @since 3.14.0
122
+     *
123
+     * @param object $amp_template The template.
124
+     */
125
+    public function amp_post_template_css( $amp_template ) {
126
+
127
+        // Hide the `wl-chord` when in AMP.
128
+        ?>
129 129
 		.wl-chord { display: none; }
130 130
 		<?php
131
-	}
131
+    }
132 132
 
133 133
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -31,30 +31,30 @@  discard block
 block discarded – undo
31 31
 
32 32
 		// Hook to the `amp_post_template_css` to hide ourselves when in AMP
33 33
 		// rendering.
34
-		add_action( 'amp_post_template_css', array(
34
+		add_action('amp_post_template_css', array(
35 35
 			$this,
36 36
 			'amp_post_template_css',
37
-		) );
37
+		));
38 38
 
39 39
 	}
40 40
 
41 41
 	/**
42 42
 	 * {@inheritdoc}
43 43
 	 */
44
-	public function render( $atts ) {
44
+	public function render($atts) {
45 45
 
46 46
 		//extract attributes and set default values
47
-		$chord_atts = shortcode_atts( array(
47
+		$chord_atts = shortcode_atts(array(
48 48
 			'width'      => '100%',
49 49
 			'height'     => '500px',
50 50
 			'main_color' => '000',
51 51
 			'depth'      => 2,
52 52
 			'global'     => false,
53
-		), $atts );
53
+		), $atts);
54 54
 
55
-		if ( $chord_atts['global'] ) {
55
+		if ($chord_atts['global']) {
56 56
 
57
-			if ( null === $post_id = wl_shortcode_chord_most_referenced_entity_id() ) {
57
+			if (null === $post_id = wl_shortcode_chord_most_referenced_entity_id()) {
58 58
 				return "WordLift Chord: no entities found.";
59 59
 			}
60 60
 
@@ -63,38 +63,38 @@  discard block
 block discarded – undo
63 63
 			// Use the provided height if any, otherwise use a default of 200px.
64 64
 			//
65 65
 			// See https://github.com/insideout10/wordlift-plugin/issues/443
66
-			$chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
66
+			$chord_atts['height'] = isset($chord_atts['height']) ? $chord_atts['height'] : '200px';
67 67
 
68 68
 		} else {
69 69
 
70 70
 			$post_id   = get_the_ID();
71
-			$widget_id = 'wl_chord_' . $post_id;
71
+			$widget_id = 'wl_chord_'.$post_id;
72 72
 
73 73
 		}
74 74
 
75 75
 		// Adding css
76
-		wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
76
+		wp_enqueue_style('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css');
77 77
 
78 78
 		// Adding javascript code
79
-		wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
79
+		wp_enqueue_script('d3', dirname(plugin_dir_url(__FILE__)).'/bower_components/d3/d3.min.js');
80 80
 
81 81
 		$this->enqueue_scripts();
82 82
 
83
-		wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
84
-				'ajax_url' => admin_url( 'admin-ajax.php' ),
83
+		wp_localize_script('wordlift-ui', 'wl_chord_params', array(
84
+				'ajax_url' => admin_url('admin-ajax.php'),
85 85
 				'action'   => 'wl_chord',
86 86
 			)
87 87
 		);
88 88
 
89 89
 		// Escaping atts.
90
-		$esc_class  = esc_attr( 'wl-chord' );
91
-		$esc_id     = esc_attr( $widget_id );
92
-		$esc_width  = esc_attr( $chord_atts['width'] );
93
-		$esc_height = esc_attr( $chord_atts['height'] );
90
+		$esc_class  = esc_attr('wl-chord');
91
+		$esc_id     = esc_attr($widget_id);
92
+		$esc_width  = esc_attr($chord_atts['width']);
93
+		$esc_height = esc_attr($chord_atts['height']);
94 94
 
95
-		$esc_post_id    = esc_attr( $post_id );
96
-		$esc_depth      = esc_attr( $chord_atts['depth'] );
97
-		$esc_main_color = esc_attr( $chord_atts['main_color'] );
95
+		$esc_post_id    = esc_attr($post_id);
96
+		$esc_depth      = esc_attr($chord_atts['depth']);
97
+		$esc_main_color = esc_attr($chord_atts['main_color']);
98 98
 
99 99
 		// Building template.
100 100
 		// TODO: in the HTML code there are static CSS rules. Move them to the CSS file.
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param object $amp_template The template.
124 124
 	 */
125
-	public function amp_post_template_css( $amp_template ) {
125
+	public function amp_post_template_css($amp_template) {
126 126
 
127 127
 		// Hide the `wl-chord` when in AMP.
128 128
 		?>
Please login to merge, or discard this patch.