Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:10up/autoshare-for-twitter into …
Browse files Browse the repository at this point in the history
…develop
  • Loading branch information
Sidsector9 committed May 6, 2024
2 parents a07891d + 38ad796 commit 03432f8
Show file tree
Hide file tree
Showing 10 changed files with 1,825 additions and 19,024 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-release-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
- name: Setup node version and npm cache
uses: actions/setup-node@v3
with:
node-version: 16
node-version-file: '.nvmrc'
cache: 'npm'

- name: Install Node dependencies
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: No Response
name: 'Close stale issues'

# **What it does**: Closes issues where the original author doesn't respond to a request for information.
# **Why we have it**: To remove the need for maintainers to remember to check back on issues periodically to see if contributors have responded.
# **Who does it impact**: Everyone that works on docs or docs-internal.

on:
issue_comment:
types: [created]
schedule:
# Schedule for five minutes after the hour, every hour
- cron: '5 * * * *'
# Schedule for every day at 1:30am UTC
- cron: '30 1 * * *'

permissions:
issues: write

jobs:
noResponse:
stale:
runs-on: ubuntu-latest
steps:
- uses: lee-dohm/[email protected]
- uses: actions/stale@v9
with:
token: ${{ github.token }}
daysUntilClose: 14 # Number of days of inactivity before an Issue is closed for lack of response
responseRequiredLabel: "needs:feedback" # Label indicating that a response from the original author is required
closeComment: >
days-before-stale: 7
days-before-close: 7
stale-issue-message: >
It has been 7 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 7 days, but if you have more information to add then please comment and the issue will stay open.
close-issue-message: >
This issue has been automatically closed because there has been no response
to our request for more information. With only the
information that is currently in the issue, we don't have enough information
to take action. Please reach out if you have or find the answers we need so
that we can investigate further. See [this blog post on bug reports and the
importance of repro steps](https://www.lee-dohm.com/2015/01/04/writing-good-bug-reports/)
for more information about the kind of information that may be helpful.
stale-issue-label: 'stale'
close-issue-reason: 'not_planned'
any-of-labels: 'needs:feedback'
remove-stale-when-updated: true

4 changes: 2 additions & 2 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: actions/checkout@v3

- name: Download build zip
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.event.repository.name }}
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact-autoshare-for-twitter
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v16
v20.11.0
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Pull requests represent a proposed solution to a specified problem. They should

For more on how 10up writes and manages code, check out our [10up Engineering Best Practices](https://10up.github.io/Engineering-Best-Practices/).

### Testing

Helping to test an open source project and provide feedback on success or failure of those tests is also a helpful contribution. You can find details on the Critical Flows and Test Cases in [this project's GitHub Wiki](https://github.com/10up/autoshare-for-twitter/wiki) as well as details on our overall approach to [Critical Flows and Test Cases in our Open Source Best Practices](https://10up.github.io/Open-Source-Best-Practices/testing/#critial-flows). Submitting the results of testing via our Critical Flows as a comment on a Pull Request of a specific feature or as an Issue when testing the entire project is the best approach for providing testing results.

## Workflow

The develop branch is the development branch which means it contains the next version to be released. `trunk` contains the latest released version as reflected in the WordPress.org plugin repository. Always work on the `develop` branch and open up PRs against `develop`.
Expand Down
16 changes: 10 additions & 6 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

namespace TenUp\AutoshareForTwitter\Utils;

use DateTime;
use DateTimeZone;
use WP_Post;
use const TenUp\AutoshareForTwitter\Core\Admin\AT_SETTINGS;
use const TenUp\AutoshareForTwitter\Core\POST_TYPE_SUPPORT_FEATURE;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\ENABLE_AUTOSHARE_FOR_TWITTER_KEY;
use const TenUp\AutoshareForTwitter\Core\Post_Meta\META_PREFIX;
Expand Down Expand Up @@ -170,7 +174,7 @@ function get_autoshare_for_twitter_settings( $key = '' ) {
'autoshare_accounts' => [],
];

$settings = get_option( \TenUp\AutoshareForTwitter\Core\Admin\AT_SETTINGS );
$settings = get_option( AT_SETTINGS );

if ( empty( $settings ) ) {
$settings = [];
Expand Down Expand Up @@ -209,11 +213,11 @@ function is_twitter_configured() {
/**
* Composes the tweet based off Title and URL.
*
* @param \WP_Post $post The post object.
* @param WP_Post $post The post object.
*
* @return string
*/
function compose_tweet_body( \WP_Post $post ) {
function compose_tweet_body( WP_Post $post ) {

/**
* Allow filtering of tweet body
Expand All @@ -227,7 +231,7 @@ function compose_tweet_body( \WP_Post $post ) {
*/
$url = apply_filters( 'autoshare_for_twitter_post_url', get_the_permalink( $post->ID ), $post );

$url = esc_url( $url );
$url = esc_url_raw( $url );
// According to this page https://developer.twitter.com/en/docs/counting-characters, all URLs are transformed to a uniform length.
$url_length = ( ! is_local() ) ? AUTOSHARE_FOR_TWITTER_URL_LENGTH : strlen( $url );
$body_max_length = 275 - $url_length; // 275 instead of 280 because of the space between body and URL and the ellipsis.
Expand Down Expand Up @@ -267,8 +271,8 @@ function date_from_twitter( $created_at ) {

$tz = get_option( 'timezone_string' );
$tz = ( ! empty( $tz ) ) ? $tz : 'UTC';
$date = new \DateTime( $created_at, new \DateTimeZone( 'UTC' ) );
$date->setTimezone( new \DateTimeZone( $tz ) );
$date = new DateTime( $created_at, new DateTimeZone( 'UTC' ) );
$date->setTimezone( new DateTimeZone( $tz ) );

return $date->format( 'Y-m-d @ g:iA' );
}
Expand Down
Loading

0 comments on commit 03432f8

Please sign in to comment.