function form($form_action, $args = array()) { global $wpdb; extract($args); $post_types = FrmProAppHelper::get_custom_post_types(); if (!$post_types) { return; } $post_type = FrmProFormsHelper::post_type($args['values']['id']); $taxonomies = get_object_taxonomies($post_type); $action_control = $this; $echo = true; $form_id = $form->id; $display = false; $displays = array(); $display_ids = FrmDb::get_col($wpdb->postmeta, array('meta_key' => 'frm_form_id', 'meta_value' => $form_id), 'post_ID'); if ($display_ids) { $query_args = array('pm.meta_key' => 'frm_show_count', 'post_type' => 'frm_display', 'pm.meta_value' => array('dynamic', 'calendar', 'one'), 'p.post_status' => array('publish', 'private'), 'p.ID' => $display_ids); $displays = FrmDb::get_results($wpdb->posts . ' p LEFT JOIN ' . $wpdb->postmeta . ' pm ON (p.ID = pm.post_ID)', $query_args, 'p.ID, p.post_title', array('order_by' => 'p.post_title ASC')); if (isset($form_action->post_content['display_id'])) { // get view from settings if (is_numeric($form_action->post_content['display_id'])) { $display = FrmProDisplay::getOne($form_action->post_content['display_id'], false, true); } } else { if (!is_numeric($form_action->post_content['post_content']) && !empty($display_ids)) { // get auto view $display = FrmProDisplay::get_form_custom_display($form_id); if ($display) { $display = FrmProDisplaysHelper::setup_edit_vars($display, true); } } } } // Get array of all custom fields $custom_fields = array(); if (isset($form_action->post_content['post_custom_fields'])) { foreach ($form_action->post_content['post_custom_fields'] as $custom_field_opts) { if (isset($custom_field_opts['meta_name'])) { $custom_fields[] = $custom_field_opts['meta_name']; } unset($custom_field_opts); } } unset($display_ids); include dirname(__FILE__) . '/post_options.php'; }
/** * Copy forms that are set to copy from one site to another */ private static function copy_forms($force) { if (!$force) { //don't check on every page load $last_checked = get_option('frmpro_copies_checked'); if (!$last_checked || time() - $last_checked >= 60 * 60) { //check every hour $force = true; } } if (!$force) { return; } global $wpdb, $blog_id; //get all forms to be copied from global table $query = $wpdb->prepare('SELECT c.*, p.post_name FROM ' . self::table_name() . ' c LEFT JOIN ' . $wpdb->prefix . 'frm_forms f ON (c.copy_key = f.form_key) LEFT JOIN ' . $wpdb->posts . ' p ON (c.copy_key = p.post_name) WHERE blog_id != %d AND ((type = %s AND f.form_key is NULL) OR (type = %s AND p.post_name is NULL)) ORDER BY type DESC', $blog_id, 'form', 'display'); $templates = FrmAppHelper::check_cache('all_templates_' . $blog_id, 'frm_copy', $query, 'get_results'); foreach ($templates as $temp) { if ($temp->type == 'form') { FrmForm::duplicate($temp->form_id, false, true, $temp->blog_id); continue; } $values = FrmProDisplay::getOne($temp->form_id, $temp->blog_id, true); if (!$values || 'trash' == $values->post_status) { continue; } // check if post with slug already exists $post_name = wp_unique_post_slug($values->post_name, 0, 'publish', 'frm_display', 0); if ($post_name != $values->post_name) { continue; } if ($values->post_name != $temp->copy_key) { $wpdb->update(self::table_name(), array('copy_key' => $values->post_name), array('id' => $temp->id)); } FrmProDisplay::duplicate($temp->form_id, true, $temp->blog_id); //TODO: replace any ids with field keys in the display before duplicated unset($temp); } update_option('frmpro_copies_checked', time()); }
function form($instance) { $pages = get_posts(array('post_type' => 'page', 'post_status' => 'publish', 'numberposts' => 999, 'order_by' => 'post_title', 'order' => 'ASC')); $displays = FrmProDisplay::getAll(array('meta_key' => 'frm_show_count', 'meta_value' => 'dynamic')); //Defaults $instance = wp_parse_args((array) $instance, array('title' => false, 'display_id' => false, 'post_id' => false, 'title_id' => false, 'cat_list' => false, 'cat_name' => false, 'cat_count' => false, 'cat_id' => false, 'limit' => false)); if ($instance['display_id']) { $selected_display = FrmProDisplay::getOne($instance['display_id']); if ($selected_display) { $selected_form_id = get_post_meta($selected_display->ID, 'frm_form_id', true); $title_opts = FrmField::getAll(array('fi.form_id' => (int) $selected_form_id, 'type not' => FrmField::no_save_fields()), 'field_order'); $instance['display_id'] = $selected_display->ID; } } ?> <p><label for="<?php echo $this->get_field_id('title'); ?> "><?php _e('Title', 'formidable'); ?> :</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('title'); ?> " name="<?php echo $this->get_field_name('title'); ?> " value="<?php echo esc_attr(stripslashes($instance['title'])); ?> " /></p> <p><label for="<?php echo $this->get_field_id('display_id'); ?> "><?php _e('Use Settings from View', 'formidable'); ?> :</label> <select name="<?php echo $this->get_field_name('display_id'); ?> " id="<?php echo $this->get_field_id('display_id'); ?> " class="widefat frm_list_items_display_id"> <option value=""> </option> <?php foreach ($displays as $display) { echo '<option value="' . esc_attr($display->ID) . '" ' . selected($instance['display_id'], $display->ID, false) . '>' . FrmAppHelper::kses($display->post_title) . '</option>'; } ?> </select> </p> <p class="description"><?php _e('Views with a "Both (Dynamic)" format will show here.', 'formidable'); ?> </p> <p><label for="<?php echo $this->get_field_id('post_id'); ?> "><?php _e('Page if not specified in View settings', 'formidable'); ?> :</label> <select name="<?php echo $this->get_field_name('post_id'); ?> " id="<?php echo $this->get_field_id('post_id'); ?> " class="widefat"> <option value=""> </option> <?php foreach ($pages as $page) { echo '<option value="' . esc_attr($page->ID) . '" ' . selected($instance['post_id'], $page->ID, false) . '>' . $page->post_title . '</option>'; } ?> </select> </p> <p><label for="<?php echo $this->get_field_id('title_id'); ?> "><?php _e('Title Field', 'formidable'); ?> :</label> <select name="<?php echo $this->get_field_name('title_id'); ?> " id="<?php echo $this->get_field_id('title_id'); ?> " class="widefat frm_list_items_title_id"> <option value=""> </option> <?php if (isset($title_opts) && $title_opts) { foreach ($title_opts as $title_opt) { if ($title_opt->type != 'checkbox') { ?> <option value="<?php echo $title_opt->id; ?> " <?php selected($instance['title_id'], $title_opt->id); ?> ><?php echo $title_opt->name; ?> </option> <?php } } } ?> </select> </p> <p><label for="<?php echo $this->get_field_id('cat_list'); ?> "><input class="checkbox frm_list_items_cat_list" type="checkbox" <?php checked($instance['cat_list'], true); ?> id="<?php echo $this->get_field_id('cat_list'); ?> " name="<?php echo $this->get_field_name('cat_list'); ?> " value="1" /> <?php _e('List Entries by Category', 'formidable'); ?> </label></p> <div id="<?php echo $this->get_field_id('hide_cat_opts'); ?> " class="frm_list_items_hide_cat_opts <?php echo $instance['cat_list'] ? '' : 'frm_hidden'; ?> "> <p><label for="<?php echo $this->get_field_id('cat_id'); ?> "><?php _e('Category Field', 'formidable'); ?> :</label> <select name="<?php echo $this->get_field_name('cat_id'); ?> " id="<?php echo $this->get_field_id('cat_id'); ?> " class="widefat frm_list_items_cat_id"> <option value=""> </option> <?php if (isset($title_opts) && $title_opts) { foreach ($title_opts as $title_opt) { if (in_array($title_opt->type, array('select', 'radio', 'checkbox'))) { echo '<option value="' . esc_attr($title_opt->id) . '"' . selected($instance['cat_id'], $title_opt->id, false) . '>' . FrmAppHelper::kses($title_opt->name) . '</option>'; } } } ?> </select> </p> <p><label for="<?php echo $this->get_field_id('cat_count'); ?> "><input class="checkbox" type="checkbox" <?php checked($instance['cat_count'], true); ?> id="<?php echo $this->get_field_id('cat_count'); ?> " name="<?php echo $this->get_field_name('cat_count'); ?> " value="1" /> <?php _e('Show Entry Counts', 'formidable'); ?> </label></p> <p><input class="checkbox" type="radio" <?php checked($instance['cat_name'], 1); ?> id="<?php echo $this->get_field_id('cat_name'); ?> " name="<?php echo $this->get_field_name('cat_name'); ?> " value="1" /> <label for="<?php echo $this->get_field_id('cat_name'); ?> "><?php _e('Show Only Category Name', 'formidable'); ?> </label><br/> <input class="checkbox" type="radio" <?php checked($instance['cat_name'], 0); ?> id="<?php echo $this->get_field_id('cat_name'); ?> " name="<?php echo $this->get_field_name('cat_name'); ?> " value="0" /> <label for="<?php echo $this->get_field_id('cat_name'); ?> "><?php _e('Show Entries Beneath Categories', 'formidable'); ?> </label></p> </div> <p><label for="<?php echo $this->get_field_id('limit'); ?> "><?php _e('Entry Limit (leave blank to list all)', 'formidable'); ?> :</label> <input type="text" class="widefat" id="<?php echo $this->get_field_id('limit'); ?> " name="<?php echo $this->get_field_name('limit'); ?> " value="<?php echo esc_attr($instance['limit']); ?> " /></p> <?php }
/** * Override the post content and date format */ private static function post_value_overrides(&$post, $new_post, $editing, $form, $entry, &$dyn_content) { //if empty post content and auto display, then save compiled post content $display_id = $editing ? get_post_meta($post['ID'], 'frm_display_id', true) : (isset($new_post['post_custom']['frm_display_id']) ? $new_post['post_custom']['frm_display_id'] : 0); if (!isset($post['post_content']) && $display_id) { $display = FrmProDisplay::getOne($display_id, false, true); if ($display) { $dyn_content = 'one' == $display->frm_show_count ? $display->post_content : $display->frm_dyncontent; $post['post_content'] = apply_filters('frm_content', $dyn_content, $form, $entry); } } if (isset($post['post_date']) && !empty($post['post_date']) && (!isset($post['post_date_gmt']) || $post['post_date_gmt'] == '0000-00-00 00:00:00')) { // set post date gmt if post date is set $post['post_date_gmt'] = get_gmt_from_date($post['post_date']); } }
public static function get_post_content() { check_ajax_referer('frm_ajax', 'nonce'); $id = (int) $_POST['id']; $display = FrmProDisplay::getOne($id, false, true); if ('one' == $display->frm_show_count) { echo $display->post_content; } else { echo $display->frm_dyncontent; } wp_die(); }