Admin error messages (#57)

* some admin error msgs esc outputs for wallet field on admin page
This commit is contained in:
Lemuel Smyth 2022-02-13 12:44:15 -06:00 committed by GitHub
parent 2c9379394f
commit 557dd888fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 "<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 +282,7 @@ class LBRY_Admin
$address = LBRY()->daemon->address_list();
$address = is_array( $address ) && ! empty( $address ) ? $address[0]->address : '';
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_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(
'<input type="checkbox" id="lbry_default_publish_setting" name="' . esc_attr('%2$s[%1$s]') . '" value="1" ' . esc_attr( $checked ) . '><p>Set Default to always Publish to <strong>LBRY</strong>, this can be adjusted when publishing a New Post.</p>',
'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(
'<input type="checkbox" id="lbry_default_publish_setting" name="' . esc_attr('%2$s[%1$s]') . '" value="1" ' . esc_attr( $checked ) . '><p>Set Default to always Publish to <strong>LBRY</strong>, this can be adjusted when publishing a New Post.</p>',
'lbry_default_publish_setting',
LBRY_SETTINGS,
);
}
/**
* Checkbox to default to always allow publish on LBRY
*/
@ -359,7 +338,6 @@ class LBRY_Admin
<?php }
}
/**
* Prints License input
*/