コード例 #1
0
 function get_content($content)
 {
     global $post, $frmpro_display;
     if (!$post) {
         return $content;
     }
     $display = $entry_id = false;
     if (is_single() or is_page()) {
         global $frmdb, $frmprodb;
         //get entry with post_id
         $entry = $frmdb->get_one_record($frmdb->entries, array('post_id' => $post->ID), $fields = 'id,item_key,form_id');
         if ($entry) {
             $display = FrmProDisplay::getAll("form_id=" . $entry->form_id . " and show_count in ('single', 'dynamic', 'calendar')", '', ' LIMIT 1');
             $entry_id = $entry->id;
         }
     }
     if (!$display) {
         $display = $frmpro_display->getAll("insert_loc != 'none' and post_id=" . $post->ID, '', ' LIMIT 1');
     }
     if ($display) {
         global $frm_displayed, $frm_display_position;
         $display->options = maybe_unserialize($display->options);
         if (!isset($display->options['insert_pos'])) {
             $display->options['insert_pos'] = 1;
         }
         if (!$frm_displayed) {
             $frm_displayed = array();
         }
         if (!$frm_display_position) {
             $frm_display_position = array();
         }
         if (!isset($frm_display_position[$display->id])) {
             $frm_display_position[$display->id] = 0;
         }
         $frm_display_position[$display->id]++;
         //make sure this isn't loaded multiple times but still works with themes and plugins that call the_content multiple times
         if (in_the_loop() and !in_array($display->id, (array) $frm_displayed) and $frm_display_position[$display->id] >= (int) $display->options['insert_pos']) {
             $entry_id = (in_array($display->show_count, array('dynamic', 'calendar')) and $display->type == 'display_key') ? $entry_id ? $entry->item_key : $entry_id : $entry_id;
             $frm_displayed[] = $display->id;
             $content = $this->get_display_data($display, $content, $entry_id);
         }
     }
     return $content;
 }
コード例 #2
0
 function post_options($values)
 {
     global $frm_ajax_url;
     $post_types = FrmProAppHelper::get_custom_post_types();
     if (!$post_types) {
         return;
     }
     $post_type = FrmProForm::post_type($values);
     if (function_exists('get_object_taxonomies')) {
         $taxonomies = get_object_taxonomies($post_type);
     }
     $echo = true;
     $show_post_type = false;
     if (isset($values['fields']) and $values['fields']) {
         foreach ($values['fields'] as $field) {
             if (!$show_post_type and $field['post_field'] != '') {
                 $show_post_type = true;
             }
         }
     }
     if ($show_post_type) {
         $values['create_post'] = true;
     }
     $form_id = (int) $_GET['id'];
     $display = FrmProDisplay::getAll("form_id={$form_id} and show_count in ('single', 'dynamic', 'calendar')", '', ' LIMIT 1');
     require FRMPRO_VIEWS_PATH . '/frmpro-forms/post_options.php';
 }
コード例 #3
0
    private static function popup_opts_display_frm_data(array &$opts, $shortcode)
    {
        //'entry_id' => '',  'user_id' => false, 'order' => '',
        $displays = FrmProDisplay::getAll(array(), 'post_title');
        ?>
        <h4 for="frmsc_<?php 
        echo esc_attr($shortcode);
        ?>
_id" class="frm_left_label"><?php 
        _e('Select a view:', 'formidable');
        ?>
</h4>
        <select id="frmsc_<?php 
        echo esc_attr($shortcode);
        ?>
_id">
            <option value=""> </option>
            <?php 
        foreach ($displays as $display) {
            ?>
            <option value="<?php 
            echo esc_attr($display->ID);
            ?>
"><?php 
            echo esc_html($display->post_title);
            ?>
</option>
            <?php 
        }
        ?>
        </select>
        <div class="frm_box_line"></div>
<?php 
        $opts = array('filter' => array('val' => 1, 'label' => __('Filter shortcodes within the view content', 'formidable')), 'drafts' => array('val' => 0, 'label' => __('Entry type(s)', 'formidable'), 'type' => 'select', 'opts' => array('0' => __('Published', 'formidable'), '1' => __('Drafts', 'formidable'), 'both' => __('Published and drafts', 'formidable'))), 'limit' => array('val' => '', 'label' => __('Limit', 'formidable'), 'type' => 'text'), 'page_size' => array('val' => '', 'label' => __('Page size', 'formidable'), 'type' => 'text'), 'order' => array('val' => '', 'label' => __('Entry order', 'formidable'), 'type' => 'select', 'opts' => array('' => __('Default', 'formidable'), 'ASC' => __('Ascending', 'formidable'), 'DESC' => __('Descending', 'formidable'))));
    }
コード例 #4
0
ファイル: FrmListEntries.php プロジェクト: swc-dng/swcsandbox
    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 
    }