@@ -18,8 +18,8 @@ discard block |
||
| 18 | 18 | $this->file_name = $atts['file_name']; |
| 19 | 19 | $this->error_message = isset( $atts['error_message'] ) ? $atts['error_message'] : ''; |
| 20 | 20 | $this->uploads = wp_upload_dir(); |
| 21 | - $this->chmod_dir = defined('FS_CHMOD_DIR') ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | - $this->chmod_file = defined('FS_CHMOD_FILE') ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 21 | + $this->chmod_dir = defined( 'FS_CHMOD_DIR' ) ? FS_CHMOD_DIR : ( fileperms( ABSPATH ) & 0777 | 0755 ); |
|
| 22 | + $this->chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : ( fileperms( ABSPATH . 'index.php' ) & 0777 | 0644 ); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function create_file( $file_content ) { |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | private function get_ftp_creds( $type ) { |
| 86 | 86 | $credentials = get_option( 'ftp_credentials', array( 'hostname' => '', 'username' => '' ) ); |
| 87 | 87 | |
| 88 | - $credentials['hostname'] = defined('FTP_HOST') ? FTP_HOST : $credentials['hostname']; |
|
| 89 | - $credentials['username'] = defined('FTP_USER') ? FTP_USER : $credentials['username']; |
|
| 90 | - $credentials['password'] = defined('FTP_PASS') ? FTP_PASS : ''; |
|
| 88 | + $credentials['hostname'] = defined( 'FTP_HOST' ) ? FTP_HOST : $credentials['hostname']; |
|
| 89 | + $credentials['username'] = defined( 'FTP_USER' ) ? FTP_USER : $credentials['username']; |
|
| 90 | + $credentials['password'] = defined( 'FTP_PASS' ) ? FTP_PASS : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Check to see if we are setting the public/private keys for ssh |
| 93 | - $credentials['public_key'] = defined('FTP_PUBKEY') ? FTP_PUBKEY : ''; |
|
| 94 | - $credentials['private_key'] = defined('FTP_PRIKEY') ? FTP_PRIKEY : ''; |
|
| 93 | + $credentials['public_key'] = defined( 'FTP_PUBKEY' ) ? FTP_PUBKEY : ''; |
|
| 94 | + $credentials['private_key'] = defined( 'FTP_PRIKEY' ) ? FTP_PRIKEY : ''; |
|
| 95 | 95 | |
| 96 | 96 | // Sanitize the hostname, Some people might pass in odd-data: |
| 97 | 97 | $credentials['hostname'] = preg_replace( '|\w+://|', '', $credentials['hostname'] ); //Strip any schemes off |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | <a href="javascript:void(0)" class="show_field_custom_html frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="<?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
| 23 | 23 | </li> |
| 24 | 24 | <?php |
| 25 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 26 | - unset($skey, $sname); |
|
| 25 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 26 | + unset( $skey, $sname ); |
|
| 27 | 27 | } |
| 28 | 28 | ?> |
| 29 | 29 | </ul> |
@@ -36,18 +36,18 @@ discard block |
||
| 36 | 36 | 'form_key' => __( 'Form Key', 'formidable' ), 'deletelink' => __( 'Delete Entry Link', 'formidable' ), |
| 37 | 37 | ) as $skey => $sname ) { ?> |
| 38 | 38 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 39 | - <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 39 | + <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 40 | 40 | </li> |
| 41 | 41 | <?php |
| 42 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 42 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | foreach ( array( 'button_label' => __( 'Button Label', 'formidable' ), 'button_action' => __( 'Button Hook', 'formidable' ) ) as $skey => $sname ) { ?> |
| 46 | 46 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 47 | - <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 47 | + <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr( $skey ) ?>"><?php echo esc_html( $sname ); ?></a> |
|
| 48 | 48 | </li> |
| 49 | 49 | <?php |
| 50 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 50 | + $col = ( $col == 'one' ) ? 'two' : 'one'; |
|
| 51 | 51 | } ?> |
| 52 | 52 | </ul> |
| 53 | 53 | </div> |
@@ -1,53 +1,53 @@ |
||
| 1 | 1 | <div id="frm-html-tags" class="tabs-panel"> |
| 2 | 2 | <ul class="frm_code_list"> |
| 3 | 3 | <?php |
| 4 | - $col = 'one'; |
|
| 5 | - $entry_shortcodes = array( |
|
| 6 | - 'id' => __( 'Field ID', 'formidable' ), |
|
| 7 | - 'key' => __( 'Field Key', 'formidable' ), |
|
| 8 | - 'field_name' => __( 'Field Name', 'formidable' ), |
|
| 9 | - 'description' => __( 'Field Description', 'formidable' ), |
|
| 10 | - 'label_position' => __( 'Label Position', 'formidable' ), |
|
| 11 | - 'required_label' => __( 'Required Label', 'formidable' ), |
|
| 12 | - 'input' => __( 'Input Field', 'formidable' ), |
|
| 4 | + $col = 'one'; |
|
| 5 | + $entry_shortcodes = array( |
|
| 6 | + 'id' => __( 'Field ID', 'formidable' ), |
|
| 7 | + 'key' => __( 'Field Key', 'formidable' ), |
|
| 8 | + 'field_name' => __( 'Field Name', 'formidable' ), |
|
| 9 | + 'description' => __( 'Field Description', 'formidable' ), |
|
| 10 | + 'label_position' => __( 'Label Position', 'formidable' ), |
|
| 11 | + 'required_label' => __( 'Required Label', 'formidable' ), |
|
| 12 | + 'input' => __( 'Input Field', 'formidable' ), |
|
| 13 | 13 | 'input opt=1' => array( 'label' => __( 'Single Option', 'formidable' ), 'title' => __( 'Show a single radio or checkbox option by replacing 1 with the order of the option', 'formidable' ) ), |
| 14 | - 'input label=0' => __( 'Hide Option Label', 'formidable' ), |
|
| 14 | + 'input label=0' => __( 'Hide Option Label', 'formidable' ), |
|
| 15 | 15 | 'required_class' => array( 'label' => __( 'Required Class', 'formidable' ), 'title' => __( 'Add class name if field is required', 'formidable' ) ), |
| 16 | 16 | 'error_class' => array( 'label' => __( 'Error Class', 'formidable' ), 'title' => __( 'Add class name if field has an error on form submit', 'formidable' ) ), |
| 17 | - ); |
|
| 17 | + ); |
|
| 18 | 18 | |
| 19 | 19 | foreach ( $entry_shortcodes as $skey => $sname ) { |
| 20 | - ?> |
|
| 20 | + ?> |
|
| 21 | 21 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 22 | 22 | <a href="javascript:void(0)" class="show_field_custom_html frmbutton button frm_insert_code <?php echo is_array( $sname ) ? 'frm_help' : ''; ?>" data-code="<?php echo esc_attr( $skey ) ?>" <?php echo is_array( $sname ) ? 'title="' . esc_attr( $sname['title'] ) . '"' : ''; ?>><?php echo is_array( $sname ) ? $sname['label'] : $sname; ?></a> |
| 23 | 23 | </li> |
| 24 | 24 | <?php |
| 25 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 26 | - unset($skey, $sname); |
|
| 27 | - } |
|
| 28 | - ?> |
|
| 25 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
| 26 | + unset($skey, $sname); |
|
| 27 | + } |
|
| 28 | + ?> |
|
| 29 | 29 | </ul> |
| 30 | 30 | |
| 31 | 31 | <ul class="frm_code_list frm_clear"> |
| 32 | 32 | <?php |
| 33 | - $col = 'one'; |
|
| 33 | + $col = 'one'; |
|
| 34 | 34 | foreach ( array( |
| 35 | - 'form_name' => __( 'Form Name', 'formidable' ), 'form_description' => __( 'Form Description', 'formidable' ), |
|
| 36 | - 'form_key' => __( 'Form Key', 'formidable' ), 'deletelink' => __( 'Delete Entry Link', 'formidable' ), |
|
| 35 | + 'form_name' => __( 'Form Name', 'formidable' ), 'form_description' => __( 'Form Description', 'formidable' ), |
|
| 36 | + 'form_key' => __( 'Form Key', 'formidable' ), 'deletelink' => __( 'Delete Entry Link', 'formidable' ), |
|
| 37 | 37 | ) as $skey => $sname ) { ?> |
| 38 | 38 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 39 | 39 | <a href="javascript:void(0)" class="show_before_html show_after_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
| 40 | 40 | </li> |
| 41 | 41 | <?php |
| 42 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 43 | - } |
|
| 42 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - foreach ( array( 'button_label' => __( 'Button Label', 'formidable' ), 'button_action' => __( 'Button Hook', 'formidable' ) ) as $skey => $sname ) { ?> |
|
| 45 | + foreach ( array( 'button_label' => __( 'Button Label', 'formidable' ), 'button_action' => __( 'Button Hook', 'formidable' ) ) as $skey => $sname ) { ?> |
|
| 46 | 46 | <li class="frm_col_<?php echo esc_attr( $col ) ?>"> |
| 47 | 47 | <a href="javascript:void(0)" class="show_submit_html frmbutton button frm_insert_code" data-code="<?php echo esc_attr($skey) ?>"><?php echo esc_html( $sname ); ?></a> |
| 48 | 48 | </li> |
| 49 | 49 | <?php |
| 50 | - $col = ($col == 'one') ? 'two' : 'one'; |
|
| 51 | - } ?> |
|
| 50 | + $col = ($col == 'one') ? 'two' : 'one'; |
|
| 51 | + } ?> |
|
| 52 | 52 | </ul> |
| 53 | 53 | </div> |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_color') ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_color' ) ) ?>" id="frm_label_color" class="hex" value="<?php echo esc_attr( $style->post_content['label_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('weight') ) ?>" id="frm_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'weight' ) ) ?>" id="frm_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,45 +12,45 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 15 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('font_size') ) ?>" id="frm_font_size" value="<?php echo esc_attr($style->post_content['font_size']) ?>" size="3" /> |
|
| 15 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'font_size' ) ) ?>" id="frm_font_size" value="<?php echo esc_attr( $style->post_content['font_size'] ) ?>" size="3" /> |
|
| 16 | 16 | </div> |
| 17 | 17 | |
| 18 | 18 | <div class="field-group clearfix frm_clear"> |
| 19 | 19 | <label><?php _e( 'Position', 'formidable' ) ?></label> |
| 20 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('position') ) ?>" id="frm_position"> |
|
| 20 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'position' ) ) ?>" id="frm_position"> |
|
| 21 | 21 | <?php foreach ( array( 'none' => __( 'top', 'formidable' ), 'left' => __( 'left', 'formidable' ), 'right' => __( 'right', 'formidable' ), 'no_label' => __( 'none', 'formidable' ) ) as $pos => $pos_label ) { ?> |
| 22 | - <option value="<?php echo esc_attr( $pos ) ?>" <?php selected($style->post_content['position'], $pos) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 22 | + <option value="<?php echo esc_attr( $pos ) ?>" <?php selected( $style->post_content['position'], $pos ) ?>><?php echo esc_html( $pos_label ) ?></option> |
|
| 23 | 23 | <?php } ?> |
| 24 | 24 | </select> |
| 25 | 25 | </div> |
| 26 | 26 | |
| 27 | 27 | <div class="field-group clearfix"> |
| 28 | 28 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 29 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('align') ) ?>" id="frm_align"> |
|
| 30 | - <option value="left" <?php selected($style->post_content['align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | - <option value="right" <?php selected($style->post_content['align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 29 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'align' ) ) ?>" id="frm_align"> |
|
| 30 | + <option value="left" <?php selected( $style->post_content['align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 31 | + <option value="right" <?php selected( $style->post_content['align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 32 | 32 | </select> |
| 33 | 33 | </div> |
| 34 | 34 | |
| 35 | 35 | <div class="field-group clearfix"> |
| 36 | 36 | <label><?php _e( 'Width', 'formidable' ) ?></label> |
| 37 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('width') ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 37 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'width' ) ) ?>" id="frm_width" value="<?php echo esc_attr( $style->post_content['width'] ) ?>" /> |
|
| 38 | 38 | </div> |
| 39 | 39 | |
| 40 | 40 | <div class="field-group clearfix frm_clear"> |
| 41 | 41 | <label><?php _e( 'Padding', 'formidable' ) ?></label> |
| 42 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('label_padding') ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 42 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'label_padding' ) ) ?>" id="frm_label_padding" value="<?php echo esc_attr( $style->post_content['label_padding'] ) ?>" /> |
|
| 43 | 43 | </div> |
| 44 | 44 | |
| 45 | 45 | <div class="clear"></div> |
| 46 | 46 | <h3><?php _e( 'Required Indicator', 'formidable' ) ?></h3> |
| 47 | 47 | <div class="field-group field-group-border clearfix after-h3"> |
| 48 | 48 | <label class="background"><?php _e( 'Color', 'formidable' ) ?></label> |
| 49 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('required_color') ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 49 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'required_color' ) ) ?>" id="frm_required_color" class="hex" value="<?php echo esc_attr( $style->post_content['required_color'] ) ?>" /> |
|
| 50 | 50 | </div> |
| 51 | 51 | <div class="field-group clearfix after-h3"> |
| 52 | 52 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 53 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('required_weight') ) ?>" id="frm_required_weight"> |
|
| 53 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'required_weight' ) ) ?>" id="frm_required_weight"> |
|
| 54 | 54 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 55 | 55 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['required_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 56 | 56 | <?php } ?> |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | if ( ! $item_ids ) { |
| 4 | - return; |
|
| 4 | + return; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | 7 | global $wp_query; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | if ( empty( $taxonomies ) ) { |
| 68 | - return; |
|
| 68 | + return; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | global $frm_inc_tax; |
@@ -75,18 +75,18 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | foreach ( (array) $terms as $term ) { |
| 77 | 77 | if ( in_array( $term->term_id, $frm_inc_tax ) ) { |
| 78 | - return; |
|
| 78 | + return; |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - $frm_inc_tax[] = $term->term_id; |
|
| 82 | - $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
| 81 | + $frm_inc_tax[] = $term->term_id; |
|
| 82 | + $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
| 83 | 83 | <term><term_id><?php echo esc_html( $term->term_id ) ?></term_id><term_taxonomy><?php echo esc_html( $term->taxonomy ); ?></term_taxonomy><?php |
| 84 | - if ( ! empty( $term->name ) ) { |
|
| 85 | - echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
|
| 86 | - } |
|
| 87 | - if ( ! empty( $term->description ) ) { |
|
| 88 | - ?><term_description><?php echo FrmXMLHelper::cdata( $term->description ) ?></term_description><?php |
|
| 89 | - } |
|
| 90 | - ?><term_slug><?php echo esc_html( $term->slug ); ?></term_slug></term> |
|
| 84 | + if ( ! empty( $term->name ) ) { |
|
| 85 | + echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
|
| 86 | + } |
|
| 87 | + if ( ! empty( $term->description ) ) { |
|
| 88 | + ?><term_description><?php echo FrmXMLHelper::cdata( $term->description ) ?></term_description><?php |
|
| 89 | + } |
|
| 90 | + ?><term_slug><?php echo esc_html( $term->slug ); ?></term_slug></term> |
|
| 91 | 91 | <?php |
| 92 | 92 | } |
@@ -79,7 +79,7 @@ |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $frm_inc_tax[] = $term->term_id; |
| 82 | - $label = ($term->taxonomy == 'category' || $term->taxonomy == 'tag') ? $term->taxonomy : 'term'; ?> |
|
| 82 | + $label = ( $term->taxonomy == 'category' || $term->taxonomy == 'tag' ) ? $term->taxonomy : 'term'; ?> |
|
| 83 | 83 | <term><term_id><?php echo esc_html( $term->term_id ) ?></term_id><term_taxonomy><?php echo esc_html( $term->taxonomy ); ?></term_taxonomy><?php |
| 84 | 84 | if ( ! empty( $term->name ) ) { |
| 85 | 85 | echo '<term_name>' . FrmXMLHelper::cdata( $term->name ) . '</term_name>'; |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <div class="field-group field-group-background clearfix frm-first-row"> |
| 2 | 2 | <label><?php _e( 'Color', 'formidable' ) ?></label> |
| 3 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_color') ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" /> |
|
| 3 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_color' ) ) ?>" id="frm_description_color" class="hex" value="<?php echo esc_attr( $style->post_content['description_color'] ) ?>" /> |
|
| 4 | 4 | </div> |
| 5 | 5 | <div class="field-group clearfix frm-first-row"> |
| 6 | 6 | <label><?php _e( 'Weight', 'formidable' ) ?></label> |
| 7 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_weight') ) ?>" id="frm_description_weight"> |
|
| 7 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_weight' ) ) ?>" id="frm_description_weight"> |
|
| 8 | 8 | <?php foreach ( FrmStyle::get_bold_options() as $value => $name ) { ?> |
| 9 | 9 | <option value="<?php echo esc_attr( $value ) ?>" <?php selected( $style->post_content['description_weight'], $value ) ?>><?php echo esc_html( $name ) ?></option> |
| 10 | 10 | <?php } ?> |
@@ -12,25 +12,25 @@ discard block |
||
| 12 | 12 | </div> |
| 13 | 13 | <div class="field-group clearfix frm-first-row"> |
| 14 | 14 | <label><?php _e( 'Style', 'formidable' ) ?></label> |
| 15 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_style') ) ?>" id="frm_description_style"> |
|
| 16 | - <option value="normal" <?php selected($style->post_content['description_style'], 'normal') ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | - <option value="italic" <?php selected($style->post_content['description_style'], 'italic') ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 15 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_style' ) ) ?>" id="frm_description_style"> |
|
| 16 | + <option value="normal" <?php selected( $style->post_content['description_style'], 'normal' ) ?>><?php _e( 'normal', 'formidable' ) ?></option> |
|
| 17 | + <option value="italic" <?php selected( $style->post_content['description_style'], 'italic' ) ?>><?php _e( 'italic', 'formidable' ) ?></option> |
|
| 18 | 18 | </select> |
| 19 | 19 | </div> |
| 20 | 20 | |
| 21 | 21 | <div class="field-group clearfix"> |
| 22 | 22 | <label><?php _e( 'Size', 'formidable' ) ?></label> |
| 23 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_font_size') ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 23 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_font_size' ) ) ?>" id="frm_description_font_size" value="<?php echo esc_attr( $style->post_content['description_font_size'] ) ?>" size="3" /> |
|
| 24 | 24 | </div> |
| 25 | 25 | <div class="field-group clearfix"> |
| 26 | 26 | <label><?php _e( 'Align', 'formidable' ) ?></label> |
| 27 | - <select name="<?php echo esc_attr( $frm_style->get_field_name('description_align') ) ?>" id="frm_description_align"> |
|
| 28 | - <option value="left" <?php selected($style->post_content['description_align'], 'left') ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | - <option value="right" <?php selected($style->post_content['description_align'], 'right') ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 27 | + <select name="<?php echo esc_attr( $frm_style->get_field_name( 'description_align' ) ) ?>" id="frm_description_align"> |
|
| 28 | + <option value="left" <?php selected( $style->post_content['description_align'], 'left' ) ?>><?php _e( 'left', 'formidable' ) ?></option> |
|
| 29 | + <option value="right" <?php selected( $style->post_content['description_align'], 'right' ) ?>><?php _e( 'right', 'formidable' ) ?></option> |
|
| 30 | 30 | </select> |
| 31 | 31 | </div> |
| 32 | 32 | <div class="field-group clearfix"> |
| 33 | 33 | <label><?php _e( 'Margin', 'formidable' ) ?></label> |
| 34 | - <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name('description_margin') ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 34 | + <input type="text" name="<?php echo esc_attr( $frm_style->get_field_name( 'description_margin' ) ) ?>" id="frm_description_margin" value="<?php echo esc_attr( $style->post_content['description_margin'] ) ?>" size="3" /> |
|
| 35 | 35 | </div> |
| 36 | 36 | <div class="clear"></div> |
@@ -308,7 +308,7 @@ |
||
| 308 | 308 | * |
| 309 | 309 | * @since 2.02.05 |
| 310 | 310 | * @param string $key |
| 311 | - * @param int|string $value |
|
| 311 | + * @param string $value |
|
| 312 | 312 | * @param string $where |
| 313 | 313 | */ |
| 314 | 314 | private static function add_query_placeholder( $key, $value, &$where ) { |
@@ -1,70 +1,70 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmDb { |
| 4 | - var $fields; |
|
| 5 | - var $forms; |
|
| 6 | - var $entries; |
|
| 7 | - var $entry_metas; |
|
| 8 | - |
|
| 9 | - public function __construct() { |
|
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 12 | - } |
|
| 13 | - |
|
| 14 | - global $wpdb; |
|
| 15 | - $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | - $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | - $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | - $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | - } |
|
| 20 | - |
|
| 21 | - public function upgrade( $old_db_version = false ) { |
|
| 22 | - do_action( 'frm_before_install' ); |
|
| 23 | - |
|
| 24 | - global $wpdb; |
|
| 25 | - //$frm_db_version is the version of the database we're moving to |
|
| 26 | - $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | - $old_db_version = (float) $old_db_version; |
|
| 28 | - if ( ! $old_db_version ) { |
|
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - if ( $frm_db_version != $old_db_version ) { |
|
| 4 | + var $fields; |
|
| 5 | + var $forms; |
|
| 6 | + var $entries; |
|
| 7 | + var $entry_metas; |
|
| 8 | + |
|
| 9 | + public function __construct() { |
|
| 10 | + if ( ! defined('ABSPATH') ) { |
|
| 11 | + die('You are not allowed to call this page directly.'); |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + global $wpdb; |
|
| 15 | + $this->fields = $wpdb->prefix . 'frm_fields'; |
|
| 16 | + $this->forms = $wpdb->prefix . 'frm_forms'; |
|
| 17 | + $this->entries = $wpdb->prefix . 'frm_items'; |
|
| 18 | + $this->entry_metas = $wpdb->prefix . 'frm_item_metas'; |
|
| 19 | + } |
|
| 20 | + |
|
| 21 | + public function upgrade( $old_db_version = false ) { |
|
| 22 | + do_action( 'frm_before_install' ); |
|
| 23 | + |
|
| 24 | + global $wpdb; |
|
| 25 | + //$frm_db_version is the version of the database we're moving to |
|
| 26 | + $frm_db_version = FrmAppHelper::$db_version; |
|
| 27 | + $old_db_version = (float) $old_db_version; |
|
| 28 | + if ( ! $old_db_version ) { |
|
| 29 | + $old_db_version = get_option('frm_db_version'); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + if ( $frm_db_version != $old_db_version ) { |
|
| 33 | 33 | // update rewrite rules for views and other custom post types |
| 34 | 34 | flush_rewrite_rules(); |
| 35 | 35 | |
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | - $this->create_tables(); |
|
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 38 | + $this->create_tables(); |
|
| 39 | + $this->migrate_data($frm_db_version, $old_db_version); |
|
| 40 | 40 | |
| 41 | - /***** SAVE DB VERSION *****/ |
|
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 41 | + /***** SAVE DB VERSION *****/ |
|
| 42 | + update_option('frm_db_version', $frm_db_version); |
|
| 43 | 43 | |
| 44 | - /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | - FrmXMLController::add_default_templates(); |
|
| 44 | + /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
|
| 45 | + FrmXMLController::add_default_templates(); |
|
| 46 | 46 | |
| 47 | 47 | if ( ! $old_db_version ) { |
| 48 | 48 | $this->maybe_create_contact_form(); |
| 49 | 49 | } |
| 50 | - } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - do_action('frm_after_install'); |
|
| 52 | + do_action('frm_after_install'); |
|
| 53 | 53 | |
| 54 | - /**** update the styling settings ****/ |
|
| 54 | + /**** update the styling settings ****/ |
|
| 55 | 55 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
| 56 | 56 | $frm_style = new FrmStyle(); |
| 57 | 57 | $frm_style->update( 'default' ); |
| 58 | 58 | } |
| 59 | - } |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - public function collation() { |
|
| 62 | - global $wpdb; |
|
| 63 | - if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 64 | - return ''; |
|
| 65 | - } |
|
| 61 | + public function collation() { |
|
| 62 | + global $wpdb; |
|
| 63 | + if ( ! $wpdb->has_cap( 'collation' ) ) { |
|
| 64 | + return ''; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - $charset_collate = ''; |
|
| 67 | + $charset_collate = ''; |
|
| 68 | 68 | if ( ! empty( $wpdb->charset ) ) { |
| 69 | 69 | $charset_collate .= ' DEFAULT CHARACTER SET ' . $wpdb->charset; |
| 70 | 70 | } |
@@ -73,14 +73,14 @@ discard block |
||
| 73 | 73 | $charset_collate .= ' COLLATE ' . $wpdb->collate; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | - return $charset_collate; |
|
| 77 | - } |
|
| 76 | + return $charset_collate; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - private function create_tables() { |
|
| 80 | - $charset_collate = $this->collation(); |
|
| 81 | - $sql = array(); |
|
| 79 | + private function create_tables() { |
|
| 80 | + $charset_collate = $this->collation(); |
|
| 81 | + $sql = array(); |
|
| 82 | 82 | |
| 83 | - /* Create/Upgrade Fields Table */ |
|
| 83 | + /* Create/Upgrade Fields Table */ |
|
| 84 | 84 | $sql[] = 'CREATE TABLE ' . $this->fields . ' ( |
| 85 | 85 | id BIGINT(20) NOT NULL auto_increment, |
| 86 | 86 | field_key varchar(100) default NULL, |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | UNIQUE KEY field_key (field_key) |
| 100 | 100 | )'; |
| 101 | 101 | |
| 102 | - /* Create/Upgrade Forms Table */ |
|
| 102 | + /* Create/Upgrade Forms Table */ |
|
| 103 | 103 | $sql[] = 'CREATE TABLE ' . $this->forms . ' ( |
| 104 | 104 | id int(11) NOT NULL auto_increment, |
| 105 | 105 | form_key varchar(100) default NULL, |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | UNIQUE KEY form_key (form_key) |
| 118 | 118 | )'; |
| 119 | 119 | |
| 120 | - /* Create/Upgrade Items Table */ |
|
| 120 | + /* Create/Upgrade Items Table */ |
|
| 121 | 121 | $sql[] = 'CREATE TABLE ' . $this->entries . ' ( |
| 122 | 122 | id BIGINT(20) NOT NULL auto_increment, |
| 123 | 123 | item_key varchar(100) default NULL, |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | UNIQUE KEY item_key (item_key) |
| 141 | 141 | )'; |
| 142 | 142 | |
| 143 | - /* Create/Upgrade Meta Table */ |
|
| 143 | + /* Create/Upgrade Meta Table */ |
|
| 144 | 144 | $sql[] = 'CREATE TABLE ' . $this->entry_metas . ' ( |
| 145 | 145 | id BIGINT(20) NOT NULL auto_increment, |
| 146 | 146 | meta_value longtext default NULL, |
@@ -152,16 +152,16 @@ discard block |
||
| 152 | 152 | KEY item_id (item_id) |
| 153 | 153 | )'; |
| 154 | 154 | |
| 155 | - foreach ( $sql as $q ) { |
|
| 155 | + foreach ( $sql as $q ) { |
|
| 156 | 156 | if ( function_exists( 'dbDelta' ) ) { |
| 157 | 157 | dbDelta( $q . $charset_collate . ';' ); |
| 158 | 158 | } else { |
| 159 | 159 | global $wpdb; |
| 160 | 160 | $wpdb->query( $q . $charset_collate ); |
| 161 | 161 | } |
| 162 | - unset($q); |
|
| 163 | - } |
|
| 164 | - } |
|
| 162 | + unset($q); |
|
| 163 | + } |
|
| 164 | + } |
|
| 165 | 165 | |
| 166 | 166 | private function maybe_create_contact_form() { |
| 167 | 167 | $template_id = FrmForm::getIdByKey( 'contact' ); |
@@ -177,32 +177,32 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * @param integer $frm_db_version |
|
| 180 | + /** |
|
| 181 | + * @param integer $frm_db_version |
|
| 182 | 182 | * @param int $old_db_version |
| 183 | - */ |
|
| 183 | + */ |
|
| 184 | 184 | private function migrate_data( $frm_db_version, $old_db_version ) { |
| 185 | 185 | $migrations = array( 4, 6, 11, 16, 17, 23, 25 ); |
| 186 | - foreach ( $migrations as $migration ) { |
|
| 187 | - if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 186 | + foreach ( $migrations as $migration ) { |
|
| 187 | + if ( $frm_db_version >= $migration && $old_db_version < $migration ) { |
|
| 188 | 188 | $function_name = 'migrate_to_' . $migration; |
| 189 | - $this->$function_name(); |
|
| 190 | - } |
|
| 191 | - } |
|
| 192 | - } |
|
| 189 | + $this->$function_name(); |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * Change array into format $wpdb->prepare can use |
|
| 194 | + /** |
|
| 195 | + * Change array into format $wpdb->prepare can use |
|
| 196 | 196 | * |
| 197 | 197 | * @param array $args |
| 198 | 198 | * @param string $starts_with |
| 199 | - */ |
|
| 200 | - public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 201 | - if ( empty($args) ) { |
|
| 199 | + */ |
|
| 200 | + public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
|
| 201 | + if ( empty($args) ) { |
|
| 202 | 202 | // add an arg to prevent prepare from failing |
| 203 | 203 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 204 | 204 | return; |
| 205 | - } |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | 207 | $where = ''; |
| 208 | 208 | $values = array(); |
@@ -213,64 +213,64 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | $args = compact( 'where', 'values' ); |
| 216 | - } |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /** |
|
| 218 | + /** |
|
| 219 | 219 | * @param array $args |
| 220 | - * @param string $base_where |
|
| 221 | - * @param string $where |
|
| 220 | + * @param string $base_where |
|
| 221 | + * @param string $where |
|
| 222 | 222 | * @param array $values |
| 223 | - */ |
|
| 224 | - public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 225 | - $condition = ' AND'; |
|
| 226 | - if ( isset( $args['or'] ) ) { |
|
| 227 | - $condition = ' OR'; |
|
| 228 | - unset( $args['or'] ); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - foreach ( $args as $key => $value ) { |
|
| 232 | - $where .= empty( $where ) ? $base_where : $condition; |
|
| 233 | - $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 234 | - if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 235 | - $where .= ' ( '; |
|
| 236 | - $nested_where = ''; |
|
| 237 | - if ( $array_inc_null ) { |
|
| 238 | - foreach ( $value as $val ) { |
|
| 239 | - self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 240 | - } |
|
| 241 | - } else { |
|
| 242 | - self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 243 | - } |
|
| 244 | - $where .= $nested_where; |
|
| 245 | - $where .= ' ) '; |
|
| 246 | - } else { |
|
| 247 | - self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @param string $key |
|
| 223 | + */ |
|
| 224 | + public static function parse_where_from_array( $args, $base_where, &$where, &$values ) { |
|
| 225 | + $condition = ' AND'; |
|
| 226 | + if ( isset( $args['or'] ) ) { |
|
| 227 | + $condition = ' OR'; |
|
| 228 | + unset( $args['or'] ); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + foreach ( $args as $key => $value ) { |
|
| 232 | + $where .= empty( $where ) ? $base_where : $condition; |
|
| 233 | + $array_inc_null = ( ! is_numeric( $key ) && is_array( $value ) && in_array( null, $value ) ); |
|
| 234 | + if ( is_numeric( $key ) || $array_inc_null ) { |
|
| 235 | + $where .= ' ( '; |
|
| 236 | + $nested_where = ''; |
|
| 237 | + if ( $array_inc_null ) { |
|
| 238 | + foreach ( $value as $val ) { |
|
| 239 | + self::parse_where_from_array( array( $key => $val, 'or' => 1 ), '', $nested_where, $values ); |
|
| 240 | + } |
|
| 241 | + } else { |
|
| 242 | + self::parse_where_from_array( $value, '', $nested_where, $values ); |
|
| 243 | + } |
|
| 244 | + $where .= $nested_where; |
|
| 245 | + $where .= ' ) '; |
|
| 246 | + } else { |
|
| 247 | + self::interpret_array_to_sql( $key, $value, $where, $values ); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param string $key |
|
| 254 | 254 | * @param string|array $value |
| 255 | - * @param string $where |
|
| 255 | + * @param string $where |
|
| 256 | 256 | * @param array $values |
| 257 | - */ |
|
| 258 | - private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 257 | + */ |
|
| 258 | + private static function interpret_array_to_sql( $key, $value, &$where, &$values ) { |
|
| 259 | 259 | $key = trim( $key ); |
| 260 | 260 | |
| 261 | 261 | if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
| 262 | - $k = explode(' ', $key); |
|
| 263 | - $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 264 | - $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 265 | - } else { |
|
| 262 | + $k = explode(' ', $key); |
|
| 263 | + $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
|
| 264 | + $values[] = '%Y-%m-%d %H:%i:%s'; |
|
| 265 | + } else { |
|
| 266 | 266 | $where .= ' ' . $key; |
| 267 | - } |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | $lowercase_key = explode( ' ', strtolower( $key ) ); |
| 270 | 270 | $lowercase_key = end( $lowercase_key ); |
| 271 | 271 | |
| 272 | - if ( is_array( $value ) ) { |
|
| 273 | - // translate array of values to "in" |
|
| 272 | + if ( is_array( $value ) ) { |
|
| 273 | + // translate array of values to "in" |
|
| 274 | 274 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 275 | 275 | $where = preg_replace('/' . $key . '$/', '', $where); |
| 276 | 276 | $where .= '('; |
@@ -288,7 +288,7 @@ discard block |
||
| 288 | 288 | $where .= ' in (' . FrmAppHelper::prepare_array_values( $value, '%s' ) . ')'; |
| 289 | 289 | $values = array_merge( $values, $value ); |
| 290 | 290 | } |
| 291 | - } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 291 | + } else if ( strpos( $lowercase_key, 'like' ) !== false ) { |
|
| 292 | 292 | /** |
| 293 | 293 | * Allow string to start or end with the value |
| 294 | 294 | * If the key is like% then skip the first % for starts with |
@@ -308,9 +308,9 @@ discard block |
||
| 308 | 308 | $where .= ' %s'; |
| 309 | 309 | $values[] = $start . FrmAppHelper::esc_like( $value ) . $end; |
| 310 | 310 | |
| 311 | - } else if ( $value === null ) { |
|
| 312 | - $where .= ' IS NULL'; |
|
| 313 | - } else { |
|
| 311 | + } else if ( $value === null ) { |
|
| 312 | + $where .= ' IS NULL'; |
|
| 313 | + } else { |
|
| 314 | 314 | // allow a - to prevent = from being added |
| 315 | 315 | if ( substr( $key, -1 ) == '-' ) { |
| 316 | 316 | $where = rtrim( $where, '-' ); |
@@ -320,9 +320,9 @@ discard block |
||
| 320 | 320 | |
| 321 | 321 | self::add_query_placeholder( $key, $value, $where ); |
| 322 | 322 | |
| 323 | - $values[] = $value; |
|
| 324 | - } |
|
| 325 | - } |
|
| 323 | + $values[] = $value; |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | 326 | |
| 327 | 327 | /** |
| 328 | 328 | * Add %d, or %s to query |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | * @param int|string $value |
| 333 | 333 | * @param string $where |
| 334 | 334 | */ |
| 335 | - private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 335 | + private static function add_query_placeholder( $key, $value, &$where ) { |
|
| 336 | 336 | if ( is_numeric( $value ) && strpos( $key, 'meta_value' ) === false ) { |
| 337 | 337 | $where .= '%d'; |
| 338 | 338 | } else { |
@@ -340,16 +340,16 @@ discard block |
||
| 340 | 340 | } |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | - /** |
|
| 344 | - * @param string $table |
|
| 343 | + /** |
|
| 344 | + * @param string $table |
|
| 345 | 345 | * @param array $where |
| 346 | 346 | * @param array $args |
| 347 | 347 | * @return int |
| 348 | - */ |
|
| 349 | - public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 350 | - $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 351 | - return $count; |
|
| 352 | - } |
|
| 348 | + */ |
|
| 349 | + public static function get_count( $table, $where = array(), $args = array() ) { |
|
| 350 | + $count = self::get_var( $table, $where, 'COUNT(*)', $args ); |
|
| 351 | + return $count; |
|
| 352 | + } |
|
| 353 | 353 | |
| 354 | 354 | /** |
| 355 | 355 | * @param string $table |
@@ -360,17 +360,17 @@ discard block |
||
| 360 | 360 | * @param string $type |
| 361 | 361 | * @return array|null|string|object |
| 362 | 362 | */ |
| 363 | - public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 364 | - $group = ''; |
|
| 365 | - self::get_group_and_table_name( $table, $group ); |
|
| 363 | + public static function get_var( $table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var' ) { |
|
| 364 | + $group = ''; |
|
| 365 | + self::get_group_and_table_name( $table, $group ); |
|
| 366 | 366 | self::convert_options_to_array( $args, '', $limit ); |
| 367 | 367 | |
| 368 | 368 | $query = self::generate_query_string_from_pieces( $field, $table, $where, $args ); |
| 369 | 369 | |
| 370 | 370 | $cache_key = self::generate_cache_key( $where, $args, $field, $type ); |
| 371 | 371 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_' . $type ); |
| 372 | - return $results; |
|
| 373 | - } |
|
| 372 | + return $results; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | 376 | * Generate a cache key from the where query, field, type, and other arguments |
@@ -396,44 +396,44 @@ discard block |
||
| 396 | 396 | return $cache_key; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - /** |
|
| 400 | - * @param string $table |
|
| 401 | - * @param array $where |
|
| 399 | + /** |
|
| 400 | + * @param string $table |
|
| 401 | + * @param array $where |
|
| 402 | 402 | * @param string $field |
| 403 | 403 | * @param array $args |
| 404 | 404 | * @param string $limit |
| 405 | 405 | * @return mixed |
| 406 | - */ |
|
| 407 | - public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 408 | - return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * @since 2.0 |
|
| 413 | - * @param string $table |
|
| 406 | + */ |
|
| 407 | + public static function get_col( $table, $where = array(), $field = 'id', $args = array(), $limit = '' ) { |
|
| 408 | + return self::get_var( $table, $where, $field, $args, $limit, 'col' ); |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * @since 2.0 |
|
| 413 | + * @param string $table |
|
| 414 | 414 | * @param array $where |
| 415 | 415 | * @param string $fields |
| 416 | 416 | * @param array $args |
| 417 | 417 | * @return mixed |
| 418 | - */ |
|
| 419 | - public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 420 | - $args['limit'] = 1; |
|
| 421 | - return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - /** |
|
| 425 | - * Prepare a key/value array before DB call |
|
| 418 | + */ |
|
| 419 | + public static function get_row( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 420 | + $args['limit'] = 1; |
|
| 421 | + return self::get_var( $table, $where, $fields, $args, '', 'row' ); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + /** |
|
| 425 | + * Prepare a key/value array before DB call |
|
| 426 | 426 | * |
| 427 | - * @since 2.0 |
|
| 428 | - * @param string $table |
|
| 427 | + * @since 2.0 |
|
| 428 | + * @param string $table |
|
| 429 | 429 | * @param array $where |
| 430 | 430 | * @param string $fields |
| 431 | 431 | * @param array $args |
| 432 | 432 | * @return mixed |
| 433 | - */ |
|
| 434 | - public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 435 | - return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 436 | - } |
|
| 433 | + */ |
|
| 434 | + public static function get_results( $table, $where = array(), $fields = '*', $args = array() ) { |
|
| 435 | + return self::get_var( $table, $where, $fields, $args, '', 'results' ); |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | /** |
| 439 | 439 | * Check for like, not like, in, not in, =, !=, >, <, <=, >= |
@@ -470,59 +470,59 @@ discard block |
||
| 470 | 470 | return ''; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - /** |
|
| 474 | - * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 475 | - * Also add the wpdb->prefix to the table if it's missing |
|
| 476 | - * |
|
| 477 | - * @param string $table |
|
| 478 | - * @param string $group |
|
| 479 | - */ |
|
| 480 | - private static function get_group_and_table_name( &$table, &$group ) { |
|
| 473 | + /** |
|
| 474 | + * Get 'frm_forms' from wp_frm_forms or a longer table param that includes a join |
|
| 475 | + * Also add the wpdb->prefix to the table if it's missing |
|
| 476 | + * |
|
| 477 | + * @param string $table |
|
| 478 | + * @param string $group |
|
| 479 | + */ |
|
| 480 | + private static function get_group_and_table_name( &$table, &$group ) { |
|
| 481 | 481 | global $wpdb, $wpmuBaseTablePrefix; |
| 482 | 482 | |
| 483 | - $table_parts = explode(' ', $table); |
|
| 484 | - $group = reset($table_parts); |
|
| 485 | - $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 483 | + $table_parts = explode(' ', $table); |
|
| 484 | + $group = reset($table_parts); |
|
| 485 | + $group = str_replace( $wpdb->prefix, '', $group ); |
|
| 486 | 486 | |
| 487 | 487 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
| 488 | 488 | $group = str_replace( $prefix, '', $group ); |
| 489 | 489 | |
| 490 | - if ( $group == $table ) { |
|
| 491 | - $table = $wpdb->prefix . $table; |
|
| 492 | - } |
|
| 490 | + if ( $group == $table ) { |
|
| 491 | + $table = $wpdb->prefix . $table; |
|
| 492 | + } |
|
| 493 | 493 | |
| 494 | 494 | // switch to singular group name |
| 495 | 495 | $group = rtrim( $group, 's' ); |
| 496 | - } |
|
| 496 | + } |
|
| 497 | 497 | |
| 498 | - private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 499 | - if ( ! is_array($args) ) { |
|
| 498 | + private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
|
| 499 | + if ( ! is_array($args) ) { |
|
| 500 | 500 | $args = array( 'order_by' => $args ); |
| 501 | - } |
|
| 501 | + } |
|
| 502 | 502 | |
| 503 | - if ( ! empty( $order_by ) ) { |
|
| 504 | - $args['order_by'] = $order_by; |
|
| 505 | - } |
|
| 503 | + if ( ! empty( $order_by ) ) { |
|
| 504 | + $args['order_by'] = $order_by; |
|
| 505 | + } |
|
| 506 | 506 | |
| 507 | - if ( ! empty( $limit ) ) { |
|
| 508 | - $args['limit'] = $limit; |
|
| 509 | - } |
|
| 507 | + if ( ! empty( $limit ) ) { |
|
| 508 | + $args['limit'] = $limit; |
|
| 509 | + } |
|
| 510 | 510 | |
| 511 | - $temp_args = $args; |
|
| 512 | - foreach ( $temp_args as $k => $v ) { |
|
| 513 | - if ( $v == '' ) { |
|
| 511 | + $temp_args = $args; |
|
| 512 | + foreach ( $temp_args as $k => $v ) { |
|
| 513 | + if ( $v == '' ) { |
|
| 514 | 514 | unset( $args[ $k ] ); |
| 515 | - continue; |
|
| 516 | - } |
|
| 515 | + continue; |
|
| 516 | + } |
|
| 517 | 517 | |
| 518 | - if ( $k == 'limit' ) { |
|
| 518 | + if ( $k == 'limit' ) { |
|
| 519 | 519 | $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
| 520 | - } |
|
| 521 | - $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 522 | - if ( strpos( $v, $db_name ) === false ) { |
|
| 520 | + } |
|
| 521 | + $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
|
| 522 | + if ( strpos( $v, $db_name ) === false ) { |
|
| 523 | 523 | $args[ $k ] = $db_name . ' ' . $v; |
| 524 | - } |
|
| 525 | - } |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | 526 | |
| 527 | 527 | // Make sure LIMIT is the last argument |
| 528 | 528 | if ( isset( $args['order_by'] ) && isset( $args['limit'] ) ) { |
@@ -530,7 +530,7 @@ discard block |
||
| 530 | 530 | unset( $args['limit'] ); |
| 531 | 531 | $args['limit'] = $temp_limit; |
| 532 | 532 | } |
| 533 | - } |
|
| 533 | + } |
|
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * Get the associative array results for the given columns, table, and where query |
@@ -583,31 +583,31 @@ discard block |
||
| 583 | 583 | return $query; |
| 584 | 584 | } |
| 585 | 585 | |
| 586 | - public function uninstall() { |
|
| 586 | + public function uninstall() { |
|
| 587 | 587 | if ( ! current_user_can( 'administrator' ) ) { |
| 588 | - $frm_settings = FrmAppHelper::get_settings(); |
|
| 589 | - wp_die($frm_settings->admin_permission); |
|
| 590 | - } |
|
| 588 | + $frm_settings = FrmAppHelper::get_settings(); |
|
| 589 | + wp_die($frm_settings->admin_permission); |
|
| 590 | + } |
|
| 591 | 591 | |
| 592 | - global $wpdb, $wp_roles; |
|
| 592 | + global $wpdb, $wp_roles; |
|
| 593 | 593 | |
| 594 | 594 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->fields ); |
| 595 | 595 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->forms ); |
| 596 | 596 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 597 | 597 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 598 | 598 | |
| 599 | - delete_option('frm_options'); |
|
| 600 | - delete_option('frm_db_version'); |
|
| 599 | + delete_option('frm_options'); |
|
| 600 | + delete_option('frm_db_version'); |
|
| 601 | 601 | |
| 602 | - //delete roles |
|
| 603 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 604 | - $roles = get_editable_roles(); |
|
| 605 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 606 | - foreach ( $roles as $role => $details ) { |
|
| 607 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 608 | - unset($role, $details); |
|
| 609 | - } |
|
| 610 | - unset($frm_role, $frm_role_description); |
|
| 602 | + //delete roles |
|
| 603 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 604 | + $roles = get_editable_roles(); |
|
| 605 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 606 | + foreach ( $roles as $role => $details ) { |
|
| 607 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 608 | + unset($role, $details); |
|
| 609 | + } |
|
| 610 | + unset($frm_role, $frm_role_description); |
|
| 611 | 611 | } |
| 612 | 612 | unset($roles, $frm_roles); |
| 613 | 613 | |
@@ -631,9 +631,9 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 633 | 633 | |
| 634 | - do_action('frm_after_uninstall'); |
|
| 635 | - return true; |
|
| 636 | - } |
|
| 634 | + do_action('frm_after_uninstall'); |
|
| 635 | + return true; |
|
| 636 | + } |
|
| 637 | 637 | |
| 638 | 638 | /** |
| 639 | 639 | * Migrate old styling settings. If sites are using the old |
@@ -672,150 +672,150 @@ discard block |
||
| 672 | 672 | } |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | - /** |
|
| 676 | - * Change field size from character to pixel -- Multiply by 9 |
|
| 677 | - */ |
|
| 678 | - private function migrate_to_17() { |
|
| 679 | - global $wpdb; |
|
| 675 | + /** |
|
| 676 | + * Change field size from character to pixel -- Multiply by 9 |
|
| 677 | + */ |
|
| 678 | + private function migrate_to_17() { |
|
| 679 | + global $wpdb; |
|
| 680 | 680 | $pixel_conversion = 9; |
| 681 | 681 | |
| 682 | - // Get query arguments |
|
| 682 | + // Get query arguments |
|
| 683 | 683 | $field_types = array( 'textarea', 'text', 'number', 'email', 'url', 'rte', 'date', 'phone', 'password', 'image', 'tag', 'file' ); |
| 684 | 684 | $query = array( 'type' => $field_types, 'field_options like' => 's:4:"size";', 'field_options not like' => 's:4:"size";s:0:' ); |
| 685 | 685 | |
| 686 | - // Get results |
|
| 686 | + // Get results |
|
| 687 | 687 | $fields = FrmDb::get_results( $this->fields, $query, 'id, field_options' ); |
| 688 | 688 | |
| 689 | - $updated = 0; |
|
| 690 | - foreach ( $fields as $f ) { |
|
| 691 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 692 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 693 | - continue; |
|
| 694 | - } |
|
| 689 | + $updated = 0; |
|
| 690 | + foreach ( $fields as $f ) { |
|
| 691 | + $f->field_options = maybe_unserialize($f->field_options); |
|
| 692 | + if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 693 | + continue; |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | 696 | $f->field_options['size'] = round( $pixel_conversion * (int) $f->field_options['size'] ); |
| 697 | - $f->field_options['size'] .= 'px'; |
|
| 698 | - $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 699 | - if ( $u ) { |
|
| 700 | - $updated++; |
|
| 701 | - } |
|
| 702 | - unset($f); |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - // Change the characters in widgets to pixels |
|
| 706 | - $widgets = get_option('widget_frm_show_form'); |
|
| 707 | - if ( empty($widgets) ) { |
|
| 708 | - return; |
|
| 709 | - } |
|
| 710 | - |
|
| 711 | - $widgets = maybe_unserialize($widgets); |
|
| 712 | - foreach ( $widgets as $k => $widget ) { |
|
| 713 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 714 | - continue; |
|
| 715 | - } |
|
| 697 | + $f->field_options['size'] .= 'px'; |
|
| 698 | + $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
|
| 699 | + if ( $u ) { |
|
| 700 | + $updated++; |
|
| 701 | + } |
|
| 702 | + unset($f); |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + // Change the characters in widgets to pixels |
|
| 706 | + $widgets = get_option('widget_frm_show_form'); |
|
| 707 | + if ( empty($widgets) ) { |
|
| 708 | + return; |
|
| 709 | + } |
|
| 710 | + |
|
| 711 | + $widgets = maybe_unserialize($widgets); |
|
| 712 | + foreach ( $widgets as $k => $widget ) { |
|
| 713 | + if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 714 | + continue; |
|
| 715 | + } |
|
| 716 | 716 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 717 | - $size .= 'px'; |
|
| 717 | + $size .= 'px'; |
|
| 718 | 718 | $widgets[ $k ]['size'] = $size; |
| 719 | - } |
|
| 720 | - update_option('widget_frm_show_form', $widgets); |
|
| 721 | - } |
|
| 722 | - |
|
| 723 | - /** |
|
| 724 | - * Migrate post and email notification settings into actions |
|
| 725 | - */ |
|
| 726 | - private function migrate_to_16() { |
|
| 727 | - global $wpdb; |
|
| 728 | - |
|
| 729 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 730 | - |
|
| 731 | - /** |
|
| 732 | - * Old email settings format: |
|
| 733 | - * email_to: Email or field id |
|
| 734 | - * also_email_to: array of fields ids |
|
| 735 | - * reply_to: Email, field id, 'custom' |
|
| 736 | - * cust_reply_to: string |
|
| 737 | - * reply_to_name: field id, 'custom' |
|
| 738 | - * cust_reply_to_name: string |
|
| 739 | - * plain_text: 0|1 |
|
| 740 | - * email_message: string or '' |
|
| 741 | - * email_subject: string or '' |
|
| 742 | - * inc_user_info: 0|1 |
|
| 743 | - * update_email: 0, 1, 2 |
|
| 744 | - * |
|
| 745 | - * Old autoresponder settings format: |
|
| 746 | - * auto_responder: 0|1 |
|
| 747 | - * ar_email_message: string or '' |
|
| 748 | - * ar_email_to: field id |
|
| 749 | - * ar_plain_text: 0|1 |
|
| 750 | - * ar_reply_to_name: string |
|
| 751 | - * ar_reply_to: string |
|
| 752 | - * ar_email_subject: string |
|
| 753 | - * ar_update_email: 0, 1, 2 |
|
| 754 | - * |
|
| 755 | - * New email settings: |
|
| 756 | - * post_content: json settings |
|
| 757 | - * post_title: form id |
|
| 758 | - * post_excerpt: message |
|
| 759 | - * |
|
| 760 | - */ |
|
| 761 | - |
|
| 762 | - foreach ( $forms as $form ) { |
|
| 719 | + } |
|
| 720 | + update_option('widget_frm_show_form', $widgets); |
|
| 721 | + } |
|
| 722 | + |
|
| 723 | + /** |
|
| 724 | + * Migrate post and email notification settings into actions |
|
| 725 | + */ |
|
| 726 | + private function migrate_to_16() { |
|
| 727 | + global $wpdb; |
|
| 728 | + |
|
| 729 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options, is_template, default_template' ); |
|
| 730 | + |
|
| 731 | + /** |
|
| 732 | + * Old email settings format: |
|
| 733 | + * email_to: Email or field id |
|
| 734 | + * also_email_to: array of fields ids |
|
| 735 | + * reply_to: Email, field id, 'custom' |
|
| 736 | + * cust_reply_to: string |
|
| 737 | + * reply_to_name: field id, 'custom' |
|
| 738 | + * cust_reply_to_name: string |
|
| 739 | + * plain_text: 0|1 |
|
| 740 | + * email_message: string or '' |
|
| 741 | + * email_subject: string or '' |
|
| 742 | + * inc_user_info: 0|1 |
|
| 743 | + * update_email: 0, 1, 2 |
|
| 744 | + * |
|
| 745 | + * Old autoresponder settings format: |
|
| 746 | + * auto_responder: 0|1 |
|
| 747 | + * ar_email_message: string or '' |
|
| 748 | + * ar_email_to: field id |
|
| 749 | + * ar_plain_text: 0|1 |
|
| 750 | + * ar_reply_to_name: string |
|
| 751 | + * ar_reply_to: string |
|
| 752 | + * ar_email_subject: string |
|
| 753 | + * ar_update_email: 0, 1, 2 |
|
| 754 | + * |
|
| 755 | + * New email settings: |
|
| 756 | + * post_content: json settings |
|
| 757 | + * post_title: form id |
|
| 758 | + * post_excerpt: message |
|
| 759 | + * |
|
| 760 | + */ |
|
| 761 | + |
|
| 762 | + foreach ( $forms as $form ) { |
|
| 763 | 763 | if ( $form->is_template && $form->default_template ) { |
| 764 | 764 | // don't migrate the default templates since the email will be added anyway |
| 765 | 765 | continue; |
| 766 | 766 | } |
| 767 | 767 | |
| 768 | - // Format form options |
|
| 769 | - $form_options = maybe_unserialize($form->options); |
|
| 768 | + // Format form options |
|
| 769 | + $form_options = maybe_unserialize($form->options); |
|
| 770 | 770 | |
| 771 | - // Migrate settings to actions |
|
| 772 | - FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 773 | - } |
|
| 774 | - } |
|
| 771 | + // Migrate settings to actions |
|
| 772 | + FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
|
| 773 | + } |
|
| 774 | + } |
|
| 775 | 775 | |
| 776 | - private function migrate_to_11() { |
|
| 777 | - global $wpdb; |
|
| 776 | + private function migrate_to_11() { |
|
| 777 | + global $wpdb; |
|
| 778 | 778 | |
| 779 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 779 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 780 | 780 | |
| 781 | - $sending = __( 'Sending', 'formidable' ); |
|
| 781 | + $sending = __( 'Sending', 'formidable' ); |
|
| 782 | 782 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
| 783 | - $old_default_html = <<<DEFAULT_HTML |
|
| 783 | + $old_default_html = <<<DEFAULT_HTML |
|
| 784 | 784 | <div class="frm_submit"> |
| 785 | 785 | [if back_button]<input type="submit" value="[back_label]" name="frm_prev_page" formnovalidate="formnovalidate" [back_hook] />[/if back_button] |
| 786 | 786 | <input type="submit" value="[button_label]" [button_action] /> |
| 787 | 787 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 788 | 788 | </div> |
| 789 | 789 | DEFAULT_HTML; |
| 790 | - unset($sending, $img); |
|
| 790 | + unset($sending, $img); |
|
| 791 | 791 | |
| 792 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 793 | - $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 792 | + $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 793 | + $draft_link = FrmFormsHelper::get_draft_link(); |
|
| 794 | 794 | foreach ( $forms as $form ) { |
| 795 | - $form->options = maybe_unserialize($form->options); |
|
| 796 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 797 | - continue; |
|
| 798 | - } |
|
| 795 | + $form->options = maybe_unserialize($form->options); |
|
| 796 | + if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 797 | + continue; |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 801 | - $form->options['submit_html'] = $new_default_html; |
|
| 800 | + if ( $form->options['submit_html'] != $new_default_html && $form->options['submit_html'] == $old_default_html ) { |
|
| 801 | + $form->options['submit_html'] = $new_default_html; |
|
| 802 | 802 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 803 | 803 | } else if ( ! strpos( $form->options['submit_html'], 'save_draft' ) ) { |
| 804 | 804 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 805 | 805 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 806 | - } |
|
| 807 | - unset($form); |
|
| 808 | - } |
|
| 809 | - unset($forms); |
|
| 810 | - } |
|
| 806 | + } |
|
| 807 | + unset($form); |
|
| 808 | + } |
|
| 809 | + unset($forms); |
|
| 810 | + } |
|
| 811 | 811 | |
| 812 | - private function migrate_to_6() { |
|
| 813 | - global $wpdb; |
|
| 812 | + private function migrate_to_6() { |
|
| 813 | + global $wpdb; |
|
| 814 | 814 | |
| 815 | 815 | $no_save = array_merge( FrmField::no_save_fields(), array( 'form', 'hidden', 'user_id' ) ); |
| 816 | 816 | $fields = FrmDb::get_results( $this->fields, array( 'type NOT' => $no_save ), 'id, field_options' ); |
| 817 | 817 | |
| 818 | - $default_html = <<<DEFAULT_HTML |
|
| 818 | + $default_html = <<<DEFAULT_HTML |
|
| 819 | 819 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 820 | 820 | <label class="frm_pos_[label_position]">[field_name] |
| 821 | 821 | <span class="frm_required">[required_label]</span> |
@@ -825,7 +825,7 @@ discard block |
||
| 825 | 825 | </div> |
| 826 | 826 | DEFAULT_HTML; |
| 827 | 827 | |
| 828 | - $old_default_html = <<<DEFAULT_HTML |
|
| 828 | + $old_default_html = <<<DEFAULT_HTML |
|
| 829 | 829 | <div id="frm_field_[id]_container" class="form-field [required_class] [error_class]"> |
| 830 | 830 | <label class="frm_pos_[label_position]">[field_name] |
| 831 | 831 | <span class="frm_required">[required_label]</span> |
@@ -835,23 +835,23 @@ discard block |
||
| 835 | 835 | </div> |
| 836 | 836 | DEFAULT_HTML; |
| 837 | 837 | |
| 838 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 839 | - foreach ( $fields as $field ) { |
|
| 840 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 838 | + $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 839 | + foreach ( $fields as $field ) { |
|
| 840 | + $field->field_options = maybe_unserialize($field->field_options); |
|
| 841 | 841 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 842 | - $field->field_options['custom_html'] = $new_default_html; |
|
| 842 | + $field->field_options['custom_html'] = $new_default_html; |
|
| 843 | 843 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 844 | - } |
|
| 845 | - unset($field); |
|
| 846 | - } |
|
| 847 | - unset($default_html, $old_default_html, $fields); |
|
| 848 | - } |
|
| 849 | - |
|
| 850 | - private function migrate_to_4() { |
|
| 851 | - global $wpdb; |
|
| 844 | + } |
|
| 845 | + unset($field); |
|
| 846 | + } |
|
| 847 | + unset($default_html, $old_default_html, $fields); |
|
| 848 | + } |
|
| 849 | + |
|
| 850 | + private function migrate_to_4() { |
|
| 851 | + global $wpdb; |
|
| 852 | 852 | $user_ids = FrmEntryMeta::getAll( array( 'fi.type' => 'user_id' ) ); |
| 853 | - foreach ( $user_ids as $user_id ) { |
|
| 853 | + foreach ( $user_ids as $user_id ) { |
|
| 854 | 854 | $wpdb->update( $this->entries, array( 'user_id' => $user_id->meta_value ), array( 'id' => $user_id->item_id ) ); |
| 855 | - } |
|
| 856 | - } |
|
| 855 | + } |
|
| 856 | + } |
|
| 857 | 857 | } |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | var $entry_metas; |
| 8 | 8 | |
| 9 | 9 | public function __construct() { |
| 10 | - if ( ! defined('ABSPATH') ) { |
|
| 11 | - die('You are not allowed to call this page directly.'); |
|
| 10 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 11 | + die( 'You are not allowed to call this page directly.' ); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | global $wpdb; |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $frm_db_version = FrmAppHelper::$db_version; |
| 27 | 27 | $old_db_version = (float) $old_db_version; |
| 28 | 28 | if ( ! $old_db_version ) { |
| 29 | - $old_db_version = get_option('frm_db_version'); |
|
| 29 | + $old_db_version = get_option( 'frm_db_version' ); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if ( $frm_db_version != $old_db_version ) { |
@@ -36,10 +36,10 @@ discard block |
||
| 36 | 36 | require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
| 37 | 37 | |
| 38 | 38 | $this->create_tables(); |
| 39 | - $this->migrate_data($frm_db_version, $old_db_version); |
|
| 39 | + $this->migrate_data( $frm_db_version, $old_db_version ); |
|
| 40 | 40 | |
| 41 | 41 | /***** SAVE DB VERSION *****/ |
| 42 | - update_option('frm_db_version', $frm_db_version); |
|
| 42 | + update_option( 'frm_db_version', $frm_db_version ); |
|
| 43 | 43 | |
| 44 | 44 | /**** ADD/UPDATE DEFAULT TEMPLATES ****/ |
| 45 | 45 | FrmXMLController::add_default_templates(); |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - do_action('frm_after_install'); |
|
| 52 | + do_action( 'frm_after_install' ); |
|
| 53 | 53 | |
| 54 | 54 | /**** update the styling settings ****/ |
| 55 | 55 | if ( is_admin() && function_exists( 'get_filesystem_method' ) ) { |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | global $wpdb; |
| 160 | 160 | $wpdb->query( $q . $charset_collate ); |
| 161 | 161 | } |
| 162 | - unset($q); |
|
| 162 | + unset( $q ); |
|
| 163 | 163 | } |
| 164 | 164 | } |
| 165 | 165 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | * @param string $starts_with |
| 199 | 199 | */ |
| 200 | 200 | public static function get_where_clause_and_values( &$args, $starts_with = ' WHERE ' ) { |
| 201 | - if ( empty($args) ) { |
|
| 201 | + if ( empty( $args ) ) { |
|
| 202 | 202 | // add an arg to prevent prepare from failing |
| 203 | 203 | $args = array( 'where' => $starts_with . '1=%d', 'values' => array( 1 ) ); |
| 204 | 204 | return; |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | $key = trim( $key ); |
| 260 | 260 | |
| 261 | 261 | if ( strpos( $key, 'created_at' ) !== false || strpos( $key, 'updated_at' ) !== false ) { |
| 262 | - $k = explode(' ', $key); |
|
| 262 | + $k = explode( ' ', $key ); |
|
| 263 | 263 | $where .= ' DATE_FORMAT(' . reset( $k ) . ', %s) ' . str_replace( reset( $k ), '', $key ); |
| 264 | 264 | $values[] = '%Y-%m-%d %H:%i:%s'; |
| 265 | 265 | } else { |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | if ( is_array( $value ) ) { |
| 273 | 273 | // translate array of values to "in" |
| 274 | 274 | if ( strpos( $lowercase_key, 'like' ) !== false ) { |
| 275 | - $where = preg_replace('/' . $key . '$/', '', $where); |
|
| 275 | + $where = preg_replace( '/' . $key . '$/', '', $where ); |
|
| 276 | 276 | $where .= '('; |
| 277 | 277 | $start = true; |
| 278 | 278 | foreach ( $value as $v ) { |
@@ -457,8 +457,8 @@ discard block |
||
| 457 | 457 | ); |
| 458 | 458 | |
| 459 | 459 | $where_is = strtolower( $where_is ); |
| 460 | - if ( isset( $switch_to[ $where_is ] ) ) { |
|
| 461 | - return ' ' . $switch_to[ $where_is ]; |
|
| 460 | + if ( isset( $switch_to[$where_is] ) ) { |
|
| 461 | + return ' ' . $switch_to[$where_is]; |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | // > and < need a little more work since we don't want them switched to >= and <= |
@@ -480,8 +480,8 @@ discard block |
||
| 480 | 480 | private static function get_group_and_table_name( &$table, &$group ) { |
| 481 | 481 | global $wpdb, $wpmuBaseTablePrefix; |
| 482 | 482 | |
| 483 | - $table_parts = explode(' ', $table); |
|
| 484 | - $group = reset($table_parts); |
|
| 483 | + $table_parts = explode( ' ', $table ); |
|
| 484 | + $group = reset( $table_parts ); |
|
| 485 | 485 | $group = str_replace( $wpdb->prefix, '', $group ); |
| 486 | 486 | |
| 487 | 487 | $prefix = $wpmuBaseTablePrefix ? $wpmuBaseTablePrefix : $wpdb->base_prefix; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | private static function convert_options_to_array( &$args, $order_by = '', $limit = '' ) { |
| 499 | - if ( ! is_array($args) ) { |
|
| 499 | + if ( ! is_array( $args ) ) { |
|
| 500 | 500 | $args = array( 'order_by' => $args ); |
| 501 | 501 | } |
| 502 | 502 | |
@@ -511,16 +511,16 @@ discard block |
||
| 511 | 511 | $temp_args = $args; |
| 512 | 512 | foreach ( $temp_args as $k => $v ) { |
| 513 | 513 | if ( $v == '' ) { |
| 514 | - unset( $args[ $k ] ); |
|
| 514 | + unset( $args[$k] ); |
|
| 515 | 515 | continue; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | 518 | if ( $k == 'limit' ) { |
| 519 | - $args[ $k ] = FrmAppHelper::esc_limit( $v ); |
|
| 519 | + $args[$k] = FrmAppHelper::esc_limit( $v ); |
|
| 520 | 520 | } |
| 521 | 521 | $db_name = strtoupper( str_replace( '_', ' ', $k ) ); |
| 522 | 522 | if ( strpos( $v, $db_name ) === false ) { |
| 523 | - $args[ $k ] = $db_name . ' ' . $v; |
|
| 523 | + $args[$k] = $db_name . ' ' . $v; |
|
| 524 | 524 | } |
| 525 | 525 | } |
| 526 | 526 | |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | $query = self::generate_query_string_from_pieces( $columns, $table, $where ); |
| 549 | 549 | |
| 550 | - $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A' , ' WHERE' ) ); |
|
| 550 | + $cache_key = str_replace( array( ' ', ',' ), '_', trim( implode( '_', FrmAppHelper::array_flatten( $where ) ) . $columns . '_results_ARRAY_A', ' WHERE' ) ); |
|
| 551 | 551 | $results = FrmAppHelper::check_cache( $cache_key, $group, $query, 'get_associative_results' ); |
| 552 | 552 | |
| 553 | 553 | return $results; |
@@ -586,7 +586,7 @@ discard block |
||
| 586 | 586 | public function uninstall() { |
| 587 | 587 | if ( ! current_user_can( 'administrator' ) ) { |
| 588 | 588 | $frm_settings = FrmAppHelper::get_settings(); |
| 589 | - wp_die($frm_settings->admin_permission); |
|
| 589 | + wp_die( $frm_settings->admin_permission ); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | global $wpdb, $wp_roles; |
@@ -596,8 +596,8 @@ discard block |
||
| 596 | 596 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entries ); |
| 597 | 597 | $wpdb->query( 'DROP TABLE IF EXISTS ' . $this->entry_metas ); |
| 598 | 598 | |
| 599 | - delete_option('frm_options'); |
|
| 600 | - delete_option('frm_db_version'); |
|
| 599 | + delete_option( 'frm_options' ); |
|
| 600 | + delete_option( 'frm_db_version' ); |
|
| 601 | 601 | |
| 602 | 602 | //delete roles |
| 603 | 603 | $frm_roles = FrmAppHelper::frm_capabilities(); |
@@ -605,11 +605,11 @@ discard block |
||
| 605 | 605 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 606 | 606 | foreach ( $roles as $role => $details ) { |
| 607 | 607 | $wp_roles->remove_cap( $role, $frm_role ); |
| 608 | - unset($role, $details); |
|
| 608 | + unset( $role, $details ); |
|
| 609 | 609 | } |
| 610 | - unset($frm_role, $frm_role_description); |
|
| 610 | + unset( $frm_role, $frm_role_description ); |
|
| 611 | 611 | } |
| 612 | - unset($roles, $frm_roles); |
|
| 612 | + unset( $roles, $frm_roles ); |
|
| 613 | 613 | |
| 614 | 614 | // delete actions, views, and styles |
| 615 | 615 | |
@@ -631,7 +631,7 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_%', '_transient_frm_form_fields_%' ) ); |
| 633 | 633 | |
| 634 | - do_action('frm_after_uninstall'); |
|
| 634 | + do_action( 'frm_after_uninstall' ); |
|
| 635 | 635 | return true; |
| 636 | 636 | } |
| 637 | 637 | |
@@ -688,8 +688,8 @@ discard block |
||
| 688 | 688 | |
| 689 | 689 | $updated = 0; |
| 690 | 690 | foreach ( $fields as $f ) { |
| 691 | - $f->field_options = maybe_unserialize($f->field_options); |
|
| 692 | - if ( empty($f->field_options['size']) || ! is_numeric($f->field_options['size']) ) { |
|
| 691 | + $f->field_options = maybe_unserialize( $f->field_options ); |
|
| 692 | + if ( empty( $f->field_options['size'] ) || ! is_numeric( $f->field_options['size'] ) ) { |
|
| 693 | 693 | continue; |
| 694 | 694 | } |
| 695 | 695 | |
@@ -697,27 +697,27 @@ discard block |
||
| 697 | 697 | $f->field_options['size'] .= 'px'; |
| 698 | 698 | $u = FrmField::update( $f->id, array( 'field_options' => $f->field_options ) ); |
| 699 | 699 | if ( $u ) { |
| 700 | - $updated++; |
|
| 700 | + $updated ++; |
|
| 701 | 701 | } |
| 702 | - unset($f); |
|
| 702 | + unset( $f ); |
|
| 703 | 703 | } |
| 704 | 704 | |
| 705 | 705 | // Change the characters in widgets to pixels |
| 706 | - $widgets = get_option('widget_frm_show_form'); |
|
| 707 | - if ( empty($widgets) ) { |
|
| 706 | + $widgets = get_option( 'widget_frm_show_form' ); |
|
| 707 | + if ( empty( $widgets ) ) { |
|
| 708 | 708 | return; |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | - $widgets = maybe_unserialize($widgets); |
|
| 711 | + $widgets = maybe_unserialize( $widgets ); |
|
| 712 | 712 | foreach ( $widgets as $k => $widget ) { |
| 713 | - if ( ! is_array($widget) || ! isset($widget['size']) ) { |
|
| 713 | + if ( ! is_array( $widget ) || ! isset( $widget['size'] ) ) { |
|
| 714 | 714 | continue; |
| 715 | 715 | } |
| 716 | 716 | $size = round( $pixel_conversion * (int) $widget['size'] ); |
| 717 | 717 | $size .= 'px'; |
| 718 | - $widgets[ $k ]['size'] = $size; |
|
| 718 | + $widgets[$k]['size'] = $size; |
|
| 719 | 719 | } |
| 720 | - update_option('widget_frm_show_form', $widgets); |
|
| 720 | + update_option( 'widget_frm_show_form', $widgets ); |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | /** |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | } |
| 767 | 767 | |
| 768 | 768 | // Format form options |
| 769 | - $form_options = maybe_unserialize($form->options); |
|
| 769 | + $form_options = maybe_unserialize( $form->options ); |
|
| 770 | 770 | |
| 771 | 771 | // Migrate settings to actions |
| 772 | 772 | FrmXMLHelper::migrate_form_settings_to_actions( $form_options, $form->id ); |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | private function migrate_to_11() { |
| 777 | 777 | global $wpdb; |
| 778 | 778 | |
| 779 | - $forms = FrmDb::get_results( $this->forms, array(), 'id, options'); |
|
| 779 | + $forms = FrmDb::get_results( $this->forms, array(), 'id, options' ); |
|
| 780 | 780 | |
| 781 | 781 | $sending = __( 'Sending', 'formidable' ); |
| 782 | 782 | $img = FrmAppHelper::plugin_url() . '/images/ajax_loader.gif'; |
@@ -787,13 +787,13 @@ discard block |
||
| 787 | 787 | <img class="frm_ajax_loading" src="$img" alt="$sending" style="visibility:hidden;" /> |
| 788 | 788 | </div> |
| 789 | 789 | DEFAULT_HTML; |
| 790 | - unset($sending, $img); |
|
| 790 | + unset( $sending, $img ); |
|
| 791 | 791 | |
| 792 | - $new_default_html = FrmFormsHelper::get_default_html('submit'); |
|
| 792 | + $new_default_html = FrmFormsHelper::get_default_html( 'submit' ); |
|
| 793 | 793 | $draft_link = FrmFormsHelper::get_draft_link(); |
| 794 | 794 | foreach ( $forms as $form ) { |
| 795 | - $form->options = maybe_unserialize($form->options); |
|
| 796 | - if ( ! isset($form->options['submit_html']) || empty($form->options['submit_html']) ) { |
|
| 795 | + $form->options = maybe_unserialize( $form->options ); |
|
| 796 | + if ( ! isset( $form->options['submit_html'] ) || empty( $form->options['submit_html'] ) ) { |
|
| 797 | 797 | continue; |
| 798 | 798 | } |
| 799 | 799 | |
@@ -804,9 +804,9 @@ discard block |
||
| 804 | 804 | $form->options['submit_html'] = preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $draft_link . "\r\n</div>", $form->options['submit_html'] ); |
| 805 | 805 | $wpdb->update( $this->forms, array( 'options' => serialize( $form->options ) ), array( 'id' => $form->id ) ); |
| 806 | 806 | } |
| 807 | - unset($form); |
|
| 807 | + unset( $form ); |
|
| 808 | 808 | } |
| 809 | - unset($forms); |
|
| 809 | + unset( $forms ); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | private function migrate_to_6() { |
@@ -835,16 +835,16 @@ discard block |
||
| 835 | 835 | </div> |
| 836 | 836 | DEFAULT_HTML; |
| 837 | 837 | |
| 838 | - $new_default_html = FrmFieldsHelper::get_default_html('text'); |
|
| 838 | + $new_default_html = FrmFieldsHelper::get_default_html( 'text' ); |
|
| 839 | 839 | foreach ( $fields as $field ) { |
| 840 | - $field->field_options = maybe_unserialize($field->field_options); |
|
| 840 | + $field->field_options = maybe_unserialize( $field->field_options ); |
|
| 841 | 841 | if ( ! FrmField::is_option_empty( $field, 'custom_html' ) || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html ) { |
| 842 | 842 | $field->field_options['custom_html'] = $new_default_html; |
| 843 | 843 | $wpdb->update( $this->fields, array( 'field_options' => maybe_serialize( $field->field_options ) ), array( 'id' => $field->id ) ); |
| 844 | 844 | } |
| 845 | - unset($field); |
|
| 845 | + unset( $field ); |
|
| 846 | 846 | } |
| 847 | - unset($default_html, $old_default_html, $fields); |
|
| 847 | + unset( $default_html, $old_default_html, $fields ); |
|
| 848 | 848 | } |
| 849 | 849 | |
| 850 | 850 | private function migrate_to_4() { |
@@ -2,109 +2,109 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmXMLController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 5 | + public static function menu() { |
|
| 6 | 6 | add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' ); |
| 7 | - } |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public static function add_default_templates() { |
|
| 9 | + public static function add_default_templates() { |
|
| 10 | 10 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 11 | - // XML import is not enabled on your server |
|
| 12 | - return; |
|
| 13 | - } |
|
| 11 | + // XML import is not enabled on your server |
|
| 12 | + return; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 16 | - $loader = libxml_disable_entity_loader( true ); |
|
| 15 | + $set_err = libxml_use_internal_errors(true); |
|
| 16 | + $loader = libxml_disable_entity_loader( true ); |
|
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | - foreach ( (array) $files as $file ) { |
|
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 23 | - } |
|
| 24 | - /* |
|
| 20 | + foreach ( (array) $files as $file ) { |
|
| 21 | + FrmXMLHelper::import_xml($file); |
|
| 22 | + unset($file); |
|
| 23 | + } |
|
| 24 | + /* |
|
| 25 | 25 | if(is_wp_error($result)) |
| 26 | 26 | $errors[] = $result->get_error_message(); |
| 27 | 27 | else if($result) |
| 28 | 28 | $message = $result; |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | - unset( $files ); |
|
| 31 | + unset( $files ); |
|
| 32 | 32 | |
| 33 | - libxml_use_internal_errors( $set_err ); |
|
| 34 | - libxml_disable_entity_loader( $loader ); |
|
| 35 | - } |
|
| 33 | + libxml_use_internal_errors( $set_err ); |
|
| 34 | + libxml_disable_entity_loader( $loader ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function route() { |
|
| 38 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 37 | + public static function route() { |
|
| 38 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 39 | 39 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 40 | 40 | if ( $action == 'import_xml' ) { |
| 41 | - return self::import_xml(); |
|
| 41 | + return self::import_xml(); |
|
| 42 | 42 | } else if ( $action == 'export_xml' ) { |
| 43 | - return self::export_xml(); |
|
| 44 | - } else { |
|
| 45 | - if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | - return self::form(); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public static function form( $errors = array(), $message = '' ) { |
|
| 43 | + return self::export_xml(); |
|
| 44 | + } else { |
|
| 45 | + if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | + return self::form(); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public static function form( $errors = array(), $message = '' ) { |
|
| 52 | 52 | $where = array( |
| 53 | 53 | 'status' => array( null, '', 'published' ), |
| 54 | 54 | ); |
| 55 | 55 | $forms = FrmForm::getAll( $where, 'name' ); |
| 56 | 56 | |
| 57 | - $export_types = apply_filters( 'frm_xml_export_types', |
|
| 58 | - array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 59 | - ); |
|
| 57 | + $export_types = apply_filters( 'frm_xml_export_types', |
|
| 58 | + array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 59 | + ); |
|
| 60 | 60 | |
| 61 | - $export_format = apply_filters( 'frm_export_formats', array( |
|
| 62 | - 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 61 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 62 | + 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 63 | 63 | 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ), |
| 64 | - ) ); |
|
| 64 | + ) ); |
|
| 65 | 65 | |
| 66 | 66 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' ); |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - public static function import_xml() { |
|
| 70 | - $errors = array(); |
|
| 71 | - $message = ''; |
|
| 69 | + public static function import_xml() { |
|
| 70 | + $errors = array(); |
|
| 71 | + $message = ''; |
|
| 72 | 72 | |
| 73 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 74 | - if ( $permission_error !== false ) { |
|
| 75 | - $errors[] = $permission_error; |
|
| 76 | - self::form($errors); |
|
| 77 | - return; |
|
| 78 | - } |
|
| 73 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 74 | + if ( $permission_error !== false ) { |
|
| 75 | + $errors[] = $permission_error; |
|
| 76 | + self::form($errors); |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | - $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 82 | - self::form($errors); |
|
| 83 | - return; |
|
| 84 | - } |
|
| 80 | + if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | + $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 82 | + self::form($errors); |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 86 | + $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 87 | 87 | |
| 88 | - if ( ! is_uploaded_file( $file ) ) { |
|
| 89 | - unset($file); |
|
| 90 | - $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 91 | - self::form($errors); |
|
| 92 | - return; |
|
| 93 | - } |
|
| 88 | + if ( ! is_uploaded_file( $file ) ) { |
|
| 89 | + unset($file); |
|
| 90 | + $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 91 | + self::form($errors); |
|
| 92 | + return; |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 95 | + //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 96 | 96 | |
| 97 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 97 | + $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | 98 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 99 | 99 | ) ); |
| 100 | 100 | |
| 101 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 102 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 103 | - // allow other file types to be imported |
|
| 101 | + $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 102 | + if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 103 | + // allow other file types to be imported |
|
| 104 | 104 | do_action( 'frm_before_import_' . $file_type ); |
| 105 | - return; |
|
| 106 | - } |
|
| 107 | - unset($file_type); |
|
| 105 | + return; |
|
| 106 | + } |
|
| 107 | + unset($file_type); |
|
| 108 | 108 | |
| 109 | 109 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 110 | 110 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -123,145 +123,145 @@ discard block |
||
| 123 | 123 | libxml_use_internal_errors( $set_err ); |
| 124 | 124 | libxml_disable_entity_loader( $loader ); |
| 125 | 125 | |
| 126 | - self::form($errors, $message); |
|
| 127 | - } |
|
| 126 | + self::form($errors, $message); |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - public static function export_xml() { |
|
| 130 | - $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 131 | - if ( ! empty($error) ) { |
|
| 132 | - wp_die( $error ); |
|
| 133 | - } |
|
| 129 | + public static function export_xml() { |
|
| 130 | + $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 131 | + if ( ! empty($error) ) { |
|
| 132 | + wp_die( $error ); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | 135 | $ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() ); |
| 136 | 136 | $type = FrmAppHelper::get_post_param( 'type', array() ); |
| 137 | 137 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
| 138 | 138 | |
| 139 | - if ( ! headers_sent() && ! $type ) { |
|
| 140 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 141 | - die(); |
|
| 142 | - } |
|
| 139 | + if ( ! headers_sent() && ! $type ) { |
|
| 140 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 141 | + die(); |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - if ( $format == 'xml' ) { |
|
| 145 | - self::generate_xml($type, compact('ids')); |
|
| 144 | + if ( $format == 'xml' ) { |
|
| 145 | + self::generate_xml($type, compact('ids')); |
|
| 146 | 146 | } if ( $format == 'csv' ) { |
| 147 | 147 | self::generate_csv( compact('ids') ); |
| 148 | - } else { |
|
| 148 | + } else { |
|
| 149 | 149 | do_action( 'frm_export_format_' . $format, compact('ids') ); |
| 150 | - } |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - wp_die(); |
|
| 153 | - } |
|
| 152 | + wp_die(); |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | 155 | public static function generate_xml( $type, $args = array() ) { |
| 156 | - global $wpdb; |
|
| 156 | + global $wpdb; |
|
| 157 | 157 | |
| 158 | - self::prepare_types_array( $type ); |
|
| 158 | + self::prepare_types_array( $type ); |
|
| 159 | 159 | |
| 160 | - $tables = array( |
|
| 160 | + $tables = array( |
|
| 161 | 161 | 'items' => $wpdb->prefix . 'frm_items', |
| 162 | 162 | 'forms' => $wpdb->prefix . 'frm_forms', |
| 163 | - 'posts' => $wpdb->posts, |
|
| 164 | - 'styles' => $wpdb->posts, |
|
| 165 | - 'actions' => $wpdb->posts, |
|
| 166 | - ); |
|
| 163 | + 'posts' => $wpdb->posts, |
|
| 164 | + 'styles' => $wpdb->posts, |
|
| 165 | + 'actions' => $wpdb->posts, |
|
| 166 | + ); |
|
| 167 | 167 | |
| 168 | 168 | $defaults = array( 'ids' => false ); |
| 169 | - $args = wp_parse_args( $args, $defaults ); |
|
| 169 | + $args = wp_parse_args( $args, $defaults ); |
|
| 170 | 170 | |
| 171 | - $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 171 | + $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 172 | 172 | |
| 173 | - if ( ! empty( $sitename ) ) { |
|
| 173 | + if ( ! empty( $sitename ) ) { |
|
| 174 | 174 | $sitename .= '.'; |
| 175 | 175 | } |
| 176 | - $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 176 | + $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 177 | 177 | |
| 178 | - header( 'Content-Description: File Transfer' ); |
|
| 179 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 180 | - header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 178 | + header( 'Content-Description: File Transfer' ); |
|
| 179 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 180 | + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 181 | 181 | |
| 182 | - //make sure ids are numeric |
|
| 183 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 184 | - $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 185 | - } |
|
| 182 | + //make sure ids are numeric |
|
| 183 | + if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 184 | + $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - $records = array(); |
|
| 187 | + $records = array(); |
|
| 188 | 188 | |
| 189 | 189 | foreach ( $type as $tb_type ) { |
| 190 | - $where = array(); |
|
| 190 | + $where = array(); |
|
| 191 | 191 | $join = ''; |
| 192 | - $table = $tables[ $tb_type ]; |
|
| 192 | + $table = $tables[ $tb_type ]; |
|
| 193 | 193 | |
| 194 | 194 | $select = $table . '.id'; |
| 195 | - $query_vars = array(); |
|
| 195 | + $query_vars = array(); |
|
| 196 | 196 | |
| 197 | - switch ( $tb_type ) { |
|
| 198 | - case 'forms': |
|
| 199 | - //add forms |
|
| 200 | - if ( $args['ids'] ) { |
|
| 197 | + switch ( $tb_type ) { |
|
| 198 | + case 'forms': |
|
| 199 | + //add forms |
|
| 200 | + if ( $args['ids'] ) { |
|
| 201 | 201 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 202 | - } else { |
|
| 202 | + } else { |
|
| 203 | 203 | $where[ $table . '.status !' ] = 'draft'; |
| 204 | - } |
|
| 205 | - break; |
|
| 206 | - case 'actions': |
|
| 204 | + } |
|
| 205 | + break; |
|
| 206 | + case 'actions': |
|
| 207 | 207 | $select = $table . '.ID'; |
| 208 | 208 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 209 | - if ( ! empty($args['ids']) ) { |
|
| 209 | + if ( ! empty($args['ids']) ) { |
|
| 210 | 210 | $where['menu_order'] = $args['ids']; |
| 211 | - } |
|
| 212 | - break; |
|
| 213 | - case 'items': |
|
| 214 | - //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 215 | - if ( $args['ids'] ) { |
|
| 211 | + } |
|
| 212 | + break; |
|
| 213 | + case 'items': |
|
| 214 | + //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 215 | + if ( $args['ids'] ) { |
|
| 216 | 216 | $where[ $table . '.form_id' ] = $args['ids']; |
| 217 | - } |
|
| 218 | - break; |
|
| 219 | - case 'styles': |
|
| 220 | - // Loop through all exported forms and get their selected style IDs |
|
| 217 | + } |
|
| 218 | + break; |
|
| 219 | + case 'styles': |
|
| 220 | + // Loop through all exported forms and get their selected style IDs |
|
| 221 | 221 | $frm_style = new FrmStyle(); |
| 222 | 222 | $default_style = $frm_style->get_default_style(); |
| 223 | - $form_ids = $args['ids']; |
|
| 224 | - $style_ids = array(); |
|
| 225 | - foreach ( $form_ids as $form_id ) { |
|
| 226 | - $form_data = FrmForm::getOne( $form_id ); |
|
| 227 | - // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 228 | - if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 223 | + $form_ids = $args['ids']; |
|
| 224 | + $style_ids = array(); |
|
| 225 | + foreach ( $form_ids as $form_id ) { |
|
| 226 | + $form_data = FrmForm::getOne( $form_id ); |
|
| 227 | + // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 228 | + if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 229 | 229 | if ( $form_data->options['custom_style'] == 1 ) { |
| 230 | 230 | $style_ids[] = $default_style->ID; |
| 231 | 231 | } else { |
| 232 | 232 | $style_ids[] = $form_data->options['custom_style']; |
| 233 | 233 | } |
| 234 | - } |
|
| 235 | - unset( $form_id, $form_data ); |
|
| 236 | - } |
|
| 234 | + } |
|
| 235 | + unset( $form_id, $form_data ); |
|
| 236 | + } |
|
| 237 | 237 | $select = $table . '.ID'; |
| 238 | - $where['post_type'] = 'frm_styles'; |
|
| 239 | - |
|
| 240 | - // Only export selected styles |
|
| 241 | - if ( ! empty( $style_ids ) ) { |
|
| 242 | - $where['ID'] = $style_ids; |
|
| 243 | - } |
|
| 244 | - break; |
|
| 245 | - default: |
|
| 238 | + $where['post_type'] = 'frm_styles'; |
|
| 239 | + |
|
| 240 | + // Only export selected styles |
|
| 241 | + if ( ! empty( $style_ids ) ) { |
|
| 242 | + $where['ID'] = $style_ids; |
|
| 243 | + } |
|
| 244 | + break; |
|
| 245 | + default: |
|
| 246 | 246 | $select = $table . '.ID'; |
| 247 | - $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 248 | - $where['pm.meta_key'] = 'frm_form_id'; |
|
| 249 | - |
|
| 250 | - if ( empty($args['ids']) ) { |
|
| 251 | - $where['pm.meta_value >'] = 1; |
|
| 252 | - } else { |
|
| 253 | - $where['pm.meta_value'] = $args['ids']; |
|
| 254 | - } |
|
| 255 | - break; |
|
| 256 | - } |
|
| 247 | + $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 248 | + $where['pm.meta_key'] = 'frm_form_id'; |
|
| 249 | + |
|
| 250 | + if ( empty($args['ids']) ) { |
|
| 251 | + $where['pm.meta_value >'] = 1; |
|
| 252 | + } else { |
|
| 253 | + $where['pm.meta_value'] = $args['ids']; |
|
| 254 | + } |
|
| 255 | + break; |
|
| 256 | + } |
|
| 257 | 257 | |
| 258 | 258 | $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
| 259 | - unset($tb_type); |
|
| 260 | - } |
|
| 259 | + unset($tb_type); |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
| 263 | 263 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 264 | - } |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | private static function prepare_types_array( &$type ) { |
| 267 | 267 | $type = (array) $type; |
@@ -342,14 +342,14 @@ discard block |
||
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | - * Get the fields that should be included in the CSV export |
|
| 346 | - * |
|
| 347 | - * @since 2.0.19 |
|
| 348 | - * |
|
| 349 | - * @param int $form_id |
|
| 350 | - * @param object $form |
|
| 351 | - * @return array $csv_fields |
|
| 352 | - */ |
|
| 345 | + * Get the fields that should be included in the CSV export |
|
| 346 | + * |
|
| 347 | + * @since 2.0.19 |
|
| 348 | + * |
|
| 349 | + * @param int $form_id |
|
| 350 | + * @param object $form |
|
| 351 | + * @return array $csv_fields |
|
| 352 | + */ |
|
| 353 | 353 | private static function get_fields_for_csv_export( $form_id, $form ) { |
| 354 | 354 | // Phase frm_csv_field_ids out by 2.01.05 |
| 355 | 355 | $csv_field_ids = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) ); |
@@ -379,16 +379,16 @@ discard block |
||
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | public static function allow_mime( $mimes ) { |
| 382 | - if ( ! isset( $mimes['csv'] ) ) { |
|
| 383 | - // allow csv files |
|
| 384 | - $mimes['csv'] = 'text/csv'; |
|
| 385 | - } |
|
| 386 | - |
|
| 387 | - if ( ! isset( $mimes['xml'] ) ) { |
|
| 388 | - // allow xml |
|
| 389 | - $mimes['xml'] = 'text/xml'; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - return $mimes; |
|
| 393 | - } |
|
| 382 | + if ( ! isset( $mimes['csv'] ) ) { |
|
| 383 | + // allow csv files |
|
| 384 | + $mimes['csv'] = 'text/csv'; |
|
| 385 | + } |
|
| 386 | + |
|
| 387 | + if ( ! isset( $mimes['xml'] ) ) { |
|
| 388 | + // allow xml |
|
| 389 | + $mimes['xml'] = 'text/xml'; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + return $mimes; |
|
| 393 | + } |
|
| 394 | 394 | } |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 15 | + $set_err = libxml_use_internal_errors( true ); |
|
| 16 | 16 | $loader = libxml_disable_entity_loader( true ); |
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | 20 | foreach ( (array) $files as $file ) { |
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 21 | + FrmXMLHelper::import_xml( $file ); |
|
| 22 | + unset( $file ); |
|
| 23 | 23 | } |
| 24 | 24 | /* |
| 25 | 25 | if(is_wp_error($result)) |
@@ -70,41 +70,41 @@ discard block |
||
| 70 | 70 | $errors = array(); |
| 71 | 71 | $message = ''; |
| 72 | 72 | |
| 73 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 73 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); |
|
| 74 | 74 | if ( $permission_error !== false ) { |
| 75 | 75 | $errors[] = $permission_error; |
| 76 | - self::form($errors); |
|
| 76 | + self::form( $errors ); |
|
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 80 | + if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | 81 | $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
| 82 | - self::form($errors); |
|
| 82 | + self::form( $errors ); |
|
| 83 | 83 | return; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | $file = $_FILES['frm_import_file']['tmp_name']; |
| 87 | 87 | |
| 88 | 88 | if ( ! is_uploaded_file( $file ) ) { |
| 89 | - unset($file); |
|
| 89 | + unset( $file ); |
|
| 90 | 90 | $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
| 91 | - self::form($errors); |
|
| 91 | + self::form( $errors ); |
|
| 92 | 92 | return; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
| 96 | 96 | |
| 97 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 97 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 98 | 98 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 99 | 99 | ) ); |
| 100 | 100 | |
| 101 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 102 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 101 | + $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
|
| 102 | + if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) { |
|
| 103 | 103 | // allow other file types to be imported |
| 104 | 104 | do_action( 'frm_before_import_' . $file_type ); |
| 105 | 105 | return; |
| 106 | 106 | } |
| 107 | - unset($file_type); |
|
| 107 | + unset( $file_type ); |
|
| 108 | 108 | |
| 109 | 109 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 110 | 110 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -123,12 +123,12 @@ discard block |
||
| 123 | 123 | libxml_use_internal_errors( $set_err ); |
| 124 | 124 | libxml_disable_entity_loader( $loader ); |
| 125 | 125 | |
| 126 | - self::form($errors, $message); |
|
| 126 | + self::form( $errors, $message ); |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | public static function export_xml() { |
| 130 | 130 | $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
| 131 | - if ( ! empty($error) ) { |
|
| 131 | + if ( ! empty( $error ) ) { |
|
| 132 | 132 | wp_die( $error ); |
| 133 | 133 | } |
| 134 | 134 | |
@@ -142,11 +142,11 @@ discard block |
||
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | if ( $format == 'xml' ) { |
| 145 | - self::generate_xml($type, compact('ids')); |
|
| 145 | + self::generate_xml( $type, compact( 'ids' ) ); |
|
| 146 | 146 | } if ( $format == 'csv' ) { |
| 147 | - self::generate_csv( compact('ids') ); |
|
| 147 | + self::generate_csv( compact( 'ids' ) ); |
|
| 148 | 148 | } else { |
| 149 | - do_action( 'frm_export_format_' . $format, compact('ids') ); |
|
| 149 | + do_action( 'frm_export_format_' . $format, compact( 'ids' ) ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | wp_die(); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | foreach ( $type as $tb_type ) { |
| 190 | 190 | $where = array(); |
| 191 | 191 | $join = ''; |
| 192 | - $table = $tables[ $tb_type ]; |
|
| 192 | + $table = $tables[$tb_type]; |
|
| 193 | 193 | |
| 194 | 194 | $select = $table . '.id'; |
| 195 | 195 | $query_vars = array(); |
@@ -200,20 +200,20 @@ discard block |
||
| 200 | 200 | if ( $args['ids'] ) { |
| 201 | 201 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
| 202 | 202 | } else { |
| 203 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 203 | + $where[$table . '.status !'] = 'draft'; |
|
| 204 | 204 | } |
| 205 | 205 | break; |
| 206 | 206 | case 'actions': |
| 207 | 207 | $select = $table . '.ID'; |
| 208 | 208 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 209 | - if ( ! empty($args['ids']) ) { |
|
| 209 | + if ( ! empty( $args['ids'] ) ) { |
|
| 210 | 210 | $where['menu_order'] = $args['ids']; |
| 211 | 211 | } |
| 212 | 212 | break; |
| 213 | 213 | case 'items': |
| 214 | 214 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 215 | 215 | if ( $args['ids'] ) { |
| 216 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 216 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 217 | 217 | } |
| 218 | 218 | break; |
| 219 | 219 | case 'styles': |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
| 248 | 248 | $where['pm.meta_key'] = 'frm_form_id'; |
| 249 | 249 | |
| 250 | - if ( empty($args['ids']) ) { |
|
| 250 | + if ( empty( $args['ids'] ) ) { |
|
| 251 | 251 | $where['pm.meta_value >'] = 1; |
| 252 | 252 | } else { |
| 253 | 253 | $where['pm.meta_value'] = $args['ids']; |
@@ -255,11 +255,11 @@ discard block |
||
| 255 | 255 | break; |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 259 | - unset($tb_type); |
|
| 258 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 259 | + unset( $tb_type ); |
|
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
|
| 262 | + echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n"; |
|
| 263 | 263 | include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
| 264 | 264 | } |
| 265 | 265 | |
@@ -297,10 +297,10 @@ discard block |
||
| 297 | 297 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | - set_time_limit(0); //Remove time limit to execute this function |
|
| 301 | - $mem_limit = str_replace('M', '', ini_get('memory_limit')); |
|
| 300 | + set_time_limit( 0 ); //Remove time limit to execute this function |
|
| 301 | + $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) ); |
|
| 302 | 302 | if ( (int) $mem_limit < 256 ) { |
| 303 | - ini_set('memory_limit', '256M'); |
|
| 303 | + ini_set( 'memory_limit', '256M' ); |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | global $wpdb; |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $no_export_fields = FrmField::no_save_fields(); |
| 371 | 371 | foreach ( $csv_fields as $k => $f ) { |
| 372 | 372 | if ( in_array( $f->type, $no_export_fields ) ) { |
| 373 | - unset( $csv_fields[ $k ] ); |
|
| 373 | + unset( $csv_fields[$k] ); |
|
| 374 | 374 | } |
| 375 | 375 | } |
| 376 | 376 | } |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | * @uses api_request() |
| 71 | 71 | * |
| 72 | 72 | * @param array $_transient_data Update array build by WordPress. |
| 73 | - * @return array Modified update array with custom plugin data. |
|
| 73 | + * @return stdClass Modified update array with custom plugin data. |
|
| 74 | 74 | */ |
| 75 | 75 | public function check_update( $_transient_data ) { |
| 76 | 76 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | $this->version = $_api_data['version']; |
| 44 | 44 | $this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false; |
| 45 | 45 | |
| 46 | - $frm_edd_plugin_data[ $this->slug ] = $this->api_data; |
|
| 46 | + $frm_edd_plugin_data[$this->slug] = $this->api_data; |
|
| 47 | 47 | |
| 48 | 48 | // Set up hooks. |
| 49 | 49 | $this->init(); |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $_transient_data = new stdClass; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) { |
|
| 86 | + if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[$this->name] ) && false === $this->wp_override ) { |
|
| 87 | 87 | return $_transient_data; |
| 88 | 88 | } |
| 89 | 89 | |
@@ -97,12 +97,12 @@ discard block |
||
| 97 | 97 | $version_info->plugin = $this->name; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - $_transient_data->response[ $this->name ] = $version_info; |
|
| 100 | + $_transient_data->response[$this->name] = $version_info; |
|
| 101 | 101 | |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | $_transient_data->last_checked = time(); |
| 105 | - $_transient_data->checked[ $this->name ] = $this->version; |
|
| 105 | + $_transient_data->checked[$this->name] = $this->version; |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | 108 | |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | wp_die( __( 'You do not have permission to install plugin updates', 'formidable' ), __( 'Error', 'formidable' ), array( 'response' => 403 ) ); |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | - $data = $frm_edd_plugin_data[ $_REQUEST['slug'] ]; |
|
| 248 | + $data = $frm_edd_plugin_data[$_REQUEST['slug']]; |
|
| 249 | 249 | $cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_version_info' ); |
| 250 | 250 | $version_info = get_transient( $cache_key ); |
| 251 | 251 | |
@@ -48,7 +48,8 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | private function translate_settings( $settings ) { |
| 51 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 51 | + if ( $settings ) { |
|
| 52 | +//workaround for W3 total cache conflict |
|
| 52 | 53 | return unserialize(serialize($settings)); |
| 53 | 54 | } |
| 54 | 55 | |
@@ -59,7 +60,8 @@ discard block |
||
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | // If unserializing didn't work |
| 62 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 63 | + if ( $settings ) { |
|
| 64 | +//workaround for W3 total cache conflict |
|
| 63 | 65 | $settings = unserialize(serialize($settings)); |
| 64 | 66 | } else { |
| 65 | 67 | $settings = $this; |
@@ -31,19 +31,19 @@ discard block |
||
| 31 | 31 | public $re_multi; |
| 32 | 32 | |
| 33 | 33 | public function __construct() { |
| 34 | - if ( ! defined('ABSPATH') ) { |
|
| 35 | - die('You are not allowed to call this page directly.'); |
|
| 34 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 35 | + die( 'You are not allowed to call this page directly.' ); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - $settings = get_transient($this->option_name); |
|
| 38 | + $settings = get_transient( $this->option_name ); |
|
| 39 | 39 | |
| 40 | - if ( ! is_object($settings) ) { |
|
| 41 | - $settings = $this->translate_settings($settings); |
|
| 40 | + if ( ! is_object( $settings ) ) { |
|
| 41 | + $settings = $this->translate_settings( $settings ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | foreach ( $settings as $setting_name => $setting ) { |
| 45 | 45 | $this->{$setting_name} = $setting; |
| 46 | - unset($setting_name, $setting); |
|
| 46 | + unset( $setting_name, $setting ); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | $this->set_default_options(); |
@@ -51,24 +51,24 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | private function translate_settings( $settings ) { |
| 53 | 53 | if ( $settings ) { //workaround for W3 total cache conflict |
| 54 | - return unserialize(serialize($settings)); |
|
| 54 | + return unserialize( serialize( $settings ) ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $settings = get_option($this->option_name); |
|
| 58 | - if ( is_object($settings) ) { |
|
| 59 | - set_transient($this->option_name, $settings); |
|
| 57 | + $settings = get_option( $this->option_name ); |
|
| 58 | + if ( is_object( $settings ) ) { |
|
| 59 | + set_transient( $this->option_name, $settings ); |
|
| 60 | 60 | return $settings; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | // If unserializing didn't work |
| 64 | 64 | if ( $settings ) { //workaround for W3 total cache conflict |
| 65 | - $settings = unserialize(serialize($settings)); |
|
| 65 | + $settings = unserialize( serialize( $settings ) ); |
|
| 66 | 66 | } else { |
| 67 | 67 | $settings = $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - update_option($this->option_name, $settings); |
|
| 71 | - set_transient($this->option_name, $settings); |
|
| 70 | + update_option( $this->option_name, $settings ); |
|
| 71 | + set_transient( $this->option_name, $settings ); |
|
| 72 | 72 | |
| 73 | 73 | return $settings; |
| 74 | 74 | } |
@@ -104,8 +104,8 @@ discard block |
||
| 104 | 104 | private function set_default_options() { |
| 105 | 105 | $this->fill_recaptcha_settings(); |
| 106 | 106 | |
| 107 | - if ( ! isset($this->load_style) ) { |
|
| 108 | - if ( ! isset($this->custom_style) ) { |
|
| 107 | + if ( ! isset( $this->load_style ) ) { |
|
| 108 | + if ( ! isset( $this->custom_style ) ) { |
|
| 109 | 109 | $this->custom_style = true; |
| 110 | 110 | } |
| 111 | 111 | |
@@ -115,16 +115,16 @@ discard block |
||
| 115 | 115 | $this->fill_with_defaults(); |
| 116 | 116 | |
| 117 | 117 | if ( is_multisite() && is_admin() ) { |
| 118 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 119 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 118 | + $mu_menu = get_site_option( 'frm_admin_menu_name' ); |
|
| 119 | + if ( $mu_menu && ! empty( $mu_menu ) ) { |
|
| 120 | 120 | $this->menu = $mu_menu; |
| 121 | 121 | $this->mu_menu = 1; |
| 122 | 122 | } |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 125 | + $frm_roles = FrmAppHelper::frm_capabilities( 'pro' ); |
|
| 126 | 126 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 127 | - if ( ! isset($this->$frm_role) ) { |
|
| 127 | + if ( ! isset( $this->$frm_role ) ) { |
|
| 128 | 128 | $this->$frm_role = 'administrator'; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -134,9 +134,9 @@ discard block |
||
| 134 | 134 | $settings = $this->default_options(); |
| 135 | 135 | |
| 136 | 136 | foreach ( $settings as $setting => $default ) { |
| 137 | - if ( isset( $params[ 'frm_' . $setting ] ) ) { |
|
| 138 | - $this->{$setting} = $params[ 'frm_' . $setting ]; |
|
| 139 | - } else if ( ! isset($this->{$setting}) ) { |
|
| 137 | + if ( isset( $params['frm_' . $setting] ) ) { |
|
| 138 | + $this->{$setting} = $params['frm_' . $setting]; |
|
| 139 | + } else if ( ! isset( $this->{$setting}) ) { |
|
| 140 | 140 | $this->{$setting} = $default; |
| 141 | 141 | } |
| 142 | 142 | |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $this->{$setting} = $default; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - unset($setting, $default); |
|
| 147 | + unset( $setting, $default ); |
|
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | |
@@ -152,23 +152,23 @@ discard block |
||
| 152 | 152 | $privkey = ''; |
| 153 | 153 | $re_lang = ''; |
| 154 | 154 | |
| 155 | - if ( ! isset($this->pubkey) ) { |
|
| 155 | + if ( ! isset( $this->pubkey ) ) { |
|
| 156 | 156 | // get the options from the database |
| 157 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 158 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 159 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 160 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 157 | + $recaptcha_opt = is_multisite() ? get_site_option( 'recaptcha' ) : get_option( 'recaptcha' ); |
|
| 158 | + $this->pubkey = isset( $recaptcha_opt['pubkey'] ) ? $recaptcha_opt['pubkey'] : ''; |
|
| 159 | + $privkey = isset( $recaptcha_opt['privkey'] ) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 160 | + $re_lang = isset( $recaptcha_opt['re_lang'] ) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 163 | + if ( ! isset( $this->re_msg ) || empty( $this->re_msg ) ) { |
|
| 164 | 164 | $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | - if ( ! isset($this->privkey) ) { |
|
| 167 | + if ( ! isset( $this->privkey ) ) { |
|
| 168 | 168 | $this->privkey = $privkey; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( ! isset($this->re_lang) ) { |
|
| 171 | + if ( ! isset( $this->re_lang ) ) { |
|
| 172 | 172 | $this->re_lang = $re_lang; |
| 173 | 173 | } |
| 174 | 174 | |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | public function update( $params ) { |
| 185 | - $this->fill_with_defaults($params); |
|
| 186 | - $this->update_settings($params); |
|
| 185 | + $this->fill_with_defaults( $params ); |
|
| 186 | + $this->update_settings( $params ); |
|
| 187 | 187 | |
| 188 | 188 | if ( $this->mu_menu ) { |
| 189 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
| 190 | - } else if ( current_user_can('administrator') ) { |
|
| 191 | - update_site_option('frm_admin_menu_name', false); |
|
| 189 | + update_site_option( 'frm_admin_menu_name', $this->menu ); |
|
| 190 | + } else if ( current_user_can( 'administrator' ) ) { |
|
| 191 | + update_site_option( 'frm_admin_menu_name', false ); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - $this->update_roles($params); |
|
| 194 | + $this->update_roles( $params ); |
|
| 195 | 195 | |
| 196 | 196 | do_action( 'frm_update_settings', $params ); |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | private function update_settings( $params ) { |
| 200 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 200 | + $this->mu_menu = isset( $params['frm_mu_menu'] ) ? $params['frm_mu_menu'] : 0; |
|
| 201 | 201 | |
| 202 | - $this->pubkey = trim($params['frm_pubkey']); |
|
| 202 | + $this->pubkey = trim( $params['frm_pubkey'] ); |
|
| 203 | 203 | $this->privkey = $params['frm_privkey']; |
| 204 | 204 | $this->re_type = $params['frm_re_type']; |
| 205 | 205 | $this->re_lang = $params['frm_re_lang']; |
@@ -208,7 +208,7 @@ discard block |
||
| 208 | 208 | $this->load_style = $params['frm_load_style']; |
| 209 | 209 | $this->preview_page_id = (int) $params['frm-preview-page-id']; |
| 210 | 210 | |
| 211 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 211 | + $this->use_html = isset( $params['frm_use_html'] ) ? $params['frm_use_html'] : 0; |
|
| 212 | 212 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
| 213 | 213 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
| 214 | 214 | $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0; |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | $frm_roles = FrmAppHelper::frm_capabilities(); |
| 221 | 221 | $roles = get_editable_roles(); |
| 222 | 222 | foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
| 223 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 223 | + $this->$frm_role = (array) ( isset( $params[$frm_role] ) ? $params[$frm_role] : 'administrator' ); |
|
| 224 | 224 | |
| 225 | 225 | // Make sure administrators always have permissions |
| 226 | 226 | if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | foreach ( $roles as $role => $details ) { |
| 231 | - if ( in_array($role, $this->$frm_role) ) { |
|
| 231 | + if ( in_array( $role, $this->$frm_role ) ) { |
|
| 232 | 232 | $wp_roles->add_cap( $role, $frm_role ); |
| 233 | 233 | } else { |
| 234 | 234 | $wp_roles->remove_cap( $role, $frm_role ); |
@@ -240,10 +240,10 @@ discard block |
||
| 240 | 240 | public function store() { |
| 241 | 241 | // Save the posted value in the database |
| 242 | 242 | |
| 243 | - update_option('frm_options', $this); |
|
| 243 | + update_option( 'frm_options', $this ); |
|
| 244 | 244 | |
| 245 | - delete_transient('frm_options'); |
|
| 246 | - set_transient('frm_options', $this); |
|
| 245 | + delete_transient( 'frm_options' ); |
|
| 246 | + set_transient( 'frm_options', $this ); |
|
| 247 | 247 | |
| 248 | 248 | do_action( 'frm_store_settings' ); |
| 249 | 249 | } |
@@ -1,250 +1,250 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmSettings { |
| 4 | - public $option_name = 'frm_options'; |
|
| 5 | - public $menu; |
|
| 6 | - public $mu_menu; |
|
| 7 | - public $preview_page_id; |
|
| 8 | - public $use_html; |
|
| 9 | - public $jquery_css; |
|
| 10 | - public $accordion_js; |
|
| 4 | + public $option_name = 'frm_options'; |
|
| 5 | + public $menu; |
|
| 6 | + public $mu_menu; |
|
| 7 | + public $preview_page_id; |
|
| 8 | + public $use_html; |
|
| 9 | + public $jquery_css; |
|
| 10 | + public $accordion_js; |
|
| 11 | 11 | public $fade_form; |
| 12 | 12 | |
| 13 | - public $success_msg; |
|
| 14 | - public $blank_msg; |
|
| 15 | - public $unique_msg; |
|
| 16 | - public $invalid_msg; |
|
| 17 | - public $failed_msg; |
|
| 18 | - public $submit_value; |
|
| 19 | - public $login_msg; |
|
| 20 | - public $admin_permission; |
|
| 21 | - |
|
| 22 | - public $email_to; |
|
| 23 | - public $load_style; |
|
| 24 | - public $custom_style; |
|
| 25 | - |
|
| 26 | - public $pubkey; |
|
| 27 | - public $privkey; |
|
| 28 | - public $re_lang; |
|
| 13 | + public $success_msg; |
|
| 14 | + public $blank_msg; |
|
| 15 | + public $unique_msg; |
|
| 16 | + public $invalid_msg; |
|
| 17 | + public $failed_msg; |
|
| 18 | + public $submit_value; |
|
| 19 | + public $login_msg; |
|
| 20 | + public $admin_permission; |
|
| 21 | + |
|
| 22 | + public $email_to; |
|
| 23 | + public $load_style; |
|
| 24 | + public $custom_style; |
|
| 25 | + |
|
| 26 | + public $pubkey; |
|
| 27 | + public $privkey; |
|
| 28 | + public $re_lang; |
|
| 29 | 29 | public $re_type; |
| 30 | - public $re_msg; |
|
| 30 | + public $re_msg; |
|
| 31 | 31 | public $re_multi; |
| 32 | 32 | |
| 33 | - public function __construct() { |
|
| 34 | - if ( ! defined('ABSPATH') ) { |
|
| 35 | - die('You are not allowed to call this page directly.'); |
|
| 36 | - } |
|
| 33 | + public function __construct() { |
|
| 34 | + if ( ! defined('ABSPATH') ) { |
|
| 35 | + die('You are not allowed to call this page directly.'); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - $settings = get_transient($this->option_name); |
|
| 38 | + $settings = get_transient($this->option_name); |
|
| 39 | 39 | |
| 40 | - if ( ! is_object($settings) ) { |
|
| 41 | - $settings = $this->translate_settings($settings); |
|
| 42 | - } |
|
| 40 | + if ( ! is_object($settings) ) { |
|
| 41 | + $settings = $this->translate_settings($settings); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - foreach ( $settings as $setting_name => $setting ) { |
|
| 45 | - $this->{$setting_name} = $setting; |
|
| 46 | - unset($setting_name, $setting); |
|
| 47 | - } |
|
| 44 | + foreach ( $settings as $setting_name => $setting ) { |
|
| 45 | + $this->{$setting_name} = $setting; |
|
| 46 | + unset($setting_name, $setting); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - $this->set_default_options(); |
|
| 50 | - } |
|
| 49 | + $this->set_default_options(); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | 52 | private function translate_settings( $settings ) { |
| 53 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 54 | - return unserialize(serialize($settings)); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - $settings = get_option($this->option_name); |
|
| 58 | - if ( is_object($settings) ) { |
|
| 59 | - set_transient($this->option_name, $settings); |
|
| 60 | - return $settings; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - // If unserializing didn't work |
|
| 64 | - if ( $settings ) { //workaround for W3 total cache conflict |
|
| 65 | - $settings = unserialize(serialize($settings)); |
|
| 66 | - } else { |
|
| 67 | - $settings = $this; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - update_option($this->option_name, $settings); |
|
| 71 | - set_transient($this->option_name, $settings); |
|
| 72 | - |
|
| 73 | - return $settings; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @return array |
|
| 78 | - */ |
|
| 53 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 54 | + return unserialize(serialize($settings)); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + $settings = get_option($this->option_name); |
|
| 58 | + if ( is_object($settings) ) { |
|
| 59 | + set_transient($this->option_name, $settings); |
|
| 60 | + return $settings; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + // If unserializing didn't work |
|
| 64 | + if ( $settings ) { //workaround for W3 total cache conflict |
|
| 65 | + $settings = unserialize(serialize($settings)); |
|
| 66 | + } else { |
|
| 67 | + $settings = $this; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + update_option($this->option_name, $settings); |
|
| 71 | + set_transient($this->option_name, $settings); |
|
| 72 | + |
|
| 73 | + return $settings; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @return array |
|
| 78 | + */ |
|
| 79 | 79 | public function default_options() { |
| 80 | - return array( |
|
| 81 | - 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ), |
|
| 82 | - 'mu_menu' => 0, |
|
| 83 | - 'preview_page_id' => 0, |
|
| 84 | - 'use_html' => true, |
|
| 85 | - 'jquery_css' => false, |
|
| 86 | - 'accordion_js' => false, |
|
| 80 | + return array( |
|
| 81 | + 'menu' => apply_filters( 'frm_default_menu', 'Formidable' ), |
|
| 82 | + 'mu_menu' => 0, |
|
| 83 | + 'preview_page_id' => 0, |
|
| 84 | + 'use_html' => true, |
|
| 85 | + 'jquery_css' => false, |
|
| 86 | + 'accordion_js' => false, |
|
| 87 | 87 | 'fade_form' => false, |
| 88 | 88 | |
| 89 | 89 | 're_multi' => 0, |
| 90 | 90 | |
| 91 | - 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 92 | - 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 93 | - 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 94 | - 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 95 | - 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 96 | - 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 97 | - 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 98 | - 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 91 | + 'success_msg' => __( 'Your responses were successfully submitted. Thank you!', 'formidable' ), |
|
| 92 | + 'blank_msg' => __( 'This field cannot be blank.', 'formidable' ), |
|
| 93 | + 'unique_msg' => __( 'This value must be unique.', 'formidable' ), |
|
| 94 | + 'invalid_msg' => __( 'There was a problem with your submission. Errors are marked below.', 'formidable' ), |
|
| 95 | + 'failed_msg' => __( 'We\'re sorry. It looks like you\'ve already submitted that.', 'formidable' ), |
|
| 96 | + 'submit_value' => __( 'Submit', 'formidable' ), |
|
| 97 | + 'login_msg' => __( 'You do not have permission to view this form.', 'formidable' ), |
|
| 98 | + 'admin_permission' => __( 'You do not have permission to do that', 'formidable' ), |
|
| 99 | 99 | |
| 100 | - 'email_to' => '[admin_email]', |
|
| 101 | - ); |
|
| 102 | - } |
|
| 100 | + 'email_to' => '[admin_email]', |
|
| 101 | + ); |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | 104 | private function set_default_options() { |
| 105 | - $this->fill_recaptcha_settings(); |
|
| 106 | - |
|
| 107 | - if ( ! isset($this->load_style) ) { |
|
| 108 | - if ( ! isset($this->custom_style) ) { |
|
| 109 | - $this->custom_style = true; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - $this->load_style = 'all'; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $this->fill_with_defaults(); |
|
| 116 | - |
|
| 117 | - if ( is_multisite() && is_admin() ) { |
|
| 118 | - $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 119 | - if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 120 | - $this->menu = $mu_menu; |
|
| 121 | - $this->mu_menu = 1; |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 126 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 127 | - if ( ! isset($this->$frm_role) ) { |
|
| 128 | - $this->$frm_role = 'administrator'; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - } |
|
| 105 | + $this->fill_recaptcha_settings(); |
|
| 106 | + |
|
| 107 | + if ( ! isset($this->load_style) ) { |
|
| 108 | + if ( ! isset($this->custom_style) ) { |
|
| 109 | + $this->custom_style = true; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + $this->load_style = 'all'; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $this->fill_with_defaults(); |
|
| 116 | + |
|
| 117 | + if ( is_multisite() && is_admin() ) { |
|
| 118 | + $mu_menu = get_site_option('frm_admin_menu_name'); |
|
| 119 | + if ( $mu_menu && ! empty($mu_menu) ) { |
|
| 120 | + $this->menu = $mu_menu; |
|
| 121 | + $this->mu_menu = 1; |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + $frm_roles = FrmAppHelper::frm_capabilities('pro'); |
|
| 126 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 127 | + if ( ! isset($this->$frm_role) ) { |
|
| 128 | + $this->$frm_role = 'administrator'; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | 133 | public function fill_with_defaults( $params = array() ) { |
| 134 | - $settings = $this->default_options(); |
|
| 134 | + $settings = $this->default_options(); |
|
| 135 | 135 | |
| 136 | - foreach ( $settings as $setting => $default ) { |
|
| 136 | + foreach ( $settings as $setting => $default ) { |
|
| 137 | 137 | if ( isset( $params[ 'frm_' . $setting ] ) ) { |
| 138 | 138 | $this->{$setting} = $params[ 'frm_' . $setting ]; |
| 139 | - } else if ( ! isset($this->{$setting}) ) { |
|
| 140 | - $this->{$setting} = $default; |
|
| 141 | - } |
|
| 139 | + } else if ( ! isset($this->{$setting}) ) { |
|
| 140 | + $this->{$setting} = $default; |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | 143 | if ( $setting == 'menu' && empty( $this->{$setting} ) ) { |
| 144 | 144 | $this->{$setting} = $default; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - unset($setting, $default); |
|
| 148 | - } |
|
| 149 | - } |
|
| 147 | + unset($setting, $default); |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | 150 | |
| 151 | - private function fill_recaptcha_settings() { |
|
| 152 | - $privkey = ''; |
|
| 151 | + private function fill_recaptcha_settings() { |
|
| 152 | + $privkey = ''; |
|
| 153 | 153 | $re_lang = ''; |
| 154 | 154 | |
| 155 | - if ( ! isset($this->pubkey) ) { |
|
| 156 | - // get the options from the database |
|
| 157 | - $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 158 | - $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 159 | - $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 160 | - $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 161 | - } |
|
| 155 | + if ( ! isset($this->pubkey) ) { |
|
| 156 | + // get the options from the database |
|
| 157 | + $recaptcha_opt = is_multisite() ? get_site_option('recaptcha') : get_option('recaptcha'); |
|
| 158 | + $this->pubkey = isset($recaptcha_opt['pubkey']) ? $recaptcha_opt['pubkey'] : ''; |
|
| 159 | + $privkey = isset($recaptcha_opt['privkey']) ? $recaptcha_opt['privkey'] : $privkey; |
|
| 160 | + $re_lang = isset($recaptcha_opt['re_lang']) ? $recaptcha_opt['re_lang'] : $re_lang; |
|
| 161 | + } |
|
| 162 | 162 | |
| 163 | - if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 164 | - $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 165 | - } |
|
| 163 | + if ( ! isset($this->re_msg) || empty($this->re_msg) ) { |
|
| 164 | + $this->re_msg = __( 'The reCAPTCHA was not entered correctly', 'formidable' ); |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - if ( ! isset($this->privkey) ) { |
|
| 168 | - $this->privkey = $privkey; |
|
| 169 | - } |
|
| 167 | + if ( ! isset($this->privkey) ) { |
|
| 168 | + $this->privkey = $privkey; |
|
| 169 | + } |
|
| 170 | 170 | |
| 171 | - if ( ! isset($this->re_lang) ) { |
|
| 172 | - $this->re_lang = $re_lang; |
|
| 173 | - } |
|
| 171 | + if ( ! isset($this->re_lang) ) { |
|
| 172 | + $this->re_lang = $re_lang; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | 175 | if ( ! isset( $this->re_type ) ) { |
| 176 | 176 | $this->re_type = ''; |
| 177 | 177 | } |
| 178 | - } |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - public function validate( $params, $errors ) { |
|
| 181 | - return apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 182 | - } |
|
| 180 | + public function validate( $params, $errors ) { |
|
| 181 | + return apply_filters( 'frm_validate_settings', $errors, $params ); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | 184 | public function update( $params ) { |
| 185 | - $this->fill_with_defaults($params); |
|
| 186 | - $this->update_settings($params); |
|
| 185 | + $this->fill_with_defaults($params); |
|
| 186 | + $this->update_settings($params); |
|
| 187 | 187 | |
| 188 | - if ( $this->mu_menu ) { |
|
| 189 | - update_site_option('frm_admin_menu_name', $this->menu); |
|
| 190 | - } else if ( current_user_can('administrator') ) { |
|
| 191 | - update_site_option('frm_admin_menu_name', false); |
|
| 192 | - } |
|
| 188 | + if ( $this->mu_menu ) { |
|
| 189 | + update_site_option('frm_admin_menu_name', $this->menu); |
|
| 190 | + } else if ( current_user_can('administrator') ) { |
|
| 191 | + update_site_option('frm_admin_menu_name', false); |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - $this->update_roles($params); |
|
| 194 | + $this->update_roles($params); |
|
| 195 | 195 | |
| 196 | - do_action( 'frm_update_settings', $params ); |
|
| 197 | - } |
|
| 196 | + do_action( 'frm_update_settings', $params ); |
|
| 197 | + } |
|
| 198 | 198 | |
| 199 | 199 | private function update_settings( $params ) { |
| 200 | - $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 200 | + $this->mu_menu = isset($params['frm_mu_menu']) ? $params['frm_mu_menu'] : 0; |
|
| 201 | 201 | |
| 202 | - $this->pubkey = trim($params['frm_pubkey']); |
|
| 203 | - $this->privkey = $params['frm_privkey']; |
|
| 202 | + $this->pubkey = trim($params['frm_pubkey']); |
|
| 203 | + $this->privkey = $params['frm_privkey']; |
|
| 204 | 204 | $this->re_type = $params['frm_re_type']; |
| 205 | - $this->re_lang = $params['frm_re_lang']; |
|
| 205 | + $this->re_lang = $params['frm_re_lang']; |
|
| 206 | 206 | $this->re_multi = isset( $params['frm_re_multi'] ) ? $params['frm_re_multi'] : 0; |
| 207 | 207 | |
| 208 | - $this->load_style = $params['frm_load_style']; |
|
| 209 | - $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 208 | + $this->load_style = $params['frm_load_style']; |
|
| 209 | + $this->preview_page_id = (int) $params['frm-preview-page-id']; |
|
| 210 | 210 | |
| 211 | - $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 211 | + $this->use_html = isset($params['frm_use_html']) ? $params['frm_use_html'] : 0; |
|
| 212 | 212 | $this->jquery_css = isset( $params['frm_jquery_css'] ) ? absint( $params['frm_jquery_css'] ) : 0; |
| 213 | 213 | $this->accordion_js = isset( $params['frm_accordion_js'] ) ? absint( $params['frm_accordion_js'] ) : 0; |
| 214 | 214 | $this->fade_form = isset( $params['frm_fade_form'] ) ? absint( $params['frm_fade_form'] ) : 0; |
| 215 | - } |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | 217 | private function update_roles( $params ) { |
| 218 | - global $wp_roles; |
|
| 218 | + global $wp_roles; |
|
| 219 | 219 | |
| 220 | - $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 221 | - $roles = get_editable_roles(); |
|
| 222 | - foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 223 | - $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 220 | + $frm_roles = FrmAppHelper::frm_capabilities(); |
|
| 221 | + $roles = get_editable_roles(); |
|
| 222 | + foreach ( $frm_roles as $frm_role => $frm_role_description ) { |
|
| 223 | + $this->$frm_role = (array) ( isset( $params[ $frm_role ] ) ? $params[ $frm_role ] : 'administrator' ); |
|
| 224 | 224 | |
| 225 | - // Make sure administrators always have permissions |
|
| 226 | - if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 225 | + // Make sure administrators always have permissions |
|
| 226 | + if ( ! in_array( 'administrator', $this->$frm_role ) ) { |
|
| 227 | 227 | array_push( $this->$frm_role, 'administrator' ); |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - foreach ( $roles as $role => $details ) { |
|
| 231 | - if ( in_array($role, $this->$frm_role) ) { |
|
| 232 | - $wp_roles->add_cap( $role, $frm_role ); |
|
| 233 | - } else { |
|
| 234 | - $wp_roles->remove_cap( $role, $frm_role ); |
|
| 235 | - } |
|
| 236 | - } |
|
| 230 | + foreach ( $roles as $role => $details ) { |
|
| 231 | + if ( in_array($role, $this->$frm_role) ) { |
|
| 232 | + $wp_roles->add_cap( $role, $frm_role ); |
|
| 233 | + } else { |
|
| 234 | + $wp_roles->remove_cap( $role, $frm_role ); |
|
| 235 | + } |
|
| 236 | + } |
|
| 237 | 237 | } |
| 238 | - } |
|
| 238 | + } |
|
| 239 | 239 | |
| 240 | 240 | public function store() { |
| 241 | - // Save the posted value in the database |
|
| 241 | + // Save the posted value in the database |
|
| 242 | 242 | |
| 243 | - update_option('frm_options', $this); |
|
| 243 | + update_option('frm_options', $this); |
|
| 244 | 244 | |
| 245 | - delete_transient('frm_options'); |
|
| 246 | - set_transient('frm_options', $this); |
|
| 245 | + delete_transient('frm_options'); |
|
| 246 | + set_transient('frm_options', $this); |
|
| 247 | 247 | |
| 248 | - do_action( 'frm_store_settings' ); |
|
| 249 | - } |
|
| 248 | + do_action( 'frm_store_settings' ); |
|
| 249 | + } |
|
| 250 | 250 | } |