Skip to content

Commit

Permalink
PHPCS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wolffe committed Oct 21, 2024
1 parent 34b2f81 commit f4b0e22
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions includes/fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function fxb_google_fonts() {
$font_array = array_unique( $font_array );
$font_array = str_replace( ' ', '+', $font_array );

$fxb_fonts = 'https://fonts.googleapis.com/css2?' . urlencode( implode( '&', $font_array ) ) . '&display=swap';
$fxb_fonts = 'https://fonts.googleapis.com/css2?' . rawurlencode( implode( '&', $font_array ) ) . '&display=swap';

return $fxb_fonts;
}
Expand All @@ -38,7 +38,7 @@ function fxb_bunny_fonts() {
$font_array = array_unique( $font_array );
$font_array = str_replace( ' ', '+', $font_array );

$fxb_fonts = 'https://fonts.bunny.net/css?family=' . urlencode( implode( '|', $font_array ) ) . '&display=swap';
$fxb_fonts = 'https://fonts.bunny.net/css?family=' . rawurlencode( implode( '|', $font_array ) ) . '&display=swap';

return $fxb_fonts;
}
Expand Down
25 changes: 14 additions & 11 deletions includes/settings/settings.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?php
function fxb_menu_links() {
add_menu_page( 'FX Builder Settings', 'FX Builder', 'manage_options', 'fx_builder', 'fxb_build_admin_page', 'dashicons-admin-home', 3 );

//add_submenu_page( 'property_drive', 'Alerts', 'Alerts', 'manage_options', 'wppd_alerts', 'wppd_build_alerts_page' );
//add_submenu_page( 'property_drive', 'Contacts', 'Contacts', 'manage_options', 'edit.php?post_type=contact' );
}

add_action( 'admin_menu', 'fxb_menu_links', 10 );
Expand All @@ -19,22 +16,26 @@ function fxb_build_admin_page() {
<h1>FX Builder</h1>

<h2 class="nav-tab-wrapper nav-tab-wrapper-wppd">
<a href="<?php echo $section; ?>dashboard" class="nav-tab <?php echo $tab === 'dashboard' ? 'nav-tab-active' : ''; ?>">Dashboard</a>
<a href="<?php echo esc_attr( $section ); ?>dashboard" class="nav-tab <?php echo $tab === 'dashboard' ? 'nav-tab-active' : ''; ?>">Dashboard</a>

<a href="<?php echo $section; ?>settings" class="nav-tab <?php echo $tab === 'settings' ? 'nav-tab-active' : ''; ?>">Settings</a>
<a href="<?php echo esc_attr( $section ); ?>settings" class="nav-tab <?php echo $tab === 'settings' ? 'nav-tab-active' : ''; ?>">Settings</a>

<a href="<?php echo $section; ?>help" class="nav-tab <?php echo $tab === 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
<a href="<?php echo esc_attr( $section ); ?>help" class="nav-tab <?php echo $tab === 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
</h2>

<?php if ( $tab === 'dashboard' ) { ?>
<h3 class="identityblock">FX Builder <code class="codeblock"><?php echo FX_BUILDER_VERSION; ?></code></h3>
<h3 class="identityblock">FX Builder <code class="codeblock"><?php echo esc_attr( FX_BUILDER_VERSION ); ?></code></h3>
<?php
} elseif ( $tab === 'settings' ) {
?>
<h2>Settings</h2>

<?php
if ( isset( $_POST['save_settings'] ) ) {
if ( ! isset( $_POST['fxb_settings_nonce'] ) || ! check_admin_referer( 'save_fxb_settings_action', 'fxb_settings_nonce' ) ) {
wp_die( esc_html__( 'Nonce verification failed. Please try again.', 'fx-builder' ) );
}

// Get previously saved post types
$previous_post_types = get_option( 'fx-builder_post_types', [] );

Expand Down Expand Up @@ -65,15 +66,17 @@ function fxb_build_admin_page() {

delete_option( 'fxb_font_provider' );

echo '<div class="updated notice is-dismissible"><p>' . __( 'Settings updated successfully!', 'fx-builder' ) . '</p></div>';
echo '<div class="updated notice is-dismissible"><p>' . esc_html__( 'Settings updated successfully!', 'fx-builder' ) . '</p></div>';
}
?>

<form method="post">
<?php wp_nonce_field( 'save_fxb_settings_action', 'fxb_settings_nonce' ); ?>

<table class="form-table">
<tbody>
<tr>
<th scope="row"><label><?php echo __( 'Enable FX Builder in', 'fx-builder' ); ?></label></th>
<th scope="row"><label><?php echo esc_html__( 'Enable FX Builder in', 'fx-builder' ); ?></label></th>
<td>
<?php
$post_types = get_post_types(
Expand Down Expand Up @@ -121,7 +124,7 @@ function fxb_build_admin_page() {

<?php if ( (string) get_option( 'fxb_google_fonts_api' ) !== '' ) { ?>
<script>
let currentFXBFontOption = <?php echo json_encode( (array) get_option( 'fxb_google_fonts' ) ); ?>;
let currentFXBFontOption = <?php echo wp_json_encode( (array) get_option( 'fxb_google_fonts' ) ); ?>;

fetch('https://www.googleapis.com/webfonts/v1/webfonts?key=<?php echo (string) get_option( 'fxb_google_fonts_api' ); ?>')

Check failure on line 129 in includes/settings/settings.php

View workflow job for this annotation

GitHub Actions / CPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '(string)'.
.then(response => {
Expand Down Expand Up @@ -169,7 +172,7 @@ function fxb_build_admin_page() {
</p>

<script>
let currentFXBBunnyFontOption = <?php echo json_encode( (array) get_option( 'fxb_bunny_fonts' ) ); ?>;
let currentFXBBunnyFontOption = <?php echo wp_json_encode( (array) get_option( 'fxb_bunny_fonts' ) ); ?>;

// Fetch the font data from the Bunny Fonts API
fetch('https://fonts.bunny.net/list')
Expand Down

0 comments on commit f4b0e22

Please sign in to comment.