25 'approve' =>
'gvapprove',
26 'disapprove' =>
'gvdisapprove',
27 'unapprove' =>
'gvunapprove',
40 add_filter(
'gform_add_field_buttons', array( $this,
'add_field_buttons' ) );
42 add_action(
'gform_editor_js_set_default_values', array( $this,
'set_defaults' ) );
47 add_action(
'gform_entries_first_column_actions', array( $this,
'add_entry_approved_hidden_input' ), 1, 5 );
49 add_filter(
'gravityview/metaboxes/tooltips', array( $this,
'tooltips' ) );
52 add_action(
'admin_enqueue_scripts', array( $this,
'add_scripts_and_styles') );
54 add_filter(
'gform_noconflict_scripts', array( $this,
'register_gform_noconflict_script' ) );
55 add_filter(
'gform_noconflict_styles', array( $this,
'register_gform_noconflict_style' ) );
57 add_filter(
'gform_filter_links_entry_list', array( $this,
'filter_links_entry_list' ), 10, 3 );
81 if(
false === apply_filters(
'gravityview/approve_entries/show_filter_links_entry_list',
true,
$form ) ) {
85 $field_filters_approved = array(
92 $field_filters_disapproved = array(
99 $field_filters_unapproved = array(
106 $approved_count = $disapproved_count = $unapproved_count = 0;
109 if( $include_counts ) {
111 $disapproved_count = count(
gravityview_get_entry_ids(
$form[
'id'], array(
'status' =>
'active',
'field_filters' => $field_filters_disapproved ) ) );
112 $unapproved_count = count(
gravityview_get_entry_ids(
$form[
'id'], array(
'status' =>
'active',
'field_filters' => $field_filters_unapproved ) ) );
115 $filter_links[] = array(
116 'id' =>
'gv_approved',
117 'field_filters' => $field_filters_approved,
118 'count' => $approved_count,
122 $filter_links[] = array(
123 'id' =>
'gv_disapproved',
124 'field_filters' => $field_filters_disapproved,
125 'count' => $disapproved_count,
129 $filter_links[] = array(
130 'id' =>
'gv_unapproved',
131 'field_filters' => $field_filters_unapproved,
132 'count' => $unapproved_count,
136 return $filter_links;
148 $tooltips[
'form_gravityview_fields'] = array(
149 'title' => __(
'GravityView Fields',
'gk-gravityview'),
150 'value' => __(
'Allow administrators to approve or reject entries and users to opt-in or opt-out of their entries being displayed.',
'gk-gravityview'),
165 $gravityview_fields = array(
166 'name' =>
'gravityview_fields',
167 'label' =>
'GravityView',
171 'value' => __(
'Approve/Reject',
'gk-gravityview' ),
172 'onclick' =>
"StartAddField('gravityviewapproved_admin');",
173 'data-type' =>
'gravityviewapproved_admin',
174 'data-icon' =>
'dashicons-yes-alt' 178 'value' => __(
'User Opt-In',
'gk-gravityview' ),
179 'onclick' =>
"StartAddField('gravityviewapproved');",
180 'data-type' =>
'gravityviewapproved',
181 'data-icon' =>
'dashicons-media-text',
186 array_push( $field_groups, $gravityview_fields );
188 return $field_groups;
201 case 'gravityviewapproved_admin':
202 field.label =
"<?php echo esc_js( __( 'Approved? (Admin-only)', 'gk-gravityview' ) ); ?>";
204 field.adminLabel =
"<?php echo esc_js( __( 'Approved?', 'gk-gravityview' ) ); ?>";
205 field.adminOnly =
true;
207 field.choices = null;
210 if( !field.choices ) {
211 field.choices =
new Array(
new Choice(
"<?php echo esc_js( GravityView_Entry_Approval_Status::get_label( GravityView_Entry_Approval_Status::APPROVED ) ); ?>") );
214 field.inputs =
new Array();
215 for( var i=1; i<=field.choices.length; i++ ) {
216 field.inputs.push(
new Input(field.id + (i/10), field.choices[i-1].text));
219 field.type =
'checkbox';
220 field.gravityview_approved = 1;
223 case 'gravityviewapproved':
224 field.label =
"<?php echo esc_js( __( 'Show Entry on Website', 'gk-gravityview' ) ); ?>";
226 field.adminLabel =
"<?php echo esc_js( __( 'Opt-In', 'gk-gravityview' ) ); ?>";
227 field.adminOnly =
false;
229 field.choices = null;
232 if( !field.choices ) {
233 field.choices =
new Array(
234 new Choice(
"<?php echo esc_js( __( 'Yes, display my entry on the website', 'gk-gravityview' ) ); ?>")
238 field.inputs =
new Array();
239 for( var i=1; i<=field.choices.length; i++ ) {
240 field.inputs.push(
new Input(field.id + (i/10), field.choices[i-1].text));
243 field.type =
'checkbox';
244 field.gravityview_approved = 1;
277 return GravityView_Entry_Approval::get_approved_column(
$form );
299 if( empty(
$entry[
'id'] ) ) {
305 if( $status_value ) {
306 echo
'<input type="hidden" class="entry_approval" id="entry_approved_'.
$entry[
'id'] .
'" value="' . esc_attr( $status_value ) .
'" />';
322 if( empty(
$form_id ) && class_exists(
'RGFormsModel') ) {
340 $forms = RGFormsModel::get_forms( null,
'title' );
342 if( ! isset(
$forms[0] ) ) {
343 gravityview()->log->error(
'No forms were found' );
349 $form_id = is_object(
$forms[0] ) ? $first_form->id : $first_form[
'id'];
357 if( ! class_exists(
'GFForms' ) ) {
358 gravityview()->log->error(
'GFForms does not exist.' );
364 if( GFForms::get_page() !==
'entry_list' ) {
377 $script_debug = (defined(
'SCRIPT_DEBUG') && SCRIPT_DEBUG) ?
'' :
'.min';
379 wp_enqueue_script(
'gravityview_gf_entries_scripts', plugins_url(
'assets/js/admin-entries-list'.$script_debug.
'.js',
GRAVITYVIEW_FILE), array(
'jquery' ),
GV_PLUGIN_VERSION );
385 wp_localize_script(
'gravityview_gf_entries_scripts',
'gvGlobals', array(
386 'nonce' => wp_create_nonce(
'gravityview_entry_approval'),
387 'admin_nonce' => wp_create_nonce(
'gravityview_admin_entry_approval'),
395 'bulk_message' => $this->bulk_update_message,
399 'column_title' => __(
'Show entry in directory view?',
'gk-gravityview'),
422 'orderby' =>
'is_approved',
423 'order' => (
'desc' === \
GV\Utils::_GET(
'order' ) ) ?
'asc' :
'desc',
426 return add_query_arg(
$args );
447 $hide_if_no_connections = apply_filters(
'gravityview/approve_entries/hide-if-no-connections',
false );
449 if( $hide_if_no_connections ) {
453 if( empty( $connected_views ) ) {
454 $show_approve_column =
false;
463 $show_approve_column = apply_filters(
'gravityview/approve_entries/show-column', $show_approve_column,
$form_id );
465 return $show_approve_column;
469 $scripts[] =
'gravityview_gf_entries_scripts';
470 $scripts[] =
'gravityview_entries_list-popper';
471 $scripts[] =
'gravityview_entries_list-tippy';
476 $styles[] =
'gravityview_entries_list';
477 $styles[] =
'gravityview_entries_list-tippy';
static get_bulk_actions( $form_id)
Get an array of options to be added to the Gravity Forms "Bulk action" dropdown in a "GravityView" op...
const GV_PLUGIN_VERSION(! GravityKit\GravityView\Foundation\meets_min_php_version_requirement(__FILE__, '7.2.0'))
Constants.
add_field_buttons( $field_groups)
Inject new add field buttons in the gravity form editor page.
get_first_form_id()
Get the first form ID from Gravity Forms, sorted in the same order as in the All Forms page...
static update_approved( $entry_id=0, $approved=0, $form_id=0, $approvedcolumn=0)
update_approved function.
static get_popover_placement()
Where should the popover be placed?
static get_approved_column( $form)
Calculate the approve field.input id.
if(gravityview() ->plugin->is_GF_25()) $form
static get_title_attr( $value_or_key)
Get the label for a specific approval value.
register_gform_noconflict_script( $scripts)
add_scripts_and_styles( $hook)
filter_links_entry_list( $filter_links=array(), $form=array(), $include_counts=true)
Add filter links to the Entries page.
get_sort_link( $form_id=0)
Generate a link to sort by approval status.
gravityview_get_connected_views( $form_id, $args=array())
Get the views for a particular form.
static update_approved( $entry_id=0, $approved=2, $form_id=0, $approvedcolumn=0)
update_approved function.
const GRAVITYVIEW_FILE
Full path to the GravityView file "GRAVITYVIEW_FILE" "./gravityview.php".
static get_entry_status( $entry, $value_or_label='label')
Get the approval status for an entry.
tooltips( $tooltips)
Add the GravityView Fields group tooltip.
get_form_id()
Get the form ID of the form currently being displayed.
if(empty( $created_by)) $form_id
static add_entry_approved_hidden_input( $form_id, $field_id, $value, $entry, $query_string)
Add a hidden input that is used in the Javascript to show approved/disapproved entries checkbox...
register_gform_noconflict_style( $styles)
gravityview()
The main GravityView wrapper function.
gravityview_get_entry_ids( $form_id, $search_criteria=array())
Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method.
static get_popover_template()
Get HTML template for a popover used to display approval statuses.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
set_defaults()
At edit form page, set the field Approve defaults.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
show_approve_entry_column( $form_id)
Should the Approve/Reject Entry column be shown in the GF Entries page?
static get_label( $value_or_key)
Get the label for a specific approval value.
new GravityView_Admin_ApproveEntries