| @@ -4,12 +4,8 @@ | ||
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | class FrmFormActionsController { |
| 7 | 7 | public static $action_post_type = 'frm_form_actions'; |
| 8 | - | |
| 9 | - /** | |
| 10 | - * @var array|null | |
| 11 | - */ | |
| 12 | 8 | public static $registered_actions; |
| 13 | 9 | |
| 14 | 10 | /** |
| 15 | 11 | * Variables saved in the post: |
| @@ -72,9 +68,8 @@ | ||
| 72 | 68 | 'googlespreadsheet' => 'FrmDefGoogleSpreadsheetAction', |
| 73 | 69 | ); |
| 74 | 70 | |
| 75 | 71 | $action_classes = apply_filters( 'frm_registered_form_actions', $action_classes ); |
| 76 | - $action_classes = self::maybe_unset_highrise( $action_classes ); | |
| 77 | 72 | |
| 78 | 73 | include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/email_action.php'; |
| 79 | 74 | include_once FrmAppHelper::plugin_path() . '/classes/views/frm-form-actions/default_actions.php'; |
| 80 | 75 | |
| @@ -83,23 +78,8 @@ | ||
| 83 | 78 | } |
| 84 | 79 | } |
| 85 | 80 | |
| 86 | 81 | /** |
| 87 | - * Remove the Highrise action if it is not registered. | |
| 88 | - * | |
| 89 | - * @since 6.23 | |
| 90 | - * | |
| 91 | - * @param array $action_classes | |
| 92 | - * @return array | |
| 93 | - */ | |
| 94 | - private static function maybe_unset_highrise( $action_classes ) { | |
| 95 | - if ( 'FrmDefHighriseAction' === ( $action_classes['highrise'] ?? '' ) ) { | |
| 96 | - unset( $action_classes['highrise'] ); | |
| 97 | - } | |
| 98 | - return $action_classes; | |
| 99 | - } | |
| 100 | - | |
| 101 | - /** | |
| 102 | 82 | * @since 4.0 |
| 103 | 83 | * |
| 104 | 84 | * @param array $values |
| 105 | 85 | */ |
| @@ -183,15 +163,18 @@ | ||
| 183 | 163 | 'constantcontact', |
| 184 | 164 | 'getresponse', |
| 185 | 165 | 'aweber', |
| 186 | 166 | 'mailpoet', |
| 187 | - 'convertkit', | |
| 188 | 167 | ), |
| 189 | 168 | ), |
| 190 | 169 | 'crm' => array( |
| 191 | 170 | 'name' => __( 'CRM', 'formidable' ), |
| 192 | 171 | 'icon' => 'frm_icon_font frm_address_card_icon', |
| 193 | - 'actions' => self::get_crm_actions(), | |
| 172 | + 'actions' => array( | |
| 173 | + 'salesforce', | |
| 174 | + 'hubspot', | |
| 175 | + 'highrise', | |
| 176 | + ), | |
| 194 | 177 | ), |
| 195 | 178 | ); |
| 196 | 179 | |
| 197 | 180 | return apply_filters( 'frm_action_groups', $groups ); |
| @@ -197,30 +180,8 @@ | ||
| 197 | 180 | return apply_filters( 'frm_action_groups', $groups ); |
| 198 | 181 | } |
| 199 | 182 | |
| 200 | 183 | /** |
| 201 | - * Get the actions to include in the CRM section. | |
| 202 | - * | |
| 203 | - * @since 6.23 | |
| 204 | - * | |
| 205 | - * @return array | |
| 206 | - */ | |
| 207 | - private static function get_crm_actions() { | |
| 208 | - $crm_actions = array( | |
| 209 | - 'salesforce', | |
| 210 | - 'hubspot', | |
| 211 | - ); | |
| 212 | - | |
| 213 | - // Only include Highrise when the add-on is active. | |
| 214 | - // This is because Highrise is deprecated. We don't want to show it in Lite. | |
| 215 | - if ( class_exists( 'FrmHrsSettings' ) ) { | |
| 216 | - $crm_actions[] = 'highrise'; | |
| 217 | - } | |
| 218 | - | |
| 219 | - return $crm_actions; | |
| 220 | - } | |
| 221 | - | |
| 222 | - /** | |
| 223 | 184 | * Get the number of currently active form actions. |
| 224 | 185 | * |
| 225 | 186 | * @since 4.0 |
| 226 | 187 | * |
| @@ -295,9 +256,8 @@ | ||
| 295 | 256 | } |
| 296 | 257 | |
| 297 | 258 | /** |
| 298 | 259 | * @param string $action |
| 299 | - * @return array|FrmFormAction A single form action is returned when a specific $action value is requested. | |
| 300 | 260 | */ |
| 301 | 261 | public static function get_form_actions( $action = 'all' ) { |
| 302 | 262 | $temp_actions = self::$registered_actions; |
| 303 | 263 | if ( empty( $temp_actions ) ) { |
| @@ -339,11 +299,8 @@ | ||
| 339 | 299 | 'post_status' => 'all', |
| 340 | 300 | ); |
| 341 | 301 | $form_actions = FrmFormAction::get_action_for_form( $form->id, 'all', $filters ); |
| 342 | 302 | |
| 343 | - /** | |
| 344 | - * @var array | |
| 345 | - */ | |
| 346 | 303 | $action_controls = self::get_form_actions(); |
| 347 | 304 | |
| 348 | 305 | $action_map = array(); |
| 349 | 306 | |
| @@ -350,10 +307,8 @@ | ||
| 350 | 307 | foreach ( $action_controls as $key => $control ) { |
| 351 | 308 | $action_map[ $control->id_base ] = $key; |
| 352 | 309 | } |
| 353 | 310 | |
| 354 | - self::maybe_show_limit_warning( $form->id, $form_actions ); | |
| 355 | - | |
| 356 | 311 | foreach ( $form_actions as $action ) { |
| 357 | 312 | if ( ! isset( $action_map[ $action->post_excerpt ] ) ) { |
| 358 | 313 | // don't try and show settings if action no longer exists |
| 359 | 314 | continue; |
| @@ -362,42 +317,8 @@ | ||
| 362 | 317 | self::action_control( $action, $form, $action->ID, $action_controls[ $action_map[ $action->post_excerpt ] ], $values ); |
| 363 | 318 | } |
| 364 | 319 | } |
| 365 | 320 | |
| 366 | - /** | |
| 367 | - * Show a warning before the form actions list if there are 99 actions, and the limit is set to 99. | |
| 368 | - * If it is filtered, the warning is still shown when applicable, just using the new limit. | |
| 369 | - * | |
| 370 | - * @since 6.17 | |
| 371 | - * | |
| 372 | - * @param int|string $form_id | |
| 373 | - * @param array $form_actions | |
| 374 | - * @return void | |
| 375 | - */ | |
| 376 | - private static function maybe_show_limit_warning( $form_id, $form_actions ) { | |
| 377 | - $count = count( $form_actions ); | |
| 378 | - if ( $count < 99 ) { | |
| 379 | - return; | |
| 380 | - } | |
| 381 | - | |
| 382 | - $limit = FrmFormAction::get_action_limit( $form_id ); | |
| 383 | - if ( $limit < 99 || $count < $limit ) { | |
| 384 | - return; | |
| 385 | - } | |
| 386 | - | |
| 387 | - $documentation_url = 'https://formidableforms.com/knowledgebase/frm_form_action_limit/#kb-increase-limit-of-form-actions'; | |
| 388 | - | |
| 389 | - echo '<div class="frm_warning_style">'; | |
| 390 | - FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon' ); | |
| 391 | - echo ' '; | |
| 392 | - printf( | |
| 393 | - // translators: %s: URL to documentation | |
| 394 | - esc_html__( 'You have reached your form action limit. To increase this limit, you will require additional code. Visit our documentation at %s.', 'formidable' ), | |
| 395 | - '<a href="' . esc_url( $documentation_url ) . '" target="_blank">' . esc_html( $documentation_url ) . '</a>' | |
| 396 | - ); | |
| 397 | - echo '</div>'; | |
| 398 | - } | |
| 399 | - | |
| 400 | 321 | public static function action_control( $form_action, $form, $action_key, $action_control, $values ) { |
| 401 | 322 | $action_control->_set( $action_key ); |
| 402 | 323 | |
| 403 | 324 | $use_logging = self::should_show_log_message( $form_action->post_excerpt ); |
| @@ -413,11 +334,8 @@ | ||
| 413 | 334 | |
| 414 | 335 | $action_key = FrmAppHelper::get_param( 'list_id', '', 'post', 'absint' ); |
| 415 | 336 | $action_type = FrmAppHelper::get_param( 'type', '', 'post', 'sanitize_text_field' ); |
| 416 | 337 | |
| 417 | - /** | |
| 418 | - * @var FrmFormAction | |
| 419 | - */ | |
| 420 | 338 | $action_control = self::get_form_actions( $action_type ); |
| 421 | 339 | $action_control->_set( $action_key ); |
| 422 | 340 | |
| 423 | 341 | $form_id = FrmAppHelper::get_param( 'form_id', '', 'post', 'absint' ); |
| @@ -583,14 +501,11 @@ | ||
| 583 | 501 | return; |
| 584 | 502 | } |
| 585 | 503 | |
| 586 | 504 | FrmForm::maybe_get_form( $form ); |
| 587 | - if ( ! is_object( $form ) ) { | |
| 588 | - return; | |
| 589 | - } | |
| 590 | 505 | |
| 591 | 506 | $link_settings = self::get_form_actions( $type ); |
| 592 | - if ( 'all' !== $type ) { | |
| 507 | + if ( 'all' != $type ) { | |
| 593 | 508 | $link_settings = array( $type => $link_settings ); |
| 594 | 509 | } |
| 595 | 510 | |
| 596 | 511 | $stored_actions = array(); |
| @@ -617,9 +532,9 @@ | ||
| 617 | 532 | if ( empty( $entry ) || ( FrmEntriesHelper::DRAFT_ENTRY_STATUS === (int) $entry->is_draft && 'draft' !== $event ) ) { |
| 618 | 533 | continue; |
| 619 | 534 | } |
| 620 | 535 | |
| 621 | - $child_entry = ( is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ! empty( $args['is_child'] ); | |
| 536 | + $child_entry = ( ( is_object( $form ) && is_numeric( $form->parent_form_id ) && $form->parent_form_id ) || ( $entry && ( $entry->form_id != $form->id || $entry->parent_item_id ) ) || ( isset( $args['is_child'] ) && $args['is_child'] ) ); | |
| 622 | 537 | |
| 623 | 538 | if ( $child_entry ) { |
| 624 | 539 | // maybe trigger actions for sub forms |
| 625 | 540 | $trigger_children = apply_filters( 'frm_use_embedded_form_actions', false, compact( 'form', 'entry' ) ); |
| @@ -679,11 +594,8 @@ | ||
| 679 | 594 | // Continue if we know which actions to copy. |
| 680 | 595 | return; |
| 681 | 596 | } |
| 682 | 597 | |
| 683 | - /** | |
| 684 | - * @var array | |
| 685 | - */ | |
| 686 | 598 | $action_controls = self::get_form_actions(); |
| 687 | 599 | |
| 688 | 600 | foreach ( $action_controls as $action_control ) { |
| 689 | 601 | $action_control->duplicate_form_actions( $form_id, $args['old_id'] ); |
| @@ -700,24 +612,8 @@ | ||
| 700 | 612 | |
| 701 | 613 | $where .= $wpdb->prepare( ' AND post_excerpt = %s ', $frm_vars['action_type'] ); |
| 702 | 614 | |
| 703 | 615 | return $where; |
| 704 | - } | |
| 705 | - | |
| 706 | - /** | |
| 707 | - * Prevent WPML from filtering form actions based on the active language. | |
| 708 | - * | |
| 709 | - * @since 6.20 | |
| 710 | - * | |
| 711 | - * @param bool|null $null | |
| 712 | - * @param string $post_type | |
| 713 | - * @return bool|null | |
| 714 | - */ | |
| 715 | - public static function prevent_wpml_translations( $null, $post_type ) { | |
| 716 | - if ( self::$action_post_type === $post_type ) { | |
| 717 | - return false; | |
| 718 | - } | |
| 719 | - return $null; | |
| 720 | 616 | } |
| 721 | 617 | } |
| 722 | 618 | |
| 723 | 619 | class Frm_Form_Action_Factory { |