Automattic /
jetpack
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Embed support for Inline PDFs |
||
| 4 | * |
||
| 5 | * Takes a plain-text PDF URL (*.pdf), and attempts to embed it directly |
||
| 6 | * in the post instead of leaving it as a bare link. |
||
| 7 | * |
||
| 8 | * @package Jetpack |
||
| 9 | */ |
||
| 10 | |||
| 11 | wp_embed_register_handler( 'inline-pdfs', '#https?://[^<]*\.pdf$#i', 'jetpack_inline_pdf_embed_handler' ); |
||
| 12 | |||
| 13 | /** |
||
| 14 | * Callback to modify the output of embedded PDF files. |
||
| 15 | * |
||
| 16 | * @param array $matches Regex partial matches against the URL passed. |
||
| 17 | * @param array $attr Attributes received in embed response. |
||
| 18 | * @param array $url Requested URL to be embedded. |
||
| 19 | */ |
||
| 20 | function jetpack_inline_pdf_embed_handler( $matches, $attr, $url ) { |
||
| 21 | /** This action is documented in modules/widgets/social-media-icons.php */ |
||
| 22 | do_action( 'jetpack_bump_stats_extras', 'embeds', 'inline-pdf' ); |
||
| 23 | |||
| 24 | if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) { |
||
| 25 | return sprintf( |
||
| 26 | '<p><a href="%1$s">%2$s</a></p>', |
||
| 27 | esc_url( $url ), |
||
| 28 | esc_html__( 'PDF Document', 'jetpack' ) |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | |||
| 32 | $filename = basename( wp_parse_url( $url, PHP_URL_PATH ) ); |
||
|
0 ignored issues
–
show
|
|||
| 33 | $fallback_text = sprintf( |
||
| 34 | /* translators: Placeholder is a file name, for example "file.pdf" */ |
||
| 35 | esc_html__( 'Click to access %1$s', 'jetpack' ), |
||
| 36 | $filename |
||
| 37 | ); |
||
| 38 | |||
| 39 | return sprintf( |
||
| 40 | '<object data="%1$s" type="application/pdf" width="100%%" height="800"> |
||
| 41 | <p><a href="%1$s">%2$s</a></p> |
||
| 42 | </object>', |
||
| 43 | esc_attr( $url ), |
||
| 44 | $fallback_text |
||
| 45 | ); |
||
| 46 | } |
||
| 47 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignorePhpDoc annotation to the duplicate definition and it will be ignored.