PluginProbe
seQura / 3.0.2
seQura v3.0.2
4.3.4 4.3.3 4.3.2 4.3.1 trunk 2.0.0 2.0.10 2.0.11 2.0.12 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 3.0.0 3.0.2 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 4.0.0 All 30 releases
sequra / src / Controllers / Hooks / Settings / class-settings-controller.php

class-settings-controller.php in seQura 3.0.2, at src/Controllers/Hooks/Settings/class-settings-controller.php

169 lines 4.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Implementation for the settings controller.
4 *
5 * @package SeQura/WC
6 * @subpackage SeQura/WC/Controllers
7 */
8
9 namespace SeQura\WC\Controllers\Hooks\Settings;
10
11 use SeQura\WC\Controllers\Controller;
12 use SeQura\WC\Core\Extension\Infrastructure\Configuration\Configuration;
13 use SeQura\WC\Services\Interface_Logger_Service;
14
15 /**
16 * Implementation for the settings controller.
17 */
18 class Settings_Controller extends Controller implements Interface_Settings_Controller {
19
20 /**
21 * Configuration service.
22 *
23 * @var Configuration
24 */
25 private $configuration;
26
27 /**
28 * Plugin basename.
29 */
30 private $plugin_basename;
31
32 /**
33 * Constructor.
34 */
35 public function __construct(
36 string $templates_path,
37 Configuration $configuration,
38 Interface_Logger_Service $logger,
39 string $plugin_basename
40 ) {
41 parent::__construct( $logger, $templates_path );
42 $this->configuration = $configuration;
43 $this->plugin_basename = $plugin_basename;
44 }
45
46 /**
47 * Register the settings page.
48 */
49 public function register_page(): void {
50 $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ );
51 add_submenu_page(
52 $this->configuration->get_parent_page(),
53 __( 'seQura', 'sequra' ),
54 __( 'seQura', 'sequra' ),
55 'manage_options',
56 $this->configuration->get_page(),
57 array( $this, 'render_page' )
58 );
59
60 // Additionally remove WP version footer text if we are in the settings page.
61 if ( $this->configuration->is_settings_page() ) {
62 remove_filter( 'update_footer', 'core_update_footer' );
63 }
64 }
65
66 /**
67 * Render the settings page.
68 */
69 public function render_page(): void {
70 $this->logger->log_info( 'Callback executed', __FUNCTION__, __CLASS__ );
71 wc_get_template( 'admin/settings_page.php', array(), '', $this->templates_path );
72 }
73
74 /**
75 * Get the settings page URL.
76 */
77 public function get_settings_page_url( ?string $url = null ): string {
78 return admin_url( 'admin.php?page=' . $this->configuration->get_page() );
79 }
80
81 /**
82 * Add action links to the plugin settings page.
83 *
84 * @param string[] $actions The actions.
85 * @param string $plugin_file The plugin file.
86 * @param string $plugin_data The plugin data.
87 * @param string $context The context.
88 * @return mixed[]
89 */
90 public function add_action_link( $actions, $plugin_file, $plugin_data, $context ): array {
91 $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ );
92 $args = array(
93 'href' => $this->get_settings_page_url(),
94 'text' => esc_attr__( 'Settings', 'sequra' ),
95 );
96 ob_start();
97 wc_get_template( 'admin/action_link.php', $args, '', $this->templates_path );
98 $actions['settings'] = ob_get_clean();
99 return $actions;
100 }
101
102 /**
103 * Removes the WP footer message
104 */
105 public function remove_footer_admin( string $text ): string {
106 $this->logger->log_info( 'Hook executed', __FUNCTION__, __CLASS__ );
107 if ( ! $this->configuration->is_settings_page() ) {
108 return $text;
109 }
110 return '';
111 }
112
113 /**
114 * Show row meta on the plugin screen.
115 *
116 * @param array $links Plugin Row Meta.
117 * @param string $file Plugin Base file.
118 */
119 public function add_plugin_row_meta( $links, $file ): array {
120 if ( $this->plugin_basename === $file ) {
121 $row_meta = array(
122 'docs' => sprintf(
123 '<a href="%s" aria-label="%s" target="_blank">%s</a>',
124 esc_url(
125 /**
126 * Filters the URL of the plugin documentation.
127 *
128 * @since 2.0.0
129 */
130 apply_filters( 'sequrapayment_docs_url', 'https://sequra.atlassian.net/wiki/spaces/DOC/pages/2247524378/WOOCOMMERCE' )
131 ),
132 esc_attr__( 'View WooCommerce documentation', 'sequra' ),
133 esc_html__( 'Docs', 'woocommerce' )
134 ),
135 'apidocs' => sprintf(
136 '<a href="%s" aria-label="%s" target="_blank">%s</a>',
137 esc_url(
138 /**
139 * Filters the URL of the plugin API documentation.
140 *
141 * @since 2.0.0
142 */
143 apply_filters( 'sequrapayment_apidocs_url', 'https://docs.sequrapi.com/' )
144 ),
145 esc_attr__( 'View WooCommerce API docs', 'sequra' ),
146 esc_html__( 'API docs', 'sequra' )
147 ),
148 'support' => sprintf(
149 '<a href="%s" aria-label="%s" target="_blank">%s</a>',
150 esc_url(
151 /**
152 * Filters the URL of the plugin support.
153 *
154 * @since 2.0.0
155 */
156 apply_filters( 'sequrapayment_support_url', 'https://sequra.atlassian.net/servicedesk/customer/portal/5/group/-1' )
157 ),
158 esc_attr__( 'Support', 'sequra' ),
159 esc_html__( 'Support', 'sequra' )
160 ),
161 );
162
163 return array_merge( $links, $row_meta );
164 }
165
166 return (array) $links;
167 }
168 }
169