Creates dashboard class and renames admin class do "views". First steps towards new naviagion menu. #494.
This commit is contained in:
parent
b3929e86d9
commit
1d6f402a0b
|
@ -1,71 +1,16 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
<svg width="4.4mm" height="4.3mm" version="1.1" viewBox="0 0 17.51 17.554" xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||||
|
<metadata>
|
||||||
<svg
|
<rdf:RDF>
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
<cc:Work rdf:about="">
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
<dc:format>image/svg+xml</dc:format>
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/>
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
</cc:Work>
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
</rdf:RDF>
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
</metadata>
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
<g transform="translate(-75.911 -118.89)">
|
||||||
width="4.4mm"
|
<g transform="matrix(.35278 0 0 -.35278 92.287 133.94)" fill="#fff">
|
||||||
height="4.3mm"
|
<path d="m0 0c-1e-3 -1e-3 -2e-3 -2e-3 -2e-3 -3e-3 -1e-3 -1e-3 -1e-3 -2e-3 -2e-3 -4e-3 -2.406-5.124-8.984-6.038-18.168-1.738 0.562 2.707 1.173 6.318 1.271 8.865 1e-3 6e-3 0 0.01 0 0.016 2.814 1.819 5.724 4.096 8.638 6.943-0.126 0.069-0.104 0.058 0 0 7.672-4.168 10.486-9.346 8.263-14.079m-10.813 15.346s-1e-3 0-1e-3 1e-3c-2.065-1.992-4.106-3.673-6.085-5.092-0.079 2.372-0.35 4.969-0.911 7.759 2.214-0.673 4.551-1.547 6.996-2.667 0.051 0.049 0.036 0.035 0 0 0-1e-3 1e-3 -1e-3 1e-3 -1e-3m-11.14 15.11c6.71 6.204 12.731 7.242 16.526 3.459 1e-3 0 2e-3 -1e-3 3e-3 -2e-3s1e-3 -2e-3 2e-3 -3e-3c3.809-3.795 2.773-9.847-3.463-16.604-0.03-0.033-0.037-0.039 0 0-0.038 0.018-3.636 1.888-9.577 3.533-0.446 2.465-3.067 8.994-3.491 9.617m2.612-21.846c-3.239-2.04-6.259-3.395-8.876-4.297-0.936 0.721-1.804 1.445-2.61 2.165v1e-3c-1.341 1.31-2.72 2.834-4.09 4.604 0.905 2.643 2.27 5.691 4.327 8.962 2.826 0.221 10.007-1.139 10.026-1.278 0.209-0.031 1.366-7.279 1.223-10.157m-1.147-9.207c-0.304-0.025-4.05 2.071-5.35 3.189v1e-3c2.01 0.761 6.373 2.992 6.373 2.992s7e-3 4e-3 0.01 6e-3c0-5e-3 -0.607-4.211-1.033-6.188m-16.205 3.133c0.059 1.056 0.24 2.919 0.836 5.352 0.639-0.775 3.704-3.826 4.496-4.505-2.413-0.597-4.267-0.782-5.332-0.847m-3.212 16.383c2.028 0.435 4.568 0.908 6.308 1.032 0 1e-3 1e-3 2e-3 1e-3 3e-3 0-1e-3 -1e-3 -2e-3 -1e-3 -3e-3 -1.292-2.246-2.298-4.41-3.081-6.441-1.1 1.616-3.221 5.398-3.227 5.409m0.59 20.584 2e-3 2e-3 3e-3 1e-3c4.788 2.234 10.015-0.674 14.185-8.533-2.828-2.867-5.1-5.73-6.921-8.501 0-1e-3 0-2e-3 -1e-3 -2e-3 1e-3 0 1e-3 1e-3 1e-3 2e-3 -2.581-0.078-5.827-0.743-8.992-1.265-4.441 9.396-3.417 15.899 1.723 18.296m18.017-17.993c-2.755 0.567-5.322 0.853-7.672 0.946 1.409 1.97 3.075 4 5.046 6.053-4e-3 8e-3 1.966-4.785 2.626-6.999m14.909-5.493c6.966 7.825 7.662 14.758 2.855 19.592l-6e-3 6e-3c-4.812 4.838-11.969 4.092-19.629-2.766v-1e-3 1e-3c-4.765 8.608-11.06 11.582-17.108 8.781l-4e-3 -2e-3c-1e-3 0-3e-3 -1e-3 -4e-3 -2e-3 -8.152-3.418-8.996-14.826 2.483-31.416h1e-3c-1e-3 0-1e-3 -1e-3 -1e-3 -1e-3 -1.403-4.747-1.592-8.448-1.596-10.265 1.794-5e-3 5.505 0.165 10.28 1.551 18.709-12.724 28.428-9.343 31.325-2.592 0 1e-3 1e-3 2e-3 2e-3 4e-3 0 1e-3 1e-3 3e-3 2e-3 4e-3 2.822 6.011-0.366 12.678-8.6 17.106" fill="#fff"/>
|
||||||
viewBox="0 0 17.510353 17.55353"
|
</g>
|
||||||
version="1.1"
|
</g>
|
||||||
id="svg1507"
|
|
||||||
inkscape:version="0.92.2 (5c3e80d, 2017-08-06)"
|
|
||||||
sodipodi:docname="tainacan_logo_symbol.svg">
|
|
||||||
<defs
|
|
||||||
id="defs1501" />
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="base"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#666666"
|
|
||||||
borderopacity="1.0"
|
|
||||||
inkscape:pageopacity="0.0"
|
|
||||||
inkscape:pageshadow="2"
|
|
||||||
inkscape:zoom="0.35"
|
|
||||||
inkscape:cx="-715.481"
|
|
||||||
inkscape:cy="-46.827981"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
inkscape:current-layer="layer1"
|
|
||||||
showgrid="false"
|
|
||||||
fit-margin-top="0"
|
|
||||||
fit-margin-left="0"
|
|
||||||
fit-margin-right="0"
|
|
||||||
fit-margin-bottom="0"
|
|
||||||
inkscape:window-width="3200"
|
|
||||||
inkscape:window-height="1678"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="66"
|
|
||||||
inkscape:window-maximized="1" />
|
|
||||||
<metadata
|
|
||||||
id="metadata1504">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:title></dc:title>
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
inkscape:label="Layer 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1"
|
|
||||||
transform="translate(-75.911491,-118.8899)">
|
|
||||||
<g
|
|
||||||
id="g296"
|
|
||||||
transform="matrix(0.35277777,0,0,-0.35277777,92.286729,133.9362)"
|
|
||||||
style="fill:#ffffff;fill-opacity:1">
|
|
||||||
<path
|
|
||||||
d="m 0,0 c -0.001,-0.001 -0.002,-0.002 -0.002,-0.003 -0.001,-0.001 -0.001,-0.002 -0.002,-0.004 -2.406,-5.124 -8.984,-6.038 -18.168,-1.738 0.562,2.707 1.173,6.318 1.271,8.865 0.001,0.006 0,0.01 0,0.016 2.814,1.819 5.724,4.096 8.638,6.943 -0.126,0.069 -0.104,0.058 0,0 C -0.591,9.911 2.223,4.733 0,0 m -10.813,15.346 c 0,0 -10e-4,0 -10e-4,10e-4 -2.065,-1.992 -4.106,-3.673 -6.085,-5.092 -0.079,2.372 -0.35,4.969 -0.911,7.759 2.214,-0.673 4.551,-1.547 6.996,-2.667 0.051,0.049 0.036,0.035 0,0 0,-10e-4 10e-4,-10e-4 10e-4,-10e-4 m -11.14,15.11 v 0 c 6.71,6.204 12.731,7.242 16.526,3.459 10e-4,0 0.002,-10e-4 0.003,-0.002 0.001,-10e-4 0.001,-0.002 0.002,-0.003 3.809,-3.795 2.773,-9.847 -3.463,-16.604 -0.03,-0.033 -0.037,-0.039 0,0 -0.038,0.018 -3.636,1.888 -9.577,3.533 -0.446,2.465 -3.067,8.994 -3.491,9.617 M -19.341,8.61 v 0 C -22.58,6.57 -25.6,5.215 -28.217,4.313 c -0.936,0.721 -1.804,1.445 -2.61,2.165 v 0.001 c -1.341,1.31 -2.72,2.834 -4.09,4.604 0.905,2.643 2.27,5.691 4.327,8.962 2.826,0.221 10.007,-1.139 10.026,-1.278 0.209,-0.031 1.366,-7.279 1.223,-10.157 m -1.147,-9.207 c -0.304,-0.025 -4.05,2.071 -5.35,3.189 v 10e-4 c 2.01,0.761 6.373,2.992 6.373,2.992 0,0 0.007,0.004 0.01,0.006 0,-0.005 -0.607,-4.211 -1.033,-6.188 m -16.205,3.133 c 0.059,1.056 0.24,2.919 0.836,5.352 0.639,-0.775 3.704,-3.826 4.496,-4.505 -2.413,-0.597 -4.267,-0.782 -5.332,-0.847 m -3.212,16.383 v 0 c 2.028,0.435 4.568,0.908 6.308,1.032 0,0.001 0.001,0.002 0.001,0.003 0,-0.001 -0.001,-0.002 -0.001,-0.003 -1.292,-2.246 -2.298,-4.41 -3.081,-6.441 -1.1,1.616 -3.221,5.398 -3.227,5.409 m 0.59,20.584 0.002,0.002 0.003,10e-4 c 4.788,2.234 10.015,-0.674 14.185,-8.533 -2.828,-2.867 -5.1,-5.73 -6.921,-8.501 0,-0.001 0,-0.002 -10e-4,-0.002 10e-4,0 10e-4,0.001 10e-4,0.002 -2.581,-0.078 -5.827,-0.743 -8.992,-1.265 -4.441,9.396 -3.417,15.899 1.723,18.296 M -21.298,21.51 c -2.755,0.567 -5.322,0.853 -7.672,0.946 1.409,1.97 3.075,4 5.046,6.053 -0.004,0.008 1.966,-4.785 2.626,-6.999 m 14.909,-5.493 c 6.966,7.825 7.662,14.758 2.855,19.592 l -0.003,0.003 c -10e-4,10e-4 -0.002,0.002 -0.003,0.003 -4.812,4.838 -11.969,4.092 -19.629,-2.766 v -10e-4 10e-4 c -4.765,8.608 -11.06,11.582 -17.108,8.781 l -0.004,-0.002 c -10e-4,0 -0.003,-10e-4 -0.004,-0.002 -8.152,-3.418 -8.996,-14.826 2.483,-31.416 h 10e-4 c -10e-4,0 -10e-4,-0.001 -10e-4,-0.001 -1.403,-4.747 -1.592,-8.448 -1.596,-10.265 1.794,-0.005 5.505,0.165 10.28,1.551 18.709,-12.724 28.428,-9.343 31.325,-2.592 0,10e-4 0.001,0.002 0.002,0.004 0,10e-4 10e-4,0.003 0.002,0.004 2.822,6.011 -0.366,12.678 -8.6,17.106"
|
|
||||||
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;"
|
|
||||||
id="path298"
|
|
||||||
inkscape:connector-curvature="0" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 2.8 KiB |
|
@ -151,8 +151,8 @@ $Tainacan_Mappers = \Tainacan\Mappers_Handler::get_instance();
|
||||||
|
|
||||||
$Tainacan_Embed = \Tainacan\Embed::get_instance();
|
$Tainacan_Embed = \Tainacan\Embed::get_instance();
|
||||||
|
|
||||||
require_once(__DIR__ . '/../views/class-tainacan-admin.php');
|
require_once(__DIR__ . '/../views/class-tainacan-views.php');
|
||||||
$Tainacan_Admin = \Tainacan\Admin::get_instance();
|
$Tainacan_Views = \Tainacan\Views::get_instance();
|
||||||
|
|
||||||
require_once(__DIR__ . '/../views/admin/classes/hooks/class-tainacan-admin-hooks.php');
|
require_once(__DIR__ . '/../views/admin/classes/hooks/class-tainacan-admin-hooks.php');
|
||||||
require_once(__DIR__ . '/../views/admin/classes/hooks/admin-hooks-functions.php');
|
require_once(__DIR__ . '/../views/admin/classes/hooks/admin-hooks-functions.php');
|
||||||
|
|
|
@ -0,0 +1,281 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tainacan;
|
||||||
|
|
||||||
|
|
||||||
|
class Admin {
|
||||||
|
|
||||||
|
private $vue_component_page_slug = 'tainacan_admin';
|
||||||
|
private $repository_links_slug = 'tainacan_admin'; // Same as vue_component_page_slug, because it is used in add_submenu_page() to create the root menu and the page has to exist
|
||||||
|
private $collections_links_slug = 'tainacan_collection_links';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
|
||||||
|
add_action( 'wp_ajax_tainacan-sample-permalink', array( &$this, 'ajax_sample_permalink') );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_admin_menu() {
|
||||||
|
|
||||||
|
// Tainacan Admin Vue component.
|
||||||
|
$tainacan_page_suffix = add_submenu_page(
|
||||||
|
\Tainacan\Views::get_instance()->tainacan_root_menu_slug,
|
||||||
|
__( 'Repository', 'tainacan' ),
|
||||||
|
__( 'Repository', 'tainacan' ),
|
||||||
|
'read',
|
||||||
|
$this->repository_links_slug,
|
||||||
|
array( &$this, 'admin_page' ),
|
||||||
|
);
|
||||||
|
add_action( 'load-' . $tainacan_page_suffix, array( &$this, 'load_admin_page' ) );
|
||||||
|
|
||||||
|
// Inner links to the admin vue component
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Metadata', 'tainacan'),
|
||||||
|
__('Metadata', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/metadata',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Filters', 'tainacan'),
|
||||||
|
__('Filters', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/filters',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Taxonomies', 'tainacan'),
|
||||||
|
__('Taxonomies', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/taxonomies',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Activities', 'tainacan'),
|
||||||
|
__('Activities', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/activities',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Capabilities', 'tainacan'),
|
||||||
|
__('Capabilities', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/capabilities',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Importers', 'tainacan'),
|
||||||
|
__('Importers', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/importers',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->repository_links_slug,
|
||||||
|
__('Exporters', 'tainacan'),
|
||||||
|
__('Exporters', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/exporters',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
\Tainacan\Views::get_instance()->tainacan_root_menu_slug,
|
||||||
|
__('Collections', 'tainacan'),
|
||||||
|
__('Collections', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->collections_links_slug,
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->collections_links_slug,
|
||||||
|
__('Collections list', 'tainacan'),
|
||||||
|
__('Collections list', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->vue_component_page_slug . '#/collections',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
add_submenu_page(
|
||||||
|
$this->collections_links_slug,
|
||||||
|
__('Items', 'tainacan'),
|
||||||
|
__('Items', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
'tainacan_admin#/items',
|
||||||
|
array( &$this, 'admin_page' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_admin_page() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_admin_css() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
|
||||||
|
wp_enqueue_script('underscore');
|
||||||
|
wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [] );
|
||||||
|
wp_enqueue_style( 'tainacan-admin-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-admin.css', [], TAINACAN_VERSION );
|
||||||
|
|
||||||
|
// $undesired_wp_styles = [
|
||||||
|
// 'admin-menu',
|
||||||
|
// 'admin-bar',
|
||||||
|
// 'code-editor',
|
||||||
|
// 'color-picker',
|
||||||
|
// 'customize-controls',
|
||||||
|
// 'customize-nav-menus',
|
||||||
|
// 'customize-widgets',
|
||||||
|
// 'dashboard',
|
||||||
|
// 'dashicons',
|
||||||
|
// 'deprecated-media',
|
||||||
|
// 'edit',
|
||||||
|
// 'wp-pointer',
|
||||||
|
// 'farbtastic',
|
||||||
|
// 'forms',
|
||||||
|
// 'common',
|
||||||
|
// 'install',
|
||||||
|
// 'wp-auth-check',
|
||||||
|
// 'site-icon',
|
||||||
|
// 'buttons',
|
||||||
|
// 'l10n',
|
||||||
|
// 'list-tables',
|
||||||
|
// 'login',
|
||||||
|
// 'media',
|
||||||
|
// 'nav-menus',
|
||||||
|
// 'revisions',
|
||||||
|
// 'themes',
|
||||||
|
// 'widgets',
|
||||||
|
// 'wp-admin'
|
||||||
|
// ];
|
||||||
|
|
||||||
|
// wp_dequeue_style( $undesired_wp_styles );
|
||||||
|
// wp_deregister_style( $undesired_wp_styles );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_admin_js() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
global $TAINACAN_EXTRA_SCRIPTS;
|
||||||
|
|
||||||
|
$deps = ['underscore', 'media-editor', 'media-views', 'customize-controls', 'wp-i18n'];
|
||||||
|
if ( !empty($TAINACAN_EXTRA_SCRIPTS) ) {
|
||||||
|
foreach($TAINACAN_EXTRA_SCRIPTS as $dep) {
|
||||||
|
$deps[] = $dep;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_enqueue_script(
|
||||||
|
'tainacan-pages-common-scripts',
|
||||||
|
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
||||||
|
$deps,
|
||||||
|
TAINACAN_VERSION
|
||||||
|
);
|
||||||
|
$settings = \Tainacan\Views::get_instance()->get_admin_js_localization_params();
|
||||||
|
|
||||||
|
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
||||||
|
wp_enqueue_media(
|
||||||
|
//[ 'post' => 131528 ]
|
||||||
|
);
|
||||||
|
wp_enqueue_script('underscore');
|
||||||
|
wp_enqueue_script('jcrop');
|
||||||
|
wp_enqueue_script( 'customize-controls' );
|
||||||
|
|
||||||
|
do_action('tainacan-enqueue-admin-scripts');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function admin_body_class( $classes ) {
|
||||||
|
|
||||||
|
if ( isset( $_GET['page'] ) && $_GET['page'] == $this->vue_component_page_slug )
|
||||||
|
$classes .= ' tainacan-admin-page';
|
||||||
|
|
||||||
|
return $classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
function admin_page() {
|
||||||
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
// @deprecated: use tainacan-admin-ui-options instead
|
||||||
|
$admin_options = apply_filters('set_tainacan_admin_options', $_GET);
|
||||||
|
$admin_options = apply_filters('tainacan-admin-ui-options', $_GET);
|
||||||
|
$admin_options = json_encode($admin_options);
|
||||||
|
echo "<div id='tainacan-admin-app' data-module='admin' data-options='$admin_options'></div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajax request used in admin to create slug for entities based on the title
|
||||||
|
*/
|
||||||
|
function ajax_sample_permalink(){
|
||||||
|
|
||||||
|
$id = sanitize_text_field($_POST['post_id']);
|
||||||
|
$title = sanitize_text_field($_POST['new_title']);
|
||||||
|
$name = sanitize_text_field($_POST['new_slug']);
|
||||||
|
|
||||||
|
$post = get_post( $id );
|
||||||
|
if ( ! $post )
|
||||||
|
return array( '', '' );
|
||||||
|
|
||||||
|
$ptype = get_post_type_object($post->post_type);
|
||||||
|
|
||||||
|
// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
|
||||||
|
if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ) ) ) {
|
||||||
|
$post->post_status = 'publish';
|
||||||
|
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the user wants to set a new name -- override the current one
|
||||||
|
// Note: if empty name is supplied -- use the title instead, see #6072
|
||||||
|
if ( !is_null($name) )
|
||||||
|
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
|
||||||
|
|
||||||
|
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
|
||||||
|
if ( $post->post_type === \Tainacan\Entities\Taxonomy::$post_type ) {
|
||||||
|
$post_name = $post->post_name;
|
||||||
|
$tax = \get_taxonomies(array('name' => $post_name));
|
||||||
|
$suffix = 2;
|
||||||
|
while ( !empty($tax) ) {
|
||||||
|
$post_name = _truncate_post_slug( $post_name, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
||||||
|
$tax = \get_taxonomies(array('name' => $post_name));
|
||||||
|
$suffix++;
|
||||||
|
};
|
||||||
|
$post->post_name = $post_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$post->filter = 'sample';
|
||||||
|
|
||||||
|
$permalink = get_permalink($post, true);
|
||||||
|
|
||||||
|
// Replace custom post_type Token with generic pagename token for ease of use.
|
||||||
|
$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
|
||||||
|
|
||||||
|
// Handle page hierarchy
|
||||||
|
if ( $ptype->hierarchical ) {
|
||||||
|
$uri = get_page_uri($post);
|
||||||
|
if ( $uri ) {
|
||||||
|
$uri = untrailingslashit($uri);
|
||||||
|
$uri = strrev( stristr( strrev( $uri ), '/' ) );
|
||||||
|
$uri = untrailingslashit($uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This filter is documented in wp-admin/edit-tag-form.php */
|
||||||
|
$uri = apply_filters( 'editable_slug', $uri, $post );
|
||||||
|
if ( !empty($uri) )
|
||||||
|
$uri .= '/';
|
||||||
|
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** This filter is documented in wp-admin/edit-tag-form.php */
|
||||||
|
$permalink = array( 'permalink' => $permalink, 'slug' => apply_filters( 'editable_slug', $post->post_name, $post ) );
|
||||||
|
|
||||||
|
echo json_encode($permalink);
|
||||||
|
|
||||||
|
wp_die();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -35,19 +35,19 @@
|
||||||
html {
|
html {
|
||||||
overflow-y: hidden;
|
overflow-y: hidden;
|
||||||
}
|
}
|
||||||
body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter {
|
// body.tainacan-admin-page #adminmenumain, body.tainacan-admin-page #wpfooter {
|
||||||
display: none;
|
// display: none;
|
||||||
}
|
// }
|
||||||
body.tainacan-admin-page #wp-auth-check-wrap {
|
body.tainacan-admin-page #wp-auth-check-wrap {
|
||||||
z-index: 9999999;
|
z-index: 9999999;
|
||||||
}
|
}
|
||||||
#tainacan-admin-app {
|
#tainacan-admin-app {
|
||||||
background: var(--tainacan-background-color);
|
background: var(--tainacan-background-color);
|
||||||
position: fixed;
|
// position: fixed;
|
||||||
top: 0;
|
// top: 0;
|
||||||
left: 0;
|
// left: 0;
|
||||||
bottom: 0;
|
// bottom: 0;
|
||||||
right: 0;
|
// right: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 999999;
|
z-index: 999999;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
|
|
|
@ -1,562 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Tainacan;
|
|
||||||
|
|
||||||
|
|
||||||
class Admin {
|
|
||||||
|
|
||||||
private $menu_slug = 'tainacan_admin';
|
|
||||||
private static $instance = null;
|
|
||||||
|
|
||||||
public static function get_instance() {
|
|
||||||
if ( ! isset( self::$instance ) ) {
|
|
||||||
self::$instance = new self();
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function __construct() {
|
|
||||||
|
|
||||||
add_action( 'wp_ajax_tainacan-sample-permalink', array( &$this, 'ajax_sample_permalink') );
|
|
||||||
|
|
||||||
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
|
||||||
add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
|
|
||||||
|
|
||||||
add_action( 'init', array( &$this, 'register_user_meta' ) );
|
|
||||||
add_action( 'after_setup_theme', array( &$this, 'load_theme_files'));
|
|
||||||
|
|
||||||
add_action( 'admin_init', array( &$this, 'register_user_setting') );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_admin_menu() {
|
|
||||||
|
|
||||||
$page_suffix = add_menu_page(
|
|
||||||
__( 'Tainacan', 'tainacan' ),
|
|
||||||
__( 'Tainacan', 'tainacan' ),
|
|
||||||
'read',
|
|
||||||
$this->menu_slug,
|
|
||||||
array( &$this, 'admin_page' ),
|
|
||||||
plugin_dir_url( __FILE__ ) . '../assets/images/tainacan_logo_symbol.svg'
|
|
||||||
);
|
|
||||||
|
|
||||||
add_submenu_page(
|
|
||||||
$this->menu_slug,
|
|
||||||
__('System check', 'tainacan'),
|
|
||||||
__('System check', 'tainacan'),
|
|
||||||
'manage_options',
|
|
||||||
'tainacan_systemcheck',
|
|
||||||
array( &$this, 'systemcheck_page' )
|
|
||||||
);
|
|
||||||
|
|
||||||
$roles_page_suffix = add_submenu_page(
|
|
||||||
$this->menu_slug,
|
|
||||||
__('User Roles', 'tainacan'),
|
|
||||||
__('User Roles', 'tainacan'),
|
|
||||||
'tnc_rep_edit_users',
|
|
||||||
'tainacan_roles',
|
|
||||||
array( &$this, 'roles_page' )
|
|
||||||
);
|
|
||||||
|
|
||||||
$reports_page_suffix = add_submenu_page(
|
|
||||||
$this->menu_slug,
|
|
||||||
__('Reports', 'tainacan'),
|
|
||||||
__('Reports', 'tainacan'),
|
|
||||||
'manage_tainacan',
|
|
||||||
'tainacan_reports',
|
|
||||||
array( &$this, 'reports_page' )
|
|
||||||
);
|
|
||||||
|
|
||||||
add_submenu_page(
|
|
||||||
$this->menu_slug,
|
|
||||||
__('Item Submission', 'tainacan'),
|
|
||||||
__('Item Submission', 'tainacan'),
|
|
||||||
'manage_options',
|
|
||||||
'tainacan_item_submission',
|
|
||||||
array( &$this, 'item_submission' )
|
|
||||||
);
|
|
||||||
|
|
||||||
$mobile_app_page_suffix = add_submenu_page(
|
|
||||||
'tainacan-no-show-menu', // Mobile app page is not listed in the menu
|
|
||||||
__('Mobile App', 'tainacan'),
|
|
||||||
__('Mobile App', 'tainacan'),
|
|
||||||
'manage_tainacan',
|
|
||||||
'tainacan_mobile_app',
|
|
||||||
array( &$this, 'mobile_app' )
|
|
||||||
);
|
|
||||||
|
|
||||||
$dashboard_page_suffix = add_submenu_page(
|
|
||||||
$this->menu_slug,
|
|
||||||
__('Dashboard', 'tainacan'),
|
|
||||||
__('Dashboard', 'tainacan'),
|
|
||||||
'manage_tainacan',
|
|
||||||
'tainacan_dashboard',
|
|
||||||
array( &$this, 'dashboard' )
|
|
||||||
);
|
|
||||||
|
|
||||||
add_action( 'load-' . $page_suffix, array( &$this, 'load_admin_page' ) );
|
|
||||||
add_action( 'load-' . $roles_page_suffix, array( &$this, 'load_roles_page' ) );
|
|
||||||
add_action( 'load-' . $reports_page_suffix, array( &$this, 'load_reports_page' ) );
|
|
||||||
add_action( 'load-' . $mobile_app_page_suffix, array( &$this, 'load_mobile_app_page' ) );
|
|
||||||
add_action( 'load-' . $dashboard_page_suffix, array( &$this, 'load_dashboard_page' ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_admin_page() {
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_css' ), 90 );
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_admin_js' ), 90 );
|
|
||||||
add_action( 'admin_enqueue_scripts', array(&$this, 'add_theme_files') );
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_roles_page() {
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_roles_css' ), 90 );
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_roles_js' ), 90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_reports_page() {
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_reports_css' ), 90 );
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_reports_js' ), 90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_mobile_app_page() {
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_mobile_app_css' ), 90 );
|
|
||||||
}
|
|
||||||
function load_dashboard_page() {
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_dashboard_css' ), 90 );
|
|
||||||
add_action( 'admin_enqueue_scripts', array( &$this, 'add_dashboard_js' ), 90 );
|
|
||||||
}
|
|
||||||
|
|
||||||
function login_styles_reset( $style ) {
|
|
||||||
if ( strpos( $style, 'wp-admin-css' ) !== false ) {
|
|
||||||
$style = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $style;
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_theme_files() {
|
|
||||||
add_action( 'wp_enqueue_scripts', array(&$this, 'add_theme_files') );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_theme_files() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
|
|
||||||
wp_enqueue_script('underscore');
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_roles_css() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_style( 'tainacan-roles-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-roles.css', [], TAINACAN_VERSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_mobile_app_css() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_style( 'tainacan-mobile-app-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-mobile-app.css', [], TAINACAN_VERSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_dashboard_css() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_admin_css( 'dashboard' );
|
|
||||||
//wp_enqueue_style( 'tainacan-dashboard-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-dashboard.css', [], TAINACAN_VERSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_dashboard_js() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_script( 'dashboard' );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_roles_js() {
|
|
||||||
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_script(
|
|
||||||
'tainacan-pages-common-scripts',
|
|
||||||
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
|
||||||
['underscore', 'wp-i18n'],
|
|
||||||
TAINACAN_VERSION
|
|
||||||
);
|
|
||||||
wp_set_script_translations('tainacan-pages-common-scripts', 'tainacan');
|
|
||||||
|
|
||||||
$settings = $this->get_admin_js_localization_params();
|
|
||||||
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
|
||||||
wp_enqueue_script('underscore');
|
|
||||||
wp_enqueue_script('wp-i18n');
|
|
||||||
|
|
||||||
do_action('tainacan-enqueue-roles-scripts');
|
|
||||||
}
|
|
||||||
|
|
||||||
function roles_page() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
echo "<div id='tainacan-roles-app' data-module='roles'></div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_reports_css() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
|
|
||||||
wp_enqueue_style( 'tainacan-reports-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-reports.css', [], TAINACAN_VERSION );
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_reports_js() {
|
|
||||||
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_script(
|
|
||||||
'tainacan-pages-common-scripts',
|
|
||||||
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
|
||||||
['underscore', 'wp-i18n'],
|
|
||||||
TAINACAN_VERSION
|
|
||||||
);
|
|
||||||
wp_set_script_translations('tainacan-pages-common-scripts', 'tainacan');
|
|
||||||
|
|
||||||
$settings = $this->get_admin_js_localization_params();
|
|
||||||
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
|
||||||
wp_enqueue_script('underscore');
|
|
||||||
wp_enqueue_script('wp-i18n');
|
|
||||||
|
|
||||||
do_action('tainacan-enqueue-reports-scripts');
|
|
||||||
}
|
|
||||||
|
|
||||||
function reports_page() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
echo "<div id='tainacan-reports-app' data-module='reports'></div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_admin_css() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
wp_enqueue_style( 'roboto-fonts', 'https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i', [] );
|
|
||||||
wp_enqueue_style( 'tainacan-admin-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-admin.css', [], TAINACAN_VERSION );
|
|
||||||
|
|
||||||
// $undesired_wp_styles = [
|
|
||||||
// 'admin-menu',
|
|
||||||
// 'admin-bar',
|
|
||||||
// 'code-editor',
|
|
||||||
// 'color-picker',
|
|
||||||
// 'customize-controls',
|
|
||||||
// 'customize-nav-menus',
|
|
||||||
// 'customize-widgets',
|
|
||||||
// 'dashboard',
|
|
||||||
// 'dashicons',
|
|
||||||
// 'deprecated-media',
|
|
||||||
// 'edit',
|
|
||||||
// 'wp-pointer',
|
|
||||||
// 'farbtastic',
|
|
||||||
// 'forms',
|
|
||||||
// 'common',
|
|
||||||
// 'install',
|
|
||||||
// 'wp-auth-check',
|
|
||||||
// 'site-icon',
|
|
||||||
// 'buttons',
|
|
||||||
// 'l10n',
|
|
||||||
// 'list-tables',
|
|
||||||
// 'login',
|
|
||||||
// 'media',
|
|
||||||
// 'nav-menus',
|
|
||||||
// 'revisions',
|
|
||||||
// 'themes',
|
|
||||||
// 'widgets',
|
|
||||||
// 'wp-admin'
|
|
||||||
// ];
|
|
||||||
|
|
||||||
// wp_dequeue_style( $undesired_wp_styles );
|
|
||||||
// wp_deregister_style( $undesired_wp_styles );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_admin_js() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
global $TAINACAN_EXTRA_SCRIPTS;
|
|
||||||
|
|
||||||
$deps = ['underscore', 'media-editor', 'media-views', 'customize-controls', 'wp-i18n'];
|
|
||||||
if ( !empty($TAINACAN_EXTRA_SCRIPTS) ) {
|
|
||||||
foreach($TAINACAN_EXTRA_SCRIPTS as $dep) {
|
|
||||||
$deps[] = $dep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
wp_enqueue_script(
|
|
||||||
'tainacan-pages-common-scripts',
|
|
||||||
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
|
||||||
$deps,
|
|
||||||
TAINACAN_VERSION
|
|
||||||
);
|
|
||||||
$settings = $this->get_admin_js_localization_params();
|
|
||||||
|
|
||||||
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
|
||||||
wp_enqueue_media(
|
|
||||||
//[ 'post' => 131528 ]
|
|
||||||
);
|
|
||||||
wp_enqueue_script('underscore');
|
|
||||||
wp_enqueue_script('jcrop');
|
|
||||||
wp_enqueue_script( 'customize-controls' );
|
|
||||||
|
|
||||||
do_action('tainacan-enqueue-admin-scripts');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_admin_js_localization_params() {
|
|
||||||
global $TAINACAN_BASE_URL, $TAINACAN_API_MAX_ITEMS_PER_PAGE;
|
|
||||||
|
|
||||||
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
|
||||||
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
|
||||||
$Tainacan_Metadata_Sections = \Tainacan\Repositories\Metadata_Sections::get_instance();
|
|
||||||
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
|
||||||
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
|
||||||
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
|
||||||
|
|
||||||
$tainacan_admin_i18n = require( 'tainacan-i18n.php' );
|
|
||||||
|
|
||||||
$entities_labels = [
|
|
||||||
'collections' => $Tainacan_Collections->get_cpt_labels(),
|
|
||||||
'metadata' => $Tainacan_Metadata->get_cpt_labels(),
|
|
||||||
'metadata-sections' => $Tainacan_Metadata_Sections->get_cpt_labels(),
|
|
||||||
'filters' => $Tainacan_Filters->get_cpt_labels(),
|
|
||||||
'items' => $Tainacan_Items->get_cpt_labels(),
|
|
||||||
'taxonomies' => $Tainacan_Taxonomies->get_cpt_labels(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$tainacan_admin_i18n['entities_labels'] = $entities_labels;
|
|
||||||
|
|
||||||
$cur_user = wp_get_current_user();
|
|
||||||
$user_caps = array();
|
|
||||||
$prefs = array();
|
|
||||||
$user_data = array();
|
|
||||||
if ( $cur_user instanceof \WP_User ) {
|
|
||||||
$tainacan_caps = \tainacan_roles()->get_repository_caps_slugs();
|
|
||||||
foreach ($tainacan_caps as $tcap) {
|
|
||||||
$user_caps[$tcap] = current_user_can( $tcap );
|
|
||||||
}
|
|
||||||
$prefs = get_user_meta( $cur_user->ID, 'tainacan_prefs', true );
|
|
||||||
|
|
||||||
if ( $cur_user->data && isset($cur_user->data->user_email) && isset($cur_user->data->display_name) ) {
|
|
||||||
$user_data = array(
|
|
||||||
'ID' => $cur_user->ID,
|
|
||||||
'email' => $cur_user->data->user_email,
|
|
||||||
'display_name' => $cur_user->data->display_name
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$settings = [
|
|
||||||
'tainacan_api_url' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
|
||||||
'wp_api_url' => esc_url_raw( rest_url() ) . 'wp/v2/',
|
|
||||||
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
|
||||||
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
|
|
||||||
'classes' => array(),
|
|
||||||
'i18n' => $tainacan_admin_i18n,
|
|
||||||
'user_caps' => $user_caps,
|
|
||||||
'user_prefs' => $prefs,
|
|
||||||
'user_data' => $user_data,
|
|
||||||
'base_url' => $TAINACAN_BASE_URL,
|
|
||||||
'plugin_dir_url' => plugin_dir_url( __DIR__ ),
|
|
||||||
'admin_url' => admin_url(),
|
|
||||||
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
|
|
||||||
'theme_collection_list_url' => get_post_type_archive_link( 'tainacan-collection' ),
|
|
||||||
'theme_taxonomy_list_url' => get_post_type_archive_link( 'tainacan-taxonomy' ),
|
|
||||||
'custom_header_support' => get_theme_support('custom-header'),
|
|
||||||
'registered_view_modes' => \Tainacan\Theme_Helper::get_instance()->get_registered_view_modes(),
|
|
||||||
'exposer_mapper_param' => \Tainacan\Mappers_Handler::MAPPER_PARAM,
|
|
||||||
'exposer_type_param' => \Tainacan\Exposers_Handler::TYPE_PARAM,
|
|
||||||
'repository_name' => get_bloginfo('name'),
|
|
||||||
'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE,
|
|
||||||
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
|
|
||||||
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key"),
|
|
||||||
'tainacan_enable_core_metadata_on_advanced_search' => ( !defined('TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH') || false === TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH ),
|
|
||||||
'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY )
|
|
||||||
];
|
|
||||||
|
|
||||||
$maps = [
|
|
||||||
'collections' => $Tainacan_Collections->get_map(),
|
|
||||||
'metadata' => $Tainacan_Metadata->get_map(),
|
|
||||||
'metadata-sections' => $Tainacan_Metadata_Sections->get_map(),
|
|
||||||
'filters' => $Tainacan_Filters->get_map(),
|
|
||||||
'items' => $Tainacan_Items->get_map(),
|
|
||||||
'taxonomies' => $Tainacan_Taxonomies->get_map(),
|
|
||||||
];
|
|
||||||
|
|
||||||
$metadata_types = $Tainacan_Metadata->fetch_metadata_types();
|
|
||||||
|
|
||||||
foreach( $maps as $type => $map ){
|
|
||||||
foreach ( $map as $metadatum => $details){
|
|
||||||
$settings['i18n']['helpers_label'][$type][$metadatum] = [ 'title' => $details['title'], 'description' => $details['description'] ];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ( $metadata_types as $index => $metadata_type){
|
|
||||||
$class = new $metadata_type;
|
|
||||||
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
|
||||||
}
|
|
||||||
|
|
||||||
$filter_types = $Tainacan_Filters->fetch_filter_types();
|
|
||||||
|
|
||||||
foreach ( $filter_types as $index => $filter_type){
|
|
||||||
$class = new $filter_type;
|
|
||||||
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
|
||||||
}
|
|
||||||
|
|
||||||
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
|
|
||||||
|
|
||||||
$wp_post_types = get_post_types(['show_ui' => true], 'objects');
|
|
||||||
if (isset($wp_post_types['attachment'])) {
|
|
||||||
unset($wp_post_types['attachment']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$wp_post_types = array_map(function($i) {
|
|
||||||
return [
|
|
||||||
'slug' => $i->name,
|
|
||||||
'label' => $i->label
|
|
||||||
];
|
|
||||||
}, $wp_post_types);
|
|
||||||
|
|
||||||
$settings['wp_post_types'] = $wp_post_types;
|
|
||||||
|
|
||||||
// Key-valued array with extra options to be passed to every request in the admin (goes the header)
|
|
||||||
$admin_request_options = [];
|
|
||||||
$admin_request_options = apply_filters('tainacan-admin-extra-request-options', $admin_request_options);
|
|
||||||
$settings['admin_request_options'] = $admin_request_options;
|
|
||||||
|
|
||||||
return $settings;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function admin_body_class( $classes ) {
|
|
||||||
|
|
||||||
if ( isset( $_GET['page'] ) && $_GET['page'] == $this->menu_slug )
|
|
||||||
$classes .= ' tainacan-admin-page';
|
|
||||||
|
|
||||||
return $classes;
|
|
||||||
}
|
|
||||||
|
|
||||||
function admin_page() {
|
|
||||||
global $TAINACAN_BASE_URL;
|
|
||||||
|
|
||||||
// @deprecated: use tainacan-admin-ui-options instead
|
|
||||||
$admin_options = apply_filters('set_tainacan_admin_options', $_GET);
|
|
||||||
$admin_options = apply_filters('tainacan-admin-ui-options', $_GET);
|
|
||||||
$admin_options = json_encode($admin_options);
|
|
||||||
|
|
||||||
echo "<div id='tainacan-admin-app' data-module='admin' data-options='$admin_options'></div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
function register_user_meta() {
|
|
||||||
$args = array(
|
|
||||||
//'sanitize_callback' => array(&$this, 'santize_user_tainacan_prefs'),
|
|
||||||
//'auth_callback' => 'authorize_my_meta_key',
|
|
||||||
'type' => 'string',
|
|
||||||
'description' => 'Tainacan admin user preferences',
|
|
||||||
'single' => true,
|
|
||||||
'show_in_rest' => true,
|
|
||||||
);
|
|
||||||
register_meta( 'user', 'tainacan_prefs', $args );
|
|
||||||
}
|
|
||||||
|
|
||||||
function register_user_setting() {
|
|
||||||
register_setting(
|
|
||||||
'tainacan_item_submission_recaptcha',
|
|
||||||
'tnc_option_recaptch_site_key',
|
|
||||||
'sanitize_text_field'
|
|
||||||
);
|
|
||||||
|
|
||||||
register_setting(
|
|
||||||
'tainacan_item_submission_recaptcha',
|
|
||||||
'tnc_option_recaptch_secret_key',
|
|
||||||
'sanitize_text_field'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function ajax_sample_permalink(){
|
|
||||||
|
|
||||||
$id = sanitize_text_field($_POST['post_id']);
|
|
||||||
$title = sanitize_text_field($_POST['new_title']);
|
|
||||||
$name = sanitize_text_field($_POST['new_slug']);
|
|
||||||
|
|
||||||
$post = get_post( $id );
|
|
||||||
if ( ! $post )
|
|
||||||
return array( '', '' );
|
|
||||||
|
|
||||||
$ptype = get_post_type_object($post->post_type);
|
|
||||||
|
|
||||||
// Hack: get_permalink() would return ugly permalink for drafts, so we will fake that our post is published.
|
|
||||||
if ( in_array( $post->post_status, array( 'auto-draft', 'draft', 'pending', 'future' ) ) ) {
|
|
||||||
$post->post_status = 'publish';
|
|
||||||
$post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the user wants to set a new name -- override the current one
|
|
||||||
// Note: if empty name is supplied -- use the title instead, see #6072
|
|
||||||
if ( !is_null($name) )
|
|
||||||
$post->post_name = sanitize_title($name ? $name : $title, $post->ID);
|
|
||||||
|
|
||||||
$post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
|
|
||||||
if ( $post->post_type === \Tainacan\Entities\Taxonomy::$post_type ) {
|
|
||||||
$post_name = $post->post_name;
|
|
||||||
$tax = \get_taxonomies(array('name' => $post_name));
|
|
||||||
$suffix = 2;
|
|
||||||
while ( !empty($tax) ) {
|
|
||||||
$post_name = _truncate_post_slug( $post_name, 200 - ( strlen( $suffix ) + 1 ) ) . "-$suffix";
|
|
||||||
$tax = \get_taxonomies(array('name' => $post_name));
|
|
||||||
$suffix++;
|
|
||||||
};
|
|
||||||
$post->post_name = $post_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
$post->filter = 'sample';
|
|
||||||
|
|
||||||
$permalink = get_permalink($post, true);
|
|
||||||
|
|
||||||
// Replace custom post_type Token with generic pagename token for ease of use.
|
|
||||||
$permalink = str_replace("%$post->post_type%", '%pagename%', $permalink);
|
|
||||||
|
|
||||||
// Handle page hierarchy
|
|
||||||
if ( $ptype->hierarchical ) {
|
|
||||||
$uri = get_page_uri($post);
|
|
||||||
if ( $uri ) {
|
|
||||||
$uri = untrailingslashit($uri);
|
|
||||||
$uri = strrev( stristr( strrev( $uri ), '/' ) );
|
|
||||||
$uri = untrailingslashit($uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This filter is documented in wp-admin/edit-tag-form.php */
|
|
||||||
$uri = apply_filters( 'editable_slug', $uri, $post );
|
|
||||||
if ( !empty($uri) )
|
|
||||||
$uri .= '/';
|
|
||||||
$permalink = str_replace('%pagename%', "{$uri}%pagename%", $permalink);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This filter is documented in wp-admin/edit-tag-form.php */
|
|
||||||
$permalink = array( 'permalink' => $permalink, 'slug' => apply_filters( 'editable_slug', $post->post_name, $post ) );
|
|
||||||
|
|
||||||
echo json_encode($permalink);
|
|
||||||
|
|
||||||
wp_die();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function systemcheck_page() {
|
|
||||||
require_once('system-check/class-tainacan-system-check.php');
|
|
||||||
$check = new System_Check();
|
|
||||||
$check->admin_page();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function item_submission() {
|
|
||||||
require_once('item-submission/class-tainacan-item-submission.php');
|
|
||||||
$submission = new Item_Submission();
|
|
||||||
$submission->admin_page();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function mobile_app() {
|
|
||||||
require_once('mobile-app/class-tainacan-mobile-app.php');
|
|
||||||
$Mobile_app = new Mobile_App();
|
|
||||||
$Mobile_app->admin_page();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function dashboard() {
|
|
||||||
require_once('dashboard/class-tainacan-dashboard.php');
|
|
||||||
$dashboard = new Dashboard();
|
|
||||||
$dashboard->admin_page();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,252 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tainacan;
|
||||||
|
|
||||||
|
class Views {
|
||||||
|
use \Tainacan\Traits\Singleton_Instance;
|
||||||
|
|
||||||
|
public $tainacan_root_menu_slug = 'tainacan-root-menu';
|
||||||
|
private $other_links_slug = 'tainacan_other_links';
|
||||||
|
|
||||||
|
private function init() {
|
||||||
|
|
||||||
|
add_action( 'init', array( &$this, 'register_user_meta' ) );
|
||||||
|
|
||||||
|
add_action( 'admin_init',array( $this, 'check_if_admin_menu_is_collapsed' ) );
|
||||||
|
|
||||||
|
require_once('dashboard/class-tainacan-dashboard.php');
|
||||||
|
new \Tainacan\Dashboard();
|
||||||
|
|
||||||
|
require_once('admin/class-tainacan-admin.php');
|
||||||
|
new \Tainacan\Admin();
|
||||||
|
|
||||||
|
require_once('system-check/class-tainacan-system-check.php');
|
||||||
|
new \Tainacan\System_Check();
|
||||||
|
|
||||||
|
require_once('roles/class-tainacan-roles.php');
|
||||||
|
new \Tainacan\Roles_Editor();
|
||||||
|
|
||||||
|
require_once('reports/class-tainacan-reports.php');
|
||||||
|
new \Tainacan\Reports();
|
||||||
|
|
||||||
|
require_once('item-submission/class-tainacan-item-submission.php');
|
||||||
|
new \Tainacan\Item_Submission();
|
||||||
|
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
|
||||||
|
add_action( 'after_setup_theme', array( &$this, 'load_theme_files') );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function load_theme_files() {
|
||||||
|
add_action( 'wp_enqueue_scripts', array(&$this, 'add_theme_files') );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_theme_files() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
|
||||||
|
wp_enqueue_script('underscore');
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_admin_menu() {
|
||||||
|
|
||||||
|
add_submenu_page(
|
||||||
|
$this->tainacan_root_menu_slug,
|
||||||
|
__('Other', 'tainacan'),
|
||||||
|
__('Other', 'tainacan'),
|
||||||
|
'read',
|
||||||
|
$this->other_links_slug,
|
||||||
|
'#'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_admin_js_localization_params() {
|
||||||
|
global $TAINACAN_BASE_URL, $TAINACAN_API_MAX_ITEMS_PER_PAGE;
|
||||||
|
|
||||||
|
$Tainacan_Collections = \Tainacan\Repositories\Collections::get_instance();
|
||||||
|
$Tainacan_Metadata = \Tainacan\Repositories\Metadata::get_instance();
|
||||||
|
$Tainacan_Metadata_Sections = \Tainacan\Repositories\Metadata_Sections::get_instance();
|
||||||
|
$Tainacan_Filters = \Tainacan\Repositories\Filters::get_instance();
|
||||||
|
$Tainacan_Items = \Tainacan\Repositories\Items::get_instance();
|
||||||
|
$Tainacan_Taxonomies = \Tainacan\Repositories\Taxonomies::get_instance();
|
||||||
|
|
||||||
|
$tainacan_admin_i18n = require( 'tainacan-i18n.php' );
|
||||||
|
|
||||||
|
$entities_labels = [
|
||||||
|
'collections' => $Tainacan_Collections->get_cpt_labels(),
|
||||||
|
'metadata' => $Tainacan_Metadata->get_cpt_labels(),
|
||||||
|
'metadata-sections' => $Tainacan_Metadata_Sections->get_cpt_labels(),
|
||||||
|
'filters' => $Tainacan_Filters->get_cpt_labels(),
|
||||||
|
'items' => $Tainacan_Items->get_cpt_labels(),
|
||||||
|
'taxonomies' => $Tainacan_Taxonomies->get_cpt_labels(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$tainacan_admin_i18n['entities_labels'] = $entities_labels;
|
||||||
|
|
||||||
|
$cur_user = wp_get_current_user();
|
||||||
|
$user_caps = array();
|
||||||
|
$prefs = array();
|
||||||
|
$user_data = array();
|
||||||
|
if ( $cur_user instanceof \WP_User ) {
|
||||||
|
$tainacan_caps = \tainacan_roles()->get_repository_caps_slugs();
|
||||||
|
foreach ($tainacan_caps as $tcap) {
|
||||||
|
$user_caps[$tcap] = current_user_can( $tcap );
|
||||||
|
}
|
||||||
|
$prefs = get_user_meta( $cur_user->ID, 'tainacan_prefs', true );
|
||||||
|
|
||||||
|
if ( $cur_user->data && isset($cur_user->data->user_email) && isset($cur_user->data->display_name) ) {
|
||||||
|
$user_data = array(
|
||||||
|
'ID' => $cur_user->ID,
|
||||||
|
'email' => $cur_user->data->user_email,
|
||||||
|
'display_name' => $cur_user->data->display_name
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings = [
|
||||||
|
'tainacan_api_url' => esc_url_raw( rest_url() ) . 'tainacan/v2',
|
||||||
|
'wp_api_url' => esc_url_raw( rest_url() ) . 'wp/v2/',
|
||||||
|
'wp_ajax_url' => admin_url( 'admin-ajax.php' ),
|
||||||
|
'nonce' => is_user_logged_in() ? wp_create_nonce( 'wp_rest' ) : false,
|
||||||
|
'classes' => array(),
|
||||||
|
'i18n' => $tainacan_admin_i18n,
|
||||||
|
'user_caps' => $user_caps,
|
||||||
|
'user_prefs' => $prefs,
|
||||||
|
'user_data' => $user_data,
|
||||||
|
'base_url' => $TAINACAN_BASE_URL,
|
||||||
|
'plugin_dir_url' => plugin_dir_url( __DIR__ ),
|
||||||
|
'admin_url' => admin_url(),
|
||||||
|
'theme_items_list_url' => esc_url_raw( get_site_url() ) . '/' . \Tainacan\Theme_Helper::get_instance()->get_items_list_slug(),
|
||||||
|
'theme_collection_list_url' => get_post_type_archive_link( 'tainacan-collection' ),
|
||||||
|
'theme_taxonomy_list_url' => get_post_type_archive_link( 'tainacan-taxonomy' ),
|
||||||
|
'custom_header_support' => get_theme_support('custom-header'),
|
||||||
|
'registered_view_modes' => \Tainacan\Theme_Helper::get_instance()->get_registered_view_modes(),
|
||||||
|
'exposer_mapper_param' => \Tainacan\Mappers_Handler::MAPPER_PARAM,
|
||||||
|
'exposer_type_param' => \Tainacan\Exposers_Handler::TYPE_PARAM,
|
||||||
|
'repository_name' => get_bloginfo('name'),
|
||||||
|
'api_max_items_per_page' => $TAINACAN_API_MAX_ITEMS_PER_PAGE,
|
||||||
|
'wp_elasticpress' => \Tainacan\Elastic_Press::get_instance()->is_active(),
|
||||||
|
'item_submission_captcha_site_key' => get_option("tnc_option_recaptch_site_key"),
|
||||||
|
'tainacan_enable_core_metadata_on_advanced_search' => ( !defined('TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH') || false === TAINACAN_DISABLE_CORE_METADATA_ON_ADVANCED_SEARCH ),
|
||||||
|
'tainacan_enable_relationship_metaquery' => ( defined('TAINACAN_ENABLE_RELATIONSHIP_METAQUERY') && true === TAINACAN_ENABLE_RELATIONSHIP_METAQUERY )
|
||||||
|
];
|
||||||
|
|
||||||
|
$maps = [
|
||||||
|
'collections' => $Tainacan_Collections->get_map(),
|
||||||
|
'metadata' => $Tainacan_Metadata->get_map(),
|
||||||
|
'metadata-sections' => $Tainacan_Metadata_Sections->get_map(),
|
||||||
|
'filters' => $Tainacan_Filters->get_map(),
|
||||||
|
'items' => $Tainacan_Items->get_map(),
|
||||||
|
'taxonomies' => $Tainacan_Taxonomies->get_map(),
|
||||||
|
];
|
||||||
|
|
||||||
|
$metadata_types = $Tainacan_Metadata->fetch_metadata_types();
|
||||||
|
|
||||||
|
foreach( $maps as $type => $map ){
|
||||||
|
foreach ( $map as $metadatum => $details){
|
||||||
|
$settings['i18n']['helpers_label'][$type][$metadatum] = [ 'title' => $details['title'], 'description' => $details['description'] ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach ( $metadata_types as $index => $metadata_type){
|
||||||
|
$class = new $metadata_type;
|
||||||
|
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
||||||
|
}
|
||||||
|
|
||||||
|
$filter_types = $Tainacan_Filters->fetch_filter_types();
|
||||||
|
|
||||||
|
foreach ( $filter_types as $index => $filter_type){
|
||||||
|
$class = new $filter_type;
|
||||||
|
$settings['i18n']['helpers_label'][$class->get_component()] = $class->get_form_labels();
|
||||||
|
}
|
||||||
|
|
||||||
|
$settings['form_hooks'] = Admin_Hooks::get_instance()->get_registered_hooks();
|
||||||
|
|
||||||
|
$wp_post_types = get_post_types(['show_ui' => true], 'objects');
|
||||||
|
if (isset($wp_post_types['attachment'])) {
|
||||||
|
unset($wp_post_types['attachment']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$wp_post_types = array_map(function($i) {
|
||||||
|
return [
|
||||||
|
'slug' => $i->name,
|
||||||
|
'label' => $i->label
|
||||||
|
];
|
||||||
|
}, $wp_post_types);
|
||||||
|
|
||||||
|
$settings['wp_post_types'] = $wp_post_types;
|
||||||
|
|
||||||
|
// Key-valued array with extra options to be passed to every request in the admin (goes the header)
|
||||||
|
$admin_request_options = [];
|
||||||
|
$admin_request_options = apply_filters('tainacan-admin-extra-request-options', $admin_request_options);
|
||||||
|
$settings['admin_request_options'] = $admin_request_options;
|
||||||
|
|
||||||
|
return $settings;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function register_user_meta() {
|
||||||
|
$args = array(
|
||||||
|
//'sanitize_callback' => array(&$this, 'santize_user_tainacan_prefs'),
|
||||||
|
//'auth_callback' => 'authorize_my_meta_key',
|
||||||
|
'type' => 'string',
|
||||||
|
'description' => 'Tainacan admin user preferences',
|
||||||
|
'single' => true,
|
||||||
|
'show_in_rest' => true,
|
||||||
|
);
|
||||||
|
register_meta( 'user', 'tainacan_prefs', $args );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function the_admin_navigation_menu() {
|
||||||
|
global $submenu;
|
||||||
|
?>
|
||||||
|
<ul>
|
||||||
|
<li><a href="admin.php?page=tainacan_dashboard"><?php _e('Home', 'tainacan'); ?></a></li>
|
||||||
|
<?php
|
||||||
|
$tainacan_root_links = isset( $submenu[$this->tainacan_root_menu_slug] ) ? $submenu[$this->tainacan_root_menu_slug] : [];
|
||||||
|
|
||||||
|
if ( count($tainacan_root_links) ) {
|
||||||
|
foreach( $tainacan_root_links as $tainacan_root_link ) {
|
||||||
|
?>
|
||||||
|
<li>
|
||||||
|
<strong>
|
||||||
|
<?php if ( isset( $submenu[$tainacan_root_link[2]] ) ) : ?>
|
||||||
|
<a onclick="console.log('implement open...')"><?php echo $tainacan_root_link[0]; ?></a>
|
||||||
|
<?php else : ?>
|
||||||
|
<a href="<?php echo $tainacan_root_link[1]; ?>"><?php echo $tainacan_root_link[0]; ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
</strong>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
<?php if ( isset( $submenu[$tainacan_root_link[2]] ) ) : ?>
|
||||||
|
<ul>
|
||||||
|
<?php foreach( $submenu[$tainacan_root_link[2]] as $link ) : ?>
|
||||||
|
<li><a href="admin.php?page=<?php echo $link[2]; ?>"><?php echo $link[0]; ?></a></li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<?php endif;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check_if_admin_menu_is_collapsed() {
|
||||||
|
if ( str_contains( $_SERVER['REQUEST_URI'], 'page=tainacan' ) ) {
|
||||||
|
$menu_folding_option = get_user_setting( 'mfold', 'o' );
|
||||||
|
if ( 'o' === $menu_folding_option ) {
|
||||||
|
set_user_setting( 'mfold', 'f');
|
||||||
|
set_user_setting( 'tainacan-set-mfold', 'yes' );
|
||||||
|
} else {
|
||||||
|
set_user_setting( 'tainacan-set-mfold', 'no' );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$menu_folding_option = get_user_setting( 'mfold', 'o' );
|
||||||
|
if ( 'f' === $menu_folding_option && 'yes' === get_user_setting( 'tainacan-set-mfold' ) )
|
||||||
|
set_user_setting( 'mfold', 'o');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -5,11 +5,47 @@ namespace Tainacan;
|
||||||
class Dashboard {
|
class Dashboard {
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->page_init();
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function page_init() {
|
|
||||||
|
|
||||||
|
function add_admin_menu() {
|
||||||
|
|
||||||
|
// Main Page, Dashboard
|
||||||
|
$dashboard_page_suffix = add_menu_page(
|
||||||
|
__( 'Tainacan', 'tainacan' ),
|
||||||
|
__( 'Tainacan', 'tainacan' ),
|
||||||
|
'read',
|
||||||
|
'tainacan_dashboard',
|
||||||
|
array( &$this, 'dashboard_page' ),
|
||||||
|
'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB3aWR0aD0iNC40bW0iIGhlaWdodD0iNC4zbW0iIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDE3LjUxIDE3LjU1NCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIiB4bWxuczpkYz0iaHR0cDovL3B1cmwub3JnL2RjL2VsZW1lbnRzLzEuMS8iIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+CjxtZXRhZGF0YT4KPHJkZjpSREY+CjxjYzpXb3JrIHJkZjphYm91dD0iIj4KPGRjOmZvcm1hdD5pbWFnZS9zdmcreG1sPC9kYzpmb3JtYXQ+CjxkYzp0eXBlIHJkZjpyZXNvdXJjZT0iaHR0cDovL3B1cmwub3JnL2RjL2RjbWl0eXBlL1N0aWxsSW1hZ2UiLz4KPC9jYzpXb3JrPgo8L3JkZjpSREY+CjwvbWV0YWRhdGE+CjxnIHRyYW5zZm9ybT0idHJhbnNsYXRlKC03NS45MTEgLTExOC44OSkiPgo8ZyB0cmFuc2Zvcm09Im1hdHJpeCguMzUyNzggMCAwIC0uMzUyNzggOTIuMjg3IDEzMy45NCkiIGZpbGw9IiNmZmYiPgo8cGF0aCBkPSJtMCAwYy0xZS0zIC0xZS0zIC0yZS0zIC0yZS0zIC0yZS0zIC0zZS0zIC0xZS0zIC0xZS0zIC0xZS0zIC0yZS0zIC0yZS0zIC00ZS0zIC0yLjQwNi01LjEyNC04Ljk4NC02LjAzOC0xOC4xNjgtMS43MzggMC41NjIgMi43MDcgMS4xNzMgNi4zMTggMS4yNzEgOC44NjUgMWUtMyA2ZS0zIDAgMC4wMSAwIDAuMDE2IDIuODE0IDEuODE5IDUuNzI0IDQuMDk2IDguNjM4IDYuOTQzLTAuMTI2IDAuMDY5LTAuMTA0IDAuMDU4IDAgMCA3LjY3Mi00LjE2OCAxMC40ODYtOS4zNDYgOC4yNjMtMTQuMDc5bS0xMC44MTMgMTUuMzQ2cy0xZS0zIDAtMWUtMyAxZS0zYy0yLjA2NS0xLjk5Mi00LjEwNi0zLjY3My02LjA4NS01LjA5Mi0wLjA3OSAyLjM3Mi0wLjM1IDQuOTY5LTAuOTExIDcuNzU5IDIuMjE0LTAuNjczIDQuNTUxLTEuNTQ3IDYuOTk2LTIuNjY3IDAuMDUxIDAuMDQ5IDAuMDM2IDAuMDM1IDAgMCAwLTFlLTMgMWUtMyAtMWUtMyAxZS0zIC0xZS0zbS0xMS4xNCAxNS4xMWM2LjcxIDYuMjA0IDEyLjczMSA3LjI0MiAxNi41MjYgMy40NTkgMWUtMyAwIDJlLTMgLTFlLTMgM2UtMyAtMmUtM3MxZS0zIC0yZS0zIDJlLTMgLTNlLTNjMy44MDktMy43OTUgMi43NzMtOS44NDctMy40NjMtMTYuNjA0LTAuMDMtMC4wMzMtMC4wMzctMC4wMzkgMCAwLTAuMDM4IDAuMDE4LTMuNjM2IDEuODg4LTkuNTc3IDMuNTMzLTAuNDQ2IDIuNDY1LTMuMDY3IDguOTk0LTMuNDkxIDkuNjE3bTIuNjEyLTIxLjg0NmMtMy4yMzktMi4wNC02LjI1OS0zLjM5NS04Ljg3Ni00LjI5Ny0wLjkzNiAwLjcyMS0xLjgwNCAxLjQ0NS0yLjYxIDIuMTY1djFlLTNjLTEuMzQxIDEuMzEtMi43MiAyLjgzNC00LjA5IDQuNjA0IDAuOTA1IDIuNjQzIDIuMjcgNS42OTEgNC4zMjcgOC45NjIgMi44MjYgMC4yMjEgMTAuMDA3LTEuMTM5IDEwLjAyNi0xLjI3OCAwLjIwOS0wLjAzMSAxLjM2Ni03LjI3OSAxLjIyMy0xMC4xNTdtLTEuMTQ3LTkuMjA3Yy0wLjMwNC0wLjAyNS00LjA1IDIuMDcxLTUuMzUgMy4xODl2MWUtM2MyLjAxIDAuNzYxIDYuMzczIDIuOTkyIDYuMzczIDIuOTkyczdlLTMgNGUtMyAwLjAxIDZlLTNjMC01ZS0zIC0wLjYwNy00LjIxMS0xLjAzMy02LjE4OG0tMTYuMjA1IDMuMTMzYzAuMDU5IDEuMDU2IDAuMjQgMi45MTkgMC44MzYgNS4zNTIgMC42MzktMC43NzUgMy43MDQtMy44MjYgNC40OTYtNC41MDUtMi40MTMtMC41OTctNC4yNjctMC43ODItNS4zMzItMC44NDdtLTMuMjEyIDE2LjM4M2MyLjAyOCAwLjQzNSA0LjU2OCAwLjkwOCA2LjMwOCAxLjAzMiAwIDFlLTMgMWUtMyAyZS0zIDFlLTMgM2UtMyAwLTFlLTMgLTFlLTMgLTJlLTMgLTFlLTMgLTNlLTMgLTEuMjkyLTIuMjQ2LTIuMjk4LTQuNDEtMy4wODEtNi40NDEtMS4xIDEuNjE2LTMuMjIxIDUuMzk4LTMuMjI3IDUuNDA5bTAuNTkgMjAuNTg0IDJlLTMgMmUtMyAzZS0zIDFlLTNjNC43ODggMi4yMzQgMTAuMDE1LTAuNjc0IDE0LjE4NS04LjUzMy0yLjgyOC0yLjg2Ny01LjEtNS43My02LjkyMS04LjUwMSAwLTFlLTMgMC0yZS0zIC0xZS0zIC0yZS0zIDFlLTMgMCAxZS0zIDFlLTMgMWUtMyAyZS0zIC0yLjU4MS0wLjA3OC01LjgyNy0wLjc0My04Ljk5Mi0xLjI2NS00LjQ0MSA5LjM5Ni0zLjQxNyAxNS44OTkgMS43MjMgMTguMjk2bTE4LjAxNy0xNy45OTNjLTIuNzU1IDAuNTY3LTUuMzIyIDAuODUzLTcuNjcyIDAuOTQ2IDEuNDA5IDEuOTcgMy4wNzUgNCA1LjA0NiA2LjA1My00ZS0zIDhlLTMgMS45NjYtNC43ODUgMi42MjYtNi45OTltMTQuOTA5LTUuNDkzYzYuOTY2IDcuODI1IDcuNjYyIDE0Ljc1OCAyLjg1NSAxOS41OTJsLTZlLTMgNmUtM2MtNC44MTIgNC44MzgtMTEuOTY5IDQuMDkyLTE5LjYyOS0yLjc2NnYtMWUtMyAxZS0zYy00Ljc2NSA4LjYwOC0xMS4wNiAxMS41ODItMTcuMTA4IDguNzgxbC00ZS0zIC0yZS0zYy0xZS0zIDAtM2UtMyAtMWUtMyAtNGUtMyAtMmUtMyAtOC4xNTItMy40MTgtOC45OTYtMTQuODI2IDIuNDgzLTMxLjQxNmgxZS0zYy0xZS0zIDAtMWUtMyAtMWUtMyAtMWUtMyAtMWUtMyAtMS40MDMtNC43NDctMS41OTItOC40NDgtMS41OTYtMTAuMjY1IDEuNzk0LTVlLTMgNS41MDUgMC4xNjUgMTAuMjggMS41NTEgMTguNzA5LTEyLjcyNCAyOC40MjgtOS4zNDMgMzEuMzI1LTIuNTkyIDAgMWUtMyAxZS0zIDJlLTMgMmUtMyA0ZS0zIDAgMWUtMyAxZS0zIDNlLTMgMmUtMyA0ZS0zIDIuODIyIDYuMDExLTAuMzY2IDEyLjY3OC04LjYgMTcuMTA2IiBmaWxsPSIjZmZmIi8+CjwvZz4KPC9nPgo8L3N2Zz4K'
|
||||||
|
);
|
||||||
|
add_action( 'load-' . $dashboard_page_suffix, array( &$this, 'load_dashboard_page' ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_dashboard_page() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_dashboard_css' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_dashboard_js' ), 90 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_dashboard_css() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_admin_css( 'dashboard' );
|
||||||
|
//wp_enqueue_style( 'tainacan-dashboard-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-dashboard.css', [], TAINACAN_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_dashboard_js() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_script( 'dashboard' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function dashboard_page() {
|
||||||
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
$this->admin_page();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -135,7 +135,7 @@ function tainacan_blocks_register_block($block_slug, $options = []) {
|
||||||
|
|
||||||
// Passes global variables to the blocks editor side
|
// Passes global variables to the blocks editor side
|
||||||
$block_settings = tainacan_blocks_get_plugin_js_settings();
|
$block_settings = tainacan_blocks_get_plugin_js_settings();
|
||||||
$plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();
|
$plugin_settings = \Tainacan\Views::get_instance()->get_admin_js_localization_params();
|
||||||
wp_localize_script( $block_slug, 'tainacan_blocks', $block_settings);
|
wp_localize_script( $block_slug, 'tainacan_blocks', $block_settings);
|
||||||
wp_localize_script( $block_slug, 'tainacan_plugin', $plugin_settings);
|
wp_localize_script( $block_slug, 'tainacan_plugin', $plugin_settings);
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ function tainacan_blocks_add_common_theme_scripts() {
|
||||||
wp_set_script_translations( 'tainacan-blocks-common-scripts', 'tainacan' );
|
wp_set_script_translations( 'tainacan-blocks-common-scripts', 'tainacan' );
|
||||||
|
|
||||||
$block_settings = tainacan_blocks_get_plugin_js_settings();
|
$block_settings = tainacan_blocks_get_plugin_js_settings();
|
||||||
$plugin_settings = \Tainacan\Admin::get_instance()->get_admin_js_localization_params();
|
$plugin_settings = \Tainacan\Views::get_instance()->get_admin_js_localization_params();
|
||||||
|
|
||||||
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_blocks', $block_settings);
|
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_blocks', $block_settings);
|
||||||
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_plugin', $plugin_settings);
|
wp_localize_script( 'tainacan-blocks-common-scripts', 'tainacan_plugin', $plugin_settings);
|
||||||
|
|
|
@ -4,13 +4,25 @@ namespace Tainacan;
|
||||||
|
|
||||||
class Item_Submission {
|
class Item_Submission {
|
||||||
|
|
||||||
public function __construct()
|
private $other_links_slug = 'tainacan_other_links';
|
||||||
{
|
|
||||||
$this->page_init();
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
add_action( 'admin_init', array( &$this, 'settings_init' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function page_init()
|
public function add_admin_menu() {
|
||||||
{
|
add_submenu_page(
|
||||||
|
$this->other_links_slug,
|
||||||
|
__('Item Submission', 'tainacan'),
|
||||||
|
__('Item Submission', 'tainacan'),
|
||||||
|
'manage_options',
|
||||||
|
'tainacan_item_submission',
|
||||||
|
array( &$this, 'item_submission_page' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function settings_init() {
|
||||||
add_settings_section(
|
add_settings_section(
|
||||||
'tainacan_item_submission_recaptcha_id', // ID
|
'tainacan_item_submission_recaptcha_id', // ID
|
||||||
'reCaptcha', // Title
|
'reCaptcha', // Title
|
||||||
|
@ -33,31 +45,44 @@ class Item_Submission {
|
||||||
'tainacan_item_submission', // Page
|
'tainacan_item_submission', // Page
|
||||||
'tainacan_item_submission_recaptcha_id' // Section
|
'tainacan_item_submission_recaptcha_id' // Section
|
||||||
);
|
);
|
||||||
|
|
||||||
|
register_setting(
|
||||||
|
'tainacan_item_submission_recaptcha',
|
||||||
|
'tnc_option_recaptch_site_key',
|
||||||
|
'sanitize_text_field'
|
||||||
|
);
|
||||||
|
|
||||||
|
register_setting(
|
||||||
|
'tainacan_item_submission_recaptcha',
|
||||||
|
'tnc_option_recaptch_secret_key',
|
||||||
|
'sanitize_text_field'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function print_section_info()
|
public function print_section_info() {
|
||||||
{
|
|
||||||
print _e('Enter your site settings below:', 'tainacan');
|
print _e('Enter your site settings below:', 'tainacan');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tnc_option_recaptch_site_key()
|
public function tnc_option_recaptch_site_key() {
|
||||||
{
|
|
||||||
printf(
|
printf(
|
||||||
'<input type="text" id="tnc_option_recaptch_site_key" name="tnc_option_recaptch_site_key" value="%s" />',
|
'<input type="text" id="tnc_option_recaptch_site_key" name="tnc_option_recaptch_site_key" value="%s" />',
|
||||||
esc_attr( get_option('tnc_option_recaptch_site_key') )
|
esc_attr( get_option('tnc_option_recaptch_site_key') )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tnc_option_recaptch_secret_key()
|
public function tnc_option_recaptch_secret_key() {
|
||||||
{
|
|
||||||
printf(
|
printf(
|
||||||
'<input type="text" id="tnc_option_recaptch_secret_key" name="tnc_option_recaptch_secret_key" value="%s" />',
|
'<input type="text" id="tnc_option_recaptch_secret_key" name="tnc_option_recaptch_secret_key" value="%s" />',
|
||||||
esc_attr( get_option('tnc_option_recaptch_secret_key') )
|
esc_attr( get_option('tnc_option_recaptch_secret_key') )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function admin_page()
|
public function item_submission_page() {
|
||||||
{
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
$this->admin_page();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function admin_page() {
|
||||||
include('admin-page.php');
|
include('admin-page.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,37 @@ namespace Tainacan;
|
||||||
|
|
||||||
class Mobile_App {
|
class Mobile_App {
|
||||||
|
|
||||||
public function __construct(){}
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
}
|
||||||
|
|
||||||
public function admin_page()
|
public function add_admin_menu() {
|
||||||
{
|
$mobile_app_page_suffix = add_submenu_page(
|
||||||
|
'tainacan-no-show-menu', // Mobile app page is not listed in the menu
|
||||||
|
__('Mobile App', 'tainacan'),
|
||||||
|
__('Mobile App', 'tainacan'),
|
||||||
|
'manage_tainacan',
|
||||||
|
'tainacan_mobile_app',
|
||||||
|
array( &$this, 'mobile_app_page' )
|
||||||
|
);
|
||||||
|
add_action( 'load-' . $mobile_app_page_suffix, array( &$this, 'load_mobile_app_page' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_mobile_app_page() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_mobile_app_css' ), 90 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_mobile_app_css() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_style( 'tainacan-mobile-app-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-mobile-app.css', [], TAINACAN_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mobile_app_page() {
|
||||||
|
$this->admin_page();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function admin_page() {
|
||||||
include('admin-page.php');
|
include('admin-page.php');
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tainacan;
|
||||||
|
|
||||||
|
class Reports {
|
||||||
|
|
||||||
|
private $other_links_slug = 'tainacan_other_links';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_admin_menu() {
|
||||||
|
$reports_page_suffix = add_submenu_page(
|
||||||
|
$this->other_links_slug,
|
||||||
|
__('Reports', 'tainacan'),
|
||||||
|
__('Reports', 'tainacan'),
|
||||||
|
'manage_tainacan',
|
||||||
|
'tainacan_reports',
|
||||||
|
array( &$this, 'reports_page' )
|
||||||
|
);
|
||||||
|
add_action( 'load-' . $reports_page_suffix, array( &$this, 'load_reports_page' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_reports_page() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_reports_css' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_reports_js' ), 90 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_reports_css() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
wp_enqueue_style( 'tainacan-fonts', $TAINACAN_BASE_URL . '/assets/css/tainacanicons.css', [], TAINACAN_VERSION );
|
||||||
|
wp_enqueue_style( 'tainacan-reports-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-reports.css', [], TAINACAN_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_reports_js() {
|
||||||
|
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_script(
|
||||||
|
'tainacan-pages-common-scripts',
|
||||||
|
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
||||||
|
['underscore', 'wp-i18n'],
|
||||||
|
TAINACAN_VERSION
|
||||||
|
);
|
||||||
|
wp_set_script_translations('tainacan-pages-common-scripts', 'tainacan');
|
||||||
|
|
||||||
|
$settings = \Tainacan\Views::get_instance()->get_admin_js_localization_params();
|
||||||
|
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
||||||
|
wp_enqueue_script('underscore');
|
||||||
|
wp_enqueue_script('wp-i18n');
|
||||||
|
|
||||||
|
do_action('tainacan-enqueue-reports-scripts');
|
||||||
|
}
|
||||||
|
|
||||||
|
function reports_page() {
|
||||||
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
echo "<div id='tainacan-reports-app' data-module='reports'></div>";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tainacan;
|
||||||
|
|
||||||
|
class Roles_Editor {
|
||||||
|
|
||||||
|
private $other_links_slug = 'tainacan_other_links';
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_admin_menu() {
|
||||||
|
$roles_page_suffix = add_submenu_page(
|
||||||
|
$this->other_links_slug,
|
||||||
|
__('User Roles', 'tainacan'),
|
||||||
|
__('User Roles', 'tainacan'),
|
||||||
|
'tnc_rep_edit_users',
|
||||||
|
'tainacan_roles',
|
||||||
|
array( &$this, 'roles_page' )
|
||||||
|
);
|
||||||
|
add_action( 'load-' . $roles_page_suffix, array( &$this, 'load_roles_page' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
function load_roles_page() {
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_roles_css' ), 90 );
|
||||||
|
add_action( 'admin_enqueue_scripts', array( &$this, 'add_roles_js' ), 90 );
|
||||||
|
}
|
||||||
|
|
||||||
|
function add_roles_css() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_style( 'tainacan-roles-page', $TAINACAN_BASE_URL . '/assets/css/tainacan-roles.css', [], TAINACAN_VERSION );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function add_roles_js() {
|
||||||
|
global $TAINACAN_BASE_URL;
|
||||||
|
|
||||||
|
wp_enqueue_script(
|
||||||
|
'tainacan-pages-common-scripts',
|
||||||
|
$TAINACAN_BASE_URL . '/assets/js/tainacan_pages_common_scripts.js',
|
||||||
|
['underscore', 'wp-i18n'],
|
||||||
|
TAINACAN_VERSION
|
||||||
|
);
|
||||||
|
wp_set_script_translations('tainacan-pages-common-scripts', 'tainacan');
|
||||||
|
|
||||||
|
$settings = \Tainacan\Views::get_instance()->get_admin_js_localization_params();
|
||||||
|
wp_localize_script( 'tainacan-pages-common-scripts', 'tainacan_plugin', $settings );
|
||||||
|
wp_enqueue_script('underscore');
|
||||||
|
wp_enqueue_script('wp-i18n');
|
||||||
|
|
||||||
|
do_action('tainacan-enqueue-roles-scripts');
|
||||||
|
}
|
||||||
|
|
||||||
|
function roles_page() {
|
||||||
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
echo "<div id='tainacan-roles-app' data-module='roles'></div>";
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,7 @@ namespace Tainacan;
|
||||||
|
|
||||||
class System_Check {
|
class System_Check {
|
||||||
|
|
||||||
|
private $other_links_slug = 'tainacan_other_links';
|
||||||
private $min_php_version = '7.0';
|
private $min_php_version = '7.0';
|
||||||
|
|
||||||
private $mysql_min_version_check;
|
private $mysql_min_version_check;
|
||||||
|
@ -15,17 +16,30 @@ class System_Check {
|
||||||
private $health_check_mysql_min_version = '5.0';
|
private $health_check_mysql_min_version = '5.0';
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->init();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function init() {
|
|
||||||
$this->prepare_sql_data();
|
$this->prepare_sql_data();
|
||||||
|
add_action( 'admin_menu', array( &$this, 'add_admin_menu' ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function admin_page() {
|
public function admin_page() {
|
||||||
include('admin-page.php');
|
include('admin-page.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function add_admin_menu() {
|
||||||
|
add_submenu_page(
|
||||||
|
$this->other_links_slug,
|
||||||
|
__('System check', 'tainacan'),
|
||||||
|
__('System check', 'tainacan'),
|
||||||
|
'manage_options',
|
||||||
|
'tainacan_systemcheck',
|
||||||
|
array( &$this, 'systemcheck_page' )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function systemcheck_page() {
|
||||||
|
\Tainacan\Views::get_instance()->the_admin_navigation_menu();
|
||||||
|
$this->admin_page();
|
||||||
|
}
|
||||||
|
|
||||||
public function test_php_version() {
|
public function test_php_version() {
|
||||||
$testphpmin = version_compare( $this->min_php_version, PHP_VERSION, '<=' );
|
$testphpmin = version_compare( $this->min_php_version, PHP_VERSION, '<=' );
|
||||||
$testphprec = version_compare( '7.4', PHP_VERSION, '<=' );
|
$testphprec = version_compare( '7.4', PHP_VERSION, '<=' );
|
||||||
|
|
Loading…
Reference in New Issue