Beispiel #1
0
 public static function importCommerceForm($results, $form_id, $data)
 {
     if (isset($data['meta']) && isset($data['meta']['commerce'])) {
         $model = CREDC_Loader::get('MODEL/Main');
         $cdata = $data['meta']['commerce'];
         //cred_log($data);
         if (isset($cdata['product'])) {
             $product = self::$handler->getAbsoluteProduct($cdata['product']);
             if (!$product && isset($results['errors'])) {
                 $results['errors'][] = sprintf(__('Product %s does not exist on this site. You will need to set the CRED Commerce settings for <a href="%s">form %s</a> manually.', 'wp-cred-pay'), $cdata['product'], CRED_CRED::getFormEditLink($form_id), $form_id);
             }
             $cdata['product'] = $product;
         }
         $model->updateFormCustomField($form_id, 'commerce', $cdata);
     }
     return $results;
 }
Beispiel #2
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>';
        }
    }