Skip to content

Commit

Permalink
Merge branch 'master' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwatkins0 committed Mar 20, 2020
2 parents e61b2ca + c4bb106 commit e4e78af
Show file tree
Hide file tree
Showing 43 changed files with 5,250 additions and 910 deletions.
8 changes: 5 additions & 3 deletions .distignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Directories
/.wordpress-org
/.git
/.github
Expand All @@ -17,6 +18,7 @@
!/vendor/symfony
!/vendor/myclabs

# Files
.babelrc
.distignore
.eslintignore
Expand All @@ -25,14 +27,14 @@
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
composer.json
composer.lock
CREDITS.md
LICENSE.md
README.md
composer.json
composer.lock
package-lock.json
package.json
phpcs.xml
phpunit.xml
README.md
webpack.config.js
webpack.gutenberg.config.js
2 changes: 2 additions & 0 deletions .github/workflows/deploy-to-wpdotorg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
run: |
npm install
npm run build
npm run build:externals
composer install -o --no-dev
- name: WordPress Plugin Deploy
uses: 10up/action-wordpress-plugin-deploy@master
env:
Expand Down
16 changes: 15 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,27 @@ jobs:
uses: icrawl/action-eslint@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

with:
job-name: eslint

test_php:
runs-on: ubuntu-latest
services:
mysql:
image: mariadb:10.4
env:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
strategy:
matrix:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3']

steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Install dependencies
run: composer install
- name: Run PHPCS
Expand All @@ -42,3 +51,8 @@ jobs:
run: |
composer run setup-local-tests
composer test
- name: Run WP Acceptance
if: matrix.php-versions == '7.3' || matrix.php-versions == '7.2'
run: |
WP_SNAPSHOTS_DIR=${{ github.workspace }}/.wpsnapshots/ ./vendor/bin/wpsnapshots configure --aws_key=${{ secrets.AWS_ACCESS_KEY }} --aws_secret=${{ secrets.SECRET_ACCESS_KEY }} --user_name="wp-acceptance" [email protected] 10up
./vendor/bin/wpacceptance run
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
dist
node_modules
screenshots
tests/coverage
vendor
22 changes: 15 additions & 7 deletions .wordpress-org/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 32 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,47 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased] - TBD

## [1.0.0] - TBD
## [1.0.2] - 2020-03-12
## Added
- WP Acceptance tests (props [@johnwatkins0](https://github.com/johnwatkins0) via [#84](https://github.com/10up/autoshare-for-twitter/pull/84))

## Changed
- New and improved settings page UX (props [@dinhtungdu](https://github.com/dinhtungdu), [@jeffpaul](https://github.com/jeffpaul/), [@johnwatkins0](https://github.com/johnwatkins0), [@linawiezkowiak](https://github.com/linawiezkowiak), [@oszkarnagy](https://github.com/oszkarnagy) via [#78](https://github.com/10up/autoshare-for-twitter/pull/78))

## Fixed
- Bug that caused posts to be inadvertently tweeted when switching from draft to publish (props [@johnwatkins0](https://github.com/johnwatkins0), [@rickalee](https://github.com/rickalee) via [#82](https://github.com/10up/autoshare-for-twitter/pull/82))
- Build script in release process (props [@johnwatkins0](https://github.com/johnwatkins0) via [#77](https://github.com/10up/autoshare-for-twitter/pull/77))

## [1.0.1] - 2020-02-03
### Added
- `autoshare_for_twitter_enabled_default` filter to allow autoshare to be enabled by default for a post type (props [@johnwatkins0](https://github.com/johnwatkins0), [@rickalee](https://github.com/rickalee), [@dinhtungdu](https://github.com/dinhtungdu) via [#71](https://github.com/10up/autoshare-for-twitter/pull/71))

### Changed
- Bypass character texturization when the post title is tweeted (props [@johnwatkins0](https://github.com/johnwatkins0), [@rickalee](https://github.com/rickalee) via [#73](https://github.com/10up/autoshare-for-twitter/pull/73))

### Removed
- Second instance of the `autoshare_for_twitter_tweet` filter (props [@johnwatkins0](https://github.com/johnwatkins0) via [#70](https://github.com/10up/autoshare-for-twitter/pull/70))

## [1.0.0] - 2019-12-17
### Added
- Initial public release! 🎉
- Support Post and Page post types by default, provide Custom Post Type (props @johnwatkins0 via #25)
- REST API endpoint to replace AJAX callback (props @johnwatkins0 via #33)
- Build process, PHPCS linting, unit tests, and Travis CI (props @johnwatkins0, @adamsilverstein via #23, #24, #28, #29)
- Plugin banner and icon images (props @sncampbell via #31)
- Twitter disclaimer per their trademark guidelines as part of their brand guidelines (props @jeffpaul via #50)
- Support Post and Page post types by default, provide Custom Post Type (props [@johnwatkins0](https://github.com/johnwatkins0) via [#25](https://github.com/10up/autoshare-for-twitter/pull/25))
- REST API endpoint to replace AJAX callback (props [@johnwatkins0](https://github.com/johnwatkins0) via [#33](https://github.com/10up/autoshare-for-twitter/pull/33))
- Build process, PHPCS linting, unit tests, and Travis CI (props [@johnwatkins0](https://github.com/johnwatkins0), [@adamsilverstein](https://github.com/adamsilverstein/) via [#23](https://github.com/10up/autoshare-for-twitter/pull/23), [#24](https://github.com/10up/autoshare-for-twitter/pull/24), [#28](https://github.com/10up/autoshare-for-twitter/pull/28), [#29](https://github.com/10up/autoshare-for-twitter/pull/29))
- Plugin banner and icon images (props [@sncampbell](https://github.com/sncampbell/) via [#31](https://github.com/10up/autoshare-for-twitter/pull/31))
- Twitter disclaimer per their trademark guidelines as part of their brand guidelines (props [@jeffpaul](https://github.com/jeffpaul/) via [#50](https://github.com/10up/autoshare-for-twitter/pull/50))

### Changed
- Refactor v0.1.0 significantly (props @adamsilverstein, @johnwatkins0, @jeffpaul via #1, #49)
- Refactor v0.1.0 significantly (props [@adamsilverstein](https://github.com/adamsilverstein/), [@johnwatkins0](https://github.com/johnwatkins0), [@jeffpaul](https://github.com/jeffpaul/) via [#1](https://github.com/10up/autoshare-for-twitter/pull/1), [#49](https://github.com/10up/autoshare-for-twitter/pull/49))

### Security
- XSS prevention - switch from .innerHTML to text (props @adamsilverstein via #1)
- XSS prevention - switch from .innerHTML to text (props [@adamsilverstein](https://github.com/adamsilverstein/) via [#1](https://github.com/10up/autoshare-for-twitter/pull/1))

## [0.1.0] - 2018-05-11
- Initial closed source release
- Initial closed source release (props [@scottlee](https://github.com/scottlee/))

[Unreleased]: https://github.com/10up/autoshare-for-twitter/compare/master...develop
[1.0.2]: https://github.com/10up/autoshare-for-twitter/compare/1.0.1...1.0.2
[1.0.1]: https://github.com/10up/autoshare-for-twitter/compare/1.0.0...1.0.1
[1.0.0]: https://github.com/10up/autoshare-for-twitter/compare/1020035...1.0.0
[0.1.0]: https://github.com/10up/autoshare-for-twitter/commit/1020035f2d4843221d996bd5f8fe39d9ee850b5d
28 changes: 16 additions & 12 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@ The `develop` branch is the development branch which means it contains the next

## Release instructions

1. Starting from `develop`, cut a release branch named `release/X.Y.Z` for your changes.
2. Version bump: Bump the version number in `autoshare-for-twitter.php` if it does not already reflect the version being released.
3. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`
4. Update the `.pot` file by running `npm run makepot`.
5. Check to be sure any new files/paths that are unnecessary in the production version are included in `.github/action-release/rsync-filter.txt`.
6. Merge: Make a non-fast-forward merge from your release branch to `develop`, then do the same for `develop` into `master`. `master` contains the stable development version.
7. Push: Push your `master` branch to GitHub, e.g. `git push origin master`.
8. [Wait for build](https://xkcd.com/303/): Head to the [Actions](https://github.com/10up/autoshare-for-twitter/actions) tab in the repo and wait for it to finish if it hasn't already. If it doesn't succeed, figure out why and start over.
9. Check the build: Check out the `stable` branch and test for functionality locally.
10. Git tag: Create the release as `X.Y.Z` on the `stable` branch in GitHub. It should now appear under [releases](https://github.com/10up/autoshare-for-twitter/releases) and in the WordPress admin as an update as well.
11. Edit the [X.Y.Z milestone](https://github.com/10up/autoshare-for-twitter/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close `X.Y.Z` milestone.
12. If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X+1.0.0`, `X.Y+1.0`, `X.Y.Z+1`, or `Future Release`
1. Branch: Starting from `develop`, cut a release branch named `release/X.Y.Z` for your changes.
2. Version bump: Bump the version number in `autoshare-for-twitter.php`, `readme.txt`, `composer.json`, `package-lock.json`, and `package.json` if it does not already reflect the version being released.
3. Changelog: Add/update the changelog in `CHANGELOG.md` and `readme.txt`.
4. Props: update `CREDITS.md` with any new contributors, confirm maintainers are accurate.
5. Translations: Update the `.pot` file by running `npm run makepot`.
6. New files: Check to be sure any new files/paths that are unnecessary in the production version are included in `.distignore`.
7. Readme updates: Make any other readme changes as necessary. `CHANGELOG.md` and `README.md` are geared toward GitHub and `readme.txt` contains WordPress.org-specific content. The two are slightly different.
8. Merge: Make a non-fast-forward merge from your release branch to `develop` (or merge the pull request), then do the same for `develop` into `master` (`git checkout master && git merge --no-ff develop`). `master` contains the stable development version.
9. Push: Push your `master` branch to GitHub (e.g. `git push origin master`).
10. [Wait for build](https://xkcd.com/303/): Head to the [Actions](https://github.com/10up/autoshare-for-twitter/actions) tab in the repo and wait for it to finish if it hasn't already. If it doesn't succeed, figure out why and start over.
11. Check the build: Check out the `stable` branch and test for functionality locally.
12. Release: Create a [new release](https://github.com/10up/autoshare-for-twitter/releases/new), naming the tag and the release with the new version number, and targeting the `stable` branch. Paste the changelog from `CHANGELOG.md` into the body of the release and include a link to the closed issues on the [1.0.1 milestone](https://github.com/10up/autoshare-for-twitter/milestone/3?closed=1).
13. SVN: Wait for the [GitHub Action](https://github.com/10up/autoshare-for-twitter/actions) to finish deploying to the WordPress.org repository. If all goes well, users with SVN commit access for that plugin will receive an emailed diff of changes.
14. Check WordPress.org: Ensure that the changes are live on https://wordpress.org/plugins/autoshare-for-twitter/. This may take a few minutes.
15. Close the milestone: Edit the [X.Y.Z milestone](https://github.com/10up/autoshare-for-twitter/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone.
16. Punt incomplete items: If any open issues or PRs which were milestoned for `X.Y.Z` do not make it into the release, update their milestone to `X+1.0.0`, `X.Y+1.0`, `X.Y.Z+1`, or `Future Release`
2 changes: 1 addition & 1 deletion CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following individuals are responsible for curating the list of issues, respo

Thank you to all the people who have already contributed to this repository via bug reports, code, design, ideas, project management, translation, testing, etc.

[Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [John Watkins (@johnwatkins0)](https://github.com/johnwatkins0), [Scott Lee (@scottlee)](https://github.com/scottlee), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Stephanie Campbell (@sncampbell)](https://github.com/sncampbell), [Ryan Welcher (@ryanwelcher)](https://github.com/ryanwelcher).
[Adam Silverstein (@adamsilverstein)](https://github.com/adamsilverstein), [John Watkins (@johnwatkins0)](https://github.com/johnwatkins0), [Scott Lee (@scottlee)](https://github.com/scottlee), [Jeffrey Paul (@jeffpaul)](https://github.com/jeffpaul), [Stephanie Campbell (@sncampbell)](https://github.com/sncampbell), [Ryan Welcher (@ryanwelcher)](https://github.com/ryanwelcher), [Ricky Lee Whittemore (@rickalee)](https://github.com/rickalee), [Tung Du (@dinhtungdu)](https://github.com/dinhtungdu), [Lina Wiezkowiak (@linawiezkowiak)](https://github.com/linawiezkowiak), [Oszkar Nagy (@oszkarnagy)](https://github.com/oszkarnagy).

## Libraries

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,27 @@ add_action( 'init', 'opt_my_cpt_into_autoshare' );

In addition, adding support while registering custom post types also works. Post types are automatically set to autoshare. Future versions of this plugin could allow this to be set manually.

While the autoshare feature can be opted into for post types using the above filter, by default the editor still has to manually enable autoshare during the post prepublish flow. The `autoshare_for_twitter_enabled_default` filter allows autoshare to be enabled by default for all posts of a given post type. Editors can still manually uncheck the option during the publishing flow.

Example:

```php
function enable_autoshare_by_default_for_core_post_type( $enabled, $post_type ) {
if ( 'post' === $post_type ) {
return true;
}

return $enabled;
}
add_filter( 'autoshare_for_twitter_enabled_default', 'enable_autoshare_by_default_for_core_post_type', 10, 2 );
```


## Plugin Compatibility

### Distributor

When using with 10up's [Distributor plugin](https://github.com/10up/distributor), posts that are distributed will not be autoshared if they are already tweeted from the origin site. Autoshare for Twitter tracks posts that have been tweeted in post meta to avoid "double tweeting". To avoid this behavior, use the `dt_blacklisted_meta` filter to exclude the 'autoshare_for_twitter_status' meta value from being distrivuted :
When using with 10up's [Distributor plugin](https://github.com/10up/distributor), posts that are distributed will not be autoshared if they are already tweeted from the origin site. Autoshare for Twitter tracks posts that have been tweeted in post meta to avoid "double tweeting". To avoid this behavior, use the `dt_blacklisted_meta` filter to exclude the 'autoshare_for_twitter_status' meta value from being distributed :

```php
add_filter( 'dt_blacklisted_meta', function( $blacklisted_metas ) {
Expand Down
79 changes: 79 additions & 0 deletions assets/css/admin-autoshare-for-twitter-settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.autoshare-settings .brand {
display: none;
}

.autoshare-settings .brand .logo img {
width: 120px;
max-width: 100%;
}

.autoshare-settings .brand nav a {
display: block;
text-decoration: none;
}

.autoshare-settings .brand nav a span {
font-size: inherit;
line-height: inherit;
vertical-align: unset;
}

.autoshare-settings .general-settings:not(.connected),
.autoshare-settings .general-settings:not(.connected) + table {
display: none;
}

.autoshare-settings .enable-for td {
padding-bottom: 5px;
}

.autoshare-settings .post-types td {
padding-top: 0;
padding-left: 40px;
}

.autoshare-settings .credentials-setup ul {
list-style: disc;
padding-left: 25px;
}

.autoshare-settings .credentials-actions a {
text-decoration: none;
}

.autoshare-settings .credentials-actions span {
font-size: inherit;
line-height: 1.5;
}

.autoshare-settings .credentials-setup:not(.connected) .open {
display: none;
}

.autoshare-settings .credentials-setup.connected .close,
.autoshare-settings .credentials-setup.connected .credentials-instructions,
.autoshare-settings .credentials-setup.connected + table {
display: none;
}

@media (min-width: 1024px) {
.autoshare-settings {
display: flex;
}

.autoshare-settings form {
width: 70%;
margin-right: 50px;
}

.autoshare-settings .brand {
display: block;
}
}

@media (min-width: 1200px) {
.autoshare-settings form {
width: 60%;
margin-right: 10%;
}
}
2 changes: 1 addition & 1 deletion assets/css/admin-autoshare-for-twitter.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
white-space: normal;
}

.autoshare-for-twitter-prepublish__checkbox .components-base-control__field, .autoshare-for-twitter-prepublish__checkbox-label {
.autoshare-for-twitter-prepublish__checkbox .components-base-control__field, .autoshare-for-twitter-prepublish__checkbox-label {
display: flex;
align-items: center;
}
Expand Down
1 change: 1 addition & 0 deletions assets/images/10up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions assets/js/admin-autoshare-for-twitter-settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
( function() {

document.addEventListener( 'DOMContentLoaded', function() {
var credSetup = document.querySelector( '.credentials-setup' ),
openCredSettingsBtn = credSetup.querySelector( '.open' ),
closeCredSettingsBtn = credSetup.querySelector( '.close' ),
postTypesWrap = document.querySelector( '.post-types' ),
postTypesCheckboxes = document.getElementsByName( 'autoshare-for-twitter[enable_for]' );

openCredSettingsBtn.addEventListener( 'click', function() {
credSetup.classList.remove( 'connected' );
} );

closeCredSettingsBtn.addEventListener( 'click', function() {
credSetup.classList.add( 'connected' );
} );

postTypesCheckboxes.forEach( function( item ) {
item.addEventListener( 'change', function( event) {
if ( event.target.value === 'all' )
return postTypesWrap.classList.add( 'hidden' );
return postTypesWrap.classList.remove( 'hidden' );
} );
} );


} );

} )();
4 changes: 4 additions & 0 deletions assets/js/admin-autoshare-for-twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@

$icon.removeClass('pending');
$tweetPost.prop('checked', false);
$('#submit').attr('disabled', true);
}

/**
Expand All @@ -70,6 +71,7 @@
var data = {};
data[adminAutoshareForTwitter.enableAutoshareKey] = status;
data[adminAutoshareForTwitter.tweetBodyKey] = $tweetText.val();
$('#submit').attr('disabled', true);

wp.apiFetch({
url: adminAutoshareForTwitter.restUrl,
Expand All @@ -95,6 +97,8 @@
$icon.toggleClass('disabled');
$tweetPost.prop('checked', false);
}

$('#submit').attr('disabled', false);
})
.catch(onRequestFail);
}
Expand Down
4 changes: 2 additions & 2 deletions autoshare-for-twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Autoshare for Twitter
* Description: Automatically tweets the post title or custom message and a link to the post.
* Disclaimer: TWITTER, TWEET, RETWEET and the Twitter logo are trademarks of Twitter, Inc. or its affiliates.
* Version: 1.0.0
* Version: 1.0.2
* Requires at least: 4.7
* Requires PHP: 7.0
* Author: 10up
Expand All @@ -19,7 +19,7 @@
}

define( 'AUTOSHARE_FOR_TWITTER', __FILE__ );
define( 'AUTOSHARE_FOR_TWITTER_VERSION', '1.0.0' );
define( 'AUTOSHARE_FOR_TWITTER_VERSION', '1.0.2' );
define( 'AUTOSHARE_FOR_TWITTER_URL', plugin_dir_url( __FILE__ ) );
define( 'AUTOSHARE_FOR_TWITTER_PATH', plugin_dir_path( __FILE__ ) );
define( 'AUTOSHARE_FOR_TWITTER_INC', AUTOSHARE_FOR_TWITTER_PATH . 'includes/' );
Expand Down
Loading

0 comments on commit e4e78af

Please sign in to comment.