priority = 1; } /** * Get the action admin fields */ public function get_action_fields() { $parent_fields = parent::get_default_fields(); unset( $parent_fields['action_status'] ); return array_merge( array( 'tags_map_mapping_section' => array( 'name' => 'tags_map_mapping_section', 'type' => 'section', 'title' => __( 'Tags mapping', 'wpcf7-redirect' ), 'fields' => array( array( 'name' => 'leads_map', 'type' => 'leads_map', 'label' => '', 'sub_title' => '', 'placeholder' => '', 'show_selector' => '', 'value' => maybe_unserialize( $this->get( 'leads_map' ) ), 'tags' => WPCF7R_Form::get_mail_tags(), ), ), ), 'action_status' => array( 'name' => 'action_status', 'type' => 'checkbox', 'label' => $this->get_action_status_label(), 'sub_title' => __( 'if this is off the rule will not be applied', 'wpcf7-redirect' ), 'placeholder' => '', 'show_selector' => '', 'toggle-label' => json_encode( array( '.field-wrap-action_status .checkbox-label,.column-status a' => array( __( 'Enabled', 'wpcf7-redirect' ), __( 'Disabled', 'wpcf7-redirect' ), ), ) ), 'value' => $this->get( 'action_status' ), ), ), $parent_fields ); } /** * Get an HTML of the */ public function get_action_settings() { $this->get_settings_template( 'html-action-redirect.php' ); } /** * Connected to manage_columns hooks. * * @param [string] $column - key of the column. * @param [int] $lead_id - the id of the relevant post. * @return void */ public function display_action_column_content( $column, $lead_id ) { switch ( $column ) { case 'form': echo $this->get_cf7_link_html(); break; case 'data_preview': echo $this->display_columns_values( $lead_id ); break; } } /** * Display the values that were selected on the action. * * @return void */ private function display_columns_values( $lead_id ) { $mapped_fields = maybe_unserialize( $this->get( 'leads_map' ) ); $none_selected = true; if ( $mapped_fields ) { foreach ( $mapped_fields as $field_key => $mapped_field ) { if ( isset( $mapped_field['appear'] ) && $mapped_field['appear'] ) { $label = $mapped_field['tag'] ? $mapped_field['tag'] : $field_key; $value = get_post_meta( $lead_id, $field_key, true ); if ( is_array( $value ) ) { $value = implode( ',', $value ); } $string = $label . ': ' . $value; echo sprintf( "