Completed
Branch master (136588)
by
unknown
02:26
created

ALNP_Admin_Action_Links::plugin_row_meta()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 3
dl 0
loc 32
rs 9.408
c 0
b 0
f 0
1
<?php
2
/**
3
 * Auto Load Next Post - Admin Action Links.
4
 *
5
 * Adds links to Auto Load Next Post on the plugins page.
6
 *
7
 * @since    1.6.0
8
 * @author   Sébastien Dumont
9
 * @category Admin
10
 * @package  Auto Load Next Post/Admin
11
 * @license  GPL-2.0+
12
 */
13
14
// Exit if accessed directly.
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
if ( ! class_exists( 'ALNP_Admin_Action_Links' ) ) {
20
21
	class ALNP_Admin_Action_Links {
22
23
		/**
24
		 * Constructor
25
		 *
26
		 * @access public
27
		 */
28
		public function __construct() {
29
			add_filter( 'plugin_action_links_' . plugin_basename( AUTO_LOAD_NEXT_POST_FILE ), array( $this, 'plugin_action_links' ) );
30
			add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta'), 10, 3 );
31
		} // END __construct()
32
33
		/**
34
		 * Plugin action links.
35
		 *
36
		 * @access public
37
		 * @param  array $links An array of plugin links.
38
		 * @return array $links
39
		 */
40
		public function plugin_action_links( $links ) {
41
			if ( current_user_can( 'manage_options' ) ) {
42
				$action_links = array(
43
					'getting-started' => '<a href="' . add_query_arg( array( 'page' => 'auto-load-next-post', 'view' => 'getting-started' ), admin_url( 'options-general.php' ) ) . '" aria-label="' . sprintf( esc_attr__( 'Getting Started with %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '">' . esc_attr__( 'Getting Started', 'auto-load-next-post' ) . '</a>',
44
					'settings'        => '<a href="' . add_query_arg( array( 'page' => 'auto-load-next-post' ), admin_url( 'options-general.php' ) ) . '" aria-label="' . sprintf( esc_attr__( 'View %s settings', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '">' . esc_attr__( 'Settings', 'auto-load-next-post' ) . '</a>'
45
				);
46
47
				return array_merge( $action_links, $links );
48
			}
49
50
			return $links;
51
		} // END plugin_action_links()
52
53
		/**
54
		 * Plugin row meta links
55
		 *
56
		 * @access public
57
		 * @param  array  $metadata An array of the plugin's metadata.
58
		 * @param  string $file     Path to the plugin file.
59
		 * @param  array  $data     Plugin Information
60
		 * @return array  $metadata
61
		 */
62
		public function plugin_row_meta( $metadata, $file, $data ) {
63
			if ( $file == plugin_basename( AUTO_LOAD_NEXT_POST_FILE ) ) {
64
				$metadata[ 1 ] = sprintf( __( 'Developed By %s', 'auto-load-next-post' ), '<a href="' . $data[ 'AuthorURI' ] . '" aria-label="' . esc_attr__( 'View the developers site', 'auto-load-next-post' ) . '">' . $data[ 'Author' ] . '</a>' );
65
66
				$campaign_args = array(
67
					'utm_medium'   => 'auto-load-next-post-lite',
68
					'utm_source'   => 'plugins-page',
69
					'utm_campaign' => 'plugins-row',
70
					'utm_content'  => 'go-pro',
71
				);
72
73
				$theme_support = add_query_arg( $campaign_args, AUTO_LOAD_NEXT_POST_STORE_URL . 'product/theme-support/' );
74
75
				$row_meta = array(
76
					'docs' => '<a href="' . esc_url( 'https://github.com/autoloadnextpost/alnp-documentation/tree/master/en_US#the-manual' ) . '" aria-label="' . sprintf( esc_attr__( 'View %s documentation', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '" target="_blank">' . esc_attr__( 'Documentation', 'auto-load-next-post' ) . '</a>',
77
					'community' => '<a href="' . esc_url( 'https://wordpress.org/support/plugin/auto-load-next-post' ) . '" aria-label="' . esc_attr__( 'Get support from the community', 'auto-load-next-post' ). '" target="_blank">' . esc_attr__( 'Community Support', 'auto-load-next-post' ) . '</a>',
78
					'theme-support' => '<a href="' . esc_url( $theme_support ) . '" attr-label="' . esc_attr__( 'Get theme support', 'auto-load-next-post' ) . '" target="_blank">' . esc_attr__( 'Theme Support', 'auto-load-next-post' ) . '</a>',
79
					'review' => '<a href="' . esc_url( AUTO_LOAD_NEXT_POST_REVIEW_URL ) . '" aria-label="' . sprintf( esc_attr__( 'Review %s on WordPress.org', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post', 'auto-load-next-post' ) ) . '" target="_blank">' . esc_attr__( 'Leave a Review', 'auto-load-next-post' ) . '</a>',
80
				);
81
82
				// Checks if Auto Load Next Post Pro has been installed.
83
				if ( ! is_alnp_pro_version_installed() ) {
84
					$store_url = add_query_arg( $campaign_args, AUTO_LOAD_NEXT_POST_STORE_URL . 'pro/' );
85
86
					$row_meta['pro'] = sprintf( '<a href="%1$s" aria-label="' . sprintf( esc_attr__( 'Sign up for %s', 'auto-load-next-post' ), esc_html__( 'Auto Load Next Post Pro', 'auto-load-next-post' ) ) . '" target="_blank" style="color: #c00; font-weight: 700;">%2$s</a>', esc_url( $store_url ), esc_attr__( 'Pro Coming Soon', 'auto-load-next-post' ) );
87
				}
88
89
				$metadata = array_merge( $metadata, $row_meta );
90
			}
91
92
			return $metadata;
93
		} // END plugin_row_meta()
94
95
	} // END class
96
97
} // END if class exists
98
99
return new ALNP_Admin_Action_Links();
100