芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/code-snippets/php/front-end/class-front-end.php
WP_REST_Server::READABLE, 'callback' => [ $this, 'get_snippets_info' ], 'permission_callback' => function () { return current_user_can( 'edit_posts' ); }, ) ); } /** * Fetch snippets data in response to a request. * * @return WP_REST_Response */ public function get_snippets_info(): WP_REST_Response { $snippets = get_snippets(); $data = []; foreach ( $snippets as $snippet ) { $data[] = [ 'id' => $snippet->id, 'name' => $snippet->name, 'type' => $snippet->type, 'active' => $snippet->active, ]; } return new WP_REST_Response( $data, 200 ); } /** * Perform the necessary actions to add a button to the TinyMCE editor */ public function setup_mce_plugin() { if ( ! code_snippets()->current_user_can() ) { return; } /* Register the TinyMCE plugin */ add_filter( 'mce_external_plugins', function ( $plugins ) { $plugins['code_snippets'] = plugins_url( 'dist/mce.js', PLUGIN_FILE ); return $plugins; } ); /* Add the button to the editor toolbar */ add_filter( 'mce_buttons', function ( $buttons ) { $buttons[] = 'code_snippets'; return $buttons; } ); /* Add the translation strings to the TinyMCE editor */ add_filter( 'mce_external_languages', function ( $languages ) { $languages['code_snippets'] = __DIR__ . '/mce-strings.php'; return $languages; } ); } /** * Enqueue the syntax highlighting assets if they are required for the current posts * * @param array
|null|false $posts List of currently visible posts. * * @return array
|null|false Unchanged list of posts. */ public function enqueue_highlighting( $posts ) { // Exit early if there are no posts to check or if the highlighter has been disabled. if ( empty( $posts ) || Settings\get_setting( 'general', 'disable_prism' ) ) { return $posts; } // Loop through the posts, checking for an existing shortcode, short-circuiting if possible. $found_shortcode_content = null; foreach ( $posts as $post ) { if ( false !== stripos( $post->post_content, '[' . self::SOURCE_SHORTCODE ) || false !== strpos( $post->post_content, '