get_automation_id(); $automation_meta = BWFAN_Model_Automations::get_automation_with_data( $automation_id ); if ( false === $automation_id || ! is_array( $automation_meta ) || 0 === count( $automation_meta ) ) { wp_die( esc_html__( 'Automation doesn\'t exists, something is wrong.', 'wp-marketing-automations' ) ); } $trigger_events = isset( $automation_meta['event'] ) ? $automation_meta['event'] : ''; $saved_integrations = array(); $parent_source = isset( $automation_meta['source'] ) ? $automation_meta['source'] : ''; $a_track_id = isset( $automation_meta['meta']['a_track_id'] ) ? $automation_meta['meta']['a_track_id'] : ''; $trigger_events_meta = isset( $automation_meta['meta']['event_meta'] ) ? $automation_meta['meta']['event_meta'] : []; $saved_integrations = isset( $automation_meta['meta']['actions'] ) ? $automation_meta['meta']['actions'] : []; $automation_sticky_line = __( 'Now Building', 'wp-marketing-automations' ); $automation_onboarding = true; $automation_title = ( isset( $automation_meta['meta'] ) && isset( $automation_meta['meta']['title'] ) ) ? $automation_meta['meta']['title'] : ''; $status = ( 1 === absint( $automation_meta['status'] ) ) ? 'publish' : 'sandbox'; if ( class_exists( 'BWFAN_Header' ) ) { $header_ins = new BWFAN_Header(); $header_ins->set_level_1_navigation_active( 'automations' ); $header_ins->set_back_link( 1, admin_url( 'admin.php?page=autonami&path=/automations-v1' ) ); $header_ins->set_level_2_side_type( 'both' ); $header_ins->set_level_2_title( $automation_title ); $automation_migrated = isset( $automation_meta['meta'] ) && isset( $automation_meta['meta']['v1_migrate'] ) && $automation_meta['meta']['v1_migrate'] == 1 ? true : false; $automation_edit_html = ! $automation_migrated ? '' : ''; $header_ins->set_level_2_post_title( $automation_edit_html ); $header_ins->set_level_2_side_navigation( BWFAN_Header::level_2_navigation_single_automation( $automation_id ) ); $header_ins->set_level_2_navigation_pos( 'right' ); ob_start(); if ( ! $automation_migrated ) { ?>
>
automations->current_automation_sync_state ); ?> />
set_level_2_right_html( $status ); echo $header_ins->render( $automation_migrated ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } ?>
get_automation_section() ) ) { include_once( $this->admin_path . '/view/section-' . $this->get_automation_section() . '.php' ); } else { /** * Allow other add-ons to show the content */ do_action( 'bwfan_dashboard_page_' . $this->get_automation_section() ); } do_action( 'bwfan_automation_page', $this->get_automation_section(), $automation_id ); ?>
sources->get_source_localize_data(); $all_triggers_events = BWFAN_Core()->sources->get_sources_events_localize_data(); $all_source_event = BWFAN_Load_Sources::get_sources_events_arr(); $group = []; $all_groups = []; $all_integrations = BWFAN_Core()->integration->get_integration_actions_localize_data(); $integration_actions_name = BWFAN_Core()->integration->get_mapped_arr_integration_name_with_action_name(); $integrations_object = BWFAN_Core()->integration->get_integration_localize_data(); $integrations_group = []; $sub_integrations = []; /** Events */ foreach ( $event_source as $key => $group_data ) { if ( ! isset( $group[ $group_data['group_slug'] ] ) ) { $group[ $group_data['group_slug'] ] = [ 'label' => $group_data['group_name'], 'subgroup' => [ $group_data['slug'] ], 'priority' => $group_data['priority'] ]; $all_groups[] = $group_data['slug']; } else { if ( ! in_array( $group_data['slug'], $group[ $group_data['group_slug'] ]['subgroup'] ) ) { $group[ $group_data['group_slug'] ]['subgroup'][] = $group_data['slug']; } $all_groups[] = $group_data['slug']; } } $group['all'] = [ 'subgroup' => $all_groups, 'show' => false, 'priority' => 999 ]; $filter_events_arr = []; /** Filter v1 events */ foreach ( $all_triggers_events as $key => $evtdata ) { $v1Event = []; foreach ( $evtdata as $evtKey => $evtVal ) { if ( $evtVal['support_v1'] ) { $v1Event[ $evtKey ] = $evtVal; } } if ( ! empty( $v1Event ) ) { $filter_events_arr[ $key ] = $v1Event; } } $filter_integration_arr = []; /** Filter v1 actions */ foreach ( $all_integrations as $key => $actiondata ) { $v1Actions = []; foreach ( $actiondata as $actionKey => $actionVal ) { if ( $actionVal['support_v1'] ) { $v1Actions[ $actionKey ] = $actionVal; } } if ( ! empty( $v1Actions ) ) { $filter_integration_arr[ $key ] = $v1Actions; } } /** Actions */ foreach ( $integrations_object as $key => $data ) { if ( ! isset( $integrations_group[ $data['group_slug'] ] ) ) { $integrations_group[ $data['group_slug'] ] = [ 'label' => $data['group_name'], 'subgroup' => [ $data['slug'] => $data['nice_name'] ], 'priority' => isset( $data['priority'] ) ? $data['priority'] : 1000 ]; $sub_integrations[ $data['slug'] ] = $data['nice_name']; } else { if ( ! in_array( $data['slug'], $integrations_group[ $data['group_slug'] ]['subgroup'] ) ) { $integrations_group[ $data['group_slug'] ]['subgroup'][ $data['slug'] ] = $data['nice_name']; } $sub_integrations[ $data['slug'] ] = $data['nice_name']; } } $integrations_group = apply_filters( 'bwfan_modify_actions_groups', $integrations_group ); $all_integrations = apply_filters( 'bwfan_modify_integrations', $filter_integration_arr ); $integrations_group['all'] = [ 'subgroup' => $sub_integrations, 'show' => false, 'priority' => 999 ]; $templates = bwfan_is_autonami_pro_active() ? BWFAN_Model_Templates::bwfan_get_templates( 0, 0, '', [] ) : []; if ( ! empty( $templates ) ) { $templates = array_map( function ( $template ) { if ( ! empty( $template['data'] ) ) { $template['data'] = json_decode( $template['data'] ); } return $template; }, $templates ); } $link_triggers = bwfan_is_autonami_pro_active() && class_exists( 'BWFAN_Model_Link_Triggers' ) ? BWFAN_Model_Link_Triggers::get_link_triggers( '', 2, '', '', false ) : []; if ( ! empty( $link_triggers ) && isset( $link_triggers['links'] ) ) { $actions = BWFCRM_Core()->actions->get_all_action_list(); $link_triggers = array_map( function ( $link ) use ( $actions ) { $temp = []; if ( isset( $link['data'] ) ) { $temp = $link['data']; unset( $link['data'] ); } if ( isset( $temp['actions'] ) && ! empty( $temp['actions'] ) && is_array( $temp['actions'] ) ) { $action = []; foreach ( $temp['actions'] as $key => $value ) { if ( isset( $actions[ $key ] ) ) { $action[] = $actions[ $key ]; } } $temp['actions'] = $action; } return array_merge( $link, $temp ); }, $link_triggers['links'] ); } $localized_data = [ 'actions' => $filter_events_arr, 'all_source' => $event_source, 'groupdata' => $group, 'source_event' => $all_source_event, 'integration_list' => $all_integrations, 'integration_group' => $integrations_group, 'woocommerce_enable' => BWFAN_Plugin_Dependency::woocommerce_active_check(), 'templates' => $templates, 'link_triggers' => $link_triggers, 'siteurl' => get_site_url(), ]; echo ''; ?>