15 if ( ! defined(
'ABSPATH' ) ) {
33 if ( class_exists(
'GFFormsModel' ) ) {
34 return GFFormsModel::get_form_meta(
$form_id );
37 if ( class_exists(
'GFAPI' ) ) {
77 public static function has_cap( $caps =
'', $object_id = null, $user_id = null ) {
91 if ( class_exists(
'GF_Fields' ) ) {
93 $field_object = GF_Fields::create(
$field );
96 $field_array = get_object_vars( $field_object );
116 $default_params = array(
117 'post_type' =>
'gravityview',
118 'posts_per_page' => -1,
119 'post_status' =>
'publish',
122 $params = wp_parse_args(
$args, $default_params );
128 $views_params = apply_filters(
'gravityview/get_all_views/params', $params );
130 $views = get_posts( $views_params );
167 $product_fields = self::get_product_field_types();
169 $fields = GFAPI::get_fields_by_type(
$form, $product_fields );
171 return empty( $fields ) ? false : $fields;
185 $product_fields = apply_filters(
'gform_product_field_types', array(
'option',
'quantity',
'product',
'total',
'shipping',
'calculation',
'price',
'hiddenproduct',
'singleproduct',
'singleshipping' ) );
187 return $product_fields;
203 if ( ! is_array(
$entry ) ) {
207 $has_transaction_data =
false;
209 $payment_meta = array(
'payment_status',
'payment_date',
'transaction_id',
'payment_amount',
'payment_method' );
211 foreach ( $payment_meta as $meta ) {
215 if ( is_numeric( $has_transaction_data ) && ( ! floatval( $has_transaction_data ) > 0 ) ) {
216 $has_transaction_data =
false;
220 if ( ! empty( $has_transaction_data ) ) {
225 return (
bool) $has_transaction_data;
238 $search_criteria = array(
239 'field_filters' => array(
241 'key' =>
'gravityview_unique_id',
259 $form_id = apply_filters(
'gravityview/common/get_entry_id_from_slug/form_id', 0 );
261 $results = GFAPI::get_entries( intval(
$form_id ), $search_criteria, null, $paging );
263 $result = ( ! empty( $results ) && ! empty( $results[0][
'id'] ) ) ? $results[0][
'id'] : null;
283 public static function get_forms_as_options( $active =
true, $trash =
false, $sort_column =
'id', $sort_dir =
'ASC' ) {
285 $forms = GFAPI::get_forms( $active, $trash, $sort_column, $sort_dir );
292 '' => esc_html__(
'Select a Form',
'gk-gravityview' ),
296 $options[ (int) $form[
'id'] ] = esc_html( $form[
'title'] );
317 public static function get_forms( $active =
true, $trash =
false, $order_by =
'id', $order =
'ASC' ) {
319 if ( ! class_exists(
'GFAPI' ) ) {
323 if (
'any' === $active ) {
324 $active_forms = GFAPI::get_forms(
true, $trash );
325 $inactive_forms = GFAPI::get_forms(
false, $trash );
326 $forms = array_merge( array_filter( $active_forms ), array_filter( $inactive_forms ) );
328 $forms = GFAPI::get_forms( $active, $trash );
331 $forms = wp_list_sort(
$forms, $order_by, $order,
true );
344 public static function get_form_fields(
$form =
'', $add_default_properties =
false, $include_parent_field =
true ) {
346 if ( ! is_array(
$form ) ) {
351 $has_product_fields =
false;
352 $has_post_fields =
false;
356 if ( $include_parent_field || empty( $field[
'inputs'] ) ) {
357 $fields[
"{$field['id']}" ] = array(
358 'label' => \
GV\Utils::get( $field,
'label' ),
360 'type' => \
GV\Utils::get( $field,
'type' ),
361 'adminLabel' => \
GV\Utils::get( $field,
'adminLabel' ),
362 'adminOnly' => \
GV\Utils::get( $field,
'adminOnly' ),
366 if ( $add_default_properties && ! empty( $field[
'inputs'] ) ) {
367 foreach ( $field[
'inputs'] as $input ) {
369 if ( ! empty( $input[
'isHidden'] ) ) {
377 if (
'email' === $field[
'type'] &&
false === strpos( $input[
'id'],
'.' ) ) {
380 $fields[
"{$input['id']}" ] = array(
381 'label' => \
GV\Utils::get( $input,
'label' ),
382 'customLabel' => \
GV\Utils::get( $input,
'customLabel' ),
384 'type' => \
GV\Utils::get( $field,
'type' ),
385 'adminLabel' => \
GV\Utils::get( $field,
'adminLabel' ),
386 'adminOnly' => \
GV\Utils::get( $field,
'adminOnly' ),
391 if ( GFCommon::is_product_field( $field[
'type'] ) ) {
392 $has_product_fields =
true;
395 if ( GFCommon::is_post_field( $field ) ) {
396 $has_post_fields =
true;
404 if ( $has_post_fields ) {
405 $fields[
'post_id'] = array(
406 'label' => __(
'Post ID',
'gk-gravityview' ),
411 if ( $has_product_fields ) {
415 foreach ( $payment_fields as $payment_field ) {
418 if ( isset( $fields[
"{$payment_field->name}" ] ) || GFCommon::get_fields_by_type(
$form, $payment_field->name ) ) {
422 $fields[
"{$payment_field->name}" ] = array(
423 'label' => $payment_field->label,
424 'desc' => $payment_field->description,
425 'type' => $payment_field->name,
437 $fields = apply_filters(
'gravityview/common/get_form_fields', $fields,
$form, $include_parent_field );
451 $extra_fields = GFFormsModel::get_entry_meta(
$form_id );
455 foreach ( $extra_fields as $key =>
$field ) {
456 if ( ! empty( $only_default_column ) && ! empty(
$field[
'is_default_column'] ) ) {
457 $fields[ $key ] = array(
458 'label' =>
$field[
'label'],
459 'type' =>
'entry_meta',
478 if ( ! class_exists(
'GFFormsModel' ) ) {
482 return GFFormsModel::search_lead_ids(
$form_id, $search_criteria );
496 $search_criteria_defaults = array(
497 'search_criteria' => null,
500 'cache' => ( isset( $passed_criteria[
'cache'] ) ? (
bool) $passed_criteria[
'cache'] :
true ),
501 'context_view_id' => null,
504 $criteria = wp_parse_args( $passed_criteria, $search_criteria_defaults );
506 if ( ! empty(
$criteria[
'search_criteria'][
'field_filters'] ) && is_array(
$criteria[
'search_criteria'][
'field_filters'] ) ) {
507 foreach (
$criteria[
'search_criteria'][
'field_filters'] as &$filter ) {
509 if ( ! is_array( $filter ) ) {
514 $filter[
'operator'] = empty( $filter[
'operator'] ) ?
'contains' : $filter[
'operator'];
521 $filter[
'operator'] = apply_filters(
'gravityview_search_operator', $filter[
'operator'], $filter );
525 if ( count(
$criteria[
'search_criteria'][
'field_filters'] ) === 1 && array_key_exists(
'mode',
$criteria[
'search_criteria'][
'field_filters'] ) ) {
526 unset(
$criteria[
'search_criteria'][
'field_filters'][
'mode'] );
534 foreach ( array(
'start_date',
'end_date' ) as $key ) {
536 if ( ! empty(
$criteria[
'search_criteria'][ $key ] ) ) {
539 $date = date_create(
$criteria[
'search_criteria'][ $key ] );
543 $criteria[
'search_criteria'][ $key ] = $date->format(
'Y-m-d H:i:s' );
546 '{key} Date format not valid:',
554 unset(
$criteria[
'search_criteria'][ $key ] );
559 if ( empty(
$criteria[
'context_view_id'] ) ) {
565 } elseif (
'delete' === GFForms::get(
'action' ) ) {
566 $criteria[
'context_view_id'] = isset( $_GET[
'view_id'] ) ? intval( $_GET[
'view_id'] ) : null;
595 public static function get_entries( $form_ids = null, $passed_criteria = null, &$total = null ) {
597 gravityview()->log->notice(
'\GVCommon::get_entries is deprecated. Use \GV\View::get_entries instead.' );
600 $criteria = self::calculate_get_entries_criteria( $passed_criteria, $form_ids );
602 gravityview()->log->debug(
'[gravityview_get_entries] Final Parameters', array(
'data' =>
$criteria ) );
608 add_filter(
'gform_is_encrypted_field',
'__return_false' );
617 if ( ! is_null( $total ) ) {
618 $total = GFAPI::count_entries( $form_ids,
$criteria[
'search_criteria'] );
625 if ( is_null( $return ) && class_exists(
'GFAPI' ) && ( is_numeric( $form_ids ) || is_array( $form_ids ) ) ) {
637 $entries = apply_filters_ref_array(
'gravityview_before_get_entries', array( null,
$criteria, $passed_criteria, &$total ) );
648 'error' =>
$entries->get_error_message(),
654 remove_filter(
'gform_is_encrypted_field',
'__return_false' );
659 if ( ! empty(
$criteria[
'cache'] ) && isset( $Cache ) ) {
670 remove_filter(
'gform_is_encrypted_field',
'__return_false' );
681 $return = apply_filters_ref_array(
'gravityview_entries', array( $return,
$criteria, $passed_criteria, &$total ) );
697 public static function get_entry_id( $entry_id_or_slug =
'', $force_allow_ids =
false ) {
705 $custom_slug = apply_filters(
'gravityview_custom_entry_slug',
false );
713 $custom_slug_id_access = $force_allow_ids || apply_filters(
'gravityview_custom_entry_slug_allow_id',
false );
719 if ( $custom_slug ) {
721 $entry_id = self::get_entry_id_from_slug( $entry_id_or_slug );
731 if (
false === $custom_slug ||
true === $custom_slug_id_access ) {
732 $entry_id = $entry_id_or_slug;
749 public static function get_entry(
$entry_slug, $force_allow_ids =
false, $check_entry_display =
true, $view = null ) {
751 if ( ! class_exists(
'GFAPI' ) || empty(
$entry_slug ) ) {
755 $entry_id = self::get_entry_id(
$entry_slug, $force_allow_ids );
757 if ( empty( $entry_id ) ) {
762 $entry = GFAPI::get_entry( $entry_id );
772 $check_entry_display = apply_filters(
'gravityview/common/get_entry/check_entry_display', $check_entry_display,
$entry, $view );
775 if ( $check_entry_display ) {
786 if ( is_wp_error(
$entry ) ) {
787 gravityview()->log->error(
'{error}', array(
'error' =>
$entry->get_error_message() ) );
815 $val1 = ! is_string( $val1 ) ? wp_json_encode( $val1 ) : $val1;
816 $val2 = ! is_string( $val2 ) ? wp_json_encode( $val2 ) : $val2;
820 if (
'context' === $val1 ) {
822 $matching_contexts = array( $val2 );
828 $matching_contexts = array(
'single',
'edit' );
832 $matching_contexts = array(
'directory' );
844 if ( $timestamp_1 && $timestamp_2 ) {
845 $val1 = (string) $timestamp_1;
846 $val2 = (string) $timestamp_2;
849 switch ( $operation ) {
851 $value = self::matches_operation( $val1, $val2,
'is' );
853 case 'greater_than_or_is':
854 case 'greater_than_or_equals':
855 $is = self::matches_operation( $val1, $val2,
'is' );
856 $gt = self::matches_operation( $val1, $val2,
'greater_than' );
859 case 'less_than_or_is':
860 case 'less_than_or_equals':
861 $is = self::matches_operation( $val1, $val2,
'is' );
862 $gt = self::matches_operation( $val1, $val2,
'less_than' );
866 $contains = self::matches_operation( $val1, $val2,
'contains' );
874 $json_val_1 = json_decode( $val1,
true );
875 $json_val_2 = json_decode( $val2,
true );
877 if ( ! empty( $json_val_1 ) || ! empty( $json_val_2 ) ) {
880 $json_val_1 = $json_val_1 ? (array) $json_val_1 : array( $val1 );
881 $json_val_2 = $json_val_2 ? (array) $json_val_2 : array( $val2 );
884 foreach ( $json_val_1 as $item_1 ) {
885 foreach ( $json_val_2 as $item_2 ) {
886 $json_in = self::matches_operation( $item_1, $item_2,
'is' );
894 $value = ( $operation ===
'in' ) ? $json_in : ! $json_in;
900 if ( is_string( $val1 ) && is_string( $val2 ) ) {
903 $value = GFFormsModel::matches_operation( $val1, $val2, $operation );
908 if ( is_string( $val1 ) && is_string( $val2 ) ) {
911 $value = GFFormsModel::matches_operation( $val1, $val2, $operation );
915 $value = GFFormsModel::matches_operation( $val1, $val2, $operation );
939 return new WP_Error(
'entry_not_found',
'Entry was not found.',
$entry );
942 if ( empty(
$entry[
'form_id'] ) ) {
943 return new WP_Error(
'form_id_not_set',
'[apply_filters_to_entry] Entry is empty!',
$entry );
946 if ( is_null( $view ) ) {
947 gravityview()->log->warning(
'$view was not supplied to check_entry_display, results will be non-typical.' );
948 return new WP_Error(
'view_not_supplied',
'View is not supplied!',
$entry );
951 if ( !
gravityview()->plugin->supports( \
GV\Plugin::FEATURE_GFQUERY ) ) {
952 return new WP_Error(
'no_gf_query',
'GF_Query is missing.',
$entry );
957 if ( $_gvid && $view->ID !== (
int) $_gvid ) {
958 return new WP_Error(
'view_id_not_match_gvid',
'View does not match passed $_GET["gvid"].', $view->ID );
961 $view_form_id = $view->form->ID;
963 if ( $view->joins ) {
964 if ( in_array( (
int)
$entry[
'form_id'], array_keys( $view::get_joined_forms( $view->ID ) ),
true ) ) {
965 $view_form_id = $entry[
'form_id'];
969 if ( (
int) $view_form_id !== (
int)
$entry[
'form_id'] ) {
970 return new WP_Error(
'view_id_not_match',
'View form source does not match entry form source ID.', $entry );
977 'gravityview/view/query',
978 $entry_subset_callback =
function( &$query, $view, $request ) use ( $entry, $view_form_id ) {
979 $_tmp_query = new \GF_Query(
982 'field_filters' => array(
987 'value' => $entry[
'id'],
993 $_tmp_query_parts = $_tmp_query->_introspect();
996 $query_parts = $query->_introspect();
998 $query->where( \GF_Query_Condition::_and( $_tmp_query_parts[
'where'], $query_parts[
'where'] ) );
1007 'gravityview_search_criteria',
1008 $remove_pagenum =
function(
$criteria ) {
1019 $entries = $view->get_entries()->all();
1022 remove_filter(
'gravityview_search_criteria', $remove_pagenum );
1025 remove_action(
'gravityview/view/query', $entry_subset_callback );
1026 return new \WP_Error(
'failed_criteria',
'Entry failed search_criteria and field_filters' );
1030 if ( $entries[0]->is_multi() ) {
1032 $multi_entry_ids = array();
1034 foreach ( $entries[0]->entries as $multi_entry ) {
1035 $multi_entry_ids[] = (int) $multi_entry->ID;
1038 if ( ! in_array( (
int) $entry[
'id'], $multi_entry_ids,
true ) ) {
1039 remove_action(
'gravityview/view/query', $entry_subset_callback );
1040 return new \WP_Error(
'failed_criteria',
'Entry failed search_criteria and field_filters' );
1042 } elseif ( (
int) $entries[0]->ID !== (
int) $entry[
'id'] ) {
1043 remove_action(
'gravityview/view/query', $entry_subset_callback );
1044 return new \WP_Error(
'failed_criteria',
'Entry failed search_criteria and field_filters' );
1047 remove_action(
'gravityview/view/query', $entry_subset_callback );
1072 $default_atts = array(
1074 'timestamp' =>
false,
1081 $atts = wp_parse_args(
$args, $default_atts );
1088 $date_gmt_time = mysql2date(
'G', $date_string );
1089 $date_local_timestamp = GFCommon::get_local_timestamp( $date_gmt_time );
1092 $is_human = ! empty( $atts[
'human'] );
1093 $is_diff = ! empty( $atts[
'diff'] );
1094 $is_raw = ! empty( $atts[
'raw'] );
1095 $is_timestamp = ! empty( $atts[
'timestamp'] );
1096 $include_time = ! empty( $atts[
'time'] );
1101 $format = $is_diff ? esc_html__(
'%s ago',
'gk-gravityview' ) : get_option(
'date_format' );
1106 $formatted_date = $date_string;
1107 } elseif ( $is_timestamp ) {
1108 $formatted_date = $date_local_timestamp;
1109 } elseif ( $is_diff ) {
1110 $formatted_date = sprintf(
$format, human_time_diff( $date_gmt_time ) );
1112 $formatted_date = GFCommon::format_date( $date_string, $is_human,
$format, $include_time );
1115 unset(
$format, $is_diff, $is_human, $is_timestamp, $is_raw, $date_gmt_time, $date_local_timestamp, $default_atts );
1117 return $formatted_date;
1179 if ( ! is_a(
$post,
'WP_Post' ) ) {
1183 if (
'gravityview' === get_post_type(
$post ) ) {
1187 return self::has_shortcode_r(
$post->post_content,
'gravityview' ) ? true :
false;
1200 if (
false === strpos(
$content,
'[' ) ) {
1204 if ( shortcode_exists( $tag ) ) {
1206 $shortcodes = array();
1208 preg_match_all(
'/' . get_shortcode_regex() .
'/s',
$content, $matches, PREG_SET_ORDER );
1209 if ( empty( $matches ) ) {
1213 foreach ( $matches as $shortcode ) {
1214 if ( $tag === $shortcode[2] ) {
1217 $shortcodes[] = $shortcode;
1219 } elseif ( isset( $shortcode[5] ) && $results = self::has_shortcode_r( $shortcode[5], $tag ) ) {
1220 foreach ( $results as $result ) {
1221 $shortcodes[] = $result;
1250 'post_type' =>
'gravityview',
1251 'posts_per_page' => 100,
1252 'meta_key' =>
'_gravityview_form_id',
1256 $views = get_posts(
$args );
1258 $views_with_joins = $wpdb->get_results(
"SELECT `post_id`, `meta_value` FROM $wpdb->postmeta WHERE `meta_key` = '_gravityview_form_joins'" );
1260 $joined_forms = array();
1261 foreach ( $views_with_joins as $view ) {
1263 $data = unserialize( $view->meta_value );
1265 if ( ! $data || ! is_array( $data ) ) {
1269 foreach ( $data as $datum ) {
1270 if ( ! empty( $datum[2] ) && (
int) $datum[2] === (
int) $form_id ) {
1271 $joined_forms[] = $view->post_id;
1276 if ( $joined_forms ) {
1277 $joined_args = array(
1278 'post_type' =>
'gravityview',
1279 'posts_per_page' =>
$args[
'posts_per_page'],
1280 'post__in' => $joined_forms,
1282 $views = array_merge( $views, get_posts( $joined_args ) );
1296 return get_post_meta(
$view_id,
'_gravityview_form_id',
true );
1309 return get_post_meta(
$view_id,
'_gravityview_directory_template',
true );
1322 $settings = get_post_meta( $post_id,
'_gravityview_template_settings',
true );
1324 if ( class_exists(
'\GV\View_Settings' ) ) {
1326 return wp_parse_args( (array)
$settings, \
GV\View_Settings::defaults() );
1345 $settings = self::get_template_settings( $post_id );
1389 $fields = get_post_meta( $post_id,
'_gravityview_directory_fields',
true );
1391 if ( $apply_filter ) {
1401 $fields = apply_filters(
'gravityview/configuration/fields', $fields, $post_id,
$form_id );
1412 $fields = apply_filters(
'gravityview/view/configuration/fields', $fields, \
GV\View::by_id( $post_id ),
$form_id );
1428 $view_widgets = get_post_meta(
$view_id,
'_gravityview_directory_widgets',
true );
1431 'header_top' => array(),
1432 'header_left' => array(),
1433 'header_right' => array(),
1434 'footer_left' => array(),
1435 'footer_right' => array(),
1438 $directory_widgets = wp_parse_args( $view_widgets, $defaults );
1440 if ( $json_decode ) {
1441 $directory_widgets =
gv_map_deep( $directory_widgets,
'gv_maybe_json_decode' );
1444 return $directory_widgets;
1455 $output =
'<option value="" ' . selected(
'', $current,
false ) .
'>' . esc_html__(
'Default (Entry ID)',
'gk-gravityview' ) .
'</option>';
1457 if ( empty( $formid ) ) {
1461 $fields = self::get_sortable_fields_array( $formid );
1463 if ( ! empty( $fields ) ) {
1465 $blocklist_field_types = array(
'list',
'textarea' );
1467 $blocklist_field_types = apply_filters_deprecated(
'gravityview_blacklist_field_types', array( $blocklist_field_types, null ),
'2.14',
'gravityview_blocklist_field_types' );
1469 $blocklist_field_types = apply_filters(
'gravityview_blocklist_field_types', $blocklist_field_types, null );
1471 foreach ( $fields as $id =>
$field ) {
1472 if ( in_array(
$field[
'type'], $blocklist_field_types ) ) {
1476 $output .=
'<option value="' . $id .
'" ' . selected( $id, $current,
false ) .
'>' . esc_attr(
$field[
'label'] ) .
'</option>';
1497 $fields = self::get_form_fields( $formid,
true,
false );
1499 $date_created = array(
1500 'date_created' => array(
1501 'type' =>
'date_created',
1502 'label' => __(
'Date Created',
'gk-gravityview' ),
1504 'date_updated' => array(
1505 'type' =>
'date_updated',
1506 'label' => __(
'Date Updated',
'gk-gravityview' ),
1510 $fields = $date_created + $fields;
1512 $blocklist_field_types = $blocklist;
1514 $blocklist_field_types = apply_filters_deprecated(
'gravityview_blacklist_field_types', array( $blocklist_field_types, null ),
'2.14',
'gravityview_blocklist_field_types' );
1516 $blocklist_field_types = apply_filters(
'gravityview_blocklist_field_types', $blocklist_field_types, null );
1519 foreach ( $fields as $id =>
$field ) {
1521 if ( in_array(
$field[
'type'], $blocklist_field_types ) ) {
1522 unset( $fields[ $id ] );
1528 if ( in_array(
$field[
'type'], array(
'date',
'time' ) ) && ! empty(
$field[
'parent'] ) ) {
1529 $fields[ intval( $id ) ] = array(
1530 'label' => \
GV\Utils::get(
$field,
'parent/label' ),
1532 'type' => \
GV\Utils::get(
$field,
'parent/type' ),
1533 'adminLabel' => \
GV\Utils::get(
$field,
'parent/adminLabel' ),
1534 'adminOnly' => \
GV\Utils::get(
$field,
'parent/adminOnly' ),
1537 unset( $fields[ $id ] );
1547 $fields = apply_filters(
'gravityview/common/sortable_fields', $fields, $formid );
1567 return class_exists(
'RGFormsModel' ) ? RGFormsModel::get_input_type(
$field ) :
'';
1581 if ( ! is_array(
$form ) && ! is_array(
$field ) ) {
1597 $numeric_types = apply_filters(
'gravityview/common/numeric_types', array(
'number',
'time' ) );
1602 $numeric_types[] =
$gv_field->is_numeric;
1606 $return = in_array( $type, $numeric_types );
1629 if ( ! class_exists(
'StandalonePHPEnkoder' ) ) {
1630 include_once
GRAVITYVIEW_DIR .
'includes/lib/StandalonePHPEnkoder.php';
1633 if ( class_exists(
'StandalonePHPEnkoder' ) ) {
1635 $enkoder =
new StandalonePHPEnkoder();
1637 $message = empty( $message ) ? __(
'Email hidden; Javascript is required.',
'gk-gravityview' ) : $message;
1645 $enkoder->enkode_msg = apply_filters(
'gravityview/phpenkoder/msg', $message,
$content );
1666 if ( empty( $string ) ) {
1673 $pairs = explode(
'&', $string );
1675 foreach ( $pairs as $pair ) {
1677 parse_str( $pair, $params );
1679 $k = key( $params );
1680 if ( ! isset( $result[ $k ] ) ) {
1682 } elseif ( array_key_exists( $k, $params ) && is_array( $params[ $k ] ) ) {
1683 $result[ $k ] = self::array_merge_recursive_distinct( $result[ $k ], $params[ $k ] );
1708 $allowed_atts = array(
1718 'data-viewid' => null,
1742 $allowed_atts = apply_filters(
'gravityview/get_link/allowed_atts', $allowed_atts );
1745 $passed_atts = wp_parse_args( $atts );
1748 $final_atts = shortcode_atts( $allowed_atts, $passed_atts );
1751 $final_atts = array_filter( $final_atts );
1754 if ( empty( $final_atts[
'href'] ) && ! empty(
$href ) ) {
1755 $final_atts[
'href'] =
$href;
1758 if ( isset( $final_atts[
'href'] ) ) {
1759 $final_atts[
'href'] = esc_url_raw( $final_atts[
'href'] );
1767 if (
'_blank' === \
GV\Utils::get( $final_atts,
'target' ) ) {
1768 $final_atts[
'rel'] = trim( \
GV\Utils::get( $final_atts,
'rel',
'' ) .
' noopener noreferrer' );
1772 ksort( $final_atts );
1776 foreach ( $final_atts as $attr =>
$value ) {
1777 $output .= sprintf(
' %s="%s"', $attr, esc_attr(
$value ) );
1803 foreach ( $array2 as $key =>
$value ) {
1804 if ( is_array(
$value ) && isset( $merged[ $key ] ) && is_array( $merged[ $key ] ) ) {
1805 $merged[ $key ] = self::array_merge_recursive_distinct( $merged[ $key ],
$value );
1806 } elseif ( is_numeric( $key ) && isset( $merged[ $key ] ) ) {
1809 $merged[ $key ] =
$value;
1823 public static function get_users( $context =
'change_entry_creator',
$args = array() ) {
1825 $default_args = array(
1827 'orderby' =>
'display_name',
1829 'fields' => array(
'ID',
'display_name',
'user_login',
'user_nicename' ),
1833 $get_users_settings = wp_parse_args(
$args, $default_args );
1840 $get_users_settings = apply_filters(
'gravityview/get_users/' . $context, apply_filters(
'gravityview_change_entry_creator_user_parameters', $get_users_settings ) );
1842 return get_users( $get_users_settings );
1860 if ( $cap && ! self::has_cap( $cap, $object_id ) ) {
1864 return '<div class="gv-notice ' . gravityview_sanitize_html_class(
$class ) .
'">' . $notice .
'</div>';
1875 $replace = array(
'[',
']',
'"' );
1876 $find = array(
'[',
']',
'"' );
1877 $string = str_replace( $find, $replace, $string );
1902 public static function send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name =
'', $message_format =
'html', $attachments =
'',
$entry =
false, $notification =
false ) {
1904 $SendEmail =
new ReflectionMethod(
'GFCommon',
'send_email' );
1907 $SendEmail->setAccessible(
true );
1911 $SendEmail->invoke(
new GFCommon(), $from, $to, $bcc, $reply_to, $subject, $message, $from_name, $message_format, $attachments,
$entry, $notification );
const GRAVITYVIEW_DIR
"GRAVITYVIEW_DIR" "./" The absolute path to the plugin directory, with trailing slash ...
static get_entry_meta( $form_id, $only_default_column=true)
get extra fields from entry meta
static has_product_field( $form=array())
Check whether a form has product fields.
static has_shortcode_r( $content, $tag='gravityview')
Placeholder until the recursive has_shortcode() patch is merged.
static js_encrypt( $content, $message='')
Encrypt content using Javascript so that it's hidden when JS is disabled.
static get_directory_fields( $post_id, $apply_filter=true, $form_id=0)
Get the field configuration for the View.
static _GET( $name, $default=null)
Grab a value from the _GET superglobal or default.
gravityview_maybe_convert_date_string_to_timestamp( $value='')
Convert a string to a timestamp if it's a valid date or a relative date prefixed with "relative:"...
static get_entry_id_from_slug( $slug)
Get the entry ID from the entry slug, which may or may not be the entry ID.
static array_merge_recursive_distinct(array &$array1, array &$array2)
array_merge_recursive does indeed merge arrays, but it converts values with duplicate keys to arrays ...
static get_directory_widgets( $view_id, $json_decode=false)
Get the widget configuration for a View.
static get_connected_views( $form_id, $args=array())
Get the views for a particular form.
static get_form_fields( $form='', $add_default_properties=false, $include_parent_field=true)
Return array of fields' id and label, for a given Form ID.
static entry_has_transaction_data( $entry=array())
Check if an entry has transaction data.
static calculate_get_entries_criteria( $passed_criteria=array(), $form_ids=array())
Calculates the Search Criteria used on the self::get_entries / self::get_entry methods.
static get_form_from_entry_id( $entry_slug)
Get the form array for an entry based only on the entry ID.
static getInstance( $passed_post=NULL)
static get_template_setting( $post_id, $key)
Get the setting for a View.
if(gv_empty( $field['value'], false, false)) $format
static get_forms( $active=true, $trash=false, $order_by='id', $order='ASC')
Alias of GFAPI::get_forms()
static get( $field_name)
Alias for get_instance()
static get_meta_form_id( $view_id)
Get the Gravity Forms form ID connected to a View.
static get_forms_as_options( $active=true, $trash=false, $sort_column='id', $sort_dir='ASC')
Get all forms to use as options in View settings.
static has_cap( $caps_to_check='', $object_id=null, $user_id=null)
Check whether the current user has a capability.
static decode_shortcodes( $string)
Inspired on ::encode_shortcodes, reverse the encoding by replacing the ascii characters by the shortc...
static generate_notice( $notice, $class='', $cap='', $object_id=null)
Display updated/error notice.
gravityview_get_link( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
static get_sortable_fields( $formid, $current='')
Render dropdown (select) with the list of sortable fields from a form ID.
static gv_parse_str( $string, &$result)
Do the same than parse_str without max_input_vars limitation: Parses $string as if it were the query ...
if(gravityview() ->plugin->is_GF_25()) $form
static matches_operation( $val1, $val2, $operation)
Wrapper for the GFFormsModel::matches_operation() method that adds additional comparisons, including: 'equals', 'greater_than_or_is', 'greater_than_or_equals', 'less_than_or_is', 'less_than_or_equals', 'not_contains', 'in', and 'not_in'.
$criteria['paging']
Modify the search parameters before the entries are fetched.
static get_template_settings( $post_id)
Get all the settings for a View.
if(empty( $field_settings['content'])) $content
static get_entry_id( $entry_id_or_slug='', $force_allow_ids=false)
Get the entry ID from a string that may be the Entry ID or the Entry Slug.
static get_entry_ids( $form_id, $search_criteria=array())
Wrapper for the Gravity Forms GFFormsModel::search_lead_ids() method.
gv_map_deep( $value, $callback)
Maps a function to all non-iterable elements of an array or an object.
static get_field_type( $form=null, $field_id='')
Returns the GF Form field type for a certain field(id) of a form.
static get_field_array( $field)
Return a Gravity Forms field array, whether using GF 1.9 or not.
static check_entry_display( $entry, $view=null)
Checks if a certain entry is valid according to the View search filters (specially the Adv Filters) ...
static get_product_field_types()
Return array of product field types.
static get_field( $form, $field_id)
Returns the field details array of a specific form given the field id.
static pre_get_form_fields( $template_id='')
Get the form fields for a preset (no form created yet)
static send_email( $from, $to, $bcc, $reply_to, $subject, $message, $from_name='', $message_format='html', $attachments='', $entry=false, $notification=false)
Send email using GFCommon::send_email()
static is_field_numeric( $form=null, $field='')
Checks if the field type is a 'numeric' field type (e.g.
static get_form_or_form_template( $form_id=0)
Returns form object for existing form or a form template.
static by_id( $post_id)
Construct a instance from a post ID.
static get_users( $context='change_entry_creator', $args=array())
Get WordPress users with reasonable limits set.
static get_sortable_fields_array( $formid, $blocklist=array( 'list', 'textarea'))
static format_date( $date_string='', $args=array())
Allow formatting date and time based on GravityView standards.
static get_entries( $form_ids=null, $passed_criteria=null, &$total=null)
Retrieve entries given search, sort, paging criteria.
static has_gravityview_shortcode( $post=null)
Check whether the post is GravityView.
if(empty( $created_by)) $form_id
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
static get_field_label( $form=array(), $field_id='', $field_value='')
Retrieve the label of a given field id (for a specific form)
static get_all( $groups='')
Get all fields.
gravityview_get_context()
Returns the current GravityView context, or empty string if not GravityView.
static get_entry( $entry_slug, $force_allow_ids=false, $check_entry_display=true, $view=null)
Return a single entry object.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
static get_meta_template_id( $view_id)
Get the template ID (list, table, datatables, map) for a View.
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
static get_all_views( $args=array())
Get all existing Views.
static get_link_html( $href='', $anchor_text='', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
static get_form( $form_id)
Returns the form object for a given Form ID.
static getInstance()
Get the one true instantiated self.