PluginProbe
Email Log / 2.1.0
Email Log v2.1.0
2.63 2.4.8 2.4.9 2.6 2.61 2.62 trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 0.9.2 1.1 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 61 releases
email-log / include / Core / UI / Component / AdminUIEnhancer.php

AdminUIEnhancer.php in Email Log 2.1.0, at include/Core/UI/Component/AdminUIEnhancer.php

114 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace EmailLog\Core\UI\Component;
2
3 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
4
5 /**
6 * Enhance Admin UI and add links about EmailLog in the following places.
7 * - Plugin List page.
8 * - Footer for all EmailLog pages.
9 *
10 * @since 2.0.0
11 */
12 class AdminUIEnhancer {
13
14 /**
15 * Plugin file name.
16 *
17 * @var string
18 */
19 protected $plugin_file;
20
21 /**
22 * Plugin basename.
23 *
24 * @var string
25 */
26 protected $plugin_basename;
27
28 /**
29 * Initialize the component and store the plugin basename.
30 *
31 * @param string|null $file Plugin file.
32 */
33 public function __construct( $file = null ) {
34 if ( null === $file ) {
35 $email_log = email_log();
36 $file = $email_log->get_plugin_file();
37 }
38
39 $this->plugin_file = $file;
40 $this->plugin_basename = plugin_basename( $file );
41 }
42
43 /**
44 * Setup hooks.
45 *
46 * @inheritdoc
47 */
48 public function load() {
49 add_filter( 'plugin_row_meta', array( $this, 'insert_addon_store_link' ), 10, 2 );
50 add_filter( 'plugin_action_links_' . $this->plugin_basename, array( $this, 'insert_view_logs_link' ) );
51
52 add_action( 'el_admin_footer', array( $this, 'hook_footer_links' ) );
53 }
54
55 /**
56 * Add link to Add-ons store.
57 *
58 * @see Additional links in the Plugin listing is based on
59 * @link http://zourbuth.com/archives/751/creating-additional-wordpress-plugin-links-row-meta/
60 *
61 * @param array $links Array with default links to display in plugins page.
62 * @param string $file The name of the plugin file.
63 *
64 * @return array Modified list of links to display in plugins page.
65 */
66 public function insert_addon_store_link( $links, $file ) {
67 if ( $file === $this->plugin_basename ) {
68 $links[] = '<a href="https://wpemaillog.com/store/?utm_campaign=Upsell&utm_medium=wpadmin&utm_source=plugin-page" target="_blank">' .
69 __( 'Buy Addons', 'email-log' ) . '</a>';
70 }
71
72 return $links;
73 }
74
75 /**
76 * Add link to 'View logs' page in plugin listing page.
77 *
78 * @param array $links List of links.
79 *
80 * @return array Modified list of links.
81 */
82 public function insert_view_logs_link( $links ) {
83 $settings_link = '<a href="admin.php?page=email-log">' . __( 'View Logs', 'email-log' ) . '</a>';
84 array_unshift( $links, $settings_link );
85
86 return $links;
87 }
88
89 /**
90 * Hook Footer links.
91 */
92 public function hook_footer_links() {
93 add_action( 'in_admin_footer', array( $this, 'add_credit_links' ) );
94 }
95
96 /**
97 * Adds Footer links.
98 *
99 * @since Genesis
100 *
101 * @see Function relied on
102 * @link http://striderweb.com/nerdaphernalia/2008/06/give-your-wordpress-plugin-credit/
103 */
104 public function add_credit_links() {
105 $plugin_data = get_plugin_data( $this->plugin_file );
106 printf(
107 '%1$s ' . __( 'plugin', 'email-log' ) . ' | ' . __( 'Version', 'email-log' ) . ' %2$s | ' . __( 'by', 'email-log' ) . ' %3$s<br />',
108 $plugin_data['Title'],
109 $plugin_data['Version'],
110 $plugin_data['Author']
111 );
112 }
113 }
114