init();
// Add to list of available analytics.
add_filter( 'wpforms_analytics_available', array( $this, 'register_analytics' ), $this->priority, 1 );
// Fetch and store the current form data when in the builder.
add_action( 'wpforms_builder_init', array( $this, 'builder_form_data' ) );
// Output builder sidebar.
add_action( 'wpforms_analytics_panel_sidebar', array( $this, 'builder_sidebar' ), $this->priority );
// Output builder content.
add_action( 'wpforms_analytics_panel_content', array( $this, 'builder_output' ), $this->priority );
}
/**
* All systems go. Used by subclasses.
*
* @since 1.0.0
*/
public function init() {
}
/**
* Add to list of registered analytics.
*
* @since 1.0.0
*
* @param array $analytics
*
* @return array
*/
public function register_analytics( $analytics = array() ) {
$analytics[ $this->slug ] = $this->name;
return $analytics;
}
/********************************************************
* Builder methods - these methods _build_ the Builder. *
********************************************************/
/**
* Fetch and store the current form data when in the builder.
*
* @since 1.1.0
*/
public function builder_form_data() {
$this->form_data = WPForms_Builder::instance()->form_data;
}
/**
* Display content inside the panel sidebar area.
*
* @since 1.0.0
*/
public function builder_sidebar() {
$configured = ! empty( $this->form_data['analytics'][ $this->slug ]['enable'] ) ? 'configured' : '';
echo '';
echo '';
echo esc_html( $this->name );
echo '';
if ( ! empty( $configured ) ) {
echo '';
}
echo '';
}
/**
* Wraps the builder content with the required markup.
*
* @since 1.0.0
*/
public function builder_output() {
?>