Example #1
0
 /**
  * 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;
         }
     }
 }
Example #2
0
 /**
  * Displays the slider. If $echo, it will output the contents 
  * 
  * @param bool $echo
  */
 public function display($echo = true)
 {
     if (!$this->slider || !$this->slides && fa_is_preview()) {
         return;
     }
     $theme = $this->options['theme'];
     $theme_file = $theme['details']['display'];
     if (!file_exists($theme_file)) {
         // trigger error just for admins
         if (current_user_can('manage_options')) {
             trigger_error(sprintf(__('Slider theme <strong>%s</strong> display file could not be found.', 'fapro'), $theme['details']['theme_config']['name']));
         }
         return;
     }
     // make ssl friendly theme URL
     if (is_ssl()) {
         $theme['details']['url'] = str_replace('http://', 'https://', $theme['details']['url']);
     }
     // load minified stylesheet
     $suffix = defined('FA_CSS_DEBUG') && FA_CSS_DEBUG ? '' : '.min';
     wp_enqueue_style('fa-theme-' . $theme['active'], path_join($theme['details']['url'], 'stylesheet' . $suffix . '.css'), false, FA_VERSION);
     if (isset($theme['details']['theme_config']['stylesheets'])) {
         $extra_styles = (array) $theme['details']['theme_config']['stylesheets'];
         /**
          * Filter that can be used in themes to prevent FontAwesome from being loaded
          * if the theme already uses it.
          * @var bool
          */
         $allow_fa = apply_filters('fa-load-font-awesome-css', true);
         // prevent Font Awesome to be loaded if set by the user in admin area
         $options = fa_get_options('settings');
         if (isset($options['load_font_awesome']) && !$options['load_font_awesome']) {
             $allow_fa = false;
         }
         // enqueue font awesome if specified by the theme settings
         if ($allow_fa && isset($extra_styles['font-awesome']) && $extra_styles['font-awesome']) {
             // enqueue font awesome only if specified by the theme settings
             wp_enqueue_style('font-awesome', (is_ssl() ? 'https://' : 'http://') . 'maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css', array(), FA_VERSION);
         }
     }
     if (!empty($this->options['theme']['color'])) {
         wp_enqueue_style('fa-theme-' . $theme['active'] . '-' . $theme['color'], path_join($theme['details']['url'], 'colors/' . str_replace('.min', '', $theme['color']) . '.css'), array('fa-theme-' . $theme['active']), FA_VERSION);
     }
     /**
      * Theme starter dependencies
      */
     $dependencies = array('jquery');
     // when debug is on, load each individual .dev file
     if (defined('FA_SCRIPT_DEBUG') && FA_SCRIPT_DEBUG) {
         $dependencies[] = fa_load_script('slider');
         $dependencies[] = fa_load_script('jquery-mobile');
         $dependencies[] = fa_load_script('jquery-transit');
     } else {
         // load only the minified file containing all scripts
         $dependencies[] = fa_load_script('_scripts.min');
     }
     // load theme starter
     $suffix = defined('FA_SCRIPT_DEBUG') && FA_SCRIPT_DEBUG ? '.dev' : '.min';
     wp_enqueue_script('fa-theme-' . $theme['active'] . '-starter', path_join($theme['details']['url'], 'starter' . $suffix . '.js'), $dependencies, FA_VERSION, true);
     global $slider_id, $fa_slider;
     // global $post
     $slider_id = $this->slider->ID;
     /**
      * Set the global $fa_slider variable that will be used
      * in templating functions and other functions.
      * 
      * @var object - the post object of the current slider
      */
     $fa_slider = $this->slider;
     // store the posts on the slider global variable
     $fa_slider->slides = $this->slides;
     // set the current to 0
     $fa_slider->current_slide = -1;
     // set the number of slides
     $fa_slider->slide_count = count($this->slides);
     // include the templating functions
     include_once fa_get_path('includes/templating.php');
     // capture the output
     ob_start();
     include $theme_file;
     $output = ob_get_clean();
     // include some cache stats on previews
     if (fa_is_preview() || current_user_can('manage_options')) {
         $output .= '<!-- Slider generated in ' . number_format(microtime(true) - $this->timer_start, 5) . ' seconds -->';
     }
     // show the edit link on slider output
     if (current_user_can('edit_fa_items', $this->slider->ID)) {
         $settings = fa_get_options('settings');
         $show = (bool) $settings['edit_links'];
         /**
          * Show slider edit link in front-end output.
          * 
          * @var bool - if callback returns false, edit link will be hidden
          * @var slider_id - id of slider
          */
         $show = apply_filters('fa_show_slider_edit_link', $show, $this->slider->ID);
         if ($show) {
             $edit_link = get_edit_post_link($this->slider->ID);
             $output .= sprintf('<a href="%s" title="%s">%s</a>', $edit_link, esc_attr(__('Edit slider', 'fapro')), __('Edit slider', 'fapro'));
         }
     }
     if ($echo) {
         echo $output;
     }
     return $output;
 }
Example #3
0
/**
 * Displays a slider based on the slider ID
 * @param int $slider_id
 * @param bool/string $dynamic_area - if slider is displayed into a dynamic area, the parameter contains the area ID
 */
function fa_display_slider($slider_id, $dynamic_area = false)
{
    /**
     * Filter that can prevent a slider from being displayed. 
     * Mainly used by dynamic areas to only show sliders in post/pages/categories allowed by user
     * in slider settings.
     * 
     * @param bool - show slider
     * @param int $slider_id - ID of slider being displayed
     * @param bool/string $dynamic_area - the area ID that the slider is set to be published in (false if not in dynamic area)
     */
    $show = apply_filters('fa_display_slider', true, $slider_id, $dynamic_area);
    if (!$show) {
        return;
    }
    /**
     * Action on slider display.
     * 
     * @param int $slider_id
     * @param string $dynamic_area
     */
    do_action('fa_slider_display', $slider_id, $dynamic_area);
    /**
     * Filters to apply on content that is displayed into slides
     */
    add_filter('the_fa_content', 'wptexturize');
    add_filter('the_fa_content', 'convert_smilies');
    add_filter('the_fa_content', 'convert_chars');
    add_filter('the_fa_content', 'wpautop');
    add_filter('the_fa_content', 'shortcode_unautop');
    require_once fa_get_path('includes/libs/class-fa-slider.php');
    $slider = new FA_Slider($slider_id);
    $slider->display();
    if (defined('FA_SCRIPT_DEBUG') && FA_SCRIPT_DEBUG) {
        echo '<!-- Slider ID: ' . $slider_id . ' ; Dynamic area ID: ' . $dynamic_area . ' -->';
    }
}
Example #4
0
/**
 * Get registered slideshow themes
 */
function fa_get_themes()
{
    global $fa_theme_manager;
    if (!class_exists('FA_Themes_Manager')) {
        require_once fa_get_path('includes/admin/libs/class-fa-themes-manager.php');
        $fa_theme_manager = new FA_Themes_Manager();
    }
    if (!$fa_theme_manager) {
        $fa_theme_manager = new FA_Themes_Manager();
    }
    $themes = $fa_theme_manager->get_themes();
    return $themes;
}
Example #5
0
 /**
  * Plugin activation hook callback function
  */
 public function on_activation()
 {
     // give full access to administrators on plugin activation
     parent::set_capabilities();
     $this->allow_admins();
     // get the current option
     $option = fa_get_options('plugin_details');
     // set the current plugin details
     $plugin_details = array('version' => FA_VERSION, 'wp_version' => get_bloginfo('version'), 'activated_on' => current_time('mysql'));
     /**
      * Action on plugin activation that allows maintenance related actions.
      * 
      * @param $option - current option stored in plugin settings
      * @param $plugin_details - the new option that is going to be saved
      */
     do_action('fa_pro_activation', $option, $plugin_details);
     // update the option
     fa_update_options('plugin_details', $plugin_details);
     // pre 3.0 plugin options verification
     $old_options = get_option('fa_plugin_details', array());
     $updated = fa_get_options('updated');
     if ($old_options && !version_compare($updated['to'], '3.0', '>=')) {
         $this->on_init();
         include_once fa_get_path('includes/libs/class-fa-update.php');
         new FA_Update();
         // flag plugin as updated to prevent update from running again if previous plugin version reactivated
         fa_update_options('updated', array('from' => $old_options['version'], 'to' => FA_VERSION));
     }
 }
Example #6
0
 /**
  * Add tinyMce plugin translations
  */
 public function tinymce_languages($locales)
 {
     $locales['fa_slider'] = fa_get_path('assets/admin/js/tinymce/fa_slider/langs/langs.php');
     return $locales;
 }