This commit is contained in:
Lem Smyth 2022-02-13 13:11:29 -06:00
parent a1dc6319e2
commit ee92d4859a

View file

@ -4,6 +4,7 @@
* *
* @package LBRYPress * @package LBRYPress
*/ */
defined('ABSPATH') || die(); // Exit if accessed directly
class LBRY_Admin class LBRY_Admin
{ {
@ -25,13 +26,14 @@ class LBRY_Admin
*/ */
public function create_options_page() public function create_options_page()
{ {
add_menu_page( add_menu_page(
__( 'LBRYPress Settings', 'lbrypress' ), __( 'LBRYPress Settings', 'lbrypress' ),
__( 'LBRYPress', 'lbrypress' ), __( 'LBRYPress', 'lbrypress' ),
'manage_options', 'manage_options',
LBRY_ADMIN_PAGE, LBRY_ADMIN_PAGE,
array( $this, 'options_page_html' ), array( $this, 'options_page_html' ),
plugin_dir_url(LBRY_PLUGIN_FILE) . '/admin/images/lbry-logo.svg' plugin_dir_url( LBRY_PLUGIN_FILE ) . '/admin/images/lbry-icon.png'
); );
// Admin stylesheet enqueue // Admin stylesheet enqueue
@ -48,6 +50,20 @@ class LBRY_Admin
} }
} }
add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' );
// Admin Error Notices
function lbry_plugin_not_configured_notice() {
echo "<div id='notice' class='updated fade'><p>LBRYPress plugin is not configured yet. Please do it now.</p></div>\n";
}
$lbry_wallet = get_option('lbry_wallet');
if ( ! isset($lbry_wallet) ) {
add_action( 'admin_notices', 'lbry_plugin_not_configured_notice' );
}
function admin_permission_check() {
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
}
}
} }
/** /**
@ -267,7 +283,7 @@ class LBRY_Admin
$address = LBRY()->daemon->address_list(); $address = LBRY()->daemon->address_list();
$address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : ''; $address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : '';
printf( printf(
'<input type="text" id="%1$s" name="%2$s[%1$s]" value="%3$s" readonly />', '<input type="text" id="'. esc_attr('%1$s') .'" name="'. esc_attr('%2$s[%1$s]') .'" value="' . esc_attr('%3$s') . '" readonly />',
LBRY_WALLET, LBRY_WALLET,
LBRY_SETTINGS, LBRY_SETTINGS,
$address $address