From 557dd888fa292ae11457bcb0fa84479494ee8537 Mon Sep 17 00:00:00 2001 From: Lemuel Smyth <36257395+lemsmyth@users.noreply.github.com> Date: Sun, 13 Feb 2022 12:44:15 -0600 Subject: [PATCH] Admin error messages (#57) * some admin error msgs esc outputs for wallet field on admin page --- classes/LBRY_Admin.php | 54 +++++++++++++----------------------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/classes/LBRY_Admin.php b/classes/LBRY_Admin.php index 3c00622..ed57234 100644 --- a/classes/LBRY_Admin.php +++ b/classes/LBRY_Admin.php @@ -25,6 +25,7 @@ class LBRY_Admin */ public function create_options_page() { + add_menu_page( __( 'LBRYPress Settings', 'lbrypress' ), __( 'LBRYPress', 'lbrypress' ), @@ -48,6 +49,20 @@ class LBRY_Admin } } add_action( 'admin_enqueue_scripts', 'load_admin_stylesheet' ); + + // Admin Error Notices + function lbry_plugin_not_configured_notice() { + echo "

LBRYPress plugin is not configured yet. Please do it now.

\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 +282,7 @@ class LBRY_Admin $address = LBRY()->daemon->address_list(); $address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : ''; printf( - '', + '', LBRY_WALLET, LBRY_SETTINGS, $address @@ -275,42 +290,6 @@ class LBRY_Admin } - /** - * Checkbox to default to always allow publish on LBRY - */ - public function lbry_always_pub_callback() - { - $options = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; - if ( ! isset( $options ) ) { - $options = 0; - } - $checked = checked( $options, 1, false ); - printf( - '

Set Default to always Publish to LBRY, this can be adjusted when publishing a New Post.

', - 'lbry_default_publish_setting', - LBRY_SETTINGS, - - ); - } - - /** - * Checkbox to default to always allow publish on LBRY - */ - public function lbry_always_pub_callback() - { - $options = get_option( LBRY_SETTINGS )['lbry_default_publish_setting']; - if ( ! isset( $options ) ) { - $options = 0; - } - $checked = checked( $options, 1, false ); - printf( - '

Set Default to always Publish to LBRY, this can be adjusted when publishing a New Post.

', - 'lbry_default_publish_setting', - LBRY_SETTINGS, - - ); - } - /** * Checkbox to default to always allow publish on LBRY */ @@ -359,7 +338,6 @@ class LBRY_Admin