Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="big_content_item">CONTENT</div>
- <div class="wide_content_item">CONTENT</div>
- <div class="content_item">CONTENT</div>
- [big_content] или [wide_content] или [content]
- add_filter('the_content', 'filter_content');
- function filter_content( $content ){
- modify_content($content, '[big_content]', '<div class="big_content_item"';
- modify_content($content, '[wide_content]', '<div class="wide_content_item"');
- modify_content($content, '[content]', '<div class="content_item"');
- return $content;
- }
- function modify_content($content, $code, $wrap) {
- if (substr($content, $code) {
- $content = str_replace($code, '');
- return $wrap . $content . '</div>';
- }
- }
- <?php
- /*
- Plugin Name: Вставка отзывов
- Plugin URI:
- Description: Создаёт блоки текста . Добавляет кнопку в редактор для вставки кода.
- Version: 1.0
- Author: SeVlad
- Author URI: http://sevladwp.wordpress.com/
- */
- //Добавление кнопки в редактор
- function true_add_mce_button() {
- // проверяем права пользователя - может ли он редактировать посты и страницы
- if ( !current_user_can( 'edit_posts' ) && !current_user_can( 'edit_pages' ) ) {
- return; // если не может, то и кнопка ему не понадобится, в этом случае выходим из функции
- }
- // проверяем, включен ли визуальный редактор у пользователя в настройках (если нет, то и кнопку подключать незачем)
- if ( 'true' == get_user_option( 'rich_editing' ) ) {
- add_filter( 'mce_external_plugins', 'true_add_tinymce_script' );
- add_filter( 'mce_buttons', 'true_register_mce_button' );
- }
- }
- add_action('admin_head', 'true_add_mce_button');
- // В этом функции указываем ссылку на JavaScript-файл кнопки
- function true_add_tinymce_script( $plugin_array ) {
- $plugin_array['ref_mce_button'] = plugin_dir_url( __FILE__ ).'refbuttons.js'; // ref_mce_button - идентификатор кнопки
- return $plugin_array;
- }
- // Регистрируем кнопку в редакторе
- function true_register_mce_button( $buttons ) {
- array_push( $buttons, 'ref_mce_button' ); // ref_mce_button - идентификатор кнопки
- return $buttons;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement