PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.5
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.5
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
← All changes | json-endpoints/class.wpcom-json-api-post-v1-1-endpoint.php +8 -112 13.4.5 → 16.3-a.5 View file →
@@ -1,6 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit( 0 );
5 +}
6 +
3 7 /**
4 8 * Post v1_1 Endpoint class.
5 9 */
6 10 abstract class WPCOM_JSON_API_Post_v1_1_Endpoint extends WPCOM_JSON_API_Endpoint { // phpcs:ignore PEAR.NamingConventions.ValidClassName.Invalid, Generic.Classes.OpeningBraceSameLine.ContentAfterBrace
@@ -33,8 +37,9 @@
33 37 'auto-draft' => 'The post is a placeholder for a new post.',
34 38 ),
35 39 'sticky' => '(bool) Is the post sticky?',
36 40 'password' => '(string) The plaintext password protecting the post, or, more likely, the empty string if the post is not password protected.',
41 + 'has_password' => '(bool) Whether the post is password protected, regardless of whether the current user can access it.',
37 42 'parent' => "(object>post_reference|false) A reference to the post's parent, if it has one.",
38 43 'type' => "(string) The post's post_type. Post types besides post, page and revision need to be whitelisted using the <code>rest_api_allowed_post_types</code> filter.",
39 44 'discussion' => '(object) Hash of discussion options for the post',
40 45 'likes_enabled' => '(bool) Is the post open to likes?',
@@ -104,13 +109,8 @@
104 109 $GLOBALS['content_width'] = (int) $args['content_width'];
105 110 }
106 111 }
107 112
108 - if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && strpos( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ), 'wp-windows8' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- we're not using this value and making changes, just checking if it exists.
109 - remove_shortcode( 'gallery', 'gallery_shortcode' );
110 - add_shortcode( 'gallery', array( $this, 'win8_gallery_shortcode' ) );
111 - }
112 -
113 113 // fetch SAL post
114 114 $post = $this->get_sal_post_by( $field, $field_value, $context );
115 115
116 116 if ( is_wp_error( $post ) ) {
@@ -219,8 +219,11 @@
219 219 break;
220 220 case 'password':
221 221 $response[ $key ] = $post->get_password();
222 222 break;
223 + case 'has_password':
224 + $response[ $key ] = $post->get_has_password();
225 + break;
223 226 /** (object|false) */
224 227 case 'parent':
225 228 $response[ $key ] = $post->get_parent();
226 229 break;
@@ -378,113 +381,6 @@
378 381 switch_to_blog( $blog_id );
379 382 $post = $this->get_post_by( 'ID', $post_id, $context );
380 383 restore_current_blog();
381 384 return $post;
382 - }
383 -
384 - /**
385 - * Win8 Gallery shortcode.
386 - *
387 - * @param array $attr - the attribute.
388 - */
389 - public function win8_gallery_shortcode( $attr ) {
390 - global $post;
391 -
392 - static $instance = 0;
393 - ++$instance;
394 -
395 - // @todo - find out if this is a bug, intentionally unused, or can be removed.
396 - $output = ''; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
397 -
398 - // We're trusting author input, so let's at least make sure it looks like a valid orderby statement
399 - if ( isset( $attr['orderby'] ) ) {
400 - $attr['orderby'] = sanitize_sql_orderby( $attr['orderby'] );
401 - if ( ! $attr['orderby'] ) {
402 - unset( $attr['orderby'] );
403 - }
404 - }
405 -
406 - $atts = shortcode_atts(
407 - array(
408 - 'order' => 'ASC',
409 - 'orderby' => 'menu_order ID',
410 - 'id' => $post->ID,
411 - 'include' => '',
412 - 'exclude' => '',
413 - 'slideshow' => false,
414 - ),
415 - $attr,
416 - 'gallery'
417 - );
418 - $id = ! empty( $atts['id'] ) ? (int) $atts['id'] : 0;
419 -
420 - // Custom image size and always use it.
421 - add_image_size( 'win8app-column', 480 );
422 - $size = 'win8app-column';
423 -
424 - if ( 'RAND' === $atts['order'] ) {
425 - $orderby = 'none';
426 - } else {
427 - $orderby = $atts['orderby'];
428 - }
429 -
430 - if ( ! empty( $atts['include'] ) ) {
431 - $include = preg_replace( '/[^0-9,]+/', '', $atts['include'] );
432 - $_attachments = get_posts(
433 - array(
434 - 'include' => $include,
435 - 'post_status' => 'inherit',
436 - 'post_type' => 'attachment',
437 - 'post_mime_type' => 'image',
438 - 'order' => $atts['order'],
439 - 'orderby' => $orderby,
440 - )
441 - );
442 - $attachments = array();
443 - foreach ( $_attachments as $key => $val ) {
444 - $attachments[ $val->ID ] = $_attachments[ $key ];
445 - }
446 - } elseif ( ! empty( $atts['exclude'] ) ) {
447 - $exclude = preg_replace( '/[^0-9,]+/', '', $atts['exclude'] );
448 - $attachments = get_children(
449 - array(
450 - 'post_parent' => $id,
451 - 'exclude' => $exclude,
452 - 'post_status' => 'inherit',
453 - 'post_type' => 'attachment',
454 - 'post_mime_type' => 'image',
455 - 'order' => $atts['order'],
456 - 'orderby' => $orderby,
457 - )
458 - );
459 - } else {
460 - $attachments = get_children(
461 - array(
462 - 'post_parent' => $id,
463 - 'post_status' => 'inherit',
464 - 'post_type' => 'attachment',
465 - 'post_mime_type' => 'image',
466 - 'order' => $atts['order'],
467 - 'orderby' => $orderby,
468 - )
469 - );
470 - }
471 -
472 - if ( ! empty( $attachments ) ) {
473 - foreach ( $attachments as $id => $attachment ) {
474 - $link = isset( $attr['link'] ) && 'file' === $attr['link']
475 - ? wp_get_attachment_link( $id, $size, false, false )
476 - : wp_get_attachment_link( $id, $size, true, false );
477 -
478 - // phpcs:disable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
479 - if ( $captiontag && trim( $attachment->post_excerpt ) ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
480 - $output .= "<div class='wp-caption aligncenter'>$link
481 - <p class='wp-caption-text'>" . wptexturize( $attachment->post_excerpt ) . '</p>
482 - </div>';
483 - } else {
484 - $output .= $link . ' ';
485 - }
486 - // phpcs:enable VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
487 - }
488 - }
489 385 }
490 386 }