HEX
Server: LiteSpeed
System: Linux eko108.isimtescil.net 4.18.0-477.21.1.lve.1.el8.x86_64 #1 SMP Tue Sep 5 23:08:35 UTC 2023 x86_64
User: uyarreklamcomtr (11202)
PHP: 7.4.33
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/uyarreklam.com.tr/httpdocs/site-insights.tar
templates/class-site-insights-duoscorecard-template.php000064400000003115151545722650017450 0ustar00<?php
/**
 * Class that handles the output for the DuoScorecard template.
 *
 * Class MonsterInsights_SiteInsights_Template_DuoScorecard
 */
abstract class MonsterInsights_SiteInsights_Template_DuoScorecard extends MonsterInsights_SiteInsights_Metric_Template {

	/**
	 * Returns the HTML of a card based of the given args.
	 *
	 * @param string $side Could be `left` or `right`.
	 * @param $value int The value to display.
	 * @param $label string The label to display.
	 * @param $compare_value int A comparable value.
	 * @param $compare_label string What are we comparing to.
	 *
	 * @return string
	 */
	protected function get_card_template( $side, $label, $value, $compare_value, $compare_label, $withComparison ) {
		$compare_class_name = '';

		if ( $compare_value > 0 ) {
			$compare_class_name = 'is-positive-percentage';
		}

		$comparison = '';

		if ( $withComparison ) {
			$comparison = sprintf(
				'<div class="monsterinsights-duo-scorecard-compare">
					<div class="monsterinsights-duo-scorecard-compare-percentage %1$s">%2$s&#37;</div>
					<div class="monsterinsights-duo-scorecard-compare-label">%3$s</div>
				</div>',
				$compare_class_name,
				$compare_value,
				$compare_label
			);
		}

		$format = '<div class="monsterinsights-duo-scorecard-half monsterinsights-duo-scorecard-%1$s">
			<div class="monsterinsights-duo-scorecard-content">
				<div class="monsterinsights-duo-scorecard-title">%2$s</div>
				<div class="monsterinsights-duo-scorecard-value">%3$s</div>
			</div>
			%4$s
		</div>';

		return sprintf(
			$format,
			$side,
			$label,
			$value,
			$comparison
		);
	}
}templates/class-site-insights-metric-template.php000064400000003556151545722650016267 0ustar00<?php
/**
 * This is the abstract class to be used as a base for Site Insights block templates.
 *
 * @package MonsterInsights
 */

/**
 * Class MonsterInsights_SiteInsights_Metric_Template
 */
abstract class MonsterInsights_SiteInsights_Metric_Template {

	/**
	 * The metric that we want to display.
	 *
	 * @var string
	 */
	protected $metric;

	/**
	 * The type that we want to display.
	 *
	 * @varstring
	 */
	protected $type;

	/**
	 * Block attributes received at init.
	 * @var array
	 */
	protected $attributes = array();

	/**
	 * GA data received at init.
	 *
	 * @var array
	 */
	protected $data = array();

	/**
	 * A method that should prepare chart options or scorecards data for the `output` method.
	 *
	 * @return array
	 */
	abstract protected function get_options();

	/**
	 * The method that returns the template for the given metric and block type.
	 *
	 * @return mixed
	 */
	abstract public function output();

	public function __construct( $attributes, $data ){
		$this->attributes = $attributes;
		$this->data = $data;
	}

	/**
	 * Returns the JSON version of `get_options`.
	 *
	 * @return false|string
	 */
	public function get_json_data() {
		$data = $this->get_options();

		if (empty($data)){
			return false;
		}

		return json_encode($data);
	}

	/**
	 * If color value is in preset format, convert it to a CSS var. Else return same value
	 * For example:
	 * "var:preset|color|pale-pink" -> "var(--wp--preset--color--pale-pink)"
	 * "#98b66e" -> "#98b66e"
	 *
	 * @param string $color_value value to be processed.
	 *
	 * @return (string)
	 */
	public static function get_color_value( $color_value ) {
		if ( is_string( $color_value ) && false !== strpos( $color_value, 'var:preset|color|' ) ) {
			$color_value = str_replace( 'var:preset|color|', '', $color_value );
			return sprintf( 'var(--wp--preset--color--%s)', $color_value );
		}

		return $color_value;
	}
}templates/graph/class-graph-age.php000064400000004022151545722650013324 0ustar00<?php
/**
 * Class that handles the output for the Age Breakdown graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Age
 */
class MonsterInsights_SiteInsights_Template_Graph_Age extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'age';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['age'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];

		$data = $this->data['age'];

		$title = __( 'Age Breakdown', 'google-analytics-for-wordpress' );

		$series = array();
		$percentages = array();
		$labels = array();

		foreach ($data as $key => $country) {
			$series[$key] = (int) $country['sessions'];
			$labels[$key] = $country['age'];
			$percentages[$key] = $country['percent'];
		}

		$options = array(
			'series' => array(
				array(
					'name' => $title,
					'data' => $series,
				)
			),
			'chart' => array(
				'height' => 430,
				'type' => 'bar',
				'zoom' => array( 'enabled' => false ),
				'toolbar' => array( 'show' => false )
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor
				)
			),
			'plotOptions' => array(
				'bar' => array(
					'borderRadius' => 5,
					'borderRadiusApplication' => 'end',
					'dataLabels' => array(
						'position' => 'top'
					)
				)
			),
			'dataLabels' => array(
				'enabled' => true,
				'offsetY' => -20,
				'style' => array(
					'fontSize' => '12px',
					'colors' => array( $primaryColor )
				),
			),
			'xaxis' => array(
				'categories' => $labels
			)
		);

		return $options;
	}
}templates/graph/class-graph-device.php000064400000004414151545722650014034 0ustar00<?php
/**
 * Class that handles the output for the Device graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Device
 */
class MonsterInsights_SiteInsights_Template_Graph_Device extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'device';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-donut-chart monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['devices'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];
		$data = $this->data['devices'];
		$labels = array();
		$series = array_values($data);

		foreach ($data as $key => $value){
			$labels[] = ucfirst($key);
		}

		$title = __( 'Device Breakdown', 'google-analytics-for-wordpress' );

		$options = array(
			'series' => $series,
			'chart' => array(
				'width' => "100%",
				'height' => 'auto',
				'type' => 'donut',
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $this->get_color_value($textColor),
					'fontSize' => '20px'
				)
			),
			'plotOptions' => array(
				'plotOptions' => array(
					'pie' => array(
						'donut' => array( 'size' => '75%' )
					)
				)
			),
			'legend' => array(
				'position' => 'right',
				'horizontalAlign' => 'center',
				'floating' => false,
				'fontSize' => '17px',
				'height' => '100%',
				'markers' => array(
					'width' => 30,
					'height' => 30,
					'radius' => 30
				),
				'formatter' => array(
					'args' => 'seriesName, opts',
					'body' => 'return [seriesName, "<strong> " + opts.w.globals.series[opts.seriesIndex] + "%</strong>"]'
				)
			),
			'dataLabels' => array(
				'enabled' => false
			),
			'labels' => $labels,
			'responsive' => array(
				0 => array(
					'breakpoint' => 767,
					'options' => array(
						'legend' => array(
							'show' => false
						)
					)
				)
			)
		);

		return $options;
	}
}templates/graph/class-graph-gender.php000064400000004102151545722650014033 0ustar00<?php
/**
 * Class that handles the output for the New vs Returning graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Gender
 */
class MonsterInsights_SiteInsights_Template_Graph_Gender extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'gender';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-donut-chart monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['gender'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];
		$title = __( 'Gender Breakdown', 'google-analytics-for-wordpress' );

		$data = $this->data['gender'];
		$series = array_column($data, 'percent');
		$labels = array_column($data, 'gender');

		$options = array(
			'series' => $series,
			'chart' => array(
				'height' => 'auto',
				'type' => 'donut',
			),
			'colors' => array( '#ebebeb', $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor,
					'fontSize' => '20px'
				)
			),
			'labels' => $labels,
			'legend' => array(
				'position' => 'right',
				'horizontalAlign' => 'center',
				'floating' => false,
				'fontSize' => '17px',
				'height' => '100%',
				'markers' => array(
					'width' => 30,
					'height' => 30,
					'radius' => 30,
				),
				'formatter' => array(
					'args' => 'seriesName, opts',
					'body' => 'return [seriesName, "<strong> " + opts.w.globals.series[opts.seriesIndex] + "%</strong>"];'
				)
			),
			'dataLabels' => array(
				'enabled' => false
			),
			'responsive' => array(
				0 => array(
					'breakpoint' => 767,
					'options' => array(
						'legend' => array(
							'show' => false
						)
					)
				)
			)
		);

		return $options;
	}
}templates/graph/class-graph-newvsreturning.php000064400000004546151545722650015703 0ustar00<?php
/**
 * Class that handles the output for the New vs Returning graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Newvsreturning
 */
class MonsterInsights_SiteInsights_Template_Graph_Newvsreturning extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'newvsreturning';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-donut-chart monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['newvsreturn'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];

		$data = $this->data['newvsreturn'];

		$title = __( 'New vs Returning', 'google-analytics-for-wordpress' );

		$options = array(
			'series' => array(
				$data['new'],
				$data['returning'],
			),
			'chart' => array(
				'width' => "100%",
				'height' => 'auto',
				'type' => 'donut',
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $this->get_color_value($textColor),
					'fontSize' => '20px'
				)
			),
			'labels' => array(
				__( 'New Visitors', 'google-analytics-for-wordpress' ),
				__( 'Returning Visitors', 'google-analytics-for-wordpress' ),
			),
			'plotOptions' => array(
				'plotOptions' => array(
					'pie' => array(
						'donut' => array( 'size' => '65%' )
					)
				)
			),
			'legend' => array(
				'position' => 'right',
				'horizontalAlign' => 'center',
				'floating' => false,
				'fontSize' => '17px',
				'height' => '100%',
				'markers' => array(
					'width' => 30,
					'height' => 30,
					'radius' => 30,
				),
				'formatter' => array(
					'args' => 'seriesName, opts',
					'body' => 'return [seriesName, "<strong> " + opts.w.globals.series[opts.seriesIndex] + "%</strong>"];'
				)
			),
			'dataLabels' => array(
				'enabled' => false
			),
			'responsive' => array(
				array(
					'breakpoint' => 767,
					'options' => array(
						'legend' => array(
							'show' => false
						)
					)
				)
			)
		);

		return $options;
	}
}templates/graph/class-graph-pageviews.php000064400000004367151545722650014576 0ustar00<?php
/**
 * Class that handles the output for the pageviews graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Pageviews
 */
class MonsterInsights_SiteInsights_Template_Graph_Pageviews extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'pageviews';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['overviewgraph'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$textColor = $this->attributes['textColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['overviewgraph'];

		$title = __( 'Page views', 'google-analytics-for-wordpress' );

		$options = array(
			'series' => array(
				array(
					'name' => $title,
					'data' => $data['pageviews']['datapoints']
				)
			),
			'chart' => array(
				'height' => 450,
				'type' => 'area',
				'zoom' => array( 'enabled' => false ),
				'toolbar' => array( 'show' => false )
			),
			'dataLabels' => array( 'enabled' => false ),
			'stroke' => array(
				'curve' => 'straight',
				'width' => 4,
				'colors' => array( $primaryColor )
			),
			'fill' => array( 'type' => 'solid' ),
			'colors' => array( $secondaryColor ),
			'markers' => array(
				'style' => 'hollow',
				'size' => 5,
				'colors' => array( '#ffffff' ),
				'strokeColors' => $primaryColor
			),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor,
					'fontSize' => '17px',
					'fontWeight' => 'bold',
				)
			),
			'grid' => array(
				'show' => true,
				'borderColor' => 'rgba(58, 147, 221, 0.15)',
				'xaxis' => array(
					'lines' => array( 'show' => true )
				),
				'yaxis' => array(
					'lines' => array( 'show' => true )
				),
				'padding' => array(
					'top' => 10,
					'right' => 10,
					'bottom' => 10,
					'left' => 10,
				)
			),
			'xaxis' => array( 'categories' => $data['labels'] ),
			'yaxis' => array( 'type' => 'numeric' ),
		);

		return $options;
	}


}templates/graph/class-graph-scrolldepth.php000064400000002443151545722650015120 0ustar00<?php
/**
 * Class that handles the output for the Scroll Depth graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Scrolldepth
 */
class MonsterInsights_SiteInsights_Template_Graph_Scrolldepth extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'scrolldepth';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (!isset($this->data['scroll']) || empty($this->data['scroll']['average'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$value = $this->data['scroll']['average'];

		$title = __( 'Average Scroll Depth', 'google-analytics-for-wordpress' );

		$options = array(
			'series' => array( $value ),
			'chart' => array(
				'height' => 350,
				'type' => 'radialBar',
			),
			'plotOptions' => array(
				'radialBar' => array(
					'size' => $value . '%',
				)
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'labels' => array( $title ),
		);

		return $options;
	}
}templates/graph/class-graph-sessions.php000064400000004332151545722650014442 0ustar00<?php
/**
 * Class that handles the output for the sessions graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Session
 */
class MonsterInsights_SiteInsights_Template_Graph_Sessions extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'sessions';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['overviewgraph'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];

		$data = $this->data['overviewgraph'];

		$title = __( 'Sessions', 'google-analytics-for-wordpress' );

		$options = array(
			'series' => array(
				array(
					'name' => $title,
					'data' => $data['sessions']['datapoints']
				)
			),
			'chart' => array(
				'type' => 'area',
				'zoom' => array( 'enabled' => false ),
				'toolbar' => array( 'show' => false )
			),
			'dataLabels' => array( 'enabled' => false ),
			'stroke' => array(
				'curve' => 'straight',
				'width' => 4,
				'colors' => array( $primaryColor )
			),
			'fill' => array( 'type' => 'solid' ),
			'colors' => array( $secondaryColor ),
			'markers' => array(
				'style' => 'hollow',
				'size' => 5,
				'colors' => array( '#ffffff' ),
				'strokeColors' => $primaryColor
			),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor,
					'fontSize' => '17px',
					'fontWeight' => 'bold',
				)
			),
			'grid' => array(
				'show' => true,
				'borderColor' => 'rgba(58, 147, 221, 0.15)',
				'xaxis' => array(
					'lines' => array( 'show' => true )
				),
				'yaxis' => array(
					'lines' => array( 'show' => true )
				),
				'padding' => array(
					'top' => 10,
					'right' => 10,
					'bottom' => 10,
					'left' => 10,
				)
			),
			'xaxis' => array( 'categories' => $data['labels'] ),
			'yaxis' => array( 'type' => 'numeric' ),
		);

		return $options;
	}


}templates/graph/class-graph-top10countries.php000064400000004016151545722650015472 0ustar00<?php
/**
 * Class that handles the output for the Top 10 Countries graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Top10countries
 */
class MonsterInsights_SiteInsights_Template_Graph_Top10countries extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'top10countries';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['countries'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];

		$data = $this->data['countries'];

		$title = __( 'Top 10 countries', 'google-analytics-for-wordpress' );
		$series = array();
		$labels = array_column($data, 'name');

		foreach ($data as $key => $country) {
			$series[$key] = (int) $country['sessions'];
		}

		$options = array(
			'series' => array(
				array(
					'name' => $title,
					'data' => $series,
				)
			),
			'chart' => array(
				'height' => 430,
				'type' => 'bar',
				'zoom' => array( 'enabled' => false ),
				'toolbar' => array( 'show' => false )
			),
			'dataLabels' => array(
				'enabled' => true,
				'style' => array(
					'fontSize' => '12px',
					'colors' => array( $textColor )
				)
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor,
					'fontSize' => '20px'
				)
			),
			'plotOptions' => array(
				'bar' => array(
					'horizontal' => true,
					'borderRadius' => 5,
					'borderRadiusApplication' => 'end',
					'dataLabels' => array(
						'position' => 'center',
					)
				)
			),
			'xaxis' => array(
				'categories' => $labels,
			)
		);

		return $options;
	}
}templates/graph/class-graph-topinterests.php000064400000004120151545722650015332 0ustar00<?php
/**
 * Class that handles the output for the Top Interests graph.
 *
 * Class MonsterInsights_SiteInsights_Template_Graph_Topinterests
 */
class MonsterInsights_SiteInsights_Template_Graph_Topinterests extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'topinterests';

	protected $type = 'graph';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['interest'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];

		$data = $this->data['interest'];

		$title = __( 'Top Interests', 'google-analytics-for-wordpress' );

		$series = array();
		$percentages = array();
		$labels = array_column($data, 'interest');

		foreach ($data as $key => $country) {
			$series[$key] = (int) $country['sessions'];
			$percentages[$key] = (int) $country['percent'];
		}

		$options = array(
			'series' => array(
				array(
					'name' => $title,
					'data' => $series,
				)
			),
			'chart' => array(
				'height' => 430,
				'type' => 'bar',
				'zoom' => array( 'enabled' => false ),
				'toolbar' => array( 'show' => false )
			),
			'dataLabels' => array(
				'enabled' => true,
				'style' => array(
					'fontSize' => '12px',
					'colors' => array( $textColor )
				)
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'title' => array(
				'text' => $title,
				'align' => 'left',
				'style' => array(
					'color' => $textColor,
					'fontSize' => '20px'
				)
			),
			'plotOptions' => array(
				'bar' => array(
					'horizontal' => true,
					'borderRadius' => 5,
					'borderRadiusApplication' => 'end',
					'dataLabels' => array(
						'position' => 'center'
					)
				)
			),
			'xaxis' => array(
				'categories' => $labels
			)
		);

		return $options;
	}
}templates/scorecard/class-scorecard-age.php000064400000004325151545722650015042 0ustar00<?php
/**
 * Class that handles the output for the Age Breakdown scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Age
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Age extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'age';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$content = $this->get_table_template(
			$data['headers'],
			$data['rows']
		);

		return sprintf(
			"<div class=\"monsterinsights-table-scorecard with-3-columns\">%s</div>",
			$content
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if (empty($this->data['age'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['age'];

		$rows = array();

		foreach ($data as $key => $item) {
			$rows[$key] = array(
				$item['age'],
				$item['sessions'],
				$item['percent'] . '%'
			);
		}

		return array(
			'rows' => $rows,
			'headers' => array(
				__( 'Age Range', 'google-analytics-for-wordpress' ),
				__( 'Sessions', 'google-analytics-for-wordpress' ),
				__( 'Percent', 'google-analytics-for-wordpress' )
			),
		);
	}

	private function get_table_template( $headers, $rows ) {
		$headers_output = '';
		$countries_output = '';

		foreach ( $headers as $key => $head ) {
			$headers_output .= sprintf( '<div class="monsterinsights-scorecard-table-head">%s</div>', $head );
		}

		foreach ( $rows as $key => $row ) {
			$items = '';

			foreach ( $row as $i => $column ) {
				$items .= sprintf( '<div class="monsterinsights-scorecard-table-column">%s</div>', $column );
			}

			$countries_output .= sprintf( '<div class="monsterinsights-scorecard-table-row">%s</div>', $items );
		}

		$header = sprintf(
			'<div class="monsterinsights-scorecard-table-header">%s</div>',
			$headers_output
		);

		$content = sprintf(
			'<div class="monsterinsights-scorecard-table-rows">%s</div>',
			$countries_output
		);

		$format = '<div class="monsterinsights-scorecard-table">%s</div>';

		return sprintf(
			$format,
			$header . $content
		);
	}
}templates/scorecard/class-scorecard-device.php000064400000004477151545722650015555 0ustar00<?php
/**
 * Class that handles the output for the Device Breakdown scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Device
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Device extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'device';

	protected $type = 'scorecard';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['devices'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];
		$title = __( 'Device Breakdown', 'google-analytics-for-wordpress' );

		$data = $this->data['devices'];

		$series = array_values( $data );
		$labels = array_keys( $data );

		$options = array(
			'series' => array(
				array(
					'data' => $series
				)
			),
			'title' => array(
				'text' => $title,
				'style' => array(
					'color' => $textColor,
					'fontSize' => '20px',
				)
			),
			'chart' => array(
				'type' => 'bar',
				'height' => 240,
				'width' => "90%",
				'toolbar' => array(
					'show' => false
				)
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'tooltip' => array(
				'enabled' => false
			),
			'grid' => array(
				'show' => false
			),
			'plotOptions' => array(
				'bar' => array(
					'borderRadius' => 5,
					'horizontal' => true,
					'columnWidth' => '33%',
					'dataLabels' => array(
						'position' => 'center',
					)
				)
			),
			'dataLabels' => array(
				'style' => array(
					'colors' => array( $textColor )
				),
				'formatter' => array(
					'args' => 'value',
					'body' => 'return value + "%"',
				)
			),
			'xaxis' => array(
				'show' => false,
				'categories' => $labels,
				'axisBorder' => array(
					'show' => false
				),
				'labels' => array(
					'show' => false
				),
				'axisTicks' => array(
					'show' => false
				)
			),
			'yaxis' => array(
				'show' => true,
				'labels' => array(
					'show' => true
				),
				'axisTicks' => array(
					'show' => false
				)
			),
		);

		return $options;
	}
}templates/scorecard/class-scorecard-gender.php000064400000004347151545722650015556 0ustar00<?php
/**
 * Class that handles the output for the Gender Breakdown scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Gender
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Gender extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'gender';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$content = $this->get_table_template(
			$data['headers'],
			$data['rows']
		);

		return sprintf(
			"<div class=\"monsterinsights-table-scorecard with-3-columns\">%s</div>",
			$content
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if (empty($this->data['gender'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['gender'];

		$rows = array();

		foreach ($data as $key => $item) {
			$rows[$key] = array(
				$item['gender'],
				$item['sessions'],
				$item['percent'] . '%'
			);
		}

		return array(
			'rows' => $rows,
			'headers' => array(
				__( 'Gender', 'google-analytics-for-wordpress' ),
				__( 'Sessions', 'google-analytics-for-wordpress' ),
				__( 'Percent', 'google-analytics-for-wordpress' )
			),
		);
	}

	private function get_table_template( $headers, $rows ) {
		$headers_output = '';
		$countries_output = '';

		foreach ( $headers as $key => $head ) {
			$headers_output .= sprintf( '<div class="monsterinsights-scorecard-table-head">%s</div>', $head );
		}

		foreach ( $rows as $key => $row ) {
			$items = '';

			foreach ( $row as $i => $column ) {
				$items .= sprintf( '<div class="monsterinsights-scorecard-table-column">%s</div>', $column );
			}

			$countries_output .= sprintf( '<div class="monsterinsights-scorecard-table-row">%s</div>', $items );
		}

		$header = sprintf(
			'<div class="monsterinsights-scorecard-table-header">%s</div>',
			$headers_output
		);

		$content = sprintf(
			'<div class="monsterinsights-scorecard-table-rows">%s</div>',
			$countries_output
		);

		$format = '<div class="monsterinsights-scorecard-table">%s</div>';

		return sprintf(
			$format,
			$header . $content
		);
	}
}templates/scorecard/class-scorecard-newvsreturning.php000064400000004726151545722650017413 0ustar00<?php
/**
 * Class that handles the output for the New vs Returning scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Newvsreturning
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Newvsreturning extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'newvsreturning';

	protected $type = 'scorecard';

	public function output(){
		$json_data = $this->get_json_data();

		if (empty($json_data)) {
			return false;
		}

		return "<div class='monsterinsights-graph-item monsterinsights-graph-{$this->metric}'>
			<script type='application/json'>{$json_data}</script>
		</div>";
	}

	protected function get_options() {
		if (empty($this->data['newvsreturn'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$textColor = $this->attributes['textColor'];
		$title = __( 'New vs Returning', 'google-analytics-for-wordpress' );

		$data = $this->data['newvsreturn'];

		$series = array( $data['returning'], $data['new'] );

		$options = array(
			'series' => array(
				array(
					'data' => $series
				)
			),
			'title' => array(
				'text' => $title,
				'style' => array(
					'color' => $textColor,
					'fontSize' => '20px',
				)
			),
			'chart' => array(
				'type' => 'bar',
				'height' => 160,
				'width' => "90%",
				'toolbar' => array(
					'show' => false
				)
			),
			'colors' => array( $primaryColor, $secondaryColor ),
			'tooltip' => array(
				'enabled' => false
			),
			'grid' => array(
				'show' => false
			),
			'plotOptions' => array(
				'bar' => array(
					'borderRadius' => 5,
					'horizontal' => true,
					'columnWidth' => '50%',
					'dataLabels' => array(
						'position' => 'center',
					)
				)
			),
			'dataLabels' => array(
				'style' => array(
					'colors' => array( $textColor )
				),
				'formatter' => array(
					'args' => 'value',
					'body' => 'return value + "%"',
				)
			),
			'xaxis' => array(
				'show' => false,
				'categories' => array(
					__( 'New Visitors', 'google-analytics-for-wordpress' ),
					__( 'Returning Visitors', 'google-analytics-for-wordpress' )
				),
				'axisBorder' => array(
					'show' => false
				),
				'labels' => array(
					'show' => false
				),
				'axisTicks' => array(
					'show' => false
				)
			),
			'yaxis' => array(
				'show' => true,
				'labels' => array(
					'show' => true
				),
				'axisTicks' => array(
					'show' => false
				)
			),
		);

		return $options;
	}
}templates/scorecard/class-scorecard-pageviews.php000064400000003325151545722650016277 0ustar00<?php
/**
 * Class that handles the output for the Sessions scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Pageviews
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Pageviews extends MonsterInsights_SiteInsights_Template_DuoScorecard {

	protected $metric = 'pageviews';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$duration = $data['duration']['value'];
		$prev_duration = $data['duration']['prev'];
		$bounce_rate = $data['bounce_rate']['value'];
		$prev_bounce_rate = $data['bounce_rate']['prev'];

		$left = $this->get_card_template(
			'left',
			__('Avg. Session Duration', 'google-analytics-for-wordpress'),
			$duration,
			$prev_duration,
			__( 'vs. Previous 30 days', 'google-analytics-for-wordpress' ),
			$data['withComparison']
		);

		$right = $this->get_card_template(
			'right',
			__('Bounce Rate', 'google-analytics-for-wordpress'),
			$bounce_rate,
			$prev_bounce_rate,
			__( 'vs. Previous 30 days', 'google-analytics-for-wordpress' ),
			$data['withComparison']
		);

		return sprintf(
			"<div class=\"monsterinsights-duo-scorecard\">%s</div>",
			$left . $right
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if ( empty($this->data['infobox'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$withComparison = $this->attributes['withComparison'];

		$data = $this->data['infobox'];

		return array(
			'duration' => $data['duration'],
			'bounce_rate' => $data['bounce_rate'],
			'withComparison' => $withComparison,
		);
	}
}templates/scorecard/class-scorecard-scrolldepth.php000064400000002242151545722650016625 0ustar00<?php
/**
 * Class that handles the output for the Scroll Depth scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Scrolldepth
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Scrolldepth extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'scrolldepth';

	protected $type = 'scorecard';

	public function output(){
		$value = $this->get_options();

		if ( empty($value) ) {
			return null;
		}

		$format = '<div class="monsterinsights-scorecard-simple-card">
			<div class="monsterinsights-scorecard-simple-card-value">%2$s</div>
			<div class="monsterinsights-scorecard-simple-card-label">%1$s</div>
		</div>';

		return sprintf(
			$format,
			__( 'Average Scroll Depth', 'google-analytics-for-wordpress' ),
			$value . '%'
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if ( !isset($this->data['scroll']) || empty($this->data['scroll']['average'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['scroll'];

		return $data['average'];
	}
}templates/scorecard/class-scorecard-sessions.php000064400000003263151545722650016154 0ustar00<?php
/**
 * Class that handles the output for the Sessions scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Sessions
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Sessions extends MonsterInsights_SiteInsights_Template_DuoScorecard {

	protected $metric = 'sessions';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$sessions = $data['sessions']['value'];
		$prev_sessions = $data['sessions']['prev'];
		$pageviews = $data['pageviews']['value'];
		$prev_pageviews = $data['pageviews']['prev'];

		$left = $this->get_card_template(
			'left',
			__('Sessions', 'google-analytics-for-wordpress'),
			$sessions,
			$prev_sessions,
			__( 'vs. Previous 30 days', 'google-analytics-for-wordpress' ),
			$data['withComparison']
		);

		$right = $this->get_card_template(
			'right',
			__('Pageviews', 'google-analytics-for-wordpress'),
			$pageviews,
			$prev_pageviews,
			__( 'vs. Previous 30 days', 'google-analytics-for-wordpress' ),
			$data['withComparison']
		);

		return sprintf(
			"<div class=\"monsterinsights-duo-scorecard\">%s</div>",
			$left . $right
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if ( empty($this->data['infobox'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];
		$withComparison = $this->attributes['withComparison'];

		$data = $this->data['infobox'];

		return array(
			'sessions' => $data['sessions'],
			'pageviews' => $data['pageviews'],
			'withComparison' => $withComparison,
		);
	}
}templates/scorecard/class-scorecard-top10countries.php000064400000004271151545722650017205 0ustar00<?php
/**
 * Class that handles the output for the Top 10 countries scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Top10countries
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Top10countries extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'top10countries';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$content = $this->get_table_template(
			$data['headers'],
			$data['rows']
		);

		return sprintf(
			"<div class=\"monsterinsights-table-scorecard with-2-columns\">%s</div>",
			$content
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if ( empty($this->data['countries'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['countries'];

		$rows = array();

		foreach ($data as $key => $country) {
			$rows[$key] = array( $country['name'], $country['sessions'] );
		}

		return array(
			'rows' => $rows,
			'headers' => array(
				__( 'Top 10 Countries', 'google-analytics-for-wordpress' ),
				__( 'Sessions', 'google-analytics-for-wordpress' )
			),
		);
	}

	private function get_table_template( $headers, $rows ) {
		$headers_output = '';
		$countries_output = '';

		foreach ( $headers as $key => $head ) {
			$headers_output .= sprintf( '<div class="monsterinsights-scorecard-table-head">%s</div>', $head );
		}

		foreach ( $rows as $key => $row ) {
			$items = '';

			foreach ( $row as $i => $column ) {
				$items .= sprintf( '<div class="monsterinsights-scorecard-table-column">%s</div>', $column );
			}

			$countries_output .= sprintf( '<div class="monsterinsights-scorecard-table-row">%s</div>', $items );
		}

		$header = sprintf(
			'<div class="monsterinsights-scorecard-table-header">%s</div>',
			$headers_output
		);

		$content = sprintf(
			'<div class="monsterinsights-scorecard-table-rows">%s</div>',
			$countries_output
		);

		$format = '<div class="monsterinsights-scorecard-table">%s</div>';

		return sprintf(
			$format,
			$header . $content
		);
	}
}templates/scorecard/class-scorecard-topinterests.php000064400000004270151545722650017050 0ustar00<?php
/**
 * Class that handles the output for the Top Interests scorecard.
 *
 * Class MonsterInsights_SiteInsights_Template_Scorecard_Topinterests
 */
class MonsterInsights_SiteInsights_Template_Scorecard_Topinterests extends MonsterInsights_SiteInsights_Metric_Template {

	protected $metric = 'topinterests';

	protected $type = 'scorecard';

	public function output(){
		$data = $this->get_options();

		if (empty($data)) {
			return false;
		}

		$content = $this->get_table_template(
			$data['headers'],
			$data['rows']
		);

		return sprintf(
			"<div class=\"monsterinsights-table-scorecard with-2-columns\">%s</div>",
			$content
		);
	}

	/**
	 * Returns data needed for this block.
	 *
	 * @return array|false
	 */
	protected function get_options() {
		if ( empty($this->data['interest'])) {
			return false;
		}

		$primaryColor = $this->attributes['primaryColor'];
		$secondaryColor = $this->attributes['secondaryColor'];

		$data = $this->data['interest'];

		$rows = array();

		foreach ($data as $key => $item) {
			$rows[$key] = array(
				$item['interest'],
				$item['percent'] . '%'
			);
		}

		return array(
			'rows' => $rows,
			'headers' => array(
				__( 'Categories', 'google-analytics-for-wordpress' ),
				__( '% of Interest', 'google-analytics-for-wordpress' )
			),
		);
	}

	private function get_table_template( $headers, $rows ) {
		$headers_output = '';
		$countries_output = '';

		foreach ( $headers as $key => $head ) {
			$headers_output .= sprintf( '<div class="monsterinsights-scorecard-table-head">%s</div>', $head );
		}

		foreach ( $rows as $key => $row ) {
			$items = '';

			foreach ( $row as $i => $column ) {
				$items .= sprintf( '<div class="monsterinsights-scorecard-table-column">%s</div>', $column );
			}

			$countries_output .= sprintf( '<div class="monsterinsights-scorecard-table-row">%s</div>', $items );
		}

		$header = sprintf(
			'<div class="monsterinsights-scorecard-table-header">%s</div>',
			$headers_output
		);

		$content = sprintf(
			'<div class="monsterinsights-scorecard-table-rows">%s</div>',
			$countries_output
		);

		$format = '<div class="monsterinsights-scorecard-table">%s</div>';

		return sprintf(
			$format,
			$header . $content
		);
	}
}