PluginProbe
Posts Table with Search & Sort / 1.4.13
Posts Table with Search & Sort v1.4.13
1.4.13 trunk 1.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.2 1.3 1.3.1 1.3.1-v2 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 All 40 releases
posts-data-table / src / Admin / Admin_Controller.php

Admin_Controller.php in Posts Table with Search & Sort 1.4.13, at src/Admin/Admin_Controller.php

79 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Barn2\Plugin\Posts_Table_Search_Sort\Admin;
3
4 use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Util;
5 use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Plugin\Plugin;
6 use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Registerable;
7 use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Service\Standard_Service;
8 use Barn2\Plugin\Posts_Table_Search_Sort\Dependencies\Lib\Service\Service_Container;
9
10 /**
11 * Handles general admin functions, such as adding links to our settings page in the Plugins menu.
12 *
13 * @package Barn2\posts-table-search-sort
14 * @author Barn2 Plugins <support@barn2.com>
15 * @license GPL-3.0
16 * @copyright Barn2 Media Ltd
17 */
18 class Admin_Controller implements Registerable, Standard_Service {
19
20 use Service_Container;
21
22 private $plugin;
23 private $settings_page;
24
25 public function __construct( Plugin $plugin ) {
26 $this->plugin = $plugin;
27 // $this->settings_page = new Settings_Page( $plugin );
28 }
29
30 public function register() {
31 $this->register_services();
32 $this->start_all_services();
33 // Extra links on Plugins page
34 add_filter( 'plugin_action_links_' . $this->plugin->get_basename(), [ $this, 'add_settings_link' ] );
35 add_filter( 'plugin_row_meta', [ $this, 'add_pro_version_link' ], 10, 2 );
36
37 // Admin scripts
38 add_action( 'admin_enqueue_scripts', [ $this, 'settings_page_scripts' ] );
39
40 // $this->settings_page->register();
41 }
42
43 public function add_settings_link( $links ) {
44 array_unshift(
45 $links,
46 sprintf(
47 '<a href="%1$s">%2$s</a>',
48 esc_url( $this->plugin->get_settings_page_url() ),
49 esc_html__( 'Settings', 'posts-data-table' )
50 )
51 );
52 return $links;
53 }
54
55 public function add_pro_version_link( $links, $file ) {
56 if ( $file === $this->plugin->get_basename() ) {
57 $links[] = sprintf(
58 '<a href="%1$s" target="_blank"><strong>%2$s</strong></a>',
59 esc_url( 'https://barn2.com/wordpress-plugins/posts-table-pro/?utm_source=settings&utm_medium=settings&utm_campaign=settingsinline&utm_content=ptss-ptp' ),
60 esc_html__( 'Pro Version', 'posts-data-table' )
61 );
62 }
63
64 return $links;
65 }
66
67 public function add_services() {
68 $this->add_service( 'settings_page', new Settings_Page( $this->plugin ) );
69 }
70
71 public function settings_page_scripts( $hook ) {
72 if ( 'settings_page_posts_table_search_sort' === $hook ) {
73 $suffix = Util::get_script_suffix();
74 wp_enqueue_style( 'ptss-admin', plugins_url( "assets/css/admin/posts-data-table-admin.css", $this->plugin->get_file() ), [], $this->plugin->get_version() );
75 }
76 }
77
78 }
79