Plugin Directory

Changeset 1648101


Ignore:
Timestamp:
04/29/2017 04:35:31 PM (9 years ago)
Author:
Zuige
Message:

Tagging version 1.3

Location:
wp-libre-form/tags
Files:
1 added
9 edited
2 copied

Legend:

Unmodified
Added
Removed
  • wp-libre-form/tags/1.2.2/classes/class-cpt-wplf-form.php

    r1640733 r1648101  
    11<?php
    22
    3 if ( !class_exists('CPT_WPLF_Form') ) :
     3if ( ! class_exists( 'CPT_WPLF_Form' ) ) :
    44
    55class CPT_WPLF_Form {
     
    2626    add_filter( 'get_sample_permalink_html', array( $this, 'modify_permalink_html' ), 10, 2 );
    2727    add_action( 'save_post', array( $this, 'save_cpt' ) );
    28     add_filter( 'content_save_pre' , array( $this, 'strip_form_tags' ), 10, 1 );
     28    add_filter( 'content_save_pre', array( $this, 'strip_form_tags' ), 10, 1 );
    2929    add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes_cpt' ) );
    3030    add_action( 'admin_enqueue_scripts', array( $this, 'admin_post_scripts_cpt' ), 10, 1 );
     
    3232    // edit.php view
    3333    add_filter( 'post_row_actions', array( $this, 'remove_row_actions' ), 10, 2 );
    34     add_filter( 'manage_edit-wplf-form_columns' , array( $this, 'custom_columns_cpt' ), 100, 1 );
    35     add_action( 'manage_posts_custom_column' , array( $this, 'custom_columns_display_cpt' ), 10, 2 );
     34    add_filter( 'manage_edit-wplf-form_columns', array( $this, 'custom_columns_cpt' ), 100, 1 );
     35    add_action( 'manage_posts_custom_column', array( $this, 'custom_columns_display_cpt' ), 10, 2 );
    3636
    3737    add_filter( 'default_content', array( $this, 'default_content_cpt' ) );
     
    4444    add_action( 'wp_enqueue_scripts', array( $this, 'maybe_enqueue_frontend_script' ) );
    4545
    46     // same default filters as the_content, but we don't want to use actual the_content for the form output
     46    // default filters for the_content, but we don't want to use actual the_content
    4747    add_filter( 'wplf_form', 'wptexturize' );
    4848    add_filter( 'wplf_form', 'convert_smilies' );
    49     add_filter( 'wplf_form', 'convert_chars'  );
     49    add_filter( 'wplf_form', 'convert_chars' );
    5050    add_filter( 'wplf_form', 'wpautop' );
    5151    add_filter( 'wplf_form', 'shortcode_unautop' );
     
    6666      'search_items'       => __( 'Search Forms', 'wp-libre-form' ),
    6767      'not_found'          => __( 'No forms found.', 'wp-libre-form' ),
    68       'not_found_in_trash' => __( 'No forms found in Trash.', 'wp-libre-form' )
     68      'not_found_in_trash' => __( 'No forms found in Trash.', 'wp-libre-form' ),
    6969    );
    7070
    7171    $args = array(
    72       'labels'             => $labels,
    73       'public'             => true,
    74       'publicly_queryable' => true,
    75       'exclude_from_search'=> true,
    76       'show_ui'            => true,
    77       'show_in_menu'       => true,
    78       'menu_icon'          => 'dashicons-archive',
    79       'query_var'          => false,
    80       'capability_type'    => 'post',
    81       'has_archive'        => false,
    82       'hierarchical'       => false,
    83       'menu_position'      => null,
    84       'rewrite'            => array(
     72      'labels'              => $labels,
     73      'public'              => true,
     74      'publicly_queryable'  => true,
     75      'exclude_from_search' => true,
     76      'show_ui'             => true,
     77      'show_in_menu'        => true,
     78      'menu_icon'           => 'dashicons-archive',
     79      'query_var'           => false,
     80      'capability_type'     => 'post',
     81      'has_archive'         => false,
     82      'hierarchical'        => false,
     83      'menu_position'       => null,
     84      'rewrite'             => array(
    8585        'slug' => 'libre-forms',
    8686      ),
    87       'supports'           => array(
     87      'supports'            => array(
    8888        'title',
    8989        'editor',
     
    102102    $publicly_visible = $this->get_publicly_visible_state( $post_id );
    103103
    104     if( get_post_type( $post_id ) === 'wplf-form' && !$publicly_visible ) {
    105       $html .= '<span>' . __( 'Permalink is for preview purposes only.', 'wp-libre-form' ) . '</span>';
     104    if ( get_post_type( $post_id ) === 'wplf-form' && ! $publicly_visible ) {
     105      $html .= '<span>';
     106      $html .= __( 'Permalink is for preview purposes only.', 'wp-libre-form' );
     107      $html .= '</span>';
    106108    }
    107109
     
    116118
    117119    // only for this cpt
    118     if ( 'wplf-form' == get_post_type( $post ) ) {
     120    if ( 'wplf-form' === get_post_type( $post ) ) {
    119121      return false;
    120122    }
     
    130132
    131133    // make sure we're on the correct view
    132     if ( 'post-new.php' != $hook && 'post.php' != $hook ) {
     134    if ( 'post-new.php' !== $hook && 'post.php' !== $hook ) {
    133135      return;
    134136    }
    135137
    136138    // only for this cpt
    137     if ( 'wplf-form' != $post->post_type ) {
     139    if ( 'wplf-form' !== $post->post_type ) {
    138140      return;
    139141    }
    140142
    141143    // enqueue the custom JS for this view
    142     wp_enqueue_script( 'wplf-form-edit-js', plugins_url( 'assets/scripts/wplf-admin-form.js', dirname(__FILE__) ) );
     144    wp_enqueue_script( 'wplf-form-edit-js', plugins_url( 'assets/scripts/wplf-admin-form.js', dirname( __FILE__ ) ) );
    143145  }
    144146
     
    151153
    152154    // only on post.php screen
    153     if ( 'post-new.php' != $pagenow && 'post.php' != $pagenow ) {
     155    if ( 'post-new.php' !== $pagenow && 'post.php' !== $pagenow ) {
    154156      return $content;
    155157    }
     
    160162
    161163      // default content starts here:
    162 ?>
    163 <label for="name"><?php _e( 'Please enter your name', 'wp-libre-form' ); ?></label>
    164 <input type="text" name="name" id="name" placeholder="<?php _ex( 'John Doe', 'Default placeholder name', 'wp-libre-form' ); ?>">
    165 
    166 <label for="email"><?php _e( 'Please enter your email address', 'wp-libre-form' ); ?> <?php _e( '(required)', 'wp-libre-form' ); ?></label>
    167 <input type="email" name="email" id="email" placeholder="<?php _ex( '[email protected]', 'Default placeholder email', 'wp-libre-form' ); ?>" required>
    168 
    169 <label for="message"><?php _e( 'Write your message below', 'wp-libre-form' ); ?> <?php _e( '(required)', 'wp-libre-form' ); ?></label>
    170 <textarea name="message" rows="5" id="message" placeholder="<?php _ex( 'I wanted to ask about...', 'Default placeholder message', 'wp-libre-form' ); ?>" required></textarea>
    171 
    172 <button type="submit"><?php _e( 'Submit', 'wp-libre-form' ); ?></button>
    173 
    174 <!-- <?php _ex( 'Any valid HTML form can be used here!', 'The HTML comment at the end of the example form', 'wp-libre-form' ); ?> -->
    175 <?php
     164      // @codingStandardsIgnoreStart
     165?>
     166<label for="name"><?php esc_html_e( 'Please enter your name', 'wp-libre-form' ); ?></label>
     167<input type="text" name="name" id="name" placeholder="<?php echo esc_html_x( 'John Doe', 'Default placeholder name', 'wp-libre-form' ); ?>">
     168
     169<label for="email"><?php echo esc_html_x( 'Please enter your email address', 'wp-libre-form' ); ?> <?php esc_html_e( '(required)', 'wp-libre-form' ); ?></label>
     170<input type="email" name="email" id="email" placeholder="<?php echo esc_html_x( '[email protected]', 'Default placeholder email', 'wp-libre-form' ); ?>" required>
     171
     172<label for="message"><?php esc_html_e( 'Write your message below', 'wp-libre-form' ); ?> <?php esc_html_e( '(required)', 'wp-libre-form' ); ?></label>
     173<textarea name="message" rows="5" id="message" placeholder="<?php echo esc_html_x( 'I wanted to ask about...', 'Default placeholder message', 'wp-libre-form' ); ?>" required></textarea>
     174
     175<button type="submit"><?php esc_html_e( 'Submit', 'wp-libre-form' ); ?></button>
     176
     177<!-- <?php echo esc_html_x( 'Any valid HTML form can be used here!', 'The HTML comment at the end of the example form', 'wp-libre-form' ); ?> -->
     178<?php
     179      // @codingStandardsIgnoreEnd
    176180      $content = esc_textarea( ob_get_clean() );
    177181    }
     
    186190    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
    187191
    188     if( $post->post_type === 'wplf-form' && !$publicly_visible )
     192    if ( 'wplf-form' === $post->post_type && ! $publicly_visible ) {
    189193      unset( $actions['view'] );
     194    }
    190195
    191196    return $actions;
     
    211216   */
    212217  function custom_columns_display_cpt( $column, $post_id ) {
    213     if( 'shortcode' === $column ) {
    214 ?>
    215 <input type="text" class="code" value='[libre-form id="<?php echo $post_id; ?>"]' readonly>
    216 <?php
    217     }
    218     if( 'submissions' === $column ) {
     218    if ( 'shortcode' === $column ) {
     219?>
     220<input type="text" class="code" value='[libre-form id="<?php echo intval( $post_id ); ?>"]' readonly>
     221<?php
     222    }
     223    if ( 'submissions' === $column ) {
    219224      // count number of submissions
    220225      $submissions = get_posts( array(
     
    223228        'meta_key' => '_form_id',
    224229        'meta_value' => $post_id,
     230        'suppress_filters' => false,
    225231      ) );
    226232?>
    227   <a href="<?php echo admin_url( 'edit.php?post_type=wplf-submission&form=' . $post_id ); ?>"><?php echo count( $submissions ); ?></a>
     233  <a href="<?php echo esc_url_raw( admin_url( 'edit.php?post_type=wplf-submission&form=' . $post_id ) ); ?>">
     234    <?php echo count( $submissions ); ?>
     235  </a>
    228236<?php
    229237    }
     
    289297  function metabox_shortcode( $post ) {
    290298?>
    291 <p><input type="text" class="code" value='[libre-form id="<?php echo $post->ID; ?>"]' readonly></p>
     299<p><input type="text" class="code" value='[libre-form id="<?php echo esc_attr( $post->ID ); ?>"]' readonly></p>
    292300<?php
    293301  }
     
    299307    // get post meta
    300308    $meta = get_post_meta( $post->ID );
    301     $message = isset( $meta['_wplf_thank_you'] ) ? $meta['_wplf_thank_you'][0] : _x( 'Thank you! :)', 'Default success message', 'wp-libre-form' );
     309    $message = isset( $meta['_wplf_thank_you'] ) ?
     310      $meta['_wplf_thank_you'][0] : _x( 'Thank you! :)', 'Default success message', 'wp-libre-form' );
    302311?>
    303312<p>
     
    307316  'textarea_name' => 'wplf_thank_you',
    308317  'textarea_rows' => 6,
    309   'teeny' => true
     318  'teeny' => true,
    310319  )); ?>
    311320</p>
     
    318327   * Meta box callback for form fields meta box
    319328   */
    320   function metabox_form_fields( $post ) {
    321 ?>
    322 <p><?php _e('Fields marked with * are required', 'wp-libre-form'); ?></p>
     329  function metabox_form_fields() {
     330?>
     331<p><?php esc_html_e( 'Fields marked with * are required', 'wp-libre-form' ); ?></p>
    323332<div class="wplf-form-field-container">
    324333<!--  <div class="wplf-form-field widget-top"><div class="widget-title"><h4>name</h4></div></div> -->
     
    340349<p>
    341350  <label for="wplf_email_copy_enabled">
    342     <input type="checkbox" <?php echo $email_enabled ? 'checked="checked"' : ''; ?> id="wplf_email_copy_enabled" name="wplf_email_copy_enabled">
    343     <?php _e( 'Send an email copy when a form is submitted?', 'wp-libre-form' ); ?>
     351    <input
     352      id="wplf_email_copy_enabled"
     353      name="wplf_email_copy_enabled"
     354      type="checkbox"
     355      <?php echo $email_enabled ? 'checked="checked"' : ''; ?>
     356    >
     357    <?php esc_html_e( 'Send an email copy when a form is submitted?', 'wp-libre-form' ); ?>
    344358  </label>
    345359</p>
    346 <p><input type="text" name="wplf_email_copy_to" value="<?php echo esc_attr( $email_copy_to ); ?>" placeholder="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>" style="width:100%;display:none"></p>
     360<p>
     361  <input
     362    type="text"
     363    name="wplf_email_copy_to"
     364    value="<?php echo esc_attr( $email_copy_to ); ?>"
     365    placeholder="<?php echo esc_attr( get_option( 'admin_email' ) ); ?>"
     366    style="width:100%;display:none"
     367  >
     368</p>
    347369<?php
    348370  }
     
    357379    $format = isset( $meta['_wplf_title_format'] ) ? $meta['_wplf_title_format'][0] : $default;
    358380?>
    359 <p><?php _e('Submissions from this form will use this formatting in their title.', 'wp-libre-form'); ?></p>
    360 <p><?php _e('You may use any field values enclosed in "%" markers.', 'wp-libre-form');?></p>
    361 <p><input type="text" name="wplf_title_format" value="<?php echo esc_attr( $format ); ?>" placeholder="<?php echo esc_attr( $default ); ?>" class="code" style="width:100%" autocomplete="off"></p>
     381<p><?php esc_html_e( 'Submissions from this form will use this formatting in their title.', 'wp-libre-form' ); ?></p>
     382<p><?php esc_html_e( 'You may use any field values enclosed in "%" markers.', 'wp-libre-form' );?></p>
     383<p>
     384  <input
     385    type="text"
     386    name="wplf_title_format"
     387    value="<?php echo esc_attr( $format ); ?>"
     388    placeholder="<?php echo esc_attr( $default ); ?>"
     389    class="code"
     390    style="width:100%"
     391    autocomplete="off"
     392  >
     393</p>
    362394<?php
    363395  }
     
    370402    if ( ! isset( $_POST['wplf_form_meta_nonce'] ) ) {
    371403      return;
    372     }
    373     else if ( ! wp_verify_nonce( $_POST['wplf_form_meta_nonce'], 'wplf_form_meta' ) ) {
     404    } elseif ( ! wp_verify_nonce( $_POST['wplf_form_meta_nonce'], 'wplf_form_meta' ) ) {
    374405      return;
    375406    }
    376407
    377408    // only for this cpt
    378     if ( !isset( $_POST['post_type'] ) || 'wplf-form' != $_POST['post_type'] ) {
     409    if ( ! isset( $_POST['post_type'] ) || 'wplf-form' !== $_POST['post_type'] ) {
    379410      return;
    380411    }
     
    403434    if ( isset( $_POST['wplf_email_copy_enabled'] ) ) {
    404435      update_post_meta( $post_id, '_wplf_email_copy_enabled', $_POST['wplf_email_copy_enabled'] === 'on' );
    405     }
    406     else {
     436    } else {
    407437      update_post_meta( $post_id, '_wplf_email_copy_enabled', false );
    408438    }
     
    410440    // save email copy
    411441    if ( isset( $_POST['wplf_email_copy_to'] ) ) {
    412       $emailField = $_POST['wplf_email_copy_to'];
     442      $email_field = $_POST['wplf_email_copy_to'];
    413443      $to = '';
    414444
    415       if( strpos( $emailField, "," ) > 0 ) {
     445      if ( strpos( $email_field, ',' ) > 0 ) {
    416446        // Intentional. Makes no sense if the first character is a comma, so pass it along as a single address.
    417447        // sanitize_email() should take care of the rest.
    418         $emailArray = explode( ",", $emailField );
    419         foreach($emailArray as $email){
    420           $email = trim($email);
    421           $email = sanitize_email( $email ) . ", ";
     448        $email_array = explode( ',', $email_field );
     449        foreach ( $email_array as $email ) {
     450          $email = trim( $email );
     451          $email = sanitize_email( $email ) . ', ';
    422452          $to .= $email;
    423453        }
    424         $to = rtrim( $to, ", " );
     454        $to = rtrim( $to, ', ' );
     455      } else {
     456        $to = sanitize_email( $email_field );
    425457      }
    426       else {
    427         $to = sanitize_email( $emailField );
    428       }
    429 
    430       if( !empty( $to ) ) {
     458
     459      if ( ! empty( $to ) ) {
    431460        update_post_meta( $post_id, '_wplf_email_copy_to', $to );
    432461      } else {
     
    455484   */
    456485  function strip_form_tags( $content ) {
    457     return preg_replace( '/<\/?form.*>/i', '', $content);
     486    return preg_replace( '/<\/?form.*>/i', '', $content );
    458487  }
    459488
     
    462491   * The function we display the form with
    463492   */
    464   function wplf_form( $id , $content = '', $xclass = '' ) {
     493  function wplf_form( $id, $content = '', $xclass = '' ) {
    465494    global $post;
    466495
    467     if( 'publish' === get_post_status( $id ) || 'true' === $_GET['preview'] ) {
    468       if( empty( $content ) ) {
     496    if ( 'publish' === get_post_status( $id ) || 'true' === $_GET['preview'] ) {
     497      if ( empty( $content ) ) {
    469498        // you can override the content via a parameter
    470499        $content = get_post( $id )->post_content;
    471500      }
    472501
    473       $multipart = "";
    474       // check if form contains file inputs
    475       if(strpos($content, "type='file'") > -1 || strpos($content, "type=\"file\"") > -1){
    476         $multipart = "enctype='multipart/form-data'";
    477       }
    478 
    479502      ob_start();
    480503?>
    481 <form class="libre-form libre-form-<?php echo $id . ' ' . $xclass; ?>" <?php echo $multipart; ?>>
    482   <?php if( is_singular( 'wplf-form' ) && current_user_can( 'edit_post', $id ) ) {
     504<form
     505  class="libre-form libre-form-<?php echo esc_attr( $id . ' ' . $xclass ); ?>"
     506  <?php
     507    // check if form contains file inputs
     508    if ( strpos( $content, "type='file'" ) >= 0 || strpos( $content, 'type="file"' ) >= 0 ) {
     509      echo "enctype='multipart/form-data'";
     510    }
     511  ?>
     512>
     513  <?php if ( is_singular( 'wplf-form' ) && current_user_can( 'edit_post', $id ) ) {
    483514    $publicly_visible = $this->get_publicly_visible_state( $id );
    484     if( !$publicly_visible ) {
     515    if ( ! $publicly_visible ) {
    485516?>
    486517      <p style="background:#f5f5f5;border-left:4px solid #dc3232;padding:6px 12px;">
    487         <b style="color:#dc3232;"><?php _e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?></b><br />
    488         <?php _e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
     518        <strong style="color:#dc3232;">
     519          <?php esc_html_e( 'This form preview URL is not public and cannot be shared.', 'wp-libre-form' ) ?>
     520        </strong>
     521        <br />
     522        <?php esc_html_e( 'Non-logged in visitors will see a 404 error page instead.', 'wp-libre-form' ) ?>
    489523      </p>
    490524<?php
    491525    }
    492526  } ?>
    493   <?php echo apply_filters( 'wplf_form', $content ); ?>
     527  <?php
     528    // This is where we output the user-input form html. We allow all HTML here. Yes, even scripts.
     529    // @codingStandardsIgnoreStart
     530    echo apply_filters( 'wplf_form', $content );
     531    // @codingStandardsIgnoreEnd
     532  ?>
    494533  <input type="hidden" name="referrer" value="<?php the_permalink(); ?>">
    495   <input type="hidden" name="_referrer_id" value="<?php esc_attr_e( get_the_id() ) ?>">
    496   <input type="hidden" name="_form_id" value="<?php esc_attr_e( $id ); ?>">
     534  <input type="hidden" name="_referrer_id" value="<?php echo esc_attr( get_the_id() ) ?>">
     535  <input type="hidden" name="_form_id" value="<?php echo esc_attr( $id ); ?>">
    497536</form>
    498537<?php
     
    515554    wp_register_script(
    516555      'wplf-form-js',
    517       plugins_url( 'assets/scripts/wplf-form.js', dirname(__FILE__) ),
     556      plugins_url( 'assets/scripts/wplf-form.js', dirname( __FILE__ ) ),
    518557      apply_filters( 'wplf_frontend_script_dependencies', array() ),
    519558      WPLF_VERSION,
     
    521560    );
    522561
    523     if( is_a( $post, 'WP_Post' ) && ( has_shortcode( $post->post_content, 'libre-form') || $post->post_type === 'wplf-form') ) {
    524       wp_enqueue_script( 'wplf-form-js' );
    525       wp_localize_script( 'wplf-form-js', 'ajax_object', array(
    526         'ajax_url' => admin_url( 'admin-ajax.php' ),
    527         'ajax_credentials' => apply_filters('wplf_ajax_fetch_credentials_mode', 'same-origin')
    528       ) );
     562    if ( is_a( $post, 'WP_Post' ) ) {
     563      if ( has_shortcode( $post->post_content, 'libre-form' ) || $post->post_type === 'wplf-form' ) {
     564        wp_enqueue_script( 'wplf-form-js' );
     565        wp_localize_script( 'wplf-form-js', 'ajax_object', array(
     566          'ajax_url' => admin_url( 'admin-ajax.php' ),
     567          'ajax_credentials' => apply_filters( 'wplf_ajax_fetch_credentials_mode', 'same-origin' ),
     568        ) );
     569      }
    529570    }
    530571  }
     
    534575   * Shortcode for displaying a Form
    535576   */
    536   function shortcode($attributes, $content = null) {
     577  function shortcode( $attributes ) {
    537578    $attributes = shortcode_atts( array(
    538579      'id' => null,
     
    550591  function use_shortcode_for_preview( $content ) {
    551592    global $post;
    552     if( isset( $post->post_type ) && $post->post_type === 'wplf-form') {
     593    if ( isset( $post->post_type ) && $post->post_type === 'wplf-form' ) {
    553594      return $this->wplf_form( $post->ID, $content );
    554595    }
     
    563604    global $post;
    564605
    565     if( !is_singular( 'wplf-form' ) )
    566       return;
     606    if ( ! is_singular( 'wplf-form' ) ) {
     607      return;
     608    }
    567609
    568610    $publicly_visible = $this->get_publicly_visible_state( $post->ID );
    569     if( $publicly_visible )
    570       return;
    571 
    572     if( !current_user_can( 'edit_post', $post->ID ) ) {
     611    if ( $publicly_visible ) {
     612      return;
     613    }
     614
     615    if ( ! current_user_can( 'edit_post', $post->ID ) ) {
    573616      global $wp_query;
    574617      $wp_query->set_404();
  • wp-libre-form/tags/1.2.2/classes/class-cpt-wplf-submission.php

    r1522463 r1648101  
    11<?php
    22
    3 if ( !class_exists('CPT_WPLF_Submission') ) :
     3if ( ! class_exists( 'CPT_WPLF_Submission' ) ) :
    44
    55class CPT_WPLF_Submission {
     
    2727
    2828    // edit.php view
    29     add_filter( 'manage_edit-wplf-submission_columns' , array( $this, 'custom_columns_cpt' ), 100, 1);
    30     add_action( 'manage_posts_custom_column' , array( $this, 'custom_columns_display_cpt' ), 10, 2 );
     29    add_filter( 'manage_edit-wplf-submission_columns', array( $this, 'custom_columns_cpt' ), 100, 1 );
     30    add_action( 'manage_posts_custom_column', array( $this, 'custom_columns_display_cpt' ), 10, 2 );
    3131    add_action( 'restrict_manage_posts', array( $this, 'form_filter_dropdown' ) );
    3232    add_filter( 'pre_get_posts', array( $this, 'filter_by_form' ) );
     33
     34    // add custom bulk actions
     35    add_action( 'admin_notices', array( $this, 'wplf_submission_bulk_action_admin_notice' ) );
     36    add_filter( 'bulk_actions-edit-wplf-submission', array( $this, 'register_wplf_submission_bulk_actions' ) );
     37    add_filter( 'handle_bulk_actions-edit-wplf-submission',
     38      array( $this, 'wplf_submission_bulk_action_handler' ), 10, 3 );
    3339  }
    3440
     
    4753      'search_items'       => __( 'Search Submissions', 'wp-libre-form' ),
    4854      'not_found'          => __( 'No submissions found.', 'wp-libre-form' ),
    49       'not_found_in_trash' => __( 'No submissions found in Trash.', 'wp-libre-form' )
     55      'not_found_in_trash' => __( 'No submissions found in Trash.', 'wp-libre-form' ),
    5056    );
    5157
     
    6369      'hierarchical'       => false,
    6470      'menu_position'      => null,
    65       'supports'           => array( 'title', 'custom-fields' )
     71      'supports'           => array( 'title', 'custom-fields' ),
    6672    );
    6773
     
    7480   */
    7581  function custom_columns_display_cpt( $column, $post_id ) {
    76     if( 'referrer' === $column ) {
    77       if( $referrer = get_post_meta($post_id, 'referrer', true) ) {
     82    if ( 'referrer' === $column ) {
     83      if ( $referrer = get_post_meta( $post_id, 'referrer', true ) ) {
    7884        echo '<a href="' . esc_url_raw( $referrer ) . '">' . esc_url( $referrer ) . '</a>';
    7985      }
    8086    }
    81     if( 'form' === $column ) {
    82       if( $form_id = get_post_meta($post_id, '_form_id', true) ) {
     87    if ( 'form' === $column ) {
     88      if ( $form_id = get_post_meta( $post_id, '_form_id', true ) ) {
    8389        $form = get_post( $form_id );
    84         echo '<a href="' . get_edit_post_link( $form_id, '' ) . '" target="_blank">' . esc_html( $form->post_title ) . '</a>';
     90        echo '<a href="' . esc_url_raw( get_edit_post_link( $form_id, '' ) ) . '" target="_blank">';
     91        echo esc_html( $form->post_title );
     92        echo '</a>';
    8593      }
    8694    }
     
    107115    global $pagenow;
    108116
    109     $allowed = array("wplf-submission"); // show filter on these post types (currently only one?)
    110     $allowed = apply_filters("wplf-dropdown-filter", $allowed);
    111     $post_type = get_query_var("post_type");
    112 
    113     if( 'edit.php' != $pagenow || !in_array($post_type, $allowed)) {
     117    $allowed = array( 'wplf-submission' ); // show filter on these post types (currently only one?)
     118    $allowed = apply_filters( 'wplf-dropdown-filter', $allowed );
     119    $post_type = get_query_var( 'post_type' );
     120
     121    if ( 'edit.php' !== $pagenow || ! in_array( $post_type, $allowed, true ) ) {
    114122      return;
    115123    }
    116124
    117     $transient = get_transient("wplf-form-filter");
    118 
    119     if($transient){
     125    $transient = get_transient( 'wplf-form-filter' );
     126
     127    if ( $transient ) {
    120128      $forms = $transient;
    121     }
    122 
    123     else{
     129    } else {
    124130      $forms = get_posts( array(
    125131        'post_per_page' => '-1',
     
    127133      ) );
    128134
    129       set_transient("wplf-form-filter", $forms, 15 *  MINUTE_IN_SECONDS);
     135      set_transient( 'wplf-form-filter', $forms, 15 * MINUTE_IN_SECONDS );
    130136    }
    131137
     
    133139<label for="filter-by-form" class="screen-reader-text">Filter by form</label>
    134140<select name="form" id="filter-by-form">
    135   <option value="0"><?php _e('All Forms', 'wp-libre-form'); ?></option>
    136   <?php foreach( $forms as $form ) : ?>
    137   <option value="<?php echo $form->ID; ?>" <?php echo isset( $_REQUEST['form'] ) && $_REQUEST['form'] == $form->ID ? 'selected' : ''; ?>><?php echo $form->post_title; ?></option>
     141  <option value="0"><?php esc_html_e( 'All Forms', 'wp-libre-form' ); ?></option>
     142  <?php foreach ( $forms as $form ) : ?>
     143    <option
     144      value="<?php echo intval( $form->ID ); ?>"
     145      <?php echo isset( $_REQUEST['form'] ) && intval( $_REQUEST['form'] ) === $form->ID ? 'selected' : ''; ?>
     146    ><?php esc_html( $form->post_title ); ?></option>
    138147  <?php endforeach; ?>
    139148</select>
     
    147156    global $pagenow;
    148157
    149     if( 'edit.php' != $pagenow ) {
     158    if ( 'edit.php' !== $pagenow ) {
    150159      return $query;
    151160    }
    152161
    153     if( $query->get( 'post_type' ) != 'wplf-submission' ) {
     162    if ( $query->get( 'post_type' ) !== 'wplf-submission' ) {
    154163      return $query;
    155164    }
    156165
    157     if( isset( $_REQUEST['form'] ) && ! empty( $_REQUEST['form'] ) ) {
     166    if ( isset( $_REQUEST['form'] ) && ! empty( $_REQUEST['form'] ) ) {
    158167      $query->set( 'meta_key', '_form_id' );
    159168      $query->set( 'meta_value', intval( $_REQUEST['form'] ) );
     
    161170
    162171    return $query;
     172  }
     173
     174  function register_wplf_submission_bulk_actions( $bulk_actions ) {
     175    $bulk_actions['wplf_resend_copy'] = __( 'Resend email copy', 'wp-libre-form' );
     176    return $bulk_actions;
     177  }
     178
     179  function wplf_submission_bulk_action_handler( $redirect_to, $doaction, $post_ids ) {
     180    if ( $doaction !== 'wplf_resend_copy' ) {
     181      return $redirect_to;
     182    }
     183
     184    foreach ( $post_ids as $post_id ) {
     185      $return = new stdClass();
     186      $return->ok = 1;
     187
     188      wplf_send_email_copy( $return, $post_id );
     189    }
     190
     191    $redirect_to = add_query_arg( 'wplf_resent', count( $post_ids ), $redirect_to );
     192    return $redirect_to;
     193  }
     194
     195  function wplf_submission_bulk_action_admin_notice() {
     196    if ( ! empty( $_REQUEST['wplf_resent'] ) ) {
     197      $count = intval( $_REQUEST['wplf_resent'] );
     198      printf(
     199        '<div id="wplf-submission-bulk-resend-message" class="notice notice-success"><p>' .
     200          esc_html(
     201             // translators: %s is number of submissions
     202             _n( 'Resent email copy of %s submission.',
     203                 'Resent email copy of %s submissions.',
     204                 $count,
     205             'wp-libre-form'
     206             )
     207          ) .
     208          '</p></div>',
     209        intval( $count ) );
     210    }
    163211  }
    164212
     
    191239    <thead>
    192240      <tr>
    193         <th><strong><?php _e( 'Field', 'wp-libre-form' ); ?></strong></th>
    194         <th><strong><?php _e( 'Value', 'wp-libre-form' ); ?></strong></th>
     241        <th><strong><?php esc_html_e( 'Field', 'wp-libre-form' ); ?></strong></th>
     242        <th><strong><?php esc_html_e( 'Value', 'wp-libre-form' ); ?></strong></th>
    195243      </tr>
    196244    </thead>
    197245    <tbody>
    198       <?php foreach( $fields as $field ) : ?>
    199         <?php if( '_' != $field[0] ) : ?>
     246      <?php foreach ( $fields as $field ) : ?>
     247        <?php if ( '_' !== $field[0] ) : ?>
    200248        <?php
    201249        $value = $postmeta[ $field ][0];
     
    206254        // if the field ends with '_attachment' and there is an attachment url that corresponds to the id, show a link
    207255        $attachment_suffix = '_attachment';
    208         if ( substr( $field, -strlen( $attachment_suffix ) ) === $attachment_suffix && wp_get_attachment_url( $value ) ) {
    209           $link_text = __( 'View Attachment', 'wp-libre-form' );
    210           $possible_link = '<a target="_blank" href="' . get_edit_post_link( $value ) . '" style="float:right">' . $link_text . '</a>';
     256        if ( substr( $field, -strlen( $attachment_suffix ) ) === $attachment_suffix ) {
     257          if ( wp_get_attachment_url( $value ) ) {
     258            $link_text = __( 'View Attachment', 'wp-libre-form' );
     259            $possible_link = '<a target="_blank" href="' . get_edit_post_link( $value ) . '" style="float:right">';
     260            $possible_link .= $link_text . '</a>';
     261          }
    211262        }
    212263
     
    220271        ?>
    221272        <tr>
    222           <th><strong><?php echo $field; ?></strong> <?php echo $possible_link; ?></th>
    223           <?php if( strlen( $value ) > 60 || strpos( $value, "\n" ) ) : ?>
     273          <th><strong><?php echo esc_html( $field ); ?></strong> <?php echo wp_kses( $possible_link ); ?></th>
     274          <?php if ( strlen( $value ) > 60 || strpos( $value, "\n" ) ) : ?>
    224275          <td><textarea style="width:100%" readonly><?php echo esc_textarea( $value ); ?></textarea></td>
    225276          <?php else : ?>
    226           <td><input style="width:100%" type="text" value="<?php esc_attr_e( $value ); ?>" readonly></td>
     277          <td><input style="width:100%" type="text" value="<?php echo esc_attr( $value ); ?>" readonly></td>
    227278          <?php endif; ?>
    228279        </tr>
  • wp-libre-form/tags/1.2.2/classes/class-wplf-polylang.php

    r1538951 r1648101  
    11<?php
    2 if ( !class_exists( 'WPLF_Polylang' ) ) {
     2if ( ! class_exists( 'WPLF_Polylang' ) ) {
    33  class WPLF_Polylang {
    44    /**
     
    2121    private function __construct() {
    2222      add_filter( 'wplf_form', array( $this, 'render_form' ) );
    23       add_filter( 'save_post_wplf-form', array( $this, 'save_form' ), 10, 3);
    24       add_action( 'after_setup_theme', array ( $this, 'register_strings') );
     23      add_filter( 'save_post_wplf-form', array( $this, 'save_form' ), 10, 3 );
     24      add_action( 'after_setup_theme', array( $this, 'register_strings' ) );
    2525
    2626      $this->strings = get_option( 'wplf-translation-strings', array() );
     
    2828    }
    2929
    30     public function render_form ( $form_content ) {
     30    public function render_form( $form_content ) {
    3131      // Get all strings inside double curly braces.
    3232      preg_match_all( $this->regular_expression, $form_content, $matches );
    33       foreach( $matches[0] as $match ){
     33      foreach ( $matches[0] as $match ) {
    3434        // match contains the braces, get rid of them.
    35         $string = trim( str_replace( array( "{" , "}" ), array( "", "" ), $match ) );
    36         $form_content = str_replace( $match, $this->translate_string ( $string ), $form_content );
     35        $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     36        $form_content = str_replace( $match, $this->translate_string( $string ), $form_content );
    3737      }
    3838
     
    4040    }
    4141
    42     function save_form ( $post_id, $post, $update ) {
     42    function save_form( $post_id, $post, $update ) {
     43      unset( $post_id, $update ); // not used here so shut up linter!
     44
    4345      preg_match_all( $this->regular_expression, $post->post_content, $matches );
    44       if( !empty( $matches ) ) {
    45         foreach( $matches[0] as $match ){
     46      if ( ! empty( $matches ) ) {
     47        foreach ( $matches[0] as $match ) {
    4648          // match contains the braces, get rid of them.
    47           $string = trim( str_replace( array( "{" , "}" ), array( "", "" ), $match ) );
    48           $this->strings[$string] = null;
     49          $string = trim( str_replace( array( '{', '}' ), array( '', '' ), $match ) );
     50          $this->strings[ $string ] = null;
    4951          // By storing the string as the array key, we don't need to use array_unique.
    5052        }
     
    5456    }
    5557
    56     public function register_strings () {
    57       foreach( $this->strings as $string => $value ) {
     58    public function register_strings() {
     59      foreach ( $this->strings as $string => $value ) {
    5860        $this->register_string( $string );
    5961      }
    6062    }
    6163
    62     public function register_string ( $string ) {
    63       if( function_exists( 'pll_register_string' ) ) {
     64    public function register_string( $string ) {
     65      if ( function_exists( 'pll_register_string' ) ) {
    6466        pll_register_string( $string, $string, 'WP Libre Form' );
    65       } else {
    66         // Don't kill anything.
    6767      }
    6868    }
    6969
    70     public function translate_string ( $string ) {
    71       if( function_exists( 'pll__' ) ) {
     70    public function translate_string( $string ) {
     71      if ( function_exists( 'pll__' ) ) {
    7272        return pll__( $string );
    7373      } else {
  • wp-libre-form/tags/1.2.2/inc/wplf-ajax.php

    r1522309 r1648101  
    11<?php
    2 
    32/**
    43 * Ajax handler for the form submissions
    54 */
     5
    66add_action( 'wp_ajax_wplf_submit', 'wplf_ajax_submit_handler' );
    77add_action( 'wp_ajax_nopriv_wplf_submit', 'wplf_ajax_submit_handler' );
     
    1111
    1212  // allow user to pre-process the post fields
    13   do_action('wplf_pre_validate_submission');
     13  do_action( 'wplf_pre_validate_submission' );
    1414
    1515  // validate form fields
     
    1717  $return = apply_filters( 'wplf_validate_submission', $return );
    1818
    19   if( $return->ok ) {
     19  if ( $return->ok ) {
    2020    // form existence has already been validated via filters
    21 
    22 
    2321    $form = get_post( intval( $_POST['_form_id'] ) );
    2422
     
    2927    $post_title = $title_format;
    3028
    31     preg_match_all('/%(.+?)%/', $post_title, $toks);
    32     foreach($toks[1] as $tok) {
     29    preg_match_all( '/%(.+?)%/', $post_title, $toks );
     30    foreach ( $toks[1] as $tok ) {
    3331      $replace = '';
    34       if( array_key_exists( $tok, $_POST ) ) {
    35         $replace = sanitize_text_field( $_POST[$tok] );
     32      if ( array_key_exists( $tok, $_POST ) ) {
     33        $replace = sanitize_text_field( $_POST[ $tok ] );
    3634      }
    37       $post_title = preg_replace('/%.+?%/', $replace, $post_title, 1);
     35      $post_title = preg_replace( '/%.+?%/', $replace, $post_title, 1 );
    3836    }
    3937
     
    4644
    4745    // add submission data as meta values
    48     foreach( $_POST as $key => $value ) {
    49       if( !is_array($value) ) {
    50         add_post_meta($post_id, $key, esc_html( $value ), true);
    51       }
    52       else {
    53         add_post_meta($post_id, $key, esc_html( json_encode( $value ) ), true);
     46    foreach ( $_POST as $key => $value ) {
     47      if ( ! is_array( $value ) ) {
     48        add_post_meta( $post_id, $key, esc_html( $value ), true );
     49      } else {
     50        add_post_meta( $post_id, $key, esc_html( wp_json_encode( $value ) ), true );
    5451      }
    5552    }
    5653
    5754    // handle files
    58     foreach( $_FILES as $key => $file) {
     55    foreach ( $_FILES as $key => $file ) {
    5956      // Is this enough security wise?
    6057      // Currenly only supports 1 file per input
    61       $attach_id = media_handle_upload( $key, 0, array(), array( "test_form" => false ) );
    62       add_post_meta( $post_id, $key, wp_get_attachment_url($attach_id) );
    63       add_post_meta( $post_id, $key . "_attachment", $attach_id );
     58      $attach_id = media_handle_upload( $key, 0, array(), array(
     59        'test_form' => false,
     60      ) );
     61      add_post_meta( $post_id, $key, wp_get_attachment_url( $attach_id ) );
     62      add_post_meta( $post_id, $key . '_attachment', $attach_id );
    6463    }
    6564
    66 
     65    // save email copy address to submission meta for later use
     66    $to = get_post_meta( $form->ID, '_wplf_email_copy_to', true );
     67    $to = ! empty( $to ) ? $to : get_option( 'admin_email' );
     68    add_post_meta( $post_id, '_wplf_email_copy_to', apply_filters( 'wplf_email_copy_to', $to ) );
    6769
    6870    $return->submission_id = $post_id;
     
    7577    // allow user to attach custom actions after the submission has been received
    7678    // these could be confirmation emails, additional processing for the submission fields, e.g.
    77     do_action('wplf_post_validate_submission', $return);
    78 
     79    do_action( 'wplf_post_validate_submission', $return );
    7980  }
    8081
  • wp-libre-form/tags/1.2.2/inc/wplf-form-actions.php

    r1538409 r1648101  
    11<?php
    22
    3 /**
    4  * Send a copy of the form fields email if feature is enabled
    5  */
    63add_action( 'wplf_post_validate_submission', 'wplf_send_email_copy', 20 );
    7 function wplf_send_email_copy( $return ) {
     4function wplf_send_email_copy( $return, $submission_id = null ) {
    85  // do nothing if form validation failed
    9   if( ! $return->ok ) {
     6  if ( ! $return->ok ) {
    107    return;
    118  }
    129
    13   $form_id = intval( $_POST['_form_id'] ); // _form_id is already validated and we know it exists by this point
     10  // _form_id is already validated and we know it exists by this point
     11  $form_id = intval( ( isset( $submission_id ) ) ?
     12    get_post_meta( $submission_id, '_form_id', true ) : $_POST['_form_id'] );
     13
    1414  $form_title = esc_html( get_the_title( $form_id ) );
    1515  $form_meta = get_post_meta( $form_id );
    16   $referrer = esc_url_raw( $_POST['referrer'] );
    1716
    18   if( isset($form_meta['_wplf_email_copy_enabled']) && $form_meta['_wplf_email_copy_enabled'][0] ) {
    19     $to = isset($form_meta['_wplf_email_copy_to']) ? $form_meta['_wplf_email_copy_to'][0] : get_option( 'admin_email' );
    20     $subject = wp_sprintf( __('New submission from %s', 'wp-libre-form'), $referrer );
    21     $content = wp_sprintf( __('Form "%s" (ID %d) was submitted with values below: ', 'wp-libre-form'), $form_title, $form_id );
    22     $content = apply_filters( 'wplf_email_copy_content_start', $content, $form_title, $form_id ). "\n\n";
     17  $referrer = esc_url_raw( ( isset( $submission_id ) ) ?
     18    get_post_meta( $submission_id, 'referrer', true ) : $_POST['referrer'] );
    2319
    24     foreach( $_POST as $key => $value ) {
    25       if( '_' === $key[0] ) {
     20  if ( ( isset( $form_meta['_wplf_email_copy_enabled'] ) && $form_meta['_wplf_email_copy_enabled'][0] )
     21    || isset( $submission_id ) ) {
     22
     23    $to = $form_meta['_wplf_email_copy_to'][0];
     24    // translators: %s is email address of form submitter
     25    $subject = wp_sprintf( __( 'New submission from %s', 'wp-libre-form' ), $referrer );
     26
     27    if ( isset( $submission_id ) ) {
     28      $to = get_post_meta( $submission_id, '_wplf_email_copy_to', true );
     29      // translators: %s is email address of form submitter
     30      $subject = wp_sprintf( __( 'Submission from %s', 'wp-libre-form' ), $referrer );
     31    }
     32
     33    $to = empty( $to ) ? get_option( 'admin_email' ) : $to;
     34    $content = wp_sprintf(
     35      // translators: %1$s is form title, %2$d is form ID
     36      __( 'Form "%1$s" (ID %2$d) was submitted with values below: ', 'wp-libre-form' ), $form_title, $form_id );
     37    $content = apply_filters( 'wplf_email_copy_content_start', $content, $form_title, $form_id ) . "\n\n";
     38
     39    $fields = $_POST;
     40    if ( isset( $submission_id ) ) {
     41      $fields = get_post_meta( $submission_id );
     42    }
     43
     44    foreach ( $fields as $key => $value ) {
     45      if ( '_' === $key[0] ) {
    2646        continue;
    2747      }
    28       if( is_array( $value ) ) { // in case input type="radio" submits an array
     48      if ( is_array( $value ) ) { // in case input type="radio" submits an array
    2949        $value = implode( ', ', $value );
    3050      }
     51      // @codingStandardsIgnoreStart
     52      // WP coding standards don't like print_r
     53      // @TODO: come up with a prettier format for default mail output
    3154      $content .= esc_html( $key ) . ': ' . esc_html( print_r( $value, true ) ) . "\n";
     55      // @codingStandardsIgnoreEnd
    3256    }
    3357
  • wp-libre-form/tags/1.2.2/inc/wplf-form-validation.php

    r1522463 r1648101  
    77function wplf_validate_form_exists( $return ) {
    88  // skip this validation if submission has already failed
    9   if( ! $return->ok ) {
     9  if ( ! $return->ok ) {
    1010    return $return;
    1111  }
    1212
    13   if( ! isset( $_POST['_form_id'] ) || ! is_numeric( $_POST['_form_id'] ) || 'publish' != get_post_status( $_POST['_form_id'] ) || 'wplf-form' != get_post_type( $_POST['_form_id'] ) ) {
     13  if ( ! isset( $_POST['_form_id'] )
     14    || ! is_numeric( $_POST['_form_id'] )
     15    || 'publish' !== get_post_status( $_POST['_form_id'] )
     16    || 'wplf-form' !== get_post_type( $_POST['_form_id'] )
     17  ) {
    1418    $return->ok = 0;
    15     $return->error = sprintf( __("Form id %d doesn't exist!", 'wp-libre-form'), intval( $_POST['_form_id'] ) );
     19    // translators: %d is form ID
     20    $return->error = sprintf( __( "Form id %d doesn't exist!", 'wp-libre-form' ), intval( $_POST['_form_id'] ) );
    1621  }
    1722  return $return;
     
    2530function wplf_validate_required_empty( $return ) {
    2631  // skip this validation if submission has already failed
    27   if( ! $return->ok ) {
     32  if ( ! $return->ok ) {
    2833    return $return;
    2934  }
     
    3439  // make sure required form fields are submitted within $_POST or $_FILES arrays
    3540  $fields_empty = array();
    36   foreach( $required as $key ) {
    37     if(
    38       ( !array_key_exists( $key, $_POST ) && !array_key_exists( $key, $_FILES ) ) ||
    39       ( empty( $_POST[$key] ) && ! ( $_FILES[$key]['size'] > 0 ) )
     41  foreach ( $required as $key ) {
     42    if (
     43      ( ! array_key_exists( $key, $_POST ) && ! array_key_exists( $key, $_FILES ) ) ||
     44      ( empty( $_POST[ $key ] ) && ! ( $_FILES[ $key ]['size'] > 0 ) )
    4045    ) {
    4146      // required field wasn't in $_POST or $_FILES
     
    4853  $return->debug = $_FILES;
    4954
    50   if(! empty( $fields_empty ) ) {
     55  if ( ! empty( $fields_empty ) ) {
    5156    $return->ok = 0;
    52     $return->error = __('Required fields are missing.', 'wp-libre-form');
     57    $return->error = __( 'Required fields are missing.', 'wp-libre-form' );
    5358    $return->fields_empty = $fields_empty;
    5459  }
     
    5661  return $return;
    5762}
    58 
  • wp-libre-form/tags/1.2.2/readme.md

    r1640733 r1648101  
    11# WP Libre Form
    2 [![Latest Stable Version](https://poser.pugx.org/anttiviljami/wp-libre-form/v/stable)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![Total Downloads](https://poser.pugx.org/anttiviljami/wp-libre-form/downloads)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![Latest Unstable Version](https://poser.pugx.org/anttiviljami/wp-libre-form/v/unstable)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![License](https://poser.pugx.org/anttiviljami/wp-libre-form/license)](https://packagist.org/packages/anttiviljami/wp-libre-form)
     2[![Build Status](https://travis-ci.org/anttiviljami/wp-libre-form.svg?branch=master)](https://travis-ci.org/anttiviljami/wp-libre-form) [![Latest Stable Version](https://poser.pugx.org/anttiviljami/wp-libre-form/v/stable)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![Total Downloads](https://poser.pugx.org/anttiviljami/wp-libre-form/downloads)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![Latest Unstable Version](https://poser.pugx.org/anttiviljami/wp-libre-form/v/unstable)](https://packagist.org/packages/anttiviljami/wp-libre-form) [![License](https://poser.pugx.org/anttiviljami/wp-libre-form/license)](https://packagist.org/packages/anttiviljami/wp-libre-form)
    33
    44Use standard HTML5 markup to create fully functional forms for WordPress
     
    8888```php
    8989wp_enqueue_script('wplf-form-js');
    90 wp_localize_script( 'wplf-form-js', 'ajax_object', array( 
     90wp_localize_script( 'wplf-form-js', 'ajax_object', array(
    9191  'ajax_url' => admin_url( 'admin-ajax.php' ),
    9292  'ajax_credentials' => apply_filters('wplf_frontend_script_credentials', 'same-origin')
  • wp-libre-form/tags/1.2.2/readme.txt

    r1640736 r1648101  
    44Donate link: https://github.com/anttiviljami
    55Requires at least: 4.2
    6 Tested up to: 4.7.3
    7 Stable tag: 1.2.3
     6Tested up to: 4.7.4
     7Stable tag: 1.3
    88License: GPLv3
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • wp-libre-form/tags/1.2.2/wp-libre-form.php

    r1640734 r1648101  
    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.2.3
     6 * Version: 1.3
    77 * Author: @anttiviljami
    88 * Author URI: https://github.com/anttiviljami/
     
    3232if ( ! class_exists( 'WP_Libre_Form' ) ) :
    3333
    34 define( 'WPLF_VERSION', '1.2.3' );
     34define( 'WPLF_VERSION', '1.3' );
    3535
    3636class WP_Libre_Form {
     
    5757    CPT_WPLF_Submission::init();
    5858
    59     add_action( 'after_setup_theme', function() {
    60       if ( apply_filters( 'wplf_load_polylang', true ) ) {
    61         require_once 'classes/class-wplf-polylang.php';
    62         WPLF_Polylang::init();
    63       }
    64     } );
     59    add_action( 'after_setup_theme', array( $this, 'init_polylang_support' ) );
    6560
    6661    add_action( 'plugins_loaded', array( $this, 'load_our_textdomain' ) );
     
    8580  public static function load_our_textdomain() {
    8681    $loaded = load_plugin_textdomain( 'wp-libre-form', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     82    if ( ! $loaded ) {
     83      $loaded = load_muplugin_textdomain( 'wp-libre-form', dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     84    }
     85  }
    8786
    88     if( !$loaded ) {
    89       $loaded = load_muplugin_textdomain( 'wp-libre-form', dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
     87  /**
     88   * Enable Polylang support
     89   */
     90  public function init_polylang_support() {
     91    if ( apply_filters( 'wplf_load_polylang', true ) ) {
     92      require_once 'classes/class-wplf-polylang.php';
     93      WPLF_Polylang::init();
    9094    }
    9195  }
Note: See TracChangeset for help on using the changeset viewer.