Skip to content

Instantly share code, notes, and snippets.

@Fanckler
Last active February 8, 2018 21:23
Show Gist options
  • Save Fanckler/e8dd156f58bde7e4762338e60b9d41d1 to your computer and use it in GitHub Desktop.
Save Fanckler/e8dd156f58bde7e4762338e60b9d41d1 to your computer and use it in GitHub Desktop.
Wordpress customizer editor
<?php
//support
add_theme_support( 'post-thumbnails' );
function invio_scripts() {
wp_enqueue_style('style-css', get_stylesheet_uri() );
wp_enqueue_style('style-ft', get_stylesheet_directory_uri().'/libs/font-awesome-4.7.0/css/font-awesome.css' );
wp_enqueue_style('style-main', get_stylesheet_directory_uri().'/css/style.css');
wp_enqueue_style('style-media', get_stylesheet_directory_uri().'/css/media.css' );
wp_enqueue_style('style-libs', get_stylesheet_directory_uri().'/css/libs.min.css');
wp_deregister_script( 'jquery' );
wp_enqueue_script( 'scripts-jq', get_template_directory_uri() . '/js/jquery-1.11.1.min.js',false, null, true );
wp_enqueue_script( 'scripts-twmax', get_template_directory_uri() . '/libs/gsap/TweenMax.min.js',false, null, true );
wp_enqueue_script( 'scripts-part', get_template_directory_uri() . '/libs/particlesImage/nextparticle.min.js',false, null, true );
wp_enqueue_script( 'scripts-slick', get_template_directory_uri() . '/libs/slick/slick.js', false, null, true );
wp_enqueue_script( 'scripts-dragg', get_template_directory_uri() . '/libs/gsap/utils/Draggable.min.js', false, null, true );
wp_enqueue_script( 'scripts-main', get_template_directory_uri() . '/js/main.js', false, null, true );
}
add_action( 'wp_enqueue_scripts', 'invio_scripts' );
//register menu
add_action('after_setup_theme', function(){
register_nav_menus( array(
'header_menu' => 'Меню в шапке',
'footer_menu' => 'Меню в подвале'
) );
});
//add panel in wp-admin team
add_action('init', 'team');
function team(){
register_post_type( 'team', array(
'public' => true,
'supports' => array('title','thumbnail','excerpt'),
'labels' => array(
'name' => 'Наша команда',
'all_items' => 'Все люди',
'add_new' => 'Добавить человека',
'featured_image' => 'Фотография учасника',
'set_featured_image' => 'Выбрать фотографию',
'add_new_item' => 'Добавить учасника',
'edit_item' => 'Введите имя',
),
'menu_icon' => 'dashicons-businessman'
));
}
//add panel in wp-admin portfolio
add_action('init', 'portfolio');
function portfolio(){
register_post_type( 'portfolio', array(
'public' => true,
'supports' => array('title','thumbnail','excerpt'),
'labels' => array(
'name' => 'Наши работы',
'all_items' => 'Все работы',
'add_new' => 'Добавить работу',
'featured_image' => 'Скриншот работ',
'set_featured_image' => 'Выбрать фотографию',
'add_new_item' => 'Добавить в портфолио',
'edit_item' => 'Введите название',
),
'menu_icon' => 'dashicons-portfolio'
));
}
if ( ! class_exists( 'WP_Customize_Control' ) )
return NULL;
/**
* Class to create a custom tags control
*/
class Text_Editor_Custom_Control extends WP_Customize_Control
{
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
?>
<label>
<span class="customize-text_editor"><?php echo esc_html( $this->label ); ?></span>
<input class="wp-editor-area" type="hidden" <?php $this->link(); ?> value="<?php echo esc_textarea( $this->value() ); ?>">
<?php
$settings = array(
'textarea_name' => $this->id,
'media_buttons' => false,
'drag_drop_upload' => false,
'teeny' => true,
'quicktags' => false,
'textarea_rows' => 5,
);
$this->filter_editor_setting_link();
wp_editor($this->value(), $this->id, $settings );
?>
</label>
<?php
do_action('admin_footer');
do_action('admin_print_footer_scripts');
}
private function filter_editor_setting_link() {
add_filter( 'the_editor', function( $output ) { return preg_replace( '/<textarea/', '<textarea ' . $this->get_link(), $output, 1 ); } );
}
}
if ( ! class_exists( 'WP_Customize_Control' ) )
return NULL;
/**
* Class to create a custom tags control
*/
class Text_Editor_Custom_Control1 extends WP_Customize_Control
{
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
?>
<label>
<span class="customize-text_editor"><?php echo esc_html( $this->label ); ?></span>
<?php
$settings = array(
'textarea_name' => $this->id
);
wp_editor($this->value(), $this->id, $settings );
?>
</label>
<?php
}
}
require 'init/customizer-api.php';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment