public static function enqueue_jquery_css() { $theme_css = FrmStylesController::get_style_val('theme_css'); if ($theme_css != -1) { wp_enqueue_style('jquery-theme', self::jquery_css_url($theme_css), array(), FrmAppHelper::plugin_version()); } }
/** * @covers FrmStylesController::custom_stylesheet */ private function get_custom_stylesheet() { global $frm_vars; $frm_vars['css_loaded'] = false; $stylesheet_urls = FrmStylesController::custom_stylesheet(); $this->assertTrue(isset($stylesheet_urls['formidable']), 'The stylesheet array is empty'); return $stylesheet_urls; }
public static function create($field_data) { if ($field_data['field_options']['label'] != 'none') { $field_data['field_options']['label'] = ''; } $defaults = array('number' => array('maxnum' => 9999999), 'date' => array('max' => '10'), 'phone' => array('size' => '115px'), 'rte' => array('max' => 7), 'end_divider' => array('format' => 'both')); if (isset($defaults[$field_data['type']])) { $field_data['field_options'] = array_merge($field_data['field_options'], $defaults[$field_data['type']]); return $field_data; } switch ($field_data['type']) { case 'scale': $field_data['options'] = serialize(range(1, 10)); $field_data['field_options']['minnum'] = 1; $field_data['field_options']['maxnum'] = 10; break; case 'select': $width = FrmStylesController::get_style_val('auto_width', $field_data['form_id']); $field_data['field_options']['size'] = $width; break; case 'user_id': $field_data['name'] = __('User ID', 'formidable'); break; case 'divider': $field_data['field_options']['label'] = 'top'; if (isset($field_data['field_options']['repeat']) && $field_data['field_options']['repeat']) { // create the repeatable form $field_data['field_options']['form_select'] = self::create_repeat_form(0, array('parent_form_id' => $field_data['form_id'], 'field_name' => $field_data['name'])); } break; case 'break': $field_data['name'] = __('Next', 'formidable'); break; } return $field_data; }
public static function load_css() { _deprecated_function(__FUNCTION__, '2.0.9', 'FrmStylesController::load_saved_css'); return FrmStylesController::load_saved_css(); }
public static function footer_js($location = 'footer') { global $frm_vars; FrmStylesController::enqueue_css(); if (!FrmAppHelper::is_admin() && $location != 'header' && !empty($frm_vars['forms_loaded'])) { //load formidable js wp_enqueue_script('formidable'); } }
/** * Add the collapse icon next to collapsible section headings * * @since 2.0.14 * * @param string $trigger * @param array $field * @param string $html, pass by reference */ private static function maybe_add_collapse_icon($trigger, $field, &$html) { if (!empty($trigger)) { $style = FrmStylesController::get_form_style($field['form_id']); preg_match_all("/\\<h[2-6]\\b(.*?)(?:(\\/))?\\>(.*?)(?:(\\/))?\\<\\/h[2-6]>/su", $html, $headings, PREG_PATTERN_ORDER); if (isset($headings[3]) && !empty($headings[3])) { $header_text = reset($headings[3]); $old_header_html = reset($headings[0]); if ('before' == $style->post_content['collapse_pos']) { $new_header_html = str_replace($header_text, '<i class="frm_icon_font frm_arrow_icon"></i> ' . $header_text, $old_header_html); } else { $new_header_html = str_replace($header_text, $header_text . '<i class="frm_icon_font frm_arrow_icon"></i> ', $old_header_html); } $html = str_replace($old_header_html, $new_header_html, $html); } } }
/** * Alternate Row Color for Default HTML * @return string */ public static function change_row_color() { global $frm_email_col; $bg_color = 'bg_color'; if ($frm_email_col) { $bg_color .= '_active'; $frm_email_col = false; } else { $frm_email_col = true; } $bg_color = FrmStylesController::get_style_val($bg_color); $alt_color = 'background-color:#' . $bg_color . ';'; return $alt_color; }
public static function add_field_class($class, $field) { if ($field['type'] == 'scale' && FrmField::is_option_true($field, 'star')) { $class .= ' star'; } else { if ($field['type'] == 'date') { $class .= ' frm_date'; } else { if ($field['type'] == 'file' && FrmField::is_option_true($field, 'multiple')) { $class .= ' frm_multiple_file'; } } } // Hide the "No files selected" text if files are selected if ($field['type'] == 'file' && !FrmField::is_option_empty($field, 'value')) { $class .= ' frm_transparent'; } if (!FrmAppHelper::is_admin() && FrmField::is_option_true($field, 'autocom') && ($field['type'] == 'select' || $field['type'] == 'data' && isset($field['data_type']) && $field['data_type'] == 'select') && !empty($field['options']) && !FrmField::is_read_only($field)) { global $frm_vars; $frm_vars['chosen_loaded'] = true; $class .= ' frm_chzn'; $style = FrmStylesController::get_form_style($field['form_id']); if ($style && 'rtl' == $style->post_content['direction']) { $class .= ' chosen-rtl'; } } return $class; }
</textarea> <?php wp_nonce_field('frm_style_nonce', 'frm_style'); ?> <div id="nav-menus-frame"> <div id="menu-settings-column" class="metabox-holder"> <div class="clear"></div> <div class="styling_settings"> <input type="hidden" name="style_name" value="frm_style_<?php echo esc_attr($style->post_name); ?> " /> <?php FrmStylesController::do_accordion_sections(FrmStylesController::$screen, 'side', compact('style', 'frm_style')); ?> </div> </div><!-- /#menu-settings-column --> <div id="menu-management-liquid"> <div id="menu-management"> <div class="menu-edit blank-slate"> <div id="nav-menu-header"> <div class="major-publishing-actions"> <label class="menu-name-label howto open-label" for="menu-name"> <span><?php _e('Style Name', 'formidable'); ?>
} else { ?> <textarea name="<?php echo esc_attr($field_name); ?> " id="<?php echo esc_attr($html_id); ?> " style="height:<?php echo $field['max'] ? (int) $field['max'] * 17 : 125; ?> px;<?php if (!$field['size']) { ?> width:<?php echo FrmStylesController::get_style_val('field_width'); } ?> " <?php do_action('frm_field_input_html', $field); ?> ><?php echo FrmAppHelper::esc_textarea($field['value']); ?> </textarea> <?php } } else { if ($field['type'] == 'file') { if (FrmField::is_read_only($field)) { // Read only file upload field shows the entry without an upload button
public static function get_display_data($display, $content = '', $entry_id = false, $extra_atts = array()) { if (post_password_required($display)) { return get_the_password_form($display); } add_action('frm_load_view_hooks', 'FrmProDisplaysController::trigger_load_view_hooks'); FrmAppHelper::trigger_hook_load('view', $display); global $frm_vars, $post; $frm_vars['forms_loaded'][] = true; if (!isset($display->frm_empty_msg)) { $display = FrmProDisplaysHelper::setup_edit_vars($display, false); } if (!isset($display->frm_form_id) || empty($display->frm_form_id)) { return $content; } //for backwards compatability $display->id = $display->frm_old_id; $display->display_key = $display->post_name; $defaults = array('filter' => false, 'user_id' => '', 'limit' => '', 'page_size' => '', 'order_by' => '', 'order' => '', 'drafts' => false, 'auto_id' => ''); $extra_atts = wp_parse_args($extra_atts, $defaults); extract($extra_atts); //if (FrmProAppHelper::rewriting_on() && $frmpro_settings->permalinks ) // self::parse_pretty_entry_url(); if ($display->frm_show_count == 'one' && is_numeric($display->frm_entry_id) && $display->frm_entry_id > 0 && !$entry_id) { $entry_id = $display->frm_entry_id; } $entry = false; $show = 'all'; // Don't filter with $entry_ids by default because the query gets too long. // Only filter with $entry_ids when showing one entry $use_ids = false; global $wpdb; $where = array('it.form_id' => $display->frm_form_id); if (in_array($display->frm_show_count, array('dynamic', 'calendar', 'one'))) { $one_param = FrmAppHelper::simple_get('entry', 'sanitize_title', $extra_atts['auto_id']); $get_param = FrmAppHelper::simple_get($display->frm_param, 'sanitize_title', $display->frm_show_count == 'one' ? $one_param : $extra_atts['auto_id']); unset($one_param); if ($get_param) { if (($display->frm_type == 'id' || $display->frm_show_count == 'one') && is_numeric($get_param)) { $where['it.id'] = $get_param; } else { $where['it.item_key'] = $get_param; } $entry = FrmEntry::getAll($where, '', 1, 0); if ($entry) { $entry = reset($entry); } if ($entry && $entry->post_id) { //redirect to single post page if this entry is a post if (in_the_loop() && $display->frm_show_count != 'one' && !is_single($entry->post_id) && $post->ID != $entry->post_id) { $this_post = get_post($entry->post_id); if (in_array($this_post->post_status, array('publish', 'private'))) { die(FrmAppHelper::js_redirect(get_permalink($entry->post_id))); } } } } unset($get_param); } if ($entry && in_array($display->frm_show_count, array('dynamic', 'calendar'))) { $new_content = $display->frm_dyncontent; $show = 'one'; } else { $new_content = $display->post_content; } $show = $display->frm_show_count == 'one' ? 'one' : $show; $shortcodes = FrmProDisplaysHelper::get_shortcodes($new_content, $display->frm_form_id); //don't let page size and limit override single entry displays if ($display->frm_show_count == 'one') { $display->frm_page_size = $display->frm_limit = ''; } //don't keep current content if post type is frm_display if ($post && $post->post_type == self::$post_type) { $display->frm_insert_loc = ''; } $pagination = ''; $form_query = array('form_id' => $display->frm_form_id, 'post_id >' => 1); if ($extra_atts['drafts'] != 'both') { $is_draft = empty($extra_atts['drafts']) ? 0 : 1; $form_query['is_draft'] = $is_draft; } else { $is_draft = 'both'; } if ($entry && $entry->form_id == $display->frm_form_id) { $form_query['id'] = $entry->id; } $form_posts = FrmDb::get_results('frm_items', $form_query, 'id, post_id'); unset($form_query); $getting_entries = !$entry || !$post || empty($extra_atts['auto_id']); $check_filter_opts = !empty($display->frm_where) && $getting_entries; if ($entry && $entry->form_id == $display->frm_form_id) { $entry_ids = array($entry->id); // Filter by this entry ID to make query faster $use_ids = true; } else { if ($check_filter_opts || isset($_GET['frm_search'])) { //Only get $entry_ids if filters are set or if frm_search parameter is set $entry_query = array('form_id' => $display->frm_form_id); if ($extra_atts['drafts'] != 'both') { $entry_query['is_draft'] = $is_draft; } $entry_ids = FrmDb::get_col('frm_items', $entry_query); unset($entry_query); } } $empty_msg = isset($display->frm_empty_msg) && !empty($display->frm_empty_msg) ? '<div class="frm_no_entries">' . FrmProFieldsHelper::get_default_value($display->frm_empty_msg, false) . '</div>' : ''; if (isset($message)) { // if an entry was deleted above, show a message $empty_msg = $message . $empty_msg; } $after_where = false; $user_id = $extra_atts['user_id']; if (!empty($user_id)) { $user_id = FrmAppHelper::get_user_id_param($user_id); $uid_used = false; } self::add_group_by_filter($display, $getting_entries); unset($getting_entries); if ($check_filter_opts) { $display->frm_where = apply_filters('frm_custom_where_opt', $display->frm_where, array('display' => $display, 'entry' => $entry)); $continue = false; foreach ($display->frm_where as $where_key => $where_opt) { $where_val = isset($display->frm_where_val[$where_key]) ? $display->frm_where_val[$where_key] : ''; if (preg_match("/\\[(get|get-(.?))\\b(.*?)(?:(\\/))?\\]/s", $where_val)) { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); //if this param doesn't exist, then don't include it if ($where_val == '') { if (!$after_where) { $continue = true; } continue; } } else { $where_val = FrmProFieldsHelper::get_default_value($where_val, false, true, true); } $continue = false; if ($where_val == 'current_user') { if ($user_id && is_numeric($user_id)) { $where_val = $user_id; $uid_used = true; } else { $where_val = get_current_user_id(); } } else { if (!is_array($where_val)) { $where_val = do_shortcode($where_val); } } if (in_array($where_opt, array('id', 'item_key', 'post_id')) && !is_array($where_val) && strpos($where_val, ',')) { $where_val = explode(',', $where_val); $where_val = array_filter($where_val); } if (is_array($where_val) && !empty($where_val)) { if (strpos($display->frm_where_is[$where_key], '!') === false && strpos($display->frm_where_is[$where_key], 'not') === false) { $display->frm_where_is[$where_key] = ' in '; } else { $display->frm_where_is[$where_key] = 'not in'; } } if (is_numeric($where_opt)) { $filter_opts = apply_filters('frm_display_filter_opt', array('where_opt' => $where_opt, 'where_is' => $display->frm_where_is[$where_key], 'where_val' => $where_val, 'form_id' => $display->frm_form_id, 'form_posts' => $form_posts, 'after_where' => $after_where, 'display' => $display, 'drafts' => $is_draft, 'use_ids' => $use_ids)); $entry_ids = FrmProAppHelper::filter_where($entry_ids, $filter_opts); unset($filter_opts); $after_where = true; $continue = false; if (empty($entry_ids)) { break; } } else { if (in_array($where_opt, array('created_at', 'updated_at'))) { if ($where_val == 'NOW') { $where_val = current_time('mysql', 1); } if (strpos($display->frm_where_is[$where_key], 'LIKE') === false) { $where_val = date('Y-m-d H:i:s', strtotime($where_val)); // If using less than or equal to, set the time to the end of the day if ($display->frm_where_is[$where_key] == '<=') { $where_val = str_replace('00:00:00', '23:59:59', $where_val); } // Convert date to GMT since that is the format in the DB $where_val = get_gmt_from_date($where_val); } $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val; $continue = true; } else { if (in_array($where_opt, array('id', 'item_key', 'post_id', 'ip'))) { $where['it.' . sanitize_title($where_opt) . FrmDb::append_where_is($display->frm_where_is[$where_key])] = $where_val; // Update entry IDs if the entry ID filter is set to "equal to" if ($where_opt == 'id' && in_array($display->frm_where_is[$where_key], array('=', ' in '))) { $entry_ids = $where_val; } $continue = true; } } } } if (!$continue && empty($entry_ids)) { if ($display->frm_insert_loc == 'after') { $content .= $empty_msg; } else { if ($display->frm_insert_loc == 'before') { $content = $empty_msg . $content; } else { if ($filter) { $empty_msg = apply_filters('the_content', $empty_msg); } if ($post && $post->post_type == self::$post_type && in_the_loop()) { $content = ''; } $content .= $empty_msg; } } return $content; } } if ($user_id && is_numeric($user_id) && !$uid_used) { $where['it.user_id'] = $user_id; } $s = FrmAppHelper::get_param('frm_search', false, 'get', 'sanitize_text_field'); if ($s) { $new_ids = FrmProEntriesHelper::get_search_ids($s, $display->frm_form_id, array('is_draft' => $extra_atts['drafts'])); if ($after_where && isset($entry_ids) && !empty($entry_ids)) { $entry_ids = array_intersect($new_ids, $entry_ids); } else { $entry_ids = $new_ids; } if (empty($entry_ids)) { if ($post->post_type == self::$post_type && in_the_loop()) { $content = ''; } return $content . ' ' . $empty_msg; } } if (isset($entry_ids) && !empty($entry_ids)) { $where['it.id'] = $entry_ids; } self::maybe_add_entry_query($entry_id, $where); if ($extra_atts['drafts'] != 'both') { $where['is_draft'] = $is_draft; } unset($is_draft); if ($show == 'one') { $limit = ' LIMIT 1'; } else { self::maybe_add_cat_query($where); } if (!empty($limit) && is_numeric($limit)) { $display->frm_limit = (int) $limit; } if (is_numeric($display->frm_limit)) { $num_limit = (int) $display->frm_limit; $limit = ' LIMIT ' . $display->frm_limit; } if (!empty($order_by)) { $display->frm_order_by = explode(',', $order_by); } if (!empty($order)) { $display->frm_order = explode(',', $order); if (!isset($display->frm_order_by[0])) { $display->frm_order_by = FrmProAppHelper::reset_keys($display->frm_order_by); } } unset($order); if (!empty($page_size) && is_numeric($page_size)) { $display->frm_page_size = (int) $page_size; } // if limit is lower than page size, ignore the page size if (isset($num_limit) && $display->frm_page_size > $num_limit) { $display->frm_page_size = ''; } $display_page_query = array('order_by_array' => $display->frm_order_by, 'order_array' => $display->frm_order, 'posts' => $form_posts, 'display' => $display); if (isset($display->frm_page_size) && is_numeric($display->frm_page_size)) { $page_param = $_GET && isset($_GET['frm-page-' . $display->ID]) ? 'frm-page-' . $display->ID : 'frm-page'; $current_page = FrmAppHelper::simple_get($page_param, 'absint', 1); $record_count = FrmEntry::getRecordCount($where); if (isset($num_limit) && $record_count > (int) $num_limit) { $record_count = (int) $num_limit; } $page_count = FrmEntry::getPageCount($display->frm_page_size, $record_count); $entry_ids = FrmProEntry::get_view_page($current_page, $display->frm_page_size, $where, $display_page_query); $page_last_record = FrmAppHelper::get_last_record_num($record_count, $current_page, $display->frm_page_size); $page_first_record = FrmAppHelper::get_first_record_num($record_count, $current_page, $display->frm_page_size); if ($page_count > 1) { $page_param = 'frm-page-' . $display->ID; $pagination = FrmAppHelper::get_file_contents(FrmAppHelper::plugin_path() . '/pro/classes/views/displays/pagination.php', compact('current_page', 'record_count', 'page_count', 'page_last_record', 'page_first_record', 'page_param')); } } else { $display_page_query['limit'] = $limit; //Get all entries $entry_ids = FrmProEntry::get_view_results($where, $display_page_query); } $total_count = count($entry_ids); $sc_atts = array(); if (isset($record_count)) { $sc_atts['record_count'] = $record_count; } else { $sc_atts['record_count'] = $total_count; } $display_content = ''; if (isset($message)) { // if an entry was deleted above, show a message $display_content .= $message; } if ($show == 'all') { $display_content .= isset($display->frm_before_content) ? $display->frm_before_content : ''; } add_filter('frm_before_display_content', 'FrmProDisplaysController::calendar_header', 10, 3); add_filter('frm_before_display_content', 'FrmProDisplaysController::filter_after_content', 10, 4); $display_content = apply_filters('frm_before_display_content', $display_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); add_filter('frm_display_entries_content', 'FrmProDisplaysController::build_calendar', 10, 5); $filtered_content = apply_filters('frm_display_entries_content', $new_content, $entry_ids, $shortcodes, $display, $show, $sc_atts); if ($filtered_content != $new_content) { $display_content .= $filtered_content; } else { $odd = 'odd'; $count = 0; if (!empty($entry_ids)) { $loop_entry_ids = $entry_ids; while ($next_set = array_splice($loop_entry_ids, 0, 30)) { $entries = FrmEntry::getAll(array('id' => $next_set), ' ORDER BY FIELD(it.id,' . implode(',', $next_set) . ')', '', true, false); foreach ($entries as $entry) { $count++; //TODO: use the count with conditionals $display_content .= apply_filters('frm_display_entry_content', $new_content, $entry, $shortcodes, $display, $show, $odd, array('count' => $count, 'total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'pagination' => $pagination, 'entry_ids' => $entry_ids)); $odd = $odd == 'odd' ? 'even' : 'odd'; unset($entry); } unset($entries); } unset($loop_entry_ids, $count); } else { if ($post && $post->post_type == self::$post_type && in_the_loop()) { $display_content = ''; } if (!isset($message) || FrmAppHelper::get_param('frm_action', '', 'get', 'sanitize_title') != 'destroy') { $display_content .= $empty_msg; } } } if (isset($message)) { unset($message); } if ($show == 'all' && isset($display->frm_after_content)) { add_filter('frm_after_content', 'FrmProDisplaysController::filter_after_content', 10, 4); $display_content .= apply_filters('frm_after_content', $display->frm_after_content, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); } if (!isset($sc_atts)) { $sc_atts = array('record_count' => 0); } if (!isset($total_count)) { $total_count = 0; } $pagination = self::calendar_footer($pagination, $display, $show); $display_content .= apply_filters('frm_after_display_content', $pagination, $display, $show, array('total_count' => $total_count, 'record_count' => $sc_atts['record_count'], 'entry_ids' => $entry_ids)); unset($sc_atts); $display_content = FrmProFieldsHelper::get_default_value($display_content, false, true, false); if ($display->frm_insert_loc == 'after') { $content .= $display_content; } else { if ($display->frm_insert_loc == 'before') { $content = $display_content . $content; } else { if ($filter) { $display_content = apply_filters('the_content', $display_content); } $content = $display_content; } } // load the styling for css classes and pagination FrmStylesController::enqueue_style(); return $content; }