themename = 'butterfly-abode'; $this->style_uri = get_stylesheet_directory_uri().'/css'; $this->script_uri = get_stylesheet_directory_uri().'/js'; $this->image_uri = get_stylesheet_directory_uri().'/images'; add_action('init', array( $this, 'theme_supports' )); add_action('widgets_init', array( $this, 'theme_sidebars' )); add_filter( 'wp_title', array( $this, 'page_title' ) ); add_action('wp_enqueue_scripts', array( $this, 'theme_imports' )); add_action( 'add_meta_boxes', array( $this, 'bfly_post_meta_box' )); add_action( 'save_post', array( $this, 'bfly_post_save_meta_box_data' )); } function page_title($title) { if( empty( $title ) && ( is_home() || is_front_page() ) ) { return __( 'Home', 'butterfly-abode' ) . ' | ' . __(get_bloginfo( 'description', 'butterfly-abode' )); } return $title; } function theme_supports() { register_nav_menu('header-menu','Header Menu'); // add_theme_support( 'post-formats', array( 'video', 'gallery' ) ); add_theme_support( 'title-tag' ); add_theme_support( 'post-thumbnails' ); add_theme_support( 'automatic-feed-links' ); if ( ! isset( $content_width ) ) $content_width = 900; } function theme_imports() { wp_enqueue_style( 'google-lato-font', 'https://fonts.googleapis.com/css?family=Titillium+Web:400,700,600,300' ); wp_enqueue_style( 'font-awesome', $this->style_uri.'/font-awesome.min.css' ); wp_enqueue_style( $this->themename.'-bootstrap-style', $this->style_uri.'/bootstrap.css' ); wp_enqueue_style( $this->themename.'-slick-style', $this->style_uri.'/slick.css' ); wp_enqueue_style( $this->themename.'-slick-theme-style', $this->style_uri.'/slick-theme.css' ); wp_enqueue_style( $this->themename.'-mmenu-style', $this->style_uri.'/jquery.mmenu.all.css' ); wp_enqueue_style( $this->themename.'-style', get_stylesheet_uri(),999 ); wp_enqueue_script( 'jquery' ); wp_enqueue_script( $this->themename.'-masonry-script', $this->script_uri . '/masonry.pkgd.min.js' ); wp_enqueue_script( $this->themename.'-infinite-scoll-script', $this->script_uri . '/jquery.infinitescroll.min.js' ); wp_enqueue_script( $this->themename.'-slick-script', $this->script_uri . '/slick.min.js' ); wp_enqueue_script( $this->themename.'-mmenu-script', $this->script_uri . '/jquery.mmenu.min.all.js' ); wp_enqueue_script( $this->themename.'-script', $this->script_uri . '/scripts.js' ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } } function theme_sidebars() { register_sidebar( array( 'name' => 'Sidebar', 'id' => 'home-sidebar', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => 'Footer 1', 'id' => 'footer-1', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => 'Footer 2', 'id' => 'footer-2', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); register_sidebar( array( 'name' => 'Footer 3', 'id' => 'footer-3', 'before_widget' => '', 'before_title' => '

', 'after_title' => '

', ) ); } function bfly_post_meta_box() { add_meta_box( 'bfly_post_settings', __('Post Settings','butterfly-abode'), array( $this,'bfly_post_meta_box_callback'), 'post' ); } function bfly_post_meta_box_callback( $post ) { wp_nonce_field( array($this,'bfly_post_save_meta_box_data'), 'bfly_post_meta_box_nonce' ); $show_in_slider = get_post_meta( $post->ID, 'show_in_slider', true ); echo '

'; echo '

'; } function bfly_post_save_meta_box_data( $post_id ) { if ( ! isset( $_POST['bfly_post_meta_box_nonce'] ) ) { return; } if ( ! wp_verify_nonce( $_POST['bfly_post_meta_box_nonce'], array($this,'bfly_post_save_meta_box_data') ) ) { return; } if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return; } if ( isset( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return; } } $show_in_slider = sanitize_text_field( $_POST['show_in_slider'] ); update_post_meta( $post_id, 'show_in_slider', $show_in_slider ); // $arr = array(); // if (isset($_POST['bfly_post'])) // { // $arr = $_POST['bfly_post']; // } // foreach ($arr as $key => $value) // { // $val = sanitize_text_field($value); // update_post_meta( $post_id, $key, $val ); // } } } $butterfly = new Butterfly(); require_once('customizer.php');