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);
 }
 public static function license_box()
 {
     $edd_update = new FrmProEddController();
     $a = FrmAppHelper::simple_get('t', 'sanitize_title', 'general_settings');
     remove_action('frm_before_settings', 'FrmSettingsController::license_box');
     $show_creds_form = !is_multisite() || is_super_admin() || !get_site_option($edd_update->pro_wpmu_store);
     include FrmAppHelper::plugin_path() . '/pro/classes/views/settings/license_box.php';
 }
 public static function manage_columns($columns)
 {
     global $frm_vars, $wpdb;
     $form_id = FrmForm::get_current_form_id();
     $columns[$form_id . '_id'] = 'ID';
     $columns[$form_id . '_item_key'] = esc_html__('Entry Key', 'formidable');
     if (!$form_id) {
         return $columns;
     }
     $form_cols = FrmField::get_all_for_form($form_id, '', 'include');
     foreach ($form_cols as $form_col) {
         if (FrmField::is_no_save_field($form_col->type)) {
             continue;
         }
         if ($form_col->type == 'form' && isset($form_col->field_options['form_select']) && !empty($form_col->field_options['form_select'])) {
             $sub_form_cols = FrmField::get_all_for_form($form_col->field_options['form_select']);
             if ($sub_form_cols) {
                 foreach ($sub_form_cols as $k => $sub_form_col) {
                     if (FrmField::is_no_save_field($sub_form_col->type)) {
                         unset($sub_form_cols[$k]);
                         continue;
                     }
                     $columns[$form_id . '_' . $sub_form_col->field_key . '-_-' . $form_col->id] = FrmAppHelper::truncate($sub_form_col->name, 35);
                     unset($sub_form_col);
                 }
             }
             unset($sub_form_cols);
         } else {
             $col_id = $form_col->field_key;
             if ($form_col->form_id != $form_id) {
                 $col_id .= '-_-form' . $form_col->form_id;
             }
             if (isset($form_col->field_options['separate_value']) && $form_col->field_options['separate_value']) {
                 $columns[$form_id . '_frmsep_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35);
             }
             $columns[$form_id . '_' . $col_id] = FrmAppHelper::truncate($form_col->name, 35);
         }
     }
     $columns[$form_id . '_created_at'] = __('Entry creation date', 'formidable');
     $columns[$form_id . '_updated_at'] = __('Entry update date', 'formidable');
     $columns[$form_id . '_ip'] = 'IP';
     $frm_vars['cols'] = $columns;
     $action = FrmAppHelper::simple_get('frm_action', 'sanitize_title');
     if (FrmAppHelper::is_admin_page('formidable-entries') && in_array($action, array('', 'list', 'destroy'))) {
         add_screen_option('per_page', array('label' => __('Entries', 'formidable'), 'default' => 20, 'option' => 'formidable_page_formidable_entries_per_page'));
     }
     return $columns;
 }
Esempio n. 4
0
 public static function replace_shortcodes($html, $field, $errors = array(), $form = false, $args = array())
 {
     $html = apply_filters('frm_before_replace_shortcodes', $html, $field, $errors, $form);
     $defaults = array('field_name' => 'item_meta[' . $field['id'] . ']', 'field_id' => $field['id'], 'field_plus_id' => '', 'section_id' => '');
     $args = wp_parse_args($args, $defaults);
     $field_name = $args['field_name'];
     $field_id = $args['field_id'];
     $html_id = self::get_html_id($field, $args['field_plus_id']);
     if (FrmField::is_multiple_select($field)) {
         $field_name .= '[]';
     }
     //replace [id]
     $html = str_replace('[id]', $field_id, $html);
     // Remove the for attribute for captcha
     if ($field['type'] == 'captcha') {
         $html = str_replace(' for="field_[key]"', '', $html);
     }
     // set the label for
     $html = str_replace('field_[key]', $html_id, $html);
     //replace [key]
     $html = str_replace('[key]', $field['field_key'], $html);
     //replace [description] and [required_label] and [error]
     $required = FrmField::is_required($field) ? $field['required_indicator'] : '';
     if (!is_array($errors)) {
         $errors = array();
     }
     $error = isset($errors['field' . $field_id]) ? $errors['field' . $field_id] : false;
     //If field type is section heading, add class so a bottom margin can be added to either the h3 or description
     if ($field['type'] == 'divider') {
         if (FrmField::is_option_true($field, 'description')) {
             $html = str_replace('frm_description', 'frm_description frm_section_spacing', $html);
         } else {
             $html = str_replace('[label_position]', '[label_position] frm_section_spacing', $html);
         }
     }
     foreach (array('description' => $field['description'], 'required_label' => $required, 'error' => $error) as $code => $value) {
         self::remove_inline_conditions($value && $value != '', $code, $value, $html);
     }
     //replace [required_class]
     $required_class = FrmField::is_required($field) ? ' frm_required_field' : '';
     $html = str_replace('[required_class]', $required_class, $html);
     //replace [label_position]
     $field['label'] = apply_filters('frm_html_label_position', $field['label'], $field, $form);
     $field['label'] = $field['label'] && $field['label'] != '' ? $field['label'] : 'top';
     $html = str_replace('[label_position]', in_array($field['type'], array('divider', 'end_divider', 'break')) ? $field['label'] : ' frm_primary_label', $html);
     //replace [field_name]
     $html = str_replace('[field_name]', $field['name'], $html);
     //replace [error_class]
     $error_class = isset($errors['field' . $field_id]) ? ' frm_blank_field' : '';
     self::get_more_field_classes($error_class, $field, $field_id, $html);
     if ($field['type'] == 'html' && strpos($html, '[error_class]') === false) {
         // there is no error_class shortcode to use for addign fields
         $html = str_replace('class="frm_form_field', 'class="frm_form_field ' . $error_class, $html);
     }
     $html = str_replace('[error_class]', $error_class, $html);
     //replace [entry_key]
     $entry_key = FrmAppHelper::simple_get('entry', 'sanitize_title');
     $html = str_replace('[entry_key]', $entry_key, $html);
     //replace [input]
     preg_match_all("/\\[(input|deletelink)\\b(.*?)(?:(\\/))?\\]/s", $html, $shortcodes, PREG_PATTERN_ORDER);
     global $frm_vars;
     $frm_settings = FrmAppHelper::get_settings();
     foreach ($shortcodes[0] as $short_key => $tag) {
         $atts = shortcode_parse_atts($shortcodes[2][$short_key]);
         $tag = self::get_shortcode_tag($shortcodes, $short_key, array('conditional' => false, 'conditional_check' => false));
         $replace_with = '';
         if ($tag == 'input') {
             if (isset($atts['opt'])) {
                 $atts['opt']--;
             }
             $field['input_class'] = isset($atts['class']) ? $atts['class'] : '';
             if (isset($atts['class'])) {
                 unset($atts['class']);
             }
             $field['shortcodes'] = $atts;
             ob_start();
             include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/input.php';
             $replace_with = ob_get_contents();
             ob_end_clean();
         } else {
             if ($tag == 'deletelink' && FrmAppHelper::pro_is_installed()) {
                 $replace_with = FrmProEntriesController::entry_delete_link($atts);
             }
         }
         $html = str_replace($shortcodes[0][$short_key], $replace_with, $html);
     }
     if ($form) {
         $form = (array) $form;
         //replace [form_key]
         $html = str_replace('[form_key]', $form['form_key'], $html);
         //replace [form_name]
         $html = str_replace('[form_name]', $form['name'], $html);
     }
     $html .= "\n";
     //Return html if conf_field to prevent loop
     if (isset($field['conf_field']) && $field['conf_field'] == 'stop') {
         return $html;
     }
     //If field is in repeating section
     if ($args['section_id']) {
         $html = apply_filters('frm_replace_shortcodes', $html, $field, array('errors' => $errors, 'form' => $form, 'field_name' => $field_name, 'field_id' => $field_id, 'field_plus_id' => $args['field_plus_id'], 'section_id' => $args['section_id']));
     } else {
         $html = apply_filters('frm_replace_shortcodes', $html, $field, array('errors' => $errors, 'form' => $form));
     }
     self::remove_collapse_shortcode($html);
     if (apply_filters('frm_do_html_shortcodes', true)) {
         $html = do_shortcode($html);
     }
     return $html;
 }
Esempio n. 5
0
    <div id="poststuff" class="metabox-holder">
    <div id="post-body">
        <div class="meta-box-sortables">
        <div class="categorydiv postbox" id="frm-categorydiv">
        <h3 class="hndle"><span><?php 
_e('Global Settings', 'formidable');
?>
</span></h3>
        <div class="inside frm-help-tabs">
        <div id="contextual-help-back"></div>
        <div id="contextual-help-columns">
        <div class="contextual-help-tabs">
        <ul class="frm-category-tabs">
			<?php 
$a = FrmAppHelper::simple_get('t', 'sanitize_title', 'general_settings');
?>
        	<li <?php 
echo $a == 'general_settings' ? 'class="tabs active"' : '';
?>
><a href="#general_settings" class="frm_cursor_pointer"><?php 
_e('General', 'formidable');
?>
</a></li>
			<?php 
foreach ($sections as $sec_name => $section) {
    ?>
				<li <?php 
    echo $a == $sec_name . '_settings' ? 'class="tabs active"' : '';
    ?>
>
<?php

if (isset($_GET['frm_style_setting']) || isset($_GET['flat'])) {
    if (isset($_GET['frm_style_setting'])) {
        extract($_GET['frm_style_setting']['post_content']);
    } else {
        extract($_GET);
    }
    $important_style = isset($important_style) ? $important_style : 0;
    $auto_width = isset($auto_width) ? $auto_width : 0;
    $submit_style = isset($submit_style) ? $submit_style : 0;
    $style_name = FrmAppHelper::simple_get('style_name', 'sanitize_title');
    if (!empty($style_name)) {
        $style_class = $style_name . '.with_frm_style';
    } else {
        $style_class = 'with_frm_style';
    }
} else {
    $style_class = 'frm_style_' . $style->post_name . '.with_frm_style';
    extract($style->post_content);
}
$important = empty($important_style) ? '' : ' !important';
$label_margin = (int) $width + 10;
$minus_icons = FrmStylesHelper::minus_icons();
$arrow_icons = FrmStylesHelper::arrow_icons();
// If left/right label is over a certain size, adjust the field description margin at a different screen size
$temp_label_width = str_replace('px', '', $width);
$change_margin = false;
if ($temp_label_width >= 230) {
    $change_margin = 800 . 'px';
} else {
 public static function is_edit_view_page()
 {
     global $pagenow;
     $post_type = FrmAppHelper::simple_get('post_type', 'sanitize_title');
     return is_admin() && $pagenow == 'edit.php' && $post_type == FrmProDisplaysController::$post_type;
 }
Esempio n. 8
0
<?php

if (!isset($new_field) || !$new_field) {
    ?>
<input type="text" name="<?php 
    echo isset($current_field_id) ? 'field_options[hide_opt_' . $current_field_id . ']' : $field_name;
    ?>
" value="" />
<?php 
    return;
}
if (!isset($is_settings_page)) {
    $is_settings_page = FrmAppHelper::simple_get('frm_action') == 'settings';
    $anything = $is_settings_page ? '' : __('Anything', 'formidable');
}
if ($new_field->type == 'data') {
    if (isset($new_field->field_options['form_select']) && is_numeric($new_field->field_options['form_select'])) {
        $new_entries = FrmEntryMeta::getAll(array('it.field_id' => (int) $new_field->field_options['form_select']), '', ' LIMIT 300', true);
    }
    $new_field->options = array();
    if (isset($new_entries) && !empty($new_entries)) {
        foreach ($new_entries as $ent) {
            $new_field->options[$ent->item_id] = $ent->meta_value;
        }
    }
} else {
    if (isset($new_field->field_options['post_field']) && $new_field->field_options['post_field'] == 'post_status') {
        $new_field->options = FrmProFieldsHelper::get_status_options($new_field);
    }
}
if (isset($new_field->field_options['post_field']) && $new_field->field_options['post_field'] == 'post_category') {
 /**
  * Get fields with specified field value 'frm_cat' = field key/id,
  * 'frm_cat_id' = order position of selected option
  * @since 2.0.6
  */
 private static function maybe_add_cat_query(&$where)
 {
     $frm_cat = FrmAppHelper::simple_get('frm_cat', 'sanitize_title');
     $frm_cat_id = FrmAppHelper::simple_get('frm_cat_id', 'sanitize_title');
     if (!$frm_cat || !isset($_GET['frm_cat_id'])) {
         return;
     }
     $cat_field = FrmField::getOne($frm_cat);
     if (!$cat_field) {
         return;
     }
     $categories = maybe_unserialize($cat_field->options);
     if (isset($categories[$frm_cat_id])) {
         $cat_entry_ids = FrmEntryMeta::getEntryIds(array('meta_value' => $categories[$frm_cat_id], 'fi.field_key' => $frm_cat));
         if ($cat_entry_ids) {
             $where['it.id'] = $cat_entry_ids;
         } else {
             $where['it.id'] = 0;
         }
     }
 }
Esempio n. 10
0
 public static function get_file_name($media_ids, $short = true)
 {
     $value = '';
     foreach ((array) $media_ids as $media_id) {
         if (!is_numeric($media_id)) {
             continue;
         }
         $attachment = get_post($media_id);
         if (!$attachment) {
             continue;
         }
         $url = wp_get_attachment_url($media_id);
         $label = $short ? basename($attachment->guid) : $url;
         $action = FrmAppHelper::simple_get('action', 'sanitize_title');
         $frm_action = FrmAppHelper::simple_get('frm_action', 'sanitize_title');
         if ($frm_action == 'csv' || $action == 'frm_entries_csv') {
             if (!empty($value)) {
                 $value .= ', ';
             }
         } else {
             if (FrmAppHelper::is_admin()) {
                 $url = '<a href="' . esc_url($url) . '">' . $label . '</a>';
                 if (strpos(FrmAppHelper::simple_get('page', 'sanitize_title'), 'formidable') === 0) {
                     $url .= '<br/><a href="' . esc_url(admin_url('media.php') . '?action=edit&attachment_id=' . $media_id) . '">' . __('Edit Uploaded File', 'formidable') . '</a>';
                 }
             } else {
                 if (!empty($value)) {
                     $value .= "<br/>\r\n";
                 }
             }
         }
         $value .= $url;
         unset($media_id);
     }
     return $value;
 }
 public static function include_style_section($atts, $sec)
 {
     extract($atts);
     $current_tab = FrmAppHelper::simple_get('page-tab', 'sanitize_title', 'default');
     include FrmAppHelper::plugin_path() . '/classes/views/styles/_' . $sec['args'] . '.php';
 }
Esempio n. 12
0
        </div><!-- #misc-publishing-actions -->
        <div class="clear"></div>
    </div><!-- #minor-publishing -->

    <div id="major-publishing-actions">
        <div id="delete-action">
            <?php 
echo FrmFormsHelper::delete_trash_link($id, $values['status']);
?>
        </div>

		<div id="publishing-action">
            <span class="spinner"></span>
			<?php 
if ('settings' == FrmAppHelper::simple_get('frm_action', 'sanitize_title')) {
    ?>
			<input type="button" value="<?php 
    esc_attr_e('Update', 'formidable');
    ?>
" class="frm_submit_form frm_submit_settings_btn button-primary button-large" id="frm_submit_side_top" />
            <?php 
} else {
    ?>
    	    <input type="button" value="<?php 
    echo isset($button) ? esc_attr($button) : __('Update', 'formidable');
    ?>
" class="frm_submit_form frm_submit_<?php 
    echo isset($values['ajax_load']) && $values['ajax_load'] ? '' : 'no_';
    ?>
ajax button-primary button-large" id="frm_submit_side_top" />
 /**
  * Get entry object for frm_field_value shortcode
  * Uses user_id, entry, or ip atts to fetch the entry
  *
  * @since 2.0.13
  * @param object $field
  * @param array $atts
  * @return boolean|object $entry
  */
 private static function get_frm_field_value_entry($field, &$atts)
 {
     $query = array('form_id' => $field->form_id);
     if ($atts['user_id']) {
         // make sure we are not getting entries for logged-out users
         $query['user_id'] = (int) FrmAppHelper::get_user_id_param($atts['user_id']);
         $query['user_id !'] = 0;
     }
     if ($atts['entry']) {
         if (!is_numeric($atts['entry'])) {
             $atts['entry'] = FrmAppHelper::simple_get($atts['entry'], 'sanitize_title', $atts['entry']);
         }
         if (empty($atts['entry'])) {
             return;
         }
         if (is_numeric($atts['entry'])) {
             $query[] = array('or' => 1, 'id' => $atts['entry'], 'parent_item_id' => $atts['entry']);
         } else {
             $query[] = array('item_key' => $atts['entry']);
         }
     }
     if ($atts['ip']) {
         $query['ip'] = $atts['ip'] == true ? FrmAppHelper::get_ip_address() : $atts['ip'];
     }
     $entry = FrmDb::get_row('frm_items', $query, 'post_id, id', array('order_by' => 'created_at DESC'));
     return $entry;
 }
 public static function license_box()
 {
     $a = FrmAppHelper::simple_get('t', 'sanitize_title', 'general_settings');
     include FrmAppHelper::plugin_path() . '/classes/views/frm-settings/license_box.php';
 }
 /**
  * @covers FrmAppHelper::simple_get
  * @covers FrmAppHelper::get_simple_request
  */
 function test_simple_get()
 {
     $set_value = '<script></script>test';
     $expected_value = 'test';
     $_GET['test4'] = $set_value;
     $result = FrmAppHelper::simple_get('test4');
     $this->assertEquals($result, $expected_value);
 }
Esempio n. 16
0
                ?>
<p><?php 
                echo wp_kses_post($field['value']);
                ?>
</p>
<input type="hidden" value="<?php 
                echo esc_attr($field['value']);
                ?>
" name="<?php 
                echo esc_attr($field_name);
                ?>
" />
<?php 
            } else {
                if ($field['data_type'] == 'text' && is_numeric($field['form_select'])) {
                    $get_id = FrmAppHelper::simple_get('id');
                    if ($_POST && isset($_POST['item_meta'])) {
                        $observed_field_val = $_POST['item_meta'][$field['hide_field']];
                    } else {
                        if ($get_id) {
                            $observed_field_val = FrmEntryMeta::get_entry_meta_by_field($get_id, $field['hide_field']);
                        }
                    }
                    if (isset($observed_field_val) && is_numeric($observed_field_val)) {
                        $value = FrmEntryMeta::get_entry_meta_by_field($observed_field_val, $field['form_select']);
                    } else {
                        $value = '';
                    }
                    ?>
<input type="text" value="<?php 
                    echo esc_attr($value);
Esempio n. 17
0
    public static function before_table($footer, $form_id = false)
    {
        if (FrmAppHelper::simple_get('page', 'sanitize_title') != 'formidable-entries') {
            return;
        }
        if ($footer) {
            if (apply_filters('frm_show_delete_all', current_user_can('frm_edit_entries'), $form_id)) {
                ?>
<div class="frm_uninstall alignleft actions"><a href="?page=formidable-entries&amp;frm_action=destroy_all<?php 
                echo $form_id ? '&amp;form=' . (int) $form_id : '';
                ?>
" class="button" onclick="return confirm('<?php 
                esc_attr_e('Are you sure you want to permanently delete ALL the entries in this form?', 'formidable');
                ?>
')"><?php 
                _e('Delete ALL Entries', 'formidable');
                ?>
</a></div>
<?php 
            }
            return;
        }
        $page_params = array('frm_action' => 0, 'action' => 'frm_entries_csv', 'form' => $form_id);
        if (!empty($_REQUEST['s'])) {
            $page_params['s'] = sanitize_text_field($_REQUEST['s']);
        }
        if (!empty($_REQUEST['search'])) {
            $page_params['search'] = sanitize_text_field($_REQUEST['search']);
        }
        if (!empty($_REQUEST['fid'])) {
            $page_params['fid'] = (int) $_REQUEST['fid'];
        }
        ?>
        <div class="alignleft actions"><a href="<?php 
        echo esc_url(add_query_arg($page_params, admin_url('admin-ajax.php')));
        ?>
" class="button"><?php 
        _e('Download CSV', 'formidable');
        ?>
</a></div>
        <?php 
    }
Esempio n. 18
0
 /**
  * Add the current_page class to that page in the form nav
  */
 public static function select_current_page($page, $current_page, $action = array())
 {
     if ($current_page != $page) {
         return;
     }
     $frm_action = FrmAppHelper::simple_get('frm_action', 'sanitize_title');
     if (empty($action) || !empty($frm_action) && in_array($frm_action, $action)) {
         echo ' class="current_page"';
     }
 }
Esempio n. 19
0
" />
    <input type="hidden" name="frm_action" value="update_settings" />

        <div class="meta-box-sortables">
        <div class="categorydiv postbox" id="frm-categorydiv">
        <h3 class="hndle"><span><?php 
echo __('Form Settings', 'formidable');
?>
</span></h3>
        <div class="inside frm-help-tabs">
        <div id="contextual-help-back"></div>
        <div id="contextual-help-columns">
        <div class="contextual-help-tabs">
        <ul class="frm-category-tabs frm-form-setting-tabs">
			<?php 
$a = FrmAppHelper::simple_get('t', 'sanitize_title', 'advanced_settings');
?>
        	<li <?php 
echo $a == 'advanced_settings' ? 'class="tabs active"' : '';
?>
><a href="#advanced_settings"><?php 
_e('General', 'formidable');
?>
</a></li>
        	<li <?php 
echo $a == 'email_settings' ? 'class="tabs active"' : '';
?>
><a href="#email_settings"><?php 
_e('Form Actions', 'formidable');
?>
</a></li>
Esempio n. 20
0
 function widget($args, $instance)
 {
     global $wpdb;
     $display = FrmProDisplay::getOne($instance['display_id'], false, true);
     $title = apply_filters('widget_title', empty($instance['title']) && $display ? $display->post_title : $instance['title']);
     $limit = empty($instance['limit']) ? ' LIMIT 100' : " LIMIT {$instance['limit']}";
     $post_id = !$display || empty($display->frm_post_id) ? $instance['post_id'] : $display->frm_post_id;
     $page_url = get_permalink($post_id);
     $order_by = '';
     $cat_field = false;
     if ($display && is_numeric($display->frm_form_id) && !empty($display->frm_form_id)) {
         //Set up order for Entries List Widget
         if (isset($display->frm_order_by) && !empty($display->frm_order_by)) {
             //Get only the first order field and order
             $order_field = reset($display->frm_order_by);
             $order = reset($display->frm_order);
             FrmAppHelper::esc_order_by($order);
             if ($order_field == 'rand') {
                 //If random is set, set the order to random
                 $order_by = ' RAND()';
             } else {
                 if (is_numeric($order_field)) {
                     //If ordering by a field
                     //Get all post IDs for this form
                     $posts = FrmDb::get_results($wpdb->prefix . 'frm_items', array('form_id' => $display->frm_form_id, 'post_id >' => 1, 'is_draft' => 0), 'id, post_id');
                     $linked_posts = array();
                     foreach ($posts as $post_meta) {
                         $linked_posts[$post_meta->post_id] = $post_meta->id;
                     }
                     //Get all field information
                     $o_field = FrmField::getOne($order_field);
                     $query = 'SELECT m.id FROM ' . $wpdb->prefix . 'frm_items m INNER JOIN ';
                     $where = array();
                     //create query with ordered values
                     //if field is some type of post field
                     if (isset($o_field->field_options['post_field']) && $o_field->field_options['post_field']) {
                         if ($o_field->field_options['post_field'] == 'post_custom' && !empty($linked_posts)) {
                             //if field is custom field
                             $where['pm.post_id'] = array_keys($linked_posts);
                             FrmDb::get_where_clause_and_values($where);
                             array_unshift($where['values'], $o_field->field_options['custom_field']);
                             $query .= $wpdb->postmeta . ' pm ON pm.post_id=m.post_id AND pm.meta_key=%s ' . $where['where'] . ' ORDER BY CASE when pm.meta_value IS NULL THEN 1 ELSE 0 END, pm.meta_value ' . $order;
                         } else {
                             if ($o_field->field_options['post_field'] != 'post_category' && !empty($linked_posts)) {
                                 //if field is a non-category post field
                                 $where['p.ID'] = array_keys($linked_posts);
                                 FrmDb::get_where_clause_and_values($where);
                                 $query .= $wpdb->posts . ' p ON p.ID=m.post_id ' . $where['where'] . ' ORDER BY CASE p.' . sanitize_title($o_field->field_options['post_field']) . ' WHEN "" THEN 1 ELSE 0 END, p.' . sanitize_title($o_field->field_options['post_field']) . ' ' . $order;
                             }
                         }
                     } else {
                         //if field is a normal, non-post field
                         $where['em.field_id'] = $o_field->id;
                         FrmDb::get_where_clause_and_values($where);
                         $query .= $wpdb->prefix . 'frm_item_metas em ON em.item_id=m.id ' . $where['where'] . ' ORDER BY CASE when em.meta_value IS NULL THEN 1 ELSE 0 END, em.meta_value' . ($o_field->type == 'number' ? ' +0 ' : '') . ' ' . $order;
                     }
                     //Get ordered values
                     if (!empty($where)) {
                         $metas = $wpdb->get_results($wpdb->prepare($query, $where['values']));
                     } else {
                         $metas = false;
                     }
                     unset($query, $where);
                     if (!empty($metas)) {
                         $order_by_array = array();
                         foreach ($metas as $meta) {
                             $order_by_array[] = $wpdb->prepare('it.id=%d DESC', $meta->id);
                         }
                         $order_by = implode(', ', $order_by_array);
                         unset($order_by_array);
                     } else {
                         $order_by .= 'it.created_at ' . $order;
                     }
                     unset($metas);
                 } else {
                     if (!empty($order_field)) {
                         //If ordering by created_at or updated_at
                         $order_by = 'it.' . sanitize_title($order_field) . ' ' . $order;
                     }
                 }
             }
             if (!empty($order_by)) {
                 $order_by = ' ORDER BY ' . $order_by;
             }
         }
         if (isset($instance['cat_list']) && (int) $instance['cat_list'] == 1 && is_numeric($instance['cat_id'])) {
             if ($cat_field = FrmField::getOne($instance['cat_id'])) {
                 $categories = maybe_unserialize($cat_field->options);
             }
         }
     }
     echo $args['before_widget'];
     if ($title) {
         echo $args['before_title'] . $title . $args['after_title'];
     }
     echo '<ul id="frm_entry_list' . ($display ? $display->frm_form_id : '') . '">' . "\n";
     //if Listing entries by category
     if (isset($instance['cat_list']) && (int) $instance['cat_list'] == 1 && isset($categories) && is_array($categories)) {
         foreach ($categories as $cat_order => $cat) {
             if ($cat == '') {
                 continue;
             }
             echo '<li>';
             if (isset($instance['cat_name']) && (int) $instance['cat_name'] == 1 && $cat_field) {
                 echo '<a href="' . esc_url(add_query_arg(array('frm_cat' => $cat_field->field_key, 'frm_cat_id' => $cat_order), $page_url)) . '">';
             }
             echo $cat;
             if (isset($instance['cat_count']) && (int) $instance['cat_count'] == 1) {
                 echo ' (' . FrmProFieldsHelper::get_field_stats($instance['cat_id'], 'count', false, $cat) . ')';
             }
             if (isset($instance['cat_name']) && (int) $instance['cat_name'] == 1) {
                 echo '</a>';
             } else {
                 $entry_ids = FrmEntryMeta::getEntryIds(array('meta_value like' => $cat, 'fi.id' => $instance['cat_id']));
                 $items = false;
                 if ($entry_ids) {
                     $items = FrmEntry::getAll(array('it.id' => $entry_ids, 'it.form_id' => (int) $display->frm_form_id), $order_by, $limit);
                 }
                 if ($items) {
                     echo '<ul>';
                     foreach ($items as $item) {
                         $url_id = $display->frm_type == 'id' ? $item->id : $item->item_key;
                         $current = FrmAppHelper::simple_get($display->frm_param) == $url_id ? ' class="current_page"' : '';
                         if ($item->post_id) {
                             $entry_link = get_permalink($item->post_id);
                         } else {
                             $entry_link = add_query_arg(array($display->frm_param => $url_id), $page_url);
                         }
                         echo '<li' . $current . '><a href="' . esc_url($entry_link) . '">' . FrmAppHelper::kses($item->name) . '</a></li>' . "\n";
                     }
                     echo '</ul>';
                 }
             }
             echo '</li>';
         }
     } else {
         // if not listing entries by category
         if ($display) {
             $items = FrmEntry::getAll(array('it.form_id' => $display->frm_form_id, 'is_draft' => '0'), $order_by, $limit);
         } else {
             $items = array();
         }
         foreach ($items as $item) {
             $url_id = $display->frm_type == 'id' ? $item->id : $item->item_key;
             $current = FrmAppHelper::simple_get($display->frm_param) == $url_id ? ' class="current_page"' : '';
             echo '<li' . $current . '><a href="' . esc_url(add_query_arg(array($display->frm_param => $url_id), $page_url)) . '">' . FrmAppHelper::kses($item->name) . '</a></li>' . "\n";
         }
     }
     echo "</ul>\n";
     echo $args['after_widget'];
 }
Esempio n. 21
0
echo esc_html($params['template'] ? __('Templates', 'formidable') : __('Forms', 'formidable'));
if (!$params['template'] && current_user_can('frm_edit_forms')) {
    ?>
        <a href="?page=formidable&amp;frm_action=new" class="add-new-h2"><?php 
    _e('Add New', 'formidable');
    ?>
</a>
<?php 
}
?>
    </h2>

<?php 
require FrmAppHelper::plugin_path() . '/classes/views/shared/errors.php';
$wp_list_table->views();
?>

<form id="posts-filter" method="get">
    <input type="hidden" name="page" value="<?php 
echo esc_attr(FrmAppHelper::simple_get('page', 'sanitize_title'));
?>
" />
    <input type="hidden" name="frm_action" value="list" />
<?php 
$wp_list_table->search_box(__('Search', 'formidable'), 'entry');
$wp_list_table->display();
?>
</form>

</div>
 public static function replace_shortcodes($html, $form, $title = false, $description = false, $values = array())
 {
     foreach (array('form_name' => $title, 'form_description' => $description, 'entry_key' => true) as $code => $show) {
         if ($code == 'form_name') {
             $replace_with = $form->name;
         } else {
             if ($code == 'form_description') {
                 $replace_with = FrmAppHelper::use_wpautop($form->description);
             } else {
                 if ($code == 'entry_key' && isset($_GET) && isset($_GET['entry'])) {
                     $replace_with = FrmAppHelper::simple_get('entry');
                 } else {
                     $replace_with = '';
                 }
             }
         }
         FrmFieldsHelper::remove_inline_conditions(FrmAppHelper::is_true($show) && $replace_with != '', $code, $replace_with, $html);
     }
     //replace [form_key]
     $html = str_replace('[form_key]', $form->form_key, $html);
     //replace [frmurl]
     $html = str_replace('[frmurl]', FrmFieldsHelper::dynamic_default_values('frmurl'), $html);
     if (strpos($html, '[button_label]')) {
         add_filter('frm_submit_button', 'FrmFormsHelper::submit_button_label', 1);
         $replace_with = apply_filters('frm_submit_button', $title, $form);
         $html = str_replace('[button_label]', $replace_with, $html);
     }
     $html = apply_filters('frm_form_replace_shortcodes', $html, $form, $values);
     if (strpos($html, '[if back_button]')) {
         $html = preg_replace('/(\\[if\\s+back_button\\])(.*?)(\\[\\/if\\s+back_button\\])/mis', '', $html);
     }
     if (strpos($html, '[if save_draft]')) {
         $html = preg_replace('/(\\[if\\s+save_draft\\])(.*?)(\\[\\/if\\s+save_draft\\])/mis', '', $html);
     }
     if (apply_filters('frm_do_html_shortcodes', true)) {
         $html = do_shortcode($html);
     }
     return $html;
 }
 public static function admin_js()
 {
     $version = FrmAppHelper::plugin_version();
     FrmAppHelper::load_admin_wide_js(false);
     wp_register_script('formidable_admin', FrmAppHelper::plugin_url() . '/js/formidable_admin.js', array('formidable_admin_global', 'formidable', 'jquery', 'jquery-ui-core', 'jquery-ui-draggable', 'jquery-ui-sortable', 'bootstrap_tooltip', 'bootstrap-multiselect'), $version, true);
     wp_register_style('formidable-admin', FrmAppHelper::plugin_url() . '/css/frm_admin.css', array(), $version);
     wp_register_script('bootstrap_tooltip', FrmAppHelper::plugin_url() . '/js/bootstrap.min.js', array('jquery'), '3.3.4');
     // load multselect js
     wp_register_script('bootstrap-multiselect', FrmAppHelper::plugin_url() . '/js/bootstrap-multiselect.js', array('jquery', 'bootstrap_tooltip'), '0.9.8', true);
     $page = FrmAppHelper::simple_get('page', 'sanitize_title');
     $post_type = FrmAppHelper::simple_get('post_type', 'sanitize_title');
     global $pagenow;
     if (strpos($page, 'formidable') === 0 || $pagenow == 'edit.php' && $post_type == 'frm_display') {
         wp_enqueue_script('admin-widgets');
         wp_enqueue_style('widgets');
         wp_enqueue_script('formidable');
         wp_enqueue_script('formidable_admin');
         FrmAppHelper::localize_script('admin');
         wp_enqueue_style('formidable-admin');
         add_thickbox();
         wp_register_script('formidable-editinplace', FrmAppHelper::plugin_url() . '/js/jquery/jquery.editinplace.packed.js', array('jquery'), '2.3.0');
     } else {
         if ($pagenow == 'post.php' || $pagenow == 'post-new.php' && $post_type == 'frm_display') {
             if (isset($_REQUEST['post_type'])) {
                 $post_type = sanitize_title($_REQUEST['post_type']);
             } else {
                 if (isset($_REQUEST['post']) && absint($_REQUEST['post'])) {
                     $post = get_post(absint($_REQUEST['post']));
                     if (!$post) {
                         return;
                     }
                     $post_type = $post->post_type;
                 } else {
                     return;
                 }
             }
             if ($post_type == 'frm_display') {
                 wp_enqueue_script('jquery-ui-draggable');
                 wp_enqueue_script('formidable_admin');
                 wp_enqueue_style('formidable-admin');
                 FrmAppHelper::localize_script('admin');
             }
         } else {
             if ($pagenow == 'widgets.php') {
                 FrmAppHelper::load_admin_wide_js();
             }
         }
     }
 }
Esempio n. 24
0
 public static function preview()
 {
     do_action('frm_wp');
     global $frm_vars;
     $frm_vars['preview'] = true;
     if (!defined('ABSPATH') && !defined('XMLRPC_REQUEST')) {
         global $wp;
         $root = dirname(dirname(dirname(dirname(__FILE__))));
         include_once $root . '/wp-config.php';
         $wp->init();
         $wp->register_globals();
     }
     self::register_pro_scripts();
     header('Content-Type: text/html; charset=' . get_option('blog_charset'));
     $key = FrmAppHelper::simple_get('form', 'sanitize_title');
     if ($key == '') {
         $key = FrmAppHelper::get_post_param('form', '', 'sanitize_title');
     }
     $form = FrmForm::getAll(array('form_key' => $key), '', 1);
     if (empty($form)) {
         $form = FrmForm::getAll(array(), '', 1);
     }
     require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
     wp_die();
 }