From d82c85e0085680fd6088b8ecff2eac67a193204d Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Thu, 15 Sep 2022 09:37:15 -0600 Subject: [PATCH 1/6] Add support for Jetpack CRM Sample Data Generator --- features/jetpack-crm.php | 67 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/features/jetpack-crm.php b/features/jetpack-crm.php index 00c34aa..5927420 100644 --- a/features/jetpack-crm.php +++ b/features/jetpack-crm.php @@ -15,6 +15,8 @@ function () { 'jpcrm' => false, 'jpcrm-build' => false, 'jpcrm-version' => false, + 'jpcrm-populate-crm-data' => false, + 'jpcrm-populate-woo-data' => false, ); add_action( @@ -48,6 +50,17 @@ function ( &$app, $features, $domain ) use ( $defaults ) { } + if ( $features['jpcrm-populate-crm-data'] || $features['jpcrm-populate-woo-data'] ) { + add_jpcrm_sdg(); + if ( $features['jpcrm-populate-crm-data'] ) { + populate_crm_data(); + } + if ( $features['jpcrm-populate-woo-data'] ) { + populate_woo_data(); + } + + } + }, 10, 3 @@ -69,6 +82,14 @@ function ( $features, $json_params ) { $features['jpcrm-build'] = $json_params['jpcrm-build']; } + if ( isset( $json_params['jpcrm-populate-crm-data'] ) ) { + $features['jpcrm-populate-crm-data'] = $json_params['jpcrm-populate-crm-data']; + } + + if ( isset( $json_params['jpcrm-populate-woo-data'] ) ) { + $features['jpcrm-populate-woo-data'] = $json_params['jpcrm-populate-woo-data']; + } + return $features; }, 10, @@ -133,6 +154,50 @@ function ( $s ) use ( $cmd ) { ); } +/** + * Installs and activates Jetpack CRM Sample Data Generator. + */ +function add_jpcrm_sdg() { + $jpcrm_sdg_url = 'https://jetpackcrm-builds.s3.amazonaws.com/jpcrm-sdg/jpcrm-sdg.zip'; + + $cmd = "wp plugin install $jpcrm_sdg_url --activate"; + + add_filter( + 'jurassic_ninja_feature_command', + function ( $s ) use ( $cmd ) { + return "$s && $cmd"; + } + ); +} + +/** + * Populates Jetpack CRM with data from JPCRM SDG. + */ +function populate_crm_data() { + $cmd = "wp jpcrmsdg --objtype=all"; + + add_filter( + 'jurassic_ninja_feature_command', + function ( $s ) use ( $cmd ) { + return "$s && $cmd"; + } + ); +} + +/** + * Populates Woo with data from JPCRM SDG. + */ +function populate_woo_data() { + $cmd = "wp jpcrmsdg --objtype=woo"; + + add_filter( + 'jurassic_ninja_feature_command', + function ( $s ) use ( $cmd ) { + return "$s && $cmd"; + } + ); +} + /** * Register a shortcode which renders Jetpack Licensing controls suitable for SpecialOps usage. */ @@ -154,6 +219,8 @@ function () {
+ + Date: Thu, 15 Sep 2022 09:37:31 -0600 Subject: [PATCH 2/6] Only show Woo data populator option if Woo is installed --- features/jetpack-crm.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/features/jetpack-crm.php b/features/jetpack-crm.php index 5927420..f3499eb 100644 --- a/features/jetpack-crm.php +++ b/features/jetpack-crm.php @@ -223,6 +223,18 @@ function () { + Date: Thu, 15 Sep 2022 09:38:01 -0600 Subject: [PATCH 3/6] Tweak some var names --- features/jetpack-crm.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/features/jetpack-crm.php b/features/jetpack-crm.php index f3499eb..6f255b7 100644 --- a/features/jetpack-crm.php +++ b/features/jetpack-crm.php @@ -122,11 +122,11 @@ function ( $s ) use ( $cmd ) { } /** - * Installs and activates a specified build of Jetpack CRM from our custom build URL. + * Installs and activates a specified branch of Jetpack CRM from our custom build URL. * - * @param string $build Hash of build to use. + * @param string $branch name of branch to use. */ -function add_jpcrm_from_custom_build( $build ) { +function add_jpcrm_from_custom_build( $branch ) { // phpcs:disable Squiz.PHP.CommentedOutCode.Found @@ -138,11 +138,11 @@ function add_jpcrm_from_custom_build( $build ) { */ // phpcs:enable - $clean_build = str_replace( '/', '_', $build ); + $clean_branch = str_replace( '/', '_', $branch ); // note that this public link is in a public repo $jpcrm_build_base_url = 'https://jetpackcrm-builds.s3.amazonaws.com/builds/'; - $jpcrm_build_url = $jpcrm_build_base_url . 'zero-bs-crm-' . $clean_build . '.zip'; + $jpcrm_build_url = $jpcrm_build_base_url . 'zero-bs-crm-' . $clean_branch . '.zip'; $cmd = "wp plugin install $jpcrm_build_url --activate"; From 3e144510e8ebb5ec412620ac3df4ee897306d39e Mon Sep 17 00:00:00 2001 From: tbradsha <32492176+tbradsha@users.noreply.github.com> Date: Thu, 15 Sep 2022 09:52:06 -0600 Subject: [PATCH 4/6] Select radio button associated with input --- features/jetpack-crm.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/features/jetpack-crm.php b/features/jetpack-crm.php index 6f255b7..574d92f 100644 --- a/features/jetpack-crm.php +++ b/features/jetpack-crm.php @@ -224,6 +224,7 @@ function () { Date: Thu, 15 Sep 2022 10:10:52 -0600 Subject: [PATCH 5/6] One more tweak --- features/jetpack-crm.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/jetpack-crm.php b/features/jetpack-crm.php index 574d92f..aa29f11 100644 --- a/features/jetpack-crm.php +++ b/features/jetpack-crm.php @@ -220,7 +220,7 @@ function () { - +