@@ -1,91 +1,91 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class FrmHooksController { |
| 4 | - /** |
|
| 5 | - * Trigger plugin-wide hook loading |
|
| 6 | - */ |
|
| 7 | - public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | - $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | - |
|
| 10 | - $trigger_hooks = $hooks; |
|
| 11 | - $hooks = (array) $hooks; |
|
| 12 | - |
|
| 13 | - if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | - if ( is_admin() ) { |
|
| 15 | - $hooks[] = 'load_admin_hooks'; |
|
| 16 | - if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | - $hooks[] = 'load_ajax_hooks'; |
|
| 18 | - $hooks[] = 'load_form_hooks'; |
|
| 19 | - } |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - if ( is_multisite() ) { |
|
| 23 | - $hooks[] = 'load_multisite_hooks'; |
|
| 24 | - } |
|
| 25 | - } else { |
|
| 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 | - foreach ( $hooks as $hook ) { |
|
| 4 | + /** |
|
| 5 | + * Trigger plugin-wide hook loading |
|
| 6 | + */ |
|
| 7 | + public static function trigger_load_hook( $hooks = 'load_hooks' ) { |
|
| 8 | + $controllers = apply_filters( 'frm_load_controllers', array( 'FrmHooksController' ) ); |
|
| 9 | + |
|
| 10 | + $trigger_hooks = $hooks; |
|
| 11 | + $hooks = (array) $hooks; |
|
| 12 | + |
|
| 13 | + if ( 'load_hooks' == $trigger_hooks ) { |
|
| 14 | + if ( is_admin() ) { |
|
| 15 | + $hooks[] = 'load_admin_hooks'; |
|
| 16 | + if ( defined( 'DOING_AJAX' ) ) { |
|
| 17 | + $hooks[] = 'load_ajax_hooks'; |
|
| 18 | + $hooks[] = 'load_form_hooks'; |
|
| 19 | + } |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + if ( is_multisite() ) { |
|
| 23 | + $hooks[] = 'load_multisite_hooks'; |
|
| 24 | + } |
|
| 25 | + } else { |
|
| 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 | + foreach ( $hooks as $hook ) { |
|
| 34 | 34 | call_user_func( array( $c, $hook ) ); |
| 35 | 35 | unset( $hook ); |
| 36 | - } |
|
| 36 | + } |
|
| 37 | 37 | unset( $c ); |
| 38 | - } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - public static function trigger_load_form_hooks() { |
|
| 43 | - self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | - } |
|
| 42 | + public static function trigger_load_form_hooks() { |
|
| 43 | + self::trigger_load_hook( 'load_form_hooks' ); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | public static function load_hooks() { |
| 47 | - if ( ! is_admin() ) { |
|
| 48 | - add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | - add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | - |
|
| 54 | - // Entries controller |
|
| 55 | - add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | - add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | - add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | - add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | - add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | - |
|
| 61 | - // Form Actions Controller |
|
| 62 | - add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 47 | + if ( ! is_admin() ) { |
|
| 48 | + add_filter( 'the_content', 'FrmAppController::page_route', 10 ); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + add_action( 'plugins_loaded', 'FrmAppController::load_lang' ); |
|
| 52 | + add_filter( 'widget_text', 'FrmAppController::widget_text_filter', 8 ); |
|
| 53 | + |
|
| 54 | + // Entries controller |
|
| 55 | + add_action( 'wp_loaded', 'FrmEntriesController::process_entry', 10, 0 ); |
|
| 56 | + add_filter( 'frm_redirect_url', 'FrmEntriesController::delete_entry_before_redirect', 50, 3 ); |
|
| 57 | + add_action( 'frm_after_entry_processed', 'FrmEntriesController::delete_entry_after_save', 100 ); |
|
| 58 | + add_filter( 'frm_email_value', 'FrmEntriesController::filter_email_value', 10, 3 ); |
|
| 59 | + add_filter( 'frmpro_fields_replace_shortcodes', 'FrmEntriesController::filter_shortcode_value', 10, 4 ); |
|
| 60 | + |
|
| 61 | + // Form Actions Controller |
|
| 62 | + add_action( 'init', 'FrmFormActionsController::register_post_types', 1 ); |
|
| 63 | 63 | add_action( 'frm_after_create_entry', 'FrmFormActionsController::trigger_create_actions', 20, 3 ); |
| 64 | 64 | |
| 65 | - // Forms Controller |
|
| 66 | - add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 65 | + // Forms Controller |
|
| 66 | + add_action( 'widgets_init', 'FrmFormsController::register_widgets' ); |
|
| 67 | 67 | add_action( 'init', 'FrmFormsController::front_head' ); |
| 68 | - add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | - add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | - add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 68 | + add_filter( 'frm_content', 'FrmFormsController::filter_content', 10, 3 ); |
|
| 69 | + add_filter( 'frm_replace_content_shortcodes', 'FrmFormsController::replace_content_shortcodes', 20, 3 ); |
|
| 70 | + add_action( 'admin_bar_init', 'FrmFormsController::admin_bar_css' ); |
|
| 71 | 71 | add_action( 'wp_footer', 'FrmFormsController::footer_js', 1, 0 ); |
| 72 | 72 | |
| 73 | 73 | add_action( 'wp_scheduled_delete', 'FrmForm::scheduled_delete' ); |
| 74 | 74 | |
| 75 | - // Form Shortcodes |
|
| 76 | - add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 75 | + // Form Shortcodes |
|
| 76 | + add_shortcode( 'formidable', 'FrmFormsController::get_form_shortcode' ); |
|
| 77 | 77 | |
| 78 | - // Styles Controller |
|
| 79 | - add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | - add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | - add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | - add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | - } |
|
| 78 | + // Styles Controller |
|
| 79 | + add_action( 'init', 'FrmStylesController::register_post_types', 0 ); |
|
| 80 | + add_filter( 'frm_get_style_opts', 'FrmStylesController::get_style_opts' ); |
|
| 81 | + add_filter( 'frm_add_form_style_class', 'FrmStylesController::get_form_style_class', 10, 2 ); |
|
| 82 | + add_filter( 'frm_show_entry_styles', 'FrmStylesController::show_entry_styles' ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | 85 | public static function load_admin_hooks() { |
| 86 | - add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | - add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | - add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 86 | + add_action( 'admin_menu', 'FrmAppController::menu', 1 ); |
|
| 87 | + add_action( 'admin_enqueue_scripts', 'FrmAppController::load_wp_admin_style' ); |
|
| 88 | + add_action( 'admin_notices', 'FrmAppController::pro_get_started_headline' ); |
|
| 89 | 89 | add_action( 'admin_init', 'FrmAppController::admin_init', 11 ); |
| 90 | 90 | add_filter( 'admin_body_class', 'FrmAppController::wp_admin_body_class' ); |
| 91 | 91 | add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' ); |
@@ -94,122 +94,122 @@ discard block |
||
| 94 | 94 | // Addons Controller |
| 95 | 95 | add_action( 'admin_menu', 'FrmAddonsController::menu', 100 ); |
| 96 | 96 | |
| 97 | - // Entries Controller |
|
| 98 | - add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | - add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | - add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | - add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | - add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 97 | + // Entries Controller |
|
| 98 | + add_action( 'admin_menu', 'FrmEntriesController::menu', 12 ); |
|
| 99 | + add_filter( 'contextual_help', 'FrmEntriesController::contextual_help', 10, 3 ); |
|
| 100 | + add_filter( 'set-screen-option', 'FrmEntriesController::save_per_page', 10, 3 ); |
|
| 101 | + add_filter( 'update_user_metadata', 'FrmEntriesController::check_hidden_cols', 10, 5 ); |
|
| 102 | + add_action( 'updated_user_meta', 'FrmEntriesController::update_hidden_cols', 10, 4 ); |
|
| 103 | 103 | |
| 104 | - // Fields Controller |
|
| 105 | - add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 104 | + // Fields Controller |
|
| 105 | + add_filter( 'frm_display_field_options', 'FrmFieldsController::display_field_options' ); |
|
| 106 | 106 | |
| 107 | - // Form Actions Controller |
|
| 108 | - if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | - add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | - } |
|
| 111 | - add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 107 | + // Form Actions Controller |
|
| 108 | + if ( FrmAppHelper::is_admin_page( 'formidable' ) ) { |
|
| 109 | + add_action( 'frm_before_update_form_settings', 'FrmFormActionsController::update_settings' ); |
|
| 110 | + } |
|
| 111 | + add_action( 'frm_after_duplicate_form', 'FrmFormActionsController::duplicate_form_actions', 20, 3 ); |
|
| 112 | 112 | |
| 113 | - // Forms Controller |
|
| 114 | - add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | - add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 113 | + // Forms Controller |
|
| 114 | + add_action( 'admin_menu', 'FrmFormsController::menu', 10 ); |
|
| 115 | + add_action( 'admin_head-toplevel_page_formidable', 'FrmFormsController::head' ); |
|
| 116 | 116 | |
| 117 | - add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | - add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 117 | + add_filter( 'set-screen-option', 'FrmFormsController::save_per_page', 10, 3 ); |
|
| 118 | + add_action( 'admin_footer', 'FrmFormsController::insert_form_popup' ); |
|
| 119 | 119 | add_action( 'media_buttons', 'FrmFormsController::insert_form_button' ); |
| 120 | 120 | |
| 121 | - // Forms Model |
|
| 122 | - add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 121 | + // Forms Model |
|
| 122 | + add_action( 'frm_after_duplicate_form', 'FrmForm::after_duplicate', 10, 2 ); |
|
| 123 | 123 | |
| 124 | - // Settings Controller |
|
| 125 | - add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | - add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 124 | + // Settings Controller |
|
| 125 | + add_action( 'admin_menu', 'FrmSettingsController::menu', 45 ); |
|
| 126 | + add_action( 'frm_before_settings', 'FrmSettingsController::license_box' ); |
|
| 127 | 127 | |
| 128 | - // Styles Controller |
|
| 129 | - add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | - add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 128 | + // Styles Controller |
|
| 129 | + add_action( 'admin_menu', 'FrmStylesController::menu', 14 ); |
|
| 130 | + add_action( 'admin_init', 'FrmStylesController::admin_init' ); |
|
| 131 | 131 | |
| 132 | - // XML Controller |
|
| 133 | - add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | - } |
|
| 132 | + // XML Controller |
|
| 133 | + add_action( 'admin_menu', 'FrmXMLController::menu', 41 ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | public static function load_ajax_hooks() { |
| 137 | 137 | add_action( 'wp_ajax_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 138 | 138 | add_action( 'wp_ajax_nopriv_frm_silent_upgrade', 'FrmAppController::ajax_install' ); |
| 139 | 139 | add_action( 'wp_ajax_frm_install', 'FrmAppController::ajax_install' ); |
| 140 | - add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | - add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 140 | + add_action( 'wp_ajax_frm_uninstall', 'FrmAppController::uninstall' ); |
|
| 141 | + add_action( 'wp_ajax_frm_deauthorize', 'FrmAppController::deauthorize' ); |
|
| 142 | 142 | |
| 143 | 143 | // Addons Controller |
| 144 | 144 | add_action('wp_ajax_frm_addon_activate', 'FrmAddon::activate' ); |
| 145 | 145 | add_action('wp_ajax_frm_addon_deactivate', 'FrmAddon::deactivate' ); |
| 146 | 146 | |
| 147 | - // Fields Controller |
|
| 148 | - add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | - add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | - add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
| 151 | - add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | - add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | - add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | - add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | - add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | - add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | - add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | - add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | - add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | - add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | - |
|
| 162 | - // Form Actions Controller |
|
| 163 | - add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | - add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | - |
|
| 166 | - // Forms Controller |
|
| 147 | + // Fields Controller |
|
| 148 | + add_action( 'wp_ajax_frm_load_field', 'FrmFieldsController::load_field' ); |
|
| 149 | + add_action( 'wp_ajax_frm_insert_field', 'FrmFieldsController::create' ); |
|
| 150 | + add_action( 'wp_ajax_frm_update_field_form_id', 'FrmFieldsController::update_form_id' ); |
|
| 151 | + add_action( 'wp_ajax_frm_field_name_in_place_edit', 'FrmFieldsController::edit_name' ); |
|
| 152 | + add_action( 'wp_ajax_frm_update_ajax_option', 'FrmFieldsController::update_ajax_option' ); |
|
| 153 | + add_action( 'wp_ajax_frm_duplicate_field', 'FrmFieldsController::duplicate' ); |
|
| 154 | + add_action( 'wp_ajax_frm_delete_field', 'FrmFieldsController::destroy' ); |
|
| 155 | + add_action( 'wp_ajax_frm_add_field_option', 'FrmFieldsController::add_option' ); |
|
| 156 | + add_action( 'wp_ajax_frm_field_option_ipe', 'FrmFieldsController::edit_option' ); |
|
| 157 | + add_action( 'wp_ajax_frm_delete_field_option', 'FrmFieldsController::delete_option' ); |
|
| 158 | + add_action( 'wp_ajax_frm_import_choices', 'FrmFieldsController::import_choices' ); |
|
| 159 | + add_action( 'wp_ajax_frm_import_options', 'FrmFieldsController::import_options' ); |
|
| 160 | + add_action( 'wp_ajax_frm_update_field_order', 'FrmFieldsController::update_order' ); |
|
| 161 | + |
|
| 162 | + // Form Actions Controller |
|
| 163 | + add_action( 'wp_ajax_frm_add_form_action', 'FrmFormActionsController::add_form_action' ); |
|
| 164 | + add_action( 'wp_ajax_frm_form_action_fill', 'FrmFormActionsController::fill_action' ); |
|
| 165 | + |
|
| 166 | + // Forms Controller |
|
| 167 | 167 | add_action( 'wp_ajax_frm_create_from_template', 'FrmFormsController::_create_from_template' ); |
| 168 | 168 | add_action( 'wp_ajax_frm_save_form', 'FrmFormsController::route' ); |
| 169 | 169 | add_action( 'wp_ajax_frm_form_key_in_place_edit', 'FrmFormsController::edit_key' ); |
| 170 | 170 | add_action( 'wp_ajax_frm_form_desc_in_place_edit', 'FrmFormsController::edit_description' ); |
| 171 | - add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | - add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | - add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | - add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | - |
|
| 176 | - // Styles Controller |
|
| 177 | - add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | - add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | - add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | - add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 171 | + add_action( 'wp_ajax_frm_get_default_html', 'FrmFormsController::get_email_html' ); |
|
| 172 | + add_action( 'wp_ajax_frm_get_shortcode_opts', 'FrmFormsController::get_shortcode_opts' ); |
|
| 173 | + add_action( 'wp_ajax_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 174 | + add_action( 'wp_ajax_nopriv_frm_forms_preview', 'FrmFormsController::preview' ); |
|
| 175 | + |
|
| 176 | + // Styles Controller |
|
| 177 | + add_action( 'wp_ajax_frm_settings_reset', 'FrmStylesController::reset_styling' ); |
|
| 178 | + add_action( 'wp_ajax_frm_change_styling', 'FrmStylesController::change_styling' ); |
|
| 179 | + add_action( 'wp_ajax_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 180 | + add_action( 'wp_ajax_nopriv_frmpro_load_css', 'FrmStylesController::load_css' ); |
|
| 181 | 181 | add_action( 'wp_ajax_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 182 | 182 | add_action( 'wp_ajax_nopriv_frmpro_css', 'FrmStylesController::load_saved_css' ); |
| 183 | 183 | |
| 184 | - // XML Controller |
|
| 184 | + // XML Controller |
|
| 185 | 185 | add_action( 'wp_ajax_frm_entries_csv', 'FrmXMLController::csv' ); |
| 186 | 186 | add_action( 'wp_ajax_nopriv_frm_entries_csv', 'FrmXMLController::csv' ); |
| 187 | - add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | - } |
|
| 187 | + add_action( 'wp_ajax_frm_export_xml', 'FrmXMLController::export_xml' ); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | public static function load_form_hooks() { |
| 191 | - // Fields Controller |
|
| 192 | - add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | - add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | - add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | - add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 191 | + // Fields Controller |
|
| 192 | + add_filter( 'frm_field_type', 'FrmFieldsController::change_type' ); |
|
| 193 | + add_action( 'frm_field_input_html', 'FrmFieldsController::input_html' ); |
|
| 194 | + add_filter( 'frm_field_value_saved', 'FrmFieldsController::check_value', 50, 3 ); |
|
| 195 | + add_filter( 'frm_field_label_seen', 'FrmFieldsController::check_label' ); |
|
| 196 | 196 | |
| 197 | 197 | // Forms Controller |
| 198 | 198 | add_filter( 'frm_form_classes', 'FrmFormsController::form_classes' ); |
| 199 | 199 | |
| 200 | - // Styles Controller |
|
| 201 | - add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | - } |
|
| 200 | + // Styles Controller |
|
| 201 | + add_filter( 'frm_use_important_width', 'FrmStylesController::important_style', 10, 2 ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | 204 | public static function load_view_hooks() { |
| 205 | - // Hooks go here when a view is loaded |
|
| 206 | - } |
|
| 205 | + // Hooks go here when a view is loaded |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | 208 | public static function load_multisite_hooks() { |
| 209 | 209 | add_action( 'init', 'FrmAppController::front_head' ); |
| 210 | 210 | add_action( 'wpmu_upgrade_site', 'FrmAppController::network_upgrade_site' ); |
| 211 | 211 | |
| 212 | - // drop tables when mu site is deleted |
|
| 213 | - add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 214 | - } |
|
| 212 | + // drop tables when mu site is deleted |
|
| 213 | + add_filter( 'wpmu_drop_tables', 'FrmAppController::drop_tables' ); |
|
| 214 | + } |
|
| 215 | 215 | } |
@@ -2,110 +2,110 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class FrmXMLController { |
| 4 | 4 | |
| 5 | - public static function menu() { |
|
| 6 | - add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route'); |
|
| 7 | - } |
|
| 5 | + public static function menu() { |
|
| 6 | + add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route'); |
|
| 7 | + } |
|
| 8 | 8 | |
| 9 | - public static function add_default_templates() { |
|
| 9 | + public static function add_default_templates() { |
|
| 10 | 10 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 11 | - // XML import is not enabled on your server |
|
| 12 | - return; |
|
| 13 | - } |
|
| 11 | + // XML import is not enabled on your server |
|
| 12 | + return; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 16 | - $loader = libxml_disable_entity_loader( true ); |
|
| 15 | + $set_err = libxml_use_internal_errors(true); |
|
| 16 | + $loader = libxml_disable_entity_loader( true ); |
|
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | - foreach ( (array) $files as $file ) { |
|
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 23 | - } |
|
| 24 | - /* |
|
| 20 | + foreach ( (array) $files as $file ) { |
|
| 21 | + FrmXMLHelper::import_xml($file); |
|
| 22 | + unset($file); |
|
| 23 | + } |
|
| 24 | + /* |
|
| 25 | 25 | if(is_wp_error($result)) |
| 26 | 26 | $errors[] = $result->get_error_message(); |
| 27 | 27 | else if($result) |
| 28 | 28 | $message = $result; |
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | - unset( $files ); |
|
| 31 | + unset( $files ); |
|
| 32 | 32 | |
| 33 | - libxml_use_internal_errors( $set_err ); |
|
| 34 | - libxml_disable_entity_loader( $loader ); |
|
| 35 | - } |
|
| 33 | + libxml_use_internal_errors( $set_err ); |
|
| 34 | + libxml_disable_entity_loader( $loader ); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public static function route() { |
|
| 38 | - $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 37 | + public static function route() { |
|
| 38 | + $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action'; |
|
| 39 | 39 | $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' ); |
| 40 | 40 | if ( $action == 'import_xml' ) { |
| 41 | - return self::import_xml(); |
|
| 41 | + return self::import_xml(); |
|
| 42 | 42 | } else if ( $action == 'export_xml' ) { |
| 43 | - return self::export_xml(); |
|
| 44 | - } else { |
|
| 45 | - if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | - return self::form(); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public static function form( $errors = array(), $message = '' ) { |
|
| 43 | + return self::export_xml(); |
|
| 44 | + } else { |
|
| 45 | + if ( apply_filters( 'frm_xml_route', true, $action ) ) { |
|
| 46 | + return self::form(); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public static function form( $errors = array(), $message = '' ) { |
|
| 52 | 52 | $where = array( |
| 53 | 53 | 'parent_form_id' => array( null, 0 ), |
| 54 | 54 | 'status' => array( null, '', 'published' ) |
| 55 | 55 | ); |
| 56 | 56 | $forms = FrmForm::getAll( $where, 'name' ); |
| 57 | 57 | |
| 58 | - $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | - array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | - ); |
|
| 58 | + $export_types = apply_filters( 'frm_xml_export_types', |
|
| 59 | + array( 'forms' => __( 'Forms', 'formidable' ), 'items' => __( 'Entries', 'formidable' ) ) |
|
| 60 | + ); |
|
| 61 | 61 | |
| 62 | - $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | - 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 62 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 63 | + 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
|
| 64 | 64 | 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single'), |
| 65 | - ) ); |
|
| 65 | + ) ); |
|
| 66 | 66 | |
| 67 | - include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php'); |
|
| 68 | - } |
|
| 67 | + include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php'); |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - public static function import_xml() { |
|
| 71 | - $errors = array(); |
|
| 72 | - $message = ''; |
|
| 70 | + public static function import_xml() { |
|
| 71 | + $errors = array(); |
|
| 72 | + $message = ''; |
|
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | - if ( $permission_error !== false ) { |
|
| 76 | - $errors[] = $permission_error; |
|
| 77 | - self::form($errors); |
|
| 78 | - return; |
|
| 79 | - } |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 75 | + if ( $permission_error !== false ) { |
|
| 76 | + $errors[] = $permission_error; |
|
| 77 | + self::form($errors); |
|
| 78 | + return; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | - $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | - self::form($errors); |
|
| 84 | - return; |
|
| 85 | - } |
|
| 81 | + if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | + $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
|
| 83 | + self::form($errors); |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 87 | + $file = $_FILES['frm_import_file']['tmp_name']; |
|
| 88 | 88 | |
| 89 | - if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | - unset($file); |
|
| 91 | - $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | - self::form($errors); |
|
| 93 | - return; |
|
| 94 | - } |
|
| 89 | + if ( ! is_uploaded_file( $file ) ) { |
|
| 90 | + unset($file); |
|
| 91 | + $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
|
| 92 | + self::form($errors); |
|
| 93 | + return; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 96 | + //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
|
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters('frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | - // allow other file types to be imported |
|
| 105 | - do_action('frm_before_import_'. $file_type ); |
|
| 106 | - return; |
|
| 107 | - } |
|
| 108 | - unset($file_type); |
|
| 102 | + $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 104 | + // allow other file types to be imported |
|
| 105 | + do_action('frm_before_import_'. $file_type ); |
|
| 106 | + return; |
|
| 107 | + } |
|
| 108 | + unset($file_type); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,148 +124,148 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 128 | - } |
|
| 127 | + self::form($errors, $message); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - public static function export_xml() { |
|
| 131 | - $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | - if ( ! empty($error) ) { |
|
| 133 | - wp_die( $error ); |
|
| 134 | - } |
|
| 130 | + public static function export_xml() { |
|
| 131 | + $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
|
| 132 | + if ( ! empty($error) ) { |
|
| 133 | + wp_die( $error ); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | 136 | $ids = FrmAppHelper::get_post_param( 'frm_export_forms', array() ); |
| 137 | 137 | $type = FrmAppHelper::get_post_param( 'type', array() ); |
| 138 | 138 | $format = FrmAppHelper::get_post_param( 'format', 'xml', 'sanitize_title' ); |
| 139 | 139 | |
| 140 | - if ( ! headers_sent() && ! $type ) { |
|
| 141 | - wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | - die(); |
|
| 143 | - } |
|
| 140 | + if ( ! headers_sent() && ! $type ) { |
|
| 141 | + wp_redirect( esc_url_raw( admin_url( 'admin.php?page=formidable-import' ) ) ); |
|
| 142 | + die(); |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - if ( $format == 'xml' ) { |
|
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 145 | + if ( $format == 'xml' ) { |
|
| 146 | + self::generate_xml($type, compact('ids')); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | 148 | self::generate_csv( compact('ids') ); |
| 149 | - } else { |
|
| 150 | - do_action('frm_export_format_'. $format, compact('ids')); |
|
| 151 | - } |
|
| 149 | + } else { |
|
| 150 | + do_action('frm_export_format_'. $format, compact('ids')); |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - wp_die(); |
|
| 154 | - } |
|
| 153 | + wp_die(); |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | 156 | public static function generate_xml( $type, $args = array() ) { |
| 157 | - global $wpdb; |
|
| 158 | - |
|
| 159 | - $type = (array) $type; |
|
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | - // make sure the form is included if there are entries |
|
| 162 | - $type[] = 'forms'; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 166 | - // include actions with forms |
|
| 167 | - $type[] = 'actions'; |
|
| 168 | - } |
|
| 169 | - |
|
| 170 | - $tables = array( |
|
| 171 | - 'items' => $wpdb->prefix .'frm_items', |
|
| 172 | - 'forms' => $wpdb->prefix .'frm_forms', |
|
| 173 | - 'posts' => $wpdb->posts, |
|
| 174 | - 'styles' => $wpdb->posts, |
|
| 175 | - 'actions' => $wpdb->posts, |
|
| 176 | - ); |
|
| 157 | + global $wpdb; |
|
| 158 | + |
|
| 159 | + $type = (array) $type; |
|
| 160 | + if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 161 | + // make sure the form is included if there are entries |
|
| 162 | + $type[] = 'forms'; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ( in_array( 'forms', $type) ) { |
|
| 166 | + // include actions with forms |
|
| 167 | + $type[] = 'actions'; |
|
| 168 | + } |
|
| 169 | + |
|
| 170 | + $tables = array( |
|
| 171 | + 'items' => $wpdb->prefix .'frm_items', |
|
| 172 | + 'forms' => $wpdb->prefix .'frm_forms', |
|
| 173 | + 'posts' => $wpdb->posts, |
|
| 174 | + 'styles' => $wpdb->posts, |
|
| 175 | + 'actions' => $wpdb->posts, |
|
| 176 | + ); |
|
| 177 | 177 | |
| 178 | 178 | $defaults = array( 'ids' => false ); |
| 179 | - $args = wp_parse_args( $args, $defaults ); |
|
| 179 | + $args = wp_parse_args( $args, $defaults ); |
|
| 180 | 180 | |
| 181 | - $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 181 | + $sitename = sanitize_key( get_bloginfo( 'name' ) ); |
|
| 182 | 182 | |
| 183 | - if ( ! empty( $sitename ) ) { |
|
| 183 | + if ( ! empty( $sitename ) ) { |
|
| 184 | 184 | $sitename .= '.'; |
| 185 | 185 | } |
| 186 | - $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 186 | + $filename = $sitename . 'formidable.' . date( 'Y-m-d' ) . '.xml'; |
|
| 187 | 187 | |
| 188 | - header( 'Content-Description: File Transfer' ); |
|
| 189 | - header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | - header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 188 | + header( 'Content-Description: File Transfer' ); |
|
| 189 | + header( 'Content-Disposition: attachment; filename=' . $filename ); |
|
| 190 | + header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), true ); |
|
| 191 | 191 | |
| 192 | - //make sure ids are numeric |
|
| 193 | - if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | - $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | - } |
|
| 192 | + //make sure ids are numeric |
|
| 193 | + if ( is_array( $args['ids'] ) && ! empty( $args['ids'] ) ) { |
|
| 194 | + $args['ids'] = array_filter( $args['ids'], 'is_numeric' ); |
|
| 195 | + } |
|
| 196 | 196 | |
| 197 | - $records = array(); |
|
| 197 | + $records = array(); |
|
| 198 | 198 | |
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | - $where = array(); |
|
| 200 | + $where = array(); |
|
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[ $tb_type ]; |
|
| 203 | 203 | |
| 204 | - $select = $table .'.id'; |
|
| 205 | - $query_vars = array(); |
|
| 204 | + $select = $table .'.id'; |
|
| 205 | + $query_vars = array(); |
|
| 206 | 206 | |
| 207 | - switch ( $tb_type ) { |
|
| 208 | - case 'forms': |
|
| 209 | - //add forms |
|
| 210 | - if ( $args['ids'] ) { |
|
| 207 | + switch ( $tb_type ) { |
|
| 208 | + case 'forms': |
|
| 209 | + //add forms |
|
| 210 | + if ( $args['ids'] ) { |
|
| 211 | 211 | $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table .'.parent_form_id' => $args['ids'] ); |
| 212 | - } else { |
|
| 212 | + } else { |
|
| 213 | 213 | $where[ $table . '.status !' ] = 'draft'; |
| 214 | - } |
|
| 215 | - break; |
|
| 216 | - case 'actions': |
|
| 217 | - $select = $table .'.ID'; |
|
| 214 | + } |
|
| 215 | + break; |
|
| 216 | + case 'actions': |
|
| 217 | + $select = $table .'.ID'; |
|
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty($args['ids']) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | - } |
|
| 222 | - break; |
|
| 223 | - case 'items': |
|
| 224 | - //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | - if ( $args['ids'] ) { |
|
| 221 | + } |
|
| 222 | + break; |
|
| 223 | + case 'items': |
|
| 224 | + //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
|
| 225 | + if ( $args['ids'] ) { |
|
| 226 | 226 | $where[ $table . '.form_id' ] = $args['ids']; |
| 227 | - } |
|
| 228 | - break; |
|
| 229 | - case 'styles': |
|
| 230 | - // Loop through all exported forms and get their selected style IDs |
|
| 231 | - $form_ids = $args['ids']; |
|
| 232 | - $style_ids = array(); |
|
| 233 | - foreach ( $form_ids as $form_id ) { |
|
| 234 | - $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | - // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | - if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | - $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | - } |
|
| 239 | - unset( $form_id, $form_data ); |
|
| 240 | - } |
|
| 241 | - $select = $table .'.ID'; |
|
| 242 | - $where['post_type'] = 'frm_styles'; |
|
| 243 | - |
|
| 244 | - // Only export selected styles |
|
| 245 | - if ( ! empty( $style_ids ) ) { |
|
| 246 | - $where['ID'] = $style_ids; |
|
| 247 | - } |
|
| 248 | - break; |
|
| 249 | - default: |
|
| 250 | - $select = $table .'.ID'; |
|
| 251 | - $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | - $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | - |
|
| 254 | - if ( empty($args['ids']) ) { |
|
| 255 | - $where['pm.meta_value >'] = 1; |
|
| 256 | - } else { |
|
| 257 | - $where['pm.meta_value'] = $args['ids']; |
|
| 258 | - } |
|
| 259 | - break; |
|
| 260 | - } |
|
| 227 | + } |
|
| 228 | + break; |
|
| 229 | + case 'styles': |
|
| 230 | + // Loop through all exported forms and get their selected style IDs |
|
| 231 | + $form_ids = $args['ids']; |
|
| 232 | + $style_ids = array(); |
|
| 233 | + foreach ( $form_ids as $form_id ) { |
|
| 234 | + $form_data = FrmForm::getOne( $form_id ); |
|
| 235 | + // For forms that have not been updated while running 2.0, check if custom_style is set |
|
| 236 | + if ( isset( $form_data->options['custom_style'] ) ) { |
|
| 237 | + $style_ids[] = $form_data->options['custom_style']; |
|
| 238 | + } |
|
| 239 | + unset( $form_id, $form_data ); |
|
| 240 | + } |
|
| 241 | + $select = $table .'.ID'; |
|
| 242 | + $where['post_type'] = 'frm_styles'; |
|
| 243 | + |
|
| 244 | + // Only export selected styles |
|
| 245 | + if ( ! empty( $style_ids ) ) { |
|
| 246 | + $where['ID'] = $style_ids; |
|
| 247 | + } |
|
| 248 | + break; |
|
| 249 | + default: |
|
| 250 | + $select = $table .'.ID'; |
|
| 251 | + $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
|
| 252 | + $where['pm.meta_key'] = 'frm_form_id'; |
|
| 253 | + |
|
| 254 | + if ( empty($args['ids']) ) { |
|
| 255 | + $where['pm.meta_value >'] = 1; |
|
| 256 | + } else { |
|
| 257 | + $where['pm.meta_value'] = $args['ids']; |
|
| 258 | + } |
|
| 259 | + break; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | 262 | $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
| 263 | - unset($tb_type); |
|
| 264 | - } |
|
| 263 | + unset($tb_type); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | 266 | echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
| 267 | - include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php'); |
|
| 268 | - } |
|
| 267 | + include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php'); |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | 271 | public static function generate_csv( $atts ) { |
@@ -348,16 +348,16 @@ discard block |
||
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | public static function allow_mime( $mimes ) { |
| 351 | - if ( ! isset( $mimes['csv'] ) ) { |
|
| 352 | - // allow csv files |
|
| 353 | - $mimes['csv'] = 'text/csv'; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - if ( ! isset( $mimes['xml'] ) ) { |
|
| 357 | - // allow xml |
|
| 358 | - $mimes['xml'] = 'text/xml'; |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - return $mimes; |
|
| 362 | - } |
|
| 351 | + if ( ! isset( $mimes['csv'] ) ) { |
|
| 352 | + // allow csv files |
|
| 353 | + $mimes['csv'] = 'text/csv'; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + if ( ! isset( $mimes['xml'] ) ) { |
|
| 357 | + // allow xml |
|
| 358 | + $mimes['xml'] = 'text/xml'; |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + return $mimes; |
|
| 362 | + } |
|
| 363 | 363 | } |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | class FrmXMLController { |
| 4 | 4 | |
| 5 | 5 | public static function menu() { |
| 6 | - add_submenu_page('formidable', 'Formidable | '. __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route'); |
|
| 6 | + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Import/Export', 'formidable' ), __( 'Import/Export', 'formidable' ), 'frm_edit_forms', 'formidable-import', 'FrmXMLController::route' ); |
|
| 7 | 7 | } |
| 8 | 8 | |
| 9 | 9 | public static function add_default_templates() { |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | return; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - $set_err = libxml_use_internal_errors(true); |
|
| 15 | + $set_err = libxml_use_internal_errors( true ); |
|
| 16 | 16 | $loader = libxml_disable_entity_loader( true ); |
| 17 | 17 | |
| 18 | 18 | $files = apply_filters( 'frm_default_templates_files', array( FrmAppHelper::plugin_path() . '/classes/views/xml/default-templates.xml' ) ); |
| 19 | 19 | |
| 20 | 20 | foreach ( (array) $files as $file ) { |
| 21 | - FrmXMLHelper::import_xml($file); |
|
| 22 | - unset($file); |
|
| 21 | + FrmXMLHelper::import_xml( $file ); |
|
| 22 | + unset( $file ); |
|
| 23 | 23 | } |
| 24 | 24 | /* |
| 25 | 25 | if(is_wp_error($result)) |
@@ -61,51 +61,51 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $export_format = apply_filters( 'frm_export_formats', array( |
| 63 | 63 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 64 | - 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single'), |
|
| 64 | + 'csv' => array( 'name' => 'CSV', 'support' => 'items', 'count' => 'single' ), |
|
| 65 | 65 | ) ); |
| 66 | 66 | |
| 67 | - include(FrmAppHelper::plugin_path() .'/classes/views/xml/import_form.php'); |
|
| 67 | + include( FrmAppHelper::plugin_path() . '/classes/views/xml/import_form.php' ); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | public static function import_xml() { |
| 71 | 71 | $errors = array(); |
| 72 | 72 | $message = ''; |
| 73 | 73 | |
| 74 | - $permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'import-xml', 'import-xml-nonce'); |
|
| 74 | + $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'import-xml', 'import-xml-nonce' ); |
|
| 75 | 75 | if ( $permission_error !== false ) { |
| 76 | 76 | $errors[] = $permission_error; |
| 77 | - self::form($errors); |
|
| 77 | + self::form( $errors ); |
|
| 78 | 78 | return; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! isset($_FILES) || ! isset($_FILES['frm_import_file']) || empty($_FILES['frm_import_file']['name']) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 81 | + if ( ! isset( $_FILES ) || ! isset( $_FILES['frm_import_file'] ) || empty( $_FILES['frm_import_file']['name'] ) || (int) $_FILES['frm_import_file']['size'] < 1 ) { |
|
| 82 | 82 | $errors[] = __( 'Oops, you didn\'t select a file.', 'formidable' ); |
| 83 | - self::form($errors); |
|
| 83 | + self::form( $errors ); |
|
| 84 | 84 | return; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $file = $_FILES['frm_import_file']['tmp_name']; |
| 88 | 88 | |
| 89 | 89 | if ( ! is_uploaded_file( $file ) ) { |
| 90 | - unset($file); |
|
| 90 | + unset( $file ); |
|
| 91 | 91 | $errors[] = __( 'The file does not exist, please try again.', 'formidable' ); |
| 92 | - self::form($errors); |
|
| 92 | + self::form( $errors ); |
|
| 93 | 93 | return; |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //add_filter('upload_mimes', 'FrmXMLController::allow_mime'); |
| 97 | 97 | |
| 98 | - $export_format = apply_filters('frm_export_formats', array( |
|
| 98 | + $export_format = apply_filters( 'frm_export_formats', array( |
|
| 99 | 99 | 'xml' => array( 'name' => 'XML', 'support' => 'forms', 'count' => 'multiple' ), |
| 100 | 100 | ) ); |
| 101 | 101 | |
| 102 | - $file_type = strtolower(pathinfo($_FILES['frm_import_file']['name'], PATHINFO_EXTENSION)); |
|
| 103 | - if ( $file_type != 'xml' && isset( $export_format[ $file_type ] ) ) { |
|
| 102 | + $file_type = strtolower( pathinfo( $_FILES['frm_import_file']['name'], PATHINFO_EXTENSION ) ); |
|
| 103 | + if ( $file_type != 'xml' && isset( $export_format[$file_type] ) ) { |
|
| 104 | 104 | // allow other file types to be imported |
| 105 | - do_action('frm_before_import_'. $file_type ); |
|
| 105 | + do_action( 'frm_before_import_' . $file_type ); |
|
| 106 | 106 | return; |
| 107 | 107 | } |
| 108 | - unset($file_type); |
|
| 108 | + unset( $file_type ); |
|
| 109 | 109 | |
| 110 | 110 | if ( ! function_exists( 'libxml_disable_entity_loader' ) ) { |
| 111 | 111 | $errors[] = __( 'XML import is not enabled on your server.', 'formidable' ); |
@@ -124,12 +124,12 @@ discard block |
||
| 124 | 124 | libxml_use_internal_errors( $set_err ); |
| 125 | 125 | libxml_disable_entity_loader( $loader ); |
| 126 | 126 | |
| 127 | - self::form($errors, $message); |
|
| 127 | + self::form( $errors, $message ); |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | public static function export_xml() { |
| 131 | 131 | $error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'export-xml', 'export-xml-nonce' ); |
| 132 | - if ( ! empty($error) ) { |
|
| 132 | + if ( ! empty( $error ) ) { |
|
| 133 | 133 | wp_die( $error ); |
| 134 | 134 | } |
| 135 | 135 | |
@@ -143,11 +143,11 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | if ( $format == 'xml' ) { |
| 146 | - self::generate_xml($type, compact('ids')); |
|
| 146 | + self::generate_xml( $type, compact( 'ids' ) ); |
|
| 147 | 147 | } if ( $format == 'csv' ) { |
| 148 | - self::generate_csv( compact('ids') ); |
|
| 148 | + self::generate_csv( compact( 'ids' ) ); |
|
| 149 | 149 | } else { |
| 150 | - do_action('frm_export_format_'. $format, compact('ids')); |
|
| 150 | + do_action( 'frm_export_format_' . $format, compact( 'ids' ) ); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | wp_die(); |
@@ -157,19 +157,19 @@ discard block |
||
| 157 | 157 | global $wpdb; |
| 158 | 158 | |
| 159 | 159 | $type = (array) $type; |
| 160 | - if ( in_array( 'items', $type) && ! in_array( 'forms', $type) ) { |
|
| 160 | + if ( in_array( 'items', $type ) && ! in_array( 'forms', $type ) ) { |
|
| 161 | 161 | // make sure the form is included if there are entries |
| 162 | 162 | $type[] = 'forms'; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - if ( in_array( 'forms', $type) ) { |
|
| 165 | + if ( in_array( 'forms', $type ) ) { |
|
| 166 | 166 | // include actions with forms |
| 167 | 167 | $type[] = 'actions'; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | $tables = array( |
| 171 | - 'items' => $wpdb->prefix .'frm_items', |
|
| 172 | - 'forms' => $wpdb->prefix .'frm_forms', |
|
| 171 | + 'items' => $wpdb->prefix . 'frm_items', |
|
| 172 | + 'forms' => $wpdb->prefix . 'frm_forms', |
|
| 173 | 173 | 'posts' => $wpdb->posts, |
| 174 | 174 | 'styles' => $wpdb->posts, |
| 175 | 175 | 'actions' => $wpdb->posts, |
@@ -199,31 +199,31 @@ discard block |
||
| 199 | 199 | foreach ( $type as $tb_type ) { |
| 200 | 200 | $where = array(); |
| 201 | 201 | $join = ''; |
| 202 | - $table = $tables[ $tb_type ]; |
|
| 202 | + $table = $tables[$tb_type]; |
|
| 203 | 203 | |
| 204 | - $select = $table .'.id'; |
|
| 204 | + $select = $table . '.id'; |
|
| 205 | 205 | $query_vars = array(); |
| 206 | 206 | |
| 207 | 207 | switch ( $tb_type ) { |
| 208 | 208 | case 'forms': |
| 209 | 209 | //add forms |
| 210 | 210 | if ( $args['ids'] ) { |
| 211 | - $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table .'.parent_form_id' => $args['ids'] ); |
|
| 211 | + $where[] = array( 'or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids'] ); |
|
| 212 | 212 | } else { |
| 213 | - $where[ $table . '.status !' ] = 'draft'; |
|
| 213 | + $where[$table . '.status !'] = 'draft'; |
|
| 214 | 214 | } |
| 215 | 215 | break; |
| 216 | 216 | case 'actions': |
| 217 | - $select = $table .'.ID'; |
|
| 217 | + $select = $table . '.ID'; |
|
| 218 | 218 | $where['post_type'] = FrmFormActionsController::$action_post_type; |
| 219 | - if ( ! empty($args['ids']) ) { |
|
| 219 | + if ( ! empty( $args['ids'] ) ) { |
|
| 220 | 220 | $where['menu_order'] = $args['ids']; |
| 221 | 221 | } |
| 222 | 222 | break; |
| 223 | 223 | case 'items': |
| 224 | 224 | //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; |
| 225 | 225 | if ( $args['ids'] ) { |
| 226 | - $where[ $table . '.form_id' ] = $args['ids']; |
|
| 226 | + $where[$table . '.form_id'] = $args['ids']; |
|
| 227 | 227 | } |
| 228 | 228 | break; |
| 229 | 229 | case 'styles': |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | } |
| 239 | 239 | unset( $form_id, $form_data ); |
| 240 | 240 | } |
| 241 | - $select = $table .'.ID'; |
|
| 241 | + $select = $table . '.ID'; |
|
| 242 | 242 | $where['post_type'] = 'frm_styles'; |
| 243 | 243 | |
| 244 | 244 | // Only export selected styles |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | } |
| 248 | 248 | break; |
| 249 | 249 | default: |
| 250 | - $select = $table .'.ID'; |
|
| 250 | + $select = $table . '.ID'; |
|
| 251 | 251 | $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; |
| 252 | 252 | $where['pm.meta_key'] = 'frm_form_id'; |
| 253 | 253 | |
| 254 | - if ( empty($args['ids']) ) { |
|
| 254 | + if ( empty( $args['ids'] ) ) { |
|
| 255 | 255 | $where['pm.meta_value >'] = 1; |
| 256 | 256 | } else { |
| 257 | 257 | $where['pm.meta_value'] = $args['ids']; |
@@ -259,12 +259,12 @@ discard block |
||
| 259 | 259 | break; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - $records[ $tb_type ] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | - unset($tb_type); |
|
| 262 | + $records[$tb_type] = FrmDb::get_col( $table . $join, $where, $select ); |
|
| 263 | + unset( $tb_type ); |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo('charset') ) . "\" ?>\n"; |
|
| 267 | - include(FrmAppHelper::plugin_path() .'/classes/views/xml/xml.php'); |
|
| 266 | + echo '<?xml version="1.0" encoding="' . esc_attr( get_bloginfo( 'charset' ) ) . "\" ?>\n"; |
|
| 267 | + include( FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php' ); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
@@ -289,11 +289,11 @@ discard block |
||
| 289 | 289 | $fid = FrmAppHelper::get_param( 'fid', '', 'get', 'sanitize_text_field' ); |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - if ( ! ini_get('safe_mode') ) { |
|
| 293 | - set_time_limit(0); //Remove time limit to execute this function |
|
| 294 | - $mem_limit = str_replace('M', '', ini_get('memory_limit')); |
|
| 292 | + if ( ! ini_get( 'safe_mode' ) ) { |
|
| 293 | + set_time_limit( 0 ); //Remove time limit to execute this function |
|
| 294 | + $mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) ); |
|
| 295 | 295 | if ( (int) $mem_limit < 256 ) { |
| 296 | - ini_set('memory_limit', '256M'); |
|
| 296 | + ini_set( 'memory_limit', '256M' ); |
|
| 297 | 297 | } |
| 298 | 298 | } |
| 299 | 299 | |
@@ -305,12 +305,12 @@ discard block |
||
| 305 | 305 | $where = array( 'fi.type not' => FrmField::no_save_fields() ); |
| 306 | 306 | $where[] = array( 'or' => 1, 'fi.form_id' => $form->id, 'fr.parent_form_id' => $form->id ); |
| 307 | 307 | |
| 308 | - $csv_fields = apply_filters('frm_csv_field_ids', '', $form_id, array( 'form' => $form)); |
|
| 308 | + $csv_fields = apply_filters( 'frm_csv_field_ids', '', $form_id, array( 'form' => $form ) ); |
|
| 309 | 309 | if ( $csv_fields ) { |
| 310 | 310 | if ( ! is_array( $csv_fields ) ) { |
| 311 | - $csv_fields = explode(',', $csv_fields); |
|
| 311 | + $csv_fields = explode( ',', $csv_fields ); |
|
| 312 | 312 | } |
| 313 | - if ( ! empty($csv_fields) ) { |
|
| 313 | + if ( ! empty( $csv_fields ) ) { |
|
| 314 | 314 | $where['fi.id'] = $csv_fields; |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -333,9 +333,9 @@ discard block |
||
| 333 | 333 | * $query is the array of options to be filtered. It includes form_id, and maybe id (array of entry ids), |
| 334 | 334 | * and the search query. This should return an array, but it can be handled as a string as well. |
| 335 | 335 | */ |
| 336 | - $query = apply_filters ('frm_csv_where', $query, compact( 'form_id', 'search', 'fid', 'item_id' ) ); |
|
| 336 | + $query = apply_filters( 'frm_csv_where', $query, compact( 'form_id', 'search', 'fid', 'item_id' ) ); |
|
| 337 | 337 | |
| 338 | - $entry_ids = FrmDb::get_col( $wpdb->prefix .'frm_items it', $query ); |
|
| 338 | + $entry_ids = FrmDb::get_col( $wpdb->prefix . 'frm_items it', $query ); |
|
| 339 | 339 | unset( $query ); |
| 340 | 340 | |
| 341 | 341 | if ( empty( $entry_ids ) ) { |
@@ -310,7 +310,7 @@ |
||
| 310 | 310 | if ( ! is_array( $csv_fields ) ) { |
| 311 | 311 | $csv_fields = explode(',', $csv_fields); |
| 312 | 312 | } |
| 313 | - if ( ! empty($csv_fields) ) { |
|
| 313 | + if ( ! empty($csv_fields) ) { |
|
| 314 | 314 | $where['fi.id'] = $csv_fields; |
| 315 | 315 | } |
| 316 | 316 | } |
@@ -235,50 +235,50 @@ discard block |
||
| 235 | 235 | return $line; |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - $convmap = false; |
|
| 238 | + $convmap = false; |
|
| 239 | 239 | |
| 240 | 240 | switch ( self::$to_encoding ) { |
| 241 | - case 'macintosh': |
|
| 242 | - // this map was derived from the differences between the MacRoman and UTF-8 Charsets |
|
| 243 | - // Reference: |
|
| 244 | - // - http://www.alanwood.net/demos/macroman.html |
|
| 245 | - $convmap = array( |
|
| 246 | - 256, 304, 0, 0xffff, |
|
| 247 | - 306, 337, 0, 0xffff, |
|
| 248 | - 340, 375, 0, 0xffff, |
|
| 249 | - 377, 401, 0, 0xffff, |
|
| 250 | - 403, 709, 0, 0xffff, |
|
| 251 | - 712, 727, 0, 0xffff, |
|
| 252 | - 734, 936, 0, 0xffff, |
|
| 253 | - 938, 959, 0, 0xffff, |
|
| 254 | - 961, 8210, 0, 0xffff, |
|
| 255 | - 8213, 8215, 0, 0xffff, |
|
| 256 | - 8219, 8219, 0, 0xffff, |
|
| 257 | - 8227, 8229, 0, 0xffff, |
|
| 258 | - 8231, 8239, 0, 0xffff, |
|
| 259 | - 8241, 8248, 0, 0xffff, |
|
| 260 | - 8251, 8259, 0, 0xffff, |
|
| 261 | - 8261, 8363, 0, 0xffff, |
|
| 262 | - 8365, 8481, 0, 0xffff, |
|
| 263 | - 8483, 8705, 0, 0xffff, |
|
| 264 | - 8707, 8709, 0, 0xffff, |
|
| 265 | - 8711, 8718, 0, 0xffff, |
|
| 266 | - 8720, 8720, 0, 0xffff, |
|
| 267 | - 8722, 8729, 0, 0xffff, |
|
| 268 | - 8731, 8733, 0, 0xffff, |
|
| 269 | - 8735, 8746, 0, 0xffff, |
|
| 270 | - 8748, 8775, 0, 0xffff, |
|
| 271 | - 8777, 8799, 0, 0xffff, |
|
| 272 | - 8801, 8803, 0, 0xffff, |
|
| 273 | - 8806, 9673, 0, 0xffff, |
|
| 274 | - 9675, 63742, 0, 0xffff, |
|
| 275 | - 63744, 64256, 0, 0xffff, |
|
| 276 | - ); |
|
| 277 | - break; |
|
| 278 | - case 'ISO-8859-1': |
|
| 279 | - $convmap = array(256, 10000, 0, 0xffff); |
|
| 280 | - break; |
|
| 281 | - } |
|
| 241 | + case 'macintosh': |
|
| 242 | + // this map was derived from the differences between the MacRoman and UTF-8 Charsets |
|
| 243 | + // Reference: |
|
| 244 | + // - http://www.alanwood.net/demos/macroman.html |
|
| 245 | + $convmap = array( |
|
| 246 | + 256, 304, 0, 0xffff, |
|
| 247 | + 306, 337, 0, 0xffff, |
|
| 248 | + 340, 375, 0, 0xffff, |
|
| 249 | + 377, 401, 0, 0xffff, |
|
| 250 | + 403, 709, 0, 0xffff, |
|
| 251 | + 712, 727, 0, 0xffff, |
|
| 252 | + 734, 936, 0, 0xffff, |
|
| 253 | + 938, 959, 0, 0xffff, |
|
| 254 | + 961, 8210, 0, 0xffff, |
|
| 255 | + 8213, 8215, 0, 0xffff, |
|
| 256 | + 8219, 8219, 0, 0xffff, |
|
| 257 | + 8227, 8229, 0, 0xffff, |
|
| 258 | + 8231, 8239, 0, 0xffff, |
|
| 259 | + 8241, 8248, 0, 0xffff, |
|
| 260 | + 8251, 8259, 0, 0xffff, |
|
| 261 | + 8261, 8363, 0, 0xffff, |
|
| 262 | + 8365, 8481, 0, 0xffff, |
|
| 263 | + 8483, 8705, 0, 0xffff, |
|
| 264 | + 8707, 8709, 0, 0xffff, |
|
| 265 | + 8711, 8718, 0, 0xffff, |
|
| 266 | + 8720, 8720, 0, 0xffff, |
|
| 267 | + 8722, 8729, 0, 0xffff, |
|
| 268 | + 8731, 8733, 0, 0xffff, |
|
| 269 | + 8735, 8746, 0, 0xffff, |
|
| 270 | + 8748, 8775, 0, 0xffff, |
|
| 271 | + 8777, 8799, 0, 0xffff, |
|
| 272 | + 8801, 8803, 0, 0xffff, |
|
| 273 | + 8806, 9673, 0, 0xffff, |
|
| 274 | + 9675, 63742, 0, 0xffff, |
|
| 275 | + 63744, 64256, 0, 0xffff, |
|
| 276 | + ); |
|
| 277 | + break; |
|
| 278 | + case 'ISO-8859-1': |
|
| 279 | + $convmap = array(256, 10000, 0, 0xffff); |
|
| 280 | + break; |
|
| 281 | + } |
|
| 282 | 282 | |
| 283 | 283 | if ( is_array( $convmap ) ) { |
| 284 | 284 | $line = mb_encode_numericentity( $line, $convmap, self::$charset ); |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | return self::escape_csv( $line ); |
| 292 | - } |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | 294 | /** |
| 295 | 295 | * Escape a " in a csv with another " |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class FrmCSVExportHelper{ |
|
| 3 | +class FrmCSVExportHelper { |
|
| 4 | 4 | protected static $separator = ', '; |
| 5 | 5 | protected static $column_separator = ','; |
| 6 | 6 | protected static $line_break = 'return'; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | header( 'Content-Description: File Transfer' ); |
| 64 | 64 | header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' ); |
| 65 | 65 | header( 'Content-Type: text/csv; charset=' . self::$charset, true ); |
| 66 | - header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date('Y' ) ) ) . ' GMT' ); |
|
| 66 | + header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', mktime( date( 'H' ) + 2, date( 'i' ), date( 's' ), date( 'm' ), date( 'd' ), date( 'Y' ) ) ) . ' GMT' ); |
|
| 67 | 67 | header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); |
| 68 | 68 | header( 'Cache-Control: no-cache, must-revalidate' ); |
| 69 | 69 | header( 'Pragma: no-cache' ); |
@@ -87,19 +87,19 @@ discard block |
||
| 87 | 87 | private static function csv_headings( &$headings ) { |
| 88 | 88 | foreach ( self::$fields as $col ) { |
| 89 | 89 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] && ! in_array( $col->type, array( 'user_id', 'file', 'data', 'date' ) ) ) { |
| 90 | - $headings[ $col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 90 | + $headings[$col->id . '_label'] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) ); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - $headings[ $col->id ] = strip_tags( $col->name ); |
|
| 93 | + $headings[$col->id] = strip_tags( $col->name ); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | if ( self::$comment_count ) { |
| 97 | - for ( $i = 0; $i < self::$comment_count; $i++ ) { |
|
| 98 | - $headings[ 'comment' . $i ] = __( 'Comment', 'formidable' ); |
|
| 99 | - $headings[ 'comment_user_id' . $i ] = __( 'Comment User', 'formidable' ); |
|
| 100 | - $headings[ 'comment_created_at' . $i ] = __( 'Comment Date', 'formidable' ); |
|
| 97 | + for ( $i = 0; $i < self::$comment_count; $i ++ ) { |
|
| 98 | + $headings['comment' . $i] = __( 'Comment', 'formidable' ); |
|
| 99 | + $headings['comment_user_id' . $i] = __( 'Comment User', 'formidable' ); |
|
| 100 | + $headings['comment_created_at' . $i] = __( 'Comment Date', 'formidable' ); |
|
| 101 | 101 | } |
| 102 | - unset($i); |
|
| 102 | + unset( $i ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | $headings['created_at'] = __( 'Timestamp', 'formidable' ); |
@@ -146,45 +146,45 @@ discard block |
||
| 146 | 146 | continue; |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 150 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array(); |
|
| 151 | - } else if ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) { |
|
| 149 | + if ( ! isset( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 150 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = array(); |
|
| 151 | + } else if ( ! is_array( $entries[self::$entry->parent_item_id]->metas[$meta_id] ) ) { |
|
| 152 | 152 | // if the data is here, it should be an array but if this field has collected data |
| 153 | 153 | // both while inside and outside of the repeating section, it's possible this is a string |
| 154 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ]; |
|
| 154 | + $entries[self::$entry->parent_item_id]->metas[$meta_id] = (array) $entries[self::$entry->parent_item_id]->metas[$meta_id]; |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | //add the repeated values |
| 158 | - $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ][] = $meta_value; |
|
| 158 | + $entries[self::$entry->parent_item_id]->metas[$meta_id][] = $meta_value; |
|
| 159 | 159 | } |
| 160 | - $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas; |
|
| 160 | + $entries[self::$entry->parent_item_id]->metas += self::$entry->metas; |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | // add the embedded form id |
| 164 | - if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) { |
|
| 165 | - $entries[ self::$entry->parent_item_id ]->embedded_fields = array(); |
|
| 164 | + if ( ! isset( $entries[self::$entry->parent_item_id]->embedded_fields ) ) { |
|
| 165 | + $entries[self::$entry->parent_item_id]->embedded_fields = array(); |
|
| 166 | 166 | } |
| 167 | - $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id; |
|
| 167 | + $entries[self::$entry->parent_item_id]->embedded_fields[self::$entry->id] = self::$entry->form_id; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | private static function add_field_values_to_csv( &$row ) { |
| 171 | 171 | foreach ( self::$fields as $col ) { |
| 172 | - $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false; |
|
| 172 | + $field_value = isset( self::$entry->metas[$col->id] ) ? self::$entry->metas[$col->id] : false; |
|
| 173 | 173 | |
| 174 | 174 | $field_value = maybe_unserialize( $field_value ); |
| 175 | - $field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator, ) ); |
|
| 175 | + $field_value = apply_filters( 'frm_csv_value', $field_value, array( 'field' => $col, 'entry' => self::$entry, 'separator' => self::$separator,) ); |
|
| 176 | 176 | |
| 177 | 177 | if ( isset( $col->field_options['separate_value'] ) && $col->field_options['separate_value'] ) { |
| 178 | 178 | $sep_value = FrmEntriesHelper::display_value( $field_value, $col, array( |
| 179 | 179 | 'type' => $col->type, 'post_id' => self::$entry->post_id, 'show_icon' => false, |
| 180 | 180 | 'entry_id' => self::$entry->id, 'sep' => self::$separator, |
| 181 | - 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ $entry->id ] ) ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, |
|
| 181 | + 'embedded_field_id' => ( isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[$entry->id] ) ) ? 'form' . self::$entry->embedded_fields[self::$entry->id] : 0, |
|
| 182 | 182 | ) ); |
| 183 | - $row[ $col->id . '_label' ] = $sep_value; |
|
| 183 | + $row[$col->id . '_label'] = $sep_value; |
|
| 184 | 184 | unset( $sep_value ); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - $row[ $col->id ] = $field_value; |
|
| 187 | + $row[$col->id] = $field_value; |
|
| 188 | 188 | |
| 189 | 189 | unset( $col, $field_value ); |
| 190 | 190 | } |
@@ -205,9 +205,9 @@ discard block |
||
| 205 | 205 | $col_count = count( $rows ); |
| 206 | 206 | $this_col = 0; |
| 207 | 207 | foreach ( $rows as $k => $row ) { |
| 208 | - $this_col++; |
|
| 208 | + $this_col ++; |
|
| 209 | 209 | |
| 210 | - if ( ! isset( self::$headings[ $k ] ) ) { |
|
| 210 | + if ( ! isset( self::$headings[$k] ) ) { |
|
| 211 | 211 | // this column has been removed from the csv, so skip it |
| 212 | 212 | continue; |
| 213 | 213 | } |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | ); |
| 277 | 277 | break; |
| 278 | 278 | case 'ISO-8859-1': |
| 279 | - $convmap = array(256, 10000, 0, 0xffff); |
|
| 279 | + $convmap = array( 256, 10000, 0, 0xffff ); |
|
| 280 | 280 | break; |
| 281 | 281 | } |
| 282 | 282 | |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -class FrmCSVExportHelper{ |
|
| 3 | +class FrmCSVExportHelper { |
|
| 4 | 4 | protected static $separator = ', '; |
| 5 | 5 | protected static $column_separator = ','; |
| 6 | 6 | protected static $line_break = 'return'; |
@@ -87,9 +87,9 @@ |
||
| 87 | 87 | } else if ( $form->is_template ) { |
| 88 | 88 | echo ' ' . __( '(template)', 'formidable' ); |
| 89 | 89 | } |
| 90 | - ?></option> |
|
| 90 | + ?></option> |
|
| 91 | 91 | <?php |
| 92 | - } ?> |
|
| 92 | + } ?> |
|
| 93 | 93 | </select> |
| 94 | 94 | <p class="howto"><?php _e( 'Hold down the CTRL/Command button to select multiple forms', 'formidable' ); ?></p> |
| 95 | 95 | </td> |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | <div class="frmicon icon32"><br/></div> |
| 3 | 3 | <h2><?php _e( 'Import/Export', 'formidable' ); ?></h2> |
| 4 | 4 | |
| 5 | - <?php include(FrmAppHelper::plugin_path() .'/classes/views/shared/errors.php'); ?> |
|
| 5 | + <?php include( FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php' ); ?> |
|
| 6 | 6 | <div id="poststuff" class="metabox-holder"> |
| 7 | 7 | <div id="post-body"> |
| 8 | 8 | <div id="post-body-content"> |
@@ -10,16 +10,16 @@ discard block |
||
| 10 | 10 | <div class="postbox "> |
| 11 | 11 | <h3 class="hndle"><span><?php _e( 'Import', 'formidable' ) ?></span></h3> |
| 12 | 12 | <div class="inside"> |
| 13 | - <p class="howto"><?php echo apply_filters('frm_upload_instructions1', __( 'Upload your Formidable XML file to import forms into this site. If your imported form key and creation date match a form on your site, that form will be updated.', 'formidable' )) ?></p> |
|
| 13 | + <p class="howto"><?php echo apply_filters( 'frm_upload_instructions1', __( 'Upload your Formidable XML file to import forms into this site. If your imported form key and creation date match a form on your site, that form will be updated.', 'formidable' ) ) ?></p> |
|
| 14 | 14 | <br/> |
| 15 | 15 | <form enctype="multipart/form-data" method="post"> |
| 16 | 16 | <input type="hidden" name="frm_action" value="import_xml" /> |
| 17 | - <?php wp_nonce_field('import-xml-nonce', 'import-xml'); ?> |
|
| 18 | - <p><label><?php echo apply_filters('frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' )) ?> (<?php printf(__( 'Maximum size: %s', 'formidable' ), ini_get('upload_max_filesize')) ?>)</label> |
|
| 17 | + <?php wp_nonce_field( 'import-xml-nonce', 'import-xml' ); ?> |
|
| 18 | + <p><label><?php echo apply_filters( 'frm_upload_instructions2', __( 'Choose a Formidable XML file', 'formidable' ) ) ?> (<?php printf( __( 'Maximum size: %s', 'formidable' ), ini_get( 'upload_max_filesize' ) ) ?>)</label> |
|
| 19 | 19 | <input type="file" name="frm_import_file" size="25" /> |
| 20 | 20 | </p> |
| 21 | 21 | |
| 22 | - <?php do_action('frm_csv_opts', $forms) ?> |
|
| 22 | + <?php do_action( 'frm_csv_opts', $forms ) ?> |
|
| 23 | 23 | |
| 24 | 24 | <p class="submit"> |
| 25 | 25 | <input type="submit" value="<?php esc_attr_e( 'Upload file and import', 'formidable' ) ?>" class="button-primary" /> |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | <div class="inside with_frm_style"> |
| 35 | 35 | <form method="post" action="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>" id="frm_export_xml"> |
| 36 | 36 | <input type="hidden" name="action" value="frm_export_xml" /> |
| 37 | - <?php wp_nonce_field('export-xml-nonce', 'export-xml'); ?> |
|
| 37 | + <?php wp_nonce_field( 'export-xml-nonce', 'export-xml' ); ?> |
|
| 38 | 38 | |
| 39 | 39 | <table class="form-table"> |
| 40 | 40 | <tr class="form-field"> |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | <td> |
| 43 | 43 | <select name="format"> |
| 44 | 44 | <?php foreach ( $export_format as $t => $type ) { ?> |
| 45 | - <option value="<?php echo esc_attr( $t ) ?>" data-support="<?php echo esc_attr( $type['support'] ) ?>" <?php echo isset( $type['count'] ) ? 'data-count="'. esc_attr( $type['count'] ) .'"' : ''; ?>><?php echo isset( $type['name'] ) ? $type['name'] : $t ?></option> |
|
| 45 | + <option value="<?php echo esc_attr( $t ) ?>" data-support="<?php echo esc_attr( $type['support'] ) ?>" <?php echo isset( $type['count'] ) ? 'data-count="' . esc_attr( $type['count'] ) . '"' : ''; ?>><?php echo isset( $type['name'] ) ? $type['name'] : $t ?></option> |
|
| 46 | 46 | <?php } ?> |
| 47 | 47 | </select> |
| 48 | 48 | |