Passed
Push — master ( a89a01...abfd6b )
by Tran Ngoc Tuan
02:44
created

Core::setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
namespace SlimSEO;
3
4
class Core {
5
	public function setup() {
6
		$this->load_textdomain();
7
8
		add_filter( 'plugin_action_links_slim-seo/slim-seo.php', [ $this, 'add_plugin_action_links' ] );
9
		add_filter( 'plugin_row_meta', [ $this, 'add_plugin_meta_links' ], 10, 2 );
10
	}
11
12
	private function load_textdomain() {
13
		unload_textdomain( 'slim-seo' );
14
		load_plugin_textdomain( 'slim-seo', false, basename( dirname( __DIR__ ) ) . '/languages/' );
15
	}
16
17
	public function add_plugin_action_links( array $links ): array {
18
		$links[]     = '<a href="' . esc_url( admin_url( 'options-general.php?page=slim-seo' ) ) . '">' . __( 'Settings', 'slim-seo' ) . '</a>';
19
		$upgradeable = apply_filters( 'slim_seo_upgradeable', true );
20
		if ( $upgradeable ) {
21
			$links[] = '<a href="https://elu.to/spp" style="color: #39b54a; font-weight: bold">' . esc_html__( 'Upgrade', 'slim-seo' ) . '</a>';
22
		}
23
		return $links;
24
	}
25
26
	public function add_plugin_meta_links( array $meta, string $file ) {
27
		if ( $file !== 'slim-seo/slim-seo.php' ) {
28
			return $meta;
29
		}
30
31
		$meta[] = '<a href="https://docs.wpslimseo.com?utm_source=plugin_links&utm_medium=link&utm_campaign=slim_seo" target="_blank">' . esc_html__( 'Documentation', 'slim-seo' ) . '</a>';
32
		$meta[] = '<a href="https://wordpress.org/support/plugin/slim-seo/reviews/?filter=5" target="_blank" title="' . esc_html__( 'Rate Slim SEO on WordPress.org', 'slim-seo' ) . '" style="color: #ffb900">'
33
			. str_repeat( '<span class="dashicons dashicons-star-filled" style="font-size: 16px; width:16px; height: 16px"></span>', 5 )
34
			. '</a>';
35
36
		return $meta;
37
	}
38
}
39