permalink-manager-actions.php
5 years ago
permalink-manager-admin-functions.php
5 years ago
permalink-manager-core-functions.php
5 years ago
permalink-manager-debug.php
5 years ago
permalink-manager-gutenberg.php
5 years ago
permalink-manager-helper-functions.php
5 years ago
permalink-manager-language-plugins.php
5 years ago
permalink-manager-third-parties.php
5 years ago
permalink-manager-uri-functions-post.php
5 years ago
permalink-manager-uri-functions.php
5 years ago
permalink-manager-gutenberg.php
47 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Additional hooks for "Permalink Manager Pro" |
| 5 | */ |
| 6 | class Permalink_Manager_Gutenberg extends Permalink_Manager_Class { |
| 7 | |
| 8 | public function __construct() { |
| 9 | add_action('enqueue_block_editor_assets', array($this, 'init')); |
| 10 | |
| 11 | // add_action('wp_ajax_pm_get_uri_editor', array($this, 'get_uri_editor')); |
| 12 | // add_action('wp_ajax_nopriv_pm_get_uri_editor', array($this, 'get_uri_editor')); |
| 13 | } |
| 14 | |
| 15 | public function init() { |
| 16 | global $current_screen; |
| 17 | |
| 18 | // Get displayed post type |
| 19 | if(empty($current_screen->post_type)) { return; } |
| 20 | $post_type = $current_screen->post_type; |
| 21 | |
| 22 | // Check if post type is disabled |
| 23 | if(Permalink_Manager_Helper_Functions::is_disabled($post_type, 'post_type')) { return; } |
| 24 | |
| 25 | // Stop the hook (if needed) |
| 26 | $show_uri_editor = apply_filters("permalink_manager_hide_uri_editor_post_{$post_type}", true); |
| 27 | if(!$show_uri_editor) { return; } |
| 28 | |
| 29 | add_meta_box('permalink-manager', __('Permalink Manager', 'permalink-manager'), array($this, 'get_uri_editor'), '', 'side', 'high' ); |
| 30 | // wp_enqueue_script('permalink-manager-gutenberg', PERMALINK_MANAGER_URL . '/out/permalink-manager-gutenberg.js', array('wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element')); |
| 31 | } |
| 32 | |
| 33 | public function get_uri_editor($post = null) { |
| 34 | if(empty($post->ID) && empty($_REQUEST['post_id'])) { |
| 35 | return ''; |
| 36 | } else if(!empty($_REQUEST['post_id'])) { |
| 37 | $post = get_post($_REQUEST['post_id']); |
| 38 | } |
| 39 | |
| 40 | // Display URI Editor |
| 41 | echo Permalink_Manager_Admin_Functions::display_uri_box($post, true); |
| 42 | } |
| 43 | |
| 44 | } |
| 45 | |
| 46 | ?> |
| 47 |