Compare commits
2 Commits
86ad3dec9a
...
9097f89926
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9097f89926 | ||
|
|
a0e4adc705 |
|
|
@ -251,23 +251,23 @@ function carhop_create_posttype()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
// -------EXPOSITIONS------- //
|
// -------EXPOSITIONS------- //
|
||||||
register_post_type(
|
register_post_type(
|
||||||
'reportages',
|
'reportages',
|
||||||
array(
|
array(
|
||||||
'labels' => array(
|
'labels' => array(
|
||||||
'name' => __('Reportages'),
|
'name' => __('Reportages'),
|
||||||
'singular_name' => __('Reportage'),
|
'singular_name' => __('Reportage'),
|
||||||
),
|
),
|
||||||
'public' => true,
|
'public' => true,
|
||||||
'has_archive' => true,
|
'has_archive' => true,
|
||||||
'rewrite' => array('slug' => 'reportages'),
|
'rewrite' => array('slug' => 'reportages'),
|
||||||
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 3.92857H16.05L11.25 0.785714V0.714286C11.25 0.321429 10.9125 0 10.5 0C10.0875 0 9.75 0.321429 9.75 0.714286V0.785714L4.95 3.92857H3.75C3.3375 3.92857 3 4.25 3 4.64286V19.2857C3 19.6786 3.3375 20 3.75 20H17.25C17.6625 20 18 19.6786 18 19.2857V4.64286C18 4.25 17.6625 3.92857 17.25 3.92857ZM10.2 1.35714C10.3125 1.39286 10.3875 1.42857 10.5 1.42857C10.6125 1.42857 10.725 1.42857 10.8 1.35714L14.7 3.92857H6.3L10.2 1.35714ZM16.5 15.3571C14.1375 11.75 12.9375 11.1786 11.55 12.9286C11.4 13.1071 11.175 13.3571 10.875 13.6429C10.9875 13.9643 11.1 14.2857 11.25 14.6071C12 16.8929 12.9 17.3929 13.65 17.8214L13.8375 17.9286L14.925 18.5357H13.4625C12.6 18.0357 11.4375 17.5714 10.5375 14.8214C10.35 14.2857 10.2 13.8214 10.0125 13.4286C8.6625 10.2857 7.2 10.3571 6.225 11.1429C5.625 11.6429 5.0625 12.3929 4.5 13.2857V5.35714H16.5V15.3571ZM13.875 8.92857C14.5125 8.92857 15 8.46429 15 7.85714C15 7.25 14.5125 6.78571 13.875 6.78571C13.2375 6.78571 12.75 7.25 12.75 7.85714C12.75 8.46429 13.2375 8.92857 13.875 8.92857Z" fill="#9BA2A9"/></svg>'),
|
'menu_icon' => 'data:image/svg+xml;base64,' . base64_encode('<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M17.25 3.92857H16.05L11.25 0.785714V0.714286C11.25 0.321429 10.9125 0 10.5 0C10.0875 0 9.75 0.321429 9.75 0.714286V0.785714L4.95 3.92857H3.75C3.3375 3.92857 3 4.25 3 4.64286V19.2857C3 19.6786 3.3375 20 3.75 20H17.25C17.6625 20 18 19.6786 18 19.2857V4.64286C18 4.25 17.6625 3.92857 17.25 3.92857ZM10.2 1.35714C10.3125 1.39286 10.3875 1.42857 10.5 1.42857C10.6125 1.42857 10.725 1.42857 10.8 1.35714L14.7 3.92857H6.3L10.2 1.35714ZM16.5 15.3571C14.1375 11.75 12.9375 11.1786 11.55 12.9286C11.4 13.1071 11.175 13.3571 10.875 13.6429C10.9875 13.9643 11.1 14.2857 11.25 14.6071C12 16.8929 12.9 17.3929 13.65 17.8214L13.8375 17.9286L14.925 18.5357H13.4625C12.6 18.0357 11.4375 17.5714 10.5375 14.8214C10.35 14.2857 10.2 13.8214 10.0125 13.4286C8.6625 10.2857 7.2 10.3571 6.225 11.1429C5.625 11.6429 5.0625 12.3929 4.5 13.2857V5.35714H16.5V15.3571ZM13.875 8.92857C14.5125 8.92857 15 8.46429 15 7.85714C15 7.25 14.5125 6.78571 13.875 6.78571C13.2375 6.78571 12.75 7.25 12.75 7.85714C12.75 8.46429 13.2375 8.92857 13.875 8.92857Z" fill="#9BA2A9"/></svg>'),
|
||||||
'show_in_rest' => true,
|
'show_in_rest' => true,
|
||||||
'supports' => array('title', 'revisions'),
|
'supports' => array('title', 'revisions'),
|
||||||
'menu_position' => 4,
|
'menu_position' => 4,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
add_action('init', 'carhop_create_posttype');
|
add_action('init', 'carhop_create_posttype');
|
||||||
|
|
||||||
|
|
@ -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