Exemplo n.º 1
0
        $upload_size_unit = wp_max_upload_size();
        for ($u = -1; $upload_size_unit > 1024 && $u < count($sizes) - 1; $u++) {
            $upload_size_unit /= 1024;
        }
        // If the upload size is 0, disable uploading, otherwise allow uploading to continue.
        if ($u < 0) {
            $upload_size_unit = 0;
            $u = 0;
        } else {
            $upload_size_unit = (int) $upload_size_unit;
        }
        return 'unit' == $type ? $u : $upload_size_unit;
    }
    /**
     * Returns the singleton instance of the class.
     *
     * @since 1.0.0
     *
     * @return object The HW_Gallery_Media_Lite object.
     */
    public static function get_instance()
    {
        if (!isset(self::$instance) && !self::$instance instanceof HW_Gallery_Media_Lite) {
            self::$instance = new HW_Gallery_Media_Lite();
        }
        return self::$instance;
    }
}
// Load the media class.
$hw_gallery_media_lite = HW_Gallery_Media_Lite::get_instance();
Exemplo n.º 2
0
    /**
     * Callback for displaying the UI for main images tab.
     *
     * @since 1.0.0
     *
     * @param object $post The current post object.
     */
    public function images_tab($post)
    {
        ?>

        <?php 
        // Output the custom media upload form.
        HW_Gallery_Media_Lite::get_instance()->media_upload_form();
        // Prepare output data.
        $gallery_data = get_post_meta($post->ID, '_eg_gallery_data', true);
        ?>
        <ul id="hw-gallery-output" class="hw-gallery-clear">
            <?php 
        if (!empty($gallery_data['gallery'])) {
            ?>
                <?php 
            foreach ($gallery_data['gallery'] as $id => $data) {
                ?>
                    <?php 
                echo $this->get_gallery_item($id, $data, $post->ID);
                ?>
                <?php 
            }
            ?>
            <?php 
        }
        ?>
        </ul>
        <?php 
        $this->media_library($post);
    }