| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
$single_action_attrs = array( |
| 7 |
'href' => 'javascript:void(0)', |
| 8 |
'class' => 'frm_single_action frm_inactive_action frm_show_upgrade button frm-button-secondary frm-button-sm frm-with-icon frm-ml-auto-force frm-fadein-down-short', |
| 9 |
); |
| 10 |
?> |
| 11 |
<p class="howto"> |
| 12 |
<?php esc_html_e( 'Add form actions to your form to perform tasks when an entry is created, updated, imported, and more.', 'formidable' ); ?> |
| 13 |
</p> |
| 14 |
|
| 15 |
<div id="frm_email_addon_menu" class="frm-mt-md"> |
| 16 |
<div class="frm-h-stack frm-mb-lg"> |
| 17 |
<div class="frm-style-tabs-wrapper" data-filter-target="#frm-actions-filter-content"> |
| 18 |
<div class="frm-tabs-delimiter"><span class="frm-tabs-active-underline"></span></div> |
| 19 |
<div class="frm-tabs-navs"> |
| 20 |
<ul class="frm-h-stack-xs frm-children-px-sm"> |
| 21 |
<li class="frm-active" data-filter="my_actions"><?php esc_html_e( 'My Actions', 'formidable' ); ?></li> |
| 22 |
<li data-filter="all"><?php esc_html_e( 'All', 'formidable' ); ?></li> |
| 23 |
<?php foreach ( $groups as $group_key => $group ) { ?> |
| 24 |
<?php if ( ! empty( $group['name'] ) && 'my_actions' !== $group_key ) { ?> |
| 25 |
<li data-filter="<?php echo esc_attr( $group_key ); ?>"><?php echo esc_html( $group['name'] ); ?></li> |
| 26 |
<?php } ?> |
| 27 |
<?php } ?> |
| 28 |
</ul> |
| 29 |
</div> |
| 30 |
</div> |
| 31 |
|
| 32 |
<?php |
| 33 |
FrmAppHelper::show_search_box( |
| 34 |
array( |
| 35 |
'input_id' => 'actions', |
| 36 |
'placeholder' => __( 'Search Actions', 'formidable' ), |
| 37 |
'tosearch' => 'frm-action', |
| 38 |
'class' => 'frm-ml-auto-force', |
| 39 |
) |
| 40 |
); |
| 41 |
?> |
| 42 |
</div> |
| 43 |
|
| 44 |
<div id="frm-actions-filter-content" data-active-filter="my_actions"> |
| 45 |
<?php |
| 46 |
foreach ( $groups as $group_key => $group ) { |
| 47 |
// Handle my_actions group with sections |
| 48 |
if ( 'my_actions' === $group_key && isset( $group['sections'] ) ) { |
| 49 |
?> |
| 50 |
<div data-group="<?php echo esc_attr( $group_key ); ?>"> |
| 51 |
<?php |
| 52 |
foreach ( $group['sections'] as $section_key => $section ) { |
| 53 |
// Skip section if it has no actions |
| 54 |
if ( empty( $section['actions'] ) ) { |
| 55 |
continue; |
| 56 |
} |
| 57 |
?> |
| 58 |
<div data-section="<?php echo esc_attr( $section_key ); ?>"> |
| 59 |
<?php if ( ! empty( $section['name'] ) ) { ?> |
| 60 |
<h3 class="frm-group-heading"><?php echo esc_html( $section['name'] ); ?></h3> |
| 61 |
<?php } ?> |
| 62 |
|
| 63 |
<?php |
| 64 |
if ( ! isset( $section['actions'] ) ) { |
| 65 |
$section['actions'] = array(); |
| 66 |
} |
| 67 |
|
| 68 |
$icon_atts = isset( $group['color'] ) ? array( 'style' => '--primary-700:' . $group['color'] ) : array(); |
| 69 |
?> |
| 70 |
<ul class="frm_actions_list frm-list-grid-layout frm-m-0"> |
| 71 |
<?php |
| 72 |
foreach ( $action_controls as $action_control ) { |
| 73 |
if ( ! in_array( $action_control->id_base, $section['actions'], true ) ) { |
| 74 |
continue; |
| 75 |
} |
| 76 |
|
| 77 |
FrmFormActionsController::show_action_icon_link( $action_control, $allowed ); |
| 78 |
} |
| 79 |
|
| 80 |
// Build array of installed action IDs to skip in second loop |
| 81 |
$installed_action_ids = array(); |
| 82 |
|
| 83 |
foreach ( $action_controls as $action_control ) { |
| 84 |
$installed_action_ids[] = $action_control->id_base; |
| 85 |
} |
| 86 |
|
| 87 |
foreach ( $section['actions'] as $action ) { |
| 88 |
// Skip if action is already installed (shown in first loop) |
| 89 |
if ( in_array( $action, $installed_action_ids, true ) ) { |
| 90 |
continue; |
| 91 |
} |
| 92 |
|
| 93 |
$icon_atts = array(); |
| 94 |
|
| 95 |
if ( isset( $group['color'] ) ) { |
| 96 |
$icon_atts = array( |
| 97 |
'style' => '--primary-700:' . $group['color'], |
| 98 |
); |
| 99 |
} |
| 100 |
|
| 101 |
$action_icon = $group['icon'] ?? 'frmfont frm_plus_icon'; |
| 102 |
|
| 103 |
$single_action_attrs['data-upgrade'] = sprintf( |
| 104 |
/* translators: %s: Name of form action */ |
| 105 |
__( '%s form actions', 'formidable' ), |
| 106 |
$action |
| 107 |
); |
| 108 |
$single_action_attrs['data-medium'] = 'settings-' . $action; |
| 109 |
$single_action_attrs['data-actiontype'] = $action; |
| 110 |
|
| 111 |
// Set limit for payment actions only if not installed |
| 112 |
if ( in_array( $action, array( 'paypal', 'stripe', 'square' ), true ) ) { |
| 113 |
// Check if this action is already installed |
| 114 |
$action_is_installed = false; |
| 115 |
|
| 116 |
foreach ( $action_controls as $action_control ) { |
| 117 |
if ( $action_control->id_base === $action ) { |
| 118 |
$action_is_installed = true; |
| 119 |
break; |
| 120 |
} |
| 121 |
} |
| 122 |
|
| 123 |
// Only set limit if action is not installed |
| 124 |
if ( ! $action_is_installed ) { |
| 125 |
$single_action_attrs['data-limit'] = 1; |
| 126 |
} |
| 127 |
} |
| 128 |
?> |
| 129 |
<li class="frm-card-item frm-card-item--outlined frm-action frm-not-installed frm-action-locked frm-group-<?php echo esc_attr( $group_key ); ?>" tabindex="0"> |
| 130 |
<div class="frm-h-stack-xs frm-w-full"> |
| 131 |
<span class="frm-border-icon"> |
| 132 |
<?php FrmAppHelper::icon_by_class( $action_icon, $icon_atts ); ?> |
| 133 |
</span> |
| 134 |
|
| 135 |
<div class="frm-flex-col frm-min-w-0"> |
| 136 |
<h3 class="frm-h-stack-xs frm-text-md frm-capitalize"> |
| 137 |
<?php FrmAppHelper::icon_by_class( 'frmfont frm_lock_icon frm_svg15', array( 'aria-label' => __( 'Lock icon', 'formidable' ) ) ); ?> |
| 138 |
<span class="frm-font-medium frm-truncate"><?php echo esc_html( $action ); ?></span> |
| 139 |
<?php |
| 140 |
if ( ! empty( $section['new_actions'] ) && in_array( $action, $section['new_actions'], true ) ) { |
| 141 |
FrmAppHelper::show_pill_text(); |
| 142 |
} |
| 143 |
?> |
| 144 |
</h3> |
| 145 |
</div> |
| 146 |
|
| 147 |
<a <?php FrmAppHelper::array_to_html_params( $single_action_attrs, true ); ?>> |
| 148 |
<span><?php esc_html_e( 'Upgrade', 'formidable' ); ?></span> |
| 149 |
</a> |
| 150 |
</div> |
| 151 |
</li> |
| 152 |
<?php |
| 153 |
}//end foreach |
| 154 |
?> |
| 155 |
</ul> |
| 156 |
</div> |
| 157 |
<?php |
| 158 |
}//end foreach |
| 159 |
?> |
| 160 |
</div> |
| 161 |
<?php |
| 162 |
continue; |
| 163 |
}//end if |
| 164 |
|
| 165 |
// Handle regular groups |
| 166 |
?> |
| 167 |
<div data-group="<?php echo esc_attr( $group_key ); ?>"<?php echo 'my_actions' === $group_key ? '' : ( 'misc' === $group_key ? ' class="frm_hidden"' : ' class="frm_hidden"' ); ?>> |
| 168 |
<?php if ( ! empty( $group['name'] ) ) { ?> |
| 169 |
<h3 class="frm-group-heading"><?php echo esc_html( $group['name'] ); ?></h3> |
| 170 |
<?php } ?> |
| 171 |
|
| 172 |
<?php |
| 173 |
if ( ! isset( $group['actions'] ) ) { |
| 174 |
$group['actions'] = array(); |
| 175 |
} |
| 176 |
|
| 177 |
$icon_atts = isset( $group['color'] ) ? array( 'style' => '--primary-700:' . $group['color'] ) : array(); |
| 178 |
?> |
| 179 |
<ul class="frm_actions_list frm-list-grid-layout frm-m-0"> |
| 180 |
<?php |
| 181 |
foreach ( $action_controls as $action_control ) { |
| 182 |
if ( ! in_array( $action_control->id_base, $group['actions'], true ) ) { |
| 183 |
continue; |
| 184 |
} |
| 185 |
|
| 186 |
FrmFormActionsController::show_action_icon_link( $action_control, $allowed ); |
| 187 |
} |
| 188 |
|
| 189 |
// Build array of installed action IDs to skip in second loop |
| 190 |
$installed_action_ids = array(); |
| 191 |
|
| 192 |
foreach ( $action_controls as $action_control ) { |
| 193 |
$installed_action_ids[] = $action_control->id_base; |
| 194 |
} |
| 195 |
|
| 196 |
foreach ( $group['actions'] as $action ) { |
| 197 |
// Skip if action is already installed (shown in first loop) |
| 198 |
if ( in_array( $action, $installed_action_ids, true ) ) { |
| 199 |
continue; |
| 200 |
} |
| 201 |
|
| 202 |
$icon_atts = array(); |
| 203 |
|
| 204 |
if ( isset( $group['color'] ) ) { |
| 205 |
$icon_atts = array( |
| 206 |
'style' => '--primary-700:' . $group['color'], |
| 207 |
); |
| 208 |
} |
| 209 |
|
| 210 |
$action_icon = $group['icon'] ?? 'frmfont frm_plus_icon'; |
| 211 |
|
| 212 |
$single_action_attrs['data-upgrade'] = sprintf( |
| 213 |
/* translators: %s: Name of form action */ |
| 214 |
__( '%s form actions', 'formidable' ), |
| 215 |
$action |
| 216 |
); |
| 217 |
$single_action_attrs['data-medium'] = 'settings-' . $action; |
| 218 |
$single_action_attrs['data-actiontype'] = $action; |
| 219 |
|
| 220 |
// Set limit for payment actions only if not installed |
| 221 |
if ( in_array( $action, array( 'paypal', 'stripe', 'square' ), true ) ) { |
| 222 |
// Check if this action is already installed |
| 223 |
$action_is_installed = false; |
| 224 |
|
| 225 |
foreach ( $action_controls as $action_control ) { |
| 226 |
if ( $action_control->id_base === $action ) { |
| 227 |
$action_is_installed = true; |
| 228 |
break; |
| 229 |
} |
| 230 |
} |
| 231 |
|
| 232 |
// Only set limit if action is not installed |
| 233 |
if ( ! $action_is_installed ) { |
| 234 |
$single_action_attrs['data-limit'] = 1; |
| 235 |
} |
| 236 |
} |
| 237 |
?> |
| 238 |
<li class="frm-card-item frm-card-item--outlined frm-action frm-not-installed frm-action-locked frm-group-<?php echo esc_attr( $group_key ); ?>" tabindex="0"> |
| 239 |
<div class="frm-h-stack-xs frm-w-full"> |
| 240 |
<span class="frm-border-icon"> |
| 241 |
<?php FrmAppHelper::icon_by_class( $action_icon, $icon_atts ); ?> |
| 242 |
</span> |
| 243 |
|
| 244 |
<div class="frm-flex-col frm-min-w-0"> |
| 245 |
<h3 class="frm-h-stack-xs frm-text-md frm-capitalize"> |
| 246 |
<?php FrmAppHelper::icon_by_class( 'frmfont frm_lock_icon frm_svg15', array( 'aria-label' => __( 'Lock icon', 'formidable' ) ) ); ?> |
| 247 |
<span class="frm-font-medium frm-truncate"><?php echo esc_html( $action ); ?></span> |
| 248 |
<?php |
| 249 |
if ( ! empty( $group['new_actions'] ) && in_array( $action, $group['new_actions'], true ) ) { |
| 250 |
FrmAppHelper::show_pill_text(); |
| 251 |
} |
| 252 |
?> |
| 253 |
</h3> |
| 254 |
</div> |
| 255 |
|
| 256 |
<a <?php FrmAppHelper::array_to_html_params( $single_action_attrs, true ); ?>> |
| 257 |
<span><?php esc_html_e( 'Upgrade', 'formidable' ); ?></span> |
| 258 |
</a> |
| 259 |
</div> |
| 260 |
</li> |
| 261 |
<?php |
| 262 |
}//end foreach |
| 263 |
?> |
| 264 |
</ul> |
| 265 |
</div> |
| 266 |
<?php |
| 267 |
}//end foreach |
| 268 |
?> |
| 269 |
|
| 270 |
<p id="frm-actions-no-results" class="frm_hidden frm-mt-0"> |
| 271 |
<?php esc_html_e( 'No actions found. Try a different search term.', 'formidable' ); ?> |
| 272 |
</p> |
| 273 |
</div> |
| 274 |
</div> |
| 275 |
|
| 276 |
<h3 class="frm-mt-xl"><?php esc_html_e( 'Current Actions', 'formidable' ); ?></h3> |
| 277 |
|
| 278 |
<?php |
| 279 |
FrmFormActionsController::list_actions( $form, $values ); |
| 280 |
FrmTipsHelper::pro_tip( 'get_form_action_tip', 'p' ); |
| 281 |
|