PluginProbe
Admin Bar Editor – Toolbar Customization with User Role based access & Custom menus / trunk
Admin Bar Editor – Toolbar Customization with User Role based access & Custom menus vtrunk
1.1.10 1.1.9 1.1.8 1.1.7 trunk 1.0 1.0.1 1.0.2.1 1.0.2.2 1.0.2.3 1.0.2.4 1.0.2.5 1.0.2.6 1.0.2.7 1.0.2.8 1.0.2.9 1.0.3.0 1.0.4.0 1.1.0 1.1.2 1.1.2.0 1.1.2.1 1.1.2.2 1.1.3 1.1.4 All 27 releases
admin-bar / Libs / Recommended.php

Recommended.php in Admin Bar Editor – Toolbar Customization with User Role based access & Custom menus trunk, at Libs/Recommended.php

76 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace JewelTheme\AdminBarEditor\Libs;
3
4 // No, Direct access Sir !!!
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 if ( ! class_exists( 'Recommended' ) ) {
10
11 /**
12 * Recommended Class
13 *
14 * Adds a submenu that links to the WordPress plugin install screen
15 * filtered by author.
16 *
17 * Jewel Theme <support@jeweltheme.com>
18 */
19 class Recommended {
20
21 public $parent_slug;
22 public $menu_title;
23 public $author;
24 public $menu_order;
25
26 /**
27 * Constructor.
28 *
29 * @param string $parent_slug Parent menu slug to attach submenu under.
30 * @param string $author WordPress.org plugin author slug to filter by.
31 * @param string $menu_title Submenu label.
32 * @param integer $menu_order Submenu order priority.
33 */
34 public function __construct( $parent_slug = '', $author = 'pixarlabs', $menu_title = '', $menu_order = 99 ) {
35 $this->parent_slug = $parent_slug;
36 $this->author = $author;
37 $this->menu_title = $menu_title;
38 $this->menu_order = $menu_order;
39
40 add_action( 'admin_menu', array( $this, 'admin_menu' ), $this->menu_order );
41 }
42
43 /**
44 * Build the plugin-install URL filtered by author.
45 */
46 public function get_recommended_url() {
47 $url = 'plugin-install.php?tab=search&type=author&s=' . rawurlencode( $this->author );
48
49 if( is_multisite() ) {
50 return network_admin_url( $url );
51 }
52
53 return admin_url( $url );
54 }
55
56 /**
57 * Register submenu pointing directly to plugin-install screen.
58 */
59 public function admin_menu() {
60 if ( empty( $this->parent_slug ) ) {
61 return;
62 }
63
64 $title = $this->menu_title ? $this->menu_title : __( 'Recommended', 'admin-bar' );
65
66 add_submenu_page(
67 $this->parent_slug,
68 $title,
69 $title,
70 'install_plugins',
71 $this->get_recommended_url()
72 );
73 }
74 }
75 }
76