Beispiel #1
0
 /**
  * (non-PHPdoc)
  * @see WP_Widget::widget()
  */
 function widget($args, $instance)
 {
     if (!$instance || (!isset($instance['slider_id']) || !$instance['slider_id'])) {
         return;
     }
     $slider = get_post($instance['slider_id']);
     if (!$slider || 'publish' != $slider->post_status && !fa_is_preview()) {
         return;
     }
     extract($args, EXTR_SKIP);
     // output HTML before widget as set by sidebar
     echo $before_widget;
     // output the widget title
     $title = apply_filters('widget_title', $instance['title']);
     if ($instance['title']) {
         // output the widget title
         echo $before_title . $title . $after_title;
     }
     $this->slider_id = $instance['slider_id'];
     $this->atts = $instance;
     // display the slider; assign it to widget area to be able to check into the display filter (index.php in plugin files).
     fa_display_slider($instance['slider_id'], 'widget_area');
     // output HTML after widget as set by sidebar
     echo $after_widget;
     // clear the slider id class variable
     $this->slider_id = false;
     $this->atts = array();
     // remove the filter to avoid messing the display of the slider on other areas
     remove_filter('fa_get_slider_options', array($this, 'options'), 999);
     // remove show filter
     remove_filter('fa_display_slider', array($this, 'overwrite_options'), 999);
 }
Beispiel #2
0
 /**
  * Callback for filter fa_get_slider_options.
  * When a preview is displayed, the function will overwrite
  * the slider options with the options passed over $_GET
  */
 public function modify_preview_options($options, $key, $slider_id)
 {
     // make this work only for previews
     if (!fa_is_preview()) {
         return $options;
     }
     // check that is the same slider ID
     if ($slider_id != $this->slider->ID) {
         return $options;
     }
     // On preview, force the review options instead of slider options
     if (!$key) {
         return $this->options;
     } else {
         return $this->options[$key];
     }
     return $options;
 }
Beispiel #3
0
 /**
  * Init callback. This should be the first to start within the plugin.
  */
 public function on_init()
 {
     // load when not in admin area
     if (!is_admin()) {
         // start custom post type class
         parent::__construct();
         // add the shortcodes
         require_once fa_get_path('includes/libs/class-fa-shortcodes.php');
         new FA_Shortcodes();
     }
     // only for admin area
     if (is_admin() || fa_is_preview()) {
         // localization - needed only for admin area
         load_plugin_textdomain('fapro', false, dirname(plugin_basename(__FILE__)) . '/languages/');
         // allow admins to manage all areas of the plugin
         add_action('set_current_user', array($this, 'allow_admins'));
         // add admin specific functions
         require_once fa_get_path('includes/admin/functions.php');
         // add administration management
         require_once fa_get_path('includes/admin/libs/class-fa-admin.php');
         // start the administration area
         new FA_Admin();
     }
 }
Beispiel #4
0
 /**
  * Init callback that checks if a preview should be displayed.
  * Verifies only front-end pages.
  * Adds filter loop_start to display the slider preview.
  */
 public function is_preview()
 {
     // previews not available on admin pages
     if (is_admin()) {
         return;
     }
     // check for preview variable
     if (!fa_is_preview()) {
         // user must be capabile of editing fa items
         if (!current_user_can('edit_fa_items')) {
             wp_die(__('Not allowed.', 'fapro'));
         }
         return;
     }
     check_admin_referer('fa-slider-theme-preview', 'fa-preview-nonce');
 }