Created
April 22, 2016 16:34
-
-
Save yanknudtskov/397dbb8ef97b2b45a24bd441b1dfdc6d to your computer and use it in GitHub Desktop.
OOP Functions for WordPress functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Functions { | |
private $theme_name; | |
private $theme_version; | |
public function __construct( $theme_name, $theme_version ) { | |
$this->theme_name = $theme_name; | |
$this->theme_version = $theme_version; | |
$this->theme_setup(); | |
} | |
$functions = new Functions( 'my-theme', '1.0.0' ); | |
private function theme_setup() { | |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); | |
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); | |
} | |
public function enqueue_styles() { | |
wp_enqueue_style( $this->theme_name . '_main_css', get_stylesheet_directory_uri() . '/dist/css/main.min.css', array(), $this->theme_version ); | |
wp_enqueue_style( $this->theme_name . '_fontawesome_css', get_stylesheet_directory_uri() . '/bower_components/font-awesome/css/font-awesome.min.css', array(), $this->theme_version ); | |
wp_enqueue_style( $this->theme_name . '_style_css', get_stylesheet_directory_uri() . '/style.css', array($this->theme_name . '_main_css'), $this->theme_version ); | |
} | |
public function enqueue_scripts() { | |
wp_enqueue_script( $this->theme_name . '_jquery_js', get_stylesheet_directory_uri() . '/bower_components/jquery/dist/jquery.min.js', array(), $this->theme_version ); | |
wp_enqueue_script( $this->theme_name . '_bootstrap_js', get_stylesheet_directory_uri() . '/bower_components/bootstrap-sass/assets/javascripts/bootstrap.min.js', array(), $this->theme_version ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment