Skip to content

Commit

Permalink
Merge branch 'feature/show-category-pull' into feature/do-category-pull
Browse files Browse the repository at this point in the history
  • Loading branch information
kirtangajjar authored Jul 10, 2024
2 parents d47454b + 4e8ed85 commit 7f14075
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 144 deletions.
1 change: 1 addition & 0 deletions .github/release-pull-request-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- [ ] Update this pull request's status from `draft` to `ready to merge`.
- [ ] Review: Do a review of the commit to the `stable` branch to ensure the contents of the diffs are as expected.
- [ ] Test: Check out the `stable` branch and test it locally to ensure everything works as expected. It is recommended that you rename the existing `distributor` directory and check out `stable` fresh because switching branches does not delete files. This can be done with `git clone --single-branch --branch stable [email protected]:10up/distributor.git`
- [ ] Either perform a regression testing utilizing the available [Critical Flows](https://10up.github.io/Open-Source-Best-Practices/testing/#critical-flows) and Test Cases or if [end-to-end tests](https://10up.github.io/Open-Source-Best-Practices/testing/#e2e-testing) cover a significant portion of those Critical Flows then run e2e tests. Only proceed if everything tests successfully.
- [ ] Release: Create a [new release](https://github.com/10up/distributor/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 milestone](https://github.com/10up/distributor/milestone/#?closed=1). The release should now appear under [releases](https://github.com/10up/distributor/releases).
- [ ] Check release: Wait for the [Publish Release Action](https://github.com/10up/distributor/actions?query=workflow%3A%22Publish+Release%22) to complete, and then check the latest release to ensure that the ZIP has been attached as an asset. Download the ZIP and inspect the contents to be sure they match the contents of the `stable` branch.
- [ ] Close milestone: Edit the [milestone](https://github.com/10up/distributor/milestone/#) with release date (in the `Due date (optional)` field) and link to GitHub release (in the `Description` field), then close the milestone.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
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: "Reporter 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: 'Reporter Feedback'
remove-stale-when-updated: true
10 changes: 5 additions & 5 deletions .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ jobs:
- {name: 'PHP Default', version: null}
core:
- {name: 'WP stable', version: 'latest'}
- {name: 'WP 5.7', version: 'WordPress/WordPress#5.7'}
- {name: 'WP 6.3', version: 'WordPress/WordPress#6.3'}
- {name: 'WP trunk', version: 'WordPress/WordPress#master'}
include:
- php: {name: 'PHP 7.4', version: '7.4'}
core: {name: 'WP 5.7', version: 'WordPress/WordPress#5.7'}
core: {name: 'WP 6.3', version: 'WordPress/WordPress#6.3'}
- php: {name: 'PHP 8.1', version: '8.1'}
core: {name: 'WP stable', version: 'latest'}
steps:
Expand Down Expand Up @@ -93,8 +93,8 @@ jobs:

- name: Log WP environment versions
run: |
npx wp-env run cli "wp core version"
npx wp-env run cli "php --version"
npx wp-env run cli wp core version
npx wp-env run cli php --version
- name: Test
run: npm run cypress:run
Expand All @@ -108,7 +108,7 @@ jobs:
npx mochawesome-report-generator tests/cypress/reports/mochawesome.json -o tests/cypress/reports/
cat ./tests/cypress/reports/mochawesome.md >> $GITHUB_STEP_SUMMARY
- name: Make artifacts available
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/generate-zip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
rm -rf ./release && unzip ${{ github.event.repository.name }}.zip -d ./release
- name: Upload the ZIP file as an artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: release
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
BRANCH=${GITHUB_REF##*/}
echo $BRANCH
VERSION=${BRANCH#'release/'}
echo ::set-output name=result::"Release: ${VERSION}"
echo "result="Release: ${VERSION}"" >> $GITHUB_OUTPUT
id: title
- name: Create Pull Request
run: gh pr create --draft --title "${{ steps.title.outputs.result }}" --body-file ./.github/release-pull-request-template.md
Expand Down
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/distributor/wiki/Critical-Flows) 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. `stable` contains the current latest release and `trunk` contains the corresponding stable development version. Always work on the `develop` branch and open up PRs against `develop`.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

> Distributor is a WordPress plugin that makes it easy to distribute and reuse content across your websites — whether in a single multisite or across the web.
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Tests](https://github.com/10up/distributor/actions/workflows/test.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/test.yml) [![Linting](https://github.com/10up/distributor/actions/workflows/lint.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/lint.yml) [![Code scanning](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml) [![Release Version](https://img.shields.io/github/release/10up/distributor.svg)](https://github.com/10up/distributor/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v6.4%20tested-success.svg) [![License](https://img.shields.io/github/license/10up/distributor.svg)](https://github.com/10up/distributor/blob/develop/LICENSE.md)
[![Support Level](https://img.shields.io/badge/support-active-green.svg)](#support-level) [![Tests](https://github.com/10up/distributor/actions/workflows/test.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/test.yml) [![Linting](https://github.com/10up/distributor/actions/workflows/lint.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/lint.yml) [![Code scanning](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/10up/distributor/actions/workflows/codeql-analysis.yml) [![Release Version](https://img.shields.io/github/release/10up/distributor.svg)](https://github.com/10up/distributor/releases/latest) ![WordPress tested up to version](https://img.shields.io/badge/WordPress-v6.5%20tested-success.svg) [![License](https://img.shields.io/github/license/10up/distributor.svg)](https://github.com/10up/distributor/blob/develop/LICENSE.md)

*You can learn more about Distributor's features at [DistributorPlugin.com](https://distributorplugin.com) and documentation at the [Distributor documentation site](https://10up.github.io/distributor/).*

Expand Down
2 changes: 1 addition & 1 deletion distributor.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Update URI: https://distributorplugin.com
* Description: Makes it easy to distribute and reuse content across your websites, whether inside of a multisite or across the web.
* Version: 2.0.4
* Requires at least: 5.7
* Requires at least: 6.3
* Requires PHP: 7.4
* Author: 10up Inc.
* Author URI: https://distributorplugin.com
Expand Down
11 changes: 8 additions & 3 deletions includes/classes/PullListTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,18 @@ public function column_date( $post ) {
}

/**
* Output categories column
* Output categories column.
*
* @param \WP_Post $post Post object.
* @since 0.8
* @since 2.0.5
*/
public function column_categories( $post ) {
$categories = $post->terms['category'] ?? [];

if ( empty( $categories ) ) {
return;
}

echo wp_kses_post( generate_taxonomy_links( 'category', $post, $categories ) );
}

Expand All @@ -268,7 +273,7 @@ public function column_categories( $post ) {
* @param string $column_name Column name.
*
* @return string.
* @since 0.8
* @since 2.0.5
*/
public function column_default( $item, $column_name ) {
if ( 'post_type' === $column_name ) {
Expand Down
4 changes: 3 additions & 1 deletion includes/pull-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,8 +594,10 @@ function output_pull_errors() {

if ( is_a( $connection_now, '\Distributor\ExternalConnection' ) ) {
$error_key = "external_{$connection_now->id}";
} else {
} elseif ( is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' ) ) {
$error_key = "internal_{$connection_now->site->blog_id}";
} else {
return;
}

$pull_errors = get_transient( 'dt_connection_pull_errors_' . $error_key );
Expand Down
9 changes: 6 additions & 3 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ function update_notice( $plugin_file, $plugin_data, $status ) {
* @since 1.2
*/
function maybe_notice() {
if ( 0 === strpos( get_current_screen()->parent_base, 'distributor' ) ) {
$parent_base = get_current_screen()->parent_base;
if ( ! $parent_base ) {
return;
}
if ( 0 === strpos( $parent_base, 'distributor' ) ) {
if ( Utils\is_development_version() ) {
?>
<div class="notice notice-warning">
Expand Down Expand Up @@ -177,8 +181,7 @@ function admin_enqueue_scripts( $hook ) {
if ( file_exists( $asset_file ) ) {
$asset_data = require $asset_file;
}

wp_enqueue_style( 'dt-admin-settings', plugins_url( '/dist/css/admin-settings.min.css', __DIR__ ), array(), $asset_data['version'] );
wp_enqueue_style( 'dt-admin-settings-screen', plugins_url( '/dist/css/admin-settings.min.css', __DIR__ ), array(), $asset_data['version'] );
}
}

Expand Down
41 changes: 32 additions & 9 deletions includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,19 +579,24 @@ function prepare_meta( $post_id ) {
* @param string $taxonomy The taxonomy name.
* @param object $post The post object.
* @param array $terms Optional. Array of terms.
*
* @return string The generated HTML for the taxonomy links.
*/
function generate_taxonomy_links( $taxonomy, $post, $terms = [] ) {
$taxonomy_object = get_taxonomy( $taxonomy );

if ( ! $taxonomy_object ) {
return '';
}

if ( ! $terms ) {
$terms = get_the_terms( $post, $taxonomy );
}

/**
* Filter the taxonomy terms that should be synced.
*
* @since x.x.x
* @since 2.0.5
* @hook dt_syncable_taxonomy_terms
*
* @param {array} $terms Array of terms.
Expand All @@ -602,11 +607,10 @@ function generate_taxonomy_links( $taxonomy, $post, $terms = [] ) {
*/
$terms = apply_filters( "dt_syncable_{$taxonomy}_terms", $terms, $taxonomy, $post );


/**
* Filter the terms that should be synced.
*
* @since x.x.x
* @since 2.0.5
* @hook dt_syncable_terms
*
* @param {array} $terms Array of categories.
Expand Down Expand Up @@ -645,12 +649,14 @@ function generate_taxonomy_links( $taxonomy, $post, $terms = [] ) {
/**
* Filters the links in `$taxonomy` column of edit.php.
*
* @since x.x.x
* @since 2.0.5
* @hook dt_taxonomy_links
*
* @param string[] $term_links Array of term editing links.
* @param string $taxonomy Taxonomy name.
* @param WP_Term[] $terms Array of term objects appearing in the post row.
* @param {string[]} $term_links Array of term editing links.
* @param {string} $taxonomy Taxonomy name.
* @param {WP_Term[]} $terms Array of term objects appearing in the post row.
*
* @return {string[]} Array of term editing links.
*/
$term_links = apply_filters( 'dt_taxonomy_links', $term_links, $taxonomy, $terms );

Expand All @@ -665,19 +671,20 @@ function generate_taxonomy_links( $taxonomy, $post, $terms = [] ) {
*
* The edit link is created in such a way that it will link to source site.
*
* @since x.x.x
* @since 2.0.5
*
* @param string[] $args Associative array of URL parameters for the link.
* @param string $link_text Link text.
* @param string $css_class Optional. Class attribute. Default empty string.
*
* @return string The formatted link string.
*/
function get_edit_link( $args, $link_text, $css_class = '' ) {
$url = '';
if ( is_internal_connection() ) {
$url = add_query_arg( $args, get_admin_url( null, 'edit.php' ) );
} else {
$url = add_query_arg( $args, get_root_url() . 'wp-admin/edit.php' );
$url = add_query_arg( $args, trailingslashit( get_root_url() ) . 'wp-admin/edit.php' );
}

$class_html = '';
Expand Down Expand Up @@ -706,43 +713,59 @@ function get_edit_link( $args, $link_text, $css_class = '' ) {
/**
* Is current connection an external connection?
*
* @since 2.0.5
*
* @return boolean
*/
function is_external_connection() {
global $connection_now;

return is_a( $connection_now, '\Distributor\ExternalConnection' );
}

/**
* Is current connection an internal connection?
*
* @since 2.0.5
*
* @return boolean
*/
function is_internal_connection() {
global $connection_now;

return is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' );
}

/**
* Get the root URL of the current connection
*
* @since 2.0.5
*
* @return string
*/
function get_root_url() {
$base_url = get_conn_base_url();

return str_replace( '/wp-json', '', $base_url );
}

/**
* Get the base URL of the current connection
*
* @since 2.0.5
*
* @return string
*/
function get_conn_base_url() {
if ( ! is_external_connection() ) {
return get_site_url();
}
global $connection_now;

if ( ! $connection_now || ! property_exists( $connection_now, 'base_url' ) ) {
return '';
}

return $connection_now->base_url;
}

Expand Down
Loading

0 comments on commit 7f14075

Please sign in to comment.