Esempio n. 1
0
 public function __construct($core)
 {
     $this->core = $core;
     $this->page_slug = Sanitize_Title(Str_Replace(array('\\', '/', '_'), '-', __CLASS__));
     # Option boxes
     $this->arr_option_box = array('main' => array(), 'side' => array());
     Add_Action('admin_menu', array($this, 'Add_Options_Page'));
 }
Esempio n. 2
0
    function Form($settings)
    {
        # Load options
        $this->load_options($settings);
        unset($settings);
        ?>
    <p style="color:green"><?php 
        $this->core->mocking_bird->Pro_Notice('widget');
        ?>
</p>

    <p>
      <label for="<?php 
        echo $this->Get_Field_Id('title');
        ?>
"><?php 
        _e('Title:');
        ?>
</label>
      <input type="text" id="<?php 
        echo $this->Get_Field_Id('title');
        ?>
" name="<?php 
        echo $this->Get_Field_Name('title');
        ?>
" value="<?php 
        echo Esc_Attr($this->Get_Option('title'));
        ?>
" class="widefat">
      <small><?php 
        echo $this->t('Leave blank to use the widget default title.');
        ?>
</small>
    </p>

    <p>
      <label for="<?php 
        echo $this->Get_Field_Id('limit');
        ?>
"><?php 
        echo $this->t('Number of Images:');
        ?>
</label>
      <input type="number" id="<?php 
        echo $this->Get_Field_Id('limit');
        ?>
" name="<?php 
        echo $this->Get_Field_Name('limit');
        ?>
" value="<?php 
        echo Esc_Attr($this->Get_Option('limit'));
        ?>
" class="widefat">
      <small><?php 
        echo $this->t('Leave blank (or "0") to show all.');
        ?>
</small>
    </p>

    <p>
      <label for="<?php 
        echo $this->Get_Field_Id('link_target');
        ?>
"><?php 
        echo $this->t('Link target:');
        ?>
</label>
      <select name="<?php 
        echo $this->Get_Field_Name('link_target');
        ?>
" id="<?php 
        echo $this->Get_Field_Id('link_target');
        ?>
" class="widefat">
        <option value="file" <?php 
        Selected($this->Get_Option('link_target'), 'file');
        ?>
><?php 
        echo $this->t('Fullsize Image');
        ?>
</option>
        <option value="gallery" <?php 
        Selected($this->Get_Option('link_target'), 'gallery');
        ?>
><?php 
        echo $this->t('Image Gallery');
        ?>
</option>
      </select>
    </p>

    <p>
      <label for="<?php 
        echo $this->Get_Field_Id('thumb_width');
        ?>
"><?php 
        echo $this->t('Thumbnail width:');
        ?>
</label>
      <input type="number" name="<?php 
        echo $this->Get_Field_Name('thumb_width');
        ?>
" id="<?php 
        echo $this->Get_Field_Id('thumb_width');
        ?>
" value="<?php 
        echo Esc_Attr($this->Get_Option('thumb_width'));
        ?>
" <?php 
        Disabled(True);
        ?>
 > px
    </p>

    <p>
      <label for="<?php 
        echo $this->Get_Field_Id('thumb_height');
        ?>
"><?php 
        echo $this->t('Thumbnail height:');
        ?>
</label>
      <input type="number" name="<?php 
        echo $this->Get_Field_Name('thumb_height');
        ?>
" id="<?php 
        echo $this->Get_Field_Id('thumb_height');
        ?>
" value="<?php 
        echo Esc_Attr($this->Get_Option('thumb_height'));
        ?>
" <?php 
        Disabled(True);
        ?>
 > px
    </p>

    <p>
      <input type="checkbox" name="<?php 
        echo $this->Get_Field_Name('thumb_grayscale');
        ?>
" id="<?php 
        echo $this->Get_Field_Id('thumb_grayscale');
        ?>
" value="yes" <?php 
        Disabled(True);
        ?>
  >
      <label for="<?php 
        echo $this->Get_Field_Id('thumb_grayscale');
        ?>
"><?php 
        echo $this->t('Convert thumbnails to grayscale.');
        ?>
</label>
    </p>

    <p>
      <input type="checkbox" name="<?php 
        echo $this->Get_Field_Name('thumb_negate');
        ?>
" id="<?php 
        echo $this->Get_Field_Id('thumb_negate');
        ?>
" value="yes" <?php 
        Disabled(True);
        ?>
 >
      <label for="<?php 
        echo $this->Get_Field_Id('thumb_negate');
        ?>
"><?php 
        echo $this->t('Negate the thumbnails.');
        ?>
</label>
    </p>

    <h3><?php 
        echo $this->t('Template');
        ?>
</h3>
    <p><?php 
        echo $this->t('Please choose a template to display this widget.');
        ?>
</p>
    <?php 
        foreach ($this->core->Get_Template_Files() as $name => $properties) {
            ?>
    <p>
      <input type="radio" name="<?php 
            echo $this->Get_Field_Name('template');
            ?>
" id="<?php 
            echo Sanitize_Title($properties['name']);
            ?>
" value="<?php 
            echo Esc_Attr($properties['file']);
            ?>
"
        <?php 
            Checked($this->Get_Option('template'), $properties['file']);
            ?>
        <?php 
            Checked(!$this->Get_Option('template') && $properties['file'] == $this->core->Get_Default_Template());
            ?>
 >
      <label for="<?php 
            echo Sanitize_Title($properties['name']);
            ?>
">
      <?php 
            if (empty($properties['name'])) {
                ?>
        <em><?php 
                echo $properties['file'];
                ?>
</em>
      <?php 
            } else {
                ?>
        <strong><?php 
                echo $properties['name'];
                ?>
</strong>
      <?php 
            }
            ?>
      </label>
      <?php 
            if ($properties['description']) {
                ?>
<br>
      <?php 
                echo $properties['description'];
            }
            ?>
    </p>
    <?php 
        }
    }
        function Form($settings)
        {
            // Load options
            $this->load_options($settings);
            unset($settings);
            ?>
    <p>
      <label for="<?php 
            echo $this->Get_Field_Id('title');
            ?>
"><?php 
            echo $this->t('Title');
            ?>
</label>:
      <input type="text" id="<?php 
            echo $this->Get_Field_Id('title');
            ?>
" name="<?php 
            echo $this->get_field_name('title');
            ?>
" value="<?php 
            echo HTMLSpecialChars($this->get_option('title'));
            ?>
" /><br />
      <small><?php 
            echo $this->t('Leave blank to use the widget default title.');
            ?>
</small>
    </p>

    <p>
      <label for="<?php 
            echo $this->Get_Field_Id('limit');
            ?>
"><?php 
            echo $this->t('Number of Images');
            ?>
</label>:
      <input type="text" id="<?php 
            echo $this->Get_Field_Id('limit');
            ?>
" name="<?php 
            echo $this->get_field_name('limit');
            ?>
" value="<?php 
            echo HTMLSpecialChars($this->get_option('limit'));
            ?>
" size="4" /><br />
      <small><?php 
            echo $this->t('Leave blank (or "0") to show all.');
            ?>
</small>
    </p>

    <p>
      <label for="<?php 
            echo $this->Get_Field_Id('link_target');
            ?>
"><?php 
            echo $this->t('Link target');
            ?>
</label>:
      <select name="<?php 
            echo $this->get_field_name('link_target');
            ?>
" id="<?php 
            echo $this->Get_Field_Id('link_target');
            ?>
">
        <option value="file" <?php 
            Selected($this->Get_option('link_target'), 'file');
            ?>
><?php 
            echo $this->t('Fullsize Image');
            ?>
</option>
        <option value="gallery" <?php 
            Selected($this->Get_option('link_target'), 'gallery');
            ?>
><?php 
            echo $this->t('Image Gallery');
            ?>
</option>
      </select>
    </p>

    <p>
      <label for="<?php 
            echo $this->Get_Field_Id('thumb_width');
            ?>
"><?php 
            echo $this->t('Thumbnail width:');
            ?>
</label>
      <input type="text" name="<?php 
            echo $this->get_field_name('thumb_width');
            ?>
" id="<?php 
            echo $this->Get_Field_Id('thumb_width');
            ?>
" value="<?php 
            echo HTMLSpecialChars($this->Get_Option('thumb_width'));
            ?>
" size="4" />px
    </p>

    <p>
      <label for="<?php 
            echo $this->Get_Field_Id('thumb_height');
            ?>
"><?php 
            echo $this->t('Thumbnail height:');
            ?>
</label>
      <input type="text" name="<?php 
            echo $this->get_field_name('thumb_height');
            ?>
" id="<?php 
            echo $this->Get_Field_Id('thumb_height');
            ?>
" value="<?php 
            echo HTMLSpecialChars($this->Get_Option('thumb_height'));
            ?>
" size="4" />px
    </p>

    <p>
      <input type="checkbox" name="<?php 
            echo $this->get_field_name('thumb_grayscale');
            ?>
" id="<?php 
            echo $this->Get_Field_Id('thumb_grayscale');
            ?>
" value="yes" <?php 
            Checked($this->Get_Option('thumb_grayscale'), 'yes');
            ?>
 />
      <label for="<?php 
            echo $this->Get_Field_Id('thumb_grayscale');
            ?>
"><?php 
            echo $this->t('Convert thumbnails to grayscale.');
            ?>
</label>
    </p>

    <p>
      <input type="checkbox" name="<?php 
            echo $this->get_field_name('thumb_negate');
            ?>
" id="<?php 
            echo $this->Get_Field_Id('thumb_negate');
            ?>
" value="yes" <?php 
            Checked($this->Get_Option('thumb_negate'), 'yes');
            ?>
 />
      <label for="<?php 
            echo $this->Get_Field_Id('thumb_negate');
            ?>
"><?php 
            echo $this->t('Negate the thumbnails.');
            ?>
</label>
    </p>

    <p>
      <label for="<?php 
            echo $this->get_field_id('exclude');
            ?>
"><?php 
            _e('Exclude:');
            ?>
</label>
      <input type="text" value="<?php 
            echo HTMLSpecialChars($this->get_option('exclude'));
            ?>
" name="<?php 
            echo $this->get_field_name('exclude');
            ?>
" id="<?php 
            echo $this->get_field_id('exclude');
            ?>
" class="widefat" /><br />
      <small><?php 
            echo $this->t('Term IDs, separated by commas.');
            ?>
</small>
    </p>

    <h3><?php 
            echo $this->t('Template');
            ?>
</h3>
    <p><?php 
            echo $this->t('Please choose a template to display this widget.');
            ?>
</p>
    <?php 
            foreach ($this->fancy_gallery->Get_Template_Files() as $name => $properties) {
                ?>
    <p>
      <input type="radio" name="<?php 
                echo $this->get_field_name('template');
                ?>
" id="<?php 
                echo Sanitize_Title($properties['file']);
                ?>
" value="<?php 
                echo HTMLSpecialChars($properties['file']);
                ?>
"
        <?php 
                Checked($this->Get_Option('template'), $properties['file']);
                ?>
        <?php 
                Checked(!$this->Get_Option('template') && $properties['file'] == $this->fancy_gallery->Get_Default_Template());
                ?>
 />
      <label for="<?php 
                echo Sanitize_Title($properties['file']);
                ?>
">
      <?php 
                if (empty($properties['name'])) {
                    ?>
        <em><?php 
                    echo $properties['file'];
                    ?>
</em>
      <?php 
                } else {
                    ?>
        <strong><?php 
                    echo $properties['name'];
                    ?>
</strong>
      <?php 
                }
                ?>
      </label>
      <?php 
                if ($properties['description']) {
                    ?>
<br /><?php 
                    echo $properties['description'];
                }
                ?>
    </p>
    <?php 
            }
        }
" id="excerpt_template_<?php 
    echo Sanitize_Title($properties['file']);
    ?>
" value="<?php 
    echo HTMLSpecialChars($properties['file']);
    ?>
"
      <?php 
    Checked($this->Get_Gallery_Meta('excerpt_template'), $properties['file']);
    ?>
      <?php 
    Checked(!$this->Get_Gallery_Meta('excerpt_template') && $properties['file'] == $this->Get_Default_Template());
    ?>
 />
    <label for="excerpt_template_<?php 
    echo Sanitize_Title($properties['file']);
    ?>
">
    <?php 
    if (empty($properties['name'])) {
        ?>
      <em><?php 
        echo $properties['file'];
        ?>
</em>
    <?php 
    } else {
        ?>
      <strong><?php 
        echo $properties['name'];
        ?>
Esempio n. 5
0
 public function Build_Gallery($arr_images, $attributes)
 {
     # Prepare Gallery Array
     $this->gallery = (object) array('attributes' => (object) $attributes, 'images' => array());
     # Generate Gallery HTML ID
     if (!empty($attributes['post_parent'])) {
         # this gallery uses the post attachments
         $this->gallery->id = $attributes['post_parent'];
     } else {
         # this gallery only includes images
         $this->gallery->id = Sanitize_Title($attributes['include']);
     }
     # Build the Gallery object
     foreach ($arr_images as $id => &$image) {
         # Thumb URL, width, height
         list($src, $width, $height) = WP_Get_Attachment_Image_Src($image->ID, $attributes['size']);
         $image->width = $width;
         $image->height = $height;
         $image->src = $src;
         $image->title = $image->post_title;
         $image->caption = $image->post_excerpt;
         $image->description = $image->post_content;
         $image->class = 'attachment-' . $attributes['size'];
         # Image Link
         if (empty($image->href)) {
             $image->href = WP_Get_Attachment_URL($image->ID);
         }
         # Run filter
         $image->attributes = Apply_Filters('wp_get_attachment_image_attributes', array('src' => $image->src, 'width' => $image->width, 'height' => $image->height, 'class' => $image->class, 'alt' => $image->title, 'title' => $image->title), $image);
         # Write in Object
         $this->gallery->images[] = $image;
     }
 }
 function Enqueue_Frontend_Scripts()
 {
     WP_Enqueue_Script('jquery.mousewheel', $this->base_url . '/js/jquery.mousewheel.js', array('jquery'), '3.0.6', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox', $this->base_url . '/fancybox/jquery.fancybox.js', array('jquery'), '2.1.4', $this->get_option('script_position') != 'header');
     WP_Enqueue_Style('fancybox', $this->base_url . '/fancybox/fancybox.css', Null, '2.1.4');
     WP_Enqueue_Script('fancybox-buttons', $this->base_url . '/fancybox/jquery.fancybox-buttons.js', array('jquery', 'fancybox'), '1.0.5', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox-media', $this->base_url . '/fancybox/jquery.fancybox-media.js', array('jquery', 'fancybox'), '1.0.5', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancybox-thumbs', $this->base_url . '/fancybox/jquery.fancybox-thumbs.js', array('jquery', 'fancybox'), '1.0.7', $this->get_option('script_position') != 'header');
     WP_Enqueue_Script('fancy-gallery', $this->base_url . '/js/fancy-gallery.js', array('jquery', 'fancybox'), $this->version, $this->get_option('script_position') != 'header');
     // Add image descriptions as title if required
     if ($this->get_option('use_as_image_title') == 'description') {
         // Collect image titles
         $arr_image_titles = array();
         foreach (Get_Posts(array('post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'order' => 'ASC', 'orderby' => 'ID')) as $i => $image) {
             $arr_image_titles[$image->ID] = $this->get_image_title($image);
         }
         // Add image title to the images
         WP_Localize_Script('fancy-gallery', 'IMAGETITLES', $arr_image_titles);
     }
     // Add the plugin options to the JS front end
     $arr_options = $this->Get_Option();
     unset($arr_options['disable_update_notification']);
     unset($arr_options['update_username']);
     unset($arr_options['update_password']);
     WP_Localize_Script('fancy-gallery', 'FANCYGALLERY', $arr_options);
     // Enqueue Template Stylesheets
     foreach ($this->Get_Template_Files() as $template_name => $template_properties) {
         $style_sheet_name = BaseName($template_properties['file'], '.php') . '.css';
         $style_sheet_file = DirName($template_properties['file']) . '/' . $style_sheet_name;
         if (!Is_File($style_sheet_file)) {
             continue;
         }
         $template_dir = DirName($style_sheet_file);
         $style_sheet_id = 'fancy-gallery-template-' . Sanitize_Title($template_name);
         $template_base_url = Get_Bloginfo('wpurl') . '/' . SubStr($template_dir, Strlen(ABSPATH));
         $template_base_url = Str_Replace("\\", '/', $template_base_url);
         // Windows workaround
         WP_Enqueue_Style($style_sheet_id, $template_base_url . '/' . $style_sheet_name);
     }
 }