GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-plugin-hooks-gravity-flow.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Add Gravity Flow output to GravityView
4  *
5  * @file class-gravityview-plugin-hooks-gravity-flow.php
6  * @package GravityView
7  * @license GPL2+
8  * @author Katz Web Services, Inc.
9  * @link https://gravityview.co
10  * @copyright Copyright 2016, Katz Web Services, Inc.
11  *
12  * @since 1.17
13  */
14 
15 /**
16  * @inheritDoc
17  * @since 1.17
18  */
20 
21  /**
22  * @var string Check for the Gravity Flow constant
23  */
24  protected $constant_name = 'GRAVITY_FLOW_VERSION';
25 
26 
27  /**
28  * Filter the values shown in GravityView frontend
29  *
30  * @since 1.17
31  */
32  function add_hooks() {
33 
34  parent::add_hooks();
35 
36  add_filter( 'gravityview/search/searchable_fields', array( $this, 'modify_search_bar_fields_dropdown'), 10, 2 );
37 
38  }
39 
40 
41  /**
42  * Get the available status choices from Gravity Flow
43  *
44  * @uses Gravity_Flow::get_entry_meta()
45  *
46  * @since 1.17.3
47  *
48  * @param int $form_id
49  * @param string $status_key By default, get all statuses
50  *
51  * @return array
52  */
53  public static function get_status_options( $form_id = 0, $status_key = 'workflow_final_status' ) {
54 
55  if( empty( $form_id ) ) {
56  $form_id = GravityView_View::getInstance()->getFormId();
57  }
58 
59  $entry_meta = gravity_flow()->get_entry_meta( array(), $form_id );
60 
61  return (array) rgars( $entry_meta, $status_key . '/filter/choices' );
62  }
63 
64 
65  /**
66  * Get the list of active Workflow Steps and Workflow Step Statuses
67  *
68  * @since 1.17.3
69  *
70  * @uses Gravity_Flow_API::get_current_step
71  *
72  * @param array $fields Array of searchable fields
73  * @param int $form_id
74  *
75  * @return array Updated Array of searchable fields
76  */
77  public function modify_search_bar_fields_dropdown( $fields, $form_id ) {
78 
79  $GFlow = new Gravity_Flow_API( $form_id );
80 
81  $workflow_steps = $GFlow->get_steps();
82 
83  if( $workflow_steps ) {
84 
85  foreach ( $workflow_steps as $step ) {
86 
87  $step_id = sprintf( 'workflow_step_status_%d', $step->get_id() );
88 
89  $fields[ $step_id ] = array(
90  'label' => sprintf( _x( 'Status: %s', 'Gravity Flow Workflow Step Status', 'gravityview' ), $step->get_name() ),
91  'type' => 'select',
92  );
93  }
94 
95  $fields['workflow_step'] = array(
96  'label' => esc_html__( 'Workflow Step', 'gravityview' ),
97  'type' => 'select',
98  );
99 
100  $fields['workflow_final_status'] = array(
101  'label' => esc_html__( 'Workflow Status', 'gravityview' ),
102  'type' => 'select',
103  );
104  }
105 
106  return $fields;
107  }
108 
109 }
110 
static get_status_options($form_id=0, $status_key= 'workflow_final_status')
Get the available status choices from Gravity Flow.
if(empty($created_by)) $form_id
static getInstance($passed_post=NULL)
Abstract class that makes it easy for plugins and themes to register no-conflict scripts and styles...
modify_search_bar_fields_dropdown($fields, $form_id)
Get the list of active Workflow Steps and Workflow Step Statuses.
add_hooks()
Filter the values shown in GravityView frontend.