Formidable Forms – Form Builder for WordPress - Version 1.07.05

Version Description

  • Added XML import/export
  • Moved more email settings and bulk form delete to free version
  • Added form edit links to admin bar
  • Removed .required class from required form inputs to minimize conflicts
  • Revert to random entry keys now that data from entries values can be used in filtering views
  • Encode email subject with frm_encode_subject hook to prevent encoding
  • PRO: Allow entries to be edited via csv import when entry ID is included
  • PRO: Expanded conditional logic for email notifications
  • PRO: Allow the frm-field-value shortcode to get the entry ID from the URL. [frm-field-value field_id=x entry_id=id]. Replace "id" with the name of the parameter in your URL
  • PRO: Added separate set of confirmation options for editing
  • PRO: Added option to disable visual tab on each view
  • PRO: Added 'action' parameter back to the frm_redirect_url hook
  • PRO: Added drafts parameter to view shortcode to show draft entries. [display-frm-data id=40 drafts=1]
  • PRO: Switched star ratings to icon font
  • PRO: Added multiple="multiple" into multiple file upload fields
  • PRO: Allow field keys in the exlude_fields shortcode option
  • PRO: Allow updated-at, created-at, updated-by to by used in conditional statements
  • PRO: Added update message and button to global default messages
  • PRO: Added progress bar to csv import
  • PRO: Added frm_csv_line_break filter for changing line breaks in csv export
  • PRO: Change the updated_at and updated_by values when a field is changed with the edit field link
  • PRO: Fixed adding new conditional logic to newly added notifications
  • PRO: Allow "GROUP BY" addition to form in frm_where_filter by rearranging SQL
  • PRO: Don't apply custom display filters to single post page
  • PRO: Fixed showing only file name in views
  • PRO: Removed Pretty Link plugin integration to be placed in an add-on
  • PRO: Added delete_link and confirm parameter to formresults shortcode
  • PRO: Added entry_id, x_title, y_title, start_date, and tooltip_label to graph shortcode options
  • PRO: Allow data from entries fields to be used as x_axis in graphs
  • PRO: Allow field keys in graph shortcode
  • PRO: Add height and line-height to Global Settings
  • PRO: Filter the empty_msg for Views
  • PRO: Added draft status to csv export/import
  • PRO: Check for valid file type when saving a draft
  • PRO: Added sorting on entry listing table for non-post fields
  • PRO: Fixed form pagination with errors and no ajax validation
  • PRO: Changed image to a link when editing an entry with an image
  • PRO: Moved the frm_setup_new_fields_vars hook to fire later when dynamically getting options from a dependent data from entries field
  • PRO: Added frm_get_categories hook
  • PRO: Added frm_jquery_themes hook for creating custom jQuery calendar themes
  • PRO: Added frm_no_data_graph hook for customizing "No Data" message for graphs
Download this release

Release Info

Developer sswells
Plugin Icon 128x128 Formidable Forms – Form Builder for WordPress
Version 1.07.05
Comparing to
See all releases

Code changes from version 1.07.0 to 1.07.05

Files changed (107) hide show
  1. classes/controllers/FrmApiController.php +0 -74
  2. classes/controllers/FrmAppController.php +224 -148
  3. classes/controllers/FrmEntriesController.php +193 -73
  4. classes/controllers/FrmFieldsController.php +79 -70
  5. classes/controllers/FrmFormsController.php +379 -174
  6. classes/controllers/FrmSettingsController.php +57 -30
  7. classes/controllers/FrmStatisticsController.php +11 -7
  8. classes/controllers/FrmUpdatesController.php +0 -538
  9. classes/controllers/FrmXMLController.php +318 -0
  10. classes/helpers/FrmAppHelper.php +123 -109
  11. classes/helpers/FrmEntriesHelper.php +53 -27
  12. classes/helpers/FrmFieldsHelper.php +113 -30
  13. classes/helpers/FrmFormsHelper.php +129 -47
  14. classes/helpers/FrmListHelper.php +45 -73
  15. classes/helpers/FrmSettingsHelper.php +0 -4
  16. classes/helpers/FrmXMLHelper.php +251 -0
  17. classes/models/FrmDb.php +53 -19
  18. classes/models/FrmEntry.php +160 -129
  19. classes/models/FrmEntryMeta.php +225 -165
  20. classes/models/FrmField.php +66 -39
  21. classes/models/FrmForm.php +271 -253
  22. classes/models/FrmNotification.php +55 -47
  23. classes/models/FrmSettings.php +13 -69
  24. classes/models/FrmUpdate.php +0 -361
  25. classes/templates/contact.php +0 -76
  26. classes/views/frm-entries/direct.php +4 -2
  27. classes/views/frm-entries/errors.php +16 -12
  28. classes/views/frm-entries/form.php +18 -15
  29. classes/views/frm-entries/frm-entry.php +39 -50
  30. classes/views/frm-entries/list.php +10 -8
  31. classes/views/frm-entries/new.php +11 -2
  32. classes/views/frm-entries/no_entries.php +10 -10
  33. classes/views/frm-fields/input.php +7 -7
  34. classes/views/frm-fields/radio.php +1 -1
  35. classes/views/frm-fields/single-option.php +5 -5
  36. classes/views/frm-forms/add_field.php +140 -63
  37. classes/views/frm-forms/add_field_links.php +2 -28
  38. classes/views/frm-forms/default-templates.php +7 -7
  39. classes/views/frm-forms/edit.php +11 -19
  40. classes/views/frm-forms/footer.php +0 -35
  41. classes/views/frm-forms/form.php +24 -8
  42. classes/views/frm-forms/insert_form_popup.php +20 -19
  43. classes/views/frm-forms/list.php +4 -189
  44. classes/views/frm-forms/mb_html_tab.php +3 -3
  45. classes/views/frm-forms/mb_insert_fields.php +2 -2
  46. classes/views/frm-forms/new-selection.php +9 -5
  47. classes/views/frm-forms/new.php +10 -13
  48. classes/views/frm-forms/notification.php +29 -19
  49. classes/views/frm-forms/settings.php +70 -80
  50. classes/views/frm-forms/sidebar-settings.php +12 -9
  51. classes/views/frm-forms/translate.php +0 -62
  52. classes/views/frm-settings/form.php +121 -208
  53. classes/views/frm-settings/license_box.php +17 -0
  54. classes/views/frm-settings/styling_tab.php +4 -0
  55. classes/views/frm-statistics/list.php +12 -7
  56. classes/views/frm-statistics/list_displays.php +7 -4
  57. classes/views/shared/errors.php +3 -2
  58. classes/views/shared/form-nav.php +6 -6
  59. classes/views/shared/item-table-nav.php +0 -12
  60. classes/views/shared/nav.php +1 -1
  61. classes/views/shared/pagination.php +0 -52
  62. classes/views/shared/update_message.php +1 -1
  63. classes/views/xml/default-templates.xml +109 -0
  64. classes/views/xml/forms_xml.php +53 -0
  65. classes/views/xml/import_form.php +110 -0
  66. classes/views/xml/xml.php +33 -0
  67. classes/widgets/FrmShowForm.php +10 -10
  68. css/frm_admin.css +537 -143
  69. css/frm_display.css +19 -9
  70. css/frm_fonts.css +34 -0
  71. deprecated.php +35 -0
  72. fonts/s11-fp.eot +0 -0
  73. fonts/s11-fp.svg +36 -0
  74. fonts/s11-fp.ttf +0 -0
  75. fonts/s11-fp.woff +0 -0
  76. formidable.php +46 -91
  77. images/duplicate.png +0 -0
  78. images/form_16-2x.png +0 -0
  79. images/form_16.png +0 -0
  80. images/form_32.png +0 -0
  81. images/form_32_sprite-2x.png +0 -0
  82. images/form_32_sprite.png +0 -0
  83. images/form_nav_bg6.png +0 -0
  84. images/grey_bg.png +0 -0
  85. images/icon.png +0 -0
  86. images/icons.png +0 -0
  87. images/marker.png +0 -0
  88. images/mask.png +0 -0
  89. images/move.png +0 -0
  90. images/report_icon.png +0 -0
  91. images/rte.gif +0 -0
  92. images/tooltip.png +0 -0
  93. images/tooltip_white.png +0 -0
  94. images/tr_icons_white.png +0 -0
  95. images/trash.png +0 -0
  96. images/wheel.png +0 -0
  97. js/bootstrap.min.js +12 -0
  98. js/formidable.js +336 -205
  99. js/formidable.min.js +38 -33
  100. js/formidable_admin.js +767 -273
  101. js/jquery/jquery-ui-themepicker.js +4 -4
  102. js/jquery/jquery.editinplace.js +1 -1
  103. js/jquery/jquery.editinplace.packed.js +1 -1
  104. js/jquery/jquery.placeholder.js +183 -0
  105. languages/formidable-de_DE.mo +0 -0
  106. languages/formidable-de_DE.po +2161 -2151
  107. languages/formidable-en_US.po +236 -487
classes/controllers/FrmApiController.php DELETED
@@ -1,74 +0,0 @@
1
- <?php
2
- /**
3
- * @package Formidable
4
- */
5
-
6
- class FrmApiController{
7
-
8
- /********* DISPLAY DATA *************/
9
- function frm_filter_content($args){
10
- global $frm_entry;
11
- $args = explode(",",$args[1]);
12
-
13
- $form_key = sanitize_title($args[0]);
14
-
15
- $where = '';//" fr.form_key = '$form_key'";
16
- $items = $frm_entry->getAll($where);
17
-
18
- $list = $form_key;
19
- foreach ($items as $item){
20
- $list .= $item->name;
21
- }
22
-
23
- return $list;
24
- }
25
-
26
- function get_frm_items($args = null){
27
- global $frm_entry, $frm_form, $frm_entry_meta;
28
-
29
- $defaults = array(
30
- 'form_key' => '', 'order' => '', 'limit' => '',
31
- 'search' =>'', 'search_type' => '',
32
- 'search_field' => '', 'search_operator' => 'LIKE'
33
- );
34
-
35
- $r = wp_parse_args( $args, $defaults );
36
-
37
- $form = $frm_form->getOne($r['form_key']);
38
-
39
- $where = " (it.form_id='". $form->id ."')";
40
-
41
- if (!($r['order'] == ''))
42
- $r['order'] = " ORDER BY {$r['order']}";
43
-
44
- if (!($r['limit'] == ''))
45
- $r['limit'] = " LIMIT {$r['limit']}";
46
-
47
- if (!($r['search'] == '') and $r['search_type'] == '')
48
- $where .= " and (it.item_key LIKE '%{$r['search']}%' or it.description LIKE '%{$r['search']}%' or it.name LIKE '%{$r['search']}%')";
49
-
50
- $items = $frm_entry->getAll($where, $r['order'], $r['limit']);
51
-
52
- if (!($r['search'] == '') and $r['search_type'] == 'meta'){ //search meta values
53
- $item_ids = $frm_entry_meta->search_entry_metas($r['search'], $r['search_field'], $r['search_operator']);
54
- $item_list = array();
55
- foreach ($items as $item){
56
- if (in_array($item->id, $item_ids))
57
- $item_list[] = $item;
58
- }
59
- return $item_list;
60
- }else
61
- return $items;
62
- }
63
-
64
- function get_frm_item($item_key){
65
- global $frm_entry;
66
- return $frm_entry->getOne( $item_key );
67
- }
68
-
69
- function get_frm_item_by_id($id){
70
- global $frm_entry;
71
- return $frm_entry->getOne( $id );
72
- }
73
-
74
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/controllers/FrmAppController.php CHANGED
@@ -2,19 +2,24 @@
2
  /**
3
  * @package Formidable
4
  */
5
-
 
 
 
 
6
  class FrmAppController{
7
- function FrmAppController(){
8
  add_action('admin_menu', 'FrmAppController::menu', 1);
9
- add_action('admin_head', 'FrmAppController::menu_css');
10
  add_filter('plugin_action_links_formidable/formidable.php', 'FrmAppController::settings_link', 10, 2 );
11
- add_action('after_plugin_row_formidable/formidable.php', 'FrmAppController::pro_action_needed');
12
  add_action('admin_notices', 'FrmAppController::pro_get_started_headline');
13
  add_filter('the_content', 'FrmAppController::page_route', 10);
 
14
  add_action('init', 'FrmAppController::front_head');
15
  add_action('wp_footer', 'FrmAppController::footer_js', 1, 0);
16
  add_action('admin_init', 'FrmAppController::admin_js', 11);
17
- register_activation_hook(FRM_PATH.'/formidable.php', 'FrmAppController::install');
18
  add_action('wp_ajax_frm_install', 'FrmAppController::install');
19
  add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall');
20
  add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize');
@@ -23,14 +28,10 @@ class FrmAppController{
23
  add_action('init', 'FrmAppController::parse_standalone_request', 40);
24
  // Update the session data
25
  add_action('init', 'FrmAppController::referer_session', 1);
26
-
27
- //Shortcodes
28
- add_shortcode('formidable', 'FrmAppController::get_form_shortcode');
29
- add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 9 );
30
  }
31
 
32
  public static function menu(){
33
- global $frmpro_is_installed, $frm_settings;
34
 
35
  if(is_super_admin() and !current_user_can('frm_view_forms')){
36
  global $current_user;
@@ -47,26 +48,35 @@ class FrmAppController{
47
  $pos = apply_filters('frm_menu_position', $pos);
48
 
49
  if(current_user_can('frm_view_forms')){
50
- add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', 'div', $pos);
51
- }else if(current_user_can('frm_view_entries') and $frmpro_is_installed){
52
- add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', 'FrmProEntriesController::route', 'div', $pos);
53
  }
 
 
54
  }
55
 
56
- public static function menu_css(){ ?>
57
- <style type="text/css">#adminmenu .toplevel_page_formidable div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL ?>/form_16.png) no-repeat center;}.menu-icon-frmdisplay .wp-menu-image img{display:none;}
58
- </style>
59
- <?php
60
- //#adminmenu .toplevel_page_formidable:hover div.wp-menu-image{background: url(<?php echo FRM_IMAGES_URL /icon_16.png) no-repeat center;}
61
  }
62
 
63
  public static function get_form_nav($id, $show_nav=false){
64
- global $pagenow;
65
 
66
  $show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
 
 
 
 
 
 
 
 
 
 
 
67
 
68
- if($show_nav)
69
- include(FRM_VIEWS_PATH.'/shared/form-nav.php');
70
  }
71
 
72
  // Adds a settings link to the plugins page
@@ -77,73 +87,109 @@ class FrmAppController{
77
  return $links;
78
  }
79
 
80
- public static function pro_action_needed( $plugin ){
81
- $frm_update = new FrmUpdatesController();
82
- if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed() ){
83
- if (IS_WPMU and $frm_update->pro_wpmu and !FrmAppHelper::is_super_admin())
84
- return;
85
- $frm_update->manually_queue_update();
86
- $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $plugin, 'upgrade-plugin_' . $plugin);
87
- ?>
88
- <td colspan="3" class="plugin-update"><div class="update-message" style="-moz-border-radius:5px;border:1px solid #CC0000;; margin:5px;background-color:#FFEBE8;padding:3px 5px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">', '</a>'); ?></div></td>
89
- <?php
90
- }
 
 
 
 
 
 
 
91
  }
92
 
93
  public static function pro_get_started_headline(){
94
- $frm_update = new FrmUpdatesController();
95
-
 
 
 
 
 
 
96
  // Don't display this error as we're upgrading the thing... cmon
97
  if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
98
  return;
99
 
100
- if (IS_WPMU and !is_super_admin())
101
  return;
102
-
103
  if(!isset($_GET['activate'])){
104
- global $frmpro_is_installed, $frm_db_version;
105
  $db_version = get_option('frm_db_version');
106
- $pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
107
- if(((int)$db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version < 21)){ //this number should match the db_version in FrmDb.php
 
108
  ?>
109
- <div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this or', 'formidable'); ?> <a id="frm_install_link" href="#" onclick="frm_install_now();return false;"><?php _e('Update Now', 'formidable') ?></a></div>
110
  <script type="text/javascript">
111
- function frm_install_now(){
112
- jQuery('#frm_install_link').replaceWith('<img src="<?php echo FRM_IMAGES_URL; ?>/wpspin_light.gif" alt="<?php _e('Loading...', 'formidable'); ?>" />');
113
- jQuery.ajax({type:"POST",url:"<?php echo admin_url('admin-ajax.php') ?>",data:"action=frm_install",
114
- success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
115
- });
116
- };
 
 
117
  </script>
118
  <?php
119
  }
120
  }
121
 
122
- if( $frm_update->pro_is_authorized() and !$frm_update->pro_is_installed()){
123
- $frm_update->manually_queue_update();
124
- $inst_install_url = wp_nonce_url('update.php?action=upgrade-plugin&plugin=' . $frm_update->plugin_name, 'upgrade-plugin_' . $frm_update->plugin_name);
125
  ?>
126
- <div class="error" style="padding:7px;"><?php printf(__('Your Formidable Pro installation isn\'t quite complete yet.<br/>%1$sAutomatically Upgrade to Enable Formidable Pro%2$s', 'formidable'), '<a href="'.$inst_install_url.'">', '</a>'); ?></div>
 
 
 
 
 
 
 
 
 
 
 
127
  <?php
128
  }
129
  }
130
 
131
  public static function admin_js(){
132
- global $frm_version, $pagenow;
133
  wp_enqueue_script('jquery');
134
  wp_enqueue_script('jquery-ui-core');
 
135
 
136
- if(isset($_GET) and (isset($_GET['page']) and preg_match('/formidable*/', $_GET['page'])) or ($pagenow == 'edit.php' and isset($_GET) and isset($_GET['post_type']) and $_GET['post_type'] == 'frm_display')){
 
137
  add_filter('admin_body_class', 'FrmAppController::admin_body_class');
138
 
139
  wp_enqueue_script('jquery-ui-sortable');
140
  wp_enqueue_script('jquery-ui-draggable');
141
  wp_enqueue_script('admin-widgets');
142
  wp_enqueue_style('widgets');
143
- wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
144
  wp_enqueue_script('formidable');
145
- wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
 
 
 
146
  add_thickbox();
 
 
 
 
 
147
  }else if($pagenow == 'post.php' or ($pagenow == 'post-new.php' and isset($_REQUEST['post_type']) and $_REQUEST['post_type'] == 'frm_display')){
148
  if(isset($_REQUEST['post_type'])){
149
  $post_type = $_REQUEST['post_type'];
@@ -157,92 +203,133 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
157
  }
158
 
159
  if($post_type == 'frm_display'){
 
160
  wp_enqueue_script('jquery-ui-draggable');
161
- wp_enqueue_script('formidable_admin', FRM_URL . '/js/formidable_admin.js', array('jquery', 'jquery-ui-draggable'), $frm_version);
162
- wp_enqueue_style('formidable-admin', FRM_URL. '/css/frm_admin.css', array(), $frm_version);
 
163
  }
164
  }
165
  }
166
 
167
  public static function admin_body_class($classes){
168
  global $wp_version;
 
 
169
  if(version_compare( $wp_version, '3.4.9', '>'))
170
  $classes .= ' frm_35_trigger';
171
 
172
  return $classes;
173
  }
174
 
175
- public static function front_head(){
176
- global $frm_settings, $frm_version, $frm_db_version;
 
 
 
177
 
178
- if (IS_WPMU){
179
- global $frmpro_is_installed;
180
- //$frm_db_version is the version of the database we're moving to
 
 
 
 
 
 
 
 
 
 
181
  $old_db_version = get_option('frm_db_version');
182
- $pro_db_version = ($frmpro_is_installed) ? get_option('frmpro_db_version') : false;
183
- if(((int)$old_db_version < (int)$frm_db_version) or ($frmpro_is_installed and (int)$pro_db_version < 21))
 
184
  self::install($old_db_version);
 
185
  }
186
-
187
- wp_register_script('formidable', FRM_URL . '/js/formidable.min.js', array('jquery'), $frm_version, true);
 
 
 
 
188
  wp_register_script('recaptcha-ajax', 'http'. (is_ssl() ? 's' : '').'://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true);
189
  wp_enqueue_script('jquery');
 
190
 
191
- $style = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css');
192
  if($style){
193
  foreach((array)$style as $k => $file){
194
- $k = $k ? 'frm-forms'. $k : 'formidable';
195
- wp_register_style($k, $file, array(), $frm_version);
 
196
  unset($k);
197
  unset($file);
198
  }
199
  }
200
 
201
- if(!is_admin() and $frm_settings->load_style == 'all'){
202
- $css = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css', 'header');
203
- if(is_array($css)){
204
- foreach($css as $css_key => $file)
205
- wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
206
- unset($css_key);
207
- unset($file);
208
- }else
209
- wp_enqueue_style('frm-forms', $css, array(), $frm_version);
210
- unset($css);
211
-
212
- global $frm_css_loaded;
213
- $frm_css_loaded = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
  }
216
 
217
  public static function footer_js($location='footer'){
218
- global $frm_load_css, $frm_settings, $frm_version, $frm_css_loaded, $frm_forms_loaded;
219
 
220
- if($frm_load_css and !is_admin() and ($frm_settings->load_style != 'none')){
221
- if($frm_css_loaded)
222
- $css = apply_filters('get_frm_stylesheet', '', $location);
223
  else
224
- $css = apply_filters('get_frm_stylesheet', FRM_URL .'/css/frm_display.css', $location);
225
 
226
  if(!empty($css)){
227
  echo "\n".'<script type="text/javascript">';
228
- if(is_array($css)){
229
- foreach($css as $css_key => $file){
230
- echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms'. ($css_key + $frm_css_loaded) .'-css\' href=\''. $file. '\' type=\'text/css\' media=\'all\' /%3E"));';
231
- //wp_enqueue_style('frm-forms'.$css_key, $file, array(), $frm_version);
232
- unset($css_key);
233
- unset($file);
234
- }
235
- }else{
236
- echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\'frm-forms-css\' href=\''. $css. '\' type=\'text/css\' media=\'all\' /%3E"));';
237
  }
238
  unset($css);
239
 
240
- //wp_enqueue_style('frm-forms', $css, array(), $frm_version);
241
  echo '</script>'."\n";
242
  }
243
  }
244
 
245
- if(!is_admin() and $location != 'header' and !empty($frm_forms_loaded)) //load formidable js
246
  FrmAppHelper::load_scripts(array('formidable'));
247
  }
248
 
@@ -255,19 +342,12 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
255
  if(is_super_admin()){
256
  global $frmdb;
257
  $frmdb->uninstall();
258
- return true;
259
- //wp_die(__('Formidable was successfully uninstalled.', 'formidable'));
260
  }else{
261
  global $frm_settings;
262
  wp_die($frm_settings->admin_permission);
263
  }
264
- }
265
-
266
- public static function deauthorize(){
267
- delete_option('frmpro-credentials');
268
- delete_option('frmpro-authorized');
269
- delete_site_option('frmpro-credentials');
270
- delete_site_option('frmpro-authorized');
271
  }
272
 
273
  // Routes for wordpress pages -- we're just replacing content here folks.
@@ -282,10 +362,13 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
282
  }
283
 
284
  public static function referer_session() {
285
- global $frm_siteurl, $frm_settings;
286
 
287
  if(!isset($frm_settings->track) or !$frm_settings->track or defined('WP_IMPORTING'))
288
  return;
 
 
 
289
 
290
  if ( !isset($_SESSION) )
291
  session_start();
@@ -296,7 +379,7 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
296
  if ( !isset($_SESSION['frm_http_referer']) or !is_array($_SESSION['frm_http_referer']) )
297
  $_SESSION['frm_http_referer'] = array();
298
 
299
- if (!isset($_SERVER['HTTP_REFERER']) or (isset($_SERVER['HTTP_REFERER']) and (strpos($_SERVER['HTTP_REFERER'], $frm_siteurl) === false) and ! (in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'])) )) {
300
  if (! isset($_SERVER['HTTP_REFERER'])){
301
  $direct = __('Type-in or bookmark', 'formidable');
302
  if(!in_array($direct, $_SESSION['frm_http_referer']))
@@ -309,10 +392,10 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
309
  if ($_SESSION['frm_http_pages'] and !empty($_SESSION['frm_http_pages']) and (end($_SESSION['frm_http_pages']) != "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']))
310
  $_SESSION['frm_http_pages'][] = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
311
 
312
- //keep the page history below 100
313
- if(count($_SESSION['frm_http_pages']) > 100){
314
  foreach($_SESSION['frm_http_pages'] as $pkey => $ppage){
315
- if(count($_SESSION['frm_http_pages']) <= 100)
316
  break;
317
 
318
  unset($_SESSION['frm_http_pages'][$pkey]);
@@ -320,58 +403,37 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
320
  }
321
  }
322
 
323
- // The tight way to process standalone requests dogg...
324
  public static function parse_standalone_request(){
325
- $plugin = FrmAppHelper::get_param('plugin');
326
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
327
  $action = FrmAppHelper::get_param($action);
328
  $controller = FrmAppHelper::get_param('controller');
329
-
330
  if( !empty($plugin) and $plugin == 'formidable' and !empty($controller) ){
331
- self::standalone_route($controller, $action);
332
- die();
333
- }
334
- }
335
-
336
- // Routes for standalone / ajax requests
337
- public static function standalone_route($controller, $action=''){
338
- if($controller == 'forms' and !in_array($action, array('export', 'import', 'xml')))
339
- FrmFormsController::preview(FrmAppHelper::get_param('form'));
340
- else
341
- do_action('frm_standalone_route', $controller, $action);
342
 
343
- do_action('frm_ajax_'. $controller .'_'. $action);
344
- }
345
-
 
346
 
347
- //formidable shortcode
348
- public static function get_form_shortcode($atts){
349
- global $frm_skip_shortcode;
350
- if($frm_skip_shortcode){
351
- $sc = '[formidable';
352
- foreach($atts as $k => $v)
353
- $sc .= ' '. $k .'="'. $v .'"';
354
- return $sc .']';
355
  }
356
-
357
- extract(shortcode_atts(array('id' => '', 'key' => '', 'title' => false, 'description' => false, 'readonly' => false, 'entry_id' => false, 'fields' => array()), $atts));
358
- do_action('formidable_shortcode_atts', compact('id', 'key', 'title', 'description', 'readonly', 'entry_id', 'fields'));
359
- return FrmEntriesController::show_form($id, $key, $title, $description);
360
  }
361
-
362
- //filter form shortcode in text widgets
363
- public static function widget_text_filter( $content ){
364
- $regex = '/\[\s*formidable\s+.*\]/';
365
- return preg_replace_callback( $regex, 'FrmAppController::widget_text_filter_callback', $content );
366
  }
367
 
368
-
369
  public static function widget_text_filter_callback( $matches ) {
370
  return do_shortcode( $matches[0] );
371
  }
372
 
373
  public static function update_message($features){
374
- include(FRM_VIEWS_PATH .'/shared/update_message.php');
375
  }
376
 
377
  public static function get_postbox_class(){
@@ -380,5 +442,19 @@ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
380
  else
381
  return 'inner-sidebar';
382
  }
383
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
384
  }
2
  /**
3
  * @package Formidable
4
  */
5
+ if(!defined('ABSPATH')) die(__('You are not allowed to call this page directly.', 'formidable'));
6
+
7
+ if(class_exists('FrmAppController'))
8
+ return;
9
+
10
  class FrmAppController{
11
+ public static function load_hooks(){
12
  add_action('admin_menu', 'FrmAppController::menu', 1);
13
+ add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
14
  add_filter('plugin_action_links_formidable/formidable.php', 'FrmAppController::settings_link', 10, 2 );
15
+ add_filter('update_plugin_complete_actions', 'FrmAppController::update_action_links', 10, 2 );
16
  add_action('admin_notices', 'FrmAppController::pro_get_started_headline');
17
  add_filter('the_content', 'FrmAppController::page_route', 10);
18
+ add_action('plugins_loaded', 'FrmAppController::load_lang');
19
  add_action('init', 'FrmAppController::front_head');
20
  add_action('wp_footer', 'FrmAppController::footer_js', 1, 0);
21
  add_action('admin_init', 'FrmAppController::admin_js', 11);
22
+ register_activation_hook(FrmAppHelper::plugin_path().'/formidable.php', 'FrmAppController::install');
23
  add_action('wp_ajax_frm_install', 'FrmAppController::install');
24
  add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall');
25
  add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize');
28
  add_action('init', 'FrmAppController::parse_standalone_request', 40);
29
  // Update the session data
30
  add_action('init', 'FrmAppController::referer_session', 1);
 
 
 
 
31
  }
32
 
33
  public static function menu(){
34
+ global $frm_vars, $frm_settings;
35
 
36
  if(is_super_admin() and !current_user_can('frm_view_forms')){
37
  global $current_user;
48
  $pos = apply_filters('frm_menu_position', $pos);
49
 
50
  if(current_user_can('frm_view_forms')){
51
+ add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos);
52
+ }else if(current_user_can('frm_view_entries') and $frm_vars['pro_is_installed']){
53
+ add_menu_page('Formidable', $frm_settings->menu, 'frm_view_entries', 'formidable', 'FrmProEntriesController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos);
54
  }
55
+
56
+ add_filter('admin_body_class', 'FrmAppController::wp_admin_body_class');
57
  }
58
 
59
+ public static function load_wp_admin_style(){
60
+ wp_enqueue_style( 'frm_fonts', FrmAppHelper::plugin_url() .'/css/frm_fonts.css', array(), FrmAppHelper::plugin_version());
 
 
 
61
  }
62
 
63
  public static function get_form_nav($id, $show_nav=false){
64
+ global $pagenow, $frm_vars;
65
 
66
  $show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
67
+ if(!$show_nav)
68
+ return;
69
+
70
+ $current_page = (isset($_GET['page'])) ? $_GET['page'] : (isset($_GET['post_type']) ? $_GET['post_type'] : 'None');
71
+ if($id and is_numeric($id)){
72
+ $frm_form = new FrmForm();
73
+ $form = $frm_form->getOne($id);
74
+ unset($frm_form);
75
+ }else{
76
+ $form = false;
77
+ }
78
 
79
+ include(FrmAppHelper::plugin_path() .'/classes/views/shared/form-nav.php');
 
80
  }
81
 
82
  // Adds a settings link to the plugins page
87
  return $links;
88
  }
89
 
90
+ public static function update_action_links( $actions, $plugin ) {
91
+
92
+ if ( 'formidable/formidable.php' != $plugin )
93
+ return $actions;
94
+
95
+ global $frm_vars;
96
+
97
+ $db_version = get_option('frm_db_version');
98
+ $pro_db_version = $frm_vars['pro_is_installed'] ? get_option('frmpro_db_version') : false;
99
+
100
+ if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
101
+ ( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
102
+
103
+ return sprintf( '<a href="%s">%s</a>', add_query_arg(array('upgraded' => 'true'), menu_page_url( 'formidable', 0 )), __( 'Click here to complete the upgrade', 'formidable' ) );
104
+
105
+ } else {
106
+ return $actions;
107
+ }
108
  }
109
 
110
  public static function pro_get_started_headline(){
111
+ if ( isset($_GET['page']) && 'formidable' == $_GET['page'] && isset( $_REQUEST['upgraded'] ) && 'true' == $_REQUEST['upgraded'] ) {
112
+ self::install();
113
+ ?>
114
+ <div id="message" class="frm_message updated"><?php _e('Congratulations! Formidable is ready to roll.', 'formidable') ?></div>
115
+ <?php
116
+ return;
117
+ }
118
+
119
  // Don't display this error as we're upgrading the thing... cmon
120
  if(isset($_GET['action']) and $_GET['action'] == 'upgrade-plugin')
121
  return;
122
 
123
+ if (is_multisite() and !is_super_admin())
124
  return;
125
+
126
  if(!isset($_GET['activate'])){
127
+ global $frm_vars;
128
  $db_version = get_option('frm_db_version');
129
+ $pro_db_version = ($frm_vars['pro_is_installed']) ? get_option('frmpro_db_version') : false;
130
+ if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
131
+ ( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
132
  ?>
133
+ <div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your Formidable database needs to be updated.<br/>Please deactivate and reactivate the plugin to fix this or', 'formidable'); ?> <a id="frm_install_link" href="javascript:void(0)"><?php _e('Update Now', 'formidable') ?></a></div>
134
  <script type="text/javascript">
135
+ jQuery(document).ready(function($){ $('#frm_install_link').click(function(){frm_install_now()}); });
136
+ function frm_install_now(){
137
+ jQuery('#frm_install_link').replaceWith('<img src="<?php echo FrmAppHelper::plugin_url() ?>/images/wpspin_light.gif" alt="<?php _e('Loading&hellip;') ?>" />');
138
+ jQuery.ajax({
139
+ type:"POST",url:ajaxurl,data:"action=frm_install",
140
+ success:function(msg){jQuery("#frm_install_message").fadeOut("slow");}
141
+ });
142
+ }
143
  </script>
144
  <?php
145
  }
146
  }
147
 
148
+ if ( self::pro_is_authorized() && !self::pro_is_installed()) {
149
+ // user is authorized, but running free version
150
+ $inst_install_url = 'http://formidablepro.com/knowledgebase/manually-install-formidable-pro/';
151
  ?>
152
+ <div class="error" style="padding:7px;"><?php echo apply_filters('frm_pro_update_msg', sprintf(__('This site has been previously authorized to run Formidable Pro.<br/>%1$sInstall the pro version%2$s or %3$sdeauthorize%4$s this site to continue running the free version and remove this message.', 'formidable'), '<a href="'. $inst_install_url .'" target="_blank">', '</a>', '<a href="javascript:void(0)" onclick="frm_deauthorize_now()" class="frm_deauthorize_link">', '</a>'), $inst_install_url); ?></div>
153
+ <script type="text/javascript">
154
+ function frm_deauthorize_now(){
155
+ if(!confirm("<?php esc_attr_e('Are you sure you want to deauthorize Formidable Pro on this site?', 'formidable') ?>"))
156
+ return false;
157
+ jQuery('.frm_deauthorize_link').html('<span class="spinner" style="display:inline-block;margin-top:0;float:none;"></span>');
158
+ jQuery.ajax({type:'POST',url:ajaxurl,data:'action=frm_deauthorize',
159
+ success:function(msg){jQuery('.error').fadeOut('slow');}
160
+ });
161
+ return false;
162
+ }
163
+ </script>
164
  <?php
165
  }
166
  }
167
 
168
  public static function admin_js(){
169
+ global $pagenow;
170
  wp_enqueue_script('jquery');
171
  wp_enqueue_script('jquery-ui-core');
172
+ wp_register_script('bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array('jquery'), '3.0.3');
173
 
174
+ if ( isset($_GET) && (isset($_GET['page']) && preg_match('/formidable*/', $_GET['page'])) || ($pagenow == 'edit.php' && isset($_GET) && isset($_GET['post_type']) && $_GET['post_type'] == 'frm_display') ) {
175
+ $version = FrmAppHelper::plugin_version();
176
  add_filter('admin_body_class', 'FrmAppController::admin_body_class');
177
 
178
  wp_enqueue_script('jquery-ui-sortable');
179
  wp_enqueue_script('jquery-ui-draggable');
180
  wp_enqueue_script('admin-widgets');
181
  wp_enqueue_style('widgets');
 
182
  wp_enqueue_script('formidable');
183
+ wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() .'/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version);
184
+ self::localize_script('admin');
185
+
186
+ wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version);
187
  add_thickbox();
188
+
189
+ wp_register_script('formidable-editinplace', FrmAppHelper::plugin_url() .'/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0');
190
+ wp_register_script('jquery-frm-themepicker', FrmAppHelper::plugin_url() .'/js/jquery/jquery-ui-themepicker.js', array('jquery'), $version);
191
+
192
+
193
  }else if($pagenow == 'post.php' or ($pagenow == 'post-new.php' and isset($_REQUEST['post_type']) and $_REQUEST['post_type'] == 'frm_display')){
194
  if(isset($_REQUEST['post_type'])){
195
  $post_type = $_REQUEST['post_type'];
203
  }
204
 
205
  if($post_type == 'frm_display'){
206
+ $version = FrmAppHelper::plugin_version();
207
  wp_enqueue_script('jquery-ui-draggable');
208
+ wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version);
209
+ wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css', array(), $version);
210
+ self::localize_script('admin');
211
  }
212
  }
213
  }
214
 
215
  public static function admin_body_class($classes){
216
  global $wp_version;
217
+
218
+ //we only need this class on Formidable pages
219
  if(version_compare( $wp_version, '3.4.9', '>'))
220
  $classes .= ' frm_35_trigger';
221
 
222
  return $classes;
223
  }
224
 
225
+ public static function wp_admin_body_class($classes){
226
+ global $wp_version;
227
+ //we need this class everywhere in the admin for the menu
228
+ if(version_compare( $wp_version, '3.7.2', '>'))
229
+ $classes .= ' frm_38_trigger';
230
 
231
+ return $classes;
232
+ }
233
+
234
+ public static function load_lang(){
235
+ load_plugin_textdomain('formidable', false, 'formidable/languages/' );
236
+ }
237
+
238
+ public static function front_head(){
239
+ global $frm_settings;
240
+
241
+ if (is_multisite()){
242
+ global $frm_vars;
243
+
244
  $old_db_version = get_option('frm_db_version');
245
+ $pro_db_version = ($frm_vars['pro_is_installed']) ? get_option('frmpro_db_version') : false;
246
+ if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
247
+ ( $frm_vars['pro_is_installed'] && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
248
  self::install($old_db_version);
249
+ }
250
  }
251
+
252
+ $version = FrmAppHelper::plugin_version();
253
+ wp_register_script('formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array('jquery'), $version, true);
254
+ if(!is_admin() or defined('DOING_AJAX'))
255
+ self::localize_script('front');
256
+
257
  wp_register_script('recaptcha-ajax', 'http'. (is_ssl() ? 's' : '').'://www.google.com/recaptcha/api/js/recaptcha_ajax.js', '', true);
258
  wp_enqueue_script('jquery');
259
+ wp_register_script('jquery-placeholder', FrmAppHelper::plugin_url() .'/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true);
260
 
261
+ $style = apply_filters('get_frm_stylesheet', array('frm-forms' => FrmAppHelper::plugin_url() .'/css/frm_display.css'));
262
  if($style){
263
  foreach((array)$style as $k => $file){
264
+ wp_register_style($k, $file, array(), $version);
265
+ if((!is_admin() or defined('DOING_AJAX')) and $frm_settings->load_style == 'all')
266
+ wp_enqueue_style($k);
267
  unset($k);
268
  unset($file);
269
  }
270
  }
271
 
272
+ if((!is_admin() or defined('DOING_AJAX')) and $frm_settings->load_style == 'all'){
273
+ global $frm_vars;
274
+ $frm_vars['css_loaded'] = true;
275
+ }
276
+ }
277
+
278
+ public static function localize_script($location){
279
+ wp_localize_script('formidable', 'frm_js', array(
280
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
281
+ 'images_url' => FrmAppHelper::plugin_url() .'/images',
282
+ 'loading' => __('Loading&hellip;'),
283
+ 'remove' => __('Remove', 'formidable')
284
+ ));
285
+
286
+ if($location == 'admin'){
287
+ global $frm_settings;
288
+ wp_localize_script('formidable_admin', 'frm_admin_js', array(
289
+ 'confirm_uninstall' => __('Are you sure you want to do this? Clicking OK will delete all forms, form data, and all other Formidable data. There is no Undo.', 'formidable'),
290
+ 'get_page' => (isset($_GET) && isset($_GET['page'])) ? $_GET['page'] : '',
291
+ 'desc' => __('(Click here to add a description or instructions)', 'formidable'),
292
+ 'blank' => __('(Blank)', 'formidable'),
293
+ 'saving' => esc_attr(__('Saving', 'formidable')),
294
+ 'saved' => esc_attr(__('Saved', 'formidable')),
295
+ 'ok' => __('OK'),
296
+ 'cancel' => __('Cancel', 'formidable'),
297
+ 'clear_default' => __('Clear default value when typing', 'formidable'),
298
+ 'no_clear_default' => __('Do not clear default value when typing', 'formidable'),
299
+ 'valid_default' => __('Default value will pass form validation', 'formidable'),
300
+ 'no_valid_default' => __('Default value will NOT pass form validation', 'formidable'),
301
+ 'deauthorize' => __('Are you sure you want to deactivate Formidable Pro on this site?', 'formidable'),
302
+ 'confirm' => __('Are you sure?', 'formidable'),
303
+ 'default_unique' => $frm_settings->unique_msg,
304
+ 'import_complete' => __('Import Complete', 'formidable'),
305
+ ));
306
  }
307
  }
308
 
309
  public static function footer_js($location='footer'){
310
+ global $frm_settings, $frm_vars;
311
 
312
+ if($frm_vars['load_css'] and (!is_admin() or defined('DOING_AJAX')) and ($frm_settings->load_style != 'none')){
313
+ if(isset($frm_vars['css_loaded']) && $frm_vars['css_loaded'])
314
+ $css = apply_filters('get_frm_stylesheet', array());
315
  else
316
+ $css = apply_filters('get_frm_stylesheet', array('frm-forms' => FrmAppHelper::plugin_url() .'/css/frm_display.css'));
317
 
318
  if(!empty($css)){
319
  echo "\n".'<script type="text/javascript">';
320
+ foreach((array)$css as $css_key => $file){
321
+ echo 'jQuery("head").append(unescape("%3Clink rel=\'stylesheet\' id=\''. ($css_key + (isset($frm_vars['css_loaded']) ? $frm_vars['css_loaded'] : false)) .'-css\' href=\''. $file. '\' type=\'text/css\' media=\'all\' /%3E"));';
322
+ //wp_enqueue_style($css_key);
323
+ unset($css_key);
324
+ unset($file);
 
 
 
 
325
  }
326
  unset($css);
327
 
 
328
  echo '</script>'."\n";
329
  }
330
  }
331
 
332
+ if((!is_admin() or defined('DOING_AJAX')) and $location != 'header' and !empty($frm_vars['forms_loaded'])) //load formidable js
333
  FrmAppHelper::load_scripts(array('formidable'));
334
  }
335
 
342
  if(is_super_admin()){
343
  global $frmdb;
344
  $frmdb->uninstall();
345
+ echo true;
 
346
  }else{
347
  global $frm_settings;
348
  wp_die($frm_settings->admin_permission);
349
  }
350
+ die();
 
 
 
 
 
 
351
  }
352
 
353
  // Routes for wordpress pages -- we're just replacing content here folks.
362
  }
363
 
364
  public static function referer_session() {
365
+ global $frm_settings;
366
 
367
  if(!isset($frm_settings->track) or !$frm_settings->track or defined('WP_IMPORTING'))
368
  return;
369
+
370
+ // keep the page history below 100
371
+ $max = 100;
372
 
373
  if ( !isset($_SESSION) )
374
  session_start();
379
  if ( !isset($_SESSION['frm_http_referer']) or !is_array($_SESSION['frm_http_referer']) )
380
  $_SESSION['frm_http_referer'] = array();
381
 
382
+ if (!isset($_SERVER['HTTP_REFERER']) or (isset($_SERVER['HTTP_REFERER']) and (strpos($_SERVER['HTTP_REFERER'], FrmAppHelper::site_url()) === false) and ! (in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'])) )) {
383
  if (! isset($_SERVER['HTTP_REFERER'])){
384
  $direct = __('Type-in or bookmark', 'formidable');
385
  if(!in_array($direct, $_SESSION['frm_http_referer']))
392
  if ($_SESSION['frm_http_pages'] and !empty($_SESSION['frm_http_pages']) and (end($_SESSION['frm_http_pages']) != "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']))
393
  $_SESSION['frm_http_pages'][] = "http://". $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
394
 
395
+ //keep the page history below the max
396
+ if(count($_SESSION['frm_http_pages']) > $max){
397
  foreach($_SESSION['frm_http_pages'] as $pkey => $ppage){
398
+ if(count($_SESSION['frm_http_pages']) <= $max)
399
  break;
400
 
401
  unset($_SESSION['frm_http_pages'][$pkey]);
403
  }
404
  }
405
 
 
406
  public static function parse_standalone_request(){
407
+ $plugin = FrmAppHelper::get_param('plugin');
408
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
409
  $action = FrmAppHelper::get_param($action);
410
  $controller = FrmAppHelper::get_param('controller');
411
+
412
  if( !empty($plugin) and $plugin == 'formidable' and !empty($controller) ){
413
+ _deprecated_function( __FUNCTION__, '1.07.02', 'wp_ajax_nopriv()' );
 
 
 
 
 
 
 
 
 
 
414
 
415
+ if($controller == 'forms')
416
+ FrmFormsController::preview(FrmAppHelper::get_param('form'));
417
+ else
418
+ do_action('frm_standalone_route', $controller, $action);
419
 
420
+ do_action('frm_ajax_'. $controller .'_'. $action);
421
+ die();
 
 
 
 
 
 
422
  }
 
 
 
 
423
  }
424
+
425
+ //formidable shortcode
426
+ public static function get_form_shortcode($atts){
427
+ _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
428
+ return FrmFormsController::get_form_shortcode($atts);
429
  }
430
 
 
431
  public static function widget_text_filter_callback( $matches ) {
432
  return do_shortcode( $matches[0] );
433
  }
434
 
435
  public static function update_message($features){
436
+ include(FrmAppHelper::plugin_path() .'/classes/views/shared/update_message.php');
437
  }
438
 
439
  public static function get_postbox_class(){
442
  else
443
  return 'inner-sidebar';
444
  }
445
+
446
+ public static function pro_is_installed(){
447
+ return file_exists(FrmAppHelper::plugin_path() . '/pro/formidable-pro.php');
448
+ }
449
+
450
+ public static function pro_is_authorized(){
451
+ return get_site_option('frmpro-authorized');
452
+ }
453
+
454
+ public static function deauthorize(){
455
+ delete_option('frmpro-credentials');
456
+ delete_option('frmpro-authorized');
457
+ delete_site_option('frmpro-credentials');
458
+ delete_site_option('frmpro-authorized');
459
+ }
460
  }
classes/controllers/FrmEntriesController.php CHANGED
@@ -3,27 +3,32 @@
3
  * @package Formidable
4
  */
5
 
 
 
 
 
 
6
  class FrmEntriesController{
7
 
8
- function FrmEntriesController(){
9
- add_action('admin_menu', 'FrmEntriesController::menu', 20);
10
  add_action('wp', 'FrmEntriesController::process_entry', 10, 0);
11
  add_action('frm_wp', 'FrmEntriesController::process_entry', 10, 0);
12
- add_filter('frm_redirect_msg', 'FrmEntriesController::delete_entry_before_redirect', 50, 3);
13
- add_filter('frm_redirect_url', 'FrmEntriesController::delete_entry_before_wpredirect', 50, 3);
14
  add_action('frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100);
15
  add_filter('frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3);
16
  }
17
 
18
  public static function menu(){
19
- global $frmpro_is_installed;
20
- if(!$frmpro_is_installed){
21
  add_submenu_page('formidable', 'Formidable |'. __('Entries', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Entries', 'formidable') .'</span>', 'administrator', 'formidable-entries', 'FrmEntriesController::list_entries');
22
  }
23
  }
24
 
25
  public static function list_entries(){
26
- global $frm_form, $frm_entry;
 
27
  $form_select = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name');
28
  $form_id = FrmAppHelper::get_param('form', false);
29
  if($form_id)
@@ -34,95 +39,57 @@ class FrmEntriesController{
34
  if($form)
35
  $entry_count = $frm_entry->getRecordCount($form->id);
36
 
37
- include(FRM_VIEWS_PATH.'/frm-entries/list.php');
38
  }
39
 
40
  public static function show_form($id='', $key='', $title=false, $description=false){
41
- global $frm_form, $user_ID, $frm_settings, $post;
42
- if ($id) $form = $frm_form->getOne((int)$id);
43
- else if ($key) $form = $frm_form->getOne($key);
44
- else $form = false;
45
-
46
- $form = apply_filters('frm_pre_display_form', $form);
47
-
48
- if(!$form or
49
- (($form->is_template or $form->status == 'draft') and !isset($_GET) and !isset($_GET['form']) and
50
- (!isset($_GET['preview']) or $post and $post->ID != $frm_settings->preview_page_id))
51
- ){
52
- return __('Please select a valid form', 'formidable');
53
- }else if ($form->logged_in and !$user_ID){
54
- global $frm_settings;
55
- return do_shortcode($frm_settings->login_msg);
56
- }
57
-
58
- if($form->logged_in and $user_ID and isset($form->options['logged_in_role']) and $form->options['logged_in_role'] != ''){
59
- if(FrmAppHelper::user_has_permission($form->options['logged_in_role'])){
60
- return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
61
- }else{
62
- global $frm_settings;
63
- return do_shortcode($frm_settings->login_msg);
64
- }
65
- }else
66
- return FrmEntriesController::get_form(FRM_VIEWS_PATH.'/frm-entries/frm-entry.php', $form, $title, $description);
67
  }
68
 
69
  public static function get_form($filename, $form, $title, $description) {
70
- if (is_file($filename)) {
71
- ob_start();
72
- include $filename;
73
- $contents = ob_get_contents();
74
- ob_end_clean();
75
- return $contents;
76
- }
77
- return false;
78
  }
79
 
80
- public static function process_entry($errors=''){
81
- if(is_admin() or !isset($_POST) or !isset($_POST['form_id']) or !is_numeric($_POST['form_id']) or !isset($_POST['item_key']))
82
  return;
83
 
84
- global $frm_entry, $frm_form, $frm_created_entry, $frm_form_params;
85
 
 
86
  $form = $frm_form->getOne($_POST['form_id']);
87
  if(!$form)
88
  return;
89
 
90
- if(!$frm_form_params)
91
- $frm_form_params = array();
92
  $params = FrmEntriesController::get_params($form);
93
- $frm_form_params[$form->id] = $params;
94
 
95
- if(!$frm_created_entry)
96
- $frm_created_entry = array();
97
-
98
- if(isset($frm_created_entry[$_POST['form_id']]))
 
99
  return;
100
-
101
  if($errors == '')
102
  $errors = $frm_entry->validate($_POST);
103
- $frm_created_entry[$_POST['form_id']] = array('errors' => $errors);
104
 
105
  if( empty($errors) ){
106
  $_POST['frm_skip_cookie'] = 1;
107
  if($params['action'] == 'create'){
108
- if (apply_filters('frm_continue_to_create', true, $_POST['form_id']) and !isset($frm_created_entry[$_POST['form_id']]['entry_id']))
109
- $frm_created_entry[$_POST['form_id']]['entry_id'] = $frm_entry->create( $_POST );
110
  }
111
 
112
- do_action('frm_process_entry', $params, $errors, $form);
113
  unset($_POST['frm_skip_cookie']);
114
  }
115
  }
116
 
117
- //Delete entry if it shouldn't be saved before redirect
118
- public static function delete_entry_before_redirect($redirect_msg, $atts){
119
- self::_delete_entry($atts['entry_id'], $atts['form']);
120
- return $redirect_msg;
121
- }
122
-
123
- public static function delete_entry_before_wpredirect($url, $form, $atts){
124
- if(!defined('DOING_AJAX'))
125
- self::_delete_entry($atts['id'], $form);
126
  return $url;
127
  }
128
 
@@ -142,9 +109,159 @@ class FrmEntriesController{
142
  }
143
  }
144
 
145
- public static function &filter_email_value($value, $meta, $entry, $atts=array()){
146
- global $frm_field;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  $field = $frm_field->getOne($meta->field_id);
149
  if(!$field)
150
  return $value;
@@ -195,13 +312,16 @@ class FrmEntriesController{
195
  }
196
 
197
  public static function get_params($form=null){
198
- global $frm_form, $frm_form_params;
199
-
 
200
  if(!$form)
201
  $form = $frm_form->getAll(array(), 'name', 1);
202
-
203
- if($frm_form_params and isset($frm_form_params[$form->id]))
204
- return $frm_form_params[$form->id];
 
 
205
 
206
  $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
207
  $action = apply_filters('frm_show_new_entry_page', FrmAppHelper::get_param($action_var, 'new'), $form);
3
  * @package Formidable
4
  */
5
 
6
+ if(!defined('ABSPATH')) die(__('You are not allowed to call this page directly.', 'formidable'));
7
+
8
+ if(class_exists('FrmEntriesController'))
9
+ return;
10
+
11
  class FrmEntriesController{
12
 
13
+ public static function load_hooks(){
14
+ add_action('admin_menu', 'FrmEntriesController::menu', 11);
15
  add_action('wp', 'FrmEntriesController::process_entry', 10, 0);
16
  add_action('frm_wp', 'FrmEntriesController::process_entry', 10, 0);
17
+ add_filter('frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3);
 
18
  add_action('frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100);
19
  add_filter('frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3);
20
  }
21
 
22
  public static function menu(){
23
+ global $frm_vars;
24
+ if(!$frm_vars['pro_is_installed']){
25
  add_submenu_page('formidable', 'Formidable |'. __('Entries', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Entries', 'formidable') .'</span>', 'administrator', 'formidable-entries', 'FrmEntriesController::list_entries');
26
  }
27
  }
28
 
29
  public static function list_entries(){
30
+ global $frm_entry;
31
+ $frm_form = new FrmForm();
32
  $form_select = $frm_form->getAll("is_template=0 AND (status is NULL OR status = '' OR status = 'published')", ' ORDER BY name');
33
  $form_id = FrmAppHelper::get_param('form', false);
34
  if($form_id)
39
  if($form)
40
  $entry_count = $frm_entry->getRecordCount($form->id);
41
 
42
+ include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/list.php');
43
  }
44
 
45
  public static function show_form($id='', $key='', $title=false, $description=false){
46
+ _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::show_form()' );
47
+ FrmFormsController::show_form($id, $key, $title, $description);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
 
50
  public static function get_form($filename, $form, $title, $description) {
51
+ _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form()' );
52
+ FrmFormsController::get_form($form, $title, $description);
 
 
 
 
 
 
53
  }
54
 
55
+ public static function process_entry($errors='', $ajax=false){
56
+ if((is_admin() and !defined('DOING_AJAX')) or !isset($_POST) or !isset($_POST['form_id']) or !is_numeric($_POST['form_id']) or !isset($_POST['item_key']))
57
  return;
58
 
59
+ global $frm_entry, $frm_vars;
60
 
61
+ $frm_form = new FrmForm();
62
  $form = $frm_form->getOne($_POST['form_id']);
63
  if(!$form)
64
  return;
65
 
 
 
66
  $params = FrmEntriesController::get_params($form);
 
67
 
68
+ if(!isset($frm_vars['form_params']))
69
+ $frm_vars['form_params'] = array();
70
+ $frm_vars['form_params'][$form->id] = $params;
71
+
72
+ if(isset($frm_vars['created_entries'][$_POST['form_id']]))
73
  return;
74
+
75
  if($errors == '')
76
  $errors = $frm_entry->validate($_POST);
77
+ $frm_vars['created_entries'][$_POST['form_id']] = array('errors' => $errors);
78
 
79
  if( empty($errors) ){
80
  $_POST['frm_skip_cookie'] = 1;
81
  if($params['action'] == 'create'){
82
+ if (apply_filters('frm_continue_to_create', true, $_POST['form_id']) and !isset($frm_vars['created_entries'][$_POST['form_id']]['entry_id']))
83
+ $frm_vars['created_entries'][$_POST['form_id']]['entry_id'] = $frm_entry->create( $_POST );
84
  }
85
 
86
+ do_action('frm_process_entry', $params, $errors, $form, array('ajax' => $ajax));
87
  unset($_POST['frm_skip_cookie']);
88
  }
89
  }
90
 
91
+ public static function delete_entry_before_redirect($url, $form, $atts){
92
+ self::_delete_entry($atts['id'], $form);
 
 
 
 
 
 
 
93
  return $url;
94
  }
95
 
109
  }
110
  }
111
 
112
+ public static function show_entry_shortcode($atts){
113
+ extract(shortcode_atts(array(
114
+ 'id' => false, 'entry' => false, 'fields' => false, 'plain_text' => false,
115
+ 'user_info' => false, 'include_blank' => false, 'default_email' => false,
116
+ 'form_id' => false, 'format' => 'text',
117
+ ), $atts));
118
+
119
+ if ( $format != 'text' ) {
120
+ //format options are text, array, or json
121
+ $plain_text = true;
122
+ }
123
+
124
+ global $frm_entry;
125
+
126
+ if ( !$entry || !is_object($entry) ) {
127
+ if ( !$id && !$default_email ) {
128
+ return '';
129
+ }
130
+
131
+ if($id)
132
+ $entry = $frm_entry->getOne($id, true);
133
+ }
134
+
135
+ if ( $entry ) {
136
+ $form_id = $entry->form_id;
137
+ $id = $entry->id;
138
+ }
139
 
140
+ if ( !$fields || !is_array($fields) ) {
141
+ global $frm_field;
142
+ $fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order');
143
+ }
144
+
145
+ $content = ( $format != 'text' ) ? array() : '';
146
+ $odd = true;
147
+
148
+ if ( !$plain_text ) {
149
+ global $frmpro_settings;
150
+ if ( !$frmpro_settings ) {
151
+ $frmpro_settings = array(
152
+ 'field_border_width' => '1px',
153
+ 'border_color' => 'dddddd',
154
+ 'bg_color' => 'f7f7f7',
155
+ 'bg_color_active' => 'ffffff',
156
+ 'text_color' => '444444',
157
+ );
158
+ $frmpro_settings = (object) $frmpro_settings;
159
+ }
160
+ $content .= "<table cellspacing='0' style='font-size:{$frmpro_settings->font_size};line-height:135%; border-bottom:{$frmpro_settings->field_border_width} solid #{$frmpro_settings->border_color};'><tbody>\r\n";
161
+ $bg_color = " style='background-color:#{$frmpro_settings->bg_color};'";
162
+ $bg_color_alt = " style='background-color:#{$frmpro_settings->bg_color_active};'";
163
+ $row_style = "style='text-align:left;color:#{$frmpro_settings->text_color};padding:7px 9px;border-top:{$frmpro_settings->field_border_width} solid #{$frmpro_settings->border_color}'";
164
+ }
165
+
166
+ foreach ( $fields as $f ) {
167
+ if ( in_array($f->type, array('divider', 'captcha', 'break', 'html')) )
168
+ continue;
169
+
170
+ if ( !isset($entry->metas[$f->id]) ) {
171
+ if ( $entry->post_id && ( $f->type == 'tag' || (isset($f->field_options['post_field']) && $f->field_options['post_field'])) ) {
172
+ $p_val = FrmProEntryMetaHelper::get_post_value($entry->post_id, $f->field_options['post_field'], $f->field_options['custom_field'], array(
173
+ 'truncate' => (($f->field_options['post_field'] == 'post_category') ? true : false),
174
+ 'form_id' => $entry->form_id, 'field' => $f, 'type' => $f->type,
175
+ 'exclude_cat' => (isset($f->field_options['exclude_cat']) ? $f->field_options['exclude_cat'] : 0)
176
+ ));
177
+ if ( $p_val != '' ) {
178
+ $entry->metas[$f->id] = $p_val;
179
+ }
180
+ }
181
+
182
+ if ( !isset($entry->metas[$f->id]) && !$include_blank && !$default_email ) {
183
+ continue;
184
+ }
185
+
186
+ $entry->metas[$f->id] = $default_email ? '['. $f->id .']' : '';
187
+ }
188
+
189
+ $prev_val = maybe_unserialize($entry->metas[$f->id]);
190
+ $meta = array('item_id' => $id, 'field_id' => $f->id, 'meta_value' => $prev_val, 'field_type' => $f->type);
191
+
192
+ if ( $default_email ) {
193
+ $val = $prev_val;
194
+ } else {
195
+ $val = apply_filters('frm_email_value', $prev_val, (object)$meta, $entry);
196
+ }
197
+
198
+ if ( $f->type == 'textarea' and !$plain_text ) {
199
+ $val = str_replace(array("\r\n", "\r", "\n"), ' <br/>', $val);
200
+ }
201
+
202
+ if ( is_array($val) && $format == 'text' ) {
203
+ $val = implode(', ', $val);
204
+ }
205
+
206
+ $fname = $default_email ? '['. $f->id .' show=field_label]' : $f->name;
207
+
208
+ if ( $format != 'text' ){
209
+ $content[$f->field_key] = $val;
210
+ } else if ( $plain_text ) {
211
+ $content .= $fname . ': ' . $val . "\r\n\r\n";
212
+ } else {
213
+ if (!$default_email){
214
+ $content .= "<tr".(($odd) ? $bg_color : $bg_color_alt)."><th $row_style>" . $fname ."</th><td $row_style>$val</td></tr>\r\n";
215
+ $odd = ($odd) ? false : true;
216
+ }else{
217
+ $content .= "[if $f->id]<tr style=\"[frm-alt-color]\"><th $row_style>" . $fname ."</th><td $row_style>$val</td></tr>\r\n[/if $f->id]";
218
+ }
219
+
220
+ }
221
+
222
+ unset($fname);
223
+ unset($f);
224
+ }
225
+
226
+ if ( $user_info ) {
227
+ if ( isset($entry->description) ) {
228
+ $data = maybe_unserialize($entry->description);
229
+ } else if ( $default_email ) {
230
+ $entry->ip = '[ip]';
231
+ $data = array(
232
+ 'browser' => '[browser]',
233
+ 'referrer' => '[referrer]',
234
+ );
235
+ }
236
+ if ( $format != 'text' ) {
237
+ $content['ip'] = $entry->ip;
238
+ $content['browser'] = $data['browser'];
239
+ $content['referrer'] = $data['referrer'];
240
+ } else if ( $plain_text ) {
241
+ $content .= "\r\n\r\n" . __('User Information', 'formidable') ."\r\n";
242
+ $content .= __('IP Address', 'formidable') . ": ". $entry->ip ."\r\n";
243
+ $content .= __('User-Agent (Browser/OS)', 'formidable') . ": ". $data['browser']."\r\n";
244
+ $content .= __('Referrer', 'formidable') . ": ". $data['referrer']."\r\n";
245
+ } else {
246
+ $content .= "<tr".(($odd) ? $bg_color : $bg_color_alt)."><th $row_style>". __('IP Address', 'formidable') . "</th><td $row_style>". $entry->ip ."</td></tr>\r\n";
247
+ $odd = ($odd) ? false : true;
248
+ $content .= "<tr".(($odd) ? $bg_color : $bg_color_alt)."><th $row_style>".__('User-Agent (Browser/OS)', 'formidable') . "</th><td $row_style>". $data['browser']."</td></tr>\r\n";
249
+ $odd = ($odd) ? false : true;
250
+ $content .= "<tr".(($odd) ? $bg_color : $bg_color_alt)."><th $row_style>".__('Referrer', 'formidable') . "</th><td $row_style>". str_replace("\r\n", '<br/>', $data['referrer']) ."</td></tr>\r\n";
251
+ }
252
+ }
253
+
254
+ if(!$plain_text)
255
+ $content .= "</tbody></table>";
256
+
257
+ if ( $format == 'json' )
258
+ $content = json_encode($content);
259
+
260
+ return $content;
261
+ }
262
+
263
+ public static function &filter_email_value($value, $meta, $entry, $atts=array()){
264
+ $frm_field = new FrmField();
265
  $field = $frm_field->getOne($meta->field_id);
266
  if(!$field)
267
  return $value;
312
  }
313
 
314
  public static function get_params($form=null){
315
+ global $frm_vars;
316
+
317
+ $frm_form = new FrmForm();
318
  if(!$form)
319
  $form = $frm_form->getAll(array(), 'name', 1);
320
+ else if(!is_object($form))
321
+ $form = $frm_form->getOne($form);
322
+
323
+ if(isset($frm_vars['form_params']) && is_array($frm_vars['form_params']) && isset($frm_vars['form_params'][$form->id]))
324
+ return $frm_vars['form_params'][$form->id];
325
 
326
  $action_var = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
327
  $action = apply_filters('frm_show_new_entry_page', FrmAppHelper::get_param($action_var, 'new'), $form);
classes/controllers/FrmFieldsController.php CHANGED
@@ -2,14 +2,18 @@
2
  /**
3
  * @package Formidable
4
  */
 
 
 
 
 
5
 
6
  class FrmFieldsController{
7
- function FrmFieldsController(){
8
  add_action('wp_ajax_frm_load_field', 'FrmFieldsController::load_field');
9
  add_action('wp_ajax_frm_insert_field', 'FrmFieldsController::create');
10
  add_action('wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name');
11
  add_action('wp_ajax_frm_field_desc_in_place_edit', 'FrmFieldsController::edit_description');
12
- add_action('wp_ajax_frm_mark_required', 'FrmFieldsController::mark_required');
13
  add_action('wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option');
14
  add_action('wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate');
15
  add_action('wp_ajax_frm_delete_field', 'FrmFieldsController::destroy');
@@ -27,8 +31,6 @@ class FrmFieldsController{
27
  }
28
 
29
  public static function load_field(){
30
- global $frm_field, $frm_form;
31
-
32
  $id = $field_id = $_POST['field_id'];
33
  if(!$field_id or !is_numeric($field_id))
34
  die();
@@ -40,43 +42,43 @@ class FrmFieldsController{
40
  $field['value'] = '';
41
 
42
  $field_name = "item_meta[$field_id]";
43
-
44
  $values = array();
45
-
46
- include(FRM_VIEWS_PATH .'/frm-forms/add_field.php');
47
- include(FRM_VIEWS_PATH .'/frm-forms/new-field-js.php');
 
 
48
 
49
  die();
50
  }
51
 
52
  public static function create(){
53
- global $frm_field;
54
  $field_data = $_POST['field'];
55
  $form_id = $_POST['form_id'];
56
  $values = array();
57
  if(class_exists('FrmProForm'))
58
- $values['post_type'] = FrmProForm::post_type($form_id);
59
 
60
  $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
61
 
 
62
  $field_id = $frm_field->create( $field_values );
63
 
64
  if ($field_id){
65
  $field = FrmFieldsHelper::setup_edit_vars($frm_field->getOne($field_id));
66
  $field_name = "item_meta[$field_id]";
67
  $id = $form_id;
68
- require(FRM_VIEWS_PATH.'/frm-forms/add_field.php');
69
- require(FRM_VIEWS_PATH.'/frm-forms/new-field-js.php');
70
  }
71
  die();
72
  }
73
 
74
  public static function edit_name(){
75
- global $frm_field;
76
  $id = str_replace('field_label_', '', $_POST['element_id']);
77
  $values = array('name' => trim($_POST['update_value']));
78
- if ($_POST['original_html'] == 'Untitled')
79
- $values['field_key'] = $_POST['update_value'];
80
  $form = $frm_field->update($id, $values);
81
  echo stripslashes($_POST['update_value']);
82
  die();
@@ -84,23 +86,16 @@ class FrmFieldsController{
84
 
85
 
86
  public static function edit_description(){
87
- global $frm_field;
88
  $id = str_replace('field_description_', '', $_POST['element_id']);
89
  $frm_field->update($id, array('description' => $_POST['update_value']));
90
  echo stripslashes($_POST['update_value']);
91
  die();
92
- }
93
-
94
- public static function mark_required(){
95
- global $frm_field;
96
- $frm_field->update($_POST['field'], array('required' => $_POST['required']));
97
- die();
98
  }
99
 
100
  public static function update_ajax_option(){
101
- global $frm_field;
102
  $field = $frm_field->getOne($_POST['field']);
103
- $field->field_options = maybe_unserialize($field->field_options);
104
  foreach(array('clear_on_focus', 'separate_value', 'default_blank') as $val){
105
  if(isset($_POST[$val])){
106
  $new_val = $_POST[$val];
@@ -118,19 +113,20 @@ class FrmFieldsController{
118
  }
119
 
120
  public static function duplicate(){
121
- global $frmdb, $frm_field;
122
 
 
123
  $copy_field = $frm_field->getOne($_POST['field_id']);
124
  if (!$copy_field) return;
125
 
126
  $values = array();
127
- $values['field_key'] = FrmAppHelper::get_unique_key('', $frmdb->fields, 'field_key');
128
  $values['options'] = maybe_serialize($copy_field->options);
129
  $values['default_value'] = maybe_serialize($copy_field->default_value);
130
  $values['form_id'] = $copy_field->form_id;
131
  foreach (array('name', 'description', 'type', 'field_options', 'required') as $col)
132
  $values[$col] = $copy_field->{$col};
133
- $field_count = FrmAppHelper::getRecordCount("form_id='$copy_field->form_id'", $frmdb->fields);
134
  $values['field_order'] = $field_count + 1;
135
 
136
  $field_id = $frm_field->create($values);
@@ -141,21 +137,21 @@ class FrmFieldsController{
141
  $id = $field['form_id'];
142
  if($field['type'] == 'html')
143
  $field['stop_filter'] = true;
144
- require(FRM_VIEWS_PATH.'/frm-forms/add_field.php');
145
- require(FRM_VIEWS_PATH.'/frm-forms/new-field-js.php');
146
  }
147
  die();
148
  }
149
 
150
  public static function destroy(){
151
- global $frm_field;
152
  $field_id = $frm_field->destroy($_POST['field_id']);
153
  die();
154
  }
155
 
156
  /* Field Options */
157
  public static function add_option(){
158
- global $frm_field;
159
 
160
  $id = $_POST['field_id'];
161
  $field = $frm_field->getOne($id);
@@ -186,12 +182,11 @@ class FrmFieldsController{
186
  $field['separate_value'] = isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0;
187
  $field_name = "item_meta[$id]";
188
 
189
- require(FRM_VIEWS_PATH.'/frm-fields/single-option.php');
190
  die();
191
  }
192
 
193
  public static function edit_option(){
194
- global $frm_field;
195
  $ids = explode('-', $_POST['element_id']);
196
  $id = str_replace('field_', '', $ids[0]);
197
  if(strpos($_POST['element_id'], 'key_')){
@@ -200,6 +195,8 @@ class FrmFieldsController{
200
  }else{
201
  $new_label = $_POST['update_value'];
202
  }
 
 
203
  $field = $frm_field->getOne($id);
204
  $options = maybe_unserialize($field->options);
205
  $this_opt = (array)$options[$ids[1]];
@@ -220,12 +217,12 @@ class FrmFieldsController{
220
  $options[$ids[1]] = $_POST['update_value'];
221
 
222
  $frm_field->update($id, array('options' => maybe_serialize($options)));
223
- echo stripslashes($_POST['update_value']);
224
  die();
225
  }
226
 
227
  public static function delete_option(){
228
- global $frm_field;
229
  $field = $frm_field->getOne($_POST['field_id']);
230
  $options = maybe_unserialize($field->options);
231
  unset($options[$_POST['opt_key']]);
@@ -239,24 +236,26 @@ class FrmFieldsController{
239
 
240
  $field_id = $_REQUEST['field_id'];
241
 
242
- global $current_screen, $hook_suffix, $frm_field;
243
 
244
  // Catch plugins that include admin-header.php before admin.php completes.
245
- if (empty( $current_screen ) and function_exists('set_current_screen')){
246
  $hook_suffix = '';
247
  set_current_screen();
248
  }
249
 
250
- if(function_exists('register_admin_color_schemes'))
251
  register_admin_color_schemes();
 
252
 
253
  $hook_suffix = $admin_body_class = '';
254
 
255
  if ( get_user_setting('mfold') == 'f' )
256
  $admin_body_class .= ' folded';
257
 
258
- if ( function_exists('is_admin_bar_showing') and is_admin_bar_showing() )
259
  $admin_body_class .= ' admin-bar';
 
260
 
261
  if ( is_rtl() )
262
  $admin_body_class .= ' rtl';
@@ -266,8 +265,14 @@ class FrmFieldsController{
266
  $prepop[__('Countries', 'formidable')] = FrmAppHelper::get_countries();
267
 
268
  $states = FrmAppHelper::get_us_states();
269
- $prepop[__('U.S. States', 'formidable')] = array_values($states);
270
- $prepop[__('U.S. State Abbreviations', 'formidable')] = array_keys($states);
 
 
 
 
 
 
271
 
272
  $prepop[__('Age', 'formidable')] = array(
273
  __('Under 18', 'formidable'), __('18-24', 'formidable'), __('25-34', 'formidable'),
@@ -290,9 +295,10 @@ class FrmFieldsController{
290
  __('Disagree', 'formidable'), __('Strongly Disagree', 'formidable'), __('N/A', 'formidable')
291
  );
292
 
 
293
  $field = $frm_field->getOne($field_id);
294
 
295
- include(FRM_VIEWS_PATH.'/frm-fields/import_choices.php');
296
  die();
297
  }
298
 
@@ -300,17 +306,15 @@ class FrmFieldsController{
300
  if(!is_admin() or !current_user_can('frm_edit_forms'))
301
  return;
302
 
303
- global $frm_field;
304
-
305
- extract($_POST);
306
 
 
307
  $field = $frm_field->getOne($field_id);
308
 
309
  if(!in_array($field->type, array('radio', 'checkbox', 'select')))
310
  return;
311
 
312
  $field = FrmFieldsHelper::setup_edit_vars($field);
313
- $opts = stripslashes($opts);
314
  $opts = explode("\n", rtrim($opts, "\n"));
315
  if($field['separate_value']){
316
  foreach($opts as $opt_key => $opt){
@@ -327,27 +331,27 @@ class FrmFieldsController{
327
 
328
  $frm_field->update($field_id, array('options' => maybe_serialize($opts)));
329
 
330
- $field['options'] = stripslashes_deep($opts);
331
  $field_name = $field['name'];
332
 
333
  if ($field['type'] == 'radio' or $field['type'] == 'checkbox'){
334
- require(FRM_VIEWS_PATH.'/frm-fields/radio.php');
335
  }else{
336
  foreach ($field['options'] as $opt_key => $opt){
337
  $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
338
  $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
339
- require(FRM_VIEWS_PATH.'/frm-fields/single-option.php');
340
  }
341
  }
342
 
343
- require(FRM_VIEWS_PATH.'/frm-forms/new-field-js.php');
344
 
345
  die();
346
  }
347
 
348
  public static function update_order(){
349
  if(isset($_POST) and isset($_POST['frm_field_id'])){
350
- global $frm_field;
351
 
352
  foreach ($_POST['frm_field_id'] as $position => $item)
353
  $frm_field->update($item, array('field_order' => $position));
@@ -356,9 +360,9 @@ class FrmFieldsController{
356
  }
357
 
358
  public static function change_type($type){
359
- global $frmpro_is_installed;
360
 
361
- if ($frmpro_is_installed) return $type;
362
 
363
  if($type == 'scale' || $type == '10radio')
364
  $type = 'radio';
@@ -401,7 +405,7 @@ class FrmFieldsController{
401
 
402
  $class = ''; //$field['type'];
403
 
404
- if(is_admin() and !in_array($field['type'], array('scale', 'radio', 'checkbox', 'data')))
405
  $class .= 'dyn_default_value';
406
 
407
  $add_html = '';
@@ -415,29 +419,33 @@ class FrmFieldsController{
415
  if(isset($field['max']) and !in_array($field['type'], array('textarea', 'rte', 'hidden')) and !empty($field['max']))
416
  $add_html .= ' maxlength="'. $field['max'] .'"';
417
 
418
- if(!is_admin() or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable_entries'){
419
- $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
420
- $action = FrmAppHelper::get_param($action);
421
-
422
- if(isset($field['required']) and $field['required']){
423
  //if($field['type'] != 'checkbox')
424
  // $add_html .= ' required="required"';
425
 
426
  if($field['type'] == 'file' and $action == 'edit'){
427
  //don't add the required class if this is a file upload when editing
428
- }else
429
  $class .= " required";
430
- }
431
-
432
- //if($frm_settings->use_html and isset($field['default_value']) and !empty($field['default_value']) and isset($field['clear_on_focus']) and $field['clear_on_focus'] and !in_array($field['type'], array('select', 'radio', 'checkbox', 'hidden')))
433
- // $add_html .= ' placeholder="'.$field['default_value'].'"';
434
-
435
  if(isset($field['clear_on_focus']) and $field['clear_on_focus'] and !empty($field['default_value'])){
436
- $val = str_replace(array("\r\n", "\n"), '\r', addslashes(str_replace('&#039;', "'", esc_attr($field['default_value']))));
437
- $add_html .= ' onfocus="frmClearDefault('."'". $val ."'". ',this)" onblur="frmReplaceDefault('."'". $val ."'". ',this)"';
438
 
439
- if($field['value'] == $field['default_value'])
440
- $class .= ' frm_default';
 
 
 
 
 
 
 
441
  }
442
  }
443
 
@@ -445,12 +453,13 @@ class FrmFieldsController{
445
  $class .= ' '. $field['input_class'];
446
 
447
  $class = apply_filters('frm_field_classes', $class, $field);
 
448
  if(!empty($class))
449
  $add_html .= ' class="'. trim($class) .'"';
450
 
451
  if(isset($field['shortcodes']) and !empty($field['shortcodes'])){
452
  foreach($field['shortcodes'] as $k => $v){
453
- if($k == 'opt') continue;
454
  $add_html .= ' '. $k .'="'. $v .'"';
455
  unset($k);
456
  unset($v);
2
  /**
3
  * @package Formidable
4
  */
5
+
6
+ if(!defined('ABSPATH')) die(__('You are not allowed to call this page directly.', 'formidable'));
7
+
8
+ if(class_exists('FrmFieldsController'))
9
+ return;
10
 
11
  class FrmFieldsController{
12
+ public static function load_hooks(){
13
  add_action('wp_ajax_frm_load_field', 'FrmFieldsController::load_field');
14
  add_action('wp_ajax_frm_insert_field', 'FrmFieldsController::create');
15
  add_action('wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name');
16
  add_action('wp_ajax_frm_field_desc_in_place_edit', 'FrmFieldsController::edit_description');
 
17
  add_action('wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option');
18
  add_action('wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate');
19
  add_action('wp_ajax_frm_delete_field', 'FrmFieldsController::destroy');
31
  }
32
 
33
  public static function load_field(){
 
 
34
  $id = $field_id = $_POST['field_id'];
35
  if(!$field_id or !is_numeric($field_id))
36
  die();
42
  $field['value'] = '';
43
 
44
  $field_name = "item_meta[$field_id]";
45
+ $ajax = true;
46
  $values = array();
47
+
48
+ $path = FrmAppHelper::plugin_path();
49
+ include($path .'/classes/views/frm-forms/add_field.php');
50
+ include($path .'/classes/views/frm-forms/new-field-js.php');
51
+ unset($path);
52
 
53
  die();
54
  }
55
 
56
  public static function create(){
 
57
  $field_data = $_POST['field'];
58
  $form_id = $_POST['form_id'];
59
  $values = array();
60
  if(class_exists('FrmProForm'))
61
+ $values['post_type'] = FrmProFormsHelper::post_type($form_id);
62
 
63
  $field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
64
 
65
+ $frm_field = new FrmField();
66
  $field_id = $frm_field->create( $field_values );
67
 
68
  if ($field_id){
69
  $field = FrmFieldsHelper::setup_edit_vars($frm_field->getOne($field_id));
70
  $field_name = "item_meta[$field_id]";
71
  $id = $form_id;
72
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
73
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new-field-js.php');
74
  }
75
  die();
76
  }
77
 
78
  public static function edit_name(){
 
79
  $id = str_replace('field_label_', '', $_POST['element_id']);
80
  $values = array('name' => trim($_POST['update_value']));
81
+ $frm_field = new FrmField();
 
82
  $form = $frm_field->update($id, $values);
83
  echo stripslashes($_POST['update_value']);
84
  die();
86
 
87
 
88
  public static function edit_description(){
89
+ $frm_field = new FrmField();
90
  $id = str_replace('field_description_', '', $_POST['element_id']);
91
  $frm_field->update($id, array('description' => $_POST['update_value']));
92
  echo stripslashes($_POST['update_value']);
93
  die();
 
 
 
 
 
 
94
  }
95
 
96
  public static function update_ajax_option(){
97
+ $frm_field = new FrmField();
98
  $field = $frm_field->getOne($_POST['field']);
 
99
  foreach(array('clear_on_focus', 'separate_value', 'default_blank') as $val){
100
  if(isset($_POST[$val])){
101
  $new_val = $_POST[$val];
113
  }
114
 
115
  public static function duplicate(){
116
+ global $wpdb;
117
 
118
+ $frm_field = new FrmField();
119
  $copy_field = $frm_field->getOne($_POST['field_id']);
120
  if (!$copy_field) return;
121
 
122
  $values = array();
123
+ $values['field_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_fields', 'field_key');
124
  $values['options'] = maybe_serialize($copy_field->options);
125
  $values['default_value'] = maybe_serialize($copy_field->default_value);
126
  $values['form_id'] = $copy_field->form_id;
127
  foreach (array('name', 'description', 'type', 'field_options', 'required') as $col)
128
  $values[$col] = $copy_field->{$col};
129
+ $field_count = FrmAppHelper::getRecordCount(array('form_id' => $copy_field->form_id), $wpdb->prefix . 'frm_fields');
130
  $values['field_order'] = $field_count + 1;
131
 
132
  $field_id = $frm_field->create($values);
137
  $id = $field['form_id'];
138
  if($field['type'] == 'html')
139
  $field['stop_filter'] = true;
140
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/add_field.php');
141
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new-field-js.php');
142
  }
143
  die();
144
  }
145
 
146
  public static function destroy(){
147
+ $frm_field = new FrmField();
148
  $field_id = $frm_field->destroy($_POST['field_id']);
149
  die();
150
  }
151
 
152
  /* Field Options */
153
  public static function add_option(){
154
+ $frm_field = new FrmField();
155
 
156
  $id = $_POST['field_id'];
157
  $field = $frm_field->getOne($id);
182
  $field['separate_value'] = isset($field_data->field_options['separate_value']) ? $field_data->field_options['separate_value'] : 0;
183
  $field_name = "item_meta[$id]";
184
 
185
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
186
  die();
187
  }
188
 
189
  public static function edit_option(){
 
190
  $ids = explode('-', $_POST['element_id']);
191
  $id = str_replace('field_', '', $ids[0]);
192
  if(strpos($_POST['element_id'], 'key_')){
195
  }else{
196
  $new_label = $_POST['update_value'];
197
  }
198
+
199
+ $frm_field = new FrmField();
200
  $field = $frm_field->getOne($id);
201
  $options = maybe_unserialize($field->options);
202
  $this_opt = (array)$options[$ids[1]];
217
  $options[$ids[1]] = $_POST['update_value'];
218
 
219
  $frm_field->update($id, array('options' => maybe_serialize($options)));
220
+ echo (trim($_POST['update_value']) == '') ? __('(Blank)', 'formidable') : stripslashes($_POST['update_value']);
221
  die();
222
  }
223
 
224
  public static function delete_option(){
225
+ $frm_field = new FrmField();
226
  $field = $frm_field->getOne($_POST['field_id']);
227
  $options = maybe_unserialize($field->options);
228
  unset($options[$_POST['opt_key']]);
236
 
237
  $field_id = $_REQUEST['field_id'];
238
 
239
+ global $current_screen, $hook_suffix;
240
 
241
  // Catch plugins that include admin-header.php before admin.php completes.
242
+ if ( empty( $current_screen ) && function_exists('set_current_screen') ) {
243
  $hook_suffix = '';
244
  set_current_screen();
245
  }
246
 
247
+ if ( function_exists('register_admin_color_schemes') ) {
248
  register_admin_color_schemes();
249
+ }
250
 
251
  $hook_suffix = $admin_body_class = '';
252
 
253
  if ( get_user_setting('mfold') == 'f' )
254
  $admin_body_class .= ' folded';
255
 
256
+ if ( function_exists('is_admin_bar_showing') && is_admin_bar_showing() ) {
257
  $admin_body_class .= ' admin-bar';
258
+ }
259
 
260
  if ( is_rtl() )
261
  $admin_body_class .= ' rtl';
265
  $prepop[__('Countries', 'formidable')] = FrmAppHelper::get_countries();
266
 
267
  $states = FrmAppHelper::get_us_states();
268
+ $state_abv = array_keys($states);
269
+ sort($state_abv);
270
+ $prepop[__('U.S. State Abbreviations', 'formidable')] = $state_abv;
271
+ $states = array_values($states);
272
+ sort($states);
273
+ $prepop[__('U.S. States', 'formidable')] = $states;
274
+ unset($state_abv);
275
+ unset($states);
276
 
277
  $prepop[__('Age', 'formidable')] = array(
278
  __('Under 18', 'formidable'), __('18-24', 'formidable'), __('25-34', 'formidable'),
295
  __('Disagree', 'formidable'), __('Strongly Disagree', 'formidable'), __('N/A', 'formidable')
296
  );
297
 
298
+ $frm_field = new FrmField();
299
  $field = $frm_field->getOne($field_id);
300
 
301
+ include(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/import_choices.php');
302
  die();
303
  }
304
 
306
  if(!is_admin() or !current_user_can('frm_edit_forms'))
307
  return;
308
 
309
+ extract(stripslashes_deep($_POST));
 
 
310
 
311
+ $frm_field = new FrmField();
312
  $field = $frm_field->getOne($field_id);
313
 
314
  if(!in_array($field->type, array('radio', 'checkbox', 'select')))
315
  return;
316
 
317
  $field = FrmFieldsHelper::setup_edit_vars($field);
 
318
  $opts = explode("\n", rtrim($opts, "\n"));
319
  if($field['separate_value']){
320
  foreach($opts as $opt_key => $opt){
331
 
332
  $frm_field->update($field_id, array('options' => maybe_serialize($opts)));
333
 
334
+ $field['options'] = $opts;
335
  $field_name = $field['name'];
336
 
337
  if ($field['type'] == 'radio' or $field['type'] == 'checkbox'){
338
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/radio.php');
339
  }else{
340
  foreach ($field['options'] as $opt_key => $opt){
341
  $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
342
  $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
343
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-fields/single-option.php');
344
  }
345
  }
346
 
347
+ require(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/new-field-js.php');
348
 
349
  die();
350
  }
351
 
352
  public static function update_order(){
353
  if(isset($_POST) and isset($_POST['frm_field_id'])){
354
+ $frm_field = new FrmField();
355
 
356
  foreach ($_POST['frm_field_id'] as $position => $item)
357
  $frm_field->update($item, array('field_order' => $position));
360
  }
361
 
362
  public static function change_type($type){
363
+ global $frm_vars;
364
 
365
+ if ($frm_vars['pro_is_installed']) return $type;
366
 
367
  if($type == 'scale' || $type == '10radio')
368
  $type = 'radio';
405
 
406
  $class = ''; //$field['type'];
407
 
408
+ if(is_admin() and !defined('DOING_AJAX') and !in_array($field['type'], array('scale', 'radio', 'checkbox', 'data')))
409
  $class .= 'dyn_default_value';
410
 
411
  $add_html = '';
419
  if(isset($field['max']) and !in_array($field['type'], array('textarea', 'rte', 'hidden')) and !empty($field['max']))
420
  $add_html .= ' maxlength="'. $field['max'] .'"';
421
 
422
+ if(!is_admin() or defined('DOING_AJAX') or !isset($_GET) or !isset($_GET['page']) or $_GET['page'] == 'formidable-entries'){
423
+ /*if(isset($field['required']) and $field['required']){
424
+ $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
425
+ $action = FrmAppHelper::get_param($action);
426
+
427
  //if($field['type'] != 'checkbox')
428
  // $add_html .= ' required="required"';
429
 
430
  if($field['type'] == 'file' and $action == 'edit'){
431
  //don't add the required class if this is a file upload when editing
432
+ }else{
433
  $class .= " required";
434
+ }
435
+ unset($action);
436
+ }*/
437
+
 
438
  if(isset($field['clear_on_focus']) and $field['clear_on_focus'] and !empty($field['default_value'])){
 
 
439
 
440
+ if($frm_settings->use_html and !in_array($field['type'], array('select', 'radio', 'checkbox', 'hidden'))){
441
+ $add_html .= ' placeholder="'. esc_attr($field['default_value']) .'"';
442
+ FrmAppHelper::load_scripts('jquery-placeholder');
443
+ }else if(!$frm_settings->use_html){
444
+ $val = str_replace(array("\r\n", "\n"), '\r', addslashes(str_replace('&#039;', "'", esc_attr($field['default_value']))));
445
+ $add_html .= ' onfocus="frmClearDefault('."'". $val ."'". ',this)" onblur="frmReplaceDefault('."'". $val ."'". ',this)"';
446
+ if($field['value'] == $field['default_value'])
447
+ $class .= ' frm_default';
448
+ }
449
  }
450
  }
451
 
453
  $class .= ' '. $field['input_class'];
454
 
455
  $class = apply_filters('frm_field_classes', $class, $field);
456
+
457
  if(!empty($class))
458
  $add_html .= ' class="'. trim($class) .'"';
459
 
460
  if(isset($field['shortcodes']) and !empty($field['shortcodes'])){
461
  foreach($field['shortcodes'] as $k => $v){
462
+ if($k == 'opt' or strpos($add_html, " $k=")) continue;
463
  $add_html .= ' '. $k .'="'. $v .'"';
464
  unset($k);
465
  unset($v);
classes/controllers/FrmFormsController.php CHANGED
@@ -1,16 +1,23 @@
1
  <?php
2
  /**
3
  * @package Formidable
4
- */
 
 
 
 
 
5
 
6
  class FrmFormsController{
7
- function FrmFormsController(){
8
- add_action('admin_menu', 'FrmFormsController::menu');
9
- add_action('admin_menu', 'FrmFormsController::lower_menu', 90);
10
  add_action('admin_head-toplevel_page_formidable', 'FrmFormsController::head');
11
- add_action('wp_ajax_frm_form_name_in_place_edit', 'FrmFormsController::edit_name');
 
12
  add_action('wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description');
13
  add_action('wp_ajax_frm_delete_form_wo_fields', 'FrmFormsController::destroy_wo_fields');
 
14
  add_action('wp_ajax_frm_save_form', 'FrmFormsController::route');
15
  add_filter('frm_submit_button', 'FrmFormsController::submit_button_label');
16
  add_filter('media_buttons_context', 'FrmFormsController::insert_form_button');
@@ -18,35 +25,49 @@ class FrmFormsController{
18
  add_action('admin_footer', 'FrmFormsController::insert_form_popup');
19
 
20
  add_filter('set-screen-option', 'FrmFormsController::save_per_page', 10, 3);
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  public static function menu(){
24
  global $frm_settings;
25
  add_submenu_page('formidable', $frm_settings->menu .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', 'formidable', 'FrmFormsController::route');
26
- add_submenu_page('formidable', $frm_settings->menu .' | '. __('Templates', 'formidable'), __('Templates', 'formidable'), 'frm_view_forms', 'formidable-templates', 'FrmFormsController::template_list');
27
 
28
- add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-new', 'FrmFormsController::head');
29
  add_action('admin_head-'. sanitize_title($frm_settings->menu) .'_page_formidable-templates', 'FrmFormsController::head');
30
 
31
- if(class_exists('WP_List_Table')){
32
- add_filter('manage_toplevel_page_formidable_columns', 'FrmFormsController::get_columns', 0 );
33
- add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_columns', 'FrmFormsController::get_columns', 0 );
34
- add_filter('manage_toplevel_page_formidable_sortable_columns', 'FrmFormsController::get_sortable_columns');
35
- add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-templates_sortable_columns', 'FrmFormsController::get_sortable_columns');
36
- add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns');
37
- add_filter('get_user_option_manage'. sanitize_title($frm_settings->menu) .'_page_formidable-templatescolumnshidden', 'FrmFormsController::hidden_columns');
38
- }
39
  }
40
 
41
- public static function lower_menu(){
42
- add_submenu_page('formidable', 'Formidable | '. __('Add New Form', 'formidable'), '<span style="display:none;">'. __('Add New Form', 'formidable') .'</span>', 'frm_edit_forms', 'formidable-new', 'FrmFormsController::new_form');
 
43
  }
44
 
45
  public static function head(){
46
  global $frm_settings;
47
 
48
- $js_file = array(FRM_URL . '/js/jquery/jquery-ui-themepicker.js', FRM_URL.'/js/jquery/jquery.editinplace.packed.js');
49
- require(FRM_VIEWS_PATH . '/shared/head.php');
 
 
 
 
 
50
  }
51
 
52
  public static function list_form(){
@@ -62,14 +83,12 @@ class FrmFormsController{
62
  }
63
 
64
  public static function new_form($values=false){
65
- global $frm_form, $frmpro_is_installed;
66
 
67
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
68
- if($values){
69
- $action = $values[$action];
70
- }else{
71
- $action = FrmAppHelper::get_param($action);
72
- }
73
  if ($action == 'create'){
74
  return self::create($values);
75
  }else if ($action == 'new'){
@@ -77,20 +96,26 @@ class FrmFormsController{
77
  $values = FrmFormsHelper::setup_new_vars($values);
78
  $id = $frm_form->create( $values );
79
  $values['id'] = $id;
80
- require(FRM_VIEWS_PATH.'/frm-forms/new.php');
81
  }else{
82
  $all_templates = $frm_form->getAll(array('is_template' => 1), 'name');
83
- require(FRM_VIEWS_PATH.'/frm-forms/new-selection.php');
84
  }
85
  }
86
 
87
  public static function create($values=false){
88
- global $frm_entry, $frm_form, $frm_field, $frmpro_is_installed;
89
  if(!$values)
90
  $values = $_POST;
91
-
 
 
 
 
 
92
  $id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
93
 
 
94
  $errors = $frm_form->validate($values);
95
 
96
  if( count($errors) > 0 ){
@@ -99,10 +124,10 @@ class FrmFormsController{
99
  $record = $frm_form->getOne( $id );
100
  $fields = $frm_field->getAll(array('fi.form_id' => $id), 'field_order');
101
  $values = FrmAppHelper::setup_edit_vars($record, 'forms', $fields, true);
102
- require(FRM_VIEWS_PATH.'/frm-forms/new.php');
103
- }else{
104
  $record = $frm_form->update( $id, $values, true );
105
- die('<script type="text/javascript">window.location="'. admin_url('admin.php?page=formidable&frm_action=settings&id='. $id) .'"</script>');
106
  //$message = __('Form was Successfully Created', 'formidable');
107
  //return self::settings($record, $message);
108
  }
@@ -120,10 +145,11 @@ class FrmFormsController{
120
  }
121
 
122
  public static function update_settings(){
123
- global $frm_form;
124
-
125
  $id = FrmAppHelper::get_param('id');
 
 
126
  $errors = $frm_form->validate($_POST);
 
127
  if( count($errors) > 0 ){
128
  return self::get_settings_vars($id, $errors);
129
  }else{
@@ -133,50 +159,55 @@ class FrmFormsController{
133
  }
134
  }
135
 
136
- public static function translate($action){
137
- global $frmpro_is_installed, $frm_form;
138
- $id = FrmAppHelper::get_param('id', false);
139
- $form = $frm_form->getOne($id);
140
- $values = (array)$form;
141
- include(FRM_VIEWS_PATH . '/frm-forms/translate.php');
142
- }
143
-
144
- public static function edit_name(){
145
- global $frm_form;
146
- $values = array('name' => trim($_POST['update_value']));
147
  $form = $frm_form->update($_POST['form_id'], $values);
148
- echo stripslashes($_POST['update_value']);
 
149
  die();
150
  }
151
 
152
  public static function edit_description(){
153
- global $frm_form;
154
  $form = $frm_form->update($_POST['form_id'], array('description' => $_POST['update_value']));
155
  $description = stripslashes($_POST['update_value']);
156
  if(apply_filters('frm_use_wpautop', true))
157
- $description = wpautop($description);
158
  echo $description;
159
  die();
160
  }
161
 
162
  public static function update($values=false){
163
- global $frm_form;
164
 
165
  if(!$values)
166
  $values = $_POST;
 
167
  $errors = $frm_form->validate($values);
 
 
 
 
 
 
168
  $id = isset($values['id']) ? (int)$values['id'] : (int)FrmAppHelper::get_param('id');
 
169
  if( count($errors) > 0 ){
170
  return self::get_edit_vars($id, $errors);
171
  }else{
172
  $record = $frm_form->update( $id, $values );
173
  $message = __('Form was Successfully Updated', 'formidable');
 
 
 
174
  return self::get_edit_vars($id, '', $message);
175
  }
176
  }
177
 
178
  public static function duplicate(){
179
- global $frm_form;
180
 
181
  $params = self::get_params();
182
  $record = $frm_form->duplicate( $params['id'], $params['template'], true );
@@ -187,19 +218,29 @@ class FrmFormsController{
187
  return self::display_forms_list($params, __('There was a problem creating new template.', 'formidable'));
188
  }
189
 
 
 
 
 
 
 
190
  public static function page_preview(){
191
- global $frm_form;
192
  $params = self::get_params();
193
  if (!$params['form']) return;
 
 
194