public static function destroy() { $id = FrmAppHelper::simple_get('id', 'absint'); $frm_style = new FrmStyle(); $frm_style->destroy($id); $message = __('Your styling settings have been deleted.', 'formidable'); self::edit('default', $message); }
" id="frm_required_color" class="hex" value="<?php echo esc_attr($style->post_content['required_color']); ?> " /> </div> <div class="field-group clearfix after-h3"> <label><?php _e('Weight', 'formidable'); ?> </label> <select name="<?php echo esc_attr($frm_style->get_field_name('required_weight')); ?> " id="frm_required_weight"> <?php foreach (FrmStyle::get_bold_options() as $value => $name) { ?> <option value="<?php echo esc_attr($value); ?> " <?php selected($style->post_content['required_weight'], $value); ?> ><?php echo esc_html($name); ?> </option> <?php } ?> </select>
public static function show_entry_styles($default_styles) { $frm_style = new FrmStyle('default'); $style = $frm_style->get_one(); if (!$style) { return $default_styles; } foreach ($default_styles as $name => $val) { $setting = $name; if ('border_width' == $name) { $setting = 'field_border_width'; } else { if ('alt_bg_color' == $name) { $setting = 'bg_color_active'; } } $default_styles[$name] = $style->post_content[$setting]; unset($name, $val); } return $default_styles; }
/** * Migrate old styling settings. If sites are using the old * default 400px field width, switch it to 100% * * @since 2.0.4 */ private function migrate_to_25() { // get the style that was created with the style migration $frm_style = new FrmStyle(); $styles = $frm_style->get_all('post_date', 'ASC', 1); if (empty($styles)) { return; } foreach ($styles as $style) { if ($style->post_content['field_width'] == '400px') { $style->post_content['field_width'] = '100%'; $frm_style->save((array) $style); return; } } }
private static function maybe_update_stylesheet($imported) { if (isset($imported['imported']['styles']) && !empty($imported['imported']['styles']) || isset($imported['updated']['styles']) && !empty($imported['updated']['styles'])) { if (is_admin() && function_exists('get_filesystem_method')) { $frm_style = new FrmStyle(); $frm_style->update('default'); } } }
<?php if (!isset($saving)) { header('Content-type: text/css'); if (isset($css) && $css) { echo $css; die; } } if (!isset($frm_style)) { $frm_style = new FrmStyle(); } $styles = $frm_style->get_all(); $default_style = $frm_style->get_default_style($styles); $defaults = $default_style->post_content; ?> .frm_hidden, .with_frm_style .frm_button.frm_hidden{ display:none; } legend.frm_hidden{ display:none !important; } .frm_transparent{ color:transparent; } .input[type=file].frm_transparent:focus, .with_frm_style input[type=file]{
private static function maybe_update_stylesheet($imported) { $new_styles = isset($imported['imported']['styles']) && !empty($imported['imported']['styles']); $updated_styles = isset($imported['updated']['styles']) && !empty($imported['updated']['styles']); if ($new_styles || $updated_styles) { if (is_admin() && function_exists('get_filesystem_method')) { $frm_style = new FrmStyle(); $frm_style->update('default'); } foreach ($imported['forms'] as $form_id) { self::update_custom_style_setting_after_import($form_id); } } }
/** * Migrate style to custom post type */ private static function migrate_to_27() { $new_post = array('post_type' => FrmStylesController::$post_type, 'post_title' => __('Formidable Style', 'formidable'), 'post_status' => 'publish', 'post_content' => array(), 'menu_order' => 1); $exists = get_posts(array('post_type' => $new_post['post_type'], 'post_status' => $new_post['post_status'], 'numberposts' => 1)); if ($exists) { $new_post['ID'] = reset($exists)->ID; } $frmpro_settings = get_option('frmpro_options'); // If unserializing didn't work if (!is_object($frmpro_settings)) { if ($frmpro_settings) { //workaround for W3 total cache conflict $frmpro_settings = unserialize(serialize($frmpro_settings)); } } if (!is_object($frmpro_settings)) { return; } $frm_style = new FrmStyle(); $default_styles = $frm_style->get_defaults(); foreach ($default_styles as $setting => $default) { if (isset($frmpro_settings->{$setting})) { $new_post['post_content'][$setting] = $frmpro_settings->{$setting}; } } $frm_style->save($new_post); }
public static function generate_xml($type, $args = array()) { global $wpdb; self::prepare_types_array($type); $tables = array('items' => $wpdb->prefix . 'frm_items', 'forms' => $wpdb->prefix . 'frm_forms', 'posts' => $wpdb->posts, 'styles' => $wpdb->posts, 'actions' => $wpdb->posts); $defaults = array('ids' => false); $args = wp_parse_args($args, $defaults); $sitename = sanitize_key(get_bloginfo('name')); if (!empty($sitename)) { $sitename .= '.'; } $filename = $sitename . 'formidable.' . date('Y-m-d') . '.xml'; header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=' . $filename); header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); //make sure ids are numeric if (is_array($args['ids']) && !empty($args['ids'])) { $args['ids'] = array_filter($args['ids'], 'is_numeric'); } $records = array(); foreach ($type as $tb_type) { $where = array(); $join = ''; $table = $tables[$tb_type]; $select = $table . '.id'; $query_vars = array(); switch ($tb_type) { case 'forms': //add forms if ($args['ids']) { $where[] = array('or' => 1, $table . '.id' => $args['ids'], $table . '.parent_form_id' => $args['ids']); } else { $where[$table . '.status !'] = 'draft'; } break; case 'actions': $select = $table . '.ID'; $where['post_type'] = FrmFormActionsController::$action_post_type; if (!empty($args['ids'])) { $where['menu_order'] = $args['ids']; } break; case 'items': //$join = "INNER JOIN {$wpdb->prefix}frm_item_metas im ON ($table.id = im.item_id)"; if ($args['ids']) { $where[$table . '.form_id'] = $args['ids']; } break; case 'styles': // Loop through all exported forms and get their selected style IDs $frm_style = new FrmStyle(); $default_style = $frm_style->get_default_style(); $form_ids = $args['ids']; $style_ids = array(); foreach ($form_ids as $form_id) { $form_data = FrmForm::getOne($form_id); // For forms that have not been updated while running 2.0, check if custom_style is set if (isset($form_data->options['custom_style'])) { if ($form_data->options['custom_style'] == 1) { $style_ids[] = $default_style->ID; } else { $style_ids[] = $form_data->options['custom_style']; } } unset($form_id, $form_data); } $select = $table . '.ID'; $where['post_type'] = 'frm_styles'; // Only export selected styles if (!empty($style_ids)) { $where['ID'] = $style_ids; } break; default: $select = $table . '.ID'; $join = ' INNER JOIN ' . $wpdb->postmeta . ' pm ON (pm.post_id=' . $table . '.ID)'; $where['pm.meta_key'] = 'frm_form_id'; if (empty($args['ids'])) { $where['pm.meta_value >'] = 1; } else { $where['pm.meta_value'] = $args['ids']; } break; } $records[$tb_type] = FrmDb::get_col($table . $join, $where, $select); unset($tb_type); } echo '<?xml version="1.0" encoding="' . esc_attr(get_bloginfo('charset')) . "\" ?>\n"; include FrmAppHelper::plugin_path() . '/classes/views/xml/xml.php'; }