Skip to content

Commit

Permalink
First version with 3 options
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-jacob committed May 11, 2023
1 parent 3a7a6b6 commit fadeb7d
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 0 deletions.
51 changes: 51 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
= Menus for Block Theme =
Contributors: lyly13, wpr0ck
Donate link: https://la-webeuse.com/menus-for-block-theme/
Tags: menu, customizer, file editor, custom menu, full site editing
Requires at least: 6.0
Tested up to: 6.2
Stable tag: trunk
Requires PHP: 5.4
License: GPLv2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Add classic menus to Block Themes. Display the customizer in admin menu. Disable files editor for plugins and themes.

== Description ==

__Menus for Block Theme__ add a setting page in the WordPress dashboard which allows to manage the following options :


= Add classic menus in block themes (Add menus to theme supports) =

Support menus in WordPress provide users with an easy way to create and manage menus directly from the WordPress dashboard. **This is very useful if your block-based theme doesn't support classic menus**.

_Appearance -> Menus_


= Display the customizer in admin menu =

Add a link in the WordPress dashboard to access the customizer. A space to configure the site identity (Site title, Tagline, Site icon), The menus (Add new, Menus locations, Menus Options), the Homepage Settings (display latest posts or static page) and add additional CSS. **This is very useful if your block-based theme does not display the tab that allows you to add your CSS styles**

_Appearance -> Customize_


= Disable files editor for plugins and themes =
**Improve security and reduce the risk of potential vulnerabilities**. By disabling the file editor, WordPress administrators are forced to make changes to the code using a more secure method, such as editing the files locally and then uploading them to the server via FTP, or using a plugin to manage code changes.

_Tools -> Theme file editor_ and _Tools -> Plugin file editor_


== Screenshots ==

1. Settings page
2. Add menus support
3. Add Customizer support

== Changelog ==

= 1.0.0 =

* Add french translation
* Add setting : Menus support
* Add setting : Customize support
* Add setting : Disallow file edit
Binary file added assets/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon-128x128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icon-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/screenshot-3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
141 changes: 141 additions & 0 deletions includes/admin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<?php

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}


/**
* Create a menu link for the plugin settings in the admin area
*
* @return void
*/
function mfbt_create_menu() {

add_submenu_page(
'options-general.php',
__( 'Menus for Block Theme : Settings', 'menus-for-block-theme' ),
__( 'MFBT Settings', 'menus-for-block-theme'),
'administrator',
'mfbt-settings',
'mfbt_settings'
);

}


/**
* register settings
*
* @return void
*/
function mfbt_register_settings() {

register_setting( 'mfbt_settings', 'mfbt_add_theme_support_menu' );
register_setting( 'mfbt_settings', 'mfbt_show_customizer' );
register_setting( 'mfbt_settings', 'mfbt_disable_files_editor' );

}


/**
* Add 'Settings' link on the plugin list
*
* @param array $settings
* @return array
*/
function mfbt_settings_link( $settings ) {

$url = esc_url(
add_query_arg(
'page',
'mfbt-settings',
get_admin_url() . 'options-general.php'
)
);

$settings[] = '<a href="' . $url . '">' . __( 'Settings', 'menus-for-block-theme' ) . '</a>';

return $settings;
}


/**
* Option page for the plugin
*
* @return void
*/
function mfbt_settings() {

if ( is_multisite() ) {
?>
<div class="wrap">
<h1><?php _e( 'Menus for Block Theme', 'menus-for-block-theme' ); ?></h1>
<p><?php _e( 'Not available on WordPress Multisite', 'menus-for-block-theme' ); ?></p>
</div>
<?php
return;
}

?>
<div class="wrap">
<h1><?php _e( 'Menus for Block Theme', 'menus-for-block-theme' ); ?></h1>

<form method="post" action="options.php">
<?php
settings_fields( 'mfbt_settings' );
do_settings_sections( 'mfbt_settings' );
?>

<table class="form-table">

<tr>
<th scope="row"><?php _e( 'Support menus', 'menus-for-block-theme' ); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php _e( 'Support menus', 'menus-for-block-theme' ); ?></span>
</legend>
<label for="mfbt_add_theme_support_menu">
<input type="checkbox" id="mfbt_add_theme_support_menu" name="mfbt_add_theme_support_menu" value="1" <?php checked( 1, get_option( 'mfbt_add_theme_support_menu' ), true ); ?> /> <?php _e( 'Add classic menus for block theme (Appearance > Menus)', 'menus-for-block-theme' ); ?></label>
</fieldset>
</td>
</tr>

<tr>
<th scope="row"><?php _e( 'Customizer', 'menus-for-block-theme' ); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php _e( 'Customizer', 'menus-for-block-theme' ); ?></span>
</legend>
<label for="mfbt_show_customizer">
<input type="checkbox" id="mfbt_show_customizer" name="mfbt_show_customizer" value="1" <?php checked( 1, get_option( 'mfbt_show_customizer' ), true ); ?> /> <?php _e( 'Display the customizer in admin menu (Appearance > Customize)', 'menus-for-block-theme' ); ?>
</label>
</fieldset>
</td>
</tr>

<tr>
<th scope="row"><?php _e( 'File editor', 'menus-for-block-theme' ); ?></th>
<td>
<fieldset>
<legend class="screen-reader-text">
<span><?php _e( 'File editor', 'menus-for-block-theme' ); ?></span>
</legend>
<label for="mfbt_disable_files_editor">
<input type="checkbox" id="mfbt_disable_files_editor" name="mfbt_disable_files_editor" value="1" <?php checked( 1, get_option( 'mfbt_disable_files_editor' ), true ); ?> /> <?php _e( 'Disable file editor for plugins and themes (Tools > Theme / Plugin File Editor)', 'menus-for-block-theme' ); ?>
</label>
</fieldset>
</td>
</tr>

</table>

<?php submit_button(); ?>

</form>
</div>
<?php
}
2 changes: 2 additions & 0 deletions includes/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
69 changes: 69 additions & 0 deletions includes/main.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}


/**
* Call Calls all functions that act if the corresponding options are activated
*
* @return void
*/
function mfbt_main() {

if ( is_multisite() ) {
return;
}

if ( ! empty( get_option( 'mfbt_add_theme_support_menu' ) ) ) {
mfbt_add_theme_support_menus();
}

if ( ! empty( get_option( 'mfbt_show_customizer' ) ) ) {
add_action( 'admin_head', 'mfbt_display_customizer' );
}

if ( ! empty( get_option( 'mfbt_disable_files_editor' ) ) ) {
mfbt_disallow_file_edit();
}
}


/**
* Add the value 'menus' to add_theme_support
*
* @return void
*/
function mfbt_add_theme_support_menus() {
add_theme_support( 'menus' );
}


/**
* Disable files editor in the admin area
*
* @return void
*/
function mfbt_disallow_file_edit() {
define( 'DISALLOW_FILE_EDIT', true );
}


/**
* Display customizer link in the admin area
*
* @return void
*/
function mfbt_display_customizer() {

global $submenu;

$customize_url = add_query_arg( 'return', urlencode( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ), 'customize.php' );

$position = ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ? 7 : 6;

$submenu['themes.php'][ $position ] = array( __( 'Customize' ), 'customize', esc_url( $customize_url ), '', 'hide-if-no-customize' );

}
2 changes: 2 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
2 changes: 2 additions & 0 deletions languages/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?php
// Silence is golden.
Binary file added languages/menus-for-block-theme-fr_FR.mo
Binary file not shown.
94 changes: 94 additions & 0 deletions languages/menus-for-block-theme-fr_FR.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
msgid ""
msgstr ""
"Project-Id-Version: Menus for Block Theme\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-03 01:46+0000\n"
"PO-Revision-Date: 2023-04-04 16:59+0000\n"
"Last-Translator: \n"
"Language-Team: Français\n"
"Language: fr_FR\n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Loco https://localise.biz/\n"
"X-Loco-Version: 2.6.4; wp-6.2\n"
"X-Domain: menus-for-block-theme"

#: includes/admin.php:101
msgid "Add classic menus for block theme (Appearance > Menus)"
msgstr ""
"Ajouter les menus classiques pour les thèmes basés sur les blocs (Apparence> "
"Menus)"

#. Description of the plugin
#| msgid ""
#| "Add menus to theme supports. Display the customizer in admin menu. "
#| "Disable files editor for plugins and themes."
msgid ""
"Add classic menus to Block Themes. Display the customizer in admin menu. "
"Disable files editor for plugins and themes."
msgstr ""
"Ajouter les menus classiques pour les thèmes basés sur les blocs. Afficher "
"\"Personnaliser\" dans le menu d'administration. Désactiver l'éditeur de "
"fichiers pour les extensions et les thèmes."

#: includes/admin.php:107 includes/admin.php:111
msgid "Customizer"
msgstr "Personnaliser"

#: includes/admin.php:128
msgid ""
"Disable file editor for plugins and themes (Tools > Theme / Plugin File "
"Editor)"
msgstr ""
"Désactiver l'éditeur de fichiers pour les extensions et les thèmes (Outils > "
"Éditeur des fichiers des thèmes / extensions)"

#: includes/admin.php:114
msgid "Display the customizer in admin menu (Appearance > Customize)"
msgstr ""
"Afficher \"Personnaliser\" dans le menu d'administration (Apparence > "
"Personnaliser)"

#: includes/admin.php:121 includes/admin.php:125
#| msgid "Files editor"
msgid "File editor"
msgstr "Éditeur de fichiers"

#. Author URI of the plugin
msgid "https://la-webeuse.com/"
msgstr ""

#. URI of the plugin
msgid "https://la-webeuse.com/menus-for-block-theme/"
msgstr ""

#. Author of the plugin
msgid "Lycia Diaz"
msgstr ""

#. Name of the plugin
#: includes/admin.php:74 includes/admin.php:83
msgid "Menus for Block Theme"
msgstr ""

#: includes/admin.php:18
msgid "Menus for Block Theme : Settings"
msgstr "Menus for Block Theme : Réglages"

#: includes/admin.php:19
msgid "MFBT Settings"
msgstr "MFBT Réglages"

#: includes/admin.php:75
msgid "Not available on WordPress Multisite"
msgstr "Non disponible sur WordPress multisite"

#: includes/admin.php:58
msgid "Settings"
msgstr "Réglages"

#: includes/admin.php:94 includes/admin.php:98
msgid "Support menus"
msgstr "Supporter les menus"
Loading

0 comments on commit fadeb7d

Please sign in to comment.