{"id":2818,"date":"2026-04-22T23:52:04","date_gmt":"2026-04-22T20:52:04","guid":{"rendered":"https:\/\/www.pexlechris.dev\/library-viewer\/?page_id=2818"},"modified":"2026-05-27T23:15:19","modified_gmt":"2026-05-27T20:15:19","slug":"admin_page","status":"publish","type":"page","link":"https:\/\/www.pexlechris.dev\/library-viewer\/docs\/admin_page\/","title":{"rendered":"Library Viewer Admin Page"},"content":{"rendered":"\n<style data-wp-block-html=\"css\">\n.su-image-carousel-controls-style-dark button.flickity-prev-next-button{\n   opacity: 1 !important;\n}\n\nh2 strong{\n   font-weight: 800;\n}\n\n#zak-secondary > section{\n\tposition: sticky;\n\ttop: 50px;\n\talign-self: flex-start;\n}\n<\/style>\n\n\n\t<style>\r\n\t\t#toggle_sidebar{\r\n\t\t\tdisplay: block !important; \r\n\t\t\tcursor: pointer;\r\n\t\t}\r\n\t\t#toggle_sidebar:hover{\r\n\t\t\tcolor: #ab46f8;\r\n\t\t}\r\n\t\t\t  \r\n\t\t#primary.for_toggle_no_padding{\r\n\t\t\tpadding: 0 !important;\r\n\t\t}\r\n\t<\/style>\r\n\t\t\t  \r\n\t<script>\r\n\t\tfunction toggle_sidebar(){\r\n\t\t\tlet t = document.getElementById(\"toggle_sidebar\");\r\n\t\t\tlet s = document.getElementById(\"zak-secondary\");\r\n\t\t\tlet p = document.getElementById(\"zak-primary\");\r\n\t\t\tif( s.style.display == \"none\" ){\r\n\t\t\t\ts.style.display = \"block\";\r\n\t\t\t\tt.innerText = \"Close sidebar\";\r\n\t\t\t\tp.style.width = \"70%\";\r\n\t\t\t\tp.classList.remove(\"for_toggle_no_padding\");\r\n\t\t\t}else{\r\n\t\t\t\ts.style.display = \"none\";\r\n\t\t\t\tt.innerText = \"Open sidebar\";\r\n\t\t\t\tp.style.width = \"100%\";\r\n\t\t\t\tp.classList.add(\"for_toggle_no_padding\");\r\n\t\t\t}\r\n\t\t} \r\n\t<\/script>\r\n\t\t\t  \r\n\t\n\n\n\n<div id=\"what_is\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; <strong>What is<\/strong> a <em>Library Viewer admin page<\/em><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A <em>Library Viewer admin page<\/em> is a registered WordPress admin menu page that allows you to <strong>display a library with folders and files in the backend<\/strong>, just like in the frontend.<br>You can register as many <em>Library Viewer admin pages<\/em> as you want. Examples are shown below.<br>By default, the plugin registers a <em>Library Viewer admin page<\/em> under the Media menu and the <strong>Settings tab<\/strong> of this page can only be accessed by users with the <code>manage_options<\/code> capability.<\/p>\n\n\n<div class=\"su-image-carousel  su-image-carousel-has-spacing su-image-carousel-has-lightbox su-image-carousel-has-outline su-image-carousel-adaptive su-image-carousel-slides-style-default su-image-carousel-controls-style-dark su-image-carousel-align-none\" style=\"\" data-flickity-options='{\"groupCells\":true,\"cellSelector\":\".su-image-carousel-item\",\"adaptiveHeight\":true,\"cellAlign\":\"left\",\"prevNextButtons\":true,\"pageDots\":false,\"autoPlay\":false,\"imagesLoaded\":true,\"contain\":false,\"selectedAttraction\":0.025,\"friction\":0.28}' id=\"su_image_carousel_6a93956558c7b\"><div class=\"su-image-carousel-item\"><div class=\"su-image-carousel-item-content\"><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings.jpg\" target=\"_blank\" rel=\"noopener noreferrer\" data-caption=\"1) The settings of the default Library Viewer admin page\"><img fetchpriority=\"high\" decoding=\"async\" width=\"812\" height=\"565\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings-1024x713.jpg\" class=\"\" alt=\"\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings-1024x713.jpg 1024w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings-300x209.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings-768x534.jpg 768w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings-600x417.jpg 600w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-settings.jpg 1121w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><span>1) The settings of the default Library Viewer admin page<\/span><\/a><\/div><\/div><div class=\"su-image-carousel-item\"><div class=\"su-image-carousel-item-content\"><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display.jpg\" target=\"_blank\" rel=\"noopener noreferrer\" data-caption=\"2) The displayed library\"><img decoding=\"async\" width=\"812\" height=\"565\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display-1024x712.jpg\" class=\"\" alt=\"\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display-1024x712.jpg 1024w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display-300x208.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display-768x534.jpg 768w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display-600x417.jpg 600w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-display.jpg 1121w\" sizes=\"(max-width: 812px) 100vw, 812px\" \/><span>2) The displayed library<\/span><\/a><\/div><\/div><\/div><script id=\"su_image_carousel_6a93956558c7b_script\">if(window.SUImageCarousel){setTimeout(function() {window.SUImageCarousel.initGallery(document.getElementById(\"su_image_carousel_6a93956558c7b\"))}, 0);}var su_image_carousel_6a93956558c7b_script=document.getElementById(\"su_image_carousel_6a93956558c7b_script\");if(su_image_carousel_6a93956558c7b_script){su_image_carousel_6a93956558c7b_script.parentNode.removeChild(su_image_carousel_6a93956558c7b_script);}<\/script>\n\n\n\n<div style=\"height:70px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n\n\n\n<div id=\"setup\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; <strong>Setup<\/strong> default <em>Library Viewer admin page<\/em> settings<\/h2>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"733\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings-1024x733.jpg\" alt=\"\" class=\"wp-image-2937\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings-1024x733.jpg 1024w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings-300x215.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings-768x550.jpg 768w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings-600x429.jpg 600w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/default-library-viewer-admin-page-settings.jpg 1122w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol style=\"padding-right:0px;padding-left:20px\" class=\"wp-block-list\">\n<li><strong>Page Title<\/strong>: The page and menu title of the <em>Library Viewer admin page<\/em>. If you leave it empty default title is: <em>Library Viewer<\/em>.<\/li>\n\n\n\n<li><strong>Who can access the library tab<\/strong>: The library tab is accessible to users whose role or capability matches the values defined in the \u201cWho can access the library tab\u201d setting.<br>In this field you can enter comma-separated roles and\/or capabilities.<\/li>\n\n\n\n<li><strong>Library to display (Paste shortcode here)<\/strong>: Here you can write or paste the shortcode that will be executed and displayed in the Library tab. For shortcode parameter documentation, see the link below.<\/li>\n<\/ol>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:20px\"><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/docs\/parameters\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc: Shortcode parameters<\/a><\/p>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"change_manage_caps\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; How to change <strong>manage capability<\/strong> of default <em>Library Viewer admin page<\/em><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By default, the <strong>settings page<\/strong> of <em>Library Viewer admin page<\/em> can only be accessed by users with the manage_options capability, which is granted to administrators by default.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can filter this capability using the <code>lv_default_admin_page_manage_caps<\/code> hook. You can pass either capabilities or user roles as an array.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example below:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('lv_default_admin_page_manage_caps', function ($caps) {\n\treturn &#091;'shop_manager', 'manage_options'];\n});<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/docs\/hooks\/?library-viewer=yes#lv_after_file\" target=\"_blank\" rel=\"noreferrer noopener\">Doc1: <\/a><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/docs\/hooks\/?library-viewer=yes#lv_default_admin_page_manage_caps\" target=\"_blank\" rel=\"noreferrer noopener\">lv_default_admin_page_manage_caps <\/a><a href=\"https:\/\/www.pexlechris.dev\/library-viewer\/docs\/hooks\/?library-viewer=yes#lv_after_file\" target=\"_blank\" rel=\"noreferrer noopener\">filter Doc<br><\/a><a href=\"https:\/\/www.pexlechris.dev\/how-to-add-php-hooks-in-your-wordpress-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc2: How to add PHP Hooks in your WordPress Site<\/a><\/p>\n<\/div>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"remove\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; How to <strong>remove<\/strong> default <em>Library Viewer admin page<\/em><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can remove the current instance of <em>Library Viewer admin page<\/em> using the following hook:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action('init', function () {\n  remove_action('init', &#091;'Library_Viewer_Init', 'register_library_viewer_media_page'], 5);\n}, 2);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pexlechris.dev\/how-to-add-php-hooks-in-your-wordpress-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc: How to add PHP Hooks in your WordPress Site<\/a><\/p>\n<\/div>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"register_under_wp_core_page\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; How to <strong>register<\/strong> a new <em>Library Viewer admin page<\/em> under an existing WP core page<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to add a new <em>Library Viewer admin page<\/em> under an existing WP core page such as Tools Page (tools.php), you can use the following hook:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ EXAMPLE 1: Library Viewer under a core WordPress admin menu\n\/\/ Example here: Tools core page (tools.php)\n\/\/ IMPORTANT: Initialize the Library_Viewer_Admin_Page instance on the init hook with priority 2-5.\n\nadd_action('init', function () {\n\n  new Library_Viewer_Admin_Page(\n\t'tools.php', \/\/ parent_menu_slug (pass exstant top-level page)\n\t'new-tools-library', \/\/ menu_slug\n\t__('Library Viewer', 'library-viewer'), \/\/ title\n\t&#091;'administrator', 'editor', 'manage_options'] \/\/ manage_caps\n  );\n\n}, 2);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pexlechris.dev\/how-to-add-php-hooks-in-your-wordpress-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc: How to add PHP Hooks in your WordPress Site<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"865\" height=\"657\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-core-page.jpg\" alt=\"\" class=\"wp-image-2955\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-core-page.jpg 865w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-core-page-300x228.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-core-page-768x583.jpg 768w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-core-page-600x456.jpg 600w\" sizes=\"(max-width: 865px) 100vw, 865px\" \/><\/figure>\n<\/div>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"register_top_level_menu_item\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; How to <strong>register<\/strong> a new <em>Library Viewer admin page<\/em> as top-level menu item<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To add a top-level menu item in the WordPress admin dashboard and attach a <em>Library Viewer admin page<\/em> to it, use the following hook:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ EXAMPLE 2: Library Viewer as top-level menu item\n\/\/ Example here: New top-level page (admin.php?page=my-libraries)\n\/\/ IMPORTANT: Initialize the Library_Viewer_Admin_Page instance on the init hook with priority 2-5.\n\nadd_action('init', function () {\n\n  \/\/ Create top-level menu if it does not already exist\n  add_menu_page(\n\t__('My Libraries', 'your-textdomain'), \/\/ page title\n\t__('My Libraries', 'your-textdomain'), \/\/ menu title\n\t'manage_options', \/\/ capability\n\t'my-libraries', \/\/ menu slug\n\t'__return_empty_string', \/\/ callback\n\t'dashicons-book',\n\t30\n  );\n\n\n  \/\/ Example: Library Viewer Admin Page under custom top-level menu\n  new Library_Viewer_Admin_Page(\n\t'admin.php?page=my-libraries', \/\/ parent menu slug (used when attaching to a top-level page)\n\t'my-libraries', \/\/ menu_slug\n\tnull, \/\/ title, null: takes default value\n\t&#091;'administrator', 'editor', 'manage_options'] \/\/ manage_caps\n  );\n\n}, 2);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pexlechris.dev\/how-to-add-php-hooks-in-your-wordpress-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc: How to add PHP Hooks in your WordPress Site<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" width=\"696\" height=\"370\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-a-top-level-menu-item.jpg\" alt=\"\" class=\"wp-image-2952\" style=\"aspect-ratio:1.6838141855320752;width:592px;height:auto\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-a-top-level-menu-item.jpg 696w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-a-top-level-menu-item-300x159.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-a-top-level-menu-item-600x319.jpg 600w\" sizes=\"(max-width: 696px) 100vw, 696px\" \/><\/figure>\n<\/div>\n\n\n\n<div style=\"height:80px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"register_under_custom_top_level_menu_item\" class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\">&gt; How to <strong>register<\/strong> a new <em>Library Viewer admin page<\/em> under a custom top-level menu item<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want to add a new <em>Library Viewer admin page<\/em> under an already registered admin page, you can use the following hook:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ EXAMPLE 3: Library Viewer under a custom top-level menu item\n\/\/ Example here: admin.php?page=my-libraries page top-level menu item, registered previously\n\/\/ IMPORTANT: Initialize the Library_Viewer_Admin_Page instance on the init hook with priority 2-5.\n\nadd_action('init', function () {\n\n  \/\/ Example: Second page under same top-level menu 'my-libraries'\n  new Library_Viewer_Admin_Page(\n\t'my-libraries', \/\/ parent_menu_slug (pass only the 'page' GET parameter)\n\t'my-library2', \/\/ menu_slug\n\t__('Library Viewer', 'library-viewer'), \/\/ title\n\t&#091;'administrator', 'editor', 'manage_options'] \/\/ manage_caps\n  );\n\t\n}, 2);<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/www.pexlechris.dev\/how-to-add-php-hooks-in-your-wordpress-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">Doc: How to add PHP Hooks in your WordPress Site<\/a><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"710\" height=\"439\" src=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-top-level-menu-item.jpg\" alt=\"\" class=\"wp-image-2954\" srcset=\"https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-top-level-menu-item.jpg 710w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-top-level-menu-item-300x185.jpg 300w, https:\/\/www.pexlechris.dev\/library-viewer\/wp-content\/uploads\/library-viewer-admin-page-under-top-level-menu-item-600x371.jpg 600w\" sizes=\"(max-width: 710px) 100vw, 710px\" \/><\/figure>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>&gt; What is a Library Viewer admin page A Library Viewer admin page is a registered WordPress admin menu page that allows you to display a library with folders and files in the backend, just like in the frontend.You can register as many Library Viewer admin pages as you want. Examples are shown below.By default, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1254,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"footnotes":""},"class_list":["post-2818","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/pages\/2818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/comments?post=2818"}],"version-history":[{"count":64,"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/pages\/2818\/revisions"}],"predecessor-version":[{"id":2957,"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/pages\/2818\/revisions\/2957"}],"up":[{"embeddable":true,"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/pages\/1254"}],"wp:attachment":[{"href":"https:\/\/www.pexlechris.dev\/library-viewer\/wp-json\/wp\/v2\/media?parent=2818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}