PluginProbe
Posts Table with Search & Sort / 1.3.3
Posts Table with Search & Sort v1.3.3
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.3.3, at src/Admin/Admin_Controller.php

68 lines 2.2 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\PTS_Lib\Util,
5 Barn2\PTS_Lib\Plugin\Plugin,
6 Barn2\PTS_Lib\Registerable,
7 Barn2\PTS_Lib\Service;
8
9 /**
10 * Handles general admin functions, such as adding links to our settings page in the Plugins menu.
11 *
12 * @package Barn2\posts-table-search-sort
13 * @author Barn2 Plugins <support@barn2.co.uk>
14 * @license GPL-3.0
15 * @copyright Barn2 Media Ltd
16 */
17 class Admin_Controller implements Registerable, Service {
18
19 private $plugin;
20 private $settings_page;
21
22 public function __construct( Plugin $plugin ) {
23 $this->plugin = $plugin;
24 $this->settings_page = new Settings_Page();
25 }
26
27 public function register() {
28 // Extra links on Plugins page
29 add_filter( 'plugin_action_links_' . $this->plugin->get_basename(), array( $this, 'add_settings_link' ) );
30 add_filter( 'plugin_row_meta', array( $this, 'add_pro_version_link' ), 10, 2 );
31
32 // Admin scripts
33 add_action( 'admin_enqueue_scripts', array( $this, 'settings_page_scripts' ) );
34
35 $this->settings_page->register();
36 }
37
38 public function add_settings_link( $links ) {
39 array_unshift(
40 $links,
41 sprintf( '<a href="%1$s">%2$s</a>',
42 esc_url( admin_url( 'options-general.php?page=' . Settings_Page::MENU_SLUG ) ),
43 esc_html__( 'Settings', 'posts-data-table' )
44 )
45 );
46 return $links;
47 }
48
49 public function add_pro_version_link( $links, $file ) {
50 if ( $file === $this->plugin->get_basename() ) {
51 $links[] = sprintf( '<a href="%1$s" target="_blank"><strong>%2$s</strong></a>',
52 esc_url( 'https://barn2.co.uk/wordpress-plugins/posts-table-pro/' ),
53 esc_html__( 'Pro Version', 'posts-data-table' )
54 );
55 }
56
57 return $links;
58 }
59
60 public function settings_page_scripts( $hook ) {
61 if ( 'settings_page_posts_table_search_sort' === $hook ) {
62 $suffix = Util::get_script_suffix();
63 wp_enqueue_style( 'ptss-admin', plugins_url( "assets/css/admin/posts-data-table-admin{$suffix}.css", $this->plugin->get_file() ), array(), $this->plugin->get_version() );
64 }
65 }
66
67 }
68