introducing option page
This commit is contained in:
parent
8ce3f075a8
commit
8710140b74
|
|
@ -1,4 +1,48 @@
|
||||||
<?php
|
<?php
|
||||||
|
/* ---------------------------
|
||||||
|
REMOVING POSTS FROM ADMIN MENU
|
||||||
|
---------------------------*/
|
||||||
|
function post_remove()
|
||||||
|
{
|
||||||
|
remove_menu_page('edit.php');
|
||||||
|
}
|
||||||
|
|
||||||
|
add_action('admin_menu', 'post_remove');
|
||||||
|
|
||||||
|
|
||||||
|
/* ---------------------------
|
||||||
|
PAGE D'OPTIONS DU THEME
|
||||||
|
---------------------------*/
|
||||||
|
|
||||||
|
function register_theme_settings_option_page()
|
||||||
|
{
|
||||||
|
|
||||||
|
// Check function exists.
|
||||||
|
if (function_exists('acf_add_options_page')) {
|
||||||
|
|
||||||
|
// Register options page.
|
||||||
|
$homegrade_option_page = acf_add_options_page(array(
|
||||||
|
'page_title' => __('Texte interface', 'homegrade-theme__texte-backoffice'),
|
||||||
|
'menu_title' => __('Texte interface', 'homegrade-theme__texte-backoffice'),
|
||||||
|
'menu_slug' => 'theme-general-settings',
|
||||||
|
'capability' => 'activate_plugins',
|
||||||
|
'redirect' => false,
|
||||||
|
'icon_url' => 'dashicons-admin-site-alt',
|
||||||
|
'position' => 2,
|
||||||
|
));
|
||||||
|
// Add sub page.
|
||||||
|
$press_kit_admin_page = acf_add_options_sub_page(array(
|
||||||
|
'page_title' => __('Presse'),
|
||||||
|
'menu_title' => __('Presse'),
|
||||||
|
'parent_slug' => $homegrade_option_page['menu_slug'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add_options_page( 'MyPlugin Options', 'MyPlugin Options', 'activate_plugins', 'myplugin-options', 'myplugin_options' );
|
||||||
|
|
||||||
|
|
||||||
|
add_action('acf/init', 'register_theme_settings_option_page');
|
||||||
|
|
||||||
|
|
||||||
// #### ADMIN STYLE
|
// #### ADMIN STYLE
|
||||||
function my_custom_admin()
|
function my_custom_admin()
|
||||||
|
|
@ -39,3 +83,46 @@ function enqueue_custom_login_stylesheet()
|
||||||
wp_enqueue_style('custom-login', get_stylesheet_directory_uri() . '/style-login.css');
|
wp_enqueue_style('custom-login', get_stylesheet_directory_uri() . '/style-login.css');
|
||||||
}
|
}
|
||||||
add_action('login_enqueue_scripts', 'enqueue_custom_login_stylesheet');
|
add_action('login_enqueue_scripts', 'enqueue_custom_login_stylesheet');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
REORDER ADMIN MENU & POST TYPE ORDER ON MENU BAR
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* Activates the 'menu_order' filter and then hooks into 'menu_order'
|
||||||
|
*/
|
||||||
|
add_filter('custom_menu_order', function () {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
add_filter('menu_order', 'my_new_admin_menu_order');
|
||||||
|
/**
|
||||||
|
* Filters WordPress' default menu order
|
||||||
|
*/
|
||||||
|
function my_new_admin_menu_order($menu_order)
|
||||||
|
{
|
||||||
|
// define your new desired menu positions here
|
||||||
|
// for example, move 'upload.php' to position #9 and built-in pages to position #1
|
||||||
|
$new_positions = array(
|
||||||
|
'session-datas-options' => 1,
|
||||||
|
'admin.php?page=my_options' => 4,
|
||||||
|
'edit.php' => 6,
|
||||||
|
'edit.php?post_type=page' => 9,
|
||||||
|
'upload.php' => 11,
|
||||||
|
);
|
||||||
|
// helper function to move an element inside an array
|
||||||
|
function move_element(&$array, $a, $b)
|
||||||
|
{
|
||||||
|
$out = array_splice($array, $a, 1);
|
||||||
|
array_splice($array, $b, 0, $out);
|
||||||
|
}
|
||||||
|
// traverse through the new positions and move
|
||||||
|
// the items if found in the original menu_positions
|
||||||
|
foreach ($new_positions as $value => $new_index) {
|
||||||
|
if ($current_index = array_search($value, $menu_order)) {
|
||||||
|
move_element($menu_order, $current_index, $new_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $menu_order;
|
||||||
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user