Skip to content

Commit

Permalink
Implemented enqueue method
Browse files Browse the repository at this point in the history
  • Loading branch information
zohaib87 committed Oct 5, 2023
1 parent 4c85e6b commit a031d97
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 35 deletions.
14 changes: 9 additions & 5 deletions helpers/class-helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function files_array( $prefix, $override = false ) {
* # Get and list menu locations.
* Will only work after init and wp hook.
*/
public static function menu_locations($override = false) {
public static function menu_locations( $override = false ) {

global $_wp_registered_nav_menus;

Expand All @@ -116,18 +116,22 @@ public static function rev_sliders() {
$data = array();
$data['none'] = esc_html__( 'None', '_xe' );

if ( class_exists('RevSlider') ) :
if ( class_exists('RevSlider') ) {

$slider = new \RevSliderSlider();
$sliders = $slider->getArrSlidersShort();

if (!empty($sliders)) {
foreach ($sliders as $key => $val) {
if ( ! empty( $sliders ) ) {

foreach ( $sliders as $key => $val ) {

$data[$key] = $val;

}

}

endif;
}

return $data;

Expand Down
46 changes: 16 additions & 30 deletions includes/class-scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace Xe_Theme\Includes;

use Xe_Theme\Helpers\Helpers;

class Scripts {

function __construct() {
Expand All @@ -23,43 +25,31 @@ function __construct() {
*/
public function frontend() {

global $xe_opt;

// Version Control for CSS and JS
$style_css = filemtime(get_template_directory() . '/style.css');
$main_css = filemtime(get_template_directory() . '/assets/css/main.css');
$bootstrap_css = filemtime(get_template_directory() . '/assets/css/bootstrap.min.css');
$fontawesome_css = filemtime(get_template_directory() . '/assets/css/all.min.css');

$bootstrap_js = filemtime(get_template_directory() . '/assets/js/bootstrap.bundle.min.js');
$stellar_js = filemtime(get_template_directory() . '/assets/js/stellar.min.js');
$sticky_js = filemtime(get_template_directory() . '/assets/js/sticky.min.js');
$main_js = filemtime(get_template_directory() . '/assets/js/main.js');

/**
* Google Fonts
*/
// wp_enqueue_style('google-fonts', '');
// wp_enqueue_style( 'google-fonts', '' );

/**
* # Styles
*/
wp_enqueue_style('_xe-style', get_template_directory_uri() . '/style.css', array(), esc_attr($style_css));
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/assets/css/bootstrap.min.css', array(), esc_attr($bootstrap_css));
wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/css/all.min.css', array(), esc_attr($fontawesome_css));
wp_enqueue_style('_xe-main', get_template_directory_uri() . '/assets/css/main.css', array(), esc_attr($main_css));
Helpers::enqueue( 'style', '_xe-style', '/style.css' );
Helpers::enqueue( 'style', 'bootstrap', '/assets/css/bootstrap.min.css' );
Helpers::enqueue( 'style', 'fontawesome', '/assets/css/all.min.css' );
Helpers::enqueue( 'style', '_xe-main', '/assets/css/main.css' );

/**
* # Scripts
*/
wp_enqueue_script('bootstrap', get_template_directory_uri() . "/assets/js/bootstrap.bundle.min.js", array('jquery'), esc_attr($bootstrap_js), true);
wp_enqueue_script('stellar', get_template_directory_uri() . "/assets/js/stellar.min.js", array('jquery'), esc_attr($stellar_js), true);
wp_enqueue_script('sticky', get_template_directory_uri() . "/assets/js/sticky.min.js", array('jquery'), esc_attr($sticky_js), true);
Helpers::enqueue( 'script', 'bootstrap', '/assets/js/bootstrap.bundle.min.js', ['jquery'] );
Helpers::enqueue( 'script', 'stellar', '/assets/js/stellar.min.js', ['jquery'] );
Helpers::enqueue( 'script', 'sticky', '/assets/js/sticky.min.js', ['jquery'] );
Helpers::enqueue( 'script', '_xe-main', '/assets/js/main.js', ['jquery'] );

if ( is_singular() && comments_open() && get_option('thread_comments') ) {

wp_enqueue_script('_xe-main', get_template_directory_uri() . '/assets/js/main.js', array('jquery'), esc_attr($main_js), true);
wp_enqueue_script( 'comment-reply' );

if (is_singular() && comments_open() && get_option('thread_comments')) {
wp_enqueue_script('comment-reply');
}

}
Expand All @@ -71,19 +61,15 @@ public function frontend() {
*/
public function backend() {

// Version Control for admin CSS and JS
$admin_css = filemtime(get_template_directory() . '/assets/css/admin.css');
$admin_js = filemtime(get_template_directory() . '/assets/js/admin.js');

/**
* # Styles
*/
wp_enqueue_style('_xe-admin', get_template_directory_uri() . '/assets/css/admin.css', array(), esc_attr($admin_css));
Helpers::enqueue( 'style', '_xe-admin', '/assets/css/admin.css' );

/**
* # Scripts
*/
wp_enqueue_script('_xe-admin', get_template_directory_uri() . '/assets/js/admin.js', array(), esc_attr($admin_js), true);
Helpers::enqueue( 'script', '_xe-admin', '/assets/js/admin.js', ['jquery'] );

}

Expand Down

0 comments on commit a031d97

Please sign in to comment.