PluginProbe
Additional Terms Lite for WooCommerce / 1.6.0
Additional Terms Lite for WooCommerce v1.6.0
1.7.3 1.7.2.1 trunk 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.6.2 1.6.3 All 35 releases
woo-additional-terms / src / Enhancements / Meta.php

Meta.php in Additional Terms Lite for WooCommerce 1.6.0, at src/Enhancements/Meta.php

120 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The plugin meta class.
4 *
5 * @author MyPreview (Github: @mahdiyazdani, @gooklani, @mypreview)
6 *
7 * @since 1.0.0
8 *
9 * @package woo-additional-terms
10 */
11
12 namespace Woo_Additional_Terms\Enhancements;
13
14 use Woo_Additional_Terms\Helper;
15
16 /**
17 * The plugin meta class.
18 */
19 class Meta {
20
21 /**
22 * The plugin basename.
23 *
24 * @since 1.0.0
25 *
26 * @var string
27 */
28 private $plugin_basename;
29
30 /**
31 * Setup hooks and filters.
32 *
33 * @since 1.0.0
34 *
35 * @param string $plugin_basename The plugin basename.
36 *
37 * @return void
38 */
39 public function setup( $plugin_basename ) {
40
41 // Set the plugin basename.
42 $this->plugin_basename = $plugin_basename;
43
44 add_filter( 'plugin_row_meta', array( $this, 'meta_links' ), 10, 2 );
45 add_filter( "plugin_action_links_{$this->plugin_basename}", array( $this, 'action_links' ) );
46 }
47
48 /**
49 * Add additional helpful links to the plugin’s metadata.
50 *
51 * @since 1.0.0
52 *
53 * @param array $links An array of the plugin’s metadata.
54 * @param string $file Path to the plugin file relative to the plugins' directory.
55 *
56 * @return array
57 */
58 public function meta_links( $links, $file ) {
59
60 // Return early if not on the plugin page.
61 if ( $this->plugin_basename !== $file ) {
62 return $links;
63 }
64
65 $plugin_links = array(
66 sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */
67 esc_html_x( '%1$sDocs%2$s', 'plugin link', 'woo-additional-terms' ),
68 sprintf(
69 '<a href="%s" target="_blank" rel="noopener noreferrer nofollow">',
70 esc_url( Helper\Links::docs_uri() )
71 ),
72 '</a>'
73 ),
74 sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */
75 esc_html_x( '%1$sCommunity support%2$s', 'plugin link', 'woo-additional-terms' ),
76 sprintf(
77 '<a href="https://wordpress.org/support/plugin/%s" target="_blank" rel="noopener noreferrer nofollow">',
78 esc_attr( woo_additional_terms()->get_slug() )
79 ),
80 '</a>'
81 ),
82 );
83
84 return array_merge( $links, $plugin_links );
85 }
86
87 /**
88 * Display additional links in the plugin table page.
89 * Filters the list of action links displayed for a specific plugin in the Plugins list table.
90 *
91 * @since 1.0.0
92 *
93 * @param array $links Plugin table/item action links.
94 *
95 * @return array
96 */
97 public function action_links( $links ) {
98
99 $plugin_links = array();
100 $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */
101 esc_html_x( '%1$sGet PRO%2$s', 'plugin link', 'woo-additional-terms' ),
102 sprintf(
103 '<a href="%s" target="_blank" rel="noopener noreferrer nofollow" style="color:green;font-weight:bold;">&#9989; ',
104 esc_url( Helper\Links::pro_uri() )
105 ),
106 '</a>'
107 );
108 $plugin_links[] = sprintf( /* translators: 1: Open anchor tag, 2: Close anchor tag. */
109 esc_html_x( '%1$sSettings%2$s', 'plugin settings page', 'woo-additional-terms' ),
110 sprintf(
111 '<a href="%s">',
112 esc_url( Helper\Settings::page_uri() )
113 ),
114 '</a>'
115 );
116
117 return array_merge( $plugin_links, $links );
118 }
119 }
120