Formidable Forms – Form Builder for WordPress - Version 2.0rc3

Version Description

Download this release

Release Info

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

Code changes from version 2.0b7 to 2.0rc3

Files changed (114) hide show
  1. .travis.yml +63 -0
  2. classes/controllers/FrmAppController.php +144 -141
  3. classes/controllers/FrmEntriesController.php +53 -34
  4. classes/controllers/FrmFieldsController.php +19 -17
  5. classes/controllers/FrmFormActionsController.php +12 -6
  6. classes/controllers/FrmFormsController.php +89 -89
  7. classes/controllers/FrmHooksController.php +17 -17
  8. classes/controllers/FrmSettingsController.php +7 -5
  9. classes/controllers/FrmStatisticsController.php +1 -1
  10. classes/controllers/FrmStylesController.php +38 -12
  11. classes/controllers/FrmXMLController.php +26 -27
  12. classes/helpers/FrmAppHelper.php +235 -78
  13. classes/helpers/FrmEntriesHelper.php +182 -87
  14. classes/helpers/FrmEntriesListHelper.php +14 -10
  15. classes/helpers/FrmFieldsHelper.php +54 -25
  16. classes/helpers/FrmFormActionsHelper.php +3 -3
  17. classes/helpers/FrmFormsHelper.php +50 -21
  18. classes/helpers/FrmFormsListHelper.php +31 -8
  19. classes/helpers/FrmListHelper.php +1 -0
  20. classes/helpers/FrmStylesHelper.php +26 -9
  21. classes/helpers/FrmXMLHelper.php +32 -23
  22. classes/models/FrmDb.php +61 -42
  23. classes/models/FrmEntry.php +39 -35
  24. classes/models/FrmEntryMeta.php +25 -19
  25. classes/models/FrmField.php +43 -26
  26. classes/models/FrmForm.php +5 -5
  27. classes/models/FrmFormAction.php +9 -8
  28. classes/models/FrmNotification.php +110 -54
  29. classes/models/FrmSettings.php +9 -8
  30. classes/models/FrmStyle.php +28 -21
  31. classes/views/frm-entries/direct.php +0 -0
  32. classes/views/frm-entries/errors.php +5 -5
  33. classes/views/frm-entries/form.php +1 -0
  34. classes/views/frm-entries/new.php +4 -4
  35. classes/views/frm-entries/show.php +3 -3
  36. classes/views/frm-entries/sidebar-shared.php +84 -0
  37. classes/views/frm-entries/sidebar-show.php +5 -3
  38. classes/views/frm-fields/import_choices.php +2 -2
  39. classes/views/frm-fields/input.php +53 -71
  40. classes/views/frm-fields/radio.php +4 -8
  41. classes/views/frm-fields/show-build.php +12 -14
  42. classes/views/frm-fields/show.php +0 -0
  43. classes/views/frm-fields/single-option.php +6 -7
  44. classes/views/frm-form-actions/_action_inside.php +7 -6
  45. classes/views/frm-form-actions/_email_settings.php +10 -10
  46. classes/views/frm-form-actions/default_actions.php +7 -7
  47. classes/views/frm-form-actions/email_action.php +3 -3
  48. classes/views/frm-form-actions/form_action.php +6 -6
  49. classes/views/frm-forms/_publish_box.php +8 -8
  50. classes/views/frm-forms/add_field.php +51 -51
  51. classes/views/frm-forms/add_field_links.php +36 -29
  52. classes/views/frm-forms/edit.php +2 -2
  53. classes/views/frm-forms/form.php +2 -2
  54. classes/views/frm-forms/insert_form_popup.php +6 -4
  55. classes/views/frm-forms/list.php +2 -2
  56. classes/views/frm-forms/mb_html_tab.php +3 -3
  57. classes/views/frm-forms/new-selection.php +1 -1
  58. classes/views/frm-forms/new.php +2 -2
  59. classes/views/frm-forms/settings.php +11 -10
  60. classes/views/frm-forms/shortcode_opts.php +39 -0
  61. classes/views/frm-forms/sidebar-settings.php +1 -1
  62. classes/views/frm-settings/form.php +5 -5
  63. classes/views/frm-settings/license_box.php +1 -1
  64. classes/views/shared/errors.php +1 -1
  65. classes/views/shared/form-nav.php +5 -5
  66. classes/views/shared/head.php +1 -19
  67. classes/views/shared/mb_adv_info.php +17 -17
  68. classes/views/shared/update_message.php +2 -2
  69. classes/views/styles/_buttons.php +20 -20
  70. classes/views/styles/_check-box-radio-fields.php +9 -11
  71. classes/views/styles/_date-fields.php +5 -5
  72. classes/views/styles/_field-colors.php +15 -15
  73. classes/views/styles/_field-description.php +5 -5
  74. classes/views/styles/_field-labels.php +12 -12
  75. classes/views/styles/_field-sizes.php +7 -7
  76. classes/views/styles/_form-messages.php +8 -8
  77. classes/views/styles/_general.php +13 -13
  78. classes/views/styles/_sample_form.php +17 -17
  79. classes/views/styles/_section-fields.php +12 -12
  80. classes/views/styles/custom_css.php +6 -6
  81. classes/views/styles/manage.php +3 -3
  82. classes/views/styles/show.php +9 -9
  83. classes/views/xml/forms_xml.php +3 -2
  84. classes/views/xml/import_form.php +5 -5
  85. classes/views/xml/posts_xml.php +2 -2
  86. classes/views/xml/xml.php +3 -2
  87. classes/widgets/FrmShowForm.php +11 -10
  88. css/_single_theme.css.php +27 -7
  89. css/custom_theme.css.php +36 -16
  90. css/frm_admin.css +34 -4
  91. css/frm_display.css +0 -0
  92. css/frm_fonts.css +22 -0
  93. deprecated.php +0 -19
  94. formidable.php +2 -2
  95. images/ajax_loader.gif +0 -0
  96. images/form_16-2x.png +0 -0
  97. images/form_16.png +0 -0
  98. images/form_32_sprite-2x.png +0 -0
  99. images/form_32_sprite.png +0 -0
  100. images/tooltip.png +0 -0
  101. images/wpspin_light.gif +0 -0
  102. js/bootstrap.min.js +3 -3
  103. js/formidable.js +0 -1050
  104. js/formidable.min.js +44 -44
  105. js/formidable_admin.js +24 -17
  106. js/jquery/jquery-ui-themepicker.js +0 -0
  107. js/jquery/jquery.editinplace.js +0 -653
  108. js/jquery/jquery.editinplace.packed.js +0 -0
  109. js/jquery/jquery.placeholder.js +0 -0
  110. languages/formidable-de_DE.mo +0 -0
  111. languages/formidable-de_DE.po +1288 -1171
  112. languages/formidable-en_US.po +1286 -1169
  113. languages/formidable-es_ES.mo +0 -0
  114. languages/formidable-es_ES.po +496 -543
.travis.yml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ language: php
2
+
3
+ sudo: false
4
+
5
+ matrix:
6
+ include:
7
+ - php: '5.6'
8
+ env: WP_VERSION=master WP_MULTISITE=0 PHPLINT=1
9
+ - php: '5.2'
10
+ env: WP_VERSION=master WP_MULTISITE=1 PHPLINT=1
11
+ - php: '5.6'
12
+ env: WP_VERSION=4.1 WP_MULTISITE=1
13
+ - php: '5.5'
14
+ env: WP_VERSION=master WP_MULTISITE=0
15
+ - php: '5.5'
16
+ env: WP_VERSION=4.1 WP_MULTISITE=1
17
+ - php: '5.4'
18
+ env: WP_VERSION=4.1 WP_MULTISITE=0
19
+ - php: '5.4'
20
+ env: WP_VERSION=4.1 WP_MULTISITE=1
21
+ - php: '5.5'
22
+ env: WP_VERSION=4.1 WP_MULTISITE=0
23
+ - php: '5.5'
24
+ env: WP_VERSION=4.0 WP_MULTISITE=1
25
+ - php: '5.3'
26
+ env: WP_VERSION=4.0 WP_MULTISITE=0
27
+ - php: '5.4'
28
+ env: WP_VERSION=3.9 WP_MULTISITE=0
29
+ - php: '5.3'
30
+ env: WP_VERSION=3.4 WP_MULTISITE=0
31
+ - php: '5.3'
32
+ env: WP_VERSION=3.4 WP_MULTISITE=1
33
+ - php: 'hhvm'
34
+ env: WP_VERSION=4.1 WP_MULTISITE=0
35
+ - php: 'hhvm'
36
+ env: WP_VERSION=4.1 WP_MULTISITE=1
37
+
38
+ before_script:
39
+ - phpenv local 5.6
40
+ - composer selfupdate --no-interaction
41
+ - composer install --no-interaction
42
+ - phpenv local --unset
43
+ - PLUGIN_SLUG=$(basename $(pwd))
44
+ - export WP_DEVELOP_DIR=/tmp/wordpress/
45
+ - git clone --depth=50 --branch="$WP_VERSION" git://develop.git.wordpress.org/ /tmp/wordpress
46
+ - cd ..
47
+ - cp -r "$PLUGIN_SLUG" "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
48
+ - cd /tmp/wordpress/
49
+ - cp wp-tests-config-sample.php wp-tests-config.php
50
+ - sed -i "s/youremptytestdbnamehere/wordpress_tests/" wp-tests-config.php
51
+ - sed -i "s/yourusernamehere/travis/" wp-tests-config.php
52
+ - sed -i "s/yourpasswordhere//" wp-tests-config.php
53
+ - mysql -e "CREATE DATABASE wordpress_tests;" -uroot
54
+ - git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs
55
+ - git clone https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
56
+ - cd phpcs
57
+ - scripts/phpcs --config-set installed_paths ../wpcs
58
+ - cd "/tmp/wordpress/src/wp-content/plugins/$PLUGIN_SLUG"
59
+ - phpenv rehash
60
+
61
+ script:
62
+ - if [[ "$PHPLINT" == "1" ]]; then /tmp/wordpress/phpcs/scripts/phpcs -p -s -v -n . --standard=./codesniffer.xml --extensions=php; fi
63
+ - phpunit -c phpunit.xml
classes/controllers/FrmAppController.php CHANGED
@@ -2,32 +2,32 @@
2
 
3
  class FrmAppController {
4
 
5
- public static function menu() {
6
- add_filter('plugin_action_links_'. FrmAppHelper::plugin_folder() .'/formidable.php', 'FrmAppController::settings_link' );
7
- add_filter('admin_body_class', 'FrmAppController::wp_admin_body_class' );
8
 
9
  FrmAppHelper::maybe_add_permissions();
10
 
11
- if ( ! current_user_can('frm_view_forms') ) {
12
  return;
13
  }
14
 
15
- $count = count(get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ));
16
  $pos = ( (int) $count > 0 ) ? '22.7' : '29.3';
17
- $pos = apply_filters('frm_menu_position', $pos);
18
 
19
  $frm_settings = FrmAppHelper::get_settings();
20
- add_menu_page('Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos);
21
  }
22
 
23
  public static function load_wp_admin_style() {
24
- wp_enqueue_style( 'frm_fonts', FrmAppHelper::plugin_url() .'/css/frm_fonts.css', array(), FrmAppHelper::plugin_version());
25
  }
26
 
27
  public static function get_form_nav($form, $show_nav = '', $title = 'show') {
28
  global $pagenow, $frm_vars;
29
 
30
- $show_nav = FrmAppHelper::get_param('show_nav', $show_nav);
31
  if ( empty($show_nav) ) {
32
  return;
33
  }
@@ -36,12 +36,12 @@ class FrmAppController {
36
  if ( $form ) {
37
  FrmFormsHelper::maybe_get_form( $form );
38
 
39
- if ( is_object($form) ) {
40
  $id = $form->id;
41
  }
42
  }
43
 
44
- if ( !isset($id) ) {
45
  $form = $id = false;
46
  }
47
 
@@ -50,24 +50,25 @@ class FrmAppController {
50
 
51
  // Adds a settings link to the plugins page
52
  public static function settings_link($links){
53
- $settings = '<a href="'. admin_url('admin.php?page=formidable-settings') .'">' . __('Settings', 'formidable') . '</a>';
54
- array_unshift($links, $settings);
55
 
56
  return $links;
57
  }
58
 
59
  public static function update_action_links( $actions, $plugin ) {
60
-
61
- if ( FrmAppHelper::plugin_folder() .'/formidable.php' != $plugin )
62
  return $actions;
 
63
 
64
- $db_version = get_option('frm_db_version');
65
- $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option('frmpro_db_version') : false;
66
 
67
  if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
68
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
69
 
70
- return '<a href="'. add_query_arg(array('upgraded' => 'true'), menu_page_url( 'formidable', 0 )) .'">'. __( 'Click here to complete the upgrade', 'formidable' ) .'</a>';
71
 
72
  }
73
 
@@ -75,10 +76,10 @@ class FrmAppController {
75
  }
76
 
77
  public static function pro_get_started_headline(){
78
- if ( FrmAppHelper::is_admin_page('formidable') && isset( $_REQUEST['upgraded'] ) && 'true' == $_REQUEST['upgraded'] ) {
79
  self::install();
80
  ?>
81
- <div id="message" class="frm_message updated"><?php _e('Congratulations! Formidable is ready to roll.', 'formidable') ?></div>
82
  <?php
83
  return;
84
  }
@@ -88,22 +89,22 @@ class FrmAppController {
88
  return;
89
  }
90
 
91
- if ( is_multisite() && !current_user_can('administrator') ) {
92
  return;
93
  }
94
 
95
  if ( ! isset($_GET['activate']) ) {
96
- $db_version = get_option('frm_db_version');
97
- $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option('frmpro_db_version') : false;
98
  if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
99
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
100
  ?>
101
- <div class="error" id="frm_install_message" style="padding:7px;"><?php _e('Your update is not complete yet.<br/>Please deactivate and reactivate the plugin to complete the update or', 'formidable'); ?> <a href="javascript:void(0)" id="frm_install_link"><?php _e('Update Now', 'formidable') ?></a></div>
102
  <script type="text/javascript">
103
  jQuery(document).ready(function($){ $(document.getElementById('frm_install_link')).click(frm_install_now); });
104
  function frm_install_now(){
105
  var $msg = jQuery(document.getElementById('frm_install_message'));
106
- $msg.html('<div style="line-height:24px;"><?php _e('Please wait while your site updates.', 'formidable') ?><div class="spinner frm_spinner" style="float:left;display:block;"></div></div>');
107
  jQuery.ajax({
108
  type:"POST",url:ajaxurl,data:"action=frm_install",
109
  success:function(){$msg.fadeOut('slow');}
@@ -115,16 +116,16 @@ function frm_install_now(){
115
  }
116
 
117
  global $frm_vars;
118
- if ( $frm_vars['pro_is_authorized'] && ! file_exists(FrmAppHelper::plugin_path() . '/pro/formidable-pro.php') ) {
119
  // user is authorized, but running free version
120
  $inst_install_url = 'http://formidablepro.com/knowledgebase/manually-install-formidable-pro/';
121
  ?>
122
- <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>
123
  <script type="text/javascript">
124
  function frm_deauthorize_now(){
125
- if(!confirm("<?php esc_attr_e('Are you sure you want to deauthorize Formidable Pro on this site?', 'formidable') ?>"))
126
  return false;
127
- jQuery('.frm_deauthorize_link').html('<span class="spinner" style="display:inline-block;margin-top:0;float:none;"></span>');
128
  jQuery.ajax({type:'POST',url:ajaxurl,data:'action=frm_deauthorize&nonce='+wp_create_nonce('frm_ajax'),
129
  success:function(msg){jQuery('.error').fadeOut('slow');}
130
  });
@@ -142,39 +143,37 @@ return false;
142
  return;
143
  }
144
 
145
- wp_register_script('bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array('jquery'), '3.2.0');
146
 
147
- if ( isset($_GET) && ((isset($_GET['page']) && strpos($_GET['page'], 'formidable') === 0 ) ||
148
- ($pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'frm_display'))
149
  ) {
150
  $version = FrmAppHelper::plugin_version();
151
- add_filter('admin_body_class', 'FrmAppController::admin_body_class' );
152
 
153
- wp_enqueue_script('jquery-ui-sortable');
154
- wp_enqueue_script('jquery-ui-draggable');
155
- wp_enqueue_script('admin-widgets');
156
- wp_enqueue_style('widgets');
157
- wp_enqueue_script('formidable');
158
- wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() .'/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version, true);
159
- self::localize_script('admin');
160
 
161
- wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version);
162
  add_thickbox();
163
 
164
- wp_register_script('formidable-editinplace', FrmAppHelper::plugin_url() .'/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0');
165
- wp_register_script('jquery-frm-themepicker', FrmAppHelper::plugin_url() .'/js/jquery/jquery-ui-themepicker.js', array('jquery'), $version);
166
 
167
- if ( FrmAppHelper::is_admin_page('formidable-settings') || FrmAppHelper::is_admin_page('formidable-styles') ) {
168
  // load multselect js
169
- wp_enqueue_script('bootstrap-multiselect', FrmAppHelper::plugin_url() .'/js/bootstrap-multiselect.js', array('jquery', 'bootstrap_tooltip'), '0.9.8', true);
170
  }
171
-
172
  } else if ( $pagenow == 'post.php' || ($pagenow == 'post-new.php' && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] == 'frm_display') ) {
173
  if ( isset($_REQUEST['post_type']) ) {
174
  $post_type = $_REQUEST['post_type'];
175
- } else if ( isset($_REQUEST['post']) && !empty($_REQUEST['post']) ) {
176
- $post = get_post($_REQUEST['post']);
177
- if ( !$post ) {
178
  return;
179
  }
180
  $post_type = $post->post_type;
@@ -184,10 +183,10 @@ return false;
184
 
185
  if ( $post_type == 'frm_display' ) {
186
  $version = FrmAppHelper::plugin_version();
187
- wp_enqueue_script('jquery-ui-draggable');
188
- wp_enqueue_script('formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version);
189
- wp_enqueue_style('formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css', array(), $version);
190
- self::localize_script('admin');
191
  }
192
  }
193
  }
@@ -196,7 +195,7 @@ return false;
196
  global $wp_version;
197
 
198
  //we only need this class on Formidable pages
199
- if ( version_compare( $wp_version, '3.4.9', '>') ) {
200
  $classes .= ' frm_35_trigger';
201
  }
202
 
@@ -206,7 +205,7 @@ return false;
206
  public static function wp_admin_body_class($classes){
207
  global $wp_version;
208
  //we need this class everywhere in the admin for the menu
209
- if ( version_compare( $wp_version, '3.7.2', '>') ) {
210
  $classes .= ' frm_38_trigger';
211
  }
212
 
@@ -214,7 +213,7 @@ return false;
214
  }
215
 
216
  public static function load_lang(){
217
- load_plugin_textdomain('formidable', false, FrmAppHelper::plugin_folder() .'/languages/' );
218
  }
219
 
220
  /*
@@ -225,37 +224,40 @@ return false;
225
  return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
226
  }
227
 
 
 
 
 
 
228
  public static function front_head(){
229
- if (is_multisite()){
230
- $old_db_version = get_option('frm_db_version');
231
- $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option('frmpro_db_version') : false;
232
  if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
233
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
234
- self::install($old_db_version);
235
  }
236
  }
237
 
238
  $version = FrmAppHelper::plugin_version();
239
- wp_register_script('formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array('jquery'), $version, true);
240
- wp_register_script('jquery-placeholder', FrmAppHelper::plugin_url() .'/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true);
241
 
242
  if ( FrmAppHelper::is_admin() ) {
243
  // don't load this in back-end
244
  return;
245
  }
246
 
247
- self::localize_script('front');
248
-
249
- wp_enqueue_script('jquery');
250
 
251
  $frm_settings = FrmAppHelper::get_settings();
252
 
253
- $style = apply_filters('get_frm_stylesheet', array());
254
- if($style){
255
  foreach ( (array) $style as $k => $file ) {
256
- wp_register_style($k, $file, array(), $version);
257
  if ( 'all' == $frm_settings->load_style ) {
258
- wp_enqueue_style($k);
259
  }
260
  unset($k, $file);
261
  }
@@ -268,46 +270,49 @@ return false;
268
  }
269
  }
270
 
 
 
 
271
  public static function localize_script($location){
272
  wp_localize_script('formidable', 'frm_js', array(
273
  'ajax_url' => admin_url( 'admin-ajax.php' ),
274
  'images_url' => FrmAppHelper::plugin_url() .'/images',
275
- 'loading' => __('Loading&hellip;'),
276
- 'remove' => __('Remove', 'formidable'),
277
- 'offset' => apply_filters('frm_scroll_offset', 4),
278
- 'nonce' => wp_create_nonce('frm_form'),
279
  ));
280
 
281
- if($location == 'admin'){
282
  $frm_settings = FrmAppHelper::get_settings();
283
  wp_localize_script('formidable_admin', 'frm_admin_js', array(
284
- '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'),
285
  'get_page' => (isset($_GET) && isset($_GET['page'])) ? $_GET['page'] : '',
286
- 'desc' => __('(Click to add description)', 'formidable'),
287
- 'blank' => __('(blank)', 'formidable'),
288
- 'no_label' => __('(no label)', 'formidable'),
289
- 'saving' => esc_attr(__('Saving', 'formidable')),
290
- 'saved' => esc_attr(__('Saved', 'formidable')),
291
- 'ok' => __('OK'),
292
- 'cancel' => __('Cancel', 'formidable'),
293
- 'clear_default' => __('Clear default value when typing', 'formidable'),
294
- 'no_clear_default' => __('Do not clear default value when typing', 'formidable'),
295
- 'valid_default' => __('Default value will pass form validation', 'formidable'),
296
- 'no_valid_default' => __('Default value will NOT pass form validation', 'formidable'),
297
- 'deauthorize' => __('Are you sure you want to deactivate Formidable Pro on this site?', 'formidable'),
298
- 'confirm' => __('Are you sure?', 'formidable'),
299
- 'conf_delete' => __('Are you sure you want to delete this field and all data associated with it?', 'formidable'),
300
- 'conf_delete_sec' => __('WARNING: This will delete all fields inside of the section as well.', 'formidable'),
301
  'default_unique' => $frm_settings->unique_msg,
302
- 'default_conf' => __('The entered values do not match', 'formidable'),
303
- 'enter_email' => __('Enter Email', 'formidable'),
304
- 'confirm_email' => __('Confirm Email', 'formidable'),
305
- 'enter_password' => __('Enter Password', 'formidable'),
306
- 'confirm_password' => __('Confirm Password', 'formidable'),
307
- 'import_complete' => __('Import Complete', 'formidable'),
308
- 'updating' => __('Please wait while your site updates.', 'formidable'),
309
- 'nonce' => wp_create_nonce('frm_ajax'),
310
- 'no_save_warning' => __('Warning: There is no way to retrieve unsaved entries.', 'formidable'),
311
  'jquery_ui_url' => FrmAppHelper::jquery_ui_base_url(),
312
  ));
313
  }
@@ -321,10 +326,10 @@ return false;
321
  if ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) {
322
  //include css in head
323
  $uploads = FrmStylesHelper::get_upload_base();
324
- if ( is_readable($uploads['basedir'] .'/formidable/css/formidablepro.css') ) {
325
  $css_file['formidable'] = $uploads['baseurl'] .'/formidable/css/formidablepro.css';
326
  } else {
327
- $css_file['formidable'] = admin_url('admin-ajax.php') . '?action=frmpro_css';
328
  }
329
  }
330
 
@@ -336,60 +341,55 @@ return false;
336
  }
337
 
338
  public static function load_css(){
339
- $css = get_transient('frmpro_css');
340
 
341
  include(FrmAppHelper::plugin_path() .'/css/custom_theme.css.php');
342
  die();
343
  }
344
 
345
- public static function footer_js($location='footer'){
346
  global $frm_vars;
347
 
348
  $frm_settings = FrmAppHelper::get_settings();
349
  if ( $frm_vars['load_css'] && ! FrmAppHelper::is_admin() && $frm_settings->load_style != 'none' ) {
350
- $css = apply_filters('get_frm_stylesheet', array());
351
 
352
- if(!empty($css)){
353
- echo "\n".'<script type="text/javascript">';
354
  foreach ( (array) $css as $css_key => $file ) {
355
- 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"));';
356
- //wp_enqueue_style($css_key);
357
- unset($css_key);
358
- unset($file);
359
  }
360
- unset($css);
361
-
362
- echo '</script>'."\n";
363
  }
 
364
  }
365
 
366
  if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty($frm_vars['forms_loaded']) ) {
367
  //load formidable js
368
- wp_enqueue_script('formidable');
369
  }
370
  }
371
 
372
  public static function activation_install() {
373
- FrmAppHelper::delete_cache_and_transient('frm_plugin_version');
374
  FrmFormActionsController::actions_init();
375
  self::install();
376
  }
377
 
378
- public static function install($old_db_version=false){
379
  $frmdb = new FrmDb();
380
- $frmdb->upgrade($old_db_version);
381
  }
382
 
383
  public static function uninstall(){
384
  check_ajax_referer( 'frm_ajax', 'nonce' );
385
 
386
- if ( current_user_can('administrator') ) {
387
  $frmdb = new FrmDb();
388
  $frmdb->uninstall();
389
  echo true;
390
  } else {
391
  $frm_settings = FrmAppHelper::get_settings();
392
- wp_die($frm_settings->admin_permission);
393
  }
394
  die();
395
  }
@@ -408,7 +408,7 @@ return false;
408
  global $post;
409
 
410
  $frm_settings = FrmAppHelper::get_settings();
411
- if( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form'])){
412
  $content = FrmFormsController::page_preview();
413
  }
414
 
@@ -418,73 +418,76 @@ return false;
418
  public static function referer_session() {
419
  $frm_settings = FrmAppHelper::get_settings();
420
 
421
- if ( !isset($frm_settings->track) || !$frm_settings->track || defined('WP_IMPORTING') ) {
422
  return;
423
  }
424
 
425
  // keep the page history below 100
426
  $max = 100;
427
 
428
- if ( !isset($_SESSION) )
429
  session_start();
 
430
 
431
- if ( ! isset($_SESSION['frm_http_pages']) || ! is_array($_SESSION['frm_http_pages']) ) {
432
  $_SESSION['frm_http_pages'] = array('http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']);
433
  }
434
 
435
- if ( ! isset($_SESSION['frm_http_referer']) || ! is_array($_SESSION['frm_http_referer']) ) {
436
  $_SESSION['frm_http_referer'] = array();
437
  }
438
 
439
  if ( ! isset($_SERVER['HTTP_REFERER']) ) {
440
- $direct = __('Type-in or bookmark', 'formidable');
441
- if(!in_array($direct, $_SESSION['frm_http_referer']))
442
  $_SESSION['frm_http_referer'][] = $direct;
443
- } else if ( strpos($_SERVER['HTTP_REFERER'], FrmAppHelper::site_url()) === false && ! in_array($_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer']) ) {
 
444
  $_SESSION['frm_http_referer'][] = $_SERVER['HTTP_REFERER'];
445
  }
446
 
447
- if ( $_SESSION['frm_http_pages'] && ! empty($_SESSION['frm_http_pages']) && ( end($_SESSION['frm_http_pages']) != 'http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']) ) {
448
- $ext = substr(strrchr(substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '?')), '.'), 1);
449
- if ( ! in_array($ext, array('css', 'js')) ) {
450
  $_SESSION['frm_http_pages'][] = 'http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
451
  }
452
  }
453
 
454
  //keep the page history below the max
455
- if(count($_SESSION['frm_http_pages']) > $max){
456
- foreach($_SESSION['frm_http_pages'] as $pkey => $ppage){
457
- if(count($_SESSION['frm_http_pages']) <= $max)
458
  break;
 
459
 
460
- unset($_SESSION['frm_http_pages'][$pkey]);
461
  }
462
  }
463
  }
464
 
465
  public static function update_message($features){
466
  _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::update_message' );
467
- return FrmAppHelper::update_message($features);
468
  }
469
 
470
  public static function deauthorize(){
471
  check_ajax_referer( 'frm_ajax', 'nonce' );
472
 
473
- delete_option('frmpro-credentials');
474
- delete_option('frmpro-authorized');
475
- delete_site_option('frmpro-credentials');
476
- delete_site_option('frmpro-authorized');
477
  die();
478
  }
479
 
480
  //formidable shortcode
481
  public static function get_form_shortcode($atts){
482
  _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
483
- return FrmFormsController::get_form_shortcode($atts);
484
  }
485
 
486
  public static function get_postbox_class(){
487
- _deprecated_function( __FUNCTION__, '2.0');
488
  return 'postbox-container';
489
  }
490
  }
2
 
3
  class FrmAppController {
4
 
5
+ public static function menu() {
6
+ add_filter( 'plugin_action_links_'. FrmAppHelper::plugin_folder() .'/formidable.php', 'FrmAppController::settings_link' );
7
+ add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' );
8
 
9
  FrmAppHelper::maybe_add_permissions();
10
 
11
+ if ( ! current_user_can( 'frm_view_forms' ) ) {
12
  return;
13
  }
14
 
15
+ $count = count( get_post_types( array( 'show_ui' => true, '_builtin' => false, 'show_in_menu' => true ) ) );
16
  $pos = ( (int) $count > 0 ) ? '22.7' : '29.3';
17
+ $pos = apply_filters( 'frm_menu_position', $pos );
18
 
19
  $frm_settings = FrmAppHelper::get_settings();
20
+ add_menu_page( 'Formidable', $frm_settings->menu, 'frm_view_forms', 'formidable', 'FrmFormsController::route', FrmAppHelper::plugin_url() .'/images/form_16.png', $pos );
21
  }
22
 
23
  public static function load_wp_admin_style() {
24
+ wp_enqueue_style( 'frm_fonts', FrmAppHelper::plugin_url() .'/css/frm_fonts.css', array(), FrmAppHelper::plugin_version() );
25
  }
26
 
27
  public static function get_form_nav($form, $show_nav = '', $title = 'show') {
28
  global $pagenow, $frm_vars;
29
 
30
+ $show_nav = FrmAppHelper::get_param( 'show_nav', $show_nav );
31
  if ( empty($show_nav) ) {
32
  return;
33
  }
36
  if ( $form ) {
37
  FrmFormsHelper::maybe_get_form( $form );
38
 
39
+ if ( is_object( $form ) ) {
40
  $id = $form->id;
41
  }
42
  }
43
 
44
+ if ( ! isset($id) ) {
45
  $form = $id = false;
46
  }
47
 
50
 
51
  // Adds a settings link to the plugins page
52
  public static function settings_link($links){
53
+ $settings = '<a href="'. admin_url( 'admin.php?page=formidable-settings' ) .'">' . __( 'Settings', 'formidable' ) . '</a>';
54
+ array_unshift( $links, $settings );
55
 
56
  return $links;
57
  }
58
 
59
  public static function update_action_links( $actions, $plugin ) {
60
+ $frm_plugin = FrmAppHelper::plugin_folder() .'/formidable.php';
61
+ if ( $frm_plugin != $plugin ) {
62
  return $actions;
63
+ }
64
 
65
+ $db_version = get_option( 'frm_db_version' );
66
+ $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
67
 
68
  if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
69
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
70
 
71
+ return '<a href="'. add_query_arg( array('upgraded' => 'true'), menu_page_url( 'formidable', 0 ) ) .'">'. __( 'Click here to complete the upgrade', 'formidable' ) .'</a>';
72
 
73
  }
74
 
76
  }
77
 
78
  public static function pro_get_started_headline(){
79
+ if ( FrmAppHelper::is_admin_page( 'formidable' ) && isset( $_REQUEST['upgraded'] ) && 'true' == $_REQUEST['upgraded'] ) {
80
  self::install();
81
  ?>
82
+ <div id="message" class="frm_message updated"><?php _e( 'Congratulations! Formidable is ready to roll.', 'formidable' ) ?></div>
83
  <?php
84
  return;
85
  }
89
  return;
90
  }
91
 
92
+ if ( is_multisite() && ! current_user_can( 'administrator' ) ) {
93
  return;
94
  }
95
 
96
  if ( ! isset($_GET['activate']) ) {
97
+ $db_version = get_option( 'frm_db_version' );
98
+ $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
99
  if ( ( (int) $db_version < (int) FrmAppHelper::$db_version ) ||
100
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
101
  ?>
102
+ <div class="error" id="frm_install_message"><?php _e( 'Your update is not complete yet.<br/>Please deactivate and reactivate the plugin to complete the update or', 'formidable' ); ?> <a href="javascript:void(0)" id="frm_install_link"><?php _e( 'Update Now', 'formidable' ) ?></a></div>
103
  <script type="text/javascript">
104
  jQuery(document).ready(function($){ $(document.getElementById('frm_install_link')).click(frm_install_now); });
105
  function frm_install_now(){
106
  var $msg = jQuery(document.getElementById('frm_install_message'));
107
+ $msg.html('<div class="frm_plugin_updating"><?php _e( 'Please wait while your site updates.', 'formidable' ) ?><div class="spinner frm_spinner"></div></div>');
108
  jQuery.ajax({
109
  type:"POST",url:ajaxurl,data:"action=frm_install",
110
  success:function(){$msg.fadeOut('slow');}
116
  }
117
 
118
  global $frm_vars;
119
+ if ( $frm_vars['pro_is_authorized'] && ! file_exists( FrmAppHelper::plugin_path() . '/pro/formidable-pro.php' ) ) {
120
  // user is authorized, but running free version
121
  $inst_install_url = 'http://formidablepro.com/knowledgebase/manually-install-formidable-pro/';
122
  ?>
123
+ <div class="error" class="frm_previous_install"><?php echo apply_filters( 'frm_pro_update_msg', sprintf( __( 'This site has been previously authorized to run Formidable Forms.<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>
124
  <script type="text/javascript">
125
  function frm_deauthorize_now(){
126
+ if(!confirm("<?php esc_attr_e( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ) ?>"))
127
  return false;
128
+ jQuery('.frm_deauthorize_link').html('<span class="spinner"></span>');
129
  jQuery.ajax({type:'POST',url:ajaxurl,data:'action=frm_deauthorize&nonce='+wp_create_nonce('frm_ajax'),
130
  success:function(msg){jQuery('.error').fadeOut('slow');}
131
  });
143
  return;
144
  }
145
 
146
+ wp_register_script( 'bootstrap_tooltip', FrmAppHelper::plugin_url() .'/js/bootstrap.min.js', array('jquery'), '3.3.2' );
147
 
148
+ if ( isset($_GET) && ( ( isset($_GET['page']) && strpos( $_GET['page'], 'formidable' ) === 0 ) ||
149
+ ( $pagenow == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'frm_display' ) )
150
  ) {
151
  $version = FrmAppHelper::plugin_version();
152
+ add_filter( 'admin_body_class', 'FrmAppController::admin_body_class' );
153
 
154
+ wp_enqueue_script( 'jquery-ui-sortable' );
155
+ wp_enqueue_script( 'jquery-ui-draggable' );
156
+ wp_enqueue_script( 'admin-widgets' );
157
+ wp_enqueue_style( 'widgets' );
158
+ wp_enqueue_script( 'formidable' );
159
+ wp_enqueue_script( 'formidable_admin', FrmAppHelper::plugin_url() .'/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version, true );
160
+ self::localize_script( 'admin' );
161
 
162
+ wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url() .'/css/frm_admin.css', array(), $version );
163
  add_thickbox();
164
 
165
+ wp_register_script( 'formidable-editinplace', FrmAppHelper::plugin_url() .'/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0' );
 
166
 
167
+ if ( FrmAppHelper::is_admin_page( 'formidable-settings' ) || FrmAppHelper::is_admin_page( 'formidable-styles' ) ) {
168
  // load multselect js
169
+ wp_enqueue_script( 'bootstrap-multiselect', FrmAppHelper::plugin_url() .'/js/bootstrap-multiselect.js', array('jquery', 'bootstrap_tooltip'), '0.9.8', true );
170
  }
 
171
  } else if ( $pagenow == 'post.php' || ($pagenow == 'post-new.php' && isset($_REQUEST['post_type']) && $_REQUEST['post_type'] == 'frm_display') ) {
172
  if ( isset($_REQUEST['post_type']) ) {
173
  $post_type = $_REQUEST['post_type'];
174
+ } else if ( isset($_REQUEST['post']) && ! empty($_REQUEST['post']) ) {
175
+ $post = get_post( $_REQUEST['post'] );
176
+ if ( ! $post ) {
177
  return;
178
  }
179
  $post_type = $post->post_type;
183
 
184
  if ( $post_type == 'frm_display' ) {
185
  $version = FrmAppHelper::plugin_version();
186
+ wp_enqueue_script( 'jquery-ui-draggable' );
187
+ wp_enqueue_script( 'formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable', 'jquery', 'jquery-ui-draggable', 'bootstrap_tooltip'), $version );
188
+ wp_enqueue_style( 'formidable-admin', FrmAppHelper::plugin_url(). '/css/frm_admin.css', array(), $version );
189
+ self::localize_script( 'admin' );
190
  }
191
  }
192
  }
195
  global $wp_version;
196
 
197
  //we only need this class on Formidable pages
198
+ if ( version_compare( $wp_version, '3.4.9', '>' ) ) {
199
  $classes .= ' frm_35_trigger';
200
  }
201
 
205
  public static function wp_admin_body_class($classes){
206
  global $wp_version;
207
  //we need this class everywhere in the admin for the menu
208
+ if ( version_compare( $wp_version, '3.7.2', '>' ) ) {
209
  $classes .= ' frm_38_trigger';
210
  }
211
 
213
  }
214
 
215
  public static function load_lang(){
216
+ load_plugin_textdomain( 'formidable', false, FrmAppHelper::plugin_folder() .'/languages/' );
217
  }
218
 
219
  /*
224
  return preg_replace_callback( $regex, 'FrmAppHelper::widget_text_filter_callback', $content );
225
  }
226
 
227
+ public static function widget_text_filter_callback( $matches ) {
228
+ _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::widget_text_filter_callback' );
229
+ return FrmAppHelper::widget_text_filter_callback( $matches );
230
+ }
231
+
232
  public static function front_head(){
233
+ if ( is_multisite() ) {
234
+ $old_db_version = get_option( 'frm_db_version' );
235
+ $pro_db_version = FrmAppHelper::pro_is_installed() ? get_option( 'frmpro_db_version' ) : false;
236
  if ( ( (int) $old_db_version < (int) FrmAppHelper::$db_version ) ||
237
  ( FrmAppHelper::pro_is_installed() && (int) $pro_db_version < (int) FrmAppHelper::$pro_db_version ) ) {
238
+ self::install( $old_db_version );
239
  }
240
  }
241
 
242
  $version = FrmAppHelper::plugin_version();
243
+ wp_register_script( 'formidable', FrmAppHelper::plugin_url() . '/js/formidable.min.js', array('jquery'), $version, true );
244
+ wp_register_script( 'jquery-placeholder', FrmAppHelper::plugin_url() .'/js/jquery/jquery.placeholder.js', array('jquery'), '2.0.7', true );
245
 
246
  if ( FrmAppHelper::is_admin() ) {
247
  // don't load this in back-end
248
  return;
249
  }
250
 
251
+ self::localize_script( 'front' );
 
 
252
 
253
  $frm_settings = FrmAppHelper::get_settings();
254
 
255
+ $style = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
256
+ if ( $style ) {
257
  foreach ( (array) $style as $k => $file ) {
258
+ wp_register_style( $k, $file, array(), $version );
259
  if ( 'all' == $frm_settings->load_style ) {
260
+ wp_enqueue_style( $k );
261
  }
262
  unset($k, $file);
263
  }
270
  }
271
  }
272
 
273
+ /**
274
+ * @param string $location
275
+ */
276
  public static function localize_script($location){
277
  wp_localize_script('formidable', 'frm_js', array(
278
  'ajax_url' => admin_url( 'admin-ajax.php' ),
279
  'images_url' => FrmAppHelper::plugin_url() .'/images',
280
+ 'loading' => __( 'Loading&hellip;' ),
281
+ 'remove' => __( 'Remove', 'formidable' ),
282
+ 'offset' => apply_filters( 'frm_scroll_offset', 4 ),
283
+ 'nonce' => wp_create_nonce( 'frm_form' ),
284
  ));
285
 
286
+ if ( $location == 'admin' ) {
287
  $frm_settings = FrmAppHelper::get_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 to add description)', 'formidable' ),
292
+ 'blank' => __( '(blank)', 'formidable' ),
293
+ 'no_label' => __( '(no label)', 'formidable' ),
294
+ 'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
295
+ 'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
296
+ 'ok' => __( 'OK' ),
297
+ 'cancel' => __( 'Cancel', 'formidable' ),
298
+ 'clear_default' => __( 'Clear default value when typing', 'formidable' ),
299
+ 'no_clear_default' => __( 'Do not clear default value when typing', 'formidable' ),
300
+ 'valid_default' => __( 'Default value will pass form validation', 'formidable' ),
301
+ 'no_valid_default' => __( 'Default value will NOT pass form validation', 'formidable' ),
302
+ 'deauthorize' => __( 'Are you sure you want to deactivate Formidable Forms on this site?', 'formidable' ),
303
+ 'confirm' => __( 'Are you sure?', 'formidable' ),
304
+ 'conf_delete' => __( 'Are you sure you want to delete this field and all data associated with it?', 'formidable' ),
305
+ 'conf_delete_sec' => __( 'WARNING: This will delete all fields inside of the section as well.', 'formidable'),
306
  'default_unique' => $frm_settings->unique_msg,
307
+ 'default_conf' => __( 'The entered values do not match', 'formidable' ),
308
+ 'enter_email' => __( 'Enter Email', 'formidable' ),
309
+ 'confirm_email' => __( 'Confirm Email', 'formidable' ),
310
+ 'enter_password' => __( 'Enter Password', 'formidable' ),
311
+ 'confirm_password' => __( 'Confirm Password', 'formidable' ),
312
+ 'import_complete' => __( 'Import Complete', 'formidable' ),
313
+ 'updating' => __( 'Please wait while your site updates.', 'formidable' ),
314
+ 'nonce' => wp_create_nonce( 'frm_ajax' ),
315
+ 'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
316
  'jquery_ui_url' => FrmAppHelper::jquery_ui_base_url(),
317
  ));
318
  }
326
  if ( ! isset($frm_vars['css_loaded']) || ! $frm_vars['css_loaded'] ) {
327
  //include css in head
328
  $uploads = FrmStylesHelper::get_upload_base();
329
+ if ( is_readable( $uploads['basedir'] .'/formidable/css/formidablepro.css' ) ) {
330
  $css_file['formidable'] = $uploads['baseurl'] .'/formidable/css/formidablepro.css';
331
  } else {
332
+ $css_file['formidable'] = admin_url( 'admin-ajax.php' ) . '?action=frmpro_css';
333
  }
334
  }
335
 
341
  }
342
 
343
  public static function load_css(){
344
+ $css = get_transient( 'frmpro_css' );
345
 
346
  include(FrmAppHelper::plugin_path() .'/css/custom_theme.css.php');
347
  die();
348
  }
349
 
350
+ public static function footer_js( $location = 'footer' ) {
351
  global $frm_vars;
352
 
353
  $frm_settings = FrmAppHelper::get_settings();
354
  if ( $frm_vars['load_css'] && ! FrmAppHelper::is_admin() && $frm_settings->load_style != 'none' ) {
355
+ $css = apply_filters( 'get_frm_stylesheet', self::custom_stylesheet() );
356
 
357
+ if ( ! empty($css) ) {
 
358
  foreach ( (array) $css as $css_key => $file ) {
359
+ wp_enqueue_style( $css_key );
360
+ unset($css_key, $file);
 
 
361
  }
 
 
 
362
  }
363
+ unset($css);
364
  }
365
 
366
  if ( ! FrmAppHelper::is_admin() && $location != 'header' && ! empty($frm_vars['forms_loaded']) ) {
367
  //load formidable js
368
+ wp_enqueue_script( 'formidable' );
369
  }
370
  }
371
 
372
  public static function activation_install() {
373
+ FrmAppHelper::delete_cache_and_transient( 'frm_plugin_version' );
374
  FrmFormActionsController::actions_init();
375
  self::install();
376
  }
377
 
378
+ public static function install( $old_db_version = false ) {
379
  $frmdb = new FrmDb();
380
+ $frmdb->upgrade( $old_db_version );
381
  }
382
 
383
  public static function uninstall(){
384
  check_ajax_referer( 'frm_ajax', 'nonce' );
385
 
386
+ if ( current_user_can( 'administrator' ) ) {
387
  $frmdb = new FrmDb();
388
  $frmdb->uninstall();
389
  echo true;
390
  } else {
391
  $frm_settings = FrmAppHelper::get_settings();
392
+ wp_die( $frm_settings->admin_permission );
393
  }
394
  die();
395
  }
408
  global $post;
409
 
410
  $frm_settings = FrmAppHelper::get_settings();
411
+ if ( $post && $post->ID == $frm_settings->preview_page_id && isset($_GET['form']) ) {
412
  $content = FrmFormsController::page_preview();
413
  }
414
 
418
  public static function referer_session() {
419
  $frm_settings = FrmAppHelper::get_settings();
420
 
421
+ if ( ! isset($frm_settings->track) || ! $frm_settings->track || defined( 'WP_IMPORTING' ) ) {
422
  return;
423
  }
424
 
425
  // keep the page history below 100
426
  $max = 100;
427
 
428
+ if ( ! isset($_SESSION) ) {
429
  session_start();
430
+ }
431
 
432
+ if ( ! isset($_SESSION['frm_http_pages']) || ! is_array( $_SESSION['frm_http_pages'] ) ) {
433
  $_SESSION['frm_http_pages'] = array('http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']);
434
  }
435
 
436
+ if ( ! isset($_SESSION['frm_http_referer']) || ! is_array( $_SESSION['frm_http_referer'] ) ) {
437
  $_SESSION['frm_http_referer'] = array();
438
  }
439
 
440
  if ( ! isset($_SERVER['HTTP_REFERER']) ) {
441
+ $direct = __( 'Type-in or bookmark', 'formidable' );
442
+ if ( ! in_array( $direct, $_SESSION['frm_http_referer'] ) ) {
443
  $_SESSION['frm_http_referer'][] = $direct;
444
+ }
445
+ } else if ( strpos($_SERVER['HTTP_REFERER'], FrmAppHelper::site_url()) === false && ! in_array( $_SERVER['HTTP_REFERER'], $_SESSION['frm_http_referer'] ) ) {
446
  $_SESSION['frm_http_referer'][] = $_SERVER['HTTP_REFERER'];
447
  }
448
 
449
+ if ( $_SESSION['frm_http_pages'] && ! empty($_SESSION['frm_http_pages']) && ( end( $_SESSION['frm_http_pages'] ) != 'http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI']) ) {
450
+ $ext = substr( strrchr( substr( $_SERVER['REQUEST_URI'], 0, strrpos( $_SERVER['REQUEST_URI'], '?' ) ), '.' ), 1 );
451
+ if ( ! in_array( $ext, array('css', 'js') ) ) {
452
  $_SESSION['frm_http_pages'][] = 'http://'. $_SERVER['SERVER_NAME']. $_SERVER['REQUEST_URI'];
453
  }
454
  }
455
 
456
  //keep the page history below the max
457
+ if ( count( $_SESSION['frm_http_pages'] ) > $max ) {
458
+ foreach ( $_SESSION['frm_http_pages'] as $pkey => $ppage ) {
459
+ if ( count( $_SESSION['frm_http_pages'] ) <= $max ) {
460
  break;
461
+ }
462
 
463
+ unset($_SESSION['frm_http_pages'][ $pkey ]);
464
  }
465
  }
466
  }
467
 
468
  public static function update_message($features){
469
  _deprecated_function( __FUNCTION__, '2.0', 'FrmAppHelper::update_message' );
470
+ return FrmAppHelper::update_message( $features );
471
  }
472
 
473
  public static function deauthorize(){
474
  check_ajax_referer( 'frm_ajax', 'nonce' );
475
 
476
+ delete_option( 'frmpro-credentials' );
477
+ delete_option( 'frmpro-authorized' );
478
+ delete_site_option( 'frmpro-credentials' );
479
+ delete_site_option( 'frmpro-authorized' );
480
  die();
481
  }
482
 
483
  //formidable shortcode
484
  public static function get_form_shortcode($atts){
485
  _deprecated_function( __FUNCTION__, '1.07.05', 'FrmFormsController::get_form_shortcode()' );
486
+ return FrmFormsController::get_form_shortcode( $atts );
487
  }
488
 
489
  public static function get_postbox_class(){
490
+ _deprecated_function( __FUNCTION__, '2.0' );
491
  return 'postbox-container';
492
  }
493
  }
classes/controllers/FrmEntriesController.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class FrmEntriesController{
4
 
5
  public static function menu() {
6
  if ( current_user_can('administrator') && !current_user_can('frm_view_entries') ) {
@@ -9,11 +9,10 @@ class FrmEntriesController{
9
  $wp_roles->add_cap( 'administrator', 'frm_delete_entries' );
10
  }
11
 
12
- $frm_settings = FrmAppHelper::get_settings();
13
-
14
- add_submenu_page('formidable', $frm_settings->menu .' | '. __('Entries', 'formidable'), __('Entries', 'formidable'), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
15
 
16
  if ( ! isset($_GET['frm_action']) || ! in_array($_GET['frm_action'], array('edit', 'show')) ) {
 
17
  add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
18
  add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
19
  add_filter('get_user_option_manage'. sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
@@ -70,8 +69,8 @@ class FrmEntriesController{
70
  global $frm_vars, $wpdb;
71
  $form_id = FrmEntriesHelper::get_current_form_id();
72
 
73
- $columns[$form_id .'_id'] = 'ID';
74
- $columns[$form_id .'_item_key'] = __('Entry Key', 'formidable');
75
 
76
  if ( ! $form_id ) {
77
  return $columns;
@@ -84,35 +83,36 @@ class FrmEntriesController{
84
  continue;
85
  }
86
 
87
- if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
88
- $columns[$form_id .'_frmsep_'. $form_col->field_key] = FrmAppHelper::truncate($form_col->name, 35);
89
- }
90
-
91
- if ( $form_col->type == 'form' && isset($form_col->field_options['form_select']) && !empty($form_col->field_options['form_select']) ) {
92
  $sub_form_cols = FrmField::get_all_for_form($form_col->field_options['form_select']);
93
 
94
  if ( $sub_form_cols ) {
95
  foreach ( $sub_form_cols as $k => $sub_form_col ) {
96
  if ( in_array($sub_form_col->type, FrmFieldsHelper::no_save_fields()) ) {
97
- unset($sub_form_cols[$k]);
98
  continue;
99
  }
100
- $columns[$form_id .'_'. $sub_form_col->field_key .'-_-'. $form_col->id] = FrmAppHelper::truncate($sub_form_col->name, 35);
101
  unset($sub_form_col);
102
  }
103
  }
104
  unset($sub_form_cols);
105
- } else if ( $form_col->form_id != $form_id ) {
106
- $columns[$form_id .'_'. $form_col->field_key .'-_-form'. $form_col->form_id] = FrmAppHelper::truncate($form_col->name, 35);
107
  } else {
108
- $columns[$form_id .'_'. $form_col->field_key] = FrmAppHelper::truncate($form_col->name, 35);
109
- }
 
 
110
 
 
 
 
 
 
111
  }
112
 
113
- $columns[$form_id .'_created_at'] = __('Entry creation date', 'formidable');
114
- $columns[$form_id .'_updated_at'] = __('Entry update date', 'formidable');
115
- $columns[$form_id .'_ip'] = 'IP';
116
 
117
  $frm_vars['cols'] = $columns;
118
 
@@ -143,18 +143,21 @@ class FrmEntriesController{
143
  public static function update_hidden_cols($meta_id, $object_id, $meta_key, $meta_value ){
144
  $frm_settings = FrmAppHelper::get_settings();
145
 
146
- if($meta_key != 'manage'. sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden')
 
147
  return;
 
148
 
149
  global $frm_vars;
150
  if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
151
  return; //don't continue if there's no previous value
152
  }
153
 
154
- foreach($meta_value as $mk => $mv){
155
  //remove blank values
156
- if(empty($mv))
157
- unset($meta_value[$mk]);
 
158
  }
159
 
160
  $cur_form_prefix = reset($meta_value);
@@ -170,8 +173,10 @@ class FrmEntriesController{
170
 
171
  $form_prefix = explode('_', $prev_hidden);
172
  $form_prefix = $form_prefix[0];
173
- if($form_prefix == $cur_form_prefix) //don't add back columns that are meant to be hidden
 
174
  continue;
 
175
 
176
  $meta_value[] = $prev_hidden;
177
  $save = true;
@@ -180,7 +185,7 @@ class FrmEntriesController{
180
 
181
  if($save){
182
  $user = wp_get_current_user();
183
- update_user_option($user->ID, 'manage'. sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden', $meta_value, true);
184
  }
185
  }
186
 
@@ -244,10 +249,11 @@ class FrmEntriesController{
244
  return $result;
245
 
246
  global $frm_vars;
247
- if(isset($frm_vars['current_form']) and $frm_vars['current_form'])
248
  $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
 
249
 
250
- if(isset($frm_vars['current_form']) and $frm_vars['current_form'] and isset($frm_vars['current_form']->options['hidden_cols']) and !empty($frm_vars['current_form']->options['hidden_cols'])){
251
  $result = $frm_vars['current_form']->options['hidden_cols'];
252
  }else{
253
  $cols = $frm_vars['cols'];
@@ -263,8 +269,7 @@ class FrmEntriesController{
263
  if($i > $max_columns)
264
  $result[] = $col_key; //remove some columns by default
265
  $i--;
266
- unset($col_key);
267
- unset($col);
268
  }
269
  }
270
 
@@ -418,13 +423,15 @@ class FrmEntriesController{
418
  global $frm_vars;
419
 
420
  $form = FrmForm::getOne($_POST['form_id']);
421
- if(!$form)
422
  return;
 
423
 
424
  $params = self::get_params($form);
425
 
426
- if(!isset($frm_vars['form_params']))
427
  $frm_vars['form_params'] = array();
 
428
  $frm_vars['form_params'][$form->id] = $params;
429
 
430
  if(isset($frm_vars['created_entries'][$_POST['form_id']]))
@@ -459,8 +466,9 @@ class FrmEntriesController{
459
  }
460
 
461
  private static function _delete_entry($entry_id, $form){
462
- if(!$form)
463
  return;
 
464
 
465
  $form->options = maybe_unserialize($form->options);
466
  if ( isset($form->options['no_save']) && $form->options['no_save'] ) {
@@ -512,6 +520,8 @@ class FrmEntriesController{
512
 
513
  if ( $atts['format'] == 'json' ) {
514
  return json_encode($values);
 
 
515
  }
516
 
517
  $content = array();
@@ -605,8 +615,9 @@ class FrmEntriesController{
605
 
606
  $values = array();
607
  $values['posted_form_id'] = FrmAppHelper::get_param('form_id');
608
- if (!is_numeric($values['posted_form_id']))
609
  $values['posted_form_id'] = FrmAppHelper::get_param('form');
 
610
 
611
  if ($form->id == $values['posted_form_id']){ //if there are two forms on the same page, make sure not to submit both
612
  foreach ($default_values as $var => $default){
@@ -632,4 +643,12 @@ class FrmEntriesController{
632
  return $values;
633
  }
634
 
 
 
 
 
 
 
 
 
635
  }
1
  <?php
2
 
3
+ class FrmEntriesController {
4
 
5
  public static function menu() {
6
  if ( current_user_can('administrator') && !current_user_can('frm_view_entries') ) {
9
  $wp_roles->add_cap( 'administrator', 'frm_delete_entries' );
10
  }
11
 
12
+ add_submenu_page('formidable', 'Formidable | '. __('Entries', 'formidable'), __('Entries', 'formidable'), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
 
 
13
 
14
  if ( ! isset($_GET['frm_action']) || ! in_array($_GET['frm_action'], array('edit', 'show')) ) {
15
+ $frm_settings = FrmAppHelper::get_settings();
16
  add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-entries_columns', 'FrmEntriesController::manage_columns' );
17
  add_filter('manage_'. sanitize_title($frm_settings->menu) .'_page_formidable-entries_sortable_columns', 'FrmEntriesController::sortable_columns' );
18
  add_filter('get_user_option_manage'. sanitize_title($frm_settings->menu) .'_page_formidable-entriescolumnshidden', 'FrmEntriesController::hidden_columns' );
69
  global $frm_vars, $wpdb;
70
  $form_id = FrmEntriesHelper::get_current_form_id();
71
 
72
+ $columns[ $form_id .'_id' ] = 'ID';
73
+ $columns[ $form_id .'_item_key' ] = __('Entry Key', 'formidable');
74
 
75
  if ( ! $form_id ) {
76
  return $columns;
83
  continue;
84
  }
85
 
86
+ if ( $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] ) ) {
 
 
 
 
87
  $sub_form_cols = FrmField::get_all_for_form($form_col->field_options['form_select']);
88
 
89
  if ( $sub_form_cols ) {
90
  foreach ( $sub_form_cols as $k => $sub_form_col ) {
91
  if ( in_array($sub_form_col->type, FrmFieldsHelper::no_save_fields()) ) {
92
+ unset( $sub_form_cols[ $k ] );
93
  continue;
94
  }
95
+ $columns[ $form_id .'_'. $sub_form_col->field_key .'-_-'. $form_col->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
96
  unset($sub_form_col);
97
  }
98
  }
99
  unset($sub_form_cols);
 
 
100
  } else {
101
+ $col_id = $form_col->field_key;
102
+ if ( $form_col->form_id != $form_id ) {
103
+ $col_id .= '-_-form'. $form_col->form_id;
104
+ }
105
 
106
+ if ( isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value'] ) {
107
+ $columns[ $form_id .'_frmsep_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
108
+ }
109
+ $columns[ $form_id .'_'. $col_id ] = FrmAppHelper::truncate( $form_col->name, 35 );
110
+ }
111
  }
112
 
113
+ $columns[ $form_id .'_created_at' ] = __( 'Entry creation date', 'formidable' );
114
+ $columns[ $form_id .'_updated_at' ] = __( 'Entry update date', 'formidable' );
115
+ $columns[ $form_id .'_ip' ] = 'IP';
116
 
117
  $frm_vars['cols'] = $columns;
118
 
143
  public static function update_hidden_cols($meta_id, $object_id, $meta_key, $meta_value ){
144
  $frm_settings = FrmAppHelper::get_settings();
145
 
146
+ $sanitized = sanitize_title($frm_settings->menu);
147
+ if ( $meta_key != 'manage'. $sanitized .'_page_formidable-entriescolumnshidden' ) {
148
  return;
149
+ }
150
 
151
  global $frm_vars;
152
  if ( ! isset($frm_vars['prev_hidden_cols']) || ! $frm_vars['prev_hidden_cols'] ) {
153
  return; //don't continue if there's no previous value
154
  }
155
 
156
+ foreach ( $meta_value as $mk => $mv ) {
157
  //remove blank values
158
+ if ( empty( $mv ) ) {
159
+ unset( $meta_value[ $mk ] );
160
+ }
161
  }
162
 
163
  $cur_form_prefix = reset($meta_value);
173
 
174
  $form_prefix = explode('_', $prev_hidden);
175
  $form_prefix = $form_prefix[0];
176
+ if ( $form_prefix == $cur_form_prefix ) {
177
+ //don't add back columns that are meant to be hidden
178
  continue;
179
+ }
180
 
181
  $meta_value[] = $prev_hidden;
182
  $save = true;
185
 
186
  if($save){
187
  $user = wp_get_current_user();
188
+ update_user_option( $user->ID, 'manage'. $sanitized .'_page_formidable-entriescolumnshidden', $meta_value, true );
189
  }
190
  }
191
 
249
  return $result;
250
 
251
  global $frm_vars;
252
+ if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] ) {
253
  $frm_vars['current_form']->options = maybe_unserialize($frm_vars['current_form']->options);
254
+ }
255
 
256
+ if ( isset($frm_vars['current_form']) && $frm_vars['current_form'] && isset($frm_vars['current_form']->options['hidden_cols']) && ! empty($frm_vars['current_form']->options['hidden_cols']) ) {
257
  $result = $frm_vars['current_form']->options['hidden_cols'];
258
  }else{
259
  $cols = $frm_vars['cols'];
269
  if($i > $max_columns)
270
  $result[] = $col_key; //remove some columns by default
271
  $i--;
272
+ unset($col_key, $col);
 
273
  }
274
  }
275
 
423
  global $frm_vars;
424
 
425
  $form = FrmForm::getOne($_POST['form_id']);
426
+ if ( ! $form ) {
427
  return;
428
+ }
429
 
430
  $params = self::get_params($form);
431
 
432
+ if ( ! isset($frm_vars['form_params']) ) {
433
  $frm_vars['form_params'] = array();
434
+ }
435
  $frm_vars['form_params'][$form->id] = $params;
436
 
437
  if(isset($frm_vars['created_entries'][$_POST['form_id']]))
466
  }
467
 
468
  private static function _delete_entry($entry_id, $form){
469
+ if ( ! $form ) {
470
  return;
471
+ }
472
 
473
  $form->options = maybe_unserialize($form->options);
474
  if ( isset($form->options['no_save']) && $form->options['no_save'] ) {
520
 
521
  if ( $atts['format'] == 'json' ) {
522
  return json_encode($values);
523
+ } else if ( $atts['format'] == 'array' ) {
524
+ return $values;
525
  }
526
 
527
  $content = array();
615
 
616
  $values = array();
617
  $values['posted_form_id'] = FrmAppHelper::get_param('form_id');
618
+ if ( ! is_numeric($values['posted_form_id']) ) {
619
  $values['posted_form_id'] = FrmAppHelper::get_param('form');
620
+ }
621
 
622
  if ($form->id == $values['posted_form_id']){ //if there are two forms on the same page, make sure not to submit both
623
  foreach ($default_values as $var => $default){
643
  return $values;
644
  }
645
 
646
+ public static function entry_sidebar($entry) {
647
+ $data = maybe_unserialize($entry->description);
648
+ $date_format = get_option('date_format');
649
+ $time_format = get_option('time_format');
650
+
651
+ include(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/sidebar-shared.php');
652
+ }
653
+
654
  }
classes/controllers/FrmFieldsController.php CHANGED
@@ -19,10 +19,14 @@ class FrmFieldsController{
19
  foreach ( $fields as $field ) {
20
  $field = htmlspecialchars_decode(nl2br($field));
21
  $field = json_decode($field, true);
 
 
 
 
22
 
23
  $field_id = $field['id'];
24
 
25
- if ( !isset($field['value']) ) {
26
  $field['value'] = '';
27
  }
28
 
@@ -77,7 +81,7 @@ class FrmFieldsController{
77
 
78
  $field_id = (int) $_POST['field'];
79
  $form_id = (int) $_POST['form_id'];
80
- if ( !$field_id || !$form_id ) {
81
  return;
82
  }
83
 
@@ -263,7 +267,7 @@ class FrmFieldsController{
263
  $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
264
  $value = isset($this_opt['value']) ? $this_opt['value'] : '';
265
 
266
- if ( !isset($new_label) ) {
267
  $new_label = $label;
268
  }
269
 
@@ -290,21 +294,20 @@ class FrmFieldsController{
290
  $response = array( 'other' => true );
291
 
292
  //If the deleted option is an "other" option
293
- if ( strpos( $opt_key, 'other' ) !== false ) {
294
  //Assume all other options are gone, unless proven otherwise
295
  $other = false;
296
 
297
- //Check if all other options are really gone in CB field
298
- if ( $field->type == 'checkbox' ) {
299
- foreach ( $options as $o_key => $o_val ) {
300
- //If there is still an other option in the field, set other to true
301
- if ( $o_key && strpos( $o_key, 'other' ) !== false ) {
302
- $other = true;
303
- break;
304
- }
305
- unset( $o_key, $o_val );
306
  }
 
307
  }
 
308
  //If all other options are gone
309
  if ( false === $other ) {
310
  $field_options = maybe_unserialize( $field->field_options );
@@ -424,8 +427,7 @@ class FrmFieldsController{
424
  }
425
  unset($vals);
426
  }
427
- unset($opt_key);
428
- unset($opt);
429
  }
430
  }
431
 
@@ -436,9 +438,9 @@ class FrmFieldsController{
436
  if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
437
  $other_array[$opt_key] = $opt;
438
  }
439
- unset($opt_key,$opt);
440
  }
441
- if ( $other_array ) {
442
  $opts = array_merge( $opts, $other_array);
443
  }
444
  }
19
  foreach ( $fields as $field ) {
20
  $field = htmlspecialchars_decode(nl2br($field));
21
  $field = json_decode($field, true);
22
+ if ( ! isset($field['id']) ) {
23
+ // this field may have already been loaded
24
+ continue;
25
+ }
26
 
27
  $field_id = $field['id'];
28
 
29
+ if ( ! isset( $field['value'] ) ) {
30
  $field['value'] = '';
31
  }
32
 
81
 
82
  $field_id = (int) $_POST['field'];
83
  $form_id = (int) $_POST['form_id'];
84
+ if ( ! $field_id || ! $form_id ) {
85
  return;
86
  }
87
 
267
  $label = isset($this_opt['label']) ? $this_opt['label'] : reset($this_opt);
268
  $value = isset($this_opt['value']) ? $this_opt['value'] : '';
269
 
270
+ if ( ! isset( $new_label ) ) {
271
  $new_label = $label;
272
  }
273
 
294
  $response = array( 'other' => true );
295
 
296
  //If the deleted option is an "other" option
297
+ if ( FrmAppHelper::is_other_opt( $opt_key ) ) {
298
  //Assume all other options are gone, unless proven otherwise
299
  $other = false;
300
 
301
+ //Check if all other options are really gone
302
+ foreach ( $options as $o_key => $o_val ) {
303
+ //If there is still an other option in the field, set other to true
304
+ if ( FrmAppHelper::is_other_opt( $o_key ) ) {
305
+ $other = true;
306
+ break;
 
 
 
307
  }
308
+ unset( $o_key, $o_val );
309
  }
310
+
311
  //If all other options are gone
312
  if ( false === $other ) {
313
  $field_options = maybe_unserialize( $field->field_options );
427
  }
428
  unset($vals);
429
  }
430
+ unset($opt_key, $opt);
 
431
  }
432
  }
433
 
438
  if ( $opt_key && strpos( $opt_key, 'other' ) !== false ) {
439
  $other_array[$opt_key] = $opt;
440
  }
441
+ unset($opt_key, $opt);
442
  }
443
+ if ( ! empty($other_array) ) {
444
  $opts = array_merge( $opts, $other_array);
445
  }
446
  }
classes/controllers/FrmFormActionsController.php CHANGED
@@ -26,10 +26,13 @@ class FrmFormActionsController{
26
  * menu_order: form id
27
  * post_excerpt: action type
28
  */
 
 
29
  }
30
 
31
  public static function actions_init() {
32
  self::$registered_actions = new Frm_Form_Action_Factory();
 
33
  do_action( 'frm_form_actions_init' );
34
  }
35
 
@@ -112,7 +115,7 @@ class FrmFormActionsController{
112
  }
113
 
114
  foreach ( $form_actions as $action ) {
115
- if ( !isset($action_map[$action->post_excerpt]) ) {
116
  // don't try and show settings if action no longer exists
117
  continue;
118
  }
@@ -174,7 +177,7 @@ class FrmFormActionsController{
174
  $f = (array) $f;
175
  $opts = (array) $f['field_options'];
176
  $f = array_merge($opts, $f);
177
- if ( !isset($f['post_field']) ) {
178
  $f['post_field'] = '';
179
  }
180
  $values['fields'][] = $f;
@@ -189,7 +192,7 @@ class FrmFormActionsController{
189
 
190
  $registered_actions = self::$registered_actions->actions;
191
 
192
- $old_actions = $wpdb->get_col($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE menu_order=%d", $form_id));
193
  $new_actions = array();
194
 
195
  foreach ( $registered_actions as $registered_action ) {
@@ -217,6 +220,9 @@ class FrmFormActionsController{
217
  self::trigger_actions('create', $form_id, $entry_id);
218
  }
219
 
 
 
 
220
  public static function trigger_actions($event, $form, $entry, $type = 'all') {
221
  $form_actions = FrmFormActionsHelper::get_action_for_form((is_object($form) ? $form->id : $form), $type);
222
 
@@ -291,7 +297,7 @@ class FrmFormActionsController{
291
  return;
292
  }
293
 
294
- $action_controls = FrmFormActionsController::get_form_actions( );
295
 
296
  foreach ( $action_controls as $action_control ) {
297
  $action_control->duplicate_form_actions($form_id, $args['old_id']);
@@ -302,7 +308,7 @@ class FrmFormActionsController{
302
  public static function limit_by_type( $where ) {
303
  global $frm_vars, $wpdb;
304
 
305
- if ( !isset($frm_vars['action_type']) ) {
306
  return $where;
307
  }
308
 
@@ -335,7 +341,7 @@ class Frm_Form_Action_Factory {
335
 
336
  foreach ( $keys as $key ) {
337
  // don't register new action if old action with the same id is already registered
338
- if ( !isset($this->actions[$key]) ) {
339
  $this->actions[$key]->_register();
340
  }
341
  }
26
  * menu_order: form id
27
  * post_excerpt: action type
28
  */
29
+
30
+ self::actions_init();
31
  }
32
 
33
  public static function actions_init() {
34
  self::$registered_actions = new Frm_Form_Action_Factory();
35
+ self::register_actions();
36
  do_action( 'frm_form_actions_init' );
37
  }
38
 
115
  }
116
 
117
  foreach ( $form_actions as $action ) {
118
+ if ( ! isset( $action_map[ $action->post_excerpt ] ) ) {
119
  // don't try and show settings if action no longer exists
120
  continue;
121
  }
177
  $f = (array) $f;
178
  $opts = (array) $f['field_options'];
179
  $f = array_merge($opts, $f);
180
+ if ( ! isset( $f['post_field'] ) ) {
181
  $f['post_field'] = '';
182
  }
183
  $values['fields'][] = $f;
192
 
193
  $registered_actions = self::$registered_actions->actions;
194
 
195
+ $old_actions = $wpdb->get_col($wpdb->prepare('SELECT ID FROM '. $wpdb->posts .' WHERE post_type=%s AND menu_order=%d', self::$action_post_type, $form_id));
196
  $new_actions = array();
197
 
198
  foreach ( $registered_actions as $registered_action ) {
220
  self::trigger_actions('create', $form_id, $entry_id);
221
  }
222
 
223
+ /**
224
+ * @param string $event
225
+ */
226
  public static function trigger_actions($event, $form, $entry, $type = 'all') {
227
  $form_actions = FrmFormActionsHelper::get_action_for_form((is_object($form) ? $form->id : $form), $type);
228
 
297
  return;
298
  }
299
 
300
+ $action_controls = self::get_form_actions( );
301
 
302
  foreach ( $action_controls as $action_control ) {
303
  $action_control->duplicate_form_actions($form_id, $args['old_id']);
308
  public static function limit_by_type( $where ) {
309
  global $frm_vars, $wpdb;
310
 
311
+ if ( ! isset( $frm_vars['action_type'] ) ) {
312
  return $where;
313
  }
314
 
341
 
342
  foreach ( $keys as $key ) {
343
  // don't register new action if old action with the same id is already registered
344
+ if ( ! isset( $this->actions[$key] ) ) {
345
  $this->actions[$key]->_register();
346
  }
347
  }
classes/controllers/FrmFormsController.php CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
 
3
  class FrmFormsController{
4
- public static $action_post_type = 'frm_form_actions';
5
 
6
  public static function trigger_load_form_hooks() {
7
  FrmHooksController::trigger_load_hook( 'load_form_hooks' );
@@ -15,9 +14,7 @@ class FrmFormsController{
15
  }
16
 
17
  public static function menu(){
18
- $frm_settings = FrmAppHelper::get_settings();
19
-
20
- add_submenu_page('formidable', $frm_settings->menu .' | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
21
 
22
  add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
23
 
@@ -27,7 +24,6 @@ class FrmFormsController{
27
 
28
  public static function head(){
29
  wp_enqueue_script('formidable-editinplace');
30
- wp_enqueue_script('jquery-frm-themepicker');
31
 
32
  if ( wp_is_mobile() ) {
33
  wp_enqueue_script( 'jquery-touch-punch' );
@@ -43,7 +39,9 @@ class FrmFormsController{
43
  FrmAppHelper::permission_check('frm_view_forms');
44
 
45
  $params = FrmFormsHelper::get_params();
46
- $errors = apply_filters('frm_admin_list_form_action', array());
 
 
47
  return self::display_forms_list($params, '', false, $errors);
48
  }
49
 
@@ -84,11 +82,13 @@ class FrmFormsController{
84
  }
85
 
86
  //Set radio button and checkbox meta equal to "other" value
87
- $values = FrmEntriesHelper::set_other_vals( $values );
 
 
88
 
89
  $id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
90
 
91
- if ( ! current_user_can('frm_edit_forms') || ( $_POST && (!isset($values['frm_save_form']) || !wp_verify_nonce($values['frm_save_form'], 'frm_save_form_nonce'))) ) {
92
  $frm_settings = FrmAppHelper::get_settings();
93
  $errors = array( 'form' => $frm_settings->admin_permission );
94
  } else {
@@ -106,8 +106,6 @@ class FrmFormsController{
106
  }else{
107
  FrmForm::update( $id, $values, true );
108
  die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
109
- //$message = __('Form was Successfully Created', 'formidable');
110
- //return self::settings($record, $message);
111
  }
112
  }
113
 
@@ -121,8 +119,9 @@ class FrmFormsController{
121
  public static function settings($id=false, $message=''){
122
  FrmAppHelper::permission_check('frm_edit_forms');
123
 
124
- if(!$id or !is_numeric($id))
125
- $id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
 
126
  return self::get_settings_vars($id, '', $message);
127
  }
128
 
@@ -145,7 +144,7 @@ class FrmFormsController{
145
  }
146
 
147
  public static function edit_key(){
148
- FrmAppHelper::ajax_permission_check('frm_edit_forms');
149
 
150
  global $wpdb;
151
  $values = array('form_key' => trim($_POST['update_value']));
@@ -157,7 +156,7 @@ class FrmFormsController{
157
  }
158
 
159
  public static function edit_description(){
160
- FrmAppHelper::ajax_permission_check('frm_edit_forms');
161
 
162
  FrmForm::update($_POST['form_id'], array('description' => $_POST['update_value']));
163
  $description = FrmAppHelper::use_wpautop(stripslashes($_POST['update_value']));
@@ -173,13 +172,14 @@ class FrmFormsController{
173
  }
174
 
175
  //Set radio button and checkbox meta equal to "other" value
176
- $values = FrmEntriesHelper::set_other_vals( $values );
 
 
177
 
178
  $errors = FrmForm::validate($values);
179
-
180
- if ( ! current_user_can('frm_edit_forms') || ( $_POST && (!isset($values['frm_save_form']) || !wp_verify_nonce($values['frm_save_form'], 'frm_save_form_nonce')) ) ) {
181
- $frm_settings = FrmAppHelper::get_settings();
182
- $errors['form'] = $frm_settings->admin_permission;
183
  }
184
 
185
  $id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
@@ -219,17 +219,16 @@ class FrmFormsController{
219
  }
220
  }
221
 
222
-
223
- public static function after_duplicate($form_id, $values) {
224
- FrmForm::after_duplicate($form_id, $values);
225
- }
226
-
227
  public static function page_preview(){
228
  $params = FrmFormsHelper::get_params();
229
- if (!$params['form']) return;
 
 
230
 
231
  $form = FrmForm::getOne($params['form']);
232
- if(!$form) return;
 
 
233
  return self::show_form($form->id, '', true, true);
234
  }
235
 
@@ -257,7 +256,9 @@ class FrmFormsController{
257
  $controller = FrmAppHelper::get_param('controller');
258
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
259
  $form = FrmForm::getAll(array('form_key' => $key), '', 1);
260
- if (!$form) $form = FrmForm::getAll('', '', 1);
 
 
261
 
262
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
263
  die();
@@ -330,27 +331,48 @@ class FrmFormsController{
330
  return $message;
331
  }
332
 
333
- // Delete trashed forms
334
- public static function scheduled_delete() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  global $wpdb;
336
 
337
  $trash_forms = $wpdb->get_results($wpdb->prepare("SELECT id, options FROM {$wpdb->prefix}frm_forms WHERE status = %s", 'trash'));
338
 
339
- if ( !$trash_forms ) {
340
  return;
341
  }
342
 
343
- $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
 
 
344
 
 
345
  foreach ( $trash_forms as $form ) {
346
  $form->options = maybe_unserialize($form->options);
347
- if ( !isset($form->options['trash_time']) || $form->options['trash_time'] < $delete_timestamp ) {
348
  FrmForm::destroy($form->id);
 
349
  }
350
 
351
  unset($form);
352
  }
353
-
354
  }
355
 
356
  public static function insert_form_button($content){
@@ -382,11 +404,11 @@ class FrmFormsController{
382
  die();
383
  }
384
 
385
- $form_id = '';
386
- $opts = array();
387
-
388
  echo '<div id="sc-opts-'. $shortcode .'" class="frm_shortcode_option">';
389
  echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" style="display:none;" />';
 
 
 
390
  switch( $shortcode ) {
391
  case 'formidable':
392
  $form_id = 'id';
@@ -398,47 +420,10 @@ class FrmFormsController{
398
  );
399
  break;
400
  }
401
-
402
  $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
403
 
404
- if ( ! empty($form_id) ) {
405
- ?>
406
- <h4 for="frmsc_<?php echo $shortcode .'_'. $form_id ?>" class="frm_left_label"><?php _e('Select a form:', 'formidable') ?></h4>
407
- <?php FrmFormsHelper::forms_dropdown( 'frmsc_'. $shortcode .'_'. $form_id ); ?>
408
- <div class="frm_box_line"></div>
409
- <?php
410
- }
411
-
412
- if ( ! empty($opts) ) { ?>
413
- <h4><?php _e('Options', 'formidable') ?></h4>
414
- <ul>
415
- <?php
416
- foreach ( $opts as $opt => $val ) {
417
- if ( isset($val['type']) && 'text' == $val['type'] ) { ?>
418
- <li><label class="setting" for="frmsc_<?php echo $shortcode .'_'. $opt ?>">
419
- <span><?php echo $val['label'] ?></span>
420
- <input type="text" id="frmsc_<?php echo $shortcode .'_'. $opt ?>" value="<?php echo esc_attr($val['val']) ?>" />
421
- </label>
422
- <li>
423
- <?php } else if ( isset($val['type']) && 'select' == $val['type'] ) { ?>
424
- <li><label class="setting" for="frmsc_<?php echo $shortcode .'_'. $opt ?>">
425
- <span><?php echo $val['label'] ?></span>
426
- <select id="frmsc_<?php echo $shortcode .'_'. $opt ?>">
427
- <?php foreach ( $val['opts'] as $select_opt => $select_label ) { ?>
428
- <option value="<?php echo esc_attr($select_opt) ?>"><?php echo $select_label ?></option>
429
- <?php } ?>
430
- </select>
431
- </label>
432
- </li>
433
- <?php } else { ?>
434
- <li><label class="setting" for="frmsc_<?php echo $shortcode .'_'. $opt ?>"><input type="checkbox" id="frmsc_<?php echo $shortcode .'_'. $opt ?>" value="<?php echo esc_attr($val['val']) ?>" /> <?php echo $val['label'] ?></label><li>
435
- <?php
436
- }
437
- }
438
- ?>
439
- </ul>
440
- <?php
441
- }
442
  echo '</div>';
443
 
444
  die();
@@ -449,8 +434,9 @@ class FrmFormsController{
449
 
450
  global $wpdb, $frm_vars;
451
 
452
- if(!$params)
453
  $params = FrmFormsHelper::get_params();
 
454
 
455
  $wp_list_table = new FrmFormsListHelper( compact('params') );
456
 
@@ -536,7 +522,7 @@ class FrmFormsController{
536
  global $frm_vars;
537
 
538
  $form = FrmForm::getOne( $id );
539
- if ( !$form ) {
540
  wp_die( __('You are trying to edit a form that does not exist.', 'formidable') );
541
  }
542
 
@@ -645,7 +631,7 @@ class FrmFormsController{
645
  FrmEntriesHelper::maybe_get_entry($entry);
646
  }
647
 
648
- if ( !$entry ) {
649
  return $content;
650
  }
651
 
@@ -685,13 +671,13 @@ class FrmFormsController{
685
  return $errors;
686
  }
687
 
688
- if ( ! isset( $_REQUEST['_wpnonce'] ) || ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'bulk-toplevel_page_formidable' ) ) {
689
- $frm_settings = FrmAppHelper::get_settings();
690
- $errors[] = $frm_settings->admin_permission;
691
  return $errors;
692
  }
693
 
694
- if ( !is_array($ids) ) {
695
  $ids = explode(',', $ids);
696
  }
697
 
@@ -738,12 +724,14 @@ class FrmFormsController{
738
  $values['form_key'] = $filename;
739
  $values['is_template'] = $template;
740
  $values['status'] = 'published';
741
- if($default) $values['default_template'] = 1;
 
 
742
 
743
  include($templates[$i]);
744
 
745
  //get updated form
746
- if ( isset($form) && $form ) {
747
  $old_id = $form->id;
748
  $form = FrmForm::getOne($form->id);
749
  } else {
@@ -781,6 +769,10 @@ class FrmFormsController{
781
  }
782
  }else{
783
  $action = FrmAppHelper::get_param($action);
 
 
 
 
784
  }
785
 
786
  add_action('frm_load_form_hooks', 'FrmFormsController::trigger_load_form_hooks');
@@ -797,6 +789,7 @@ class FrmFormsController{
797
  case 'trash':
798
  case 'untrash':
799
  case 'destroy':
 
800
  case 'settings':
801
  case 'update_settings':
802
  return self::$action($vars);
@@ -934,12 +927,12 @@ class FrmFormsController{
934
  $frm_settings = FrmAppHelper::get_settings();
935
 
936
  // don't show a draft form on a page
937
- if ( $form->status == 'draft' && (!$post || $post->ID != $frm_settings->preview_page_id) ) {
938
  return __('Please select a valid form', 'formidable');
939
  }
940
 
941
  // don't show the form if user should be logged in
942
- if ( $form->logged_in && !is_user_logged_in() ) {
943
  return do_shortcode($frm_settings->login_msg);
944
  }
945
 
@@ -1022,9 +1015,16 @@ class FrmFormsController{
1022
  return;
1023
  }
1024
 
1025
- $saved_message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1026
- $saved_message = apply_filters('frm_content', $saved_message, $form, $created);
1027
- $message = ($created && is_numeric($created)) ? '<div class="frm_message" id="message">'. wpautop(do_shortcode($saved_message)) .'</div>' : '<div class="frm_error_style">'. $frm_settings->failed_msg .'</div>';
 
 
 
 
 
 
 
1028
 
1029
  if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1030
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
1
  <?php
2
 
3
  class FrmFormsController{
 
4
 
5
  public static function trigger_load_form_hooks() {
6
  FrmHooksController::trigger_load_hook( 'load_form_hooks' );
14
  }
15
 
16
  public static function menu(){
17
+ add_submenu_page('formidable', 'Formidable | '. __('Forms', 'formidable'), __('Forms', 'formidable'), 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
 
 
18
 
19
  add_filter('get_user_option_managetoplevel_page_formidablecolumnshidden', 'FrmFormsController::hidden_columns' );
20
 
24
 
25
  public static function head(){
26
  wp_enqueue_script('formidable-editinplace');
 
27
 
28
  if ( wp_is_mobile() ) {
29
  wp_enqueue_script( 'jquery-touch-punch' );
39
  FrmAppHelper::permission_check('frm_view_forms');
40
 
41
  $params = FrmFormsHelper::get_params();
42
+ $errors = self::process_bulk_form_actions(array());
43
+ $errors = apply_filters('frm_admin_list_form_action', $errors);
44
+
45
  return self::display_forms_list($params, '', false, $errors);
46
  }
47
 
82
  }
83
 
84
  //Set radio button and checkbox meta equal to "other" value
85
+ if ( FrmAppHelper::pro_is_installed() ) {
86
+ $values = FrmProEntry::mod_other_vals( $values, 'back' );
87
+ }
88
 
89
  $id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
90
 
91
+ if ( ! current_user_can( 'frm_edit_forms' ) || ( $_POST && ( ! isset( $values['frm_save_form'] ) || ! wp_verify_nonce( $values['frm_save_form'], 'frm_save_form_nonce' ) ) ) ) {
92
  $frm_settings = FrmAppHelper::get_settings();
93
  $errors = array( 'form' => $frm_settings->admin_permission );
94
  } else {
106
  }else{
107
  FrmForm::update( $id, $values, true );
108
  die(FrmAppHelper::js_redirect(admin_url('admin.php?page=formidable&frm_action=settings&id='. $id)));
 
 
109
  }
110
  }
111
 
119
  public static function settings($id=false, $message=''){
120
  FrmAppHelper::permission_check('frm_edit_forms');
121
 
122
+ if ( ! $id || ! is_numeric($id) ) {
123
+ $id = (int) FrmAppHelper::get_param('id');
124
+ }
125
  return self::get_settings_vars($id, '', $message);
126
  }
127
 
144
  }
145
 
146
  public static function edit_key(){
147
+ FrmAppHelper::permission_check('frm_edit_forms', 'hide');
148
 
149
  global $wpdb;
150
  $values = array('form_key' => trim($_POST['update_value']));
156
  }
157
 
158
  public static function edit_description(){
159
+ FrmAppHelper::permission_check('frm_edit_forms', 'hide');
160
 
161
  FrmForm::update($_POST['form_id'], array('description' => $_POST['update_value']));
162
  $description = FrmAppHelper::use_wpautop(stripslashes($_POST['update_value']));
172
  }
173
 
174
  //Set radio button and checkbox meta equal to "other" value
175
+ if ( FrmAppHelper::pro_is_installed() ) {
176
+ $values = FrmProEntry::mod_other_vals( $values, 'back' );
177
+ }
178
 
179
  $errors = FrmForm::validate($values);
180
+ $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce');
181
+ if ( $permission_error !== false ) {
182
+ $errors['form'] = $permission_error;
 
183
  }
184
 
185
  $id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
219
  }
220
  }
221
 
 
 
 
 
 
222
  public static function page_preview(){
223
  $params = FrmFormsHelper::get_params();
224
+ if ( ! $params['form'] ) {
225
+ return;
226
+ }
227
 
228
  $form = FrmForm::getOne($params['form']);
229
+ if ( ! $form ) {
230
+ return;
231
+ }
232
  return self::show_form($form->id, '', true, true);
233
  }
234
 
256
  $controller = FrmAppHelper::get_param('controller');
257
  $key = (isset($_GET['form']) ? $_GET['form'] : (isset($_POST['form']) ? $_POST['form'] : ''));
258
  $form = FrmForm::getAll(array('form_key' => $key), '', 1);
259
+ if ( empty($form) ) {
260
+ $form = FrmForm::getAll('', '', 1);
261
+ }
262
 
263
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/direct.php');
264
  die();
331
  return $message;
332
  }
333
 
334
+ private static function delete_all() {
335
+ //check nonce url
336
+ $permission_error = FrmAppHelper::permission_nonce_error('frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable');
337
+ if ( $permission_error !== false ) {
338
+ self::display_forms_list('', '', 1, array($permission_error));
339
+ return;
340
+ }
341
+
342
+ $count = self::scheduled_delete(time());
343
+ $message = sprintf(_n( '%1$s form permanently deleted.', '%1$s forms permanently deleted.', $count, 'formidable' ), $count);
344
+
345
+ self::display_forms_list('', $message, 1);
346
+ }
347
+
348
+ /*
349
+ * Delete trashed forms based on how long they have been trashed
350
+ * @return int The number of forms deleted
351
+ */
352
+ public static function scheduled_delete($delete_timestamp = '') {
353
  global $wpdb;
354
 
355
  $trash_forms = $wpdb->get_results($wpdb->prepare("SELECT id, options FROM {$wpdb->prefix}frm_forms WHERE status = %s", 'trash'));
356
 
357
+ if ( ! $trash_forms ) {
358
  return;
359
  }
360
 
361
+ if ( empty($delete_timestamp) ) {
362
+ $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
363
+ }
364
 
365
+ $count = 0;
366
  foreach ( $trash_forms as $form ) {
367
  $form->options = maybe_unserialize($form->options);
368
+ if ( ! isset( $form->options['trash_time'] ) || $form->options['trash_time'] < $delete_timestamp ) {
369
  FrmForm::destroy($form->id);
370
+ $count++;
371
  }
372
 
373
  unset($form);
374
  }
375
+ return $count;
376
  }
377
 
378
  public static function insert_form_button($content){
404
  die();
405
  }
406
 
 
 
 
407
  echo '<div id="sc-opts-'. $shortcode .'" class="frm_shortcode_option">';
408
  echo '<input type="radio" name="frmsc" value="'. esc_attr($shortcode) .'" id="sc-'. esc_attr($shortcode) .'" style="display:none;" />';
409
+
410
+ $form_id = '';
411
+ $opts = array();
412
  switch( $shortcode ) {
413
  case 'formidable':
414
  $form_id = 'id';
420
  );
421
  break;
422
  }
 
423
  $opts = apply_filters('frm_sc_popup_opts', $opts, $shortcode);
424
 
425
+ include(FrmAppHelper::plugin_path() .'/classes/views/frm-forms/shortcode_opts.php');
426
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
427
  echo '</div>';
428
 
429
  die();
434
 
435
  global $wpdb, $frm_vars;
436
 
437
+ if ( ! $params ) {
438
  $params = FrmFormsHelper::get_params();
439
+ }
440
 
441
  $wp_list_table = new FrmFormsListHelper( compact('params') );
442
 
522
  global $frm_vars;
523
 
524
  $form = FrmForm::getOne( $id );
525
+ if ( ! $form ) {
526
  wp_die( __('You are trying to edit a form that does not exist.', 'formidable') );
527
  }
528
 
631
  FrmEntriesHelper::maybe_get_entry($entry);
632
  }
633
 
634
+ if ( ! $entry ) {
635
  return $content;
636
  }
637
 
671
  return $errors;
672
  }
673
 
674
+ $permission_error = FrmAppHelper::permission_nonce_error('', '_wpnonce', 'bulk-toplevel_page_formidable');
675
+ if ( $permission_error !== false ) {
676
+ $errors[] = $permission_error;
677
  return $errors;
678
  }
679
 
680
+ if ( ! is_array($ids) ) {
681
  $ids = explode(',', $ids);
682
  }
683
 
724
  $values['form_key'] = $filename;
725
  $values['is_template'] = $template;
726
  $values['status'] = 'published';
727
+ if ( $default ) {
728
+ $values['default_template'] = 1;
729
+ }
730
 
731
  include($templates[$i]);
732
 
733
  //get updated form
734
+ if ( isset($form) && ! empty($form) ) {
735
  $old_id = $form->id;
736
  $form = FrmForm::getOne($form->id);
737
  } else {
769
  }
770
  }else{
771
  $action = FrmAppHelper::get_param($action);
772
+ if ( isset( $_REQUEST['delete_all'] ) ) {
773
+ // override the action for this page
774
+ $action = 'delete_all';
775
+ }
776
  }
777
 
778
  add_action('frm_load_form_hooks', 'FrmFormsController::trigger_load_form_hooks');
789
  case 'trash':
790
  case 'untrash':
791
  case 'destroy':
792
+ case 'delete_all':
793
  case 'settings':
794
  case 'update_settings':
795
  return self::$action($vars);
927
  $frm_settings = FrmAppHelper::get_settings();
928
 
929
  // don't show a draft form on a page
930
+ if ( $form->status == 'draft' && ( ! $post || $post->ID != $frm_settings->preview_page_id ) ) {
931
  return __('Please select a valid form', 'formidable');
932
  }
933
 
934
  // don't show the form if user should be logged in
935
+ if ( $form->logged_in && ! is_user_logged_in() ) {
936
  return do_shortcode($frm_settings->login_msg);
937
  }
938
 
1015
  return;
1016
  }
1017
 
1018
+ if ( $created && is_numeric($created) ){
1019
+ $message = isset($form->options['success_msg']) ? $form->options['success_msg'] : $frm_settings->success_msg;
1020
+ $class = 'frm_message';
1021
+ } else {
1022
+ $message = $frm_settings->failed_msg;
1023
+ $class = 'frm_error_style';
1024
+ }
1025
+ $message = apply_filters('frm_content', $message, $form, $created);
1026
+ $message = '<div class="'. $class .'">'. wpautop(do_shortcode($message)) .'</div>';
1027
+ $message = apply_filters('frm_main_feedback', $message, $form, $created);
1028
 
1029
  if ( ! isset($form->options['show_form']) || $form->options['show_form'] ) {
1030
  require(FrmAppHelper::plugin_path() .'/classes/views/frm-entries/new.php');
classes/controllers/FrmHooksController.php CHANGED
@@ -26,19 +26,21 @@ class FrmHooksController{
26
  // Make sure the hooks are only triggered once
27
  add_filter('frm'. str_replace('load', '', $trigger_hooks) .'_loaded', '__return_true');
28
  }
 
29
 
30
  // Instansiate Controllers
31
  foreach ( $controllers as $c ) {
 
32
  foreach ( $hooks as $hook ) {
33
- $c::$hook();
34
  unset($hook);
35
  }
36
- unset($c);
37
  }
38
 
39
  }
40
 
41
- public static function load_hooks(){
42
  if ( ! is_admin() ) {
43
  add_filter('the_content', 'FrmAppController::page_route', 10);
44
  }
@@ -46,12 +48,12 @@ class FrmHooksController{
46
  add_action('plugins_loaded', 'FrmAppController::load_lang' );
47
  add_action('init', 'FrmAppController::front_head' );
48
  add_filter('widget_text', 'FrmAppController::widget_text_filter', 8 );
49
- add_filter('get_frm_stylesheet', 'FrmAppController::custom_stylesheet' );
50
-
51
  add_action('wp_footer', 'FrmAppController::footer_js', 1, 0);
52
 
53
- // Update the session data
54
- add_action('init', 'FrmAppController::referer_session', 1);
 
 
55
 
56
  // Entries controller
57
  add_action('wp', 'FrmEntriesController::process_entry', 10, 0);
@@ -62,9 +64,7 @@ class FrmHooksController{
62
  add_filter('frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4);
63
 
64
  // Form Actions Controller
65
- add_action('init', 'FrmFormActionsController::register_post_types', 0);
66
- add_action('init', 'FrmFormActionsController::actions_init', 1);
67
- add_action('frm_form_actions_init', 'FrmFormActionsController::register_actions');
68
  add_action('frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 2);
69
 
70
  // Forms Controller
@@ -85,7 +85,7 @@ class FrmHooksController{
85
  add_filter('frm_show_entry_styles', 'FrmStylesController::show_entry_styles');
86
  }
87
 
88
- public static function load_admin_hooks() {
89
  add_action('admin_menu', 'FrmAppController::menu', 1);
90
  add_action('admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
91
  add_filter('update_plugin_complete_actions', 'FrmAppController::update_action_links', 10, 2 );
@@ -113,13 +113,13 @@ class FrmHooksController{
113
  // Forms Controller
114
  add_action('admin_menu', 'FrmFormsController::menu', 10);
115
  add_action('admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
116
- add_action('frm_after_duplicate_form', 'FrmFormsController::after_duplicate', 10, 2);
117
 
118
  add_filter('set-screen-option', 'FrmFormsController::save_per_page', 10, 3);
119
  add_action('admin_footer', 'FrmFormsController::insert_form_popup' );
120
  add_filter('media_buttons_context', 'FrmFormsController::insert_form_button' );
121
 
122
- add_filter('frm_admin_list_form_action', 'FrmFormsController::process_bulk_form_actions' );
 
123
 
124
  // Settings Controller
125
  add_action('admin_menu', 'FrmSettingsController::menu', 45);
@@ -137,7 +137,7 @@ class FrmHooksController{
137
  add_action('admin_menu', 'FrmXMLController::menu', 41);
138
  }
139
 
140
- public static function load_ajax_hooks() {
141
  add_action('wp_ajax_frm_install', 'FrmAppController::install' );
142
  add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
143
  add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
@@ -183,7 +183,7 @@ class FrmHooksController{
183
  add_action('wp_ajax_frm_export_xml', 'FrmXMLController::export_xml');
184
  }
185
 
186
- public static function load_form_hooks() {
187
  // Fields Controller
188
  add_filter('frm_field_type', 'FrmFieldsController::change_type');
189
  add_action('frm_field_input_html', 'FrmFieldsController::input_html');
@@ -194,11 +194,11 @@ class FrmHooksController{
194
  add_filter('frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
195
  }
196
 
197
- public static function load_view_hooks() {
198
  // Hooks go here when a view is loaded
199
  }
200
 
201
- public static function load_multisite_hooks() {
202
  // drop tables when mu site is deleted
203
  add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
204
  }
26
  // Make sure the hooks are only triggered once
27
  add_filter('frm'. str_replace('load', '', $trigger_hooks) .'_loaded', '__return_true');
28
  }
29
+ unset($trigger_hooks);
30
 
31
  // Instansiate Controllers
32
  foreach ( $controllers as $c ) {
33
+ $class = new $c;
34
  foreach ( $hooks as $hook ) {
35
+ $class->$hook();
36
  unset($hook);
37
  }
38
+ unset($c, $class);
39
  }
40
 
41
  }
42
 
43
+ public function load_hooks(){
44
  if ( ! is_admin() ) {
45
  add_filter('the_content', 'FrmAppController::page_route', 10);
46
  }
48
  add_action('plugins_loaded', 'FrmAppController::load_lang' );
49
  add_action('init', 'FrmAppController::front_head' );
50
  add_filter('widget_text', 'FrmAppController::widget_text_filter', 8 );
 
 
51
  add_action('wp_footer', 'FrmAppController::footer_js', 1, 0);
52
 
53
+ if ( ! FrmAppHelper::is_admin() ) {
54
+ // Update the session data
55
+ add_action('init', 'FrmAppController::referer_session', 1);
56
+ }
57
 
58
  // Entries controller
59
  add_action('wp', 'FrmEntriesController::process_entry', 10, 0);
64
  add_filter('frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4);
65
 
66
  // Form Actions Controller
67
+ add_action('init', 'FrmFormActionsController::register_post_types', 1);
 
 
68
  add_action('frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 2);
69
 
70
  // Forms Controller
85
  add_filter('frm_show_entry_styles', 'FrmStylesController::show_entry_styles');
86
  }
87
 
88
+ public function load_admin_hooks() {
89
  add_action('admin_menu', 'FrmAppController::menu', 1);
90
  add_action('admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' );
91
  add_filter('update_plugin_complete_actions', 'FrmAppController::update_action_links', 10, 2 );
113
  // Forms Controller
114
  add_action('admin_menu', 'FrmFormsController::menu', 10);
115
  add_action('admin_head-toplevel_page_formidable', 'FrmFormsController::head' );
 
116
 
117
  add_filter('set-screen-option', 'FrmFormsController::save_per_page', 10, 3);
118
  add_action('admin_footer', 'FrmFormsController::insert_form_popup' );
119
  add_filter('media_buttons_context', 'FrmFormsController::insert_form_button' );
120
 
121
+ // Forms Model
122
+ add_action('frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2);
123
 
124
  // Settings Controller
125
  add_action('admin_menu', 'FrmSettingsController::menu', 45);
137
  add_action('admin_menu', 'FrmXMLController::menu', 41);
138
  }
139
 
140
+ public function load_ajax_hooks() {
141
  add_action('wp_ajax_frm_install', 'FrmAppController::install' );
142
  add_action('wp_ajax_frm_uninstall', 'FrmAppController::uninstall' );
143
  add_action('wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' );
183
  add_action('wp_ajax_frm_export_xml', 'FrmXMLController::export_xml');
184
  }
185
 
186
+ public function load_form_hooks() {
187
  // Fields Controller
188
  add_filter('frm_field_type', 'FrmFieldsController::change_type');
189
  add_action('frm_field_input_html', 'FrmFieldsController::input_html');
194
  add_filter('frm_use_important_width', 'FrmStylesController::important_style', 10, 2 );
195
  }
196
 
197
+ public function load_view_hooks() {
198
  // Hooks go here when a view is loaded
199
  }
200
 
201
+ public function load_multisite_hooks() {
202
  // drop tables when mu site is deleted
203
  add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' );
204
  }
classes/controllers/FrmSettingsController.php CHANGED
@@ -31,17 +31,18 @@ class FrmSettingsController{
31
 
32
  $frm_settings = FrmAppHelper::get_settings();
33
 
34
- if(!isset($_POST['process_form']) or !wp_verify_nonce($_POST['process_form'], 'process_form_nonce'))
35
  wp_die($frm_settings->admin_permission);
 
36
 
37
  $errors = array();
38
  $message = '';
39
 
40
- if(!isset($frm_vars['settings_routed']) or !$frm_vars['settings_routed']){
41
  //$errors = $frm_settings->validate($_POST,array());
42
  $frm_settings->update(stripslashes_deep($_POST));
43
 
44
- if( empty($errors) ){
45
  $frm_settings->store();
46
  $message = __('Settings Saved', 'formidable');
47
  }
@@ -60,9 +61,10 @@ class FrmSettingsController{
60
  public static function route($stop_load=false){
61
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
62
  $action = FrmAppHelper::get_param($action);
63
- if($action == 'process-form')
64
  return self::process_form($stop_load);
65
- else if($stop_load != 'stop_load')
66
  return self::display_form();
 
67
  }
68
  }
31
 
32
  $frm_settings = FrmAppHelper::get_settings();
33
 
34
+ if ( ! isset($_POST['process_form']) || ! wp_verify_nonce($_POST['process_form'], 'process_form_nonce') ) {
35
  wp_die($frm_settings->admin_permission);
36
+ }
37
 
38
  $errors = array();
39
  $message = '';
40
 
41
+ if ( ! isset($frm_vars['settings_routed']) || ! $frm_vars['settings_routed'] ) {
42
  //$errors = $frm_settings->validate($_POST,array());
43
  $frm_settings->update(stripslashes_deep($_POST));
44
 
45
+ if ( empty($errors) ) {
46
  $frm_settings->store();
47
  $message = __('Settings Saved', 'formidable');
48
  }
61
  public static function route($stop_load=false){
62
  $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
63
  $action = FrmAppHelper::get_param($action);
64
+ if ( $action == 'process-form' ) {
65
  return self::process_form($stop_load);
66
+ } else if ( $stop_load != 'stop_load' ) {
67
  return self::display_form();
68
+ }
69
  }
70
  }
classes/controllers/FrmStatisticsController.php CHANGED
@@ -3,7 +3,7 @@
3
  class FrmStatisticsController{
4
 
5
  public static function menu(){
6
- add_submenu_page('formidable', 'Formidable | '. __('Views', 'formidable'), '<span style="opacity:.5;filter:alpha(opacity=50);">'. __('Views', 'formidable') .'</span>', 'administrator', 'formidable-entry-templates', 'FrmStatisticsController::list_displays');
7
  }
8
 
9
  public static function list_reports(){
3
  class FrmStatisticsController{
4
 
5
  public static function menu(){
6
+ add_submenu_page( 'formidable', 'Formidable | '. __('Views', 'formidable'), '<span class="frm_inactive_menu">'. __( 'Views', 'formidable' ) .'</span>', 'administrator', 'formidable-entry-templates', 'FrmStatisticsController::list_displays' );
7
  }
8
 
9
  public static function list_reports(){
classes/controllers/FrmStylesController.php CHANGED
@@ -42,20 +42,17 @@ class FrmStylesController{
42
 
43
  self::load_pro_hooks();
44
  wp_enqueue_script('jquery-ui-datepicker');
45
- add_action('admin_head', 'FrmStylesController::head');
46
- }
47
 
48
- public static function head() {
49
- wp_enqueue_script('jquery-frm-themepicker');
 
 
 
50
 
51
  $style = apply_filters('frm_style_head', false);
52
- ?>
53
- <link type="text/css" rel="stylesheet" href="<?php echo FrmAppHelper::jquery_ui_base_url() ?>/themes/base/ui.all.css" />
54
-