Skip to content

Commit 4c6dbc2

Browse files
release: v1.12.15
- Starter Sites Improvements
2 parents 0bc8d2b + 6bc55b1 commit 4c6dbc2

File tree

7 files changed

+127
-21
lines changed

7 files changed

+127
-21
lines changed

assets/src/Components/ImportModal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ const ImportModal = ( {
583583
source: 'remote',
584584
frontPage: importData.front_page,
585585
shopPages: importData.shop_pages,
586+
paymentForms: importData.payment_forms,
586587
demoSlug: importData.slug,
587588
editor,
588589
} )

composer.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/Importers/Cleanup/Active_State.php

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@
1414
*/
1515
class Active_State {
1616

17-
const STATE_NAME = 'neve_last_imports';
18-
const HOUR_IN_SECONDS = 3600;
19-
const PLUGINS_NSP = 'plugins';
20-
const CATEGORY_NSP = 'category';
21-
const TAGS_NSP = 'tags';
22-
const TERMS_NSP = 'terms';
23-
const POSTS_NSP = 'posts';
24-
const COMMENTS_NSP = 'comments';
25-
const ATTACHMENT_NSP = 'attachment';
26-
const FRONT_PAGE_NSP = 'front_page_options';
27-
const SHOP_PAGE_NSP = 'shop_page_options';
28-
const THEME_MODS_NSP = 'theme_mods';
29-
const MENUS_NSP = 'menus';
30-
const WIDGETS_NSP = 'widgets';
17+
const STATE_NAME = 'neve_last_imports';
18+
const HOUR_IN_SECONDS = 3600;
19+
const PLUGINS_NSP = 'plugins';
20+
const CATEGORY_NSP = 'category';
21+
const TAGS_NSP = 'tags';
22+
const TERMS_NSP = 'terms';
23+
const POSTS_NSP = 'posts';
24+
const COMMENTS_NSP = 'comments';
25+
const ATTACHMENT_NSP = 'attachment';
26+
const FRONT_PAGE_NSP = 'front_page_options';
27+
const SHOP_PAGE_NSP = 'shop_page_options';
28+
const PAYMENT_FORM_NSP = 'payment_form_options';
29+
const THEME_MODS_NSP = 'theme_mods';
30+
const MENUS_NSP = 'menus';
31+
const WIDGETS_NSP = 'widgets';
3132
/**
3233
* @var array $state
3334
*/
@@ -64,6 +65,7 @@ private function is_allowed_property( $property_key ) {
6465
self::WIDGETS_NSP,
6566
self::FRONT_PAGE_NSP,
6667
self::SHOP_PAGE_NSP,
68+
self::PAYMENT_FORM_NSP,
6769
),
6870
true
6971
);

includes/Importers/Cleanup/Manager.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,44 @@ private function cleanup_options( $namespace, $state ) {
240240
}
241241
}
242242

243+
/**
244+
* Handles form cleanup.
245+
* @param array $state The cleanup state.
246+
*/
247+
private function cleanup_forms( $namespace, $state ) {
248+
if ( ! class_exists( 'MM_WPFS_Database' ) ) {
249+
return;
250+
}
251+
252+
$db = new \MM_WPFS_Database();
253+
254+
if ( isset( $state[ $namespace ] ) ) {
255+
foreach ( $state[ $namespace ] as $name => $form ) {
256+
$get = 'get' . ucfirst( $form['layout'] ) . ucfirst( $form['type'] ) . 'FormByName';
257+
$method = 'delete' . ucfirst( $form['layout'] ) . ucfirst( $form['type'] ) . 'Form';
258+
$id = null;
259+
260+
if ( method_exists( 'MM_WPFS_Database', $get ) ) {
261+
$item = $db->$get( $name );
262+
foreach ( $item as $key => $value ) {
263+
if ( strpos( $key, 'FormID' ) !== false ) {
264+
$id = $value;
265+
break;
266+
}
267+
}
268+
}
269+
270+
if ( empty( $id ) ) {
271+
continue;
272+
}
273+
274+
if ( method_exists( 'MM_WPFS_Database', $method ) ) {
275+
$db->$method( $id );
276+
}
277+
}
278+
}
279+
}
280+
243281
final public function do_cleanup() {
244282
$active_state = new Active_State();
245283
$state = $active_state->get();
@@ -250,6 +288,7 @@ final public function do_cleanup() {
250288
$this->cleanup_terms( $state );
251289
$this->cleanup_options( Active_State::FRONT_PAGE_NSP, $state );
252290
$this->cleanup_options( Active_State::SHOP_PAGE_NSP, $state );
291+
$this->cleanup_forms( Active_State::PAYMENT_FORM_NSP, $state );
253292
$this->cleanup_posts( $state );
254293
$this->cleanup_attachments( $state );
255294
$this->cleanup_widgets( $state );

includes/Importers/Content_Importer.php

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ public function import_remote_xml( WP_REST_Request $request ) {
156156
}
157157
do_action( 'themeisle_ob_after_shop_pages_setup' );
158158

159+
// Set payment forms.
160+
if ( isset( $body['paymentForms'] ) ) {
161+
$this->setup_payment_forms( $body['paymentForms'] );
162+
}
163+
do_action( 'themeisle_ob_after_payment_forms_setup' );
164+
159165
if ( empty( $frontpage_id ) ) {
160166
$this->logger->log( 'No front page ID.' );
161167
}
@@ -265,6 +271,62 @@ public function setup_shop_pages( $pages, $demo_slug ) {
265271
$this->logger->log( 'Shop pages set up.', 'success' );
266272
}
267273

274+
public function setup_payment_forms( $forms ) {
275+
$this->logger->log( 'Setting up payment forms.', 'progress' );
276+
if ( ! class_exists( 'MM_WPFS_Database' ) ) {
277+
$this->logger->log( 'No WP Full Stripe.', 'success' );
278+
return;
279+
}
280+
281+
if ( ! is_array( $forms ) ) {
282+
$this->logger->log( 'No Payment Forms.', 'success' );
283+
return;
284+
}
285+
286+
$db = new \MM_WPFS_Database();
287+
288+
$payment_form_options = array();
289+
foreach ( $forms as $key => $form ) {
290+
if ( ! in_array( $form['type'], array( 'payment', 'subscription', 'donation' ) ) || ! in_array( $form['layout'], array( 'inline', 'checkout' ) ) ) {
291+
continue;
292+
}
293+
294+
$check = 'get' . ucfirst( $form['layout'] ) . ucfirst( $form['type'] ) . 'FormByName';
295+
$insert = 'insert' . ucfirst( $form['layout'] ) . ucfirst( $form['type'] ) . 'Form';
296+
297+
if ( method_exists( $db, $check ) ) {
298+
$existing_form = $db->$check( $form['name'] );
299+
if ( $existing_form ) {
300+
$this->logger->log( "Form {$form['name']} already exists.", 'success' );
301+
continue;
302+
}
303+
}
304+
305+
if ( method_exists( $db, $insert ) ) {
306+
$form['data'] = array_filter(
307+
$form['data'],
308+
function ( $key ) {
309+
return strpos( $key, 'FormID' ) === false;
310+
},
311+
ARRAY_FILTER_USE_KEY
312+
);
313+
314+
$db->$insert( $form['data'] );
315+
316+
$payment_form_options[ $form['data']['name'] ] = array(
317+
'layout' => $form['layout'],
318+
'type' => $form['type'],
319+
);
320+
} else {
321+
$this->logger->log( "Method {$insert} does not exist.", 'error' );
322+
}
323+
}
324+
325+
do_action( 'themeisle_cl_add_property_state', Active_State::PAYMENT_FORM_NSP, $payment_form_options );
326+
327+
$this->logger->log( 'Payment forms set up.', 'success' );
328+
}
329+
268330
/**
269331
* Maybe bust cache for elementor plugin.
270332
*/

includes/Importers/Plugin_Importer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Plugin_Importer {
5353
'recipe-card-blocks-by-wpzoom' => 'wpzoom-recipe-card.php',
5454
'restrict-content' => 'restrictcontent.php',
5555
'pods' => 'init.php',
56+
'wp-full-stripe-free' => 'wp-full-stripe.php',
5657
);
5758

5859
public function __construct() {

onboarding/src/Components/Steps/Import.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ const Import = ( {
160160
source: 'remote',
161161
frontPage: importData.front_page,
162162
shopPages: importData.shop_pages,
163+
paymentForms: importData.payment_forms,
163164
demoSlug: importData.slug,
164165
editor,
165166
} )

0 commit comments

Comments
 (0)