Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/disqus/disqus-wordpress-plugin
WordPress plugin for Disqus (Latest version)
https://github.com/disqus/disqus-wordpress-plugin
php react typescript wordpress
Last synced: about 2 months ago
JSON representation
WordPress plugin for Disqus (Latest version)
- Host: GitHub
- URL: https://github.com/disqus/disqus-wordpress-plugin
- Owner: disqus
- Created: 2016-12-12T18:34:22.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2024-10-30T18:08:23.000Z (2 months ago)
- Last Synced: 2024-10-30T18:29:43.174Z (2 months ago)
- Topics: php, react, typescript, wordpress
- Language: TypeScript
- Homepage: https://disqus.com/
- Size: 4.01 MB
- Stars: 34
- Watchers: 13
- Forks: 25
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
Awesome Lists containing this project
README
# Disqus WordPress Plugin
## Local Testing
There's a Docker configuration to bootstrap a local WordPress installation. To start it:
- You'll need both [Docker](https://docs.docker.com/install/) and [yarn](https://yarnpkg.com/) installed on your local machine.
- From the root directory, run `$ yarn` to install the frontend dependencies.
- Once that's done, run `$ make run` to build the docker image.
- Install wordpress with the default values by running `$ make install`.
- Activate the Disqus plugin using `$ make activate`.
- Alternatively you can now complete configuration by going to: http://localhost:8888/wp-admin/install.php
- Otherwise you can continue to: http://localhost:8888/### Unit tests
To run unit tests locally:
- Run `$ make docker-test`.
This will run all frontend (Jest) and backend (PHPUnit) tests.
## Installing to existing WordPress site
To install the plugin on an existing WordPress site, you'll need to build the frontend and create a .zip file:
- Make sure you have [yarn](https://yarnpkg.com/) installed on your local machine.
- From the root directory, run `$ make dist`.
- From your WordPress plugin page, select Plugins->Add New->Upload Plugin and choose the `disqus.zip` file you created.
- Activate the plugin and then install using the instructions in the plugin.## Custom Filters
### dsq_can_load
You can override when Disqus loads on a certain page using the `dsq_can_load` filter. By default Disqus won't load scripts on:
- On RSS feed pages
- If the `shortname` is missing from the configurationAdditionally Disqus will not load the embed.js script:
- On pages that are not 'post' or 'page' types
- Posts or pages that have comment turned off
- Draft postsThe filter will pass one argument, the `$script_name` enumeration, which can be:
- `'count'` — The count.js script file for showing comment counts next to a link
- `'embed'` — The commenting embed.js fileIn this example, you can add a filter which disables the comment count script, while still allowing the comments embed to load:
```php
function filter_dsq_can_load( $script_name ) {
// $script_name is either 'count' or 'embed'.
if ( 'count' === $script_name ) {
return false;
}return true;
}
add_filter( 'dsq_can_load', 'filter_dsq_can_load' );
```