Plugin Directory

Changeset 1734198


Ignore:
Timestamp:
09/22/2017 10:17:31 AM (9 years ago)
Author:
Zuige
Message:

Tagging v1.4.1

Location:
wp-libre-form
Files:
24 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wp-libre-form/tags/1.2.3/assets/scripts/wplf-form.js

    r1652323 r1734198  
    1616      var form = e.target;
    1717      var data = new FormData(form);
     18
     19      // Pass language if it exists.
     20      ajax_object.lang && data.append('lang', ajax_object.lang);
     21
    1822      // add class to enable css changes to indicate ajax loading
    1923      form.classList.add("sending");
  • wp-libre-form/tags/1.2.3/classes/class-cpt-wplf-form.php

    r1652323 r1734198  
    1919   * Hook our actions, filters and such
    2020   */
    21   private function __construct() {
     21  public function __construct() {
    2222    // init custom post type
    2323    add_action( 'init', array( $this, 'register_cpt' ) );
     
    386386?>
    387387<p><?php esc_html_e( 'Submissions from this form will use this formatting in their title.', 'wp-libre-form' ); ?></p>
    388 <p><?php esc_html_e( 'You may use any field values enclosed in "%" markers.', 'wp-libre-form' );?></p>
     388<p><?php esc_html_e( 'You may use any field values enclosed in "%" markers.', 'wp-libre-form' ); ?></p>
    389389<p>
    390390  <input
     
    424424    // save success message
    425425    if ( isset( $_POST['wplf_thank_you'] ) ) {
    426       update_post_meta( $post_id, '_wplf_thank_you', wp_kses_post( $_POST['wplf_thank_you'] ) );
     426      $success = wp_kses_post( $_POST['wplf_thank_you'] );
     427      $success = apply_filters( 'wplf_save_success_message', $success, $post_id );
     428      update_post_meta( $post_id, '_wplf_thank_you', $success );
    427429    }
    428430
     
    541543      <p style="background:#f5f5f5;border-left:4px solid #dc3232;padding:6px 12px;">
    542544        <strong style="color:#dc3232;">
    543           <?php esc_html_e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?>
     545          <?php esc_html_e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ); ?>
    544546        </strong>
    545547        <br />
    546         <?php esc_html_e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
     548        <?php esc_html_e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ); ?>
    547549      </p>
    548550    <?php endif; ?>
     
    555557  ?>
    556558  <input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
    557   <input type="hidden" name="_referrer_id" value="<?php echo esc_attr( get_the_id() ) ?>">
     559  <input type="hidden" name="_referrer_id" value="<?php echo esc_attr( get_the_id() ); ?>">
    558560  <input type="hidden" name="_form_id" value="<?php echo esc_attr( $id ); ?>">
    559561</form>
     
    588590
    589591    // add dynamic variables to the script's scope
    590     wp_localize_script( 'wplf-form-js', 'ajax_object', array(
     592    wp_localize_script( 'wplf-form-js', 'ajax_object', apply_filters( 'wplf_ajax_object', array(
    591593      'ajax_url' => admin_url( 'admin-ajax.php' ),
    592594      'ajax_credentials' => apply_filters( 'wplf_ajax_fetch_credentials_mode', 'same-origin' ),
    593     ) );
     595    ) ) );
    594596  }
    595597
  • wp-libre-form/tags/1.2.3/classes/class-cpt-wplf-submission.php

    r1648110 r1734198  
    1919   * Hook our actions, filters and such
    2020   */
    21   private function __construct() {
     21  public function __construct() {
    2222    // init custom post type
    2323    add_action( 'init', array( $this, 'register_cpt' ) );
     
    264264        // Show a link if the field corresponds to a URL
    265265        // assume values starting with '/' are root relative URLs and should be handled as links
    266         $value_is_url = $value[0] === '/' ? true : filter_var( $value, FILTER_VALIDATE_URL );
     266        $value_is_url = false;
     267        if ( strlen( $value ) > 0 ) {
     268          $value_is_url = $value[0] === '/' ? true : filter_var( $value, FILTER_VALIDATE_URL );
     269        }
    267270        if ( $value_is_url ) {
    268271          $link_text = __( 'Open Link', 'wp-libre-form' );
  • wp-libre-form/tags/1.2.3/classes/class-wplf-polylang.php

    r1648100 r1734198  
    22if ( ! class_exists( 'WPLF_Polylang' ) ) {
    33  class WPLF_Polylang {
    4     /**
    5      * CPT for the forms
    6      */
     4
    75    public static $instance;
    86    protected $regular_expression = "/{{[^{}\n]+}}/";
     
    1917     * Hook our actions, filters and such
    2018     */
    21     private function __construct() {
     19    public function __construct() {
    2220      add_filter( 'wplf_form', array( $this, 'render_form' ) );
    2321      add_filter( 'save_post_wplf-form', array( $this, 'save_form' ), 10, 3 );
    2422      add_action( 'after_setup_theme', array( $this, 'register_strings' ) );
     23
     24      // Earlier than default. User probably wants to filter the translated message.
     25      add_action( 'wplf_success_message', array( $this, 'render_success_message' ), 9 );
     26      add_action( 'wplf_save_success_message', array( $this, 'save_success_message' ) );
     27      add_action( 'wplf_ajax_object', array( $this, 'ajax_object' ) );
    2528
    2629      $this->strings = get_option( 'wplf-translation-strings', array() );
     
    5659    }
    5760
     61    public function render_success_message( $message ) {
     62      // Get all strings inside double curly braces.
     63      preg_match_all( $this->regular_expression, $message, $matches );
     64      foreach ( $matches[0] as $match ) {
     65        // match contains the braces, get rid of them.
     66        $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     67        $message = str_replace( $match, $this->translate_string( $string ), $message );
     68      }
     69
     70      return $message;
     71    }
     72
     73    public function save_success_message( $message ) {
     74      preg_match_all( $this->regular_expression, $message, $matches );
     75      if ( ! empty( $matches ) ) {
     76        foreach ( $matches[0] as $match ) {
     77          // match contains the braces, get rid of them.
     78          $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     79          $this->strings[ $string ] = null;
     80          // By storing the string as the array key, we don't need to use array_unique.
     81        }
     82      }
     83
     84      update_option( 'wplf-translation-strings', $this->strings ); // Let's be optimistic.
     85
     86      return $message;
     87    }
     88
     89    public function ajax_object( $array ) {
     90      $array['lang'] = pll_current_language();
     91      return $array;
     92    }
     93
    5894    public function register_strings() {
    5995      foreach ( $this->strings as $string => $value ) {
  • wp-libre-form/tags/1.2.3/inc/wplf-ajax.php

    r1652323 r1734198  
    6666        'test_form' => false,
    6767      ) );
    68       add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
    69       add_post_meta( $post_id, $key . '_attachment', $attach_id );
     68
     69      if ( ! is_wp_error( $attach_id ) ) {
     70        add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
     71        add_post_meta( $post_id, $key . '_attachment', $attach_id );
     72      }
    7073    }
    7174
     
    7982    $return->form_id = $form->ID;
    8083
     84    $success = get_post_meta( $form->ID, '_wplf_thank_you', true );
     85    $success = apply_filters( "wplf_{$form->post_name}_success_message", $success );
     86    $success = apply_filters( "wplf_{$form->ID}_success_message", $success );
     87    $success = apply_filters( 'wplf_success_message', $success );
     88
    8189    // return the success message for the form
    82     $return->success = apply_filters( 'the_content', get_post_meta( $form->ID, '_wplf_thank_you', true ) );
     90    $return->success = $success;
    8391
    8492    // allow user to attach custom actions after the submission has been received
  • wp-libre-form/tags/1.2.3/inc/wplf-form-actions.php

    r1652323 r1734198  
    7575    $content = apply_filters( "wplf_{$form->post_name}_email_copy_content", $content );
    7676    $headers = apply_filters( "wplf_{$form->post_name}_email_copy_headers", $headers );
    77     $attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachment );
     77    $attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachments );
    7878
    7979    // form ID specific filters
     
    8282    $content = apply_filters( "wplf_{$form->ID}_email_copy_content", $content );
    8383    $headers = apply_filters( "wplf_{$form->ID}_email_copy_headers", $headers );
    84     $attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachment );
     84    $attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachments );
    8585
    8686    wp_mail( $to, $subject, $content, $headers, $attachments );
  • wp-libre-form/tags/1.2.3/phpcs.xml

    r1648100 r1734198  
    101101    <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
    102102
     103    <!-- <?php doesn't have to be on its own line -->
     104    <exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" />
     105    <exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterOpen" />
     106
     107    <!-- Squiz.PHP.EmbeddedPhp.ContentBeforeEnd -->
     108    <exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
     109
    103110    <!-- These indentation rules are just wrong :) -->
    104111    <exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
     
    119126    <exclude name="WordPress.Files.FileName.InvalidClassFileName" />
    120127
     128    <!-- This one is just weird. -->
     129    <exclude name="WordPress.Arrays.ArrayIndentation" />
     130
    121131  </rule>
    122132</ruleset>
  • wp-libre-form/tags/1.2.3/readme.md

    r1652323 r1734198  
    138138add_action( 'wplf_post_validate_submission', 'my_email_thankyou' );
    139139function my_email_thankyou( $return ) {
     140  // recipient details from submission
    140141  $name = sanitize_text_field( $_POST['name'] );
    141142  $email = sanitize_email( $_POST['email'] );
    142   $to = "\"$name\" <$email>";
     143
     144  // email subject
    143145  $subject = __( 'Thank You For Submitting A Form' );
    144   $content = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
    145   wp_mail( $to, $subject, $content );
     146
     147  // text body of email
     148  $body = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
     149
     150  // send the email
     151  wp_mail( $email, $subject, $body );
    146152}
    147153```
     
    159165
    160166These callbacks are executed in the order they appear.
     167
     168To avoid running your JavaScript too early, add `wplf-form-js` to your enqueue dependencies:
     169```php
     170wp_enqueue_script( "themejs", "/path/to/theme.js", array( "wplf-form-js" ), ... );
     171```
     172Otherwise you might run into errors like "Cannot read property 'push' of undefined". 
    161173
    162174## Multilingual
  • wp-libre-form/tags/1.2.3/readme.txt

    r1652327 r1734198  
    55Requires at least: 4.2
    66Tested up to: 4.7.4
    7 Stable tag: 1.4
     7Stable tag: 1.4.1
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • wp-libre-form/tags/1.2.3/vendor/composer/ClassLoader.php

    r1538409 r1734198  
    5656    private $classMapAuthoritative = false;
    5757    private $missingClasses = array();
     58    private $apcuPrefix;
    5859
    5960    public function getPrefixes()
     
    273274
    274275    /**
     276     * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
     277     *
     278     * @param string|null $apcuPrefix
     279     */
     280    public function setApcuPrefix($apcuPrefix)
     281    {
     282        $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
     283    }
     284
     285    /**
     286     * The APCu prefix in use, or null if APCu caching is not enabled.
     287     *
     288     * @return string|null
     289     */
     290    public function getApcuPrefix()
     291    {
     292        return $this->apcuPrefix;
     293    }
     294
     295    /**
    275296     * Registers this instance as an autoloader.
    276297     *
     
    314335    public function findFile($class)
    315336    {
    316         // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
    317         if ('\\' == $class[0]) {
    318             $class = substr($class, 1);
    319         }
    320 
    321337        // class map lookup
    322338        if (isset($this->classMap[$class])) {
     
    326342            return false;
    327343        }
     344        if (null !== $this->apcuPrefix) {
     345            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
     346            if ($hit) {
     347                return $file;
     348            }
     349        }
    328350
    329351        $file = $this->findFileWithExtension($class, '.php');
     
    334356        }
    335357
     358        if (null !== $this->apcuPrefix) {
     359            apcu_add($this->apcuPrefix.$class, $file);
     360        }
     361
    336362        if (false === $file) {
    337363            // Remember that this class does not exist.
     
    349375        $first = $class[0];
    350376        if (isset($this->prefixLengthsPsr4[$first])) {
    351             foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
    352                 if (0 === strpos($class, $prefix)) {
    353                     foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
     377            $subPath = $class;
     378            while (false !== $lastPos = strrpos($subPath, '\\')) {
     379                $subPath = substr($subPath, 0, $lastPos);
     380                $search = $subPath.'\\';
     381                if (isset($this->prefixDirsPsr4[$search])) {
     382                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
     383                        $length = $this->prefixLengthsPsr4[$first][$search];
    354384                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
    355385                            return $file;
  • wp-libre-form/tags/1.2.3/vendor/composer/LICENSE

    r1450039 r1734198  
    11
    2 Copyright (c) 2016 Nils Adermann, Jordi Boggiano
     2Copyright (c) Nils Adermann, Jordi Boggiano
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
  • wp-libre-form/tags/1.2.3/wp-libre-form.php

    r1652323 r1734198  
    44 * Plugin URI: https://github.com/anttiviljami/wp-libre-form
    55 * Description: A minimal HTML form builder for WordPress; made for developers
    6  * Version: 1.4
     6 * Version: 1.4.1
    77 * Author: @anttiviljami
    88 * Author URI: https://github.com/anttiviljami/
     
    3232if ( ! class_exists( 'WP_Libre_Form' ) ) :
    3333
    34 define( 'WPLF_VERSION', '1.4' );
     34define( 'WPLF_VERSION', '1.4.1' );
    3535
    3636class WP_Libre_Form {
     
    8989   */
    9090  public function init_polylang_support() {
    91     if ( apply_filters( 'wplf_load_polylang', true ) ) {
     91    if ( apply_filters( 'wplf_load_polylang', true ) && class_exists( 'Polylang' ) ) {
    9292      require_once 'classes/class-wplf-polylang.php';
    9393      WPLF_Polylang::init();
  • wp-libre-form/trunk/assets/scripts/wplf-form.js

    r1652323 r1734198  
    1616      var form = e.target;
    1717      var data = new FormData(form);
     18
     19      // Pass language if it exists.
     20      ajax_object.lang && data.append('lang', ajax_object.lang);
     21
    1822      // add class to enable css changes to indicate ajax loading
    1923      form.classList.add("sending");
  • wp-libre-form/trunk/classes/class-cpt-wplf-form.php

    r1652323 r1734198  
    1919   * Hook our actions, filters and such
    2020   */
    21   private function __construct() {
     21  public function __construct() {
    2222    // init custom post type
    2323    add_action( 'init', array( $this, 'register_cpt' ) );
     
    386386?>
    387387<p><?php esc_html_e( 'Submissions from this form will use this formatting in their title.', 'wp-libre-form' ); ?></p>
    388 <p><?php esc_html_e( 'You may use any field values enclosed in "%" markers.', 'wp-libre-form' );?></p>
     388<p><?php esc_html_e( 'You may use any field values enclosed in "%" markers.', 'wp-libre-form' ); ?></p>
    389389<p>
    390390  <input
     
    424424    // save success message
    425425    if ( isset( $_POST['wplf_thank_you'] ) ) {
    426       update_post_meta( $post_id, '_wplf_thank_you', wp_kses_post( $_POST['wplf_thank_you'] ) );
     426      $success = wp_kses_post( $_POST['wplf_thank_you'] );
     427      $success = apply_filters( 'wplf_save_success_message', $success, $post_id );
     428      update_post_meta( $post_id, '_wplf_thank_you', $success );
    427429    }
    428430
     
    541543      <p style="background:#f5f5f5;border-left:4px solid #dc3232;padding:6px 12px;">
    542544        <strong style="color:#dc3232;">
    543           <?php esc_html_e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?>
     545          <?php esc_html_e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ); ?>
    544546        </strong>
    545547        <br />
    546         <?php esc_html_e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
     548        <?php esc_html_e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ); ?>
    547549      </p>
    548550    <?php endif; ?>
     
    555557  ?>
    556558  <input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
    557   <input type="hidden" name="_referrer_id" value="<?php echo esc_attr( get_the_id() ) ?>">
     559  <input type="hidden" name="_referrer_id" value="<?php echo esc_attr( get_the_id() ); ?>">
    558560  <input type="hidden" name="_form_id" value="<?php echo esc_attr( $id ); ?>">
    559561</form>
     
    588590
    589591    // add dynamic variables to the script's scope
    590     wp_localize_script( 'wplf-form-js', 'ajax_object', array(
     592    wp_localize_script( 'wplf-form-js', 'ajax_object', apply_filters( 'wplf_ajax_object', array(
    591593      'ajax_url' => admin_url( 'admin-ajax.php' ),
    592594      'ajax_credentials' => apply_filters( 'wplf_ajax_fetch_credentials_mode', 'same-origin' ),
    593     ) );
     595    ) ) );
    594596  }
    595597
  • wp-libre-form/trunk/classes/class-cpt-wplf-submission.php

    r1648110 r1734198  
    1919   * Hook our actions, filters and such
    2020   */
    21   private function __construct() {
     21  public function __construct() {
    2222    // init custom post type
    2323    add_action( 'init', array( $this, 'register_cpt' ) );
     
    264264        // Show a link if the field corresponds to a URL
    265265        // assume values starting with '/' are root relative URLs and should be handled as links
    266         $value_is_url = $value[0] === '/' ? true : filter_var( $value, FILTER_VALIDATE_URL );
     266        $value_is_url = false;
     267        if ( strlen( $value ) > 0 ) {
     268          $value_is_url = $value[0] === '/' ? true : filter_var( $value, FILTER_VALIDATE_URL );
     269        }
    267270        if ( $value_is_url ) {
    268271          $link_text = __( 'Open Link', 'wp-libre-form' );
  • wp-libre-form/trunk/classes/class-wplf-polylang.php

    r1648100 r1734198  
    22if ( ! class_exists( 'WPLF_Polylang' ) ) {
    33  class WPLF_Polylang {
    4     /**
    5      * CPT for the forms
    6      */
     4
    75    public static $instance;
    86    protected $regular_expression = "/{{[^{}\n]+}}/";
     
    1917     * Hook our actions, filters and such
    2018     */
    21     private function __construct() {
     19    public function __construct() {
    2220      add_filter( 'wplf_form', array( $this, 'render_form' ) );
    2321      add_filter( 'save_post_wplf-form', array( $this, 'save_form' ), 10, 3 );
    2422      add_action( 'after_setup_theme', array( $this, 'register_strings' ) );
     23
     24      // Earlier than default. User probably wants to filter the translated message.
     25      add_action( 'wplf_success_message', array( $this, 'render_success_message' ), 9 );
     26      add_action( 'wplf_save_success_message', array( $this, 'save_success_message' ) );
     27      add_action( 'wplf_ajax_object', array( $this, 'ajax_object' ) );
    2528
    2629      $this->strings = get_option( 'wplf-translation-strings', array() );
     
    5659    }
    5760
     61    public function render_success_message( $message ) {
     62      // Get all strings inside double curly braces.
     63      preg_match_all( $this->regular_expression, $message, $matches );
     64      foreach ( $matches[0] as $match ) {
     65        // match contains the braces, get rid of them.
     66        $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     67        $message = str_replace( $match, $this->translate_string( $string ), $message );
     68      }
     69
     70      return $message;
     71    }
     72
     73    public function save_success_message( $message ) {
     74      preg_match_all( $this->regular_expression, $message, $matches );
     75      if ( ! empty( $matches ) ) {
     76        foreach ( $matches[0] as $match ) {
     77          // match contains the braces, get rid of them.
     78          $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     79          $this->strings[ $string ] = null;
     80          // By storing the string as the array key, we don't need to use array_unique.
     81        }
     82      }
     83
     84      update_option( 'wplf-translation-strings', $this->strings ); // Let's be optimistic.
     85
     86      return $message;
     87    }
     88
     89    public function ajax_object( $array ) {
     90      $array['lang'] = pll_current_language();
     91      return $array;
     92    }
     93
    5894    public function register_strings() {
    5995      foreach ( $this->strings as $string => $value ) {
  • wp-libre-form/trunk/inc/wplf-ajax.php

    r1652323 r1734198  
    6666        'test_form' => false,
    6767      ) );
    68       add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
    69       add_post_meta( $post_id, $key . '_attachment', $attach_id );
     68
     69      if ( ! is_wp_error( $attach_id ) ) {
     70        add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
     71        add_post_meta( $post_id, $key . '_attachment', $attach_id );
     72      }
    7073    }
    7174
     
    7982    $return->form_id = $form->ID;
    8083
     84    $success = get_post_meta( $form->ID, '_wplf_thank_you', true );
     85    $success = apply_filters( "wplf_{$form->post_name}_success_message", $success );
     86    $success = apply_filters( "wplf_{$form->ID}_success_message", $success );
     87    $success = apply_filters( 'wplf_success_message', $success );
     88
    8189    // return the success message for the form
    82     $return->success = apply_filters( 'the_content', get_post_meta( $form->ID, '_wplf_thank_you', true ) );
     90    $return->success = $success;
    8391
    8492    // allow user to attach custom actions after the submission has been received
  • wp-libre-form/trunk/inc/wplf-form-actions.php

    r1652323 r1734198  
    7575    $content = apply_filters( "wplf_{$form->post_name}_email_copy_content", $content );
    7676    $headers = apply_filters( "wplf_{$form->post_name}_email_copy_headers", $headers );
    77     $attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachment );
     77    $attachments = apply_filters( "wplf_{$form->post_name}_email_copy_attachments", $attachments );
    7878
    7979    // form ID specific filters
     
    8282    $content = apply_filters( "wplf_{$form->ID}_email_copy_content", $content );
    8383    $headers = apply_filters( "wplf_{$form->ID}_email_copy_headers", $headers );
    84     $attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachment );
     84    $attachments = apply_filters( "wplf_{$form->ID}_email_copy_attachments", $attachments );
    8585
    8686    wp_mail( $to, $subject, $content, $headers, $attachments );
  • wp-libre-form/trunk/phpcs.xml

    r1648100 r1734198  
    101101    <exclude name="Squiz.Commenting.InlineComment.InvalidEndChar" />
    102102
     103    <!-- <?php doesn't have to be on its own line -->
     104    <exclude name="Squiz.PHP.EmbeddedPhp.ContentBeforeEnd" />
     105    <exclude name="Squiz.PHP.EmbeddedPhp.ContentAfterOpen" />
     106
     107    <!-- Squiz.PHP.EmbeddedPhp.ContentBeforeEnd -->
     108    <exclude name="Generic.ControlStructures.InlineControlStructure.NotAllowed" />
     109
    103110    <!-- These indentation rules are just wrong :) -->
    104111    <exclude name="PEAR.Functions.FunctionCallSignature.Indent" />
     
    119126    <exclude name="WordPress.Files.FileName.InvalidClassFileName" />
    120127
     128    <!-- This one is just weird. -->
     129    <exclude name="WordPress.Arrays.ArrayIndentation" />
     130
    121131  </rule>
    122132</ruleset>
  • wp-libre-form/trunk/readme.md

    r1652323 r1734198  
    138138add_action( 'wplf_post_validate_submission', 'my_email_thankyou' );
    139139function my_email_thankyou( $return ) {
     140  // recipient details from submission
    140141  $name = sanitize_text_field( $_POST['name'] );
    141142  $email = sanitize_email( $_POST['email'] );
    142   $to = "\"$name\" <$email>";
     143
     144  // email subject
    143145  $subject = __( 'Thank You For Submitting A Form' );
    144   $content = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
    145   wp_mail( $to, $subject, $content );
     146
     147  // text body of email
     148  $body = wp_sprintf( __('Thanks, %s for clicking Submit on this glorious HTML5 Form!'), $name );
     149
     150  // send the email
     151  wp_mail( $email, $subject, $body );
    146152}
    147153```
     
    159165
    160166These callbacks are executed in the order they appear.
     167
     168To avoid running your JavaScript too early, add `wplf-form-js` to your enqueue dependencies:
     169```php
     170wp_enqueue_script( "themejs", "/path/to/theme.js", array( "wplf-form-js" ), ... );
     171```
     172Otherwise you might run into errors like "Cannot read property 'push' of undefined". 
    161173
    162174## Multilingual
  • wp-libre-form/trunk/readme.txt

    r1652327 r1734198  
    55Requires at least: 4.2
    66Tested up to: 4.7.4
    7 Stable tag: 1.4
     7Stable tag: 1.4.1
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • wp-libre-form/trunk/vendor/composer/ClassLoader.php

    r1538409 r1734198  
    5656    private $classMapAuthoritative = false;
    5757    private $missingClasses = array();
     58    private $apcuPrefix;
    5859
    5960    public function getPrefixes()
     
    273274
    274275    /**
     276     * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
     277     *
     278     * @param string|null $apcuPrefix
     279     */
     280    public function setApcuPrefix($apcuPrefix)
     281    {
     282        $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
     283    }
     284
     285    /**
     286     * The APCu prefix in use, or null if APCu caching is not enabled.
     287     *
     288     * @return string|null
     289     */
     290    public function getApcuPrefix()
     291    {
     292        return $this->apcuPrefix;
     293    }
     294
     295    /**
    275296     * Registers this instance as an autoloader.
    276297     *
     
    314335    public function findFile($class)
    315336    {
    316         // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
    317         if ('\\' == $class[0]) {
    318             $class = substr($class, 1);
    319         }
    320 
    321337        // class map lookup
    322338        if (isset($this->classMap[$class])) {
     
    326342            return false;
    327343        }
     344        if (null !== $this->apcuPrefix) {
     345            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
     346            if ($hit) {
     347                return $file;
     348            }
     349        }
    328350
    329351        $file = $this->findFileWithExtension($class, '.php');
     
    334356        }
    335357
     358        if (null !== $this->apcuPrefix) {
     359            apcu_add($this->apcuPrefix.$class, $file);
     360        }
     361
    336362        if (false === $file) {
    337363            // Remember that this class does not exist.
     
    349375        $first = $class[0];
    350376        if (isset($this->prefixLengthsPsr4[$first])) {
    351             foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
    352                 if (0 === strpos($class, $prefix)) {
    353                     foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
     377            $subPath = $class;
     378            while (false !== $lastPos = strrpos($subPath, '\\')) {
     379                $subPath = substr($subPath, 0, $lastPos);
     380                $search = $subPath.'\\';
     381                if (isset($this->prefixDirsPsr4[$search])) {
     382                    foreach ($this->prefixDirsPsr4[$search] as $dir) {
     383                        $length = $this->prefixLengthsPsr4[$first][$search];
    354384                        if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
    355385                            return $file;
  • wp-libre-form/trunk/vendor/composer/LICENSE

    r1450039 r1734198  
    11
    2 Copyright (c) 2016 Nils Adermann, Jordi Boggiano
     2Copyright (c) Nils Adermann, Jordi Boggiano
    33
    44Permission is hereby granted, free of charge, to any person obtaining a copy
  • wp-libre-form/trunk/wp-libre-form.php

    r1652323 r1734198  
    44 * Plugin URI: https://github.com/anttiviljami/wp-libre-form
    55 * Description: A minimal HTML form builder for WordPress; made for developers
    6  * Version: 1.4
     6 * Version: 1.4.1
    77 * Author: @anttiviljami
    88 * Author URI: https://github.com/anttiviljami/
     
    3232if ( ! class_exists( 'WP_Libre_Form' ) ) :
    3333
    34 define( 'WPLF_VERSION', '1.4' );
     34define( 'WPLF_VERSION', '1.4.1' );
    3535
    3636class WP_Libre_Form {
     
    8989   */
    9090  public function init_polylang_support() {
    91     if ( apply_filters( 'wplf_load_polylang', true ) ) {
     91    if ( apply_filters( 'wplf_load_polylang', true ) && class_exists( 'Polylang' ) ) {
    9292      require_once 'classes/class-wplf-polylang.php';
    9393      WPLF_Polylang::init();
Note: See TracChangeset for help on using the changeset viewer.