self::get_templates(), 'forms' => self::get_forms(), 'is_lightspeed' => areoi_is_lightspeed(), 'pattern' => get_option( 'areoi-lightspeed-styles-strip-pattern', false ), 'divider' => get_option( 'areoi-lightspeed-styles-strip-divider', false ), 'transition' => get_option( 'areoi-lightspeed-transition-transition', false ), 'parallax' => get_option( 'areoi-lightspeed-parallax-parallax', false ), ) ); wp_set_script_translations( 'areoi-lightspeed-blocks', AREOI__TEXT_DOMAIN ); } } public static function add_block_categories( $categories, $post ) { $new_category = [ 'slug' => 'areoi-lightspeed', 'title' => __( 'Lightspeed', AREOI__TEXT_DOMAIN ), 'icon' => '' ]; $new_categories[] = $new_category; return array_merge( $new_categories, $categories); } public static function add_scripts() { $enqueue = 'assets/js/global.js'; wp_enqueue_script( 'areoi-lightspeed', AREOI__PLUGIN_LIGHTSPEED_URI . $enqueue, array( 'jquery' ), filemtime( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ); $scripts = ''; ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . 'assets/js/site.js' ); $scripts .= ob_get_clean(); $transition = get_option( 'areoi-lightspeed-transition-transition', false ); if ( $transition ) { $enqueue = 'assets/js/transition.js'; if ( file_exists( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ) { ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ); $scripts .= ob_get_clean(); } } $page_transition = get_option( 'areoi-lightspeed-transition-page', false ); if ( $page_transition ) { $enqueue = 'assets/js/transition-page.js'; if ( file_exists( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ) { ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ); $scripts .= ob_get_clean(); } } $background_transition = get_option( 'areoi-lightspeed-transition-background', false ); if ( $background_transition ) { $enqueue = 'assets/js/transition-background.js'; if ( file_exists( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ) { ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ); $scripts .= ob_get_clean(); } } $parallax = get_option( 'areoi-lightspeed-parallax-parallax', false ); if ( $parallax ) { $enqueue = 'assets/js/parallax.js'; if ( file_exists( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ) { ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ); $scripts .= ob_get_clean(); } } $gallery = get_option( 'areoi-lightspeed-gallery-include', false ); if ( $gallery ) { $enqueue = 'assets/js/gallery.js'; if ( file_exists( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ) { ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ); $scripts .= ob_get_clean(); } } if ( $scripts ) { $scripts = ' jQuery(document).ready(function($){ ' . $scripts . ' }); '; wp_add_inline_script( 'areoi-lightspeed', areoi_minify_js( $scripts ) ); } } public static function add_admin_scripts() { $enqueue = 'assets/js/admin.js'; wp_enqueue_script( 'areoi-lightspeed-admin', AREOI__PLUGIN_LIGHTSPEED_URI . $enqueue, array( 'jquery' ), filemtime( AREOI__PLUGIN_LIGHTSPEED_DIR . $enqueue ) ); self::add_custom_fonts(); } public static function get_templates() { $block_folders = array( 'hero' => 'hero/templates', 'header_main' => 'header/templates/main', 'header_top_bar' => 'header/templates/top_bar', 'header_search' => 'header/templates/search', 'header_more' => 'header/templates/more', 'header_feature' => 'header/templates/feature', 'footer' => 'footer/templates', 'content_with_media'=> 'content-with-media/templates', 'content_with_items'=> 'content-with-items/templates', 'media' => 'media/templates', 'post_grid' => 'post-grid/templates', 'call_to_action' => 'call-to-action/templates', 'next_and_previous' => 'next-and-previous/templates', 'logos' => 'logos/templates', 'contact' => 'contact/templates', ); $templates = array(); foreach ( $block_folders as $block_folder_key => $block_folder ) { $directory = AREOI__PLUGIN_LIGHTSPEED_DIR . 'blocks/' . $block_folder . '/'; $plugin_templates = lightspeed_list_files( $directory ); $theme_directory = get_template_directory() . '/all-bootstrap-blocks/lightspeed/' . $block_folder . '/'; $theme_templates = lightspeed_list_files( $theme_directory ); $all_templates = array_merge( $plugin_templates, $theme_templates ); sort( $all_templates, SORT_NATURAL | SORT_FLAG_CASE ); $block_templates = array( array( 'value' => '', 'label' => 'Default' ) ); foreach ( $all_templates as $template ) { $block_templates[] = array( 'value' => $template, 'label' => 'Template (' . $template . ')' ); } $templates[$block_folder_key] = $block_templates; } return $templates; } public static function get_forms() { $forms = array( array( 'value' => '', 'label' => 'None' ) ); if ( class_exists( 'Ninja_Forms' ) ) { $ninja_forms = Ninja_Forms()->form()->get_forms(); foreach ( $ninja_forms as $form_key => $form ) { $forms[] = array( 'value' => $form->get_id(), 'label' => $form->get_setting( 'title' ) ); } } return $forms; } public static function add_custom_fonts() { $fonts = array(); $heading_font = get_option( 'areoi-lightspeed-company-heading-font-url', '' ); $body_font = get_option( 'areoi-lightspeed-company-body-font-url', '' ); if ( $heading_font ) $fonts['areoi-heading-font'] = $heading_font; if ( $body_font && $body_font != $heading_font ) $fonts['areoi-body-font'] = $body_font; if ( !empty( $fonts ) ) { foreach ( $fonts as $font_key => $font ) { wp_enqueue_style( $font_key, $font, array(), '' ); } } } public static function add_styles() { self::add_custom_fonts(); ob_start(); include( AREOI__PLUGIN_LIGHTSPEED_DIR . 'assets/css/lightspeed.css' ); $styles = ob_get_clean(); $styles .= self::generate_header_and_footer_styles(); $frame = get_option( 'areoi-lightspeed-styles-frame', false ); if ( $frame ) { add_action( 'wp_body_open', function() { echo '