Compare commits
2 Commits
86ad3dec9a
...
9097f89926
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9097f89926 | ||
|
|
a0e4adc705 |
|
|
@ -279,3 +279,53 @@ function carhop_hide_default_post_type()
|
||||||
remove_menu_page('edit-comments.php');
|
remove_menu_page('edit-comments.php');
|
||||||
}
|
}
|
||||||
add_action('admin_menu', 'carhop_hide_default_post_type');
|
add_action('admin_menu', 'carhop_hide_default_post_type');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
REORDER ADMIN MENU & POST TYPE ORDER ON MENU BAR
|
||||||
|
------------------------------------------------------------------------*/
|
||||||
|
/**
|
||||||
|
* Filters WordPress' default menu order
|
||||||
|
*/
|
||||||
|
function carhop_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(
|
||||||
|
'edit.php?post_type=auteurs' => 3,
|
||||||
|
'edit.php?post_type=actualites' => 4,
|
||||||
|
'edit.php?post_type=analyses-etudes' => 5,
|
||||||
|
'edit.php?post_type=dbmob' => 6,
|
||||||
|
'edit.php?post_type=outils-pedagogiques' => 7,
|
||||||
|
'edit.php?post_type=fonds-archives' => 8,
|
||||||
|
'edit.php?post_type=expositions' => 9,
|
||||||
|
'edit.php?post_type=activites' => 10,
|
||||||
|
'carhop-presse' => 11,
|
||||||
|
'edit.php?post_type=recherches' => 12,
|
||||||
|
'edit.php?post_type=reportages' => 13,
|
||||||
|
'edit.php?post_type=page' => 14,
|
||||||
|
'upload.php' => 15,
|
||||||
|
'theme-general-settings' => 16,
|
||||||
|
'rank-math' => 20,
|
||||||
|
);
|
||||||
|
// helper function to move an element inside an array
|
||||||
|
function carhop_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)) {
|
||||||
|
carhop_move_element($menu_order, $current_index, $new_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $menu_order;
|
||||||
|
};
|
||||||
|
add_action('admin_menu', function () {
|
||||||
|
add_filter('menu_order', 'carhop_new_admin_menu_order');
|
||||||
|
add_filter('custom_menu_order', '__return_true');
|
||||||
|
});
|
||||||
|
|
|
||||||
20
plugins/carhop-blocks/src/reportages-list/block.json
Normal file
20
plugins/carhop-blocks/src/reportages-list/block.json
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||||
|
"apiVersion": 3,
|
||||||
|
"name": "carhop-blocks/reportages-list",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"title": "Liste des reportages",
|
||||||
|
"category": "carhop-blocks",
|
||||||
|
"icon": "smiley",
|
||||||
|
"description": "Liste des reportages",
|
||||||
|
"example": {},
|
||||||
|
"supports": {
|
||||||
|
"html": false
|
||||||
|
},
|
||||||
|
"textdomain": "carhop-blocks",
|
||||||
|
"editorScript": "file:./index.js",
|
||||||
|
"editorStyle": "file:./index.css",
|
||||||
|
"style": "file:./style-index.css",
|
||||||
|
"render": "file:./render.php",
|
||||||
|
"viewScript": "file:./view.js"
|
||||||
|
}
|
||||||
12
plugins/carhop-blocks/src/reportages-list/edit.js
Normal file
12
plugins/carhop-blocks/src/reportages-list/edit.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { __ } from "@wordpress/i18n";
|
||||||
|
import { useBlockProps } from "@wordpress/block-editor";
|
||||||
|
import "./editor.scss";
|
||||||
|
import ServerSideRender from "@wordpress/server-side-render";
|
||||||
|
|
||||||
|
export default function Edit() {
|
||||||
|
return (
|
||||||
|
<div {...useBlockProps({ className: "alignwide" })}>
|
||||||
|
<ServerSideRender block="carhop-blocks/reportages-list" />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
16
plugins/carhop-blocks/src/reportages-list/index.js
Normal file
16
plugins/carhop-blocks/src/reportages-list/index.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { registerBlockType } from "@wordpress/blocks";
|
||||||
|
import "./style.scss";
|
||||||
|
|
||||||
|
import Edit from "./edit";
|
||||||
|
import metadata from "./block.json";
|
||||||
|
|
||||||
|
registerBlockType(metadata.name, {
|
||||||
|
icon: {
|
||||||
|
src: (
|
||||||
|
<svg width="32" height="32" viewBox="0 0 32 32">
|
||||||
|
<path d="M16 24L8 16L16 8L24 16L16 24Z" />
|
||||||
|
</svg>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
edit: Edit,
|
||||||
|
});
|
||||||
15
plugins/carhop-blocks/src/reportages-list/render.php
Normal file
15
plugins/carhop-blocks/src/reportages-list/render.php
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
$wrapper_attributes = get_block_wrapper_attributes(['class' => 'press-ressources alignwide']);
|
||||||
|
|
||||||
|
$contact_persons = get_field('contact_persons', 'option');
|
||||||
|
$ressources_graphiques = get_field('ressources_graphiques', 'option');
|
||||||
|
?>
|
||||||
|
|
||||||
|
<section <?php echo $wrapper_attributes; ?>>
|
||||||
|
|
||||||
|
<div class="ressources-tabs-grid ressources-grid-content-wrapper" data-active-tab="communiques">
|
||||||
|
|
||||||
|
<?php get_template_part('template-parts/post-types/reportages/reportages-grid'); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
12
plugins/carhop-blocks/src/reportages-list/style.scss
Normal file
12
plugins/carhop-blocks/src/reportages-list/style.scss
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
/**
|
||||||
|
* The following styles get applied both on the front of your site
|
||||||
|
* and in the editor.
|
||||||
|
*
|
||||||
|
* Replace them with your own styles or remove the file completely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.wp-block-create-block-chapo {
|
||||||
|
background-color: #21759b;
|
||||||
|
color: #fff;
|
||||||
|
padding: 2px;
|
||||||
|
}
|
||||||
29
plugins/carhop-blocks/src/reportages-list/view.js
Normal file
29
plugins/carhop-blocks/src/reportages-list/view.js
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
const toolbar = document.querySelector("#press-toolbar");
|
||||||
|
if (!toolbar) return;
|
||||||
|
const toolbarButtons = toolbar.querySelectorAll("button");
|
||||||
|
const ressourcesGridContentWrapper = document.querySelector(
|
||||||
|
".ressources-grid-content-wrapper"
|
||||||
|
);
|
||||||
|
|
||||||
|
function setActiveTab(currentButton) {
|
||||||
|
toolbarButtons.forEach((button) => {
|
||||||
|
button.setAttribute("aria-selected", "false");
|
||||||
|
});
|
||||||
|
|
||||||
|
currentButton.setAttribute("aria-selected", "true");
|
||||||
|
ressourcesGridContentWrapper.setAttribute(
|
||||||
|
"data-active-tab",
|
||||||
|
currentButton.getAttribute("data-tab")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function initToolbar() {
|
||||||
|
toolbarButtons.forEach((button) => {
|
||||||
|
button.addEventListener("click", function () {
|
||||||
|
setActiveTab(button);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
initToolbar();
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user