Completed
Push — develop ( 7939dc...a64e13 )
by David
02:58
created
src/public/class-wordlift-chord-shortcode.php 2 patches
Indentation   +97 added lines, -97 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
-	 * Render shordcode.
43
-	 *
44
-	 * @param array $atts shortcode attributes.
45
-	 *
46
-	 * @return string The HTML output.
47
-	 */
48
-	public function render( $atts ) {
49
-
50
-		// extract attributes and set default values.
51
-		$chord_atts = shortcode_atts( array(
52
-			'width'      => '100%',
53
-			'height'     => '500px',
54
-			'main_color' => '000',
55
-			'depth'      => 2,
56
-			'global'     => false,
57
-		), $atts );
58
-
59
-		if ( $chord_atts['global'] ) {
60
-
61
-			$post_id = wl_shortcode_chord_most_referenced_entity_id();
62
-
63
-			if ( null === $post_id ) {
64
-				return 'WordLift Chord: no entities found.';
65
-			}
66
-
67
-			// Use the provided height if any, otherwise use a default of 200px.
68
-			//
69
-			// See https://github.com/insideout10/wordlift-plugin/issues/443.
70
-			$chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
71
-
72
-		} else {
73
-			$post_id = get_the_ID();
74
-		}
75
-
76
-		// Adding css.
77
-		wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
78
-
79
-		// Adding javascript code.
80
-		wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
81
-
82
-		$this->enqueue_scripts();
83
-
84
-		wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
85
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
86
-			'action'   => 'wl_chord',
87
-		) );
88
-
89
-		// Escaping atts.
90
-		$esc_class  = esc_attr( 'wl-chord' );
91
-		$esc_id     = esc_attr( uniqid( 'wl-chord-' ) );
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
+     * Render shordcode.
43
+     *
44
+     * @param array $atts shortcode attributes.
45
+     *
46
+     * @return string The HTML output.
47
+     */
48
+    public function render( $atts ) {
49
+
50
+        // extract attributes and set default values.
51
+        $chord_atts = shortcode_atts( array(
52
+            'width'      => '100%',
53
+            'height'     => '500px',
54
+            'main_color' => '000',
55
+            'depth'      => 2,
56
+            'global'     => false,
57
+        ), $atts );
58
+
59
+        if ( $chord_atts['global'] ) {
60
+
61
+            $post_id = wl_shortcode_chord_most_referenced_entity_id();
62
+
63
+            if ( null === $post_id ) {
64
+                return 'WordLift Chord: no entities found.';
65
+            }
66
+
67
+            // Use the provided height if any, otherwise use a default of 200px.
68
+            //
69
+            // See https://github.com/insideout10/wordlift-plugin/issues/443.
70
+            $chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
71
+
72
+        } else {
73
+            $post_id = get_the_ID();
74
+        }
75
+
76
+        // Adding css.
77
+        wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
78
+
79
+        // Adding javascript code.
80
+        wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
81
+
82
+        $this->enqueue_scripts();
83
+
84
+        wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
85
+            'ajax_url' => admin_url( 'admin-ajax.php' ),
86
+            'action'   => 'wl_chord',
87
+        ) );
88
+
89
+        // Escaping atts.
90
+        $esc_class  = esc_attr( 'wl-chord' );
91
+        $esc_id     = esc_attr( uniqid( 'wl-chord-' ) );
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,21 +111,21 @@  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
-	public function amp_post_template_css( $amp_template ) {
124
-
125
-		// Hide the `wl-chord` when in AMP.
126
-		?>
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
+    public function amp_post_template_css( $amp_template ) {
124
+
125
+        // Hide the `wl-chord` when in AMP.
126
+        ?>
127 127
 		.wl-chord { display: none; }
128 128
 		<?php
129
-	}
129
+    }
130 130
 
131 131
 }
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@  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
 
@@ -45,56 +45,56 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @return string The HTML output.
47 47
 	 */
48
-	public function render( $atts ) {
48
+	public function render($atts) {
49 49
 
50 50
 		// extract attributes and set default values.
51
-		$chord_atts = shortcode_atts( array(
51
+		$chord_atts = shortcode_atts(array(
52 52
 			'width'      => '100%',
53 53
 			'height'     => '500px',
54 54
 			'main_color' => '000',
55 55
 			'depth'      => 2,
56 56
 			'global'     => false,
57
-		), $atts );
57
+		), $atts);
58 58
 
59
-		if ( $chord_atts['global'] ) {
59
+		if ($chord_atts['global']) {
60 60
 
61 61
 			$post_id = wl_shortcode_chord_most_referenced_entity_id();
62 62
 
63
-			if ( null === $post_id ) {
63
+			if (null === $post_id) {
64 64
 				return 'WordLift Chord: no entities found.';
65 65
 			}
66 66
 
67 67
 			// Use the provided height if any, otherwise use a default of 200px.
68 68
 			//
69 69
 			// See https://github.com/insideout10/wordlift-plugin/issues/443.
70
-			$chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px';
70
+			$chord_atts['height'] = isset($chord_atts['height']) ? $chord_atts['height'] : '200px';
71 71
 
72 72
 		} else {
73 73
 			$post_id = get_the_ID();
74 74
 		}
75 75
 
76 76
 		// Adding css.
77
-		wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' );
77
+		wp_enqueue_style('wordlift-ui', dirname(plugin_dir_url(__FILE__)).'/css/wordlift-ui.min.css');
78 78
 
79 79
 		// Adding javascript code.
80
-		wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js' );
80
+		wp_enqueue_script('d3', dirname(plugin_dir_url(__FILE__)).'/bower_components/d3/d3.min.js');
81 81
 
82 82
 		$this->enqueue_scripts();
83 83
 
84
-		wp_localize_script( 'wordlift-ui', 'wl_chord_params', array(
85
-			'ajax_url' => admin_url( 'admin-ajax.php' ),
84
+		wp_localize_script('wordlift-ui', 'wl_chord_params', array(
85
+			'ajax_url' => admin_url('admin-ajax.php'),
86 86
 			'action'   => 'wl_chord',
87
-		) );
87
+		));
88 88
 
89 89
 		// Escaping atts.
90
-		$esc_class  = esc_attr( 'wl-chord' );
91
-		$esc_id     = esc_attr( uniqid( 'wl-chord-' ) );
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(uniqid('wl-chord-'));
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.
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 	 *
121 121
 	 * @since 3.14.0
122 122
 	 */
123
-	public function amp_post_template_css( $amp_template ) {
123
+	public function amp_post_template_css($amp_template) {
124 124
 
125 125
 		// Hide the `wl-chord` when in AMP.
126 126
 		?>
Please login to merge, or discard this patch.