| Server IP : 37.27.51.148 / Your IP : 37.27.51.148 Web Server : nginx/1.14.1 System : Linux libra 4.18.0-553.51.1.el8_10.x86_64 #1 SMP Wed Apr 30 20:24:04 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.31 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/plugins/luckywp-table-of-contents/plugin/mcePlugin/ |
Upload File : |
<?php
namespace luckywp\tableOfContents\plugin\mcePlugin;
use luckywp\tableOfContents\core\base\BaseObject;
use luckywp\tableOfContents\core\Core;
class McePlugin extends BaseObject
{
public function init()
{
parent::init();
add_action('admin_init', [$this, 'adminInit'], 20);
}
public function adminInit()
{
if (current_user_can('edit_posts') || current_user_can('edit_pages')) {
add_filter('mce_css', [$this, 'mceCss']);
add_action('enqueue_block_editor_assets', [$this, 'editorCss']);
add_filter('mce_external_plugins', [$this, 'plugin']);
add_filter('mce_buttons', [$this, 'button']);
}
}
/**
* @param string $css
* @return string
*/
public function mceCss($css)
{
if (!empty($css)) {
$css .= ',';
}
$css .= $this->getUrl() . '/mce.min.css';
return $css;
}
/**
* CSS для Gutenberg
*/
public function editorCss()
{
wp_enqueue_style('lwptoc-editor-css', Core::$plugin->mcePlugin->getUrl() . '/mce.min.css');
}
/**
* @param array $plugins
* @return array
*/
public function plugin($plugins)
{
$plugins['lwptoc'] = $this->getUrl() . '/plugin.min.js';
return $plugins;
}
/**
* @param array $buttons
* @return array
*/
public function button($buttons)
{
array_push($buttons, 'lwptocButton');
return $buttons;
}
/**
* @return string
*/
protected function getUrl()
{
return Core::$plugin->url . '/plugin/mcePlugin';
}
}