Skip to content

Commit

Permalink
Revert "Revert "Transfer Verbum app into into jetpack-mu-wpcom""
Browse files Browse the repository at this point in the history
  • Loading branch information
alshakero authored Jan 23, 2024
1 parent 61c3400 commit 131396f
Show file tree
Hide file tree
Showing 67 changed files with 5,271 additions and 58 deletions.
97 changes: 90 additions & 7 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/packages/jetpack-mu-wpcom/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ module.exports = {
allowedTextDomain: 'jetpack-mu-wpcom',
},
],
'testing-library/prefer-screen-queries': 'off',
'react/jsx-no-bind': 'off',
// Not needed for TypeScript.
'jsdoc/require-param-type': 'off',
'jsdoc/require-returns-type': 'off',
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add Verbum Comments in jetpack-mu-wpcom plugin
2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "5.9.x-dev"
"dev-trunk": "5.10.x-dev"
},
"textdomain": "jetpack-mu-wpcom",
"version-constants": {
Expand Down
18 changes: 15 additions & 3 deletions projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom",
"version": "5.9.0",
"version": "5.10.0-alpha",
"description": "Enhances your site with features powered by WordPress.com",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme",
"bugs": {
Expand All @@ -19,6 +19,7 @@
"build-js": "pnpm clean && webpack",
"build-production": "echo 'Not implemented.'",
"build-production-js": "NODE_ENV=production BABEL_ENV=production pnpm build-js",
"lint": "eslint --ext .js,.jsx,.cjs,.mjs,.ts,.tsx .",
"clean": "rm -rf src/build/"
},
"optionalDependencies": {
Expand All @@ -28,7 +29,13 @@
"devDependencies": {
"@automattic/jetpack-webpack-config": "workspace:*",
"@babel/core": "7.23.5",
"@babel/plugin-transform-react-jsx": "7.23.4",
"@babel/preset-react": "7.23.3",
"@types/node": "^20.4.2",
"@types/react": "^18.2.28",
"@types/react-dom": "18.2.0",
"babel-plugin-transform-rename-properties": "0.1.0",
"copy-webpack-plugin": "11.0.0",
"sass": "1.64.1",
"sass-loader": "12.4.0",
"typescript": "^5.0.4",
Expand All @@ -37,15 +44,20 @@
},
"dependencies": {
"@automattic/typography": "1.0.0",
"@preact/signals": "^1.2.2",
"@sentry/browser": "7.80.1",
"@wordpress/api-fetch": "6.45.0",
"@wordpress/base-styles": "4.39.0",
"@wordpress/components": "25.14.0",
"@wordpress/dom-ready": "^3.48.0",
"@wordpress/data": "9.18.0",
"@wordpress/dom-ready": "^3.48.0",
"@wordpress/hooks": "3.48.0",
"@wordpress/i18n": "4.48.0",
"@wordpress/plugins": "6.16.0",
"@wordpress/url": "3.49.0"
"@wordpress/url": "3.49.0",
"preact": "^10.13.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"wpcom-proxy-request": "^7.0.3"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Jetpack_Mu_Wpcom main class.
*/
class Jetpack_Mu_Wpcom {
const PACKAGE_VERSION = '5.9.0';
const PACKAGE_VERSION = '5.10.0-alpha';
const PKG_DIR = __DIR__ . '/../';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;
Expand Down Expand Up @@ -42,6 +42,8 @@ public static function init() {

add_action( 'plugins_loaded', array( __CLASS__, 'load_first_posts_stream_helpers' ) );

add_action( 'plugins_loaded', array( __CLASS__, 'load_verbum_comments' ) );

// Unified navigation fix for changes in WordPress 6.2.
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'unbind_focusout_on_wp_admin_bar_menu_toggle' ) );

Expand Down Expand Up @@ -218,4 +220,42 @@ public static function load_marketplace_products_updater() {
public static function load_first_posts_stream_helpers() {
require_once __DIR__ . '/features/first-posts-stream/first-posts-stream-helpers.php';
}

/**
* Determine whether to disable the comment experience.
*
* @param int $blog_id The blog ID.
* @return boolean
*/
private function should_disable_comment_experience( $blog_id ) {
require_once WP_CONTENT_DIR . '/lib/wpforteams/functions.php';
// This covers both P2 and P2020 themes.
$is_p2 = str_contains( get_stylesheet(), 'pub/p2' ) || function_exists( '\WPForTeams\is_wpforteams_site' ) && is_wpforteams_site( $blog_id );
$is_forums = str_contains( get_stylesheet(), 'a8c/supportforums' ); // Not in /forums

// Don't load any comment experience in the Reader, GlotPress, wp-admin, or P2.
return ( 1 === $blog_id || TRANSLATE_BLOG_ID === $blog_id || is_admin() || $is_p2 || $is_forums );
}

/**
* Load Verbum Comments.
*/
public static function load_verbum_comments() {
if ( class_exists( 'Verbum_Comments' ) ) {
return;
} else {
$blog_id = get_current_blog_id();
// Jetpack loads Verbum though an iframe from jetpack.wordpress.com.
// So we need to check the GET request for the blogid.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
if ( isset( $_GET['blogid'] ) ) {
$blog_id = intval( $_GET['blogid'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
}
if ( should_disable_comment_experience( $blog_id ) ) {
return false;
}
require_once __DIR__ . '/build/verbum-comments/class-verbum-comments.php';
new \Automattic\Jetpack\Verbum_Comments();
}
}
}
Loading

0 comments on commit 131396f

Please sign in to comment.