load_assets(); $data = $this->get_data(); if ( empty( $data ) ) { return null; } // Based on the $type and $metric we'll compose the template path and class name for the block output. $template_file = MONSTERINSIGHTS_PLUGIN_DIR . 'includes/gutenberg/site-insights/templates/' . $type . '/class-' . $type . '-' . $metric . '.php'; if (!file_exists($template_file)) { return false; } require_once MONSTERINSIGHTS_PLUGIN_DIR . '/includes/gutenberg/site-insights/templates/class-site-insights-metric-template.php'; require_once MONSTERINSIGHTS_PLUGIN_DIR . '/includes/gutenberg/site-insights/templates/class-site-insights-duoscorecard-template.php'; require_once $template_file; $class_name = 'MonsterInsights_SiteInsights_Template_' . ucfirst($type) . '_' . ucfirst($metric); if ( !class_exists($class_name) ) { return false; } $template = new $class_name($attributes, $data); $output = $template->output(); $block_attributes = get_block_wrapper_attributes(array( 'class' => "monsterinsights-{$type}-block", )); return sprintf( '