-
Notifications
You must be signed in to change notification settings - Fork 798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the instagram embed #2003
Conversation
* Add alternate username-based URL format handler for instagram embed and shortcode * Remove no longer needed fallback for older format embeds * Fix a typo for the comment returned when there is no embed found * Adjust the way the instagram script is loaded/fired so that it works with infinite scroll -- this adds a new js file that is enqueued properly (and thus compatible with infinite scroll) and detects IS loads and fires the appropriate instagram function to reprocess any images on the page
Adjust the way the facebook script is loaded/fired so that it works with infinite scroll -- this adds a new js file that is enqueued properly (and thus compatible with infinite scroll) and detects IS loads and fires the appropriate facebook function to reprocess any embeds on the page that were loaded via IS. Similar approach to #2003 for instagram
} | ||
|
||
// there's a script in the response, which we strip on purpose since it's added above | ||
wp_enqueue_script( 'jetpack-instagram-embed', plugins_url( 'js/instagram.js', __FILE__ ), array( 'jquery' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please consider updating this enqueue to wp_enqueue_script( 'jetpack-instagram-embed', plugins_url( 'js/instagram.js', __FILE__ ), array( 'jquery' ), 1.0, true );
to ensure that it is loaded at the end of the page. The script specifically relies on the <body>
tag being present, so it makes sense to specify that it is loaded in the footer to prevent it from being loaded early.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we updated this on the WP.com side, and I've now updated this PR as well. Thanks for reviewing this.
prevents js errors with loading things before the main content is ready
Instagram Shortcode: Don't bother trying to validate the URL because this is no different than doing [embed]URL[/embed] and the WP_Embed class will take care of verifying the URL as being valid. If it's not, it'll just return a clickable URL. Props @Viper007Bond
merged in with cbc53d4 |
This syncs the instagram integration from WordPress.com to Jetpack with some changes I did over the last 3 days:
Note that this last bit adds a new file
shortcodes/js/instagram.js
which has a corresponding file on WordPress.com and will need to be added to the build script as per @dereksmart's instructions :)