Version Description
- New: Add one-click form creation from a form template and adjust the way a new form is created
- New: Add a new process for creating a custom form template
- Tweak: Create smaller XML fiels when exporting forms
- Tweak: Use the name of the form for XML exports when a single form is exported
- Tweak: Don't limit the width of the color picker in the form styler to avoid conflicts with some color picker plugins
- Fix: Prevent the 'Advanced' section from hiding on non-Formidable blocks
- Fix: Some users were seeing PHP error messages in PHP 5.2
- Fix: XML form exports set to use the default style were not correctly setting the style on import
Download this release
Release Info
Developer | sswells |
Plugin | Formidable Forms – Form Builder for WordPress |
Version | 3.06 |
Comparing to | |
See all releases |
Code changes from version 3.05 to 3.06
- classes/controllers/FrmAddonsController.php +61 -132
- classes/controllers/FrmAppController.php +1 -1
- classes/controllers/FrmFormsController.php +117 -10
- classes/controllers/FrmHooksController.php +3 -1
- classes/controllers/FrmSimpleBlocksController.php +4 -1
- classes/controllers/FrmStylesController.php +1 -1
- classes/controllers/FrmXMLController.php +120 -19
- classes/helpers/FrmAppHelper.php +36 -6
- classes/helpers/FrmEntriesHelper.php +1 -1
- classes/helpers/FrmEntriesListHelper.php +3 -3
- classes/helpers/FrmFieldsHelper.php +1 -1
- classes/helpers/FrmFormsHelper.php +2 -4
- classes/helpers/FrmFormsListHelper.php +12 -67
- classes/helpers/FrmListHelper.php +20 -27
- classes/helpers/FrmXMLHelper.php +136 -26
- classes/models/FrmAddon.php +14 -8
- classes/models/FrmEntry.php +7 -7
- classes/models/FrmField.php +7 -7
- classes/models/FrmForm.php +0 -1
- classes/models/FrmFormApi.php +202 -0
- classes/models/FrmFormTemplateApi.php +25 -0
- classes/models/FrmMigrate.php +36 -18
- classes/models/FrmPersonalData.php +1 -1
- classes/views/addons/list.php +4 -4
- classes/views/frm-entries/_sidebar-shared-pub.php +2 -2
- classes/views/frm-fields/back-end/number-range.php +1 -1
- classes/views/frm-forms/_publish_box.php +1 -19
- classes/views/frm-forms/add-new.php +59 -0
- classes/views/frm-forms/form.php +1 -12
- classes/views/frm-forms/list-templates.php +149 -0
- classes/views/frm-forms/list.php +1 -1
- classes/views/frm-forms/template-name-overlay.php +46 -0
- classes/views/frm-settings/form.php +3 -3
- classes/views/shared/admin-header.php +4 -1
- classes/views/shared/form-nav.php +1 -1
- classes/views/shared/upgrade_overlay.php +2 -2
- classes/views/styles/manage.php +1 -1
- classes/views/xml/default-templates.xml +2 -3
- classes/views/xml/forms_xml.php +1 -1
- classes/views/xml/import_form.php +18 -22
- css/custom_theme.css.php +1 -0
- css/formidableforms.css +1 -1
- css/frm_admin.css +225 -66
- css/frm_blocks.css +0 -4
- deprecated/FrmDeprecated.php +56 -3
- formidable.php +1 -1
- images/new-blank.svg +57 -0
- images/new-form.svg +53 -0
- images/new-import.svg +66 -0
- js/formidable_admin.js +232 -56
- js/formidable_blocks.js +1 -1
- js/jquery/jquery.editinplace.js +653 -0
- languages/formidable-js-strings.php +3 -3
- languages/formidable-js.pot +60 -0
- languages/formidable.pot +613 -380
- readme.txt +12 -9
classes/controllers/FrmAddonsController.php
CHANGED
@@ -18,8 +18,10 @@ class FrmAddonsController {
|
|
18 |
$installed_addons = apply_filters( 'frm_installed_addons', array() );
|
19 |
|
20 |
$addons = self::get_api_addons();
|
21 |
-
$errors =
|
22 |
if ( isset( $addons['error'] ) ) {
|
|
|
|
|
23 |
unset( $addons['error'] );
|
24 |
}
|
25 |
self::prepare_addons( $addons );
|
@@ -42,13 +44,8 @@ class FrmAddonsController {
|
|
42 |
}
|
43 |
|
44 |
private static function get_api_addons() {
|
45 |
-
$
|
46 |
-
$
|
47 |
-
if ( ! empty( $edd_update ) ) {
|
48 |
-
$license = $edd_update->license;
|
49 |
-
}
|
50 |
-
|
51 |
-
$addons = self::get_addon_info( $license );
|
52 |
|
53 |
if ( empty( $addons ) ) {
|
54 |
$addons = self::fallback_plugin_list();
|
@@ -63,17 +60,6 @@ class FrmAddonsController {
|
|
63 |
return $addons;
|
64 |
}
|
65 |
|
66 |
-
/**
|
67 |
-
* @since 3.04.03
|
68 |
-
*/
|
69 |
-
public static function get_pro_updater() {
|
70 |
-
if ( FrmAppHelper::pro_is_installed() && is_callable( 'FrmProAppHelper::get_updater' ) ) {
|
71 |
-
return FrmProAppHelper::get_updater();
|
72 |
-
}
|
73 |
-
|
74 |
-
return false;
|
75 |
-
}
|
76 |
-
|
77 |
/**
|
78 |
* If the API is unable to connect, show something on the addons page
|
79 |
*
|
@@ -182,121 +168,13 @@ class FrmAddonsController {
|
|
182 |
$license = strtoupper( $license );
|
183 |
}
|
184 |
|
185 |
-
$
|
|
|
186 |
$pro = isset( $downloads['93790'] ) ? $downloads['93790'] : array();
|
187 |
|
188 |
return isset( $pro['url'] ) ? $pro['url'] : '';
|
189 |
}
|
190 |
|
191 |
-
/**
|
192 |
-
* @since 3.04.03
|
193 |
-
* @return array
|
194 |
-
*/
|
195 |
-
public static function get_addon_info( $license = '' ) {
|
196 |
-
$addons = array();
|
197 |
-
$url = 'https://formidableforms.com/wp-json/s11edd/v1/updates/';
|
198 |
-
if ( ! empty( $license ) ) {
|
199 |
-
$url .= '?l=' . urlencode( base64_encode( $license ) );
|
200 |
-
}
|
201 |
-
|
202 |
-
$addons = self::get_cached_addons( $license );
|
203 |
-
if ( ! empty( $addons ) ) {
|
204 |
-
return $addons;
|
205 |
-
}
|
206 |
-
|
207 |
-
$response = wp_remote_get( $url );
|
208 |
-
if ( is_array( $response ) && ! is_wp_error( $response ) ) {
|
209 |
-
$addons = $response['body'];
|
210 |
-
if ( ! empty( $addons ) ) {
|
211 |
-
$addons = json_decode( $addons, true );
|
212 |
-
|
213 |
-
$skip_categories = array( 'WordPress Form Templates', 'WordPress Form Style Templates' );
|
214 |
-
foreach ( $addons as $k => $addon ) {
|
215 |
-
if ( ! isset( $addon['categories'] ) ) {
|
216 |
-
continue;
|
217 |
-
}
|
218 |
-
$cats = array_intersect( $skip_categories, $addon['categories'] );
|
219 |
-
if ( ! empty( $cats ) ) {
|
220 |
-
unset( $addons[ $k ] );
|
221 |
-
}
|
222 |
-
}
|
223 |
-
|
224 |
-
self::set_cached_addons( $addons, $license );
|
225 |
-
}
|
226 |
-
}
|
227 |
-
|
228 |
-
return $addons;
|
229 |
-
}
|
230 |
-
|
231 |
-
/**
|
232 |
-
* @since 3.04.03
|
233 |
-
* @return array
|
234 |
-
*/
|
235 |
-
private static function get_cached_addons( $license = '' ) {
|
236 |
-
$cache_key = self::get_cache_key( $license );
|
237 |
-
$cache = get_option( $cache_key );
|
238 |
-
|
239 |
-
if ( empty( $cache ) || empty( $cache['timeout'] ) || current_time( 'timestamp' ) > $cache['timeout'] ) {
|
240 |
-
return false; // Cache is expired
|
241 |
-
}
|
242 |
-
|
243 |
-
return json_decode( $cache['value'], true );
|
244 |
-
}
|
245 |
-
|
246 |
-
/**
|
247 |
-
* @since 3.04.03
|
248 |
-
*/
|
249 |
-
private static function set_cached_addons( $addons, $license = '' ) {
|
250 |
-
$cache_key = self::get_cache_key( $license );
|
251 |
-
$data = array(
|
252 |
-
'timeout' => strtotime( '+6 hours', current_time( 'timestamp' ) ),
|
253 |
-
'value' => json_encode( $addons ),
|
254 |
-
);
|
255 |
-
|
256 |
-
update_option( $cache_key, $data, 'no' );
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
* @since 3.04.03
|
261 |
-
*/
|
262 |
-
public static function reset_cached_addons( $license = '' ) {
|
263 |
-
delete_option( self::get_cache_key( $license ) );
|
264 |
-
}
|
265 |
-
|
266 |
-
/**
|
267 |
-
* @since 3.04.03
|
268 |
-
* @return string
|
269 |
-
*/
|
270 |
-
public static function get_cache_key( $license ) {
|
271 |
-
return 'frm_addons_l' . ( empty( $license ) ? '' : md5( $license ) );
|
272 |
-
}
|
273 |
-
|
274 |
-
/**
|
275 |
-
* @since 3.04.03
|
276 |
-
* @return array
|
277 |
-
*/
|
278 |
-
public static function error_for_license( $license ) {
|
279 |
-
$errors = array();
|
280 |
-
if ( ! empty( $license ) ) {
|
281 |
-
$addons = self::get_addon_info( $license );
|
282 |
-
$errors = self::get_error_from_response( $addons );
|
283 |
-
}
|
284 |
-
return $errors;
|
285 |
-
}
|
286 |
-
|
287 |
-
/**
|
288 |
-
* @since 3.04.03
|
289 |
-
* @return array
|
290 |
-
*/
|
291 |
-
private static function get_error_from_response( $addons ) {
|
292 |
-
$errors = array();
|
293 |
-
if ( isset( $addons['error'] ) ) {
|
294 |
-
$errors[] = $addons['error']['message'];
|
295 |
-
do_action( 'frm_license_error', $addons['error'] );
|
296 |
-
}
|
297 |
-
return $errors;
|
298 |
-
}
|
299 |
-
|
300 |
/**
|
301 |
* @since 3.04.03
|
302 |
*/
|
@@ -389,12 +267,13 @@ class FrmAddonsController {
|
|
389 |
|
390 |
$checked_licenses[] = $new_license;
|
391 |
|
|
|
392 |
if ( empty( $version_info ) ) {
|
393 |
-
$version_info =
|
394 |
continue;
|
395 |
}
|
396 |
|
397 |
-
$plugin =
|
398 |
if ( empty( $plugin ) ) {
|
399 |
continue;
|
400 |
}
|
@@ -402,7 +281,7 @@ class FrmAddonsController {
|
|
402 |
$download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
|
403 |
if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
|
404 |
// if this addon is using its own license, get the update url
|
405 |
-
$addon_info =
|
406 |
|
407 |
$version_info[ $download_id ] = $addon_info[ $download_id ];
|
408 |
if ( isset( $addon_info['error'] ) ) {
|
@@ -665,6 +544,56 @@ class FrmAddonsController {
|
|
665 |
}
|
666 |
}
|
667 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
/**
|
669 |
* @since 2.03.08
|
670 |
* @deprecated 3.04.03
|
18 |
$installed_addons = apply_filters( 'frm_installed_addons', array() );
|
19 |
|
20 |
$addons = self::get_api_addons();
|
21 |
+
$errors = array();
|
22 |
if ( isset( $addons['error'] ) ) {
|
23 |
+
$api = new FrmFormApi();
|
24 |
+
$errors = $api->get_error_from_response( $addons );
|
25 |
unset( $addons['error'] );
|
26 |
}
|
27 |
self::prepare_addons( $addons );
|
44 |
}
|
45 |
|
46 |
private static function get_api_addons() {
|
47 |
+
$api = new FrmFormApi();
|
48 |
+
$addons = $api->get_api_info();
|
|
|
|
|
|
|
|
|
|
|
49 |
|
50 |
if ( empty( $addons ) ) {
|
51 |
$addons = self::fallback_plugin_list();
|
60 |
return $addons;
|
61 |
}
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
/**
|
64 |
* If the API is unable to connect, show something on the addons page
|
65 |
*
|
168 |
$license = strtoupper( $license );
|
169 |
}
|
170 |
|
171 |
+
$api = new FrmFormApi( $license );
|
172 |
+
$downloads = $api->get_api_info();
|
173 |
$pro = isset( $downloads['93790'] ) ? $downloads['93790'] : array();
|
174 |
|
175 |
return isset( $pro['url'] ) ? $pro['url'] : '';
|
176 |
}
|
177 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
/**
|
179 |
* @since 3.04.03
|
180 |
*/
|
267 |
|
268 |
$checked_licenses[] = $new_license;
|
269 |
|
270 |
+
$api = new FrmFormApi( $new_license );
|
271 |
if ( empty( $version_info ) ) {
|
272 |
+
$version_info = $api->get_api_info();
|
273 |
continue;
|
274 |
}
|
275 |
|
276 |
+
$plugin = $api->get_addon_for_license( $addon, $version_info );
|
277 |
if ( empty( $plugin ) ) {
|
278 |
continue;
|
279 |
}
|
281 |
$download_id = isset( $plugin['id'] ) ? $plugin['id'] : 0;
|
282 |
if ( ! empty( $download_id ) && ! isset( $version_info[ $download_id ]['package'] ) ) {
|
283 |
// if this addon is using its own license, get the update url
|
284 |
+
$addon_info = $api->get_api_info();
|
285 |
|
286 |
$version_info[ $download_id ] = $addon_info[ $download_id ];
|
287 |
if ( isset( $addon_info['error'] ) ) {
|
544 |
}
|
545 |
}
|
546 |
|
547 |
+
/**
|
548 |
+
* @since 3.04.03
|
549 |
+
* @deprecated 3.06
|
550 |
+
* @codeCoverageIgnore
|
551 |
+
* @return array
|
552 |
+
*/
|
553 |
+
public static function error_for_license( $license ) {
|
554 |
+
return FrmDeprecated::error_for_license( $license );
|
555 |
+
}
|
556 |
+
|
557 |
+
/**
|
558 |
+
* @since 3.04.03
|
559 |
+
* @deprecated 3.06
|
560 |
+
* @codeCoverageIgnore
|
561 |
+
*/
|
562 |
+
public static function get_pro_updater() {
|
563 |
+
return FrmDeprecated::get_pro_updater();
|
564 |
+
}
|
565 |
+
|
566 |
+
/**
|
567 |
+
* @since 3.04.03
|
568 |
+
* @deprecated 3.06
|
569 |
+
* @codeCoverageIgnore
|
570 |
+
*
|
571 |
+
* @return array
|
572 |
+
*/
|
573 |
+
public static function get_addon_info( $license = '' ) {
|
574 |
+
return FrmDeprecated::get_addon_info( $license );
|
575 |
+
}
|
576 |
+
|
577 |
+
/**
|
578 |
+
* @since 3.04.03
|
579 |
+
* @deprecated 3.06
|
580 |
+
* @codeCoverageIgnore
|
581 |
+
*
|
582 |
+
* @return string
|
583 |
+
*/
|
584 |
+
public static function get_cache_key( $license ) {
|
585 |
+
return FrmDeprecated::get_cache_key( $license );
|
586 |
+
}
|
587 |
+
|
588 |
+
/**
|
589 |
+
* @since 3.04.03
|
590 |
+
* @deprecated 3.06
|
591 |
+
* @codeCoverageIgnore
|
592 |
+
*/
|
593 |
+
public static function reset_cached_addons( $license = '' ) {
|
594 |
+
FrmDeprecated::reset_cached_addons( $license );
|
595 |
+
}
|
596 |
+
|
597 |
/**
|
598 |
* @since 2.03.08
|
599 |
* @deprecated 3.04.03
|
classes/controllers/FrmAppController.php
CHANGED
@@ -44,7 +44,7 @@ class FrmAppController {
|
|
44 |
* @since 3.0
|
45 |
*/
|
46 |
private static function is_white_page() {
|
47 |
-
$is_white_page = ( FrmAppHelper::is_admin_page( 'formidable' ) || FrmAppHelper::is_admin_page( 'formidable-entries' ) || FrmAppHelper::is_admin_page( 'formidable-pro-upgrade' ) || FrmAppHelper::is_admin_page( 'formidable-addons' ) );
|
48 |
if ( ! $is_white_page ) {
|
49 |
$screen = get_current_screen();
|
50 |
$is_white_page = ( $screen && $screen->id === 'edit-frm_display' );
|
44 |
* @since 3.0
|
45 |
*/
|
46 |
private static function is_white_page() {
|
47 |
+
$is_white_page = ( FrmAppHelper::is_admin_page( 'formidable' ) || FrmAppHelper::is_admin_page( 'formidable-entries' ) || FrmAppHelper::is_admin_page( 'formidable-pro-upgrade' ) || FrmAppHelper::is_admin_page( 'formidable-addons' ) || FrmAppHelper::is_admin_page( 'formidable-import' ) );
|
48 |
if ( ! $is_white_page ) {
|
49 |
$screen = get_current_screen();
|
50 |
$is_white_page = ( $screen && $screen->id === 'edit-frm_display' );
|
classes/controllers/FrmFormsController.php
CHANGED
@@ -51,11 +51,25 @@ class FrmFormsController {
|
|
51 |
public static function list_form() {
|
52 |
FrmAppHelper::permission_check( 'frm_view_forms' );
|
53 |
|
|
|
54 |
$params = FrmForm::list_page_params();
|
55 |
$errors = self::process_bulk_form_actions( array() );
|
|
|
|
|
|
|
|
|
56 |
$errors = apply_filters( 'frm_admin_list_form_action', $errors );
|
57 |
|
58 |
-
return self::display_forms_list( $params,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
|
61 |
public static function new_form( $values = array() ) {
|
@@ -209,8 +223,11 @@ class FrmFormsController {
|
|
209 |
* Also delete the current form
|
210 |
*
|
211 |
* @since 2.0
|
|
|
212 |
*/
|
213 |
public static function _create_from_template() {
|
|
|
|
|
214 |
FrmAppHelper::permission_check( 'frm_edit_forms' );
|
215 |
check_ajax_referer( 'frm_ajax', 'nonce' );
|
216 |
|
@@ -388,6 +405,17 @@ class FrmFormsController {
|
|
388 |
return $message;
|
389 |
}
|
390 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
391 |
public static function trash() {
|
392 |
self::change_form_status( 'trash' );
|
393 |
}
|
@@ -514,6 +542,46 @@ class FrmFormsController {
|
|
514 |
self::display_forms_list( array(), $message );
|
515 |
}
|
516 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
517 |
/**
|
518 |
* Inserts Formidable button
|
519 |
* Hook exists since 2.5.0
|
@@ -692,6 +760,49 @@ class FrmFormsController {
|
|
692 |
return $save;
|
693 |
}
|
694 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
695 |
private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
|
696 |
global $frm_vars;
|
697 |
|
@@ -728,9 +839,7 @@ class FrmFormsController {
|
|
728 |
|
729 |
$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
|
730 |
|
731 |
-
|
732 |
-
wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) );
|
733 |
-
} elseif ( defined( 'DOING_AJAX' ) ) {
|
734 |
wp_die();
|
735 |
} else if ( $create_link ) {
|
736 |
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
|
@@ -749,10 +858,6 @@ class FrmFormsController {
|
|
749 |
$fields = FrmField::get_all_for_form( $id );
|
750 |
$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
|
751 |
|
752 |
-
if ( isset( $values['default_template'] ) && $values['default_template'] ) {
|
753 |
-
wp_die( esc_html__( 'That template cannot be edited', 'formidable' ) );
|
754 |
-
}
|
755 |
-
|
756 |
self::clean_submit_html( $values );
|
757 |
|
758 |
$action_controls = FrmFormActionsController::get_form_actions();
|
@@ -1010,7 +1115,7 @@ class FrmFormsController {
|
|
1010 |
}
|
1011 |
|
1012 |
if ( isset( $message ) && ! empty( $message ) ) {
|
1013 |
-
|
1014 |
}
|
1015 |
|
1016 |
return $errors;
|
@@ -1053,6 +1158,8 @@ class FrmFormsController {
|
|
1053 |
switch ( $action ) {
|
1054 |
case 'new':
|
1055 |
return self::new_form( $vars );
|
|
|
|
|
1056 |
case 'create':
|
1057 |
case 'edit':
|
1058 |
case 'update':
|
@@ -1154,7 +1261,7 @@ class FrmFormsController {
|
|
1154 |
array(
|
1155 |
'parent' => 'frm-forms',
|
1156 |
'id' => 'edit_form_' . $form_id,
|
1157 |
-
'title' => empty( $name ) ? __( '(no title)' ) : $name,
|
1158 |
'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
|
1159 |
)
|
1160 |
);
|
51 |
public static function list_form() {
|
52 |
FrmAppHelper::permission_check( 'frm_view_forms' );
|
53 |
|
54 |
+
$message = '';
|
55 |
$params = FrmForm::list_page_params();
|
56 |
$errors = self::process_bulk_form_actions( array() );
|
57 |
+
if ( isset( $errors['message'] ) ) {
|
58 |
+
$message = $errors['message'];
|
59 |
+
unset( $errors['message'] );
|
60 |
+
}
|
61 |
$errors = apply_filters( 'frm_admin_list_form_action', $errors );
|
62 |
|
63 |
+
return self::display_forms_list( $params, $message, $errors );
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Choose which type of form to create
|
68 |
+
*
|
69 |
+
* @since 3.06
|
70 |
+
*/
|
71 |
+
public static function add_new() {
|
72 |
+
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add-new.php' );
|
73 |
}
|
74 |
|
75 |
public static function new_form( $values = array() ) {
|
223 |
* Also delete the current form
|
224 |
*
|
225 |
* @since 2.0
|
226 |
+
* @deprecated 3.06
|
227 |
*/
|
228 |
public static function _create_from_template() {
|
229 |
+
_deprecated_function( __FUNCTION__, '3.06' );
|
230 |
+
|
231 |
FrmAppHelper::permission_check( 'frm_edit_forms' );
|
232 |
check_ajax_referer( 'frm_ajax', 'nonce' );
|
233 |
|
405 |
return $message;
|
406 |
}
|
407 |
|
408 |
+
/**
|
409 |
+
* @since 3.06
|
410 |
+
*/
|
411 |
+
public static function ajax_trash() {
|
412 |
+
FrmAppHelper::permission_check( 'frm_delete_forms' );
|
413 |
+
check_ajax_referer( 'frm_ajax', 'nonce' );
|
414 |
+
$form_id = FrmAppHelper::get_param( 'id', '', 'post', 'absint' );
|
415 |
+
FrmForm::set_status( $form_id, 'trash' );
|
416 |
+
wp_die();
|
417 |
+
}
|
418 |
+
|
419 |
public static function trash() {
|
420 |
self::change_form_status( 'trash' );
|
421 |
}
|
542 |
self::display_forms_list( array(), $message );
|
543 |
}
|
544 |
|
545 |
+
/**
|
546 |
+
* Create a custom template from a form
|
547 |
+
*
|
548 |
+
* @since 3.06
|
549 |
+
*/
|
550 |
+
public static function build_template() {
|
551 |
+
global $wpdb;
|
552 |
+
|
553 |
+
FrmAppHelper::permission_check( 'frm_edit_forms' );
|
554 |
+
check_ajax_referer( 'frm_ajax', 'nonce' );
|
555 |
+
|
556 |
+
$form_id = FrmAppHelper::get_param( 'xml', '', 'post', 'absint' );
|
557 |
+
$new_form_id = FrmForm::duplicate( $form_id, 1, true );
|
558 |
+
if ( empty( $new_form_id ) ) {
|
559 |
+
$response = array(
|
560 |
+
'message' => __( 'There was an error creating a template.', 'formidable' ),
|
561 |
+
);
|
562 |
+
} else {
|
563 |
+
// Update the new form name and description.
|
564 |
+
$name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
|
565 |
+
$desc = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
|
566 |
+
|
567 |
+
$new_values = array(
|
568 |
+
'name' => $name,
|
569 |
+
'description' => $desc,
|
570 |
+
);
|
571 |
+
$query_results = $wpdb->update( $wpdb->prefix . 'frm_forms', $new_values, array( 'id' => $new_form_id ) );
|
572 |
+
if ( $query_results ) {
|
573 |
+
FrmForm::clear_form_cache();
|
574 |
+
}
|
575 |
+
|
576 |
+
$response = array(
|
577 |
+
'redirect' => admin_url( 'admin.php?page=formidable&frm_action=list_templates' ),
|
578 |
+
);
|
579 |
+
}
|
580 |
+
|
581 |
+
echo wp_json_encode( $response );
|
582 |
+
wp_die();
|
583 |
+
}
|
584 |
+
|
585 |
/**
|
586 |
* Inserts Formidable button
|
587 |
* Hook exists since 2.5.0
|
760 |
return $save;
|
761 |
}
|
762 |
|
763 |
+
/**
|
764 |
+
* Show the template listing page
|
765 |
+
*
|
766 |
+
* @since 3.06
|
767 |
+
*/
|
768 |
+
private static function list_templates() {
|
769 |
+
wp_enqueue_script( 'jquery-ui-dialog' );
|
770 |
+
wp_enqueue_style( 'jquery-ui-dialog' );
|
771 |
+
|
772 |
+
$where = apply_filters( 'frm_forms_dropdown', array(), '' );
|
773 |
+
$forms = FrmForm::get_published_forms( $where );
|
774 |
+
|
775 |
+
$api = new FrmFormTemplateApi();
|
776 |
+
$templates = $api->get_api_info();
|
777 |
+
self::add_user_templates( $templates );
|
778 |
+
|
779 |
+
$pricing = FrmAppHelper::admin_upgrade_link( 'form-templates' );
|
780 |
+
$plans = array( 'free', 'Personal', 'Business', 'Elite' );
|
781 |
+
|
782 |
+
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list-templates.php' );
|
783 |
+
}
|
784 |
+
|
785 |
+
private static function add_user_templates( &$templates ) {
|
786 |
+
$user_templates = array(
|
787 |
+
'is_template' => 1,
|
788 |
+
'default_template' => 0,
|
789 |
+
);
|
790 |
+
$user_templates = FrmForm::getAll( $user_templates, 'name' );
|
791 |
+
foreach ( $user_templates as $template ) {
|
792 |
+
$template = array(
|
793 |
+
'id' => $template->id,
|
794 |
+
'name' => $template->name,
|
795 |
+
'key' => $template->form_key,
|
796 |
+
'description' => $template->description,
|
797 |
+
'url' => admin_url( 'admin.php?page=formidable&frm_action=duplicate&id=' . absint( $template->id ) ),
|
798 |
+
'released' => $template->created_at,
|
799 |
+
'installed' => 1,
|
800 |
+
);
|
801 |
+
array_unshift( $templates, $template );
|
802 |
+
unset( $template );
|
803 |
+
}
|
804 |
+
}
|
805 |
+
|
806 |
private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
|
807 |
global $frm_vars;
|
808 |
|
839 |
|
840 |
$all_templates = FrmForm::getAll( array( 'is_template' => 1 ), 'name' );
|
841 |
|
842 |
+
if ( defined( 'DOING_AJAX' ) ) {
|
|
|
|
|
843 |
wp_die();
|
844 |
} else if ( $create_link ) {
|
845 |
require( FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php' );
|
858 |
$fields = FrmField::get_all_for_form( $id );
|
859 |
$values = FrmAppHelper::setup_edit_vars( $form, 'forms', $fields, true );
|
860 |
|
|
|
|
|
|
|
|
|
861 |
self::clean_submit_html( $values );
|
862 |
|
863 |
$action_controls = FrmFormActionsController::get_form_actions();
|
1115 |
}
|
1116 |
|
1117 |
if ( isset( $message ) && ! empty( $message ) ) {
|
1118 |
+
$errors['message'] = $message;
|
1119 |
}
|
1120 |
|
1121 |
return $errors;
|
1158 |
switch ( $action ) {
|
1159 |
case 'new':
|
1160 |
return self::new_form( $vars );
|
1161 |
+
case 'add_new':
|
1162 |
+
case 'list_templates':
|
1163 |
case 'create':
|
1164 |
case 'edit':
|
1165 |
case 'update':
|
1261 |
array(
|
1262 |
'parent' => 'frm-forms',
|
1263 |
'id' => 'edit_form_' . $form_id,
|
1264 |
+
'title' => empty( $name ) ? __( '(no title)', 'formidable' ) : $name,
|
1265 |
'href' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ),
|
1266 |
)
|
1267 |
);
|
classes/controllers/FrmHooksController.php
CHANGED
@@ -163,12 +163,13 @@ class FrmHooksController {
|
|
163 |
add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
|
164 |
|
165 |
// Forms Controller
|
166 |
-
add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' );
|
167 |
add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
|
168 |
add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
|
169 |
add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
|
170 |
add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
|
171 |
add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
|
|
|
|
|
172 |
|
173 |
// Settings
|
174 |
add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' );
|
@@ -182,6 +183,7 @@ class FrmHooksController {
|
|
182 |
add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
|
183 |
|
184 |
// XML Controller
|
|
|
185 |
add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
|
186 |
add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
|
187 |
add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
|
163 |
add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' );
|
164 |
|
165 |
// Forms Controller
|
|
|
166 |
add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' );
|
167 |
add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' );
|
168 |
add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' );
|
169 |
add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' );
|
170 |
add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' );
|
171 |
+
add_action( 'wp_ajax_frm_forms_trash', 'FrmFormsController::ajax_trash' );
|
172 |
+
add_action( 'wp_ajax_frm_build_template', 'FrmFormsController::build_template' );
|
173 |
|
174 |
// Settings
|
175 |
add_action( 'wp_ajax_frm_lite_settings_upgrade', 'FrmSettingsController::settings_cta_dismiss' );
|
183 |
add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' );
|
184 |
|
185 |
// XML Controller
|
186 |
+
add_action( 'wp_ajax_frm_install_template', 'FrmXMLController::install_template' );
|
187 |
add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' );
|
188 |
add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' );
|
189 |
add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' );
|
classes/controllers/FrmSimpleBlocksController.php
CHANGED
@@ -60,7 +60,7 @@ class FrmSimpleBlocksController {
|
|
60 |
'name'
|
61 |
);
|
62 |
|
63 |
-
return array_map( '
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -105,6 +105,9 @@ class FrmSimpleBlocksController {
|
|
105 |
'minimize' => array(
|
106 |
'type' => 'string',
|
107 |
),
|
|
|
|
|
|
|
108 |
),
|
109 |
'editor_style' => 'formidable',
|
110 |
'editor_script' => 'formidable-form-selector',
|
60 |
'name'
|
61 |
);
|
62 |
|
63 |
+
return array_map( 'FrmSimpleBlocksController::set_form_options', $forms );
|
64 |
}
|
65 |
|
66 |
/**
|
105 |
'minimize' => array(
|
106 |
'type' => 'string',
|
107 |
),
|
108 |
+
'className' => array(
|
109 |
+
'type' => 'string',
|
110 |
+
),
|
111 |
),
|
112 |
'editor_style' => 'formidable',
|
113 |
'editor_script' => 'formidable-form-selector',
|
classes/controllers/FrmStylesController.php
CHANGED
@@ -35,7 +35,7 @@ class FrmStylesController {
|
|
35 |
'name' => __( 'Styles', 'formidable' ),
|
36 |
'singular_name' => __( 'Style', 'formidable' ),
|
37 |
'menu_name' => __( 'Style', 'formidable' ),
|
38 |
-
'edit' => __( 'Edit' ),
|
39 |
'add_new_item' => __( 'Create a New Style', 'formidable' ),
|
40 |
'edit_item' => __( 'Edit Style', 'formidable' ),
|
41 |
),
|
35 |
'name' => __( 'Styles', 'formidable' ),
|
36 |
'singular_name' => __( 'Style', 'formidable' ),
|
37 |
'menu_name' => __( 'Style', 'formidable' ),
|
38 |
+
'edit' => __( 'Edit', 'formidable' ),
|
39 |
'add_new_item' => __( 'Create a New Style', 'formidable' ),
|
40 |
'edit_item' => __( 'Edit Style', 'formidable' ),
|
41 |
),
|
classes/controllers/FrmXMLController.php
CHANGED
@@ -15,18 +15,12 @@ class FrmXMLController {
|
|
15 |
$set_err = libxml_use_internal_errors( true );
|
16 |
$loader = libxml_disable_entity_loader( true );
|
17 |
|
18 |
-
$files = apply_filters( 'frm_default_templates_files', array(
|
19 |
|
20 |
foreach ( (array) $files as $file ) {
|
21 |
FrmXMLHelper::import_xml( $file );
|
22 |
unset( $file );
|
23 |
}
|
24 |
-
/*
|
25 |
-
if(is_wp_error($result))
|
26 |
-
$errors[] = $result->get_error_message();
|
27 |
-
else if($result)
|
28 |
-
$message = $result;
|
29 |
-
*/
|
30 |
|
31 |
unset( $files );
|
32 |
|
@@ -34,6 +28,86 @@ class FrmXMLController {
|
|
34 |
libxml_disable_entity_loader( $loader );
|
35 |
}
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
public static function route() {
|
38 |
$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
|
39 |
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
|
@@ -184,18 +258,7 @@ class FrmXMLController {
|
|
184 |
);
|
185 |
$args = wp_parse_args( $args, $defaults );
|
186 |
|
187 |
-
|
188 |
-
|
189 |
-
if ( ! empty( $sitename ) ) {
|
190 |
-
$sitename .= '.';
|
191 |
-
}
|
192 |
-
$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
|
193 |
-
|
194 |
-
header( 'Content-Description: File Transfer' );
|
195 |
-
header( 'Content-Disposition: attachment; filename=' . $filename );
|
196 |
-
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
197 |
-
|
198 |
-
//make sure ids are numeric
|
199 |
if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
|
200 |
$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
|
201 |
}
|
@@ -278,6 +341,12 @@ class FrmXMLController {
|
|
278 |
unset( $tb_type );
|
279 |
}
|
280 |
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
|
282 |
include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
|
283 |
}
|
@@ -295,6 +364,38 @@ class FrmXMLController {
|
|
295 |
}
|
296 |
}
|
297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
public static function generate_csv( $atts ) {
|
299 |
$form_ids = $atts['ids'];
|
300 |
if ( empty( $form_ids ) ) {
|
15 |
$set_err = libxml_use_internal_errors( true );
|
16 |
$loader = libxml_disable_entity_loader( true );
|
17 |
|
18 |
+
$files = apply_filters( 'frm_default_templates_files', array() );
|
19 |
|
20 |
foreach ( (array) $files as $file ) {
|
21 |
FrmXMLHelper::import_xml( $file );
|
22 |
unset( $file );
|
23 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
unset( $files );
|
26 |
|
28 |
libxml_disable_entity_loader( $loader );
|
29 |
}
|
30 |
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Use the template link to install the XML template
|
34 |
+
*
|
35 |
+
* @since 3.06
|
36 |
+
*/
|
37 |
+
public static function install_template() {
|
38 |
+
FrmAppHelper::permission_check( 'frm_create_forms' );
|
39 |
+
check_ajax_referer( 'frm_ajax', 'nonce' );
|
40 |
+
|
41 |
+
$url = FrmAppHelper::get_param( 'xml', '', 'post', 'esc_url_raw' );
|
42 |
+
|
43 |
+
$response = wp_remote_get( $url );
|
44 |
+
$body = wp_remote_retrieve_body( $response );
|
45 |
+
$xml = simplexml_load_string( $body );
|
46 |
+
|
47 |
+
if ( ! $xml ) {
|
48 |
+
$response = array(
|
49 |
+
'message' => __( 'There was an error reading the form template', 'formidable' ),
|
50 |
+
);
|
51 |
+
echo wp_json_encode( $response );
|
52 |
+
wp_die();
|
53 |
+
}
|
54 |
+
|
55 |
+
self::set_new_form_name( $xml );
|
56 |
+
|
57 |
+
$imported = FrmXMLHelper::import_xml_now( $xml );
|
58 |
+
if ( isset( $imported['form_status'] ) && ! empty( $imported['form_status'] ) ) {
|
59 |
+
// Get the last form id in case there are child forms.
|
60 |
+
end( $imported['form_status'] );
|
61 |
+
$form_id = key( $imported['form_status'] );
|
62 |
+
$response = array(
|
63 |
+
'id' => $form_id,
|
64 |
+
'redirect' => admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . absint( $form_id ) ),
|
65 |
+
'success' => 1,
|
66 |
+
);
|
67 |
+
} else {
|
68 |
+
$response = array(
|
69 |
+
'message' => __( 'There was an error importing form', 'formidable' ),
|
70 |
+
);
|
71 |
+
}
|
72 |
+
|
73 |
+
echo wp_json_encode( $response );
|
74 |
+
wp_die();
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Change the name of the last form that is not a child.
|
79 |
+
* This will allow for lookup fields and embedded forms
|
80 |
+
* since we redirect to the last form.
|
81 |
+
*
|
82 |
+
* @since 3.06
|
83 |
+
* @param object $xml The values included in the XML.
|
84 |
+
*/
|
85 |
+
private static function set_new_form_name( &$xml ) {
|
86 |
+
if ( ! isset( $xml->form ) ) {
|
87 |
+
return;
|
88 |
+
}
|
89 |
+
|
90 |
+
// Get the main form ID.
|
91 |
+
$set_name = 0;
|
92 |
+
foreach ( $xml->form as $form ) {
|
93 |
+
if ( ! isset( $form->parent_form_id ) || empty( $form->parent_form_id ) ) {
|
94 |
+
$set_name = $form->id;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
|
98 |
+
foreach ( $xml->form as $form ) {
|
99 |
+
// Maybe set the form name if this isn't a child form.
|
100 |
+
if ( $set_name == $form->id ) {
|
101 |
+
$form->name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
|
102 |
+
$form->description = FrmAppHelper::get_param( 'desc', '', 'post', 'sanitize_textarea_field' );
|
103 |
+
}
|
104 |
+
|
105 |
+
// Use a unique key to prevent editing existing form.
|
106 |
+
$name = sanitize_title( $form->name );
|
107 |
+
$form->form_key = FrmAppHelper::get_unique_key( $name, 'frm_forms', 'form_key' );
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
public static function route() {
|
112 |
$action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
|
113 |
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
|
258 |
);
|
259 |
$args = wp_parse_args( $args, $defaults );
|
260 |
|
261 |
+
// Make sure ids are numeric.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) {
|
263 |
$args['ids'] = array_filter( $args['ids'], 'is_numeric' );
|
264 |
}
|
341 |
unset( $tb_type );
|
342 |
}
|
343 |
|
344 |
+
$filename = self::get_file_name( $args, $type, $records );
|
345 |
+
|
346 |
+
header( 'Content-Description: File Transfer' );
|
347 |
+
header( 'Content-Disposition: attachment; filename=' . $filename );
|
348 |
+
header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true );
|
349 |
+
|
350 |
echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n";
|
351 |
include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' );
|
352 |
}
|
364 |
}
|
365 |
}
|
366 |
|
367 |
+
/**
|
368 |
+
* Use a generic file name if multiple items are exported.
|
369 |
+
* Use the nme of the form if only one form is exported.
|
370 |
+
*
|
371 |
+
* @since 3.06
|
372 |
+
*
|
373 |
+
* @return string
|
374 |
+
*/
|
375 |
+
private static function get_file_name( $args, $type, $records ) {
|
376 |
+
$has_one_form = isset( $records['forms'] ) && ! empty( $records['forms'] ) && count( $args['ids'] ) === 1;
|
377 |
+
if ( $has_one_form ) {
|
378 |
+
// one form is being exported
|
379 |
+
$selected_form_id = reset( $args['ids'] );
|
380 |
+
foreach ( $records['forms'] as $form_id ) {
|
381 |
+
$filename = 'form-' . $form_id . '.xml';
|
382 |
+
if ( $selected_form_id === $form_id ) {
|
383 |
+
$form = FrmForm::getOne( $form_id );
|
384 |
+
$filename = sanitize_title( $form->name ) . '-form.xml';
|
385 |
+
break;
|
386 |
+
}
|
387 |
+
}
|
388 |
+
} else {
|
389 |
+
$sitename = sanitize_key( get_bloginfo( 'name' ) );
|
390 |
+
|
391 |
+
if ( ! empty( $sitename ) ) {
|
392 |
+
$sitename .= '.';
|
393 |
+
}
|
394 |
+
$filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml';
|
395 |
+
}
|
396 |
+
return $filename;
|
397 |
+
}
|
398 |
+
|
399 |
public static function generate_csv( $atts ) {
|
400 |
$form_ids = $atts['ids'];
|
401 |
if ( empty( $form_ids ) ) {
|
classes/helpers/FrmAppHelper.php
CHANGED
@@ -4,14 +4,14 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
4 |
}
|
5 |
|
6 |
class FrmAppHelper {
|
7 |
-
public static $db_version =
|
8 |
public static $pro_db_version = 37; //deprecated
|
9 |
public static $font_version = 3;
|
10 |
|
11 |
/**
|
12 |
* @since 2.0
|
13 |
*/
|
14 |
-
public static $plug_version = '3.
|
15 |
|
16 |
/**
|
17 |
* @since 1.07.02
|
@@ -620,6 +620,36 @@ class FrmAppHelper {
|
|
620 |
}
|
621 |
}
|
622 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
623 |
/**
|
624 |
* @param string $type
|
625 |
*/
|
@@ -1650,7 +1680,7 @@ class FrmAppHelper {
|
|
1650 |
'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
|
1651 |
'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
|
1652 |
'url' => self::plugin_url(),
|
1653 |
-
'loading' => __( 'Loading…' ),
|
1654 |
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
1655 |
);
|
1656 |
wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
|
@@ -1677,7 +1707,7 @@ class FrmAppHelper {
|
|
1677 |
$script_strings = array(
|
1678 |
'ajax_url' => $ajax_url,
|
1679 |
'images_url' => self::plugin_url() . '/images',
|
1680 |
-
'loading' => __( 'Loading…' ),
|
1681 |
'remove' => __( 'Remove', 'formidable' ),
|
1682 |
'offset' => apply_filters( 'frm_scroll_offset', 4 ),
|
1683 |
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
@@ -1698,7 +1728,7 @@ class FrmAppHelper {
|
|
1698 |
'no_label' => __( '(no label)', 'formidable' ),
|
1699 |
'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
|
1700 |
'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
|
1701 |
-
'ok' => __( 'OK' ),
|
1702 |
'cancel' => __( 'Cancel', 'formidable' ),
|
1703 |
'default' => __( 'Default', 'formidable' ),
|
1704 |
'clear_default' => __( 'Clear default value when typing', 'formidable' ),
|
@@ -1719,7 +1749,7 @@ class FrmAppHelper {
|
|
1719 |
'import_complete' => __( 'Import Complete', 'formidable' ),
|
1720 |
'updating' => __( 'Please wait while your site updates.', 'formidable' ),
|
1721 |
'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
|
1722 |
-
'private' => __( 'Private' ),
|
1723 |
'jquery_ui_url' => self::jquery_ui_base_url(),
|
1724 |
'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
|
1725 |
'no_licenses' => __( 'No new licenses were found', 'formidable' ),
|
4 |
}
|
5 |
|
6 |
class FrmAppHelper {
|
7 |
+
public static $db_version = 90; //version of the database we are moving to
|
8 |
public static $pro_db_version = 37; //deprecated
|
9 |
public static $font_version = 3;
|
10 |
|
11 |
/**
|
12 |
* @since 2.0
|
13 |
*/
|
14 |
+
public static $plug_version = '3.06';
|
15 |
|
16 |
/**
|
17 |
* @since 1.07.02
|
620 |
}
|
621 |
}
|
622 |
|
623 |
+
/**
|
624 |
+
* @since 3.06
|
625 |
+
*/
|
626 |
+
public static function show_search_box( $text, $input_id, $placeholder = '' ) {
|
627 |
+
$tosearch = '';
|
628 |
+
$class = 'frm-search-input';
|
629 |
+
if ( $input_id === 'template' ) {
|
630 |
+
$tosearch = 'frm-card';
|
631 |
+
$class .= ' frm-auto-search';
|
632 |
+
}
|
633 |
+
$input_id = $input_id . '-search-input';
|
634 |
+
if ( empty( $text ) ) {
|
635 |
+
$text = __( 'Search', 'formidable' );
|
636 |
+
}
|
637 |
+
?>
|
638 |
+
<p class="search-box frm-search">
|
639 |
+
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ) ?>">
|
640 |
+
<?php echo wp_kses( $text, array() ); ?>:
|
641 |
+
</label>
|
642 |
+
<span class="dashicons dashicons-search"></span>
|
643 |
+
<input type="search" id="<?php echo esc_attr( $input_id ) ?>" name="s" value="<?php _admin_search_query(); ?>" placeholder="<?php echo esc_attr( $placeholder ); ?>" class="<?php echo esc_attr( $class ); ?>" data-tosearch="<?php echo esc_attr( $tosearch ); ?>" />
|
644 |
+
<?php
|
645 |
+
if ( empty( $tosearch ) ) {
|
646 |
+
submit_button( $text, 'button-secondary', '', false, array( 'id' => 'search-submit' ) );
|
647 |
+
}
|
648 |
+
?>
|
649 |
+
</p>
|
650 |
+
<?php
|
651 |
+
}
|
652 |
+
|
653 |
/**
|
654 |
* @param string $type
|
655 |
*/
|
1680 |
'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
|
1681 |
'deauthorize' => __( 'Are you sure you want to deauthorize Formidable Forms on this site?', 'formidable' ),
|
1682 |
'url' => self::plugin_url(),
|
1683 |
+
'loading' => __( 'Loading…', 'formidable' ),
|
1684 |
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
1685 |
);
|
1686 |
wp_localize_script( 'formidable_admin_global', 'frmGlobal', $global_strings );
|
1707 |
$script_strings = array(
|
1708 |
'ajax_url' => $ajax_url,
|
1709 |
'images_url' => self::plugin_url() . '/images',
|
1710 |
+
'loading' => __( 'Loading…', 'formidable' ),
|
1711 |
'remove' => __( 'Remove', 'formidable' ),
|
1712 |
'offset' => apply_filters( 'frm_scroll_offset', 4 ),
|
1713 |
'nonce' => wp_create_nonce( 'frm_ajax' ),
|
1728 |
'no_label' => __( '(no label)', 'formidable' ),
|
1729 |
'saving' => esc_attr( __( 'Saving', 'formidable' ) ),
|
1730 |
'saved' => esc_attr( __( 'Saved', 'formidable' ) ),
|
1731 |
+
'ok' => __( 'OK', 'formidable' ),
|
1732 |
'cancel' => __( 'Cancel', 'formidable' ),
|
1733 |
'default' => __( 'Default', 'formidable' ),
|
1734 |
'clear_default' => __( 'Clear default value when typing', 'formidable' ),
|
1749 |
'import_complete' => __( 'Import Complete', 'formidable' ),
|
1750 |
'updating' => __( 'Please wait while your site updates.', 'formidable' ),
|
1751 |
'no_save_warning' => __( 'Warning: There is no way to retrieve unsaved entries.', 'formidable' ),
|
1752 |
+
'private' => __( 'Private', 'formidable' ),
|
1753 |
'jquery_ui_url' => self::jquery_ui_base_url(),
|
1754 |
'pro_url' => is_callable( 'FrmProAppHelper::plugin_url' ) ? FrmProAppHelper::plugin_url() : '',
|
1755 |
'no_licenses' => __( 'No new licenses were found', 'formidable' ),
|
classes/helpers/FrmEntriesHelper.php
CHANGED
@@ -538,7 +538,7 @@ class FrmEntriesHelper {
|
|
538 |
if ( current_user_can( 'frm_delete_entries' ) ) {
|
539 |
$actions['frm_delete'] = array(
|
540 |
'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
|
541 |
-
'label' => __( 'Delete' ),
|
542 |
'icon' => 'frm_icon_font frm_delete_icon',
|
543 |
'data' => array( 'frmverify' => __( 'Really delete?', 'formidable' ) ),
|
544 |
);
|
538 |
if ( current_user_can( 'frm_delete_entries' ) ) {
|
539 |
$actions['frm_delete'] = array(
|
540 |
'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ),
|
541 |
+
'label' => __( 'Delete', 'formidable' ),
|
542 |
'icon' => 'frm_icon_font frm_delete_icon',
|
543 |
'data' => array( 'frmverify' => __( 'Really delete?', 'formidable' ) ),
|
544 |
);
|
classes/helpers/FrmEntriesListHelper.php
CHANGED
@@ -111,7 +111,7 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
111 |
if ( $which == 'top' && empty( $form_id ) ) {
|
112 |
echo '<div class="alignleft actions">';
|
113 |
echo FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) ); // WPCS: XSS ok.
|
114 |
-
submit_button( __( 'Filter' ), 'filter_action', '', false, array( 'id' => 'post-query-submit' ) );
|
115 |
echo '</div>';
|
116 |
}
|
117 |
}
|
@@ -221,7 +221,7 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
221 |
$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
|
222 |
break;
|
223 |
case 'is_draft':
|
224 |
-
$val = empty( $item->is_draft ) ? esc_html__( 'No' ) : esc_html__( 'Yes' );
|
225 |
break;
|
226 |
case 'form_id':
|
227 |
$val = FrmFormsHelper::edit_form_link( $item->form_id );
|
@@ -254,7 +254,7 @@ class FrmEntriesListHelper extends FrmListHelper {
|
|
254 |
|
255 |
if ( current_user_can( 'frm_delete_entries' ) ) {
|
256 |
$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
|
257 |
-
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete' ) . '</a>';
|
258 |
}
|
259 |
|
260 |
$actions = apply_filters( 'frm_row_actions', $actions, $item );
|
111 |
if ( $which == 'top' && empty( $form_id ) ) {
|
112 |
echo '<div class="alignleft actions">';
|
113 |
echo FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) ); // WPCS: XSS ok.
|
114 |
+
submit_button( __( 'Filter', 'formidable' ), 'filter_action', '', false, array( 'id' => 'post-query-submit' ) );
|
115 |
echo '</div>';
|
116 |
}
|
117 |
}
|
221 |
$val = '<abbr title="' . esc_attr( FrmAppHelper::get_formatted_time( $item->{$col_name}, '', 'g:i:s A' ) ) . '">' . $date . '</abbr>';
|
222 |
break;
|
223 |
case 'is_draft':
|
224 |
+
$val = empty( $item->is_draft ) ? esc_html__( 'No', 'formidable' ) : esc_html__( 'Yes', 'formidable' );
|
225 |
break;
|
226 |
case 'form_id':
|
227 |
$val = FrmFormsHelper::edit_form_link( $item->form_id );
|
254 |
|
255 |
if ( current_user_can( 'frm_delete_entries' ) ) {
|
256 |
$delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
|
257 |
+
$actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Are you sure?', 'formidable' ) . '">' . __( 'Delete', 'formidable' ) . '</a>';
|
258 |
}
|
259 |
|
260 |
$actions = apply_filters( 'frm_row_actions', $actions, $item );
|
classes/helpers/FrmFieldsHelper.php
CHANGED
@@ -438,7 +438,7 @@ class FrmFieldsHelper {
|
|
438 |
|
439 |
$link = sprintf(
|
440 |
esc_html__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
|
441 |
-
'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? esc_html__( 'Categories' ) : $tax->labels->name ) . '</a>'
|
442 |
);
|
443 |
unset( $tax );
|
444 |
|
438 |
|
439 |
$link = sprintf(
|
440 |
esc_html__( 'Please add options from the WordPress "%1$s" page', 'formidable' ),
|
441 |
+
'<a href="' . esc_url( admin_url( 'edit-tags.php?taxonomy=' . $tax->name ) ) . '" target="_blank">' . ( empty( $tax->labels->name ) ? esc_html__( 'Categories', 'formidable' ) : $tax->labels->name ) . '</a>'
|
442 |
);
|
443 |
unset( $tax );
|
444 |
|
classes/helpers/FrmFormsHelper.php
CHANGED
@@ -110,7 +110,7 @@ class FrmFormsHelper {
|
|
110 |
$args['form'] = $form->id;
|
111 |
}
|
112 |
?>
|
113 |
-
<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
|
114 |
<?php
|
115 |
unset( $form );
|
116 |
}
|
@@ -217,7 +217,6 @@ class FrmFormsHelper {
|
|
217 |
'form_id' => '',
|
218 |
'logged_in' => '',
|
219 |
'editable' => '',
|
220 |
-
'default_template' => 0,
|
221 |
'is_template' => 0,
|
222 |
'status' => 'draft',
|
223 |
'parent_form_id' => 0,
|
@@ -248,7 +247,6 @@ class FrmFormsHelper {
|
|
248 |
}
|
249 |
|
250 |
$values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
|
251 |
-
$values['default_template'] = isset( $post_values['default_template'] ) ? $post_values['default_template'] : $record->default_template;
|
252 |
$values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
|
253 |
$values['status'] = $record->status;
|
254 |
|
@@ -776,7 +774,7 @@ BEFORE_HTML;
|
|
776 |
}
|
777 |
|
778 |
if ( $form_id ) {
|
779 |
-
$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
|
780 |
} else {
|
781 |
$val = '';
|
782 |
}
|
110 |
$args['form'] = $form->id;
|
111 |
}
|
112 |
?>
|
113 |
+
<li><a href="<?php echo esc_url( isset( $base ) ? add_query_arg( $args, $base ) : add_query_arg( $args ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $form->name, 60 ) ); ?></a></li>
|
114 |
<?php
|
115 |
unset( $form );
|
116 |
}
|
217 |
'form_id' => '',
|
218 |
'logged_in' => '',
|
219 |
'editable' => '',
|
|
|
220 |
'is_template' => 0,
|
221 |
'status' => 'draft',
|
222 |
'parent_form_id' => 0,
|
247 |
}
|
248 |
|
249 |
$values['form_key'] = isset( $post_values['form_key'] ) ? $post_values['form_key'] : $record->form_key;
|
|
|
250 |
$values['is_template'] = isset( $post_values['is_template'] ) ? $post_values['is_template'] : $record->is_template;
|
251 |
$values['status'] = $record->status;
|
252 |
|
774 |
}
|
775 |
|
776 |
if ( $form_id ) {
|
777 |
+
$val = '<a href="' . esc_url( admin_url( 'admin.php?page=formidable&frm_action=edit&id=' . $form_id ) ) . '">' . ( '' == $name ? __( '(no title)', 'formidable' ) : FrmAppHelper::truncate( $name, 40 ) ) . '</a>';
|
778 |
} else {
|
779 |
$val = '';
|
780 |
}
|
classes/helpers/FrmFormsListHelper.php
CHANGED
@@ -51,10 +51,6 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
51 |
),
|
52 |
);
|
53 |
switch ( $this->status ) {
|
54 |
-
case 'template':
|
55 |
-
$s_query['is_template'] = 1;
|
56 |
-
$s_query['status !'] = 'trash';
|
57 |
-
break;
|
58 |
case 'draft':
|
59 |
$s_query['is_template'] = 0;
|
60 |
$s_query['status'] = 'draft';
|
@@ -100,14 +96,12 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
100 |
}
|
101 |
|
102 |
public function no_items() {
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
esc_html_e( '
|
107 |
-
|
108 |
-
<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>"><?php esc_html_e( 'Add New', 'formidable' ); ?></a>
|
109 |
<?php
|
110 |
-
}
|
111 |
}
|
112 |
|
113 |
public function get_bulk_actions() {
|
@@ -124,7 +118,7 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
124 |
} elseif ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
|
125 |
$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
|
126 |
} elseif ( current_user_can( 'frm_delete_forms' ) ) {
|
127 |
-
$actions['bulk_delete'] = __( 'Delete' );
|
128 |
}
|
129 |
|
130 |
return $actions;
|
@@ -138,56 +132,16 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
138 |
if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
|
139 |
?>
|
140 |
<div class="alignleft actions frm_visible_overflow">
|
141 |
-
<?php submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); ?>
|
142 |
</div>
|
143 |
<?php
|
144 |
-
return;
|
145 |
}
|
146 |
-
|
147 |
-
if ( 'template' != $this->status ) {
|
148 |
-
return;
|
149 |
-
}
|
150 |
-
|
151 |
-
$where = apply_filters( 'frm_forms_dropdown', array(), '' );
|
152 |
-
$forms = FrmForm::get_published_forms( $where );
|
153 |
-
|
154 |
-
$base = admin_url( 'admin.php?page=formidable&form_type=template' );
|
155 |
-
$args = array(
|
156 |
-
'frm_action' => 'duplicate',
|
157 |
-
'template' => true,
|
158 |
-
);
|
159 |
-
|
160 |
-
?>
|
161 |
-
<div class="alignleft actions frm_visible_overflow">
|
162 |
-
<div class="dropdown frm_tiny_top_margin">
|
163 |
-
<a href="#" id="frm-templateDrop" class="frm-dropdown-toggle button" data-toggle="dropdown"><?php esc_html_e( 'Create New Template', 'formidable' ) ?> <b class="caret"></b></a>
|
164 |
-
<ul class="frm-dropdown-menu" role="menu" aria-labelledby="frm-templateDrop">
|
165 |
-
<?php
|
166 |
-
if ( empty( $forms ) ) {
|
167 |
-
?>
|
168 |
-
<li class="frm_dropdown_li"><?php esc_html_e( 'You have not created any forms yet. You must create a form before you can make a template.', 'formidable' ) ?></li>
|
169 |
-
<?php
|
170 |
-
} else {
|
171 |
-
foreach ( $forms as $form ) {
|
172 |
-
$args['id'] = $form->id;
|
173 |
-
?>
|
174 |
-
<li><a href="<?php echo esc_url( add_query_arg( $args, $base ) ); ?>" tabindex="-1"><?php echo esc_html( empty( $form->name ) ? __( '(no title)' ) : FrmAppHelper::truncate( $form->name, 33 ) ); ?></a></li>
|
175 |
-
<?php
|
176 |
-
unset( $form );
|
177 |
-
}
|
178 |
-
}
|
179 |
-
?>
|
180 |
-
</ul>
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
<?php
|
184 |
}
|
185 |
|
186 |
public function get_views() {
|
187 |
|
188 |
$statuses = array(
|
189 |
'published' => __( 'My Forms', 'formidable' ),
|
190 |
-
'template' => __( 'Templates', 'formidable' ),
|
191 |
'draft' => __( 'Drafts', 'formidable' ),
|
192 |
'trash' => __( 'Trash', 'formidable' ),
|
193 |
);
|
@@ -209,7 +163,7 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
209 |
$class = '';
|
210 |
}
|
211 |
|
212 |
-
if ( $counts->{$status} || 'published' == $status
|
213 |
$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
|
214 |
}
|
215 |
|
@@ -295,10 +249,6 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
295 |
$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
|
296 |
unset( $text );
|
297 |
}
|
298 |
-
break;
|
299 |
-
case 'type':
|
300 |
-
$val = ( $item->is_template && $item->default_template ) ? __( 'Default', 'formidable' ) : __( 'Custom', 'formidable' );
|
301 |
-
break;
|
302 |
}
|
303 |
|
304 |
if ( isset( $val ) ) {
|
@@ -328,17 +278,12 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
328 |
}
|
329 |
|
330 |
if ( current_user_can( 'frm_edit_forms' ) ) {
|
331 |
-
|
332 |
-
|
333 |
-
}
|
334 |
-
|
335 |
-
if ( ! $item->is_template ) {
|
336 |
-
$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
|
337 |
-
}
|
338 |
}
|
339 |
|
340 |
$actions = array_merge( $actions, $new_actions );
|
341 |
-
$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview' ) . '</a>';
|
342 |
}
|
343 |
|
344 |
/**
|
@@ -347,7 +292,7 @@ class FrmFormsListHelper extends FrmListHelper {
|
|
347 |
private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
|
348 |
$form_name = $item->name;
|
349 |
if ( trim( $form_name ) == '' ) {
|
350 |
-
$form_name = __( '(no title)' );
|
351 |
}
|
352 |
$form_name = FrmAppHelper::kses( $form_name );
|
353 |
if ( 'excerpt' != $mode ) {
|
51 |
),
|
52 |
);
|
53 |
switch ( $this->status ) {
|
|
|
|
|
|
|
|
|
54 |
case 'draft':
|
55 |
$s_query['is_template'] = 0;
|
56 |
$s_query['status'] = 'draft';
|
96 |
}
|
97 |
|
98 |
public function no_items() {
|
99 |
+
esc_html_e( 'No Forms Found.', 'formidable' );
|
100 |
+
?>
|
101 |
+
<a href="<?php echo esc_url( admin_url( 'admin.php?page=formidable&frm_action=new' ) ) ?>">
|
102 |
+
<?php esc_html_e( 'Add New', 'formidable' ); ?>
|
103 |
+
</a>
|
|
|
104 |
<?php
|
|
|
105 |
}
|
106 |
|
107 |
public function get_bulk_actions() {
|
118 |
} elseif ( EMPTY_TRASH_DAYS && current_user_can( 'frm_delete_forms' ) ) {
|
119 |
$actions['bulk_trash'] = __( 'Move to Trash', 'formidable' );
|
120 |
} elseif ( current_user_can( 'frm_delete_forms' ) ) {
|
121 |
+
$actions['bulk_delete'] = __( 'Delete', 'formidable' );
|
122 |
}
|
123 |
|
124 |
return $actions;
|
132 |
if ( 'trash' == $this->status && current_user_can( 'frm_delete_forms' ) ) {
|
133 |
?>
|
134 |
<div class="alignleft actions frm_visible_overflow">
|
135 |
+
<?php submit_button( __( 'Empty Trash', 'formidable' ), 'apply', 'delete_all', false ); ?>
|
136 |
</div>
|
137 |
<?php
|
|
|
138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
|
141 |
public function get_views() {
|
142 |
|
143 |
$statuses = array(
|
144 |
'published' => __( 'My Forms', 'formidable' ),
|
|
|
145 |
'draft' => __( 'Drafts', 'formidable' ),
|
146 |
'trash' => __( 'Trash', 'formidable' ),
|
147 |
);
|
163 |
$class = '';
|
164 |
}
|
165 |
|
166 |
+
if ( $counts->{$status} || 'published' == $status ) {
|
167 |
$links[ $status ] = '<a href="' . esc_url( '?page=formidable&form_type=' . $status ) . '" ' . $class . '>' . sprintf( __( '%1$s <span class="count">(%2$s)</span>', 'formidable' ), $name, number_format_i18n( $counts->{$status} ) ) . '</a>';
|
168 |
}
|
169 |
|
249 |
$val = current_user_can( 'frm_view_entries' ) ? '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-entries&form=' . $item->id ) ) . '">' . $text . '</a>' : $text;
|
250 |
unset( $text );
|
251 |
}
|
|
|
|
|
|
|
|
|
252 |
}
|
253 |
|
254 |
if ( isset( $val ) ) {
|
278 |
}
|
279 |
|
280 |
if ( current_user_can( 'frm_edit_forms' ) ) {
|
281 |
+
$actions['frm_edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'formidable' ) . '</a>';
|
282 |
+
$actions['frm_settings'] = '<a href="' . esc_url( '?page=formidable&frm_action=settings&id=' . $item->id ) . '">' . __( 'Settings', 'formidable' ) . '</a>';
|
|
|
|
|
|
|
|
|
|
|
283 |
}
|
284 |
|
285 |
$actions = array_merge( $actions, $new_actions );
|
286 |
+
$actions['view'] = '<a href="' . esc_url( FrmFormsHelper::get_direct_link( $item->form_key, $item ) ) . '" target="_blank">' . __( 'Preview', 'formidable' ) . '</a>';
|
287 |
}
|
288 |
|
289 |
/**
|
292 |
private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
|
293 |
$form_name = $item->name;
|
294 |
if ( trim( $form_name ) == '' ) {
|
295 |
+
$form_name = __( '(no title)', 'formidable' );
|
296 |
}
|
297 |
$form_name = FrmAppHelper::kses( $form_name );
|
298 |
if ( 'excerpt' != $mode ) {
|
classes/helpers/FrmListHelper.php
CHANGED
@@ -120,8 +120,8 @@ class FrmListHelper {
|
|
120 |
|
121 |
if ( empty( $this->modes ) ) {
|
122 |
$this->modes = array(
|
123 |
-
'list' => __( 'List View' ),
|
124 |
-
'excerpt' => __( 'Excerpt View' ),
|
125 |
);
|
126 |
}
|
127 |
}
|
@@ -237,7 +237,7 @@ class FrmListHelper {
|
|
237 |
* @access public
|
238 |
*/
|
239 |
public function no_items() {
|
240 |
-
esc_html_e( 'No items found.' );
|
241 |
}
|
242 |
|
243 |
/**
|
@@ -254,18 +254,11 @@ class FrmListHelper {
|
|
254 |
return;
|
255 |
}
|
256 |
|
257 |
-
$input_id = $input_id . '-search-input';
|
258 |
-
|
259 |
foreach ( array( 'orderby', 'order' ) as $search_params ) {
|
260 |
$this->hidden_search_inputs( $search_params );
|
261 |
}
|
262 |
-
|
263 |
-
|
264 |
-
<label class="screen-reader-text" for="<?php echo esc_attr( $input_id ) ?>"><?php echo wp_kses( $text, array() ); ?>:</label>
|
265 |
-
<input type="search" id="<?php echo esc_attr( $input_id ) ?>" name="s" value="<?php _admin_search_query(); ?>" />
|
266 |
-
<?php submit_button( $text, 'button', '', false, array( 'id' => 'search-submit' ) ); ?>
|
267 |
-
</p>
|
268 |
-
<?php
|
269 |
}
|
270 |
|
271 |
private function hidden_search_inputs( $param_name ) {
|
@@ -369,9 +362,9 @@ class FrmListHelper {
|
|
369 |
return;
|
370 |
}
|
371 |
|
372 |
-
echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_attr__( 'Select bulk action' ) . '</label>';
|
373 |
echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
|
374 |
-
echo "<option value='-1' selected='selected'>" . esc_attr__( 'Bulk Actions' ) . "</option>\n";
|
375 |
|
376 |
foreach ( $this->_actions as $name => $title ) {
|
377 |
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
@@ -381,7 +374,7 @@ class FrmListHelper {
|
|
381 |
|
382 |
echo "</select>\n";
|
383 |
|
384 |
-
submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
385 |
echo "\n";
|
386 |
}
|
387 |
|
@@ -446,7 +439,7 @@ class FrmListHelper {
|
|
446 |
}
|
447 |
$out .= '</div>';
|
448 |
|
449 |
-
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>';
|
450 |
|
451 |
return $out;
|
452 |
}
|
@@ -552,7 +545,7 @@ class FrmListHelper {
|
|
552 |
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
553 |
}
|
554 |
|
555 |
-
$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>';
|
556 |
|
557 |
$current = $this->get_pagenum();
|
558 |
|
@@ -583,17 +576,17 @@ class FrmListHelper {
|
|
583 |
|
584 |
if ( 'bottom' == $which ) {
|
585 |
$html_current_page = $current;
|
586 |
-
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input">';
|
587 |
} else {
|
588 |
$html_current_page = sprintf(
|
589 |
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
|
590 |
-
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>',
|
591 |
$current,
|
592 |
strlen( $total_pages )
|
593 |
);
|
594 |
}
|
595 |
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
596 |
-
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;
|
597 |
|
598 |
$page_links[] = $this->add_page_link(
|
599 |
array(
|
@@ -657,10 +650,10 @@ class FrmListHelper {
|
|
657 |
|
658 |
private function link_label( $link ) {
|
659 |
$labels = array(
|
660 |
-
'first' => __( 'First page' ),
|
661 |
-
'last' => __( 'Last page' ),
|
662 |
-
'prev' => __( 'Previous page' ),
|
663 |
-
'next' => __( 'Next page' ),
|
664 |
);
|
665 |
return $labels[ $link ];
|
666 |
}
|
@@ -875,7 +868,7 @@ class FrmListHelper {
|
|
875 |
|
876 |
if ( ! empty( $columns['cb'] ) ) {
|
877 |
static $cb_counter = 1;
|
878 |
-
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'
|
879 |
. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
|
880 |
$cb_counter++;
|
881 |
}
|
@@ -1099,7 +1092,7 @@ class FrmListHelper {
|
|
1099 |
* @return string The row actions output. In this case, an empty string.
|
1100 |
*/
|
1101 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
1102 |
-
return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details' ) . '</span></button>' : '';
|
1103 |
}
|
1104 |
|
1105 |
/**
|
@@ -1124,7 +1117,7 @@ class FrmListHelper {
|
|
1124 |
|
1125 |
if ( isset( $this->_pagination_args['total_items'] ) ) {
|
1126 |
$response['total_items_i18n'] = sprintf(
|
1127 |
-
_n( '%s item', '%s items', $this->_pagination_args['total_items'] ),
|
1128 |
number_format_i18n( $this->_pagination_args['total_items'] )
|
1129 |
);
|
1130 |
}
|
120 |
|
121 |
if ( empty( $this->modes ) ) {
|
122 |
$this->modes = array(
|
123 |
+
'list' => __( 'List View', 'formidable' ),
|
124 |
+
'excerpt' => __( 'Excerpt View', 'formidable' ),
|
125 |
);
|
126 |
}
|
127 |
}
|
237 |
* @access public
|
238 |
*/
|
239 |
public function no_items() {
|
240 |
+
esc_html_e( 'No items found.', 'formidable' );
|
241 |
}
|
242 |
|
243 |
/**
|
254 |
return;
|
255 |
}
|
256 |
|
|
|
|
|
257 |
foreach ( array( 'orderby', 'order' ) as $search_params ) {
|
258 |
$this->hidden_search_inputs( $search_params );
|
259 |
}
|
260 |
+
|
261 |
+
FrmAppHelper::show_search_box( $text, $input_id );
|
|
|
|
|
|
|
|
|
|
|
262 |
}
|
263 |
|
264 |
private function hidden_search_inputs( $param_name ) {
|
362 |
return;
|
363 |
}
|
364 |
|
365 |
+
echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_attr__( 'Select bulk action', 'formidable' ) . '</label>';
|
366 |
echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
|
367 |
+
echo "<option value='-1' selected='selected'>" . esc_attr__( 'Bulk Actions', 'formidable' ) . "</option>\n";
|
368 |
|
369 |
foreach ( $this->_actions as $name => $title ) {
|
370 |
$class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
|
374 |
|
375 |
echo "</select>\n";
|
376 |
|
377 |
+
submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
|
378 |
echo "\n";
|
379 |
}
|
380 |
|
439 |
}
|
440 |
$out .= '</div>';
|
441 |
|
442 |
+
$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
|
443 |
|
444 |
return $out;
|
445 |
}
|
545 |
$infinite_scroll = $this->_pagination_args['infinite_scroll'];
|
546 |
}
|
547 |
|
548 |
+
$output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
|
549 |
|
550 |
$current = $this->get_pagenum();
|
551 |
|
576 |
|
577 |
if ( 'bottom' == $which ) {
|
578 |
$html_current_page = $current;
|
579 |
+
$total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
|
580 |
} else {
|
581 |
$html_current_page = sprintf(
|
582 |
"%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
|
583 |
+
'<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>',
|
584 |
$current,
|
585 |
strlen( $total_pages )
|
586 |
);
|
587 |
}
|
588 |
$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
|
589 |
+
$page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'formidable' ), $html_current_page, $html_total_pages ) . $total_pages_after;
|
590 |
|
591 |
$page_links[] = $this->add_page_link(
|
592 |
array(
|
650 |
|
651 |
private function link_label( $link ) {
|
652 |
$labels = array(
|
653 |
+
'first' => __( 'First page', 'formidable' ),
|
654 |
+
'last' => __( 'Last page', 'formidable' ),
|
655 |
+
'prev' => __( 'Previous page', 'formidable' ),
|
656 |
+
'next' => __( 'Next page', 'formidable' ),
|
657 |
);
|
658 |
return $labels[ $link ];
|
659 |
}
|
868 |
|
869 |
if ( ! empty( $columns['cb'] ) ) {
|
870 |
static $cb_counter = 1;
|
871 |
+
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>'
|
872 |
. '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
|
873 |
$cb_counter++;
|
874 |
}
|
1092 |
* @return string The row actions output. In this case, an empty string.
|
1093 |
*/
|
1094 |
protected function handle_row_actions( $item, $column_name, $primary ) {
|
1095 |
+
return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : '';
|
1096 |
}
|
1097 |
|
1098 |
/**
|
1117 |
|
1118 |
if ( isset( $this->_pagination_args['total_items'] ) ) {
|
1119 |
$response['total_items_i18n'] = sprintf(
|
1120 |
+
_n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
|
1121 |
number_format_i18n( $this->_pagination_args['total_items'] )
|
1122 |
);
|
1123 |
}
|
classes/helpers/FrmXMLHelper.php
CHANGED
@@ -23,25 +23,6 @@ class FrmXMLHelper {
|
|
23 |
}
|
24 |
|
25 |
public static function import_xml( $file ) {
|
26 |
-
$defaults = array(
|
27 |
-
'forms' => 0,
|
28 |
-
'fields' => 0,
|
29 |
-
'terms' => 0,
|
30 |
-
'posts' => 0,
|
31 |
-
'views' => 0,
|
32 |
-
'actions' => 0,
|
33 |
-
'styles' => 0,
|
34 |
-
);
|
35 |
-
|
36 |
-
$imported = array(
|
37 |
-
'imported' => $defaults,
|
38 |
-
'updated' => $defaults,
|
39 |
-
'forms' => array(),
|
40 |
-
'terms' => array(),
|
41 |
-
);
|
42 |
-
|
43 |
-
unset( $defaults );
|
44 |
-
|
45 |
if ( ! defined( 'WP_IMPORTING' ) ) {
|
46 |
define( 'WP_IMPORTING', true );
|
47 |
}
|
@@ -68,7 +49,18 @@ class FrmXMLHelper {
|
|
68 |
return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
|
69 |
}
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
|
73 |
// grab cats, tags, and terms, or forms or posts
|
74 |
if ( isset( $xml->{$item_type} ) ) {
|
@@ -78,10 +70,31 @@ class FrmXMLHelper {
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
-
|
|
|
82 |
|
83 |
-
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
|
86 |
public static function import_xml_terms( $terms, $imported ) {
|
87 |
foreach ( $terms as $t ) {
|
@@ -190,7 +203,6 @@ class FrmXMLHelper {
|
|
190 |
'options' => (string) $item->options,
|
191 |
'logged_in' => (int) $item->logged_in,
|
192 |
'is_template' => (int) $item->is_template,
|
193 |
-
'default_template' => (int) $item->default_template,
|
194 |
'editable' => (int) $item->editable,
|
195 |
'status' => (string) $item->status,
|
196 |
'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
|
@@ -872,8 +884,9 @@ class FrmXMLHelper {
|
|
872 |
*/
|
873 |
public static function prepare_form_options_for_export( $options ) {
|
874 |
$options = maybe_unserialize( $options );
|
875 |
-
// Change custom_style to the post_name instead of ID
|
876 |
-
|
|
|
877 |
global $wpdb;
|
878 |
$table = $wpdb->prefix . 'posts';
|
879 |
$where = array( 'ID' => $options['custom_style'] );
|
@@ -887,10 +900,107 @@ class FrmXMLHelper {
|
|
887 |
$options['custom_style'] = 1;
|
888 |
}
|
889 |
}
|
|
|
890 |
$options = serialize( $options );
|
891 |
return self::cdata( $options );
|
892 |
}
|
893 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
894 |
public static function cdata( $str ) {
|
895 |
$str = maybe_unserialize( $str );
|
896 |
if ( is_array( $str ) ) {
|
23 |
}
|
24 |
|
25 |
public static function import_xml( $file ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
if ( ! defined( 'WP_IMPORTING' ) ) {
|
27 |
define( 'WP_IMPORTING', true );
|
28 |
}
|
49 |
return new WP_Error( 'SimpleXML_parse_error', __( 'There was an error when reading this XML file', 'formidable' ), libxml_get_errors() );
|
50 |
}
|
51 |
|
52 |
+
return self::import_xml_now( $xml );
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Add terms, forms (form and field ids), posts (post ids), and entries to db, in that order
|
57 |
+
*
|
58 |
+
* @since 3.06
|
59 |
+
* @return array The number of items imported
|
60 |
+
*/
|
61 |
+
public static function import_xml_now( $xml ) {
|
62 |
+
$imported = self::pre_import_data();
|
63 |
+
|
64 |
foreach ( array( 'term', 'form', 'view' ) as $item_type ) {
|
65 |
// grab cats, tags, and terms, or forms or posts
|
66 |
if ( isset( $xml->{$item_type} ) ) {
|
70 |
}
|
71 |
}
|
72 |
|
73 |
+
return apply_filters( 'frm_importing_xml', $imported, $xml );
|
74 |
+
}
|
75 |
|
76 |
+
/**
|
77 |
+
* @since 3.06
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
private static function pre_import_data() {
|
81 |
+
$defaults = array(
|
82 |
+
'forms' => 0,
|
83 |
+
'fields' => 0,
|
84 |
+
'terms' => 0,
|
85 |
+
'posts' => 0,
|
86 |
+
'views' => 0,
|
87 |
+
'actions' => 0,
|
88 |
+
'styles' => 0,
|
89 |
+
);
|
90 |
+
|
91 |
+
return array(
|
92 |
+
'imported' => $defaults,
|
93 |
+
'updated' => $defaults,
|
94 |
+
'forms' => array(),
|
95 |
+
'terms' => array(),
|
96 |
+
);
|
97 |
+
}
|
98 |
|
99 |
public static function import_xml_terms( $terms, $imported ) {
|
100 |
foreach ( $terms as $t ) {
|
203 |
'options' => (string) $item->options,
|
204 |
'logged_in' => (int) $item->logged_in,
|
205 |
'is_template' => (int) $item->is_template,
|
|
|
206 |
'editable' => (int) $item->editable,
|
207 |
'status' => (string) $item->status,
|
208 |
'parent_form_id' => isset( $item->parent_form_id ) ? (int) $item->parent_form_id : 0,
|
884 |
*/
|
885 |
public static function prepare_form_options_for_export( $options ) {
|
886 |
$options = maybe_unserialize( $options );
|
887 |
+
// Change custom_style to the post_name instead of ID (1 may be a string)
|
888 |
+
$not_default = isset( $options['custom_style'] ) && 1 != $options['custom_style'];
|
889 |
+
if ( $not_default ) {
|
890 |
global $wpdb;
|
891 |
$table = $wpdb->prefix . 'posts';
|
892 |
$where = array( 'ID' => $options['custom_style'] );
|
900 |
$options['custom_style'] = 1;
|
901 |
}
|
902 |
}
|
903 |
+
self::remove_default_form_options( $options );
|
904 |
$options = serialize( $options );
|
905 |
return self::cdata( $options );
|
906 |
}
|
907 |
|
908 |
+
/**
|
909 |
+
* If the saved value is the same as the default, remove it from the export
|
910 |
+
* This keeps file size down and prevents overriding global settings after import
|
911 |
+
*
|
912 |
+
* @since 3.06
|
913 |
+
*/
|
914 |
+
private static function remove_default_form_options( &$options ) {
|
915 |
+
$defaults = FrmFormsHelper::get_default_opts();
|
916 |
+
if ( is_callable( 'FrmProFormsHelper::get_default_opts' ) ) {
|
917 |
+
$defaults += FrmProFormsHelper::get_default_opts();
|
918 |
+
}
|
919 |
+
self::remove_defaults( $defaults, $options );
|
920 |
+
}
|
921 |
+
|
922 |
+
/**
|
923 |
+
* Remove extra settings from field to keep file size down
|
924 |
+
*
|
925 |
+
* @since 3.06
|
926 |
+
*/
|
927 |
+
public static function prepare_field_for_export( &$field ) {
|
928 |
+
self::remove_default_field_options( $field );
|
929 |
+
}
|
930 |
+
|
931 |
+
/**
|
932 |
+
* Remove defaults from field options too
|
933 |
+
*
|
934 |
+
* @since 3.06
|
935 |
+
*/
|
936 |
+
private static function remove_default_field_options( &$field ) {
|
937 |
+
$defaults = FrmFieldsHelper::get_default_field_options( $field->type );
|
938 |
+
if ( empty( $defaults['blank'] ) ) {
|
939 |
+
$global_settings = new FrmSettings();
|
940 |
+
$global_defaults = $global_settings->default_options();
|
941 |
+
$defaults['blank'] = $global_defaults['blank_msg'];
|
942 |
+
}
|
943 |
+
|
944 |
+
if ( empty( $defaults['custom_html'] ) ) {
|
945 |
+
$defaults['custom_html'] = FrmFieldsHelper::get_default_html( $field->type );
|
946 |
+
}
|
947 |
+
$options = maybe_unserialize( $field->field_options );
|
948 |
+
self::remove_defaults( $defaults, $options );
|
949 |
+
self::remove_default_html( 'custom_html', $defaults, $options );
|
950 |
+
|
951 |
+
// Get variations on the defaults.
|
952 |
+
if ( isset( $options['invalid'] ) ) {
|
953 |
+
$defaults = array(
|
954 |
+
'invalid' => sprintf( __( '%s is invalid', 'formidable' ), $field->name ),
|
955 |
+
);
|
956 |
+
self::remove_defaults( $defaults, $options );
|
957 |
+
}
|
958 |
+
|
959 |
+
$field->field_options = serialize( $options );
|
960 |
+
}
|
961 |
+
|
962 |
+
/**
|
963 |
+
* Compare the default array to the saved values and
|
964 |
+
* remove if they are the same
|
965 |
+
*
|
966 |
+
* @since 3.06
|
967 |
+
*/
|
968 |
+
private static function remove_defaults( $defaults, &$saved ) {
|
969 |
+
$array_defaults = array_filter( $defaults, 'is_array' );
|
970 |
+
foreach ( $array_defaults as $d => $default ) {
|
971 |
+
// compare array defaults
|
972 |
+
if ( $default == $saved[ $d ] ) {
|
973 |
+
unset( $saved[ $d ] );
|
974 |
+
}
|
975 |
+
unset( $defaults[ $d ] );
|
976 |
+
}
|
977 |
+
$saved = array_diff_assoc( (array) $saved, $defaults );
|
978 |
+
}
|
979 |
+
|
980 |
+
/**
|
981 |
+
* The line endings may prevent html from being equal when it should
|
982 |
+
*
|
983 |
+
* @since 3.06
|
984 |
+
*/
|
985 |
+
private static function remove_default_html( $html_name, $defaults, &$options ) {
|
986 |
+
if ( ! isset( $options[ $html_name ] ) || ! isset( $defaults[ $html_name ] ) ) {
|
987 |
+
return;
|
988 |
+
}
|
989 |
+
|
990 |
+
$old_html = str_replace( "\r\n", "\n", $options[ $html_name ] );
|
991 |
+
$default_html = $defaults[ $html_name ];
|
992 |
+
if ( $old_html == $default_html ) {
|
993 |
+
unset( $options[ $html_name ] );
|
994 |
+
return;
|
995 |
+
}
|
996 |
+
|
997 |
+
// Account for some of the older field default HTML.
|
998 |
+
$default_html = str_replace( ' id="frm_desc_field_[key]"', '', $default_html );
|
999 |
+
if ( $old_html == $default_html ) {
|
1000 |
+
unset( $options[ $html_name ] );
|
1001 |
+
}
|
1002 |
+
}
|
1003 |
+
|
1004 |
public static function cdata( $str ) {
|
1005 |
$str = maybe_unserialize( $str );
|
1006 |
if ( is_array( $str ) ) {
|
classes/models/FrmAddon.php
CHANGED
@@ -104,7 +104,8 @@ class FrmAddon {
|
|
104 |
),
|
105 |
);
|
106 |
} else {
|
107 |
-
$
|
|
|
108 |
$_data = $plugins[ $item_id ];
|
109 |
}
|
110 |
|
@@ -143,8 +144,9 @@ class FrmAddon {
|
|
143 |
return false;
|
144 |
}
|
145 |
|
146 |
-
$
|
147 |
-
$
|
|
|
148 |
if ( empty( $license ) ) {
|
149 |
return false;
|
150 |
}
|
@@ -236,7 +238,9 @@ class FrmAddon {
|
|
236 |
*/
|
237 |
protected function delete_cache() {
|
238 |
delete_transient( 'frm_api_licence' );
|
239 |
-
|
|
|
|
|
240 |
}
|
241 |
|
242 |
/**
|
@@ -260,7 +264,8 @@ class FrmAddon {
|
|
260 |
/* translators: %1$s: Plugin name, %2$s: Start link HTML, %3$s: end link HTML */
|
261 |
$message = sprintf( esc_html__( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), esc_html( $this->plugin_name ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
|
262 |
} else {
|
263 |
-
$
|
|
|
264 |
if ( ! empty( $errors ) ) {
|
265 |
$message = reset( $errors );
|
266 |
}
|
@@ -338,8 +343,8 @@ class FrmAddon {
|
|
338 |
* @since 3.04.03
|
339 |
*/
|
340 |
protected function get_api_info( $license ) {
|
341 |
-
$
|
342 |
-
$addon =
|
343 |
|
344 |
// if there is no download url, this license does not apply to the addon
|
345 |
if ( isset( $addon['package'] ) ) {
|
@@ -363,7 +368,8 @@ class FrmAddon {
|
|
363 |
$timeout = ( isset( $version_info->timeout ) && ! empty( $version_info->timeout ) ) ? $version_info->timeout : 0;
|
364 |
if ( ! empty( $timeout ) && time() > $timeout ) {
|
365 |
$version_info = false; // Cache is expired
|
366 |
-
|
|
|
367 |
}
|
368 |
}
|
369 |
|
104 |
),
|
105 |
);
|
106 |
} else {
|
107 |
+
$api = new FrmFormApi( $this->license );
|
108 |
+
$plugins = $api->get_api_info();
|
109 |
$_data = $plugins[ $item_id ];
|
110 |
}
|
111 |
|
144 |
return false;
|
145 |
}
|
146 |
|
147 |
+
$api = new FrmFormApi();
|
148 |
+
$api->get_pro_updater();
|
149 |
+
$license = $api->get_license();
|
150 |
if ( empty( $license ) ) {
|
151 |
return false;
|
152 |
}
|
238 |
*/
|
239 |
protected function delete_cache() {
|
240 |
delete_transient( 'frm_api_licence' );
|
241 |
+
|
242 |
+
$api = new FrmFormApi( $this->license );
|
243 |
+
$api->reset_cached();
|
244 |
}
|
245 |
|
246 |
/**
|
264 |
/* translators: %1$s: Plugin name, %2$s: Start link HTML, %3$s: end link HTML */
|
265 |
$message = sprintf( esc_html__( 'Your %1$s license key is missing. Please add it on the %2$slicenses page%3$s.', 'formidable' ), esc_html( $this->plugin_name ), '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=licenses_settings' ) ) . '">', '</a>' );
|
266 |
} else {
|
267 |
+
$api = new FrmFormApi( $this->license );
|
268 |
+
$errors = $api->error_for_license();
|
269 |
if ( ! empty( $errors ) ) {
|
270 |
$message = reset( $errors );
|
271 |
}
|
343 |
* @since 3.04.03
|
344 |
*/
|
345 |
protected function get_api_info( $license ) {
|
346 |
+
$api = new FrmFormApi( $license );
|
347 |
+
$addon = $api->get_addon_for_license( $this );
|
348 |
|
349 |
// if there is no download url, this license does not apply to the addon
|
350 |
if ( isset( $addon['package'] ) ) {
|
368 |
$timeout = ( isset( $version_info->timeout ) && ! empty( $version_info->timeout ) ) ? $version_info->timeout : 0;
|
369 |
if ( ! empty( $timeout ) && time() > $timeout ) {
|
370 |
$version_info = false; // Cache is expired
|
371 |
+
$api = new FrmFormApi( $this->license );
|
372 |
+
$api->reset_cached();
|
373 |
}
|
374 |
}
|
375 |
|
classes/models/FrmEntry.php
CHANGED
@@ -899,12 +899,12 @@ class FrmEntry {
|
|
899 |
return $updated;
|
900 |
}
|
901 |
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
public static function get_id_by_key( $key ) {
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
}
|
899 |
return $updated;
|
900 |
}
|
901 |
|
902 |
+
/**
|
903 |
+
* @param string $key
|
904 |
+
* @return int entry_id
|
905 |
+
*/
|
906 |
public static function get_id_by_key( $key ) {
|
907 |
+
$entry_id = FrmDb::get_var( 'frm_items', array( 'item_key' => sanitize_title( $key ) ) );
|
908 |
+
return (int) $entry_id;
|
909 |
+
}
|
910 |
}
|
classes/models/FrmField.php
CHANGED
@@ -868,14 +868,14 @@ class FrmField {
|
|
868 |
return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
|
869 |
}
|
870 |
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
public static function get_id_by_key( $key ) {
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
|
880 |
/**
|
881 |
* @param string $id
|
868 |
return ( $is_repeating_field && self::is_option_true( $field, 'repeat' ) );
|
869 |
}
|
870 |
|
871 |
+
/**
|
872 |
+
* @param string $key
|
873 |
+
* @return int field id
|
874 |
+
*/
|
875 |
public static function get_id_by_key( $key ) {
|
876 |
+
$id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
|
877 |
+
return (int) $id;
|
878 |
+
}
|
879 |
|
880 |
/**
|
881 |
* @param string $id
|
classes/models/FrmForm.php
CHANGED
@@ -20,7 +20,6 @@ class FrmForm {
|
|
20 |
'is_template' => isset( $values['is_template'] ) ? (int) $values['is_template'] : 0,
|
21 |
'parent_form_id' => isset( $values['parent_form_id'] ) ? absint( $values['parent_form_id'] ) : 0,
|
22 |
'editable' => isset( $values['editable'] ) ? (int) $values['editable'] : 0,
|
23 |
-
'default_template' => isset( $values['default_template'] ) ? (int) $values['default_template'] : 0,
|
24 |
'created_at' => isset( $values['created_at'] ) ? $values['created_at'] : current_time( 'mysql', 1 ),
|
25 |
);
|
26 |
|