Guest User

Untitled

a guest
Dec 14th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.45 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Edutica functions and definitions
  4.  *
  5.  * @package Edutica
  6.  * @since Edutica 1.0
  7.  */
  8.  
  9. require_once dirname( __FILE__ ) . '/lib/framework/framework-init.php';
  10. require_once dirname( __FILE__ ) . '/custom-post-type.php';
  11.  
  12. /**
  13.  * Set the content width based on the theme's design and stylesheet.
  14.  *
  15.  * @since Edutica 1.0
  16.  */
  17. if ( ! isset( $content_width ) )
  18.     $content_width = 640; /* pixels */
  19.  
  20. class WeDevs_Bootstrap {
  21.    
  22.     function __construct() {
  23.         add_action( 'after_setup_theme', array( $this, 'setup_theme' ), 14 );
  24.         add_action( 'widgets_init', array( $this, 'widgets_init' ) );
  25.         add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
  26.     }
  27.    
  28.     /**
  29.      * Sets up theme defaults and registers support for various WordPress features.
  30.      *
  31.      * Note that this function is hooked into the after_setup_theme hook, which runs
  32.      * before the init hook. The init hook is too late for some features, such as indicating
  33.      * support post thumbnails.
  34.      *
  35.      * @since Edutica 1.0
  36.      */
  37.     function setup_theme() {
  38.  
  39.         /**
  40.          * Make theme available for translation
  41.          * Translations can be filed in the /languages/ directory
  42.          * If you're building a theme based on Edutica, use a find and replace
  43.          * to change 'edutica' to the name of your theme in all the template files
  44.          */
  45.         load_theme_textdomain( 'edutica', get_template_directory() . '/languages' );
  46.  
  47.         add_theme_support( 'slider' );
  48.         add_theme_support( 'custom-sidebar' );
  49.         add_theme_support( 'post-template' );
  50.  
  51.         /**
  52.          * This theme uses wp_nav_menu() in one location.
  53.          */
  54.         register_nav_menus( array(
  55.             'primary' => __( 'Primary Menu', 'edutica' ),
  56.         ) );
  57.  
  58.         /**
  59.          * Add support for the Aside Post Formats
  60.          */
  61.         add_theme_support( 'post-formats', array( 'aside', ) );
  62.     }
  63.    
  64.     /**
  65.      * Register widgetized area and update sidebar with default widgets
  66.      *
  67.      * @since Edutica 1.0
  68.      */
  69.     function widgets_init() {
  70.         register_sidebar( array(
  71.             'name' => __( 'Sidebar', 'edutica' ),
  72.             'id' => 'sidebar-1',
  73.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  74.             'after_widget' => '</div></aside>',
  75.             'before_title' => '<h3 class="widget-title">',
  76.             'after_title' => '</h3><div class="inside">',
  77.         ) );
  78.  
  79.         register_sidebar( array(
  80.             'name' => __( 'Home Right Sidebar', 'edutica' ),
  81.             'id' => 'home-right-sidebar',
  82.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  83.             'after_widget' => '</div></aside>',
  84.             'before_title' => '<h3 class="widget-title">',
  85.             'after_title' => '</h3><div class="inside">',
  86.         ) );
  87.  
  88.         register_sidebar( array(
  89.             'name' => __( 'Home Left Sidebar', 'edutica' ),
  90.             'id' => 'home-left-sidebar',
  91.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  92.             'after_widget' => '</div></aside>',
  93.             'before_title' => '<h3 class="widget-title">',
  94.             'after_title' => '</h3><div class="inside">',
  95.         ) );
  96.        
  97.         register_sidebar( array(
  98.             'name' => __( 'Homepage Center', 'edutica' ),
  99.             'id' => 'homepage-center',
  100.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  101.             'after_widget' => '</aside>',
  102.             'before_title' => '<h3 class="widget-title">',
  103.             'after_title' => '</h3>',
  104.         ) );
  105.        
  106.         // footer sidebars
  107.         register_sidebar( array(
  108.             'name' => __( 'Footer 1', 'edutica' ),
  109.             'id' => 'footer_1',
  110.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  111.             'after_widget' => '</div></aside>',
  112.             'before_title' => '<h3 class="widget-title">',
  113.             'after_title' => '</h3><div class="inside">',
  114.         ) );
  115.  
  116.         register_sidebar( array(
  117.             'name' => __( 'Footer 2', 'edutica' ),
  118.             'id' => 'footer_2',
  119.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  120.             'after_widget' => '</div></aside>',
  121.             'before_title' => '<h3 class="widget-title">',
  122.             'after_title' => '</h3><div class="inside">',
  123.         ) );
  124.  
  125.         register_sidebar( array(
  126.             'name' => __( 'Footer 3', 'edutica' ),
  127.             'id' => 'footer_3',
  128.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  129.             'after_widget' => '</div></aside>',
  130.             'before_title' => '<h3 class="widget-title">',
  131.             'after_title' => '</h3><div class="inside">',
  132.         ) );
  133.  
  134.         register_sidebar( array(
  135.             'name' => __( 'Footer 4', 'edutica' ),
  136.             'id' => 'footer_4',
  137.             'before_widget' => '<aside id="%1$s" class="widget %2$s">',
  138.             'after_widget' => '</div></aside>',
  139.             'before_title' => '<h3 class="widget-title">',
  140.             'after_title' => '</h3><div class="inside">',
  141.         ) );
  142.        
  143.         // Botom Widget
  144.         register_sidebar( array(
  145.             'name' => __( 'Widget Bottom ', 'edutica' ),
  146.             'id' => 'destination_1',
  147.             'before_widget' => '<aside id="%1$s" class="widget span3 %2$s">',
  148.             'after_widget' => '</div></aside>',
  149.             'before_title' => '<h3 class="widget-title">',
  150.             'after_title' => '</h3><div class="inside">',
  151.         ) );
  152.        
  153.     }
  154.    
  155.    
  156.     /**
  157.      * Enqueue scripts and styles
  158.      */
  159.     function enqueue_scripts() {
  160.         wp_enqueue_style( 'bootstrap', THEME_CSS . '/bootstrap.min.css' );
  161.         // wp_enqueue_style( 'bootstrap-responsive', THEME_CSS . '/bootstrap-responsive.min.css' );
  162.         wp_enqueue_style( 'prettyphoto', THEME_CSS . '/prettyPhoto.css' );
  163.         wp_enqueue_style( 'theme-style', THEME_CSS . '/style.css' );
  164.         wp_enqueue_style( 'shortcode' );
  165.         wp_enqueue_style( 'collection' );
  166.         wp_dequeue_style('wp_sidebarlogin_css_styles');
  167.  
  168.         wp_enqueue_script( 'tinynav', THEME_JS . '/tinynav.min.js', array( 'jquery' ), '20120206', true );
  169.  
  170.         if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  171.             wp_enqueue_script( 'comment-reply' );
  172.         }
  173.  
  174.         if ( is_singular() && wp_attachment_is_image() ) {
  175.             wp_enqueue_script( 'keyboard-image-navigation', THEME_JS . '/keyboard-image-navigation.js', array( 'jquery' ), '20120202' );
  176.         }
  177.        
  178.         wp_enqueue_script( 'flexslider', THEME_JS . '/jquery.flexslider-min.js', array( 'jquery' ) );
  179.         wp_enqueue_script( 'bootstrap-js', THEME_JS . '/bootstrap.min.js', array('jquery') );
  180.         wp_enqueue_script( 'prettyphoto', THEME_JS . '/jquery.prettyPhoto.js', array('jquery') );
  181.         wp_enqueue_script( 'theme-script' );
  182.     }
  183. }
  184.  
  185. $wedevs_bootstrap = new WeDevs_Bootstrap();
  186.  
  187.  
  188. /**
  189.  * Rename user roles
  190.  */
  191. function edutica_rename_user_roles() {
  192.     global $wp_roles;
  193.    
  194.     if ( ! isset( $wp_roles ) ) {
  195.         $wp_roles = new WP_Roles();
  196.     }
  197.    
  198.     $custom_names = array(
  199.         'subscriber' => __( 'Student', 'wedevs' ),
  200.         'contributor' => __( 'Officers', 'wedevs' ),
  201.         'author' => __( 'Teacher', 'wedevs' )
  202.     );
  203.    
  204.     $roles = $wp_roles->get_names();
  205.     foreach( $roles as $role => $name ) {
  206.         if( array_key_exists( $role, $custom_names ) ) {
  207.             $wp_roles->roles[$role]['name'] = $custom_names[$role];
  208.             $wp_roles->role_names[$role] = $custom_names[$role];
  209.         }
  210.        
  211.     }
  212. }
  213. add_action( 'init', 'edutica_rename_user_roles' );
  214.  
  215. /**
  216.  * Add buttons to tinyMCE
  217.  */
  218. function edutica_add_button() {  
  219.     if ( current_user_can('edit_posts') &&  current_user_can('edit_pages') ) {
  220.         add_filter('mce_external_plugins', 'edutica_tinymce_plugins');  
  221.         add_filter('mce_buttons_3', 'edutica_register_buttons');  
  222.     }
  223. }
  224.  
  225. add_action('init', 'edutica_add_button');
  226.  
  227. /**
  228.  * Register custom shortcode buttons
  229.  */
  230. function edutica_register_buttons( $buttons ) {  
  231.     $custom_buttons = array("youtube", "vimeo", "soundcloud", "button","tab", "toggle","accordion" ,
  232.         "tooltip", "dropcap","unlist", "social", "featurebox", "row", "one_half", "one_third",
  233.         "two_third", "one_fourth", "three_fourth", "slider", "testimonial", "progress", "person",
  234.         "alert", "pricing_table", "recent_works", "tagline_box", "content_boxes", "recent_posts"
  235.     );
  236.  
  237.     return array_merge( $buttons, $custom_buttons );
  238. }  
  239.  
  240.  
  241. function edutica_tinymce_plugins($plugin_array) {  
  242.    $plugin_array['youtube'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  243.    $plugin_array['vimeo'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  244.    $plugin_array['soundcloud'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  245.    $plugin_array['button'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  246.    $plugin_array['tab'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  247.    $plugin_array['toggle'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  248.    $plugin_array['accordion'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  249.    $plugin_array['tooltip'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  250.    $plugin_array['dropcap'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  251.    $plugin_array['unlist'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  252.    $plugin_array['social'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  253.    $plugin_array['featurebox'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  254.    $plugin_array['row'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  255.    $plugin_array['one_half'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  256.    $plugin_array['one_third'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  257.    $plugin_array['two_third'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  258.    $plugin_array['one_fourth'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  259.    $plugin_array['three_fourth'] = get_template_directory_uri().'/lib/tinymce/shortcode-buttons.js';
  260.  
  261.    
  262.    return $plugin_array;  
  263. }  
  264.  
  265. // custom post type
  266. $book = new Custom_Post_Type( 'Event' );  
  267. $book->add_taxonomy( 'category' );  
  268. $book->add_meta_box(  
  269.     'Event Date',  
  270.     array(  
  271.         'Date' => 'text',  
  272.         'Time' => 'text'  
  273.     )  
  274. );  
  275. $book->add_meta_box(  
  276.     'Event Place',  
  277.     array(  
  278.         'Name' => 'text'  
  279.     )  
  280. );
Add Comment
Please, Sign In to add comment