Changeset 2334429
- Timestamp:
- 07/02/2020 06:15:11 PM (6 years ago)
- Location:
- oauth2-server/trunk
- Files:
-
- 6 edited
-
admin/class-codexshaper-oauth-server-admin-menu.php (modified) (2 diffs)
-
admin/class-codexshaper-oauth-server-admin-submenu.php (modified) (2 diffs)
-
bootstrap/app.php (modified) (1 diff)
-
composer.json (modified) (1 diff)
-
includes/class-codexshaper-oauth-server.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
oauth2-server/trunk/admin/class-codexshaper-oauth-server-admin-menu.php
r2333274 r2334429 23 23 class Codexshaper_Oauth_Server_Admin_Menu { 24 24 25 public $page_title; 25 /** 26 * The menu page title. 27 * 28 * @since 1.0.0 29 * @access public 30 * @var string $page_title The string used to set menu page title. 31 */ 32 public $page_title; 26 33 34 /** 35 * The menu title. 36 * 37 * @since 1.0.0 38 * @access public 39 * @var string $menu_title The string used to set menu title. 40 */ 27 41 public $menu_title; 28 42 43 /** 44 * The menu capability. 45 * 46 * @since 1.0.0 47 * @access public 48 * @var string $capability The string used to set menu capability. 49 */ 29 50 public $capability; 30 51 52 /** 53 * The menu slug. 54 * 55 * @since 1.0.0 56 * @access public 57 * @var string $slug The string used to set menu slug. 58 */ 31 59 public $slug; 32 60 61 /** 62 * The callback to render content. 63 * 64 * @since 1.0.0 65 * @access public 66 * @var callback $callback The callback used to render content. 67 */ 33 68 public $callback; 34 69 70 /** 71 * The menu icon. 72 * 73 * @since 1.0.0 74 * @access public 75 * @var string $icon The string used to set menu icon. 76 */ 35 77 public $icon; 36 78 79 /** 80 * The menu position. 81 * 82 * @since 1.0.0 83 * @access public 84 * @var int $position The string used to set menu position. 85 */ 37 86 public $position; 38 87 39 public $plugin_name; 88 /** 89 * The menu plugin name. 90 * 91 * @since 1.0.0 92 * @access private 93 * @var string $plugin_name The string used to uniquely identify this plugin. 94 */ 95 private $plugin_name; 40 96 41 public function save() 42 { 43 add_action('admin_menu', [$this, 'create_menu']); 97 /** 98 * Boot Menu. 99 * 100 * @param string $plugin_name The string used to uniquely identify this plugin. 101 * @since 1.0.0 102 * @access public 103 */ 104 public function __construct( $plugin_name ) { 105 $this->plugin_name = $plugin_name; 44 106 } 45 107 46 public static function make($options = []) 47 { 48 foreach ($options as $property => $value) { 49 if (property_exists($this, $property)) { 108 /** 109 * Create a new menu page. 110 * 111 * @since 1.0.0 112 * @access public 113 */ 114 public function save() { 115 add_action( 'admin_menu', array( $this, 'create_menu' ) ); 116 } 117 118 /** 119 * Create a new menu page. 120 * 121 * @since 1.0.0 122 * @param array $options Pass proprties as an array. 123 * @access public 124 */ 125 public function make( $options = array() ) { 126 foreach ( $options as $property => $value ) { 127 if ( property_exists( get_called_class(), $property ) ) { 50 128 $this->{$property} = $value; 51 129 } 52 130 } 53 add_action( 'admin_menu', [$this, 'create_menu']);131 add_action( 'admin_menu', array( $this, 'create_menu' ) ); 54 132 } 55 133 56 134 /** 57 * Register ourmenu page.135 * Register new menu page. 58 136 * 59 137 * @return void 60 138 */ 61 public function create_menu() 62 { 63 global $submenu; 64 139 public function create_menu() { 65 140 $hook = add_menu_page( 66 141 $this->page_title, … … 72 147 ); 73 148 74 // if ( current_user_can( $this->capability ) ) { 75 // $submenu[ $this->slug ][] = array( __( 'Clients', 'textdomain' ), $this->capability, 'admin.php?page=' . $this->slug . '#/clients' ); 76 // $submenu[ $this->slug ][] = array( __( 'Settings', 'textdomain' ), $this->capability, 'admin.php?page=' . $this->slug . '#/settings' ); 77 // } 78 79 add_action('load-'.$hook, [$this, 'init_hooks']); 149 add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); 80 150 } 81 151 82 152 /** 83 * Initialize ourhooks for the admin page.153 * Initialize hooks for the admin page. 84 154 * 85 155 * @return void 86 156 */ 87 public function init_hooks() 88 { 89 add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); 157 public function init_hooks() { 158 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 90 159 } 91 160 92 161 /** 93 * Load scripts and styles for the app.162 * Load scripts and styles for the current menu page. 94 163 * 95 164 * @return void 96 165 */ 97 public function enqueue_scripts() 98 { 99 wp_enqueue_style($this->plugin_name . '-vendors'); 100 wp_enqueue_style($this->plugin_name . '-admin'); 101 wp_enqueue_script($this->plugin_name . '-admin'); 102 } 103 104 /** 105 * Render our admin page. 106 * 107 * @return void 108 */ 109 public function plugin_page() 110 { 111 echo '<div class="wrap"><div id="'. $this->plugin_name .'-admin" csrf-token="'.csrf_token().'"></div></div>'; 166 public function enqueue_scripts() { 167 wp_enqueue_style( $this->plugin_name . '-vendors' ); 168 wp_enqueue_style( $this->plugin_name . '-admin' ); 169 wp_enqueue_script( $this->plugin_name . '-admin' ); 112 170 } 113 171 -
oauth2-server/trunk/admin/class-codexshaper-oauth-server-admin-submenu.php
r2333274 r2334429 23 23 class Codexshaper_Oauth_Server_Admin_SubMenu { 24 24 25 public $parent_slug; 26 25 /** 26 * The menu page title. 27 * 28 * @since 1.0.0 29 * @access public 30 * @var string $page_title The string used to set menu page title. 31 */ 27 32 public $page_title; 28 33 34 /** 35 * The menu title. 36 * 37 * @since 1.0.0 38 * @access public 39 * @var string $menu_title The string used to set menu title. 40 */ 29 41 public $menu_title; 30 42 43 /** 44 * The menu capability. 45 * 46 * @since 1.0.0 47 * @access public 48 * @var string $capability The string used to set menu capability. 49 */ 31 50 public $capability; 32 51 52 /** 53 * The menu slug. 54 * 55 * @since 1.0.0 56 * @access public 57 * @var string $slug The string used to set menu slug. 58 */ 33 59 public $slug; 34 60 61 /** 62 * The callback to render content. 63 * 64 * @since 1.0.0 65 * @access public 66 * @var callback $callback The callback used to render content. 67 */ 35 68 public $callback; 36 69 70 /** 71 * The menu icon. 72 * 73 * @since 1.0.0 74 * @access public 75 * @var string $icon The string used to set menu icon. 76 */ 77 public $icon; 78 79 /** 80 * The menu position. 81 * 82 * @since 1.0.0 83 * @access public 84 * @var int $position The string used to set menu position. 85 */ 37 86 public $position; 38 87 39 public $plugin_name; 88 /** 89 * The menu plugin name. 90 * 91 * @since 1.0.0 92 * @access private 93 * @var string $plugin_name The string used to uniquely identify this plugin. 94 */ 95 private $plugin_name; 40 96 41 public function save() 42 { 43 add_action('admin_menu', [$this, 'create_submenu']); 97 /** 98 * Boot Menu. 99 * 100 * @param string $plugin_name The string used to uniquely identify this plugin. 101 * @since 1.0.0 102 * @access public 103 */ 104 public function __construct( $plugin_name ) { 105 $this->plugin_name = $plugin_name; 44 106 } 45 107 46 public static function make($options = []) 47 { 48 foreach ($options as $property => $value) { 49 if (property_exists($this, $property)) { 108 /** 109 * Create a new menu page. 110 * 111 * @since 1.0.0 112 * @access public 113 */ 114 public function save() { 115 add_action( 'admin_menu', array( $this, 'create_submenu' ) ); 116 } 117 118 /** 119 * Create a new submenu page. 120 * 121 * @since 1.0.0 122 * @param array $options Pass proprties as an array. 123 * @access public 124 */ 125 public function make( $options = array() ) { 126 foreach ( $options as $property => $value ) { 127 if ( property_exists( $this, $property ) ) { 50 128 $this->{$property} = $value; 51 129 } 52 130 } 53 add_action( 'admin_menu', [$this, 'create_submenu']);131 add_action( 'admin_menu', array( $this, 'create_submenu' ) ); 54 132 } 55 133 56 134 /** 57 * Register ourmenu page.135 * Register new submenu page. 58 136 * 59 137 * @return void 60 138 */ 61 public function create_submenu() 62 { 63 if (current_user_can($this->capability)) { 139 public function create_submenu() { 140 if ( current_user_can( $this->capability ) ) { 64 141 $hook = add_submenu_page( 65 142 $this->parent_slug, … … 73 150 } 74 151 75 // if ( current_user_can( $this->capability ) ) { 76 // $submenu[ $this->slug ][] = array( __( 'Clients', 'textdomain' ), $this->capability, 'admin.php?page=' . $this->slug . '#/clients' ); 77 // $submenu[ $this->slug ][] = array( __( 'Settings', 'textdomain' ), $this->capability, 'admin.php?page=' . $this->slug . '#/settings' ); 78 // } 79 80 add_action('load-'.$hook, [$this, 'init_hooks']); 152 add_action( 'load-' . $hook, array( $this, 'init_hooks' ) ); 81 153 } 82 154 83 155 /** 84 * Initialize ourhooks for the admin page.156 * Initialize hooks for the admin page. 85 157 * 86 158 * @return void 87 159 */ 88 public function init_hooks() 89 { 90 add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); 160 public function init_hooks() { 161 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); 91 162 } 92 163 93 164 /** 94 * Load scripts and styles for the app.165 * Load scripts and styles for the submenu page. 95 166 * 96 167 * @return void 97 168 */ 98 public function enqueue_scripts() 99 { 100 wp_enqueue_style($this->plugin_name . '-vendors'); 101 wp_enqueue_style($this->plugin_name . '-admin'); 102 wp_enqueue_script($this->plugin_name . '-admin'); 169 public function enqueue_scripts() { 170 wp_enqueue_style( $this->plugin_name . '-vendors' ); 171 wp_enqueue_style( $this->plugin_name . '-admin' ); 172 wp_enqueue_script( $this->plugin_name . '-admin' ); 103 173 } 104 105 /**106 * Render our admin page.107 *108 * @return void109 */110 public function plugin_page()111 {112 echo '<div class="wrap"><div id="'. $this->plugin_name .'-admin" csrf-token="'.csrf_token().'"></div></div>';113 }114 115 174 } -
oauth2-server/trunk/bootstrap/app.php
r2334413 r2334429 1 1 <?php 2 /** 3 * The file that defines the bootsrap plugin 4 * 5 * @link https://github.com/maab16 6 * @since 1.0.0 7 * 8 * @package Codexshaper_Oauth_Server 9 * @subpackage Codexshaper_Oauth_Server/bootstrap 10 */ 2 11 3 12 require_once ABSPATH . 'wp-includes/pluggable.php'; -
oauth2-server/trunk/composer.json
r2333274 r2334429 40 40 "scripts": { 41 41 "post-autoload-dump": [ 42 "CodexShaper\\Composer\\ComposerScripts::post AutoloadDump"42 "CodexShaper\\Composer\\ComposerScripts::post_autoload_dump" 43 43 ], 44 44 "post-install-cmd": [ -
oauth2-server/trunk/includes/class-codexshaper-oauth-server.php
r2334413 r2334429 84 84 $this->define_oauth2_hooks(); 85 85 86 $menu = new Codexshaper_Oauth_Server_Admin_Menu(); 87 $menu->plugin_name = 'codexshaper-oauth-server'; 86 $menu = new Codexshaper_Oauth_Server_Admin_Menu($this->plugin_name); 88 87 $menu->page_title = 'OAuth2 Server'; 89 88 $menu->menu_title = 'OAuth2 Server'; … … 96 95 $menu->save(); 97 96 98 $submenu = new Codexshaper_Oauth_Server_Admin_SubMenu(); 99 $submenu->plugin_name = 'codexshaper-oauth-server'; 97 $submenu = new Codexshaper_Oauth_Server_Admin_SubMenu($this->plugin_name); 100 98 $submenu->parent_slug = $menu->slug; 101 99 $submenu->page_title = 'Clients'; -
oauth2-server/trunk/readme.txt
r2334413 r2334429 32 32 = 1.0 = 33 33 * This is the initial release. 34 35 == Contribution == 36 37 This is free open source project, so anyone can use and contribute. If you are interested you can contribute in our github repository https://github.com/Codexshaper/wp-oauth2. 38 39 If anyone found or face any security issue please mail us at codexshaper@gmail.com or create an issue in https://github.com/Codexshaper/wp-oauth2/issues. 40 41 = Contributors = 42 43 * [Md Abu Ahsan Basir](https://github.com/maab16)
Note: See TracChangeset
for help on using the changeset viewer.