[0-9.|a-zA-Z.]*)#';
// Get the matching numbers.
preg_match_all( $pattern, $u_agent, $matches );
// See how many we have
$i = count( $matches['browser'] );
if ( $i > 1 ) {
// We will have two since we are not using 'other' argument yet
// See if version is before or after the name.
$version = strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ? $matches['version'][0] : $matches['version'][1];
} elseif ( $i === 1 ) {
$version = $matches['version'][0];
} else {
$version = '';
}
// Check if we have a number
if ( $version === '' ) {
$version = '?';
}
return $bname . ' ' . $version . ' / ' . $platform;
}
/**
* @since 3.0
*
* @param array $atts Action dropdown attributes.
*
* @return void
*/
public static function actions_dropdown( $atts ) {
$id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
$links = self::get_action_links( $id, $atts['entry'] );
foreach ( $links as $link ) {
// phpcs:disable Generic.WhiteSpace.ScopeIndent
?>
admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
'label' => __( 'View Entry', 'formidable' ),
'icon' => 'frmfont frm_save_icon',
);
}
if ( current_user_can( 'frm_delete_entries' ) ) {
$actions['frm_delete'] = array(
'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
'label' => __( 'Delete Entry', 'formidable' ),
'icon' => 'frmfont frm_delete_icon',
'data' => array(
'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
'frmverify-btn' => 'frm-button-red',
),
);
}
if ( $page === 'show' ) {
$actions['frm_print'] = array(
'url' => '#',
'label' => __( 'Print Entry', 'formidable' ),
'data' => array(
'frmprint' => '1',
),
'icon' => 'frmfont frm_printer_icon',
);
}
$actions['frm_resend'] = array(
'url' => '#',
'label' => __( 'Resend Emails', 'formidable' ),
'class' => 'frm_noallow',
'data' => array(
'upgrade' => __( 'Resend Emails', 'formidable' ),
'medium' => 'resend-email',
'content' => 'entry',
),
'icon' => 'frmfont frm_email_icon',
);
if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
$actions['frm_download_pdf'] = array(
'url' => '#',
'label' => __( 'Download as PDF', 'formidable' ),
'class' => 'frm_noallow',
'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
'icon' => 'frmfont frm_download_icon',
);
}
$actions['frm_edit'] = array(
'url' => '#',
'label' => __( 'Edit Entry', 'formidable' ),
'class' => 'frm_noallow',
'data' => array(
'upgrade' => __( 'Entry edits', 'formidable' ),
'medium' => 'edit-entries',
'content' => 'entry',
),
'icon' => 'frmfont frm_pencil_icon',
);
return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
}
/**
* Gets data attributes for PDFs addon upgrade link.
*
* @param string $medium The source of the upgrade link used for analytics data.
*
* @return array
*/
private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
$data = array(
'oneclick' => '',
'requires' => '',
'upgrade' => __( 'Forms to PDF', 'formidable' ),
'medium' => $medium,
);
$upgrading = FrmAddonsController::install_link( 'pdfs' );
if ( isset( $upgrading['url'] ) ) {
$data['oneclick'] = json_encode( $upgrading );
} else {
$data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
}
return $data;
}
/**
* @since 5.0.15
*
* @param int|string $entry_id
*
* @return void
*/
public static function maybe_render_captcha_score( $entry_id ) {
$query = array(
'item_id' => (int) $entry_id,
'field_id' => 0,
);
$metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
foreach ( $metas_without_a_field as $meta ) {
if ( empty( $meta->meta_value['captcha_score'] ) ) {
continue;
}
echo '';
FrmAppHelper::icon_by_class( 'frmfont frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
echo '' . esc_html( $meta->meta_value['captcha_score'] ) . '';
echo '
';
return;
}
}
/**
* Return entry status based on is_draft column value.
*
* @since 6.5
*
* @param int $status is_draft column.
*
* @return int
*/
public static function get_entry_status( $status ) {
$statuses = self::get_entry_statuses();
if ( array_key_exists( $status, $statuses ) ) {
return $status;
}
if ( ! $status ) {
// If the status is empty, let's default to 0.
return self::SUBMITTED_ENTRY_STATUS;
}
// If it has a value that isn't in the array, let's default to 1. There may be old entries that don't have a value for is_draft.
return self::DRAFT_ENTRY_STATUS;
}
/**
* Return entry status label based on passed value.
*
* @since 6.5
*
* @param int $status is_draft column.
*
* @return string
*/
public static function get_entry_status_label( $status ) {
$statuses = self::get_entry_statuses();
return $statuses[ self::get_entry_status( $status ) ];
}
/**
* Get all entry statuses.
*
* @since 6.5
* @since 6.6 function went from private to public.
*
* @return array
*/
public static function get_entry_statuses() {
$default_entry_statuses = array(
self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ),
self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ),
);
/**
* Register entry status.
*
* "2" is used in abandonment-addon and reserved for "In progress".
* "3" is used in abandonment-addon and reserved for "Abandoned".
*
* @since 6.5
*
* @param array $extended_entry_status Entry statuses.
*/
$extended_entry_status = apply_filters( 'frm_entry_statuses', array() );
if ( ! is_array( $extended_entry_status ) ) {
_doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' );
$extended_entry_status = array();
}
return array_replace( $default_entry_statuses, $extended_entry_status );
}
/**
* @since 6.17
*
* @return int
*/
public static function get_visible_unread_inbox_count() {
$menu_name = FrmAppHelper::get_menu_name();
if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
return 0;
}
$inbox = new FrmInbox();
$inbox_count = count( $inbox->unread() );
if ( ! $inbox_count ) {
return 0;
}
if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) {
$inbox_count = FrmProSettingsController::inbox_badge( $inbox_count );
if ( ! $inbox_count ) {
return 0;
}
}
return $inbox_count;
}
}