Changeset 3208758
- Timestamp:
- 12/16/2024 06:59:07 PM (14 months ago)
- Location:
- ninja-forms
- Files:
-
- 8 edited
- 1 copied
-
tags/3.8.23 (copied) (copied from ninja-forms/trunk)
-
tags/3.8.23/includes/Display/Preview.php (modified) (3 diffs)
-
tags/3.8.23/ninja-forms.php (modified) (2 diffs)
-
tags/3.8.23/readme.txt (modified) (2 diffs)
-
tags/3.8.23/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/includes/Display/Preview.php (modified) (3 diffs)
-
trunk/ninja-forms.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ninja-forms/tags/3.8.23/includes/Display/Preview.php
r3110508 r3208758 4 4 * Class NF_Display_Preview 5 5 */ 6 finalclass NF_Display_Preview6 class NF_Display_Preview 7 7 { 8 protected $form_id = '';9 8 protected $_form_id = ''; 10 9 11 public function __construct()12 {13 if ( ! isset( $_GET['nf_preview_form'] ) ) return;10 public function __construct() 11 { 12 $this->_form_id = $this->constructFormId(); 14 13 15 $this->_form_id = WPN_Helper::sanitize_text_field($_GET['nf_preview_form']); 14 if(is_null($this->_form_id)){ 15 return; 16 } 17 18 add_action('pre_get_posts', array($this, 'pre_get_posts')); 16 19 17 add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 20 add_filter('the_title', array($this, 'the_title')); 21 remove_filter('the_content', 'wpautop'); 22 remove_filter('the_excerpt', 'wpautop'); 23 add_filter('the_content', array($this, 'the_content'), 9001); 24 add_filter('get_the_excerpt', array($this, 'the_content')); 25 //switched from template_include to template redirect filter hook to work with block-based (FSE) themes 26 add_filter('template_redirect', array($this, 'template_include')); 18 27 19 add_filter('the_title', array( $this, 'the_title' ) ); 20 remove_filter( 'the_content', 'wpautop' ); 21 remove_filter( 'the_excerpt', 'wpautop' ); 22 add_filter('the_content', array( $this, 'the_content' ), 9001 ); 23 add_filter('get_the_excerpt', array( $this, 'the_content' ) ); 24 //switched from template_include to template redirect filter hook to work with block-based (FSE) themes 25 add_filter('template_redirect', array( $this, 'template_include' ) ); 26 27 add_filter('post_thumbnail_html', array( $this, 'post_thumbnail_html' ) ); 28 } 28 add_filter('post_thumbnail_html', array($this, 'post_thumbnail_html')); 29 } 29 30 30 31 public function pre_get_posts( $query ) … … 50 51 function the_content() 51 52 { 52 if ( ! is_user_logged_in() ) return esc_html__( 'You must be logged into preview a form.', 'ninja-forms' );53 if ( !$this->userCanViewPreview() ) return esc_html__( 'You must be logged in and have form privileges to preview a form.', 'ninja-forms' ); 53 54 54 55 // takes into account if we are trying to preview a non-published form … … 64 65 || ! is_numeric( $tmp_id_test[ 1 ] ) ) ) ) { 65 66 return esc_html__( 'You must provide a valid form ID.', 'ninja-forms' ); 66 }67 68 return do_shortcode( "[nf_preview id='". esc_attr($this->_form_id) . "']" );69 67 } 70 68 71 /** 72 * Locate_template will be loaded using second argument of the get_query_templates() function 73 * First argument will be prefixed with _template to create a hook 74 * @return void 69 return do_shortcode("[nf_preview id='" . esc_attr($this->_form_id) . "']"); 70 } 71 72 /** 73 * Construct the form id 74 * 75 * Check for GET parameter, then sanitize. Failures return null 76 * 77 * @return string|null 78 */ 79 protected function constructFormId() 80 { 81 $return = null; 82 83 $previewParameter = $this->extractPreviewGetParameter(); 84 85 if (is_null($previewParameter)) { 86 return $return; 87 } 88 89 $sanitizedFormId = $this->sanitizeFormId($previewParameter); 90 91 if (is_null($sanitizedFormId)) { 92 return $return; 93 } 94 95 return $sanitizedFormId; 96 } 97 98 /** 99 * Return the GET parameter for form preview id 100 * 101 * @return string|null 75 102 */ 103 protected function extractPreviewGetParameter() 104 { 105 $return = null; 106 107 if ( isset( $_GET['nf_preview_form'] ) ){ 108 $return = $_GET['nf_preview_form']; 109 } 110 111 return $return; 112 } 113 114 /** 115 * Ensure form Id is only integer or tmp-* 116 * 117 * If disallowed structure is found, return null 118 * 119 * @param int|string $unsanitizedFormId 120 * @return int|string|null 121 */ 122 protected function sanitizeFormId($unsanitizedFormId) 123 { 124 $return = null; 125 126 $wpSanitized = WPN_Helper::sanitize_text_field($unsanitizedFormId); 127 128 if(is_int($wpSanitized) || 129 is_string($wpSanitized) && ctype_digit($wpSanitized) ){ 130 131 $return = $wpSanitized; 132 return $return; 133 } 134 135 if(!is_string($wpSanitized)){ 136 return $return; 137 } 138 139 $return = $this->sanitizeForUnpublishedFormId($wpSanitized); 140 141 return $return; 142 } 143 144 /** 145 * Allow non-integer-like values form unpublished form 146 * 147 * Uses format tmp-*** 148 * 149 * @param string $incoming 150 * @return void 151 */ 152 protected function sanitizeForUnpublishedFormId(string $incoming) 153 { 154 $return = null; 155 156 if (strpos($incoming, 'tmp-') === 0) { 157 $prefixRemoved = str_replace('tmp-', '', $incoming); 158 if (ctype_digit($prefixRemoved)) { 159 $return = $incoming; 160 } 161 } 162 163 return $return; 164 } 165 166 /** 167 * Does user have permission to preview forms? 168 * 169 * @return boolean 170 */ 171 protected function userCanViewPreview(): bool 172 { 173 $return = true; 174 if (! is_user_logged_in() || !current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) { 175 $return = false; 176 } 177 return $return; 178 } 179 180 /** 181 * Locate_template will be loaded using second argument of the get_query_templates() function 182 * First argument will be prefixed with _template to create a hook 183 * @return void 184 */ 76 185 function template_include() 77 186 { -
ninja-forms/tags/3.8.23/ninja-forms.php
r3205797 r3208758 4 4 Plugin URI: http://ninjaforms.com/?utm_source=WordPress&utm_medium=readme 5 5 Description: Ninja Forms is a webform builder with unparalleled ease of use and features. 6 Version: 3.8.2 26 Version: 3.8.23 7 7 Author: Saturday Drive 8 8 Author URI: http://ninjaforms.com/?utm_source=Ninja+Forms+Plugin&utm_medium=Plugins+WP+Dashboard … … 44 44 */ 45 45 46 const VERSION = '3.8.2 2';46 const VERSION = '3.8.23'; 47 47 48 48 /** -
ninja-forms/tags/3.8.23/readme.txt
r3205797 r3208758 6 6 Requires at least: 6.5 7 7 Tested up to: 6.7 8 Stable tag: 3.8.2 28 Stable tag: 3.8.23 9 9 10 10 Requires PHP: 7.4 … … 313 313 314 314 == Upgrade Notice == 315 = 3.8.2 2 (10 December 2024) =316 *Bug Fixes:* 317 - Update timing for widget loading on page builders315 = 3.8.23 (16 December 2024) 316 *Bug Fixes:* 317 - Ensure only permitted form previews are available to a given user 318 318 319 319 == Changelog == 320 = 3.8.23 (16 December 2024) 321 *Bug Fixes:* 322 - Ensure only permitted form previews are available to a given user 323 320 324 = 3.8.22 (10 December 2024) = 321 325 *Bug Fixes:* -
ninja-forms/tags/3.8.23/vendor/composer/installed.php
r3205797 r3208758 2 2 'root' => array( 3 3 'name' => 'saturday-drive/ninja-forms', 4 'pretty_version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',5 'version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',6 'reference' => ' ccccaaafe850b16a48ac6ec4509164d26eb28fcb',4 'pretty_version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 5 'version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 6 'reference' => '46478907677c6e1b880f7058e592dd6f766a86ef', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'saturday-drive/ninja-forms' => array( 14 'pretty_version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',15 'version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',16 'reference' => ' ccccaaafe850b16a48ac6ec4509164d26eb28fcb',14 'pretty_version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 15 'version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 16 'reference' => '46478907677c6e1b880f7058e592dd6f766a86ef', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../', -
ninja-forms/trunk/includes/Display/Preview.php
r3110508 r3208758 4 4 * Class NF_Display_Preview 5 5 */ 6 finalclass NF_Display_Preview6 class NF_Display_Preview 7 7 { 8 protected $form_id = '';9 8 protected $_form_id = ''; 10 9 11 public function __construct()12 {13 if ( ! isset( $_GET['nf_preview_form'] ) ) return;10 public function __construct() 11 { 12 $this->_form_id = $this->constructFormId(); 14 13 15 $this->_form_id = WPN_Helper::sanitize_text_field($_GET['nf_preview_form']); 14 if(is_null($this->_form_id)){ 15 return; 16 } 17 18 add_action('pre_get_posts', array($this, 'pre_get_posts')); 16 19 17 add_action( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 20 add_filter('the_title', array($this, 'the_title')); 21 remove_filter('the_content', 'wpautop'); 22 remove_filter('the_excerpt', 'wpautop'); 23 add_filter('the_content', array($this, 'the_content'), 9001); 24 add_filter('get_the_excerpt', array($this, 'the_content')); 25 //switched from template_include to template redirect filter hook to work with block-based (FSE) themes 26 add_filter('template_redirect', array($this, 'template_include')); 18 27 19 add_filter('the_title', array( $this, 'the_title' ) ); 20 remove_filter( 'the_content', 'wpautop' ); 21 remove_filter( 'the_excerpt', 'wpautop' ); 22 add_filter('the_content', array( $this, 'the_content' ), 9001 ); 23 add_filter('get_the_excerpt', array( $this, 'the_content' ) ); 24 //switched from template_include to template redirect filter hook to work with block-based (FSE) themes 25 add_filter('template_redirect', array( $this, 'template_include' ) ); 26 27 add_filter('post_thumbnail_html', array( $this, 'post_thumbnail_html' ) ); 28 } 28 add_filter('post_thumbnail_html', array($this, 'post_thumbnail_html')); 29 } 29 30 30 31 public function pre_get_posts( $query ) … … 50 51 function the_content() 51 52 { 52 if ( ! is_user_logged_in() ) return esc_html__( 'You must be logged into preview a form.', 'ninja-forms' );53 if ( !$this->userCanViewPreview() ) return esc_html__( 'You must be logged in and have form privileges to preview a form.', 'ninja-forms' ); 53 54 54 55 // takes into account if we are trying to preview a non-published form … … 64 65 || ! is_numeric( $tmp_id_test[ 1 ] ) ) ) ) { 65 66 return esc_html__( 'You must provide a valid form ID.', 'ninja-forms' ); 66 }67 68 return do_shortcode( "[nf_preview id='". esc_attr($this->_form_id) . "']" );69 67 } 70 68 71 /** 72 * Locate_template will be loaded using second argument of the get_query_templates() function 73 * First argument will be prefixed with _template to create a hook 74 * @return void 69 return do_shortcode("[nf_preview id='" . esc_attr($this->_form_id) . "']"); 70 } 71 72 /** 73 * Construct the form id 74 * 75 * Check for GET parameter, then sanitize. Failures return null 76 * 77 * @return string|null 78 */ 79 protected function constructFormId() 80 { 81 $return = null; 82 83 $previewParameter = $this->extractPreviewGetParameter(); 84 85 if (is_null($previewParameter)) { 86 return $return; 87 } 88 89 $sanitizedFormId = $this->sanitizeFormId($previewParameter); 90 91 if (is_null($sanitizedFormId)) { 92 return $return; 93 } 94 95 return $sanitizedFormId; 96 } 97 98 /** 99 * Return the GET parameter for form preview id 100 * 101 * @return string|null 75 102 */ 103 protected function extractPreviewGetParameter() 104 { 105 $return = null; 106 107 if ( isset( $_GET['nf_preview_form'] ) ){ 108 $return = $_GET['nf_preview_form']; 109 } 110 111 return $return; 112 } 113 114 /** 115 * Ensure form Id is only integer or tmp-* 116 * 117 * If disallowed structure is found, return null 118 * 119 * @param int|string $unsanitizedFormId 120 * @return int|string|null 121 */ 122 protected function sanitizeFormId($unsanitizedFormId) 123 { 124 $return = null; 125 126 $wpSanitized = WPN_Helper::sanitize_text_field($unsanitizedFormId); 127 128 if(is_int($wpSanitized) || 129 is_string($wpSanitized) && ctype_digit($wpSanitized) ){ 130 131 $return = $wpSanitized; 132 return $return; 133 } 134 135 if(!is_string($wpSanitized)){ 136 return $return; 137 } 138 139 $return = $this->sanitizeForUnpublishedFormId($wpSanitized); 140 141 return $return; 142 } 143 144 /** 145 * Allow non-integer-like values form unpublished form 146 * 147 * Uses format tmp-*** 148 * 149 * @param string $incoming 150 * @return void 151 */ 152 protected function sanitizeForUnpublishedFormId(string $incoming) 153 { 154 $return = null; 155 156 if (strpos($incoming, 'tmp-') === 0) { 157 $prefixRemoved = str_replace('tmp-', '', $incoming); 158 if (ctype_digit($prefixRemoved)) { 159 $return = $incoming; 160 } 161 } 162 163 return $return; 164 } 165 166 /** 167 * Does user have permission to preview forms? 168 * 169 * @return boolean 170 */ 171 protected function userCanViewPreview(): bool 172 { 173 $return = true; 174 if (! is_user_logged_in() || !current_user_can(apply_filters('ninja_forms_admin_all_forms_capabilities', 'manage_options'))) { 175 $return = false; 176 } 177 return $return; 178 } 179 180 /** 181 * Locate_template will be loaded using second argument of the get_query_templates() function 182 * First argument will be prefixed with _template to create a hook 183 * @return void 184 */ 76 185 function template_include() 77 186 { -
ninja-forms/trunk/ninja-forms.php
r3205797 r3208758 4 4 Plugin URI: http://ninjaforms.com/?utm_source=WordPress&utm_medium=readme 5 5 Description: Ninja Forms is a webform builder with unparalleled ease of use and features. 6 Version: 3.8.2 26 Version: 3.8.23 7 7 Author: Saturday Drive 8 8 Author URI: http://ninjaforms.com/?utm_source=Ninja+Forms+Plugin&utm_medium=Plugins+WP+Dashboard … … 44 44 */ 45 45 46 const VERSION = '3.8.2 2';46 const VERSION = '3.8.23'; 47 47 48 48 /** -
ninja-forms/trunk/readme.txt
r3205797 r3208758 6 6 Requires at least: 6.5 7 7 Tested up to: 6.7 8 Stable tag: 3.8.2 28 Stable tag: 3.8.23 9 9 10 10 Requires PHP: 7.4 … … 313 313 314 314 == Upgrade Notice == 315 = 3.8.2 2 (10 December 2024) =316 *Bug Fixes:* 317 - Update timing for widget loading on page builders315 = 3.8.23 (16 December 2024) 316 *Bug Fixes:* 317 - Ensure only permitted form previews are available to a given user 318 318 319 319 == Changelog == 320 = 3.8.23 (16 December 2024) 321 *Bug Fixes:* 322 - Ensure only permitted form previews are available to a given user 323 320 324 = 3.8.22 (10 December 2024) = 321 325 *Bug Fixes:* -
ninja-forms/trunk/vendor/composer/installed.php
r3205797 r3208758 2 2 'root' => array( 3 3 'name' => 'saturday-drive/ninja-forms', 4 'pretty_version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',5 'version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',6 'reference' => ' ccccaaafe850b16a48ac6ec4509164d26eb28fcb',4 'pretty_version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 5 'version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 6 'reference' => '46478907677c6e1b880f7058e592dd6f766a86ef', 7 7 'type' => 'library', 8 8 'install_path' => __DIR__ . '/../../', … … 12 12 'versions' => array( 13 13 'saturday-drive/ninja-forms' => array( 14 'pretty_version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',15 'version' => 'dev- ccccaaafe850b16a48ac6ec4509164d26eb28fcb',16 'reference' => ' ccccaaafe850b16a48ac6ec4509164d26eb28fcb',14 'pretty_version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 15 'version' => 'dev-46478907677c6e1b880f7058e592dd6f766a86ef', 16 'reference' => '46478907677c6e1b880f7058e592dd6f766a86ef', 17 17 'type' => 'library', 18 18 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.