diff --git a/.github/workflows/tests-php.yml b/.github/workflows/tests-php.yml index aecaa7e2ae..81b8cbfaeb 100644 --- a/.github/workflows/tests-php.yml +++ b/.github/workflows/tests-php.yml @@ -122,7 +122,7 @@ jobs: # Upload artifacts (On failure) # ------------------------------------------------------------------------------ - name: Upload artifacts - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: failure() with: name: output ${{ matrix.suite }} diff --git a/.phpcs.xml b/.phpcs.xml index 4f73fb0ad4..e62d37353a 100755 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -16,7 +16,7 @@ - + diff --git a/changelog.txt b/changelog.txt index a75bee2ef5..4384b1d792 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,27 @@ Found a bug? Have a great feature idea? Get on GitHub and tell us about it and w Our GitHub has the full list of all prior releases of Pods: https://github.com/pods-framework/pods/releases += 3.2.8 - November 17th, 2024 = + +REMINDER: PHP support for Pod Templates and Pod Pages been turned off by default in Pods 3.2.7+ (`PODS_DISABLE_EVAL` constant set to `false` can be used to re-enable it). It will be completely removed in Pods 3.3 after being deprecated back in Pods 2.3. (@sc0ttkclark) + +* Feature: Migrate the PHP in your Pod Templates and Pod Pages directly into your current theme with a new Pods Admin > Tools > Migrate PHP tool. We recommend you use a child theme that you control. PHP warnings now appear on the Pod Template and Pod Page editor screens to prompt you to run the migration. (@sc0ttkclark) +* Feature: Updated the design and user experience of the various guided screens inside of the Pods Admin to make it easier to read and click through on small screens. (@sc0ttkclark, @heybran) +* Enhanced: Pod Page template part handling for PHP template files now passes the `$pods` variable. (@sc0ttkclark) +* Enhanced: Added support for parsing magic tags in Pod Template files in the theme when you set the PHP header comment `Magic Tags: Enabled`. (@sc0ttkclark) +* Enhanced: Run wpautop on Pods Item List and Pods Related Item List blocks for the "not found" content if they are not already formatted. (@sc0ttkclark) +* Fixed: Only running wpautop for block the Pods Field block content if it does not contain div, ul, ol, heading, or p HTML tags. (@sc0ttkclark) +* Fixed: Resolve issue with empty strings showing when using magic tags before/after functionality. (@JoryHogeveen) +* Fixed: Ignore more internal WP post types and taxonomies plus others from other plugins. +* Fixed: Move load_plugin_textdomain usage into init and make it optional with the constant `PODS_LOAD_TEXTDOMAIN` set to `true`. It is no longer needed for WordPress.org plugins but may be needed in the future for testing. (@sc0ttkclark) +* Fixed: When getting plugin data, don't make it translatable. (@sc0ttkclark) +* Fixed: When saving bidirectional relationship, attempt to save hook up existing related items data in the `wp_podsrel` table with the bidirectional connection. (@sc0ttkclark) +* Fixed: Resolve PHP notices with site debug information. (@sc0ttkclark) +* Fixed: Resolve PHP warnings with empty template code. (@sc0ttkclark) +* Fixed: More improvements to Pod Page and Pod Template file loading from themes. (@sc0ttkclark) +* Fixed: Resolve issue with slug fields not formatting as expected. (@sc0ttkclark) +* Fixed: SCSS migrated from `@import` to `@use` for compatibility with the latest versions of our SCSS scripting. (@sc0ttkclark) + = 3.2.7.1 - October 9th, 2024 = * Security: Lock down heading field to only specific allowed HTML tags and preventing it from being used to insert malicious scripts. Props to the CleanTalk / Dmitrii Ignatyev for responsibly reporting this. (@sc0ttkclark) diff --git a/classes/Pods.php b/classes/Pods.php index dbcb023c35..cb11f392cb 100644 --- a/classes/Pods.php +++ b/classes/Pods.php @@ -4329,7 +4329,7 @@ private function process_magic_tags( $tag ) { ) ); } - if ( null !== $value && false !== $value ) { + if ( $value || is_numeric( $value ) ) { return $before . $value . $after; } diff --git a/classes/PodsAPI.php b/classes/PodsAPI.php index cb1212e930..1fc5cae735 100644 --- a/classes/PodsAPI.php +++ b/classes/PodsAPI.php @@ -4017,7 +4017,9 @@ public function save_field( $params, $table_operation = true, $sanitized = false pods_query( ' UPDATE `@wp_podsrel` - SET `related_field_id` = 0 + SET + `related_pod_id` = 0, + `related_field_id` = 0 WHERE `field_id` = %d ', array( $old_sister_id, @@ -4028,14 +4030,33 @@ public function save_field( $params, $table_operation = true, $sanitized = false update_post_meta( $sister_id, 'sister_id', $params->id ); if ( true === $db && pods_podsrel_enabled( $field, 'save' ) ) { - pods_query( ' - UPDATE `@wp_podsrel` - SET `related_field_id` = %d - WHERE `field_id` = %d - ', array( - $params->id, - $sister_id, - ) ); + $sister_field = $this->load_field( [ 'id' => $sister_id ] ); + + if ( $sister_field ) { + pods_query( ' + UPDATE `@wp_podsrel` + SET + `related_pod_id` = %d, + `related_field_id` = %d + WHERE `field_id` = %d + ', [ + $pod['id'], + $params->id, + $sister_id, + ] ); + + pods_query( ' + UPDATE `@wp_podsrel` + SET + `related_pod_id` = %d, + `related_field_id` = %d + WHERE `field_id` = %d + ', [ + $sister_field->get_parent_id(), + $sister_id, + $params->id, + ] ); + } } } elseif ( 0 < $old_sister_id ) { delete_post_meta( $old_sister_id, 'sister_id' ); diff --git a/classes/PodsAdmin.php b/classes/PodsAdmin.php index 3dfbcdd358..4735444971 100644 --- a/classes/PodsAdmin.php +++ b/classes/PodsAdmin.php @@ -4817,7 +4817,16 @@ public function add_debug_information( $info ) { $value = $setting_field['site_health_data'][ $value ]; } elseif ( $has_value && isset( $setting_field['data'] ) && isset( $setting_field['data'][ $value ] ) ) { $value = $setting_field['data'][ $value ]; - } elseif ( 'boolean' === $setting_field['data'] || '1' === $value || '0' === $value ) { + } elseif ( + ( + isset( $setting_field['data'] ) + && 'boolean' === $setting_field['data'] + ) + && ( + '1' === $value + || '0' === $value + ) + ) { $value = '1' === $value ? __( 'Yes', 'pods' ) : __( 'No', 'pods' ); } } diff --git a/classes/PodsInit.php b/classes/PodsInit.php index a657701910..6ad1a16d97 100644 --- a/classes/PodsInit.php +++ b/classes/PodsInit.php @@ -260,10 +260,6 @@ public function plugins_loaded() { define( 'PODS_DISABLE_EVAL', true ); } - if ( ! defined( 'PODS_TEXTDOMAIN' ) || PODS_TEXTDOMAIN ) { - load_plugin_textdomain( 'pods' ); - } - if ( ! defined( 'PODS_STATS_TRACKING' ) || PODS_STATS_TRACKING ) { $this->stats_tracking( PODS_FILE, 'pods' ); } @@ -566,6 +562,10 @@ public function core() { if ( method_exists( $avatar, 'get_avatar_data' ) ) { add_filter( 'get_avatar_data', array( $avatar, 'get_avatar_data' ), 10, 2 ); } + + if ( defined( 'PODS_TEXTDOMAIN' ) && PODS_TEXTDOMAIN ) { + load_plugin_textdomain( 'pods' ); + } } /** diff --git a/classes/PodsMeta.php b/classes/PodsMeta.php index f0e6c32020..7251dc7a68 100644 --- a/classes/PodsMeta.php +++ b/classes/PodsMeta.php @@ -2949,6 +2949,16 @@ public function is_type_covered( $type, $object_name = null ) { 'wp_navigation' => true, 'wp_template' => true, 'wp_template_part' => true, + 'wp_font_face' => true, + 'wp_font_family' => true, + // Disable ACF post types. + 'acf-taxonomy' => true, + 'acf-post-type' => true, + 'acf-field-group' => true, + 'acf-field' => true, + // Disable Advanced views. + 'acf_views' => true, + 'acf_cards' => true, // Disable Beaver Builder post types. 'fl-theme-layout' => true, 'fl-builder-template' => true, @@ -2973,6 +2983,7 @@ public function is_type_covered( $type, $object_name = null ) { 'post_format' => true, 'wp_theme' => true, 'wp_template_part_area' => true, + 'wp_pattern_category' => true, // Disable Beaver Builder taxonomies. 'fl-builder-template-category' => true, 'fl-builder-template-type' => true, diff --git a/components/Migrate-ACF/ui/wizard.php b/components/Migrate-ACF/ui/wizard.php index 00969f69b4..cd05785baf 100644 --- a/components/Migrate-ACF/ui/wizard.php +++ b/components/Migrate-ACF/ui/wizard.php @@ -9,7 +9,7 @@ array( 'id' => 'pods_cleanup' ) ) ); ?> -

+

@@ -17,11 +17,11 @@
  • - 1 + 1
  • - 2 + 2
@@ -29,37 +29,47 @@
-

+

-
-
- -

- -

-

-
- -


-
- -
+
-

+

+ +

+ +

-

+

@@ -68,10 +78,15 @@ ?>

- +

+

+ +

+
    -

    +

    @@ -105,7 +120,7 @@
-

+

@@ -114,10 +129,15 @@ ?>

- +

+

+ +

+
    -

    +

    @@ -151,8 +171,8 @@
    - - + +
    @@ -173,7 +193,33 @@ jQuery( '#pods_cleanup' ).val( $opt.data( 'opt' ) ); }; + const toggle_all = { + all: true + }; + jQuery( function ( $ ) { + $( '.pods-wizard-toggle-all' ).on( 'click', function ( e ) { + e.preventDefault(); + + const toggleData = $( this ).data( 'toggle' ); + + if ( 'undefined' == typeof toggle_all[toggleData] ) { + toggle_all[toggleData] = true; + } + + let $parent; + + if ( 'all' !== toggleData ) { + $parent = $( this ).closest( '.pods-field-option-group' ); + } else { + $parent = $( this ).closest( '.pods-wizard-option-content' ); + } + + $parent.find( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', (!toggle_all[toggleData]) ); + + toggle_all[toggleData] = (!toggle_all[toggleData]); + } ); + $( document ).Pods( 'validate' ); $( document ).Pods( 'submit' ); $( document ).Pods( 'wizard' ); diff --git a/components/Migrate-CPTUI/ui/wizard.php b/components/Migrate-CPTUI/ui/wizard.php index 7f238b9c14..a083b043ec 100644 --- a/components/Migrate-CPTUI/ui/wizard.php +++ b/components/Migrate-CPTUI/ui/wizard.php @@ -9,7 +9,7 @@ array( 'id' => 'pods_cleanup' ) ) ); ?> -

    +

    @@ -17,11 +17,11 @@
    • - 1 + 1
    • - 2 + 2
    @@ -29,36 +29,46 @@
    -

    +

    -
    -
    - -

    - -

    -
    -


    -
    - -
    +
    -

    +

    + +

    + +

    -

    +

    @@ -67,20 +77,25 @@ ?>

    - +

    +

    + +

    +
    • $post_type_label . ' (' . $post_type_name . ')', 'disable_dfv' => true, ] ); @@ -96,7 +111,7 @@ -

      +

      @@ -104,7 +119,7 @@
      -

      +

      @@ -113,19 +128,24 @@ ?>

      - +

      +

      + +

      +
      • $taxonomy_label . ' (' . $taxonomy_name . ')', 'disable_dfv' => true, ] ); @@ -140,7 +160,7 @@ -

        +

        @@ -150,8 +170,8 @@
        - - + +
        @@ -172,7 +192,33 @@ jQuery( '#pods_cleanup' ).val( $opt.data( 'opt' ) ); }; + const toggle_all = { + all: true + }; + jQuery( function ( $ ) { + $( '.pods-wizard-toggle-all' ).on( 'click', function ( e ) { + e.preventDefault(); + + const toggleData = $( this ).data( 'toggle' ); + + if ( 'undefined' == typeof toggle_all[toggleData] ) { + toggle_all[toggleData] = true; + } + + let $parent; + + if ( 'all' !== toggleData ) { + $parent = $( this ).closest( '.pods-field-option-group' ); + } else { + $parent = $( this ).closest( '.pods-wizard-option-content' ); + } + + $parent.find( '.pods-field.pods-boolean input[type="checkbox"]' ).prop( 'checked', (!toggle_all[toggleData]) ); + + toggle_all[toggleData] = (!toggle_all[toggleData]); + } ); + $( document ).Pods( 'validate' ); $( document ).Pods( 'submit' ); $( document ).Pods( 'wizard' ); diff --git a/components/Migrate-PHP/Migrate-PHP.php b/components/Migrate-PHP/Migrate-PHP.php new file mode 100644 index 0000000000..f1473ce768 --- /dev/null +++ b/components/Migrate-PHP/Migrate-PHP.php @@ -0,0 +1,459 @@ +More information about Pod Page template hierarchy | More information about Pod Template hierarchy + * + * Category: Migration + * + * Version: 1.0 + * + * Plugin: pods-migrate-php/pods-migrate-php.php + * + * @package Pods\Components + * @subpackage Migrate-PHP + */ + +use Pods\Whatsit; +use Pods\Whatsit\Page; +use Pods\Whatsit\Template; + +if ( class_exists( 'Pods_Migrate_PHP' ) ) { + return; +} + +/** + * Class Pods_Migrate_PHP + */ +class Pods_Migrate_PHP extends PodsComponent { + + /** + * {@inheritdoc} + */ + public function init() { + // Nothing to do here. + } + + /** + * Enqueue styles + */ + public function admin_assets() { + wp_enqueue_style( 'pods-wizard' ); + } + + /** + * Get the list of objects that need migration. + * + * @return array{pod_templates:Template[],pod_pages:Page[]} The list of objects that need migration. + */ + public function get_objects_that_need_migration(): array { + $pod_templates = []; + $pod_pages = []; + + $api = pods_api(); + + if ( class_exists( 'Pods_Templates' ) ) { + $pod_templates = array_filter( + $api->load_templates(), + static function( $object ) { + if ( ! $object instanceof Whatsit ) { + return false; + } + + return ! empty( $object->get_id() ) && false !== strpos( $object->get_description(), 'load_pages(), + static function( $object ) { + if ( ! $object instanceof Whatsit ) { + return false; + } + + return ( + ! empty( $object->get_id() ) + && ( + false !== strpos( $object->get_description(), 'get_arg( 'precode' ), 'get_id(); + }, $pod_templates ), $pod_templates ); + + $pod_pages = array_combine( array_map( static function( $object ) { + return $object->get_id(); + }, $pod_pages ), $pod_pages ); + + return compact( 'pod_templates', 'pod_pages' ); + } + + /** + * Show the Admin + * + * @param $options + * @param $component + */ + public function admin( $options, $component ) { + $method = 'migrate'; + + [ + 'pod_templates' => $pod_templates, + 'pod_pages' => $pod_pages, + ] = $this->get_objects_that_need_migration(); + + $has_objects_to_migrate = ! empty( $pod_templates ) || ! empty( $pod_pages ); + + // ajax_migrate + pods_view( __DIR__ . '/ui/wizard.php', compact( array_keys( get_defined_vars() ) ) ); + } + + /** + * Handle the Migration AJAX + * + * @param $params + */ + public function ajax_migrate( $params ) { + WP_Filesystem(); + + [ + 'pod_templates' => $pod_templates_available_to_migrate, + 'pod_pages' => $pod_pages_available_to_migrate, + ] = $this->get_objects_that_need_migration(); + + $objects_can_be_migrated = ! empty( $pod_templates_available_to_migrate ) || ! empty( $pod_pages_available_to_migrate ); + + $cleanup = 1 === (int) pods_v( 'cleanup', $params, 0 ); + + $pod_templates = []; + $pod_pages = []; + + $pod_templates_selected = (array) pods_v( 'templates', $params, [] ); + $pod_templates_selected = array_filter( $pod_templates_selected ); + + $pod_pages_selected = (array) pods_v( 'pages', $params, [] ); + $pod_pages_selected = array_filter( $pod_pages_selected ); + + $has_objects_to_migrate = ! empty( $pod_templates_selected ) || ! empty( $pod_pages_selected ); + + foreach ( $pod_templates_selected as $object_id => $checked ) { + if ( true === (boolean) $checked && isset( $pod_templates_available_to_migrate[ (int) $object_id ] ) ) { + $pod_templates[] = $object_id; + } + } + + foreach ( $pod_pages_selected as $object_id => $checked ) { + if ( true === (boolean) $checked && isset( $pod_pages_available_to_migrate[ (int) $object_id ] ) ) { + $pod_pages[] = $object_id; + } + } + + $pod_templates_file_paths = []; + $pod_pages_file_paths = []; + + $migrated = false; + + foreach ( $pod_templates as $object_id ) { + $migrated = true; + + $pod_templates_file_paths[] = $this->migrate_template( $object_id, $cleanup ); + } + + foreach ( $pod_pages as $object_id ) { + $migrated = true; + + $pod_pages_file_paths[] = $this->migrate_page( $object_id, $cleanup ); + } + + $content = '
        ' . "\n"; + + if ( ! $has_objects_to_migrate ) { + $content .= '

        ' . esc_html__( 'No Pod Templates or Pod Pages were selected.', 'pods' ) . '

        ' . "\n"; + } elseif ( ! $objects_can_be_migrated ) { + $content .= '

        ' . esc_html__( 'The selected Pod Templates or Pod Pages are not available for migration. They no longer contain PHP.', 'pods' ) . '

        ' . "\n"; + } elseif ( ! $migrated ) { + $content .= '

        ' . esc_html__( 'The selected Pod Templates or Pod Pages were not successfully migrated.', 'pods' ) . '

        ' . "\n"; + } else { + $content .= '

        ' . esc_html__( 'Migration Complete! The following paths were saved:', 'pods' ) . '

        ' . "\n"; + + if ( ! empty( $pod_templates_file_paths ) ) { + $content .= '

        ' . esc_html__( 'Pod Templates saved', 'pods' ) . '

        ' . "\n"; + $content .= '
          ' . "\n"; + + foreach ( $pod_templates_file_paths as $file_path ) { + $content .= '
        • ' . esc_html( $file_path ) . '
        • ' . "\n"; + } + + $content .= '
        ' . "\n"; + } + + if ( ! empty( $pod_pages_file_paths ) ) { + $content .= '

        ' . esc_html__( 'Pod Pages saved', 'pods' ) . '

        ' . "\n"; + $content .= '
          ' . "\n"; + + foreach ( $pod_pages_file_paths as $file_path ) { + $content .= '
        • ' . esc_html( $file_path ) . '
        • ' . "\n"; + } + + $content .= '
        ' . "\n"; + } + + if ( $cleanup ) { + $content .= '

        ' . esc_html__( 'The Pod Page(s) and/or Pod Template(s) were cleaned up and will now load directly from the theme files.', 'pods' ) . '

        ' . "\n"; + } else { + $content .= '

        ' . esc_html__( 'The Pod Page(s) and/or Pod Template(s) were not modified. You will need to empty the content on them before they will load from the theme files.', 'pods' ) . '

        ' . "\n"; + } + } + + return $content; + } + + private function setup_file_path( $file_path ) { + /** + * @var $wp_filesystem WP_Filesystem_Base + */ + global $wp_filesystem; + + if ( ! $wp_filesystem->is_dir( dirname( $file_path ) ) ) { + $pods_path = trailingslashit( get_stylesheet_directory() ) . 'pods'; + + if ( ! $wp_filesystem->is_dir( $pods_path ) && ! $wp_filesystem->mkdir( $pods_path, FS_CHMOD_DIR ) ) { + // translators: %s is the directory path. + pods_error( sprintf( esc_html__( 'Unable to create the directory: %s', 'pods' ), $pods_path ) ); + } + + $grandparent_path = dirname( dirname( $file_path ) ); + + if ( $pods_path !== $grandparent_path && ! $wp_filesystem->is_dir( $grandparent_path ) && ! $wp_filesystem->mkdir( $grandparent_path, FS_CHMOD_DIR ) ) { + // translators: %s is the directory path. + pods_error( sprintf( esc_html__( 'Unable to create the directory: %s', 'pods' ), $grandparent_path ) ); + } + + if ( ! $wp_filesystem->mkdir( dirname( $file_path ), FS_CHMOD_DIR ) ) { + // translators: %s is the directory path. + pods_error( sprintf( esc_html__( 'Unable to create the directory: %s', 'pods' ), $file_path ) ); + } + } elseif ( ! $wp_filesystem->is_writable( dirname( $file_path ) ) ) { + // translators: %s is the directory path. + pods_error( sprintf( esc_html__( 'Unable to write to the directory: %s', 'pods' ), $file_path ) ); + } + } + + private function migrate_template( $object_id, bool $cleanup ) { + /** + * @var $wp_filesystem WP_Filesystem_Base + */ + global $wp_filesystem; + + $api = pods_api(); + + /** @var Template $object */ + $object = $api->load_template( [ 'id' => $object_id ] ); + + if ( ! $object ) { + // translators: %s is the object ID. + pods_error( sprintf( esc_html__( 'Unable to find the Pod Template by ID: %s', 'pods' ), $object_id ) ); + } + + $files = Pods_Templates::get_templates_for_pod_template( $object ); + + if ( count( $files ) < 2 ) { + // translators: %s is the file paths found. + pods_error( sprintf( esc_html__( 'Unable to detect the file path: %s', 'pods' ), json_encode( $files, JSON_PRETTY_PRINT ) ) ); + } + + $file_path = trailingslashit( get_stylesheet_directory() ) . array_shift( $files ); + + $this->setup_file_path( $file_path ); + + $template_code = $object->get_description(); + + $extra_headers = ''; + + if ( false !== strpos( $template_code, '{@' ) ) { + $extra_headers = <<get_label()}{$extra_headers} + * + * @var Pods \$obj + */ +?> + +{$template_code} +PHPTEMPLATE; + + if ( ! $wp_filesystem->put_contents( $file_path, $contents, FS_CHMOD_FILE ) ) { + // translators: %s is the file path. + pods_error( sprintf( esc_html__( 'Unable to write to the file: %s', 'pods' ), $file_path ) ); + } + + if ( $cleanup ) { + $api->save_template( [ + 'id' => $object->get_id(), + 'name' => $object->get_label(), + 'code' => '', + ] ); + } + + return str_replace( ABSPATH, '', $file_path ); + } + + private function migrate_page( $object_id, bool $cleanup ) { + /** + * @var $wp_filesystem WP_Filesystem_Base + */ + global $wp_filesystem; + + $api = pods_api(); + + /** @var Page $object */ + $object = $api->load_page( [ 'id' => $object_id ] ); + + if ( ! $object ) { + // translators: %s is the object ID. + pods_error( sprintf( esc_html__( 'Unable to find the Pod Page by ID: %s', 'pods' ), $object_id ) ); + } + + $files = Pods_Pages::get_templates_for_pod_page( $object ); + $files_for_content = Pods_Pages::get_templates_for_pod_page_content( $object ); + + if ( count( $files ) < 2 ) { + // translators: %s is the file paths found. + pods_error( sprintf( esc_html__( 'Unable to detect the file path: %s', 'pods' ), json_encode( $files, JSON_PRETTY_PRINT ) ) ); + } + + $file_path = trailingslashit( get_stylesheet_directory() ) . array_shift( $files ); + $file_path_for_content = trailingslashit( get_stylesheet_directory() ) . array_shift( $files_for_content ); + + $this->setup_file_path( $file_path ); + + $precode = (string) $object->get_arg( 'precode' ); + $page_template = (string) $object->get_arg( 'page_template' ); + + if ( false !== strpos( $precode, '' ) ) { + $precode .= "\n?>"; + } + + $precode_template = ''; + + if ( ! empty( $precode ) ) { + $precode_template = "\n" . << +{$precode} +PHPTEMPLATE . "\n"; + } + + $template_code = trim( $object->get_description() ); + + $has_page_template = ! empty( $page_template ); + + $precode_has_end_tag = false !== strpos( $precode, '?>' ); + + if ( false === strpos( $template_code, '\n" . $template_code . ( ! $has_page_template ? '' : "\nsetup_file_path( $file_path_for_content ); + + if ( '_custom' !== $page_template && 'blank' !== $page_template ) { + $extra_notes .= "\n" . <<get_label()}{$extra_headers}{$extra_notes} + * + * @var Pods \$pods + */ + +{$precode_template} + +{$template_code} +PHPTEMPLATE; + + // Clean up the PHP tags that open and close too often. + $contents = preg_replace( '/\?>\s*<\?php(\s*)/Umi', '$1', $contents ); + $contents = preg_replace( '/\?>\s*<\?(\s*)/Umi', '$1', $contents ); + $contents = preg_replace( '/\n{3,}/', "\n\n", $contents ); + + if ( ! $wp_filesystem->put_contents( $file_path, $contents, FS_CHMOD_FILE ) ) { + // translators: %s is the file path. + pods_error( sprintf( esc_html__( 'Unable to write to the file: %s', 'pods' ), $file_path ) ); + } + + if ( $cleanup ) { + $api->save_page( [ + 'id' => $object->get_id(), + 'name' => $object->get_label(), + 'code' => '', + 'precode' => '', + ] ); + } + + return str_replace( ABSPATH, '', $file_path ); + } + +} diff --git a/components/Migrate-PHP/ui/wizard.php b/components/Migrate-PHP/ui/wizard.php new file mode 100644 index 0000000000..d063a482ec --- /dev/null +++ b/components/Migrate-PHP/ui/wizard.php @@ -0,0 +1,268 @@ +
        +

        + +
        +
        + + + + + array( 'id' => 'pods_cleanup' ) ) ); ?> + +

        + + + +
        +
        +
          +
        • + 1 + +
        • +
        • + 2 + +
        • +
        +
        +
        +
        +
        +

        + + +

        + +
        + + + + +
        +
        +
        +

        +

        + +

        + +

        +
        + + + +
        +

        + +

        + +
        +
        +
        +

        + +

        + +
          + +
        • + $item['name'] . ( ! empty( $item['label'] ) ? ' (' . $item['label'] . ')' : '' ), + 'disable_dfv' => true, + ] ); + ?> +
        • + +
        +
        +
        +
        +
        + + + + +
        +

        + +

        + +
        +
        +
        +

        + +

        + +
          + +
        • + $item['name'] . ( ! empty( $item['label'] ) ? ' (' . $item['label'] . ')' : '' ), + 'disable_dfv' => true, + ] ); + ?> +
        • + +
        +
        +
        +
        +
        + + + + + +
        + +
        +
        + + +
        +
        + +
        +
        +
        +
        +
        +
        +
        + diff --git a/components/Migrate-Packages/ui/wizard.php b/components/Migrate-Packages/ui/wizard.php index 87df959f6b..9f4da5333b 100644 --- a/components/Migrate-Packages/ui/wizard.php +++ b/components/Migrate-Packages/ui/wizard.php @@ -9,18 +9,18 @@ -

        +

        -
        +
        • - 1 + 1
        • - 2 + 2
        @@ -32,53 +32,57 @@ $pods = $api->load_pods( array( 'fields' => false ) ); $pod_templates = $api->load_templates(); $pod_pages = $api->load_pages(); - $pod_helpers = $api->load_helpers(); $export = true; - if ( empty( $pods ) && empty( $pod_templates ) && empty( $pod_pages ) && empty( $pod_helpers ) ) { + if ( empty( $pods ) && empty( $pod_templates ) && empty( $pod_pages ) ) { $export = false; } ?>
        -

        +

        +

        -
        - -

        - -

        -
        - -


        -
        - - +
        + + if ( $export ) { + ?> + + +
        -

        +

        @@ -114,16 +118,16 @@ class="button button-secondary button-small hidden"
        -

        +

        - +

        - +

        @@ -169,14 +173,14 @@ class="button button-secondary button-small hidden" ?>

        - +

        - +

          @@ -215,14 +219,14 @@ class="button button-secondary button-small hidden" ?>

          - +

          - +

            @@ -261,60 +265,14 @@ class="button button-secondary button-small hidden" ?>

            - -

            - -
            -
            -
            -

            - -

            - -
              - -
            • - $item['name'] . ( ! empty( $item['label'] ) ? ' (' . $item['label'] . ')' : '' ), - 'disable_dfv' => true, - ] ); - ?> -
            • - -
            -
            -
            -
            -
            - -
            -

            - +

            - +

              @@ -347,14 +305,14 @@ class="button button-secondary button-small hidden"