Plugin Directory

Changeset 3208758


Ignore:
Timestamp:
12/16/2024 06:59:07 PM (14 months ago)
Author:
nahuelmahe
Message:

Update to version 3.8.23 from GitHub

Location:
ninja-forms
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ninja-forms/tags/3.8.23/includes/Display/Preview.php

    r3110508 r3208758  
    44 * Class NF_Display_Preview
    55 */
    6 final class NF_Display_Preview
     6class NF_Display_Preview
    77{
    8     protected $form_id = '';
    98    protected $_form_id = '';
    109
    11     public function __construct()
    12     {
    13         if ( ! isset( $_GET['nf_preview_form'] ) ) return;
     10  public function __construct()
     11  {
     12    $this->_form_id = $this->constructFormId();
    1413
    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'));
    1619
    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'));
    1827
    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  }
    2930
    3031    public function pre_get_posts( $query )
     
    5051    function the_content()
    5152    {
    52         if ( ! is_user_logged_in() ) return esc_html__( 'You must be logged in to 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' );
    5354
    5455        // takes into account if we are trying to preview a non-published form
     
    6465                     || ! is_numeric( $tmp_id_test[ 1 ] ) ) ) ) {
    6566            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) . "']" );
    6967    }
    7068
    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
    75102     */
     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   */
    76185    function template_include()
    77186    {
  • ninja-forms/tags/3.8.23/ninja-forms.php

    r3205797 r3208758  
    44Plugin URI: http://ninjaforms.com/?utm_source=WordPress&utm_medium=readme
    55Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
    6 Version: 3.8.22
     6Version: 3.8.23
    77Author: Saturday Drive
    88Author URI: http://ninjaforms.com/?utm_source=Ninja+Forms+Plugin&utm_medium=Plugins+WP+Dashboard
     
    4444     */
    4545
    46     const VERSION = '3.8.22';
     46    const VERSION = '3.8.23';
    4747
    4848    /**
  • ninja-forms/tags/3.8.23/readme.txt

    r3205797 r3208758  
    66Requires at least: 6.5
    77Tested up to: 6.7
    8 Stable tag: 3.8.22
     8Stable tag: 3.8.23
    99
    1010Requires PHP: 7.4
     
    313313
    314314== Upgrade Notice ==
    315 = 3.8.22 (10 December 2024) =
    316 *Bug Fixes:*
    317 - Update timing for widget loading on page builders
     315= 3.8.23 (16 December 2024)
     316*Bug Fixes:*
     317- Ensure only permitted form previews are available to a given user
    318318
    319319== Changelog ==
     320= 3.8.23 (16 December 2024)
     321*Bug Fixes:*
     322- Ensure only permitted form previews are available to a given user
     323
    320324= 3.8.22 (10 December 2024) =
    321325*Bug Fixes:*
  • ninja-forms/tags/3.8.23/vendor/composer/installed.php

    r3205797 r3208758  
    22    'root' => array(
    33        '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',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
  • ninja-forms/trunk/includes/Display/Preview.php

    r3110508 r3208758  
    44 * Class NF_Display_Preview
    55 */
    6 final class NF_Display_Preview
     6class NF_Display_Preview
    77{
    8     protected $form_id = '';
    98    protected $_form_id = '';
    109
    11     public function __construct()
    12     {
    13         if ( ! isset( $_GET['nf_preview_form'] ) ) return;
     10  public function __construct()
     11  {
     12    $this->_form_id = $this->constructFormId();
    1413
    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'));
    1619
    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'));
    1827
    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  }
    2930
    3031    public function pre_get_posts( $query )
     
    5051    function the_content()
    5152    {
    52         if ( ! is_user_logged_in() ) return esc_html__( 'You must be logged in to 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' );
    5354
    5455        // takes into account if we are trying to preview a non-published form
     
    6465                     || ! is_numeric( $tmp_id_test[ 1 ] ) ) ) ) {
    6566            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) . "']" );
    6967    }
    7068
    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
    75102     */
     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   */
    76185    function template_include()
    77186    {
  • ninja-forms/trunk/ninja-forms.php

    r3205797 r3208758  
    44Plugin URI: http://ninjaforms.com/?utm_source=WordPress&utm_medium=readme
    55Description: Ninja Forms is a webform builder with unparalleled ease of use and features.
    6 Version: 3.8.22
     6Version: 3.8.23
    77Author: Saturday Drive
    88Author URI: http://ninjaforms.com/?utm_source=Ninja+Forms+Plugin&utm_medium=Plugins+WP+Dashboard
     
    4444     */
    4545
    46     const VERSION = '3.8.22';
     46    const VERSION = '3.8.23';
    4747
    4848    /**
  • ninja-forms/trunk/readme.txt

    r3205797 r3208758  
    66Requires at least: 6.5
    77Tested up to: 6.7
    8 Stable tag: 3.8.22
     8Stable tag: 3.8.23
    99
    1010Requires PHP: 7.4
     
    313313
    314314== Upgrade Notice ==
    315 = 3.8.22 (10 December 2024) =
    316 *Bug Fixes:*
    317 - Update timing for widget loading on page builders
     315= 3.8.23 (16 December 2024)
     316*Bug Fixes:*
     317- Ensure only permitted form previews are available to a given user
    318318
    319319== Changelog ==
     320= 3.8.23 (16 December 2024)
     321*Bug Fixes:*
     322- Ensure only permitted form previews are available to a given user
     323
    320324= 3.8.22 (10 December 2024) =
    321325*Bug Fixes:*
  • ninja-forms/trunk/vendor/composer/installed.php

    r3205797 r3208758  
    22    'root' => array(
    33        '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',
    77        'type' => 'library',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        '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',
    1717            'type' => 'library',
    1818            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.