From 4c98447f1cc6eca3f36077708192721fbc3f4043 Mon Sep 17 00:00:00 2001 From: Chigozie Orunta Date: Fri, 13 May 2022 19:27:08 +0100 Subject: [PATCH 01/24] Make provision for post and page post types within args --- includes/rest-api.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index 00c60278e..31bb5ec73 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -411,10 +411,13 @@ function check_post_types_permissions() { * @return \WP_REST_Response|\WP_Error */ function get_pull_content( $request ) { + $post_type = isset( $request['post_type'] ) ? $request['post_type'] : 'all'; + $post_type = 'all' === $post_type ? array( 'post', 'page' ) : $post_type; + $args = [ 'posts_per_page' => isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : 20, 'paged' => isset( $request['page'] ) ? $request['page'] : 1, - 'post_type' => isset( $request['post_type'] ) ? $request['post_type'] : 'post', + 'post_type' => $post_type, 'post_status' => isset( $request['post_status'] ) ? $request['post_status'] : array( 'any' ), ]; From 1edf95e3b4adb84847e0ba099382c3be4200e772 Mon Sep 17 00:00:00 2001 From: Chigozie Orunta Date: Sat, 14 May 2022 23:45:25 +0100 Subject: [PATCH 02/24] Make post and page types available --- includes/rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index 31bb5ec73..6a43e29fe 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -417,7 +417,7 @@ function get_pull_content( $request ) { $args = [ 'posts_per_page' => isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : 20, 'paged' => isset( $request['page'] ) ? $request['page'] : 1, - 'post_type' => $post_type, + 'post_type' => array( 'post', 'page' ), 'post_status' => isset( $request['post_status'] ) ? $request['post_status'] : array( 'any' ), ]; From 03a25b0613b89a47c486493c77da8b25e5edfcf3 Mon Sep 17 00:00:00 2001 From: Chigozie Orunta Date: Sat, 14 May 2022 23:50:27 +0100 Subject: [PATCH 03/24] Show View All for all connection types --- includes/classes/PullListTable.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 9cd2026a2..3b46d4eee 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -612,13 +612,11 @@ public function extra_tablenav( $which ) {
pull_post_type = ''; $connection_now->pull_post_types = \Distributor\Utils\available_pull_post_types( $connection_now, $connection_type ); - // Ensure we have at least one post type to pull. - $connection_now->pull_post_type = ''; - if ( ! empty( $connection_now->pull_post_types ) ) { - $connection_now->pull_post_type = ( 'internal' === $connection_type ) ? 'all' : $connection_now->pull_post_types[0]['slug']; - } - // Set the post type we want to pull (if any) // This is either from a query param, "post" post type, or the first in the list foreach ( $connection_now->pull_post_types as $post_type ) { - if ( isset( $_GET['pull_post_type'] ) ) { // @codingStandardsIgnoreLine No nonce needed here. - if ( $_GET['pull_post_type'] === $post_type['slug'] ) { // @codingStandardsIgnoreLine Comparing values, no nonce needed. - $connection_now->pull_post_type = $post_type['slug']; + if ( ! empty( $_GET['pull_post_type'] ) ) { // @codingStandardsIgnoreLine No nonce needed here. + if ( 'all' === $_GET['pull_post_type'] ) { + $connection_now->pull_post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); break; - } - } else { - if ( 'post' === $post_type['slug'] && 'external' === $connection_type ) { + } elseif ( $_GET['pull_post_type'] === $post_type['slug'] ) { // @codingStandardsIgnoreLine Comparing values, no nonce needed. $connection_now->pull_post_type = $post_type['slug']; break; } + } else { + $connection_now->pull_post_type = ! empty( $post_type['slug'] ) ? $post_type['slug'] : 'post'; + break; } } ?> From 96632aaed5927732475975e81a063af5dd057831 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Sat, 14 Jan 2023 11:09:31 +0530 Subject: [PATCH 05/24] improve the way data is pulled --- includes/classes/PullListTable.php | 49 ++++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 4f86798e9..ecbd25369 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -441,15 +441,11 @@ public function prepare_items() { $current_page = $this->get_pagenum(); - // Support 'View all' filtering for internal connections. - if ( is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' ) ) { - if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { - $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); - } else { - $post_type = $connection_now->pull_post_type; - } + // Support 'View all' filtering for all type of connections. + if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { + $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); } else { - $post_type = $connection_now->pull_post_type ? $connection_now->pull_post_type : 'post'; + $post_type = $connection_now->pull_post_type; } $remote_get_args = [ @@ -527,17 +523,29 @@ public function prepare_items() { $remote_get_args['paged'] = 1; } - $remote_get = $connection_now->remote_get( $remote_get_args ); + if ( ! is_array( $remote_get_args['post_type'] ) ) { + $remote_get_args['post_type'] = [ $remote_get_args['post_type'] ]; + } - if ( is_wp_error( $remote_get ) ) { - $this->pull_error = $remote_get->get_error_messages(); + $total_items = ''; + $response_data = []; - return; - } + foreach( $remote_get_args['post_type'] as $type ) { + $remote_get_args['post_type'] = $type; + $remote_get = $connection_now->remote_get( $remote_get_args ); - // Get total items retrieved from the remote request if not already set. - if ( false === $total_items ) { - $total_items = $remote_get['total_items']; + if ( is_wp_error( $remote_get ) ) { + $this->pull_error = $remote_get->get_error_messages(); + + continue; + } + + // Get total items retrieved from the remote request if not already set. + // if ( false === $response_data['total_items'] ) { + $total_items += $remote_get['total_items']; + $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); + + // } } $this->set_pagination_args( @@ -547,7 +555,7 @@ public function prepare_items() { ] ); - foreach ( $remote_get['items'] as $item ) { + foreach ( $response_data as $item ) { $this->items[] = $item; } } @@ -611,8 +619,9 @@ public function extra_tablenav( $which ) { } else { $connection_type = 'external'; } - - if ( $connection_now && $connection_now->pull_post_types && $connection_now->pull_post_type ) : + // echo "
"; print_r($connection_now);echo "
"; +// var_dump($connection_now && $connection_now->pull_post_types && $connection_now->pull_post_type); + if ( $connection_now && $connection_now->pull_post_types ) : ?>
@@ -622,7 +631,7 @@ public function extra_tablenav( $which ) { pull_post_types as $post_type ) : ?> - From 169781534c582e625be73da6085a5ed6a601a077 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Sat, 14 Jan 2023 11:15:59 +0530 Subject: [PATCH 06/24] improve some phpcs errors --- includes/classes/PullListTable.php | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index ecbd25369..f0ea08b29 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -530,22 +530,17 @@ public function prepare_items() { $total_items = ''; $response_data = []; - foreach( $remote_get_args['post_type'] as $type ) { + foreach ( $remote_get_args['post_type'] as $type ) { $remote_get_args['post_type'] = $type; - $remote_get = $connection_now->remote_get( $remote_get_args ); + $remote_get = $connection_now->remote_get( $remote_get_args ); if ( is_wp_error( $remote_get ) ) { $this->pull_error = $remote_get->get_error_messages(); - continue; } - // Get total items retrieved from the remote request if not already set. - // if ( false === $response_data['total_items'] ) { - $total_items += $remote_get['total_items']; - $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); - - // } + $total_items += $remote_get['total_items']; + $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); } $this->set_pagination_args( @@ -619,8 +614,7 @@ public function extra_tablenav( $which ) { } else { $connection_type = 'external'; } - // echo "
"; print_r($connection_now);echo "
"; -// var_dump($connection_now && $connection_now->pull_post_types && $connection_now->pull_post_type); + if ( $connection_now && $connection_now->pull_post_types ) : ?> From d39eb312df602cfbb374f00863ff32adddde15d3 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Sat, 14 Jan 2023 15:05:22 +0530 Subject: [PATCH 07/24] resolve phpcs misalignment issue --- includes/classes/PullListTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index f0ea08b29..8a95cf49c 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -539,7 +539,7 @@ public function prepare_items() { continue; } - $total_items += $remote_get['total_items']; + $total_items += $remote_get['total_items']; $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); } From 86c342437ae5962b14ca18bb08b0a0130a454e93 Mon Sep 17 00:00:00 2001 From: Dhanendran Rajagopal Date: Fri, 8 Dec 2023 23:36:16 +0530 Subject: [PATCH 08/24] Check return value of get_post_meta --- includes/utils.php | 1 + 1 file changed, 1 insertion(+) diff --git a/includes/utils.php b/includes/utils.php index 41aa5b8df..8b84204d5 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -435,6 +435,7 @@ function excluded_meta() { function prepare_meta( $post_id ) { update_postmeta_cache( array( $post_id ) ); $meta = get_post_meta( $post_id ); + $meta = is_array( $meta ) ? $meta : array(); $prepared_meta = array(); $excluded_meta = excluded_meta(); From 137ee7b53566125ed417281cca8f6d9f6ff18c8c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 18 Jun 2024 06:30:00 +0000 Subject: [PATCH 09/24] Bump the npm_and_yarn group across 1 directory with 5 updates Bumps the npm_and_yarn group with 5 updates in the / directory: | Package | From | To | | --- | --- | --- | | [braces](https://github.com/micromatch/braces) | `3.0.2` | `3.0.3` | | [ip](https://github.com/indutny/node-ip) | `1.1.9` | `removed` | | [pac-resolver](https://github.com/TooTallNate/proxy-agents/tree/HEAD/packages/pac-resolver) | `7.0.0` | `7.0.1` | | [socks](https://github.com/JoshGlazebrook/socks) | `2.7.1` | `2.8.3` | | [ws](https://github.com/websockets/ws) | `7.5.9` | `7.5.10` | Updates `braces` from 3.0.2 to 3.0.3 - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md) - [Commits](https://github.com/micromatch/braces/compare/3.0.2...3.0.3) Removes `ip` Updates `pac-resolver` from 7.0.0 to 7.0.1 - [Release notes](https://github.com/TooTallNate/proxy-agents/releases) - [Changelog](https://github.com/TooTallNate/proxy-agents/blob/main/packages/pac-resolver/CHANGELOG.md) - [Commits](https://github.com/TooTallNate/proxy-agents/commits/pac-resolver@7.0.1/packages/pac-resolver) Updates `socks` from 2.7.1 to 2.8.3 - [Release notes](https://github.com/JoshGlazebrook/socks/releases) - [Commits](https://github.com/JoshGlazebrook/socks/compare/2.7.1...2.8.3) Updates `ws` from 7.5.9 to 7.5.10 - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/7.5.9...7.5.10) --- updated-dependencies: - dependency-name: braces dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: ip dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: pac-resolver dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: socks dependency-type: indirect dependency-group: npm_and_yarn - dependency-name: ws dependency-type: indirect dependency-group: npm_and_yarn ... Signed-off-by: dependabot[bot] --- package-lock.json | 165 ++++++++++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 72 deletions(-) diff --git a/package-lock.json b/package-lock.json index a90feccc9..ede458f05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6191,12 +6191,12 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -10161,9 +10161,9 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "dependencies": { "to-regex-range": "^5.0.1" @@ -11503,10 +11503,29 @@ "deprecated": "We've written a new parser that's 6x faster and is backwards compatible. Please use @formatjs/icu-messageformat-parser", "dev": true }, - "node_modules/ip": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.9.tgz", - "integrity": "sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ==", + "node_modules/ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "dependencies": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "engines": { + "node": ">= 12" + } + }, + "node_modules/ip-address/node_modules/jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, + "node_modules/ip-address/node_modules/sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "dev": true }, "node_modules/ipaddr.js": { @@ -13581,9 +13600,9 @@ } }, "node_modules/lighthouse/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "engines": { "node": ">=8.3.0" @@ -15859,13 +15878,12 @@ } }, "node_modules/pac-resolver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", - "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", + "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", "dev": true, "dependencies": { "degenerator": "^5.0.0", - "ip": "^1.1.8", "netmask": "^2.0.2" }, "engines": { @@ -18483,16 +18501,16 @@ } }, "node_modules/socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "dependencies": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" }, "engines": { - "node": ">= 10.13.0", + "node": ">= 10.0.0", "npm": ">= 3.0.0" } }, @@ -18522,12 +18540,6 @@ "node": ">= 14" } }, - "node_modules/socks/node_modules/ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", - "dev": true - }, "node_modules/source-map": { "version": "0.7.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", @@ -20423,9 +20435,9 @@ } }, "node_modules/webpack-bundle-analyzer/node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "engines": { "node": ">=8.3.0" @@ -21039,9 +21051,9 @@ } }, "node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "dev": true, "engines": { "node": ">=10.0.0" @@ -25834,12 +25846,12 @@ } }, "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, "requires": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" } }, "browser-stdout": { @@ -28802,9 +28814,9 @@ } }, "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, "requires": { "to-regex-range": "^5.0.1" @@ -29793,11 +29805,29 @@ "integrity": "sha512-IMSCKVf0USrM/959vj3xac7s8f87sc+80Y/ipBzdKy4ifBv5Gsj2tZ41EAaURVg01QU71fYr77uA8Meh6kELbg==", "dev": true }, - "ip": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.9.tgz", - "integrity": "sha512-cyRxvOEpNHNtchU3Ln9KC/auJgup87llfQpQ+t5ghoC/UhL16SWzbueiCsdTnWmqAWl7LadfuwhlqmtOaqMHdQ==", - "dev": true + "ip-address": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", + "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", + "dev": true, + "requires": { + "jsbn": "1.1.0", + "sprintf-js": "^1.1.3" + }, + "dependencies": { + "jsbn": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", + "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", + "dev": true + }, + "sprintf-js": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", + "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", + "dev": true + } + } }, "ipaddr.js": { "version": "2.1.0", @@ -31318,9 +31348,9 @@ } }, "ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "requires": {} }, @@ -33101,13 +33131,12 @@ } }, "pac-resolver": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.0.tgz", - "integrity": "sha512-Fd9lT9vJbHYRACT8OhCbZBbxr6KRSawSovFpy8nDGshaK99S/EBhVIHp9+crhxrsZOuvLpgL1n23iyPg6Rl2hg==", + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz", + "integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==", "dev": true, "requires": { "degenerator": "^5.0.0", - "ip": "^1.1.8", "netmask": "^2.0.2" } }, @@ -34997,21 +35026,13 @@ } }, "socks": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", - "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", + "integrity": "sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw==", "dev": true, "requires": { - "ip": "^2.0.0", + "ip-address": "^9.0.5", "smart-buffer": "^4.2.0" - }, - "dependencies": { - "ip": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.1.tgz", - "integrity": "sha512-lJUL9imLTNi1ZfXT+DU6rBBdbiKGBuay9B6xGSPVjUeQwaH1RIGqef8RZkUtHioLmSNpPR5M4HVKJGm1j8FWVQ==", - "dev": true - } } }, "socks-proxy-agent": { @@ -36520,9 +36541,9 @@ "dev": true }, "ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, "requires": {} } @@ -36966,9 +36987,9 @@ } }, "ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.17.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", + "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", "dev": true, "requires": {} }, From 58471b8aa2f22bf922eead522af7acbef5a273a4 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Wed, 26 Jun 2024 22:42:12 +0530 Subject: [PATCH 10/24] use post type variable --- includes/rest-api.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index d9cdab03c..a0e814c33 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -623,10 +623,11 @@ function check_post_types_permissions() { * @return \WP_REST_Response|\WP_Error */ function get_pull_content_list( $request ) { - $args = [ + $post_type = ! empty( $request['post_type'] ) ? $request['post_type'] : array( 'post', 'page' ); + $args = [ 'posts_per_page' => isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : 20, 'paged' => isset( $request['page'] ) ? $request['page'] : 1, - 'post_type' => array( 'post', 'page' ), + 'post_type' => $post_type, 'post_status' => isset( $request['post_status'] ) ? $request['post_status'] : array( 'any' ), 'order' => ! empty( $request['order'] ) ? strtoupper( $request['order'] ) : 'DESC', ]; From 342cb0c8f506d72f952e78c015a545e841b01157 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Thu, 27 Jun 2024 00:26:34 +0530 Subject: [PATCH 11/24] fix the operand type error --- includes/classes/PullListTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 8a95cf49c..606710887 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -527,7 +527,7 @@ public function prepare_items() { $remote_get_args['post_type'] = [ $remote_get_args['post_type'] ]; } - $total_items = ''; + $total_items = 0; $response_data = []; foreach ( $remote_get_args['post_type'] as $type ) { From 5332b6c0da83ebcf9be771364030939e0685879e Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Thu, 27 Jun 2024 00:34:34 +0530 Subject: [PATCH 12/24] add support for multiple pull errors --- includes/classes/PullListTable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 606710887..e14fc872a 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -29,9 +29,9 @@ class PullListTable extends \WP_List_Table { /** * Save error to determine if we can show the pull table * - * @var bool + * @var array */ - public $pull_error; + public $pull_error = []; /** * Initialize pull table @@ -535,7 +535,7 @@ public function prepare_items() { $remote_get = $connection_now->remote_get( $remote_get_args ); if ( is_wp_error( $remote_get ) ) { - $this->pull_error = $remote_get->get_error_messages(); + $this->pull_error[] = $remote_get->get_error_messages(); continue; } From e474219c8cc5cdc1e226d92bd03d84f6886cccdd Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Thu, 27 Jun 2024 00:50:01 +0530 Subject: [PATCH 13/24] improve the logic for view all --- includes/classes/PullListTable.php | 32 ++++++++++-------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index e14fc872a..34d515989 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -437,16 +437,9 @@ public function prepare_items() { /** Process bulk action */ $this->process_bulk_action(); - $per_page = $this->get_items_per_page( 'pull_posts_per_page', get_option( 'posts_per_page' ) ); - + $per_page = $this->get_items_per_page( 'pull_posts_per_page', get_option( 'posts_per_page' ) ); $current_page = $this->get_pagenum(); - - // Support 'View all' filtering for all type of connections. - if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { - $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); - } else { - $post_type = $connection_now->pull_post_type; - } + $post_type = ! empty( $connection_now->pull_post_type ) ? $connection_now->pull_post_type : array( 'post', 'page' ); $remote_get_args = [ 'posts_per_page' => $per_page, @@ -527,22 +520,19 @@ public function prepare_items() { $remote_get_args['post_type'] = [ $remote_get_args['post_type'] ]; } - $total_items = 0; - $response_data = []; + $total_items = 0; - foreach ( $remote_get_args['post_type'] as $type ) { - $remote_get_args['post_type'] = $type; - $remote_get = $connection_now->remote_get( $remote_get_args ); + // Setup remote connection from the connection object. + $remote_get = $connection_now->remote_get( $remote_get_args ); - if ( is_wp_error( $remote_get ) ) { - $this->pull_error[] = $remote_get->get_error_messages(); - continue; - } - - $total_items += $remote_get['total_items']; - $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); + // Check and throw error if there is one. + if ( is_wp_error( $remote_get ) ) { + $this->pull_error[] = $remote_get->get_error_messages(); } + $total_items = $remote_get['total_items']; + $response_data = array_merge( $response_data, array_values( $remote_get['items'] ) ); + $this->set_pagination_args( [ 'total_items' => $total_items, From dbc5104b82b68e391253996a01206d07c973e8f8 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Fri, 28 Jun 2024 15:20:08 +0530 Subject: [PATCH 14/24] resolve fatal error --- includes/classes/PullListTable.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 34d515989..d1b17c03b 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -520,7 +520,8 @@ public function prepare_items() { $remote_get_args['post_type'] = [ $remote_get_args['post_type'] ]; } - $total_items = 0; + $total_items = 0; + $response_data = array(); // Setup remote connection from the connection object. $remote_get = $connection_now->remote_get( $remote_get_args ); From 5a1177927f53281ef6cae5b7cf6f11743f68d920 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Fri, 28 Jun 2024 15:26:27 +0530 Subject: [PATCH 15/24] reverted pull error change --- includes/classes/PullListTable.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index d1b17c03b..2b97c2ae2 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -29,9 +29,9 @@ class PullListTable extends \WP_List_Table { /** * Save error to determine if we can show the pull table * - * @var array + * @var bool */ - public $pull_error = []; + public $pull_error; /** * Initialize pull table @@ -528,7 +528,7 @@ public function prepare_items() { // Check and throw error if there is one. if ( is_wp_error( $remote_get ) ) { - $this->pull_error[] = $remote_get->get_error_messages(); + $this->pull_error = $remote_get->get_error_messages(); } $total_items = $remote_get['total_items']; From 75a23d78269a6590fbe305f8f5c95ad07d928ac4 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Fri, 28 Jun 2024 15:28:06 +0530 Subject: [PATCH 16/24] revert change to the removed code --- includes/classes/PullListTable.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 2b97c2ae2..084762335 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -439,7 +439,17 @@ public function prepare_items() { $per_page = $this->get_items_per_page( 'pull_posts_per_page', get_option( 'posts_per_page' ) ); $current_page = $this->get_pagenum(); - $post_type = ! empty( $connection_now->pull_post_type ) ? $connection_now->pull_post_type : array( 'post', 'page' ); + + // Support 'View all' filtering for internal connections. + if ( is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' ) ) { + if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { + $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); + } else { + $post_type = $connection_now->pull_post_type; + } + } else { + $post_type = ! empty( $connection_now->pull_post_type ) ? $connection_now->pull_post_type : array( 'post', 'page' ); + } $remote_get_args = [ 'posts_per_page' => $per_page, From 7cdc43be12326f70b70766697eb975f7270c71f7 Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Thu, 4 Jul 2024 10:56:38 +1000 Subject: [PATCH 17/24] Resolve array to string conversion notices. --- includes/classes/PullListTable.php | 10 +++------- includes/pull-ui.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/includes/classes/PullListTable.php b/includes/classes/PullListTable.php index 084762335..759afe833 100644 --- a/includes/classes/PullListTable.php +++ b/includes/classes/PullListTable.php @@ -441,14 +441,10 @@ public function prepare_items() { $current_page = $this->get_pagenum(); // Support 'View all' filtering for internal connections. - if ( is_a( $connection_now, '\Distributor\InternalConnections\NetworkSiteConnection' ) ) { - if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { - $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); - } else { - $post_type = $connection_now->pull_post_type; - } + if ( empty( $connection_now->pull_post_type ) || 'all' === $connection_now->pull_post_type ) { + $post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); } else { - $post_type = ! empty( $connection_now->pull_post_type ) ? $connection_now->pull_post_type : array( 'post', 'page' ); + $post_type = $connection_now->pull_post_type; } $remote_get_args = [ diff --git a/includes/pull-ui.php b/includes/pull-ui.php index 7166777d9..5261b3a34 100644 --- a/includes/pull-ui.php +++ b/includes/pull-ui.php @@ -475,19 +475,25 @@ function dashboard() { $connection_now->pull_post_type = ''; $connection_now->pull_post_types = \Distributor\Utils\available_pull_post_types( $connection_now, $connection_type ); + // Ensure we have at least one post type to pull. + $connection_now->pull_post_type = ''; + if ( ! empty( $connection_now->pull_post_types ) ) { + $connection_now->pull_post_type = 'all'; + } + // Set the post type we want to pull (if any) // This is either from a query param, "post" post type, or the first in the list foreach ( $connection_now->pull_post_types as $post_type ) { - if ( ! empty( $_GET['pull_post_type'] ) ) { // @codingStandardsIgnoreLine No nonce needed here. + if ( ! empty( $_GET['pull_post_type'] ) ) { if ( 'all' === $_GET['pull_post_type'] ) { - $connection_now->pull_post_type = wp_list_pluck( $connection_now->pull_post_types, 'slug' ); + $connection_now->pull_post_type = 'all'; break; - } elseif ( $_GET['pull_post_type'] === $post_type['slug'] ) { // @codingStandardsIgnoreLine Comparing values, no nonce needed. + } elseif ( $_GET['pull_post_type'] === $post_type['slug'] ) { $connection_now->pull_post_type = $post_type['slug']; break; } } else { - $connection_now->pull_post_type = ! empty( $post_type['slug'] ) ? $post_type['slug'] : 'post'; + $connection_now->pull_post_type = ! empty( $post_type['slug'] ) ? $post_type['slug'] : 'all'; break; } } From a382cfdcd612234476e8dc4b50937f15238010aa Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Thu, 4 Jul 2024 23:53:45 +0530 Subject: [PATCH 18/24] Early return if meta is false --- includes/utils.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/utils.php b/includes/utils.php index 8f604f94d..5b139308e 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -435,6 +435,11 @@ function excluded_meta() { function prepare_meta( $post_id ) { update_postmeta_cache( array( $post_id ) ); $meta = get_post_meta( $post_id ); + + if ( false === $meta ) { + return array(); + } + $meta = is_array( $meta ) ? $meta : array(); $prepared_meta = array(); $excluded_meta = excluded_meta(); From 2f6c586a223ecb69330b6ed3f592a542e362c533 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:23:21 +0530 Subject: [PATCH 19/24] Update includes/utils.php Co-authored-by: Faisal Alvi --- includes/utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index 5b139308e..607a07985 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -434,7 +434,7 @@ function excluded_meta() { */ function prepare_meta( $post_id ) { update_postmeta_cache( array( $post_id ) ); - $meta = get_post_meta( $post_id ); + $meta = get_post_meta( $post_id ); if ( false === $meta ) { return array(); From c151a3ad79bdecc93b5f786eb1ff1b1444f805bf Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar <8456197+kirtangajjar@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:23:51 +0530 Subject: [PATCH 20/24] Update includes/utils.php Co-authored-by: Faisal Alvi --- includes/utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index 607a07985..beea76d2e 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -440,7 +440,7 @@ function prepare_meta( $post_id ) { return array(); } - $meta = is_array( $meta ) ? $meta : array(); + $meta = is_array( $meta ) ? $meta : array(); $prepared_meta = array(); $excluded_meta = excluded_meta(); From 253cf825bb18ba6a5a7d22c3cec4034b9a09bfe3 Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Sat, 6 Jul 2024 16:11:38 +0530 Subject: [PATCH 21/24] revert the default post type to just post --- includes/rest-api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index a0e814c33..5cc2b656e 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -623,7 +623,7 @@ function check_post_types_permissions() { * @return \WP_REST_Response|\WP_Error */ function get_pull_content_list( $request ) { - $post_type = ! empty( $request['post_type'] ) ? $request['post_type'] : array( 'post', 'page' ); + $post_type = ! empty( $request['post_type'] ) ? $request['post_type'] : array( 'post' ); $args = [ 'posts_per_page' => isset( $request['posts_per_page'] ) ? $request['posts_per_page'] : 20, 'paged' => isset( $request['page'] ) ? $request['page'] : 1, From 58984799c1ac40daeed3dff5d731c951296d843e Mon Sep 17 00:00:00 2001 From: Faisal Alvi Date: Tue, 9 Jul 2024 17:25:39 +0530 Subject: [PATCH 22/24] Update includes/utils.php --- includes/utils.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/utils.php b/includes/utils.php index beea76d2e..607a07985 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -440,7 +440,7 @@ function prepare_meta( $post_id ) { return array(); } - $meta = is_array( $meta ) ? $meta : array(); + $meta = is_array( $meta ) ? $meta : array(); $prepared_meta = array(); $excluded_meta = excluded_meta(); From a03c26fb693c24724e72f79ca20fef340ce158ec Mon Sep 17 00:00:00 2001 From: Mehul Gohil Date: Sat, 13 Jul 2024 08:43:39 +0530 Subject: [PATCH 23/24] replace get post type with distributable one --- includes/rest-api.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/includes/rest-api.php b/includes/rest-api.php index 41dceed42..c008a18eb 100644 --- a/includes/rest-api.php +++ b/includes/rest-api.php @@ -586,12 +586,7 @@ function distributor_meta() { * Check user permissions for available post types */ function check_post_types_permissions() { - $types = get_post_types( - array( - 'show_in_rest' => true, - ), - 'objects' - ); + $types = Utils\distributable_post_types( 'objects' ); $response = array( 'can_get' => array(), From eecf7a11ba0fb6e5e24d4452222f67a3dfa70369 Mon Sep 17 00:00:00 2001 From: Siddharth Thevaril Date: Mon, 15 Jul 2024 00:33:32 +0530 Subject: [PATCH 24/24] fix undefined array key "id" --- includes/classes/DistributorPost.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/classes/DistributorPost.php b/includes/classes/DistributorPost.php index 17d1d5eb3..fef6d0c18 100644 --- a/includes/classes/DistributorPost.php +++ b/includes/classes/DistributorPost.php @@ -748,7 +748,11 @@ protected function parse_blocks_for_attachment_id( $block ) { } if ( in_array( $block['blockName'], $block_names, true ) ) { - $media[] = $block['attrs'][ $media_blocks[ $block['blockName'] ] ]; + $attribute_key = $media_blocks[ $block['blockName'] ]; + + if ( isset( $block['attrs'][ $attribute_key ] ) ) { + $media[] = $block['attrs'][ $attribute_key ]; + } } return $media;