Plugin Directory

Changeset 2605428


Ignore:
Timestamp:
09/27/2021 09:18:03 AM (4 years ago)
Author:
heyjackmail
Message:

jackmail-newsletters 1.2.19

Location:
jackmail-newsletters/trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • jackmail-newsletters/trunk/html/template.php

    r2161892 r2605428  
    77                <div class="jackmail_name">
    88                    <span jackmail-content-editable ng-click="t.focus_template_name()"
    9                           when-enter="t.blur_template_name()" input-value="t.template.name"></span>
     9                          when-enter="t.blur_template_name()" input-value="t.template.name"></span>
    1010                    <span ng-hide="t.name_editing" ng-click="t.focus_template_name()" class="dashicons dashicons-edit"></span>
    1111                </div>
    1212                <div class="jackmail_header_buttons">
    1313                    <div jackmail-search></div>
    14                     <div class="jackmail_campaign_save" jackmail-dropdown-button
    15                         button-value="<?php esc_attr_e( 'Save', 'jackmail-newsletters' ) ?>"
    16                         titles-clicks-array="t.save_choice_select_title_template"
    17                         titles-clicks-array-event="t.save_template_or_create_campaign( key )">
    18                     </div>
     14                    <div class="jackmail_campaign_save" jackmail-dropdown-button
     15                        button-value="<?php esc_attr_e( 'Save', 'jackmail-newsletters' ) ?>"
     16                        titles-clicks-array="t.save_choice_select_title_template"
     17                        titles-clicks-array-event="t.save_template_or_create_campaign( key )">
     18                    </div>
    1919                </div>
    2020            </div>
     
    2929                               type="button" value="<" title="<?php esc_attr_e( 'Go to templates list', 'jackmail-newsletters' ) ?>"/>
    3030                        <input ng-click="t.reset_emailbuilder_content()" class="jackmail_white_button"
    31                                type="button" value="<?php esc_attr_e( 'Reset content', 'jackmail-newsletters' ) ?>"/>
     31                               type="button" value="<?php esc_attr_e( 'Reset content', 'jackmail-newsletters' ) ?>"/>
    3232                    </div>
    3333                </div>
     
    4242                    <p>
    4343                        <input ng-model="t.template.name" ng-enter="t.hide_name_popup()" ng-echap="t.hide_name_popup()"
    44                               class="jackmail_name_popup" type="text"/>
     44                               class="jackmail_name_popup" type="text"/>
    4545                    </p>
    4646                    <p>
    4747                        <span ng-click="t.hide_name_popup()" class="jackmail_confirm_icon dashicons dashicons-yes"
    48                               title="<?php esc_attr_e( 'OK', 'jackmail-newsletters' ) ?>">
     48                              title="<?php esc_attr_e( 'OK', 'jackmail-newsletters' ) ?>">
    4949                        </span>
    5050                        <span ng-click="t.hide_name_popup()" class="jackmail_confirm_icon dashicons dashicons-no-alt"
    51                               title="<?php esc_attr_e( 'Cancel', 'jackmail-newsletters' ) ?>">
     51                              title="<?php esc_attr_e( 'Cancel', 'jackmail-newsletters' ) ?>">
    5252                        </span>
    5353                    </p>
  • jackmail-newsletters/trunk/html/widget_back.php

    r2115987 r2605428  
    1111$lists_details                  = $params['lists_details'];
    1212$js_lists_details               = $params['js_lists_details'];
    13 $id                             = $params['id'];
    1413$id_list                        = $params['id_list'];
    1514$double_optin_scenario_link     = $params['double_optin_scenario_link'];
    1615$emailbuilder_installed         = $params['emailbuilder_installed'];
     16$field_id = $this->get_field_id( '' );
     17$fields_array = json_decode( $fields );
    1718?>
    18 <div id="jackmail_widget_content_<?php esc_attr_e( $id ) ?>">
     19<div>
    1920    <p>
    20         <label for="<?php echo $this->get_field_id( 'title' ) ?>_<?php esc_attr_e( $id ) ?>">
     21        <label for="<?php echo $this->get_field_id( 'title' ) ?>">
    2122            <?php _e( 'Title:', 'jackmail-newsletters' ) ?>
    2223        </label>
    23         <input autocomplete="off" id="<?php echo $this->get_field_id( 'title' ) ?>_<?php esc_attr_e( $id ) ?>"
    24                class="widefat" name="<?php echo $this->get_field_name( 'title' ) ?>"
    25                type="text" value="<?php esc_attr_e( $title ) ?>"/>
     24        <input autocomplete="off"
     25               id="<?php echo $this->get_field_id( 'title' ) ?>"
     26               name="<?php echo $this->get_field_name( 'title' ) ?>"
     27               class="widefat"
     28               type="text"
     29               value="<?php esc_attr_e( $title ) ?>"/>
    2630    </p>
    2731    <p>
    28         <label for="jackmail_widget_list_<?php echo $id ?>"><?php _e( 'List:', 'jackmail-newsletters' ) ?></label>
    29         <select autocomplete="off" class="widefat" id="jackmail_widget_list_<?php echo $id ?>" name="<?php echo $this->get_field_name( 'id_list' ) ?>"
    30                 onkeyup="jackmail_widget_select_list( '<?php esc_attr_e( $id ) ?>', false, '<?php esc_attr_e( $fields ) ?>', jackmail_lists_details )"
    31                 onchange="jackmail_widget_select_list( '<?php esc_attr_e( $id ) ?>', false, '<?php esc_attr_e( $fields ) ?>', jackmail_lists_details )">
     32        <label for="<?php echo $this->get_field_id( 'id_list' ) ?>"><?php _e( 'List:', 'jackmail-newsletters' ) ?></label>
     33        <select autocomplete="off"
     34                class="widefat"
     35                id="<?php echo $this->get_field_id( 'id_list' ) ?>"
     36                name="<?php echo $this->get_field_name( 'id_list' ) ?>"
     37                onkeyup="jackmail_widget_select_list( '<?php esc_attr_e( $field_id ) ?>' )"
     38                onchange="jackmail_widget_select_list( '<?php esc_attr_e( $field_id ) ?>' )">
    3239            <option value=""><?php _e( 'Select a list', 'jackmail-newsletters' ) ?></option>
    3340            <?php
    3441            foreach ( $lists as $list ) { ?>
    35                 <option value="<?php esc_attr_e( $list->id ) ?>"><?php echo htmlentities( $list->name ) ?></option>
     42            <option value="<?php esc_attr_e( $list->id ) ?>"<?php if ( $id_list === $list->id ) { ?> selected="selected"<?php } ?>>
     43                <?php echo htmlentities( $list->name ) ?>
     44            </option>
    3645            <?php } ?>
    3746        </select>
    3847    </p>
    39     <p id="jackmail_widget_fields_<?php echo $id ?>_container">
    40         <input autocomplete="off" type="hidden" id="jackmail_widget_fields_<?php esc_attr_e( $id ) ?>"
    41                name="<?php echo $this->get_field_name( 'fields' ) ?>"/>
     48    <p id="<?php echo $this->get_field_id( 'fields_container' ) ?>">
     49        <input autocomplete="off"
     50               type="hidden"
     51               id="<?php echo $this->get_field_id( 'fields' ) ?>"
     52               name="<?php echo $this->get_field_name( 'fields' ) ?>"
     53               value="<?php esc_attr_e( $fields ) ?>"/>
    4254        <label><?php _e( 'Fields:', 'jackmail-newsletters' ) ?></label>
    4355        <br/>
     
    4557        foreach ( $lists_details as $list_detail ) {
    4658        ?>
    47         <span id="jackmail_widget_field_<?php esc_attr_e( $list_detail['id'] ) ?>_<?php esc_attr_e( $id ) ?>_container">
     59        <span id="<?php echo $this->get_field_id( 'list_' . $list_detail['id'] . '_fields' ) ?>"
     60              class="<?php echo $this->get_field_id( 'lists_fields' ) ?>"
     61              style="display:<?php if ( $id_list === $list_detail['id'] ) { ?>block<?php } else { ?>none<?php } ?>">
    4862            <?php
    4963            $all_fields = $list_detail['all_fields'];
    5064            foreach ( $all_fields as $key => $field ) {
    51                 $id_html = $list_detail['id'] . '_' . ( $key + 1 ) . '_' . $id;
     65                $i = $key + 1;
    5266            ?>
    53             <span id="jackmail_widget_field_<?php esc_attr_e( $id_html ) ?>_container">
    54                 <input autocomplete="off" type="checkbox" id="jackmail_widget_field_<?php esc_attr_e( $id_html ) ?>_checkbox"
    55                        onchange="jackmail_widget_select_list_field( '<?php esc_attr_e( $id ) ?>', <?php echo( $key + 1 ) ?>, jackmail_lists_details )"/>
    56                 <label id="jackmail_widget_field_<?php esc_attr_e( $id_html ) ?>" for="jackmail_widget_field_<?php esc_attr_e( $id_html ) ?>_checkbox">
     67            <span>
     68                <input autocomplete="off"<?php if ( $id_list === $list_detail['id'] && in_array( $i, $fields_array ) ) { ?> checked="checked"<?php } ?>
     69                       type="checkbox"
     70                       value="<?php esc_attr_e( $i ) ?>"
     71                       id="<?php echo $this->get_field_id( 'list_' . $list_detail['id'] . '_field_' . $i . '_checkbox' ) ?>"
     72                       class="<?php echo $this->get_field_id( 'list_' . $list_detail['id'] . '_field' ) ?> <?php echo $this->get_field_id( 'list_field' ) ?>"
     73                       onchange="jackmail_widget_select_list_field( '<?php esc_attr_e( $field_id ) ?>' )"/>
     74                <label for="<?php echo $this->get_field_id( 'list_' . $list_detail['id'] . '_field_' . $i . '_checkbox' ) ?>">
    5775                    <?php echo htmlentities( ucfirst( mb_strtolower( $field ) ) ) ?>
    5876                </label>
     
    6381        <?php } ?>
    6482    </p>
    65     <p>
    66         <?php if ( $emailbuilder_installed ) { ?>
     83    <?php if ( $emailbuilder_installed ) { ?>
     84    <p id="<?php echo $this->get_field_id( 'jackmail_emailbuilder_installed' ) ?>">
    6785        <span style="margin-bottom:5px;display:block">
    68             <input type="checkbox" autocomplete="off"
    69                    onclick="jackmail_widget_select_double_optin( '<?php esc_attr_e( $id ) ?>' )"
    70                    id="jackmail_double_optin_<?php esc_attr_e( $id ) ?>"
    71                    name="<?php echo $this->get_field_name( 'double_optin' ) ?>"/>
    72             <label for="jackmail_double_optin_<?php esc_attr_e( $id ) ?>">
     86            <input autocomplete="off"<?php if ( $double_optin ) { ?> checked="checked"<?php } ?>
     87                   type="checkbox"
     88                   onclick="jackmail_widget_select_double_optin( '<?php esc_attr_e( $field_id ) ?>' )"
     89                   id="<?php echo $this->get_field_id( 'double_optin' ) ?>"
     90                   name="<?php echo $this->get_field_name( 'double_optin' ) ?>"/>
     91            <label for="<?php echo $this->get_field_id( 'double_optin' ) ?>">
    7392                <?php _e( 'Double optin', 'jackmail-newsletters' ) ?>
    7493            </label>
    7594        </span>
    76         <span id="jackmail_double_optin_configuration_block_<?php esc_attr_e( $id ) ?>">
     95        <span id="<?php echo $this->get_field_id( 'double_optin_configuration' ) ?>"
     96              style="display:<?php if ( $double_optin ) { ?>block<?php } else { ?>none<?php } ?>">
    7797            <span style="margin-bottom:5px;display:block">
    7898                <a href="<?php echo $double_optin_scenario_link ?>">
     
    81101            </span>
    82102            <select style="margin-bottom:5px;display:block"
    83                     autocomplete="off" class="widefat" id="jackmail_widget_confirmation_type_<?php esc_attr_e( $id ) ?>"
    84                     name="<?php echo $this->get_field_name( 'double_optin_confirmation_type' ) ?>"
    85                     onkeyup="jackmail_widget_select_confirmation_type( '<?php esc_attr_e( $id ) ?>' )"
    86                     onchange="jackmail_widget_select_confirmation_type( '<?php esc_attr_e( $id ) ?>' )">
    87                 <option value="default"><?php _e( 'Default confirmation message', 'jackmail-newsletters' ) ?></option>
    88                 <option value="url"><?php _e( 'Customized Url', 'jackmail-newsletters' ) ?></option>
     103                    autocomplete="off"
     104                    class="widefat"
     105                    id="<?php echo $this->get_field_id( 'double_optin_confirmation_type' ) ?>"
     106                    name="<?php echo $this->get_field_name( 'double_optin_confirmation_type' ) ?>"
     107                    onkeyup="jackmail_widget_select_confirmation_type( '<?php esc_attr_e( $field_id ) ?>' )"
     108                    onchange="jackmail_widget_select_confirmation_type( '<?php esc_attr_e( $field_id ) ?>' )">
     109                <option value="default">
     110                    <?php _e( 'Default confirmation message', 'jackmail-newsletters' ) ?>
     111                </option>
     112                <option value="url"<?php if ( $double_optin_confirmation_type === 'url' ) { ?> selected="selected"<?php } ?>>
     113                    <?php _e( 'Customized Url', 'jackmail-newsletters' ) ?>
     114                </option>
    89115            </select>
    90             <input style="margin-bottom:5px;display:block"
    91                    autocomplete="off" id="jackmail_double_optin_confirmation_url_<?php esc_attr_e( $id ) ?>"
    92                    class="widefat" name="<?php echo $this->get_field_name( 'double_optin_confirmation_url' ) ?>"
    93                    placeholder="Url"
    94                    type="text" value="<?php esc_attr_e( $double_optin_confirmation_url ) ?>"/>
     116            <input style="margin-bottom:5px;display:<?php if ( $double_optin_confirmation_type === 'url' ) { ?>block<?php } else { ?>none<?php } ?>"
     117                   autocomplete="off"
     118                   id="<?php echo $this->get_field_id( 'double_optin_confirmation_url' ) ?>"
     119                   name="<?php echo $this->get_field_name( 'double_optin_confirmation_url' ) ?>"
     120                   class="widefat"
     121                   placeholder="Url"
     122                   type="text"
     123                   value="<?php esc_attr_e( $double_optin_confirmation_url ) ?>"/>
    95124        </span>
    96         <?php } else { ?>
     125    </p>
     126    <?php } else { ?>
     127    <p>
    97128        <span><?php _e( 'Double optin:', 'jackmail-newsletters' ) ?></span>
    98129        <br/>
     
    101132            <a href="admin.php?page=jackmail_settings#/settings">"<?php _e( 'Settings', 'jackmail-newsletters' ) ?>"</a>.
    102133        </span>
    103         <?php } ?>
    104134    </p>
     135    <?php } ?>
    105136    <p>
    106137        <span style="margin-bottom:5px;display:block">
    107             <input type="checkbox" autocomplete="off"
    108                    onclick="jackmail_widget_select_gdpr( '<?php esc_attr_e( $id ) ?>' )"
    109                    id="jackmail_gdpr_<?php esc_attr_e( $id ) ?>"
    110                    name="<?php echo $this->get_field_name( 'gdpr' ) ?>"/>
    111             <label for="jackmail_gdpr_<?php esc_attr_e( $id ) ?>">
     138            <input autocomplete="off"<?php if ( $gdpr ) { ?> checked="checked"<?php } ?>
     139                   type="checkbox"
     140                   onclick="jackmail_widget_select_gdpr( '<?php esc_attr_e( $field_id ) ?>' )"
     141                   id="<?php echo $this->get_field_id( 'gdpr' ) ?>"
     142                   name="<?php echo $this->get_field_name( 'gdpr' ) ?>"/>
     143            <label for="<?php echo $this->get_field_id( 'gdpr' ) ?>">
    112144                <?php _e( 'GDPR mention', 'jackmail-newsletters' ) ?>
    113145            </label>
    114146        </span>
    115         <textarea id="jackmail_gdpr_configuration_block_<?php esc_attr_e( $id ) ?>"
    116                   name="<?php echo $this->get_field_name( 'gdpr_content' ) ?>"
    117                   style="width:100%;"><?php echo htmlentities( $gdpr_content ) ?></textarea>
     147        <textarea id="<?php echo $this->get_field_id( 'gdpr_content' ) ?>"
     148                  name="<?php echo $this->get_field_name( 'gdpr_content' ) ?>"
     149                  style="width:100%;display:<?php if ( $gdpr ) { ?>block<?php } else { ?>none<?php } ?>"
     150                  ><?php echo htmlentities( $gdpr_content ) ?></textarea>
    118151    </p>
    119     <script>
    120         var jackmail_lists_details = <?php echo $js_lists_details ?>;
    121         jackmail_widget_set_data(
    122             '<?php esc_attr_e( $id ) ?>',
    123             '<?php esc_attr_e( $fields ) ?>',
    124             '<?php esc_attr_e( $id_list ) ?>',
    125             jackmail_lists_details,
    126             '<?php esc_attr_e( $double_optin ) ?>',
    127             '<?php esc_attr_e( $double_optin_confirmation_type ) ?>',
    128             '<?php esc_attr_e( $gdpr ) ?>'
    129         );
    130     </script>
    131152</div>
    132153<?php } ?>
  • jackmail-newsletters/trunk/html/widget_front.php

    r1878945 r2605428  
    99$after_widget                   = $params['after_widget'];
    1010$fields                         = $params['fields'];
    11 $id                             = $params['id'];
    1211$list_fields                    = $params['list_fields'];
    1312$double_optin                   = $params['double_optin'];
     
    1918$confirm_email                  = $params['confirm_data']['email'];
    2019$confirm_fields                 = $params['confirm_data']['fields'];
     20$field_id = $this->get_field_id( '' );
     21$nonce_submit = wp_create_nonce( $action_submit . get_option( 'jackmail_front_nonce' ) );
     22$nonce_confirm = wp_create_nonce( $action_confirm . get_option( 'jackmail_front_nonce' ) );
     23$display_gdpr = ( $gdpr === '1' && $gdpr_content !== '' );
     24$display_double_optin_confirm = ( $confirm_id_list !== '' && $confirm_email !== '' && $confirm_fields !== '' );
    2125echo $before_widget;
    2226echo $title;
    2327?>
    24 <p id="jackmail_widget_confirmation_<?php esc_attr_e( $id ) ?>"></p>
     28<p id="<?php echo $this->get_field_id( 'confirmation' ) ?>"></p>
    2529<p>
    26     <label for="jackmail_widget_email_<?php esc_attr_e( $id ) ?>"><?php _e( 'Email', 'jackmail-newsletters' ) ?></label>
    27     <input id="jackmail_widget_email_<?php esc_attr_e( $id ) ?>" name="jackmail_widget_email" type="text" autocomplete="off"/>
     30    <label for="<?php echo $this->get_field_id( 'email' ) ?>">
     31        <?php _e( 'Email', 'jackmail-newsletters' ) ?>
     32    </label>
     33    <input id="<?php echo $this->get_field_id( 'email' ) ?>"
     34           name="<?php echo $this->get_field_name( 'email' ) ?>"
     35           type="text"
     36           autocomplete="off"/>
    2837</p>
    2938<?php
     
    3342    ?>
    3443<p>
    35     <label for="jackmail_widget_field<?php echo $i ?>_<?php esc_attr_e( $id ) ?>">
     44    <label for="<?php echo $this->get_field_id( 'field' ) . $i ?>">
    3645        <?php echo htmlentities( ucfirst( mb_strtolower( $field ) ) ) ?>
    3746    </label>
    38     <input id="jackmail_widget_field<?php echo $i ?>_<?php esc_attr_e( $id ) ?>"
    39            name="jackmail_widget_field<?php echo $i ?>"
    40            type="text" autocomplete="off"/>
     47    <input id="<?php echo $this->get_field_id( 'name_field' ) . $i ?>>"
     48           class="<?php echo $this->get_field_id( 'name_field' ) ?>"
     49           type="hidden"
     50           value="<?php esc_attr_e( $field ) ?>"/>
     51    <input id="<?php echo $this->get_field_id( 'field' ) . $i ?>"
     52           class="<?php echo $this->get_field_id( 'field' ) ?>"
     53           name="<?php echo $this->get_field_name( 'field' ) . $i ?>"
     54           type="text"
     55           autocomplete="off"/>
    4156</p>
    4257    <?php
     
    4560?>
    4661<?php
    47 if ( $gdpr === '1' && $gdpr_content !== '' ) {
     62if ( $display_gdpr ) {
    4863?>
    4964<p><?php echo $gdpr_content ?></p>
     
    5267?>
    5368<p>
    54     <input id="jackmail_widget_submit_<?php esc_attr_e( $id ) ?>"
    55            onclick="submit_jackmail_widget_form_<?php esc_attr_e( $id ) ?>()"
    56            type="button" value="<?php esc_attr_e( 'OK', 'jackmail-newsletters' ) ?>"/>
     69    <input id="<?php echo $this->get_field_id( 'submit' ) ?>"
     70           onclick="
     71           event.preventDefault();
     72           submit_jackmail_widget_form(
     73               '<?php esc_attr_e( $field_id ) ?>',
     74               '<?php esc_attr_e( $url ) ?>',
     75               '<?php esc_attr_e( $action_submit ) ?>',
     76               '<?php esc_attr_e( $nonce_submit ) ?>',
     77               '<?php esc_attr_e( $widget_id ) ?>'
     78           )"
     79           type="submit"
     80           value="<?php esc_attr_e( 'OK', 'jackmail-newsletters' ) ?>"
     81    />
    5782</p>
    58 <div id="jackmail_widget_container_form_<?php esc_attr_e( $id ) ?>"></div>
    59 <script type="text/javascript">
    60     function submit_jackmail_widget_form_<?php esc_attr_e( $id ) ?>() {
    61         var fields = [];
    62         <?php
    63         foreach ( $list_fields as $key => $field ) {
    64             $i = $key + 1;
    65             if ( in_array( $i, $fields ) ) {
    66         ?>
    67         fields.push( {
    68             'field': '<?php esc_attr_e( $field ) ?>',
    69             'value': document.getElementById( 'jackmail_widget_field<?php echo $i ?>_<?php esc_attr_e( $id ) ?>' ).value
    70         } );
    71         <?php
    72             }
    73         }
    74         ?>
    75         var data = {
    76             action: '<?php esc_attr_e( $action_submit ) ?>',
    77             nonce: '<?php esc_attr_e( wp_create_nonce( $action_submit . get_option( 'jackmail_front_nonce' ) ) ) ?>',
    78             jackmail_widget_id: '<?php esc_attr_e( $widget_id ) ?>',
    79             jackmail_widget_email: document.getElementById( 'jackmail_widget_email_<?php esc_attr_e( $id ) ?>' ).value,
    80             jackmail_widget_fields: JSON.stringify( fields )
    81         };
    82         document.getElementById( 'jackmail_widget_submit_<?php esc_attr_e( $id ) ?>' ).disabled = true;
    83         query_jackmail_widget_form_<?php esc_attr_e( $id ) ?>(
    84             '<?php esc_attr_e( $url ) ?>',
    85             data,
    86             function( data ) {
    87                 data = JSON.parse( data );
    88                 document.getElementById( 'jackmail_widget_email_<?php esc_attr_e( $id ) ?>' ).value = '';
    89                 <?php
    90                 foreach ( $list_fields as $key => $field ) {
    91                     $i = $key + 1;
    92                     if ( in_array( $i, $fields ) ) {
    93                 ?>
    94                 document.getElementById( 'jackmail_widget_field<?php echo $i ?>_<?php esc_attr_e( $id ) ?>' ).value = '';
    95                 <?php
    96                     }
    97                 }
    98                 ?>
    99                 document.getElementById( 'jackmail_widget_confirmation_<?php esc_attr_e( $id ) ?>' ).innerHTML = data.message;
    100                 alert( data.message );
    101                 document.getElementById( 'jackmail_widget_submit_<?php esc_attr_e( $id ) ?>' ).disabled = false;
    102             }
    103         );
    104     }
    105     function query_jackmail_widget_form_<?php esc_attr_e( $id ) ?>( url, data, success ) {
    106         var params = Object.keys( data ).map(
    107             function( k ) {
    108                 return encodeURIComponent( k ) + '=' + encodeURIComponent( data[ k ] );
    109             }
    110         ).join( '&' );
    111         var xhr = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject( 'Microsoft.XMLHTTP' );
    112         xhr.open( 'POST', url );
    113         xhr.onreadystatechange = function() {
    114             if ( xhr.readyState > 3 && xhr.status === 200 ) {
    115                 success( xhr.responseText );
    116             }
    117         };
    118         xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );
    119         xhr.send( params );
    120         return xhr;
    121     }
    122     <?php if ( $confirm_id_list !== '' && $confirm_email !== '' && $confirm_fields !== '' ) { ?>
    123     function confirm_jackmail_widget_form_<?php esc_attr_e( $id ) ?>() {
    124         var jackmail_widget_fields = <?php echo $confirm_fields ?>;
    125         var data = {
    126             action: '<?php esc_attr_e( $action_confirm ) ?>',
    127             nonce: '<?php esc_attr_e( wp_create_nonce( $action_confirm . get_option( 'jackmail_front_nonce' ) ) ) ?>',
    128             jackmail_widget_id_list: '<?php esc_attr_e( $confirm_id_list ) ?>',
    129             jackmail_widget_email: '<?php esc_attr_e( $confirm_email ) ?>',
    130             jackmail_widget_fields: JSON.stringify( jackmail_widget_fields )
    131         };
    132         query_jackmail_widget_form_<?php esc_attr_e( $id ) ?>(
    133             '<?php esc_attr_e( $url ) ?>',
    134             data,
    135             function( data ) {
    136                 data = JSON.parse( data );
    137                 document.getElementById( 'jackmail_widget_confirmation_<?php esc_attr_e( $id ) ?>' ).innerHTML = data.message;
    138                 <?php if ( $double_optin_confirmation_type === 'url' && $double_optin_confirmation_url !== '' ) { ?>
    139                 if ( data.success === false ) {
    140                     alert( data.message );
    141                 } else {
    142                     window.location.href = '<?php esc_attr_e( $double_optin_confirmation_url ) ?>';
    143                 }
    144                 <?php } else { ?>
    145                 alert( data.message );
    146                 <?php } ?>
    147             }
    148         );
    149     }
    150     setTimeout( function() {
    151         confirm_jackmail_widget_form_<?php esc_attr_e( $id ) ?>();
    152     } );
    153     <?php } ?>
    154 </script>
     83<?php if ( $display_double_optin_confirm ) { ?>
     84<span id="jackmail_widget_double_optin_confirm_values">
     85    <input id="jackmail_widget_double_optin_confirm_id"
     86           type="hidden"
     87           value="<?php esc_attr_e( $field_id ) ?>"/>
     88    <input id="jackmail_widget_double_optin_confirm_fields"
     89           type="hidden"
     90           value="<?php esc_attr_e( $confirm_fields ) ?>"/>
     91    <input id="jackmail_widget_double_optin_confirm_action_confirm"
     92           type="hidden"
     93           value="<?php esc_attr_e( $action_confirm ) ?>"/>
     94    <input id="jackmail_widget_double_optin_confirm_nonce"
     95           type="hidden"
     96           value="<?php esc_attr_e( $nonce_confirm ) ?>"/>
     97    <input id="jackmail_widget_double_optin_confirm_id_list"
     98           type="hidden"
     99           value="<?php esc_attr_e( $confirm_id_list ) ?>"/>
     100    <input id="jackmail_widget_double_optin_confirm_email"
     101           type="hidden"
     102           value="<?php esc_attr_e( $confirm_email ) ?>"/>
     103    <input id="jackmail_widget_double_optin_confirm_url"
     104           type="hidden"
     105           value="<?php esc_attr_e( $url ) ?>"/>
     106    <input id="jackmail_widget_double_optin_confirm_confirmation_type"
     107           type="hidden"
     108           value="<?php esc_attr_e( $double_optin_confirmation_type ) ?>"/>
     109    <input id="jackmail_widget_double_optin_confirm_confirmation_url"
     110           type="hidden"
     111           value="<?php esc_attr_e( $double_optin_confirmation_url ) ?>"/>
     112</span>
     113<?php } ?>
    155114<?php
    156115echo $after_widget;
  • jackmail-newsletters/trunk/jackmail-newsletters.php

    r2577695 r2605428  
    44Plugin URI: https://www.jackmail.com
    55Description: Create and send responsive newsletter with a professional routing platform and a lot of features: automated emails and newsletters, statistics, email & Live Support etc.
    6 Version: 1.2.18
     6Version: 1.2.19
    77Author: Jackmail & Sarbacane
    88Author URI: https://www.jackmail.com
  • jackmail-newsletters/trunk/js/widget.js

    r1874492 r2605428  
    11'use strict';
    22
    3 function jackmail_widget_set_data( id, default_fields, id_list, lists, double_optin, double_optin_confirmation_type, gdpr ) {
    4     var content = document.getElementById( 'jackmail_widget_content_' + id ).innerHTML;
    5     var random = new Date().getTime() + '' + Math.floor( ( Math.random() * 9999999 ) + 1000000 );
    6     content = content.replace( new RegExp( id, 'g' ), random );
    7     content = content.replace( 'var jackmail_lists_details', '// var jackmail_lists_details' );
    8     document.getElementById( 'jackmail_widget_content_' + id ).innerHTML = content;
    9     document.getElementById( 'jackmail_widget_content_' + id ).setAttribute( 'id', 'jackmail_widget_content_' + random );
    10     id = random;
    11     document.getElementById( 'jackmail_widget_list_' + id ).value = id_list;
    12     jackmail_widget_select_list( id, default_fields, id_list, lists );
    13     if ( double_optin === '1' ) {
    14         document.getElementById( 'jackmail_double_optin_' + id ).checked = true;
    15         document.getElementById( 'jackmail_widget_confirmation_type_' + id ).value = double_optin_confirmation_type;
     3function jackmail_widget_get_id_list_selected( id ) {
     4    return document.getElementById( id + 'id_list' ).options[ document.getElementById( id + 'id_list' ).selectedIndex ].value;
     5}
     6
     7function jackmail_widget_select_list( id ) {
     8    var id_list_selected = jackmail_widget_get_id_list_selected( id );
     9    var new_selected_fields = [];
     10    var i;
     11
     12    var lists_fields = document.getElementsByClassName( id + 'lists_fields' );
     13    var nb_lists_fields = lists_fields.length;
     14    for ( i = 0 ; i < nb_lists_fields ; i++ ) {
     15        lists_fields[ i ].style.display = 'none';
     16    }
     17
     18    var all_fields = document.getElementsByClassName( id + 'list_field' );
     19    var nb_fields = all_fields.length;
     20    for ( i = 0 ; i < nb_fields ; i++ ) {
     21        all_fields[ i ].checked = false;
     22    }
     23
     24    if ( id_list_selected > 0 ) {
     25        var all_lists_fields = document.getElementsByClassName( id + 'list_' + id_list_selected + '_field' );
     26        var nb_all_lists_fields = all_lists_fields.length;
     27        for ( i = 0; i < nb_all_lists_fields; i++ ) {
     28            all_lists_fields[ i ].checked = true;
     29            new_selected_fields.push( parseInt( all_lists_fields [ i ].value ) );
     30        }
     31        document.getElementById( id + 'list_' + id_list_selected + '_fields' ).style.display = 'block';
     32        document.getElementById( id + 'fields_container' ).style.display = 'block';
    1633    } else {
    17         document.getElementById( 'jackmail_double_optin_configuration_block_' + id ).style.display = 'none';
     34        document.getElementById( id + 'fields_container' ).style.display = 'none';
    1835    }
    19     jackmail_widget_select_confirmation_type( id );
    20     if ( gdpr === '1' ) {
    21         document.getElementById( 'jackmail_gdpr_' + id ).checked = true;
    22     } else {
    23         document.getElementById( 'jackmail_gdpr_configuration_block_' + id ).style.display = 'none';
     36
     37    new_selected_fields.sort();
     38    document.getElementById( id + 'fields' ).value = JSON.stringify( new_selected_fields );
     39}
     40
     41function jackmail_widget_select_list_field( id ) {
     42    var id_list_selected = jackmail_widget_get_id_list_selected( id );
     43    var new_selected_fields = [];
     44    var i;
     45
     46    var all_lists_fields = document.getElementsByClassName( id + 'list_' + id_list_selected + '_field' );
     47    var nb_all_lists_fields = all_lists_fields.length;
     48    for ( i = 0; i < nb_all_lists_fields; i++ ) {
     49        if ( all_lists_fields[ i ].checked === true ) {
     50            new_selected_fields.push( parseInt( all_lists_fields[ i ].value ) );
     51        }
     52    }
     53    new_selected_fields.sort();
     54    document.getElementById( id + 'fields' ).value = JSON.stringify( new_selected_fields );
     55}
     56
     57function jackmail_widget_select_confirmation_type( id ) {
     58    if ( jackmail_emailbuilder_installed( id ) ) {
     59        var style_display = 'none';
     60        if ( document.getElementById( id + 'double_optin_confirmation_type' ).value === 'url' ) {
     61            style_display = 'block';
     62        }
     63        document.getElementById( id + 'double_optin_confirmation_url' ).style.display = style_display;
    2464    }
    2565}
    2666
    27 function jackmail_widget_select_list( id, default_fields, id_list, lists ) {
    28     var i;
    29     var nb_lists = lists.length;
    30     var default_fields_array = JSON.parse( default_fields );
    31     var selected_id = document.getElementById( 'jackmail_widget_list_' + id ).value;
    32     var current_fields = document.getElementById( 'jackmail_widget_fields_' + id ).value;
    33     var fields = [];
    34     for ( i = 0; i < nb_lists; i++ ) {
    35         var list_id = lists[ i ].id;
    36         var all_fields = lists[ i ].all_fields;
    37         document.getElementById( 'jackmail_widget_field_' + list_id + '_' + id + '_container' ).style.display = 'none';
    38         var j;
    39         var nb_fields = all_fields.length;
    40         for ( j = 0; j < nb_fields; j++ ) {
    41             var html_id = list_id + '_' + ( j + 1 ) + '_' + id;
    42             var checked = false;
    43             if ( ( list_id !== id_list ) || ( list_id === id_list && default_fields_array.indexOf( j + 1 ) !== -1 ) ) {
    44                 checked = true;
    45                 if ( list_id === selected_id ) {
    46                     fields.push( j + 1 );
    47                 }
    48             }
    49             document.getElementById( 'jackmail_widget_field_' + html_id + '_checkbox' ).checked = checked;
     67function jackmail_widget_select_double_optin( id ) {
     68    if ( jackmail_emailbuilder_installed( id ) ) {
     69        var style_display = 'none';
     70        if ( document.getElementById( id + 'double_optin_configuration' ).style.display === 'none') {
     71            style_display = 'block';
    5072        }
     73        document.getElementById( id + 'double_optin_configuration' ).style.display = style_display;
    5174    }
    52     fields = JSON.stringify( fields );
    53     if ( fields !== current_fields ) {
    54         document.getElementById( 'jackmail_widget_fields_' + id ).value = fields;
    55     }
    56     if ( selected_id > 0 ) {
    57         var value = document.getElementById( 'jackmail_widget_field_' + selected_id + '_' + id + '_container' ).innerHTML;
    58         var display = 'block';
    59         if ( value.replace( /^\s+/g, '' ).replace( /\s+$/g, '' ) === '' ) {
    60             display = 'none';
    61         }
    62         document.getElementById( 'jackmail_widget_field_' + selected_id + '_' + id + '_container' ).style.display = display;
    63         document.getElementById( 'jackmail_widget_fields_' + id + '_container' ).style.display = display;
    64     }
    65     else {
    66         document.getElementById( 'jackmail_widget_fields_' + id + '_container' ).style.display = 'none';
    67     }
    68 }
    69 
    70 function jackmail_widget_select_list_field( id, field_id ) {
    71     var selected_fields = document.getElementById( 'jackmail_widget_fields_' + id ).value;
    72     if ( selected_fields !== '' ) {
    73         selected_fields = JSON.parse( selected_fields );
    74     }
    75     else {
    76         selected_fields = [];
    77     }
    78     var i;
    79     var nb_selected_fields = selected_fields.length;
    80     var new_selected_fields = [];
    81     var add_field = true;
    82     for ( i = 0; i < nb_selected_fields; i++ ) {
    83         if ( selected_fields[ i ] < field_id || selected_fields[ i ] > field_id ) {
    84             new_selected_fields.push( selected_fields[ i ] );
    85         }
    86         else {
    87             add_field = false;
    88         }
    89     }
    90     if ( add_field ) {
    91         new_selected_fields.push( field_id );
    92         new_selected_fields.sort();
    93     }
    94     document.getElementById( 'jackmail_widget_fields_' + id ).value = JSON.stringify( new_selected_fields );
    95 }
    96 
    97 function jackmail_widget_select_confirmation_type( id ) {
    98     var style_display = 'none';
    99     if ( document.getElementById( 'jackmail_widget_confirmation_type_' + id ).value === 'url' ) {
    100         style_display = 'block';
    101     }
    102     document.getElementById( 'jackmail_double_optin_confirmation_url_' + id ).style.display = style_display;
    103 }
    104 
    105 function jackmail_widget_select_double_optin( id ) {
    106     var style_display = 'none';
    107     if ( document.getElementById( 'jackmail_double_optin_configuration_block_' + id ).style.display === 'none' ) {
    108         style_display = 'block';
    109     }
    110     document.getElementById( 'jackmail_double_optin_configuration_block_' + id ).style.display = style_display;
    11175}
    11276
    11377function jackmail_widget_select_gdpr( id ) {
    11478    var style_display = 'none';
    115     if ( document.getElementById( 'jackmail_gdpr_configuration_block_' + id ).style.display === 'none' ) {
     79    if ( document.getElementById( id + 'gdpr_content' ).style.display === 'none' ) {
    11680        style_display = 'block';
    11781    }
    118     document.getElementById( 'jackmail_gdpr_configuration_block_' + id ).style.display = style_display;
     82    document.getElementById( id + 'gdpr_content' ).style.display = style_display;
    11983}
     84
     85function jackmail_emailbuilder_installed( id ) {
     86    if ( document.getElementById( id + 'jackmail_emailbuilder_installed' ) ) {
     87        return true;
     88    }
     89    return false;
     90}
  • jackmail-newsletters/trunk/readme.txt

    r2577695 r2605428  
    55Tested up to: 5.8
    66Requires PHP : 5.4
    7 Stable tag: 1.2.18
     7Stable tag: 1.2.19
    88License: GPLv2
    99
     
    166166== Changelog ==
    167167
     168= 1.2.19 =
     169* Widget compatibility for WordPress 5.8
     170
    168171= 1.2.18 =
    169172* Refused by moderation information
  • jackmail-newsletters/trunk/widget.php

    r2094328 r2605428  
    4141        $lists         = $this->get_lists();
    4242        $lists_details = array();
    43         foreach ( $lists as $key => $list ) {
     43        foreach ( $lists as $list ) {
    4444            $fields_explode  = $core->explode_fields( $list->fields );
    4545            $lists_details[] = array(
     
    4949        }
    5050        $params_configuration = $this->get_configuration( $instance );
     51        $double_optin_scenario_link = '';
     52        $double_optin_scenario_id = $core->get_widget_double_optin_scenario();
     53        if ( $double_optin_scenario_id !== false ) {
     54            $double_optin_scenario_link = 'admin.php?page=jackmail_scenario#/scenario/widget_double_optin/' . $double_optin_scenario_id . '/create';
     55        }
    5156        $params               = array(
    5257            'lists'                      => $lists,
    5358            'lists_details'              => $lists_details,
    5459            'js_lists_details'           => $this->get_json_js( $lists_details ),
    55             'id'                         => $core->get_current_timestamp_gmt() . mt_rand( 1000000, 9999999 ),
    56             'double_optin_scenario_link' => 'admin.php?page=jackmail_scenario#/scenario/widget_double_optin/' . $core->get_widget_double_optin_scenario() . '/create',
     60            'double_optin_scenario_link' => $double_optin_scenario_link,
    5761            'emailbuilder_installed'     => $core->emailbuilder_installed()
    5862        );
     
    6569        $update['id_list'] = isset( $instance['id_list'] ) ? $instance['id_list'] : '';
    6670        $update['title']   = isset( $instance['title'] ) ? $instance['title'] : '';
    67         $update['fields']  = isset( $instance['fields'] ) ? $instance['fields'] : '[]';
     71        $update['fields']  = isset( $instance['fields'] ) && $instance['fields'] !== '' ? $instance['fields'] : '[]';
    6872        return $update;
    6973    }
     
    9397            'id_list'                        => isset( $instance['id_list'] ) ? $instance['id_list'] : '',
    9498            'title'                          => isset( $instance['title'] ) ? $instance['title'] : '',
    95             'fields'                         => isset( $instance['fields'] ) ? $instance['fields'] : '[]',
     99            'fields'                         => isset( $instance['fields'] ) && $instance['fields'] !== '' ? $instance['fields'] : '[]',
    96100            'double_optin'                   => $double_optin,
    97101            'double_optin_confirmation_type' => $double_optin_confirmation_type,
     
    118122        if ( isset( $instance['id_list'], $instance['title'], $instance['fields'],
    119123            $instance['double_optin'], $instance['double_optin_confirmation_type'], $instance['double_optin_confirmation_url'] ) ) {
     124            if ( ! isset( $args['widget_id'] ) ) {
     125                $args['widget_id'] = 'jackmail_widget-0';
     126            }
    120127            if ( isset( $args['before_widget'], $args['before_title'], $args['after_title'], $args['after_widget'], $args['widget_id'] ) ) {
    121128                $id_list      = $instance['id_list'];
     
    164171                        'gdpr'                           => $instance['gdpr'],
    165172                        'gdpr_content'                   => strip_tags( $instance['gdpr_content'], '<b><a>' ),
    166                         'id'                             => $core->get_current_timestamp_gmt() . mt_rand( 1000000, 9999999 ),
    167173                        'list_fields'                    => $core->explode_fields( $list->fields ),
    168174                        'confirm_data'                   => $confirm_data
     
    190196        add_action( 'wp_ajax_nopriv_jackmail_front_widget_confirmed', array( $this, 'front_widget_confirmed_callback' ) );
    191197
    192         add_action( 'wp_footer', array( $this, 'front_widget_confirmation_script' ) );
     198        add_action( 'wp_footer', array( $this, 'front_widget_scripts' ) );
    193199
    194200    }
     
    314320    }
    315321
    316     public function front_widget_confirmation_script() {
     322    public function front_widget_scripts() {
     323        include plugin_dir_path( __FILE__ ) . 'html/widget_front_script.php';
    317324        if ( isset( $_GET['jackmail_widget_confirm'] ) ) {
    318325            $data = $this->core->request_text_data( $_GET['jackmail_widget_confirm'] );
     
    322329                ?>
    323330                <script>
    324                     setTimeout( function() {
     331                    setTimeout( function () {
    325332                        alert( '<?php esc_attr_e( 'Your subscription to our list has been confirmed [Test]', 'jackmail-newsletters' ) ?>' );
    326333                    } );
    327334                </script>
    328335                <?php
     336            } else if ( isset( $data['rand'] ) ) {
     337                include plugin_dir_path( __FILE__ ) . 'html/widget_front_script_double_optin.php';
    329338            }
    330339        }
Note: See TracChangeset for help on using the changeset viewer.