From 86ef9537a035f417e9dd73929dd476868c7e318e Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Sat, 28 Sep 2024 15:45:18 -0500 Subject: [PATCH] Add more notices when using precode or page code --- components/Pages.php | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/components/Pages.php b/components/Pages.php index 54cc0c8f9c..42c57fa668 100644 --- a/components/Pages.php +++ b/components/Pages.php @@ -200,6 +200,22 @@ public function register_config() { 'label' => __( 'Page Title', 'pods' ), 'type' => 'text', ], + [ + 'name' => 'code_php_notice', + 'type' => 'html', + 'html_content' => sprintf( + '

⚠️  %1s - %3$s

', + __( 'PHP detected, this feature is deprecated', 'pods' ), + 'https://docs.pods.io/displaying-pods/pod-page-template-hierarchy-for-themes/', + __( 'Switch to file-based Pod Pages', 'pods' ) + ), + 'wildcard-on' => [ + 'code' => [ + '\?>', + '<\?', + ], + ], + ], [ 'name' => 'code', 'label' => __( 'Page Code', 'pods' ), @@ -213,6 +229,19 @@ public function register_config() { ], ], ], + [ + 'name' => 'precode_notice', + 'type' => 'html', + 'html_content' => sprintf( + '

⚠️  %1s - %3$s

', + __( 'Precode detected, this feature is deprecated', 'pods' ), + 'https://docs.pods.io/displaying-pods/pod-page-template-hierarchy-for-themes/', + __( 'Switch to file-based Pod Pages', 'pods' ) + ), + 'excludes-on' => [ + 'precode' => '', + ], + ], [ 'name' => 'precode', 'label' => __( 'Page Precode', 'pods' ), @@ -226,7 +255,7 @@ public function register_config() { 'type' => 'pick', 'pick_object' => 'custom-simple', 'pick_format_type' => 'single', - 'pick_format_single' => 'dropdown', + 'pick_format_single' => 'dropdown', 'data' => $page_templates, 'override_object_field' => true, ], @@ -691,14 +720,14 @@ public function edit_page_form() { } if ( $has_precode ) { - pods_deprecated( 'Pod Page PHP precode has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1' ); + pods_deprecated( 'Pod Page precode has been deprecated, please use WP Page Templates or hook into the pods_content filter instead of embedding PHP.', '2.1' ); if ( PODS_DISABLE_EVAL ) { pods_message( sprintf( '

%1$s: %2$s

%4$s

', __( 'Pod Page Error', 'pods' ), - __( 'This Pod Page contains PHP precode that will not run due to security restrictions in Pods. To enable PHP code, you must configure your website to allow PHP by setting the constant PODS_DISABLE_EVAL to false.', 'pods' ), + __( 'This Pod Page contains precode (deprecated) that will not run due to security restrictions in Pods. To enable PHP code, you must configure your website to allow PHP by setting the constant PODS_DISABLE_EVAL to false.', 'pods' ), 'https://docs.pods.io/displaying-pods/pod-page-template-hierarchy-for-themes/', __( 'Switch to file-based Pod Pages', 'pods' ) ), @@ -711,7 +740,7 @@ public function edit_page_form() { sprintf( '

%1$s: %2$s

%4$s

', __( 'Pod Page Warning', 'pods' ), - __( 'This Pod Page contains PHP precode that will no longer run in Pods 3.3+.', 'pods' ), + __( 'This Pod Page contains precode which is deprecated -- it will no longer run in Pods 3.3+.', 'pods' ), 'https://docs.pods.io/displaying-pods/pod-page-template-hierarchy-for-themes/', __( 'Switch to file-based Pod Pages', 'pods' ) ),