Esempio n. 1
0
 public function getCustomField($get, $post)
 {
     if (!current_user_can(CRED_CAPABILITY)) {
         wp_die();
     }
     if (!isset($get['_wpnonce']) || !wp_verify_nonce($get['_wpnonce'], '_cred_customfield')) {
         echo "wpnonce error";
         die;
     }
     $popup_close = 'false';
     $fm = CRED_Loader::get('MODEL/Fields');
     $fields = $fm->getTypesDefaultFields(true);
     if (isset($post['field']) && is_array($post['field'])) {
         $fm = CRED_Loader::get('MODEL/Fields');
         $fm->setCustomField($post['field']);
         $popup_close = 'true';
     }
     if (isset($get['field_name'])) {
         $field_name = sanitize_text_field($get['field_name']);
         $post_type = isset($get['post_type']) ? $get['post_type'] : 'post';
         if (isset($get['_reset_']) && '1' == $get['_reset_']) {
             $fm->ignoreCustomFields($post_type, array($field_name), 'reset');
             $popup_close = 'true';
             $data = array();
             $field_type = '';
             //__('Not Set','wp-cred');
         } else {
             $data = $fm->getCustomField($post_type, $field_name);
             if (isset($get['field'])) {
                 $field_type = $get['field'];
                 if (isset($data['type']) && $data['type'] != $field_type) {
                     $data = array();
                 }
             } else {
                 $field_type = isset($data['type']) ? $data['type'] : 'textfield';
             }
         }
         echo CRED_Loader::tpl('custom-field-setup', array('field' => $fields[$field_type], 'data' => $data, 'popup_close' => $popup_close, 'field_name' => $field_name, 'post_type' => $post_type, 'url' => CRED_CRED::route('/Generic_Fields/getCustomField?post_type=' . $post_type . '&field_name=' . $field_name . '&_wpnonce=' . wp_create_nonce('_cred_customfield')), 'fields' => $fields));
     }
     die;
 }
Esempio n. 2
0
            
            if (action=='export-selected')
            {
                // nothing selected to export
                if (!checked.length)
                {
                    event.preventDefault();
                    return false;
                }
                    
                // prevent action from submission, it conflicts with ajax action param
                $('form#list select[name="action"]').attr('disabled','disabled');
                event.preventDefault();

                $.fileDownload('<?php 
echo CRED_CRED::route('/Forms/exportSelected?type=user&ajax=1');
?>
',{
                    successCallback:function() {
                        $('form#list select[name="action"]').removeAttr('disabled');
                        overlay_loader.hide();
                    },
                    beforeDownloadCallback:function() {
                        overlay_loader.css({'background-position':'center '+(0.5*$win.height()+$win.scrollTop())+'px'}).show();
                    },
                    failCallback:function() {
                        $('form#list select[name="action"]').removeAttr('disabled');
                        overlay_loader.hide();
                        cred.gui.Popups.alert({
                            message:'<?php 
echo esc_js(__('An error occurred please try again', 'wp-cred'));
</h3>
        <i title='<?php 
echo esc_attr(__('Close', 'wp-cred'));
?>
' class='icon-remove cred-close-button cred-cred-cancel-close'></i>
        </div>
        <div id="cred-generic-shortcodes-box-inner" class="cred-popup-inner">
        <?php 
foreach ($gfields as $type => $field) {
    //Removing next row in order to fix this: https://icanlocalize.basecamphq.com/projects/7393061-toolset/todo_items/187372012/comments
    //if ($field['type']=='audio'||$field['type']=='video') continue;
    echo "<a href='" . CRED_CRED::route('/Generic_Fields/getField?field=' . $type . '&TB_iframe=true&width=500&height=450') . "' class='button thickbox cred_field_add' title='" . esc_js(sprintf(__('Insert Field type "%s"', 'wp-cred'), $field['title'])) . "'>" . $field['title'] . "</a>";
}
?>
            <a href='javascript:;' onclick="var _href='<?php 
echo CRED_CRED::route('/Generic_Fields/getField?field=conditional_group');
?>
&post_type='+jQuery('#cred_post_type').val()+'&TB_iframe=true&ampwidth=500&ampheight=450';this.href=_href;return true;" class='button thickbox cred_field_add' title='<?php 
echo esc_attr(sprintf(__('Insert Field type "%s"', 'wp-cred'), __('Conditional Group', 'wp-cred')));
?>
'><?php 
_e('Conditional Group', 'wp-cred');
?>
</a>
        </div>
        <a class='cred-help-link' style='' href='<?php 
echo $help['generic_fields_settings']['link'];
?>
' target='<?php 
echo $help_target;
?>
Esempio n. 4
0
            
            if (action=='export-selected')
            {
                // nothing selected to export
                if (!checked.length)
                {
                    event.preventDefault();
                    return false;
                }
                    
                // prevent action from submission, it conflicts with ajax action param
                $('form#list select[name="action"]').attr('disabled','disabled');
                event.preventDefault();

                $.fileDownload('<?php 
echo CRED_CRED::route('/Forms/exportSelected?ajax=1');
?>
',{
                    successCallback:function() {
                        $('form#list select[name="action"]').removeAttr('disabled');
                        overlay_loader.hide();
                    },
                    beforeDownloadCallback:function() {
                        overlay_loader.css({'background-position':'center '+(0.5*$win.height()+$win.scrollTop())+'px'}).show();
                    },
                    failCallback:function() {
                        $('form#list select[name="action"]').removeAttr('disabled');
                        overlay_loader.hide();
                        cred.gui.Popups.alert({
                            message:'<?php 
echo esc_js(__('An error occurred please try again', 'wp-cred'));
Esempio n. 5
0
 /**
  * method forms the data output style 
  * 
  */
 function display_rows()
 {
     $path = admin_url('admin.php') . '?page=CRED_Fields';
     //Get the records registered in the prepare_items method
     $records = $this->items;
     $cred_fields = CRED_Loader::get('MODEL/Fields')->getCustomFields($this->_post_type);
     $default_types = CRED_Loader::get('MODEL/Fields')->getTypesDefaultFields(true);
     //Get the columns registered in the get_columns and get_sortable_columns methods
     list($columns, $hidden) = $this->get_column_info();
     //Loop for each record
     if (empty($records)) {
         return false;
     }
     foreach ($records as $rec) {
         //Open the line
         $field_id = $rec;
         $ignore = false;
         $credfieldtype = '<strong>' . __('Not Set', 'wp-cred') . '</strong>';
         $credfieldname = '<strong>' . __('Not Set', 'wp-cred') . '</strong>';
         if (isset($cred_fields[$rec])) {
             $credfieldtype = $cred_fields[$rec]['type'];
             $credfieldname = isset($default_types[$cred_fields[$rec]['type']]) ? $default_types[$cred_fields[$rec]['type']]['title'] : $credfieldname;
             if (isset($cred_fields[$rec]['_cred_ignore'])) {
                 $ignore = true;
             }
         }
         // set api ajax paths
         $setfieldpath = CRED_CRED::route('/Generic_Fields/getCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield') . '&TB_iframe=true&width=600&height=450');
         $editfieldpath = CRED_CRED::route('/Generic_Fields/getCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield') . '&TB_iframe=true&width=600&height=450');
         $removefieldpath = CRED_CRED::route('/Generic_Fields/removeCustomField' . '?post_type=' . $this->_post_type . '&field_name=' . $rec . '&_wpnonce=' . wp_create_nonce('_cred_customfield'));
         echo '<tr id="' . $field_id . '">';
         foreach ($columns as $column_name => $column_display_name) {
             //Style attributes for each col
             $class = "class='{$column_name} column-{$column_name}'";
             $style = "";
             if (in_array($column_name, $hidden)) {
                 $style = ' style="display:none;"';
             }
             $attributes = $class . $style;
             //Display the cell
             switch ($column_name) {
                 case "cred_field_name":
                     echo '<td ' . $attributes . '><strong><a class="thickbox" href="' . $editfieldpath . '" title="" title="' . __('Edit', 'wp-cred') . '">' . stripslashes($rec) . '</a>';
                     echo '</td>';
                     break;
                 case "cred_cred_type":
                     echo '<td ' . $attributes . '><span class="cred-field-type" style="margin-right:15px">' . $credfieldname . '</span></td>';
                     break;
                 case "cred_actions":
                     $actions = array('<a style="margin-right:10px" class="cred-field-actions _cred-field-set thickbox" href="' . $setfieldpath . '" title=\'' . esc_attr(__('Set field type', 'wp-cred')) . '\'>' . __('Add', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-edit thickbox" href="' . $editfieldpath . '" title=\'' . esc_attr(__('Edit field settings', 'wp-cred')) . '\'>' . __('Edit', 'wp-cred') . '</a>', '<a style="margin-right:10px" class="cred-field-actions _cred-field-remove" href="' . $removefieldpath . '" title=\'' . esc_attr(__('Remove this field as a CRED field type', 'wp-cred')) . '\'>' . __('Remove', 'wp-cred') . '</a>');
                     $act_out = implode('', $actions);
                     echo '<td ' . $attributes . '>' . $act_out . '</td>';
                     break;
             }
         }
         echo '</tr>';
     }
 }
Esempio n. 6
0
    /**
     * method forms the data output style 
     * 
     */
    function display_rows()
    {
        $post_type = CRED_USER_FORMS_CUSTOM_POST_NAME;
        $path = admin_url('admin.php') . '?page=CRED_User_Forms';
        //$editpath = admin_url('post.php').'?action=edit';
        //Get the records registered in the prepare_items method
        $records = $this->items;
        //Get the columns registered in the get_columns and get_sortable_columns methods
        list($columns, $hidden) = $this->get_column_info();
        //Loop for each record
        if (empty($records)) {
            return false;
        }
        $form_types = apply_filters('cred_admin_form_type_options', array("new" => __('Create user', 'wp-cred'), "edit" => __('Edit user', 'wp-cred')), '', null);
        foreach ($records as $rec) {
            $settings = isset($rec->meta) ? maybe_unserialize($rec->meta) : false;
            $editlink = CRED_CRED::getFormEditLink($rec->ID);
            //Open the line
            echo '<tr id="record_' . $rec->ID . '">';
            $checkbox_id = "checkbox_" . $rec->ID;
            $checkbox = "<input type='checkbox' name='checked[]' value='" . $rec->ID . "' id='" . $checkbox_id . "' /><label class='screen-reader-text' for='" . $checkbox_id . "' >" . __('Select') . " " . $rec->post_title . "</label>";
            $exportpath = CRED_CRED::route('/Forms/exportForm' . "?form={$rec->ID}&type=user&_wpnonce=" . wp_create_nonce('cred-export-' . $rec->ID));
            foreach ($columns as $column_name => $column_display_name) {
                //Style attributes for each col
                $class = "class='{$column_name} column-{$column_name}'";
                $style = "";
                if (in_array($column_name, $hidden)) {
                    $style = ' style="display:none;"';
                }
                $attributes = $class . $style;
                //Display the cell
                switch ($column_name) {
                    case "cb":
                        echo "<th scope='row' class='check-column'>{$checkbox}</th>";
                        break;
                    case "cred_form_name":
                        //$editlink = $editpath."&post=$rec->ID";
                        //$onclick_delete="if(confirm('".esc_js( sprintf( __( "Are you sure that you want to delete this form '%s'?\n\n Click [Cancel] to stop, [OK] to delete.", 'wp-cred' ), $rec->post_title ) ) . "' ) ) { return true;}return false;";
                        $onclick_clone = "var cred_form_title=prompt('" . esc_js(__('Title of New Form ', 'wp-cred')) . "','" . $rec->post_title . ' Copy' . "'); if (cred_form_title) {this.href+='&cred_form_title='+encodeURI(cred_form_title); return true;} else return false;";
                        $actions = array();
                        $actions['edit'] = '<a class="submitedit" href="' . $editlink . '" title=\'' . esc_attr(__('Edit', 'wp-cred')) . '\'>' . __('Edit', 'wp-cred') . '</a>';
                        $actions['clone'] = "<a class='submitclone' href='" . wp_nonce_url($path . "&action=clone&amp;id={$rec->ID}", 'clone-form_' . $rec->ID) . "' onclick=\"" . $onclick_clone . "\">" . __('Clone', 'wp-cred') . "</a>";
                        $actions['export'] = '<a class="submitexport" target="_blank" href="' . $exportpath . '" title=\'' . esc_attr(__('Export', 'wp-cred')) . '\'>' . __('Export', 'wp-cred') . '</a>';
                        //$actions['delete'] = "<a class='submitdelete' href='".wp_nonce_url( $path."&action=delete&amp;id=$rec->ID", 'delete-form_'.$rec->ID )."' onclick=\"".$onclick_delete."\">" . __( 'Delete', 'wp-cred') . "</a>";
                        $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($path . "&action=delete&amp;id={$rec->ID}", 'delete-form_' . $rec->ID) . "'>" . __('Delete', 'wp-cred') . "</a>";
                        echo '<td ' . $attributes . '><strong><a href="' . $editlink . '" title=\'' . esc_attr(__('Edit', 'wp-cred')) . '\'>' . stripslashes($rec->post_title) . '</a>&nbsp;&nbsp;(ID:&nbsp;' . $rec->ID . ')</strong>';
                        echo $this->row_actions($actions);
                        echo '</td>';
                        break;
                    case "cred_form_type":
                        if ($settings && !empty($settings->form['type']) && isset($form_types[stripslashes($settings->form['type'])])) {
                            echo '<td ' . $attributes . '>' . $form_types[stripslashes($settings->form['type'])] . '</td>';
                        } else {
                            echo '<td ' . $attributes . '><strong>' . __('Not Set', 'wp-cred') . '</strong></td>';
                        }
                        break;
                    case "cred_user_role":
                        $r = empty($settings->form['user_role']) ? __('All', 'wp-cred') : $settings->form['user_role'];
                        echo '<td ' . $attributes . '>' . $r . '</td>';
                        break;
                    case "cred_post_type":
                        //                        if ($settings && !empty($settings->post['post_type'])) {
                        //                            $pt = stripslashes($settings->post['post_type']);
                        //                            $pto = get_post_type_object($pt);
                        //                            if ($pto) {
                        //                                $ptname = $pto->labels->name;
                        //                            } else {
                        //                                $ptname = $pt . '&nbsp&nbsp;<span style="color:red">(' . __('NOT FOUND', 'wp-cred') . ')</span>';
                        //                            }
                        //                            echo '<td ' . $attributes . '>' . $ptname . '</td>';
                        //                        } else
                        echo '<td ' . $attributes . '><strong>' . __('User', 'wp-cred') . '</strong></td>';
                        break;
                        // display extra columns (if hooked)
                    // display extra columns (if hooked)
                    default:
                        ?>
                        <td <?php 
                        echo $attributes;
                        ?>
><?php 
                        do_action('manage_posts_custom_column', $column_name, $rec->ID);
                        do_action("manage_{$post_type}_posts_custom_column", $column_name, $rec->ID);
                        ?>
</td>
                        <?php 
                        break;
                }
            }
            echo '</tr>';
        }
    }
Esempio n. 7
0
                                                        domRef: '#notification_user_required-<?php 
echo $ii;
?>
' 
                                                    },
                                                    {
                                                        action: 'validateSection' 
                                                    }
                                                ]
                                            }
                                        }, 
                                        event: 'init', 
                                        action: {
                                            suggest: {
                                                url: '<?php 
echo CRED_CRED::route('/Forms/suggestUserMail');
?>
', 
                                                param: 'user', 
                                                loader: '#cred_notification_user_mail_suggest_loader_<?php 
echo $ii;
?>
'
                                            }                                            
                                         }
                                      }"
                        type="text" class="cred_mail_to_user" style="width:200px" name="_cred[notification][notifications][<?php 
echo $ii;
?>
][to][wp_user][user]" placeholder="<?php 
echo esc_attr(__('-- Choose user --', 'wp-cred'));