@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @return string The HTML output. |
51 | 51 | */ |
52 | - public function render( $atts ) { |
|
52 | + public function render($atts) { |
|
53 | 53 | |
54 | 54 | // extract attributes and set default values. |
55 | 55 | $chord_atts = shortcode_atts( |
@@ -63,18 +63,18 @@ discard block |
||
63 | 63 | $atts |
64 | 64 | ); |
65 | 65 | |
66 | - if ( $chord_atts['global'] ) { |
|
66 | + if ($chord_atts['global']) { |
|
67 | 67 | |
68 | 68 | $post_id = wl_shortcode_chord_most_referenced_entity_id(); |
69 | 69 | |
70 | - if ( null === $post_id ) { |
|
71 | - return __( 'WordLift Chord: no entities found.', 'wordlift' ); |
|
70 | + if (null === $post_id) { |
|
71 | + return __('WordLift Chord: no entities found.', 'wordlift'); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | // Use the provided height if any, otherwise use a default of 200px. |
75 | 75 | // |
76 | 76 | // See https://github.com/insideout10/wordlift-plugin/issues/443. |
77 | - $chord_atts['height'] = isset( $chord_atts['height'] ) ? $chord_atts['height'] : '200px'; |
|
77 | + $chord_atts['height'] = isset($chord_atts['height']) ? $chord_atts['height'] : '200px'; |
|
78 | 78 | |
79 | 79 | } else { |
80 | 80 | $post_id = get_the_ID(); |
@@ -84,10 +84,10 @@ discard block |
||
84 | 84 | // |
85 | 85 | // @see https://github.com/insideout10/wordlift-plugin/issues/699 |
86 | 86 | // wp_enqueue_style( 'wordlift-ui', dirname( plugin_dir_url( __FILE__ ) ) . '/css/wordlift-ui.min.css' ); |
87 | - wp_enqueue_style( 'wordlift-ui' ); |
|
87 | + wp_enqueue_style('wordlift-ui'); |
|
88 | 88 | |
89 | 89 | // Adding javascript code. |
90 | - wp_enqueue_script( 'd3', dirname( plugin_dir_url( __FILE__ ) ) . '/bower_components/d3/d3.min.js', array(), WORDLIFT_VERSION, false ); |
|
90 | + wp_enqueue_script('d3', dirname(plugin_dir_url(__FILE__)).'/bower_components/d3/d3.min.js', array(), WORDLIFT_VERSION, false); |
|
91 | 91 | |
92 | 92 | $this->enqueue_scripts(); |
93 | 93 | |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | 'wordlift-ui', |
96 | 96 | 'wl_chord_params', |
97 | 97 | array( |
98 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
98 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
99 | 99 | 'action' => 'wl_chord', |
100 | - 'wl_chord_nonce' => wp_create_nonce( 'wl_chord' ), |
|
100 | + 'wl_chord_nonce' => wp_create_nonce('wl_chord'), |
|
101 | 101 | ) |
102 | 102 | ); |
103 | 103 | |
104 | 104 | // Escaping atts. |
105 | - $esc_class = esc_attr( 'wl-chord' ); |
|
106 | - $esc_id = esc_attr( uniqid( 'wl-chord-' ) ); |
|
107 | - $esc_width = esc_attr( $chord_atts['width'] ); |
|
108 | - $esc_height = esc_attr( $chord_atts['height'] ); |
|
105 | + $esc_class = esc_attr('wl-chord'); |
|
106 | + $esc_id = esc_attr(uniqid('wl-chord-')); |
|
107 | + $esc_width = esc_attr($chord_atts['width']); |
|
108 | + $esc_height = esc_attr($chord_atts['height']); |
|
109 | 109 | |
110 | - $esc_post_id = esc_attr( $post_id ); |
|
111 | - $esc_depth = esc_attr( $chord_atts['depth'] ); |
|
112 | - $esc_main_color = esc_attr( $chord_atts['main_color'] ); |
|
110 | + $esc_post_id = esc_attr($post_id); |
|
111 | + $esc_depth = esc_attr($chord_atts['depth']); |
|
112 | + $esc_main_color = esc_attr($chord_atts['main_color']); |
|
113 | 113 | |
114 | 114 | // Building template. |
115 | 115 | // TODO: in the HTML code there are static CSS rules. Move them to the CSS file. |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | |
135 | 135 | add_action( |
136 | 136 | 'init', |
137 | - function () use ( $scope ) { |
|
138 | - if ( ! function_exists( 'register_block_type' ) ) { |
|
137 | + function() use ($scope) { |
|
138 | + if ( ! function_exists('register_block_type')) { |
|
139 | 139 | // Gutenberg is not active. |
140 | 140 | return; |
141 | 141 | } |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | 'wordlift/chord', |
145 | 145 | array( |
146 | 146 | 'editor_script' => 'wl-block-editor', |
147 | - 'render_callback' => function ( $attributes ) use ( $scope ) { |
|
147 | + 'render_callback' => function($attributes) use ($scope) { |
|
148 | 148 | $attr_code = ''; |
149 | - foreach ( $attributes as $key => $value ) { |
|
150 | - $attr_code .= $key . '="' . htmlentities( $value ) . '" '; |
|
149 | + foreach ($attributes as $key => $value) { |
|
150 | + $attr_code .= $key.'="'.htmlentities($value).'" '; |
|
151 | 151 | } |
152 | 152 | |
153 | - return '[' . $scope::SHORTCODE . ' ' . $attr_code . ']'; |
|
153 | + return '['.$scope::SHORTCODE.' '.$attr_code.']'; |
|
154 | 154 | }, |
155 | 155 | 'attributes' => array( |
156 | 156 | 'width' => array( |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | ), |
180 | 180 | 'preview_src' => array( |
181 | 181 | 'type' => 'string', |
182 | - 'default' => WP_CONTENT_URL . '/plugins/wordlift/images/block-previews/chord.png', |
|
182 | + 'default' => WP_CONTENT_URL.'/plugins/wordlift/images/block-previews/chord.png', |
|
183 | 183 | ), |
184 | 184 | ), |
185 | 185 | ) |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | * @since 3.14.0 |
197 | 197 | */ |
198 | 198 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
199 | - public function amp_post_template_css( $amp_template ) { |
|
199 | + public function amp_post_template_css($amp_template) { |
|
200 | 200 | |
201 | 201 | // Hide the `wl-chord` when in AMP. |
202 | 202 | ?> |