npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

wp-comment-reply-module

v0.0.2

Published

A vanilla ES6/ES2015 replacement for the WordPress core comment reply script

Downloads

17

Readme

WORDPRESS COMMENT REPLY MODULE

This is a vanilla ES6/ECMA2015 rewrite of the WordPress core comment-reply.js script for threaded comments. It is designed for use in themes developed with a build process that already handles transpiling, polyfilling, module bundling, etc. There are no dependencies and jQuery is not required but you'll need to customize your markup and initialize the script on your own. Functionally it accomplishes the same thing as the original: once activated, the script listens for clicks on the reply button and moves the comment form into the appropriate location in the DOM while updating form data behind the scenes.

Documentation is not yet complete but the source is easy to read; it's not even 150 lines of code. For reference you can see this script in action here.

Note: this module is not for WordPress beginners. If you're not already comfortable with the jargon you've encountered thus far I strongly suggest looking elsewhere. This is very specifically intended for theme developers, not end users.

Installation

npm install --save-dev wp-comment-reply-module

Additionally you may need to polyfill Element.closest() (see browser support; reference here). I recommend npm install --save-dev element-closest (GitHub, npm).

Usage

Import the module and activate with options, which are all identifiers to help the script recognize your markup. Depending on your module bundling configuration you may need to whitelist the path so the module is properly transpiled. Some CSS will also be necessary to hide the cancel button.

import commentReply from 'wp-comment-reply-module';`

commentReply({ [options] });

Each reply button should be provisioned with the necessary data (commentId, parentId, and postId) in a JSON-encoded data attribute (data-reply by default). An example in Twig:

<button class="comment-reply" data-reply="{{ { commentId: comment.id, parentId: comment.comment_parent, postId: post.id } | json_encode | e }}">

If you're still writing spaghetti WordPress code you can JSON encode an array of the required data and insert it into the required data attribute.

License

Licensed under the GPL. Please feel free to improve on this script and use it at your own risk in your projects.