/** * Constructor */ public function __construct() { // default themes path and URL $this->default_themes_path = fa_get_path('themes'); $this->default_themes_url = fa_get_uri('themes'); // extra themes path and URL $option = fa_get_options('settings'); $rel_path = isset($option['themes_dir']) ? $option['themes_dir'] : false; if ($rel_path) { $path = wp_normalize_path(path_join(WP_CONTENT_DIR, $rel_path)); if ($path != $this->default_themes_path && is_dir($path)) { $this->extra_themes_path = $path; $this->extra_themes_url = (is_ssl() ? str_replace('http://', 'https://', WP_CONTENT_URL) : WP_CONTENT_URL) . '/' . $rel_path; } } }
/** * Enqueues a given front-end script. File name should not have .js extension. * An array of dependencies can be passed to it. * * @param string $script - filename from within plugin folder assets/front/js without the .js extension * @param array $dependency - array of dependencies. Defaults to jquery * * @return string - script handle */ function fa_load_script($script, $dependency = array('jquery')) { if (defined('FA_SCRIPT_DEBUG') && FA_SCRIPT_DEBUG) { $script .= '.dev'; } $url = fa_get_uri('assets/front/js/' . $script . '.js'); wp_enqueue_script('fa-script-' . $script, $url, $dependency, FA_VERSION); return 'fa-script-' . $script; }
/** * Outputs the slide image according to size set in slider settings * * @param string $before * @param string $after * @param bool $set_width * @param bool $overlay_link * @param bool $echo */ function the_fa_image($before = '<div class="image_container">', $after = '</div>', $set_width = false, $overlay_link = true, $echo = true) { global $fa_slider; $post = get_current_slide(); // get slider options and check if titles are visible $slider_options = fa_get_slider_options($fa_slider->ID, 'content_image'); if (!$slider_options['show']) { return; } // slide options $options = fa_get_slide_options($post->ID); // get the attached image ID $image = get_the_fa_slide_image_url($post->ID, $fa_slider->ID); // if no image URL was detected, stop if (!$image) { return false; } // the image URL $image_url = $image['url']; $attrs = array(); if ($slider_options['show_width']) { $attrs[] = 'width="' . absint($image['width']) . '"'; } if ($slider_options['show_height']) { $attrs[] = 'height="' . absint($image['height']) . '"'; } $attrs[] = 'data-width="' . absint($image['width']) . '"'; $attrs[] = 'data-height="' . absint($image['height']) . '"'; $style = array(); if ($set_width) { $style[] = 'width:' . absint($image['width']) . 'px'; } // create the link $link = array('', ''); if ($slider_options['clickable']) { $url = get_permalink($post->ID); if ($url && !empty($url)) { $link[0] = sprintf('<a href="%1$s" title="%2$s" target="%3$s">', $url, esc_attr($post->post_title), '_self'); $link[1] = '</a>'; } } // the image output $img_html = '<img class="fa_slide_image main-image" src="' . $image_url . '" ' . implode(' ', $attrs) . ' style="' . implode('; ', $style) . '" />'; // preload image functionality $container_class = array('fa-image-container'); $container_data = array(); if ($slider_options['preload']) { $container_class[] = 'preload_image'; $container_data = array('data-image' => 'data-image="' . $image_url . '"', 'data-image_class' => 'data-image_class="fa_slide_image main-image"', 'data-width' => 'data-width="' . $image['width'] . '"', 'data-height' => 'data-height="' . $image['height'] . '"'); $img_url = fa_get_uri('assets/front/images/loading.gif'); $img_html = '<img class="fa_slide_image main-image preloader" src="' . $img_url . '" alt="" />'; } // start the output $img_output = $before . '<div class="' . implode(' ', $container_class) . '" ' . implode(' ', $container_data) . '>' . $link[0] . $img_html . $link[1] . '</div>' . $after; /** * Filter the image output * * @var string $img_output - the image HTML output * @var object $post - the slide post being processed * @var object $fa_slider - the slider post being processed */ $output = apply_filters('the_fa_slide_image', $img_output, $post, $fa_slider); if ($echo) { echo $output; } return $output; }
/** * Function to load a tinymce plugin styling. * Tinymce plugins are located inside folder assets/js/tinymce/PLUGIN_NAME * Only pass the plugin folder name to the function. Actual css file should always be named style.css * @param string $plugin */ function fa_tinymce_plugin_style($plugin) { $rel_path = 'assets/admin/js/tinymce/' . $plugin . '/style.css'; return fa_get_uri($rel_path); }
/** * Enqueues stylesheet and js file to preload sliders */ public function slides_preload() { $settings = fa_get_options('settings'); if (!$settings['preload_sliders']) { return; } ?> <style type="text/css"> .fa-slideshow.slider-loading{ background-image:url( <?php echo fa_get_uri('assets/front/images/loading.gif'); ?> )!important; background-position:center center!important; background-repeat:no-repeat!important; background-color:#000!important; } .fa-slideshow.slider-loading :nth-child(odd), .fa-slideshow.slider-loading :nth-child(even){ visibility:hidden!important; } </style> <?php }