@@ 61-72 (lines=12) @@ | ||
58 | * @param string $text The heading text. |
|
59 | * @return array The heading blob of data. |
|
60 | */ |
|
61 | public function generateHeadingData( $text ) { |
|
62 | return array( |
|
63 | 'attributes' => array( |
|
64 | 'content' => $text, |
|
65 | ), |
|
66 | 'block' => array( |
|
67 | 'blockName' => 'core/heading', |
|
68 | 'innerHTML' => "\n<h2>$text</h2>\n", |
|
69 | ), |
|
70 | 'clientId' => wp_generate_uuid4(), |
|
71 | ); |
|
72 | } |
|
73 | ||
74 | /** |
|
75 | * Helper function. Given a string of text, it will generate the blob of data |
|
@@ 81-92 (lines=12) @@ | ||
78 | * @param string $text The verse text. |
|
79 | * @return array The verse blob of data. |
|
80 | */ |
|
81 | public function generateVerseData( $text ) { |
|
82 | return array( |
|
83 | 'attributes' => array( |
|
84 | 'content' => $text, |
|
85 | ), |
|
86 | 'block' => array( |
|
87 | 'blockName' => 'core/verse', |
|
88 | 'innerHTML' => "<pre>$text</pre>", |
|
89 | ), |
|
90 | 'clientId' => wp_generate_uuid4(), |
|
91 | ); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * Helper function. Given a quote and attribution, it will generate the blob of data |
|
@@ 127-138 (lines=12) @@ | ||
124 | * @param string $html The list data. |
|
125 | * @return array The list blob of data. |
|
126 | */ |
|
127 | public function generateListData( $html ) { |
|
128 | return array( |
|
129 | 'attributes' => array( |
|
130 | 'values' => $html, |
|
131 | ), |
|
132 | 'block' => array( |
|
133 | 'blockName' => 'core/list', |
|
134 | 'innerHTML' => "<ul>$html</ul>", |
|
135 | ), |
|
136 | 'clientId' => wp_generate_uuid4(), |
|
137 | ); |
|
138 | } |
|
139 | ||
140 | /** |
|
141 | * Helper function. Given a URL, it will generate the blob of data |
|
@@ 148-160 (lines=13) @@ | ||
145 | * @param string $alt The image alt text. |
|
146 | * @return array The image blob of data. |
|
147 | */ |
|
148 | public function generateImageData( $url, $alt ) { |
|
149 | return array( |
|
150 | 'attributes' => array( |
|
151 | 'url' => $url, |
|
152 | 'alt' => $alt, |
|
153 | ), |
|
154 | 'block' => array( |
|
155 | 'blockName' => 'core/image', |
|
156 | 'innerHTML' => "<figure><img src='$url' alt='$alt'/></figure>", |
|
157 | ), |
|
158 | 'clientId' => wp_generate_uuid4(), |
|
159 | ); |
|
160 | } |
|
161 | ||
162 | /** |
|
163 | * Helper function. Given a URL, it will generate the blob of data |
|
@@ 169-180 (lines=12) @@ | ||
166 | * @param string $url The video URL. |
|
167 | * @return array The video blob of data. |
|
168 | */ |
|
169 | public function generateVideoData( $url ) { |
|
170 | return array( |
|
171 | 'attributes' => array( |
|
172 | 'url' => $url, |
|
173 | ), |
|
174 | 'block' => array( |
|
175 | 'blockName' => 'core/video', |
|
176 | 'innerHTML' => "<figure><video src='$url'/></figure>", |
|
177 | ), |
|
178 | 'clientId' => wp_generate_uuid4(), |
|
179 | ); |
|
180 | } |
|
181 | ||
182 | /** |
|
183 | * Helper function. Given a URL, it will generate the blob of data |
|
@@ 245-254 (lines=10) @@ | ||
242 | * |
|
243 | * @return array The spacer blob of data. |
|
244 | */ |
|
245 | public function generateSpacerData() { |
|
246 | return array( |
|
247 | 'attributes' => array(), |
|
248 | 'block' => array( |
|
249 | 'blockName' => 'core/spacer', |
|
250 | 'innerHTML' => '<div />', |
|
251 | ), |
|
252 | 'clientId' => wp_generate_uuid4(), |
|
253 | ); |
|
254 | } |
|
255 | ||
256 | /** |
|
257 | * Helper function. Generate the blob of data that the parser |
|
@@ 262-271 (lines=10) @@ | ||
259 | * |
|
260 | * @return array The separator blob of data. |
|
261 | */ |
|
262 | public function generateSeparatorData() { |
|
263 | return array( |
|
264 | 'attributes' => array(), |
|
265 | 'block' => array( |
|
266 | 'blockName' => 'core/separator', |
|
267 | 'innerHTML' => '<hr />', |
|
268 | ), |
|
269 | 'clientId' => wp_generate_uuid4(), |
|
270 | ); |
|
271 | } |
|
272 | ||
273 | /** |
|
274 | * Helper function. Generate the blob of data that the parser |
|
@@ 326-339 (lines=14) @@ | ||
323 | * |
|
324 | * @return array The embedded tweet blob of data. |
|
325 | */ |
|
326 | public function generateJetpackGifData( $url ) { |
|
327 | return array( |
|
328 | 'attributes' => array( |
|
329 | 'giphyUrl' => $url, |
|
330 | ), |
|
331 | 'block' => array( |
|
332 | 'attrs' => array( |
|
333 | 'giphyUrl' => $url, |
|
334 | ), |
|
335 | 'blockName' => 'jetpack/gif', |
|
336 | ), |
|
337 | 'clientId' => wp_generate_uuid4(), |
|
338 | ); |
|
339 | } |
|
340 | ||
341 | /** |
|
342 | * Helper function. Generates a normal boundary marker. |