| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Admin Sticky Sidebar |
| 4 |
Description: Makes the sidebar follow you when you scroll and remembers scroll position on update. For more info, see the readme. |
| 5 |
Version: 1.8 |
| 6 |
Author: Tom Walter |
| 7 |
Author URI: https://littlefragments.com |
| 8 |
License: GPLv2 |
| 9 |
*/ |
| 10 |
|
| 11 |
// only load assets on classic post editor screens ---------------------------- |
| 12 |
function admin_sticky_sidebar_should_enqueue($hook) |
| 13 |
{ |
| 14 |
if ($hook !== 'post.php' && $hook !== 'post-new.php') return false; |
| 15 |
|
| 16 |
if (!function_exists('get_current_screen')) return true; |
| 17 |
|
| 18 |
$screen = get_current_screen(); |
| 19 |
if ($screen && method_exists($screen, 'is_block_editor') && $screen->is_block_editor()) { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
return true; |
| 24 |
} |
| 25 |
|
| 26 |
// add css to the admin -------------------------------------------------------- |
| 27 |
function admin_sticky_sidebar_css($hook) |
| 28 |
{ |
| 29 |
if (!admin_sticky_sidebar_should_enqueue($hook)) return; |
| 30 |
|
| 31 |
wp_enqueue_style('admin-sticky-sidebar-style', plugins_url('admin-sticky-sidebar.css', __FILE__), array(), '1.8'); |
| 32 |
} |
| 33 |
add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_css'); |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
// add js to the admin --------------------------------------------------------- |
| 38 |
function admin_sticky_sidebar_js($hook) |
| 39 |
{ |
| 40 |
if (!admin_sticky_sidebar_should_enqueue($hook)) return; |
| 41 |
|
| 42 |
wp_enqueue_script('admin-sticky-sidebar-script', plugins_url('admin-sticky-sidebar.js', __FILE__), array(), '1.8'); |
| 43 |
} |
| 44 |
add_action('admin_enqueue_scripts', 'admin_sticky_sidebar_js'); |
| 45 |
|