示例#1
0
文件: Ajax.php 项目: wir/WP-Tiles
 public function get_posts()
 {
     $query = $_POST['query'];
     $hash = $this->get_query_hash($query);
     check_ajax_referer($hash);
     // $query is signed by nonce
     $wp_query = new \WP_Query($query);
     $posts = $wp_query->posts;
     if (!$posts) {
         exit('-1');
     }
     $posted_opts = $_POST['opts'];
     $opts = array('hide_title' => $this->_bool($posted_opts['hide_title']), 'link' => in_array($posted_opts['link'], array('post', 'file', 'thickbox', 'none')) ? $posted_opts['link'] : wp_tiles()->options->get_option('link'), 'byline_template' => wp_kses_post($posted_opts['byline_template']), 'byline_template_textonly' => $this->_bool($posted_opts['byline_template_textonly']), 'images_only' => $this->_bool($posted_opts['images_only']), 'image_size' => $posted_opts['image_size'], 'text_only' => $this->_bool($posted_opts['text_only']), 'link_new_window' => $this->_bool($posted_opts['link_new_window']));
     ob_start();
     wp_tiles()->render_tile_html($posts, $opts);
     $html = ob_get_contents();
     ob_end_clean();
     $ret = array('tiles' => $html);
     $max_page = $wp_query->max_num_pages;
     $next_page = intval($wp_query->get('paged')) + 1;
     // Is there another page?
     if ($next_page <= $max_page) {
         $ret['has_more'] = true;
         $query['paged'] = $next_page;
         $ret['_ajax_nonce'] = $this->get_query_nonce($query);
     } else {
         $ret['has_more'] = false;
     }
     $this->_return($ret);
 }
示例#2
0
 /**
  * Show the posts in the current query.
  *
  * Can be used to replace the loop.
  *
  * @param array (optional) $opts
  * @since 0.4.2
  */
 function the_loop_wp_tiles($opts = array())
 {
     if (WPTiles\Legacy::maybe_process_shortcode($opts)) {
         $opts = WPTiles\Legacy::convert_option_array($opts);
     }
     global $wp_query;
     wp_tiles()->display_tiles($wp_query, $opts);
 }
示例#3
0
 public static function get_options($original_atts)
 {
     $defaults = wp_tiles()->options->get_options();
     $atts = shortcode_atts(array('grids' => $defaults['grids'], 'grid' => false, 'colors' => $defaults['colors'], 'background_opacity' => $defaults['background_opacity'], 'grid_selector_color' => $defaults['grid_selector_color'], 'breakpoint' => $defaults['breakpoint'], 'small_screen_grid' => $defaults['small_screen_grid'], 'byline_template' => $defaults['byline_template'], 'byline_template_textonly' => $defaults['byline_template_textonly'], 'byline_opacity' => $defaults['byline_opacity'], 'byline_color' => $defaults['byline_color'], 'byline_height' => $defaults['byline_height'], 'byline_height_auto' => $defaults['byline_height_auto'], 'byline_align' => $defaults['byline_align'], 'byline_effect' => $defaults['byline_effect'], 'image_effect' => $defaults['image_effect'], 'text_color' => $defaults['text_color'], 'image_text_color' => $defaults['image_text_color'], 'link' => $defaults['link'], 'link_new_window' => $defaults['link_new_window'], 'text_only' => $defaults['text_only'], 'images_only' => $defaults['images_only'], 'hide_title' => $defaults['hide_title'], 'image_size' => $defaults['image_size'], 'image_source' => $defaults['image_source'], 'padding' => $defaults['padding'], 'animated' => true, 'animate_init' => $defaults['animate_init'], 'animate_resize' => $defaults['animate_resize'], 'animate_template' => $defaults['animate_template'], 'pagination' => $defaults['pagination'], 'extra_classes' => $defaults['extra_classes'], 'extra_classes_grid_selector' => $defaults['extra_classes_grid_selector'], 'full_width' => $defaults['full_width']), $original_atts);
     if ($atts['grid']) {
         $atts['grids'] = array('Custom' => wp_tiles()->format_grid($atts['grid']));
     }
     // Maybe convert full grid strings into grids so they are not interpreted as names
     if ($atts['small_screen_grid'] && self::_is_grid_string($atts['small_screen_grid'])) {
         $atts['small_screen_grid'] = array('Custom' => wp_tiles()->format_grid($atts['small_screen_grid']));
     }
     $grid_names = self::_get_options_array($atts['grids']);
     $options = array('grids' => $grid_names, 'small_screen_grid' => $atts['small_screen_grid'], 'breakpoint' => (int) $atts['breakpoint'], 'colors' => self::_get_colors($atts['colors']), 'background_opacity' => (double) $atts['background_opacity'], 'grid_selector_color' => $atts['grid_selector_color'], 'byline_template' => $atts['byline_template'], 'byline_template_textonly' => $atts['byline_template_textonly'], 'byline_opacity' => (double) $atts['byline_opacity'], 'byline_color' => $atts['byline_color'], 'byline_height' => (int) $atts['byline_height'], 'byline_height_auto' => wp_tiles()->options->boolean($atts['byline_height_auto']), 'byline_align' => $atts['byline_align'], 'byline_effect' => $atts['byline_effect'], 'image_effect' => $atts['image_effect'], 'text_color' => $atts['text_color'], 'image_text_color' => $atts['image_text_color'], 'link' => $atts['link'], 'link_new_window' => $atts['link_new_window'], 'text_only' => wp_tiles()->options->boolean($atts['text_only']), 'images_only' => wp_tiles()->options->boolean($atts['images_only']), 'hide_title' => wp_tiles()->options->boolean($atts['hide_title']), 'image_source' => $atts['image_source'], 'image_size' => $atts['image_size'], 'padding' => (int) $atts['padding'], 'extra_classes' => self::_get_options_array($atts['extra_classes']), 'extra_classes_grid_selector' => self::_get_options_array($atts['extra_classes_grid_selector']), 'animate_init' => $atts['animated'] && $atts['animate_init'], 'animate_resize' => $atts['animated'] && $atts['animate_resize'], 'animate_template' => $atts['animated'] && $atts['animate_template'], 'pagination' => $atts['pagination'], 'full_width' => $atts['full_width']);
     if ($atts['breakpoint']) {
         $options['small_screen_grid'] = $atts['small_screen_grid'];
         $options['breakpoint'] = (int) $atts['breakpoint'];
     }
     return $options;
 }
示例#4
0
文件: Options.php 项目: wir/WP-Tiles
 public function get_options()
 {
     static $options = false;
     if (!$options) {
         $options = array();
         $defaults = $this->get_defaults();
         foreach ($defaults as $option => $default) {
             $value = $this->get_option($option, false);
             $options[$option] = is_null($value) ? $default : $value;
         }
         // @todo Cache results?
         $options['grids'] = wp_tiles()->get_grids($options['default_grid']);
         $small_screen_grids = wp_tiles()->get_grids($options['small_screen_grid']);
         $options['small_screen_grid'] = end($small_screen_grids);
         $colors = array();
         for ($i = 1; $i <= 5; $i++) {
             $color = $this->get_option('color_' . $i);
             if ($color) {
                 $colors[] = $color;
             }
         }
         $options['colors'] = Helper::colors_to_rgba($colors);
         if (empty($options['byline_color'])) {
             $options['byline_color'] = 'random';
         }
         $options['byline_color'] = $this->get_byline_color($options);
         if (!$this->get_option('byline_for_text_only')) {
             $options['byline_template_textonly'] = false;
         }
         // Disable individual animations when disabled globally
         if (!$this->get_option('animated')) {
             foreach (array('animate_init', 'animate_resize', 'animate_template') as $a) {
                 $options[$a] = false;
             }
         }
     }
     return $options;
 }
示例#5
0
if (!defined('VP_VERSION')) {
    require plugin_dir_path(__FILE__) . 'vafpress-framework/bootstrap.php';
}
require WP_TILES_DIR . 'vendor/autoload.php';
/**
 * Backward compat
 */
if (get_option('wp-tiles-options') !== 'legacy') {
    add_action('init', array('WPTiles\\Legacy', 'convert_options'), 1);
}
/**
 * Get the one and only true instance of WP Tiles
 *
 * @return WPTiles\WPTiles
 * @since 0.4.2
 */
function wp_tiles()
{
    return \WPTiles\WPTiles::get_instance();
}
// Initialize
wp_tiles();
add_action('plugins_loaded', 'wptiles_load_pluggables');
function wptiles_load_pluggables()
{
    require_once WP_TILES_DIR . '/wp-tiles-pluggables.php';
}
function wp_tiles_preview_tile()
{
    return WPTiles\Admin\Admin::preview_tile();
}
示例#6
0
文件: Admin.php 项目: wir/WP-Tiles
    public static function preview_tile($atts = array())
    {
        if (defined('DOING_AJAX') && DOING_AJAX && isset($_POST['params']) && count($_POST['params']) === 8) {
            $atts = array_combine(array('byline_height_auto', 'byline_height', 'byline_color', 'byline_opacity', 'byline_align', 'byline_effect', 'image_effect', 'image_text_color'), $_POST['params']);
            // Sanitize!
            $atts['byline_height'] = (int) $atts['byline_height'];
            if ('random' == $atts['byline_color'] || empty($atts['byline_color'])) {
                $atts['byline_color'] = wp_tiles()->options->get_option('color_1');
            }
            $atts['byline_opacity'] = (double) $atts['byline_opacity'];
            $atts['byline_align'] = 'top' == $atts['byline_align'] ? 'top' : 'bottom';
            $atts['id'] = 'tile-ajax-preview';
        } else {
            $atts = shortcode_atts(array('byline_height_auto' => wp_tiles()->options->get_option('byline_height_auto'), 'byline_height' => wp_tiles()->options->get_option('byline_height'), 'byline_color' => wp_tiles()->options->get_option('byline_color'), 'byline_opacity' => wp_tiles()->options->get_option('byline_opacity'), 'byline_align' => wp_tiles()->options->get_option('byline_align'), 'byline_effect' => wp_tiles()->options->get_option('byline_effect'), 'image_effect' => wp_tiles()->options->get_option('image_effect'), 'image_text_color' => wp_tiles()->options->get_option('image_text_color'), 'id' => 'tile-preview'), $atts);
        }
        $id = $atts['id'];
        $byline_height_auto = wp_tiles()->options->boolean($atts['byline_height_auto']);
        $byline_height = $atts['byline_height'];
        $byline_color = Helper::hex_to_rgba($atts['byline_color'], $atts['byline_opacity'], true);
        $byline_align = $atts['byline_align'];
        $byline_effect = $atts['byline_effect'];
        $image_effect = $atts['image_effect'];
        $image_text_color = $atts['image_text_color'];
        /**
         * ANIMATION CLASSES
         */
        $classes = array('wp-tiles-byline-align-' . $byline_align);
        if (!empty($byline_effect) && in_array($byline_effect, wp_tiles()->options->get_allowed_byline_effects())) {
            $classes = array_merge($classes, array('wp-tiles-byline-animated', 'wp-tiles-byline-' . $byline_effect));
        }
        if (!empty($image_effect) && in_array($image_effect, wp_tiles()->options->get_allowed_image_effects())) {
            $classes = array_merge($classes, array('wp-tiles-image-animated', 'wp-tiles-image-' . $image_effect));
        }
        ob_start();
        ?>
        <div class="wp-tiles-container wp-tiles-tile-demo wp-tiles-loaded" id="<?php 
        echo $id;
        ?>
">

            <div id="wp_tiles_1" class="wp-tiles-grid <?php 
        echo implode(' ', $classes);
        ?>
">

                <div class="wp-tiles-tile" id="tile-1">

                    <a href="javascript:void(0)" title="Animation Demo">

                        <article class="wp-tiles-tile-with-image wp-tiles-tile-wrapper" itemscope itemtype="http://schema.org/CreateWork">

                            <div class="wp-tiles-tile-bg"></div>

                            <div class="wp-tiles-byline">

                                <h4 itemprop="name" class="wp-tiles-byline-title"><?php 
        _e('Byline Preview', 'wp-tiles');
        ?>
</h4>

                                <div class="wp-tiles-byline-content" itemprop="description">
                                    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in...
                                </div>

                            </div>

                        </article>

                    </a>
                </div>

            </div>

        </div>
        <style>
            #<?php 
        echo $id;
        ?>
 .wp-tiles-byline {
                background: <?php 
        echo $byline_color;
        ?>
;
                <?php 
        if ($byline_height_auto) {
            ?>
max-<?php 
        }
        ?>
height: <?php 
        echo $byline_height;
        ?>
%;
                <?php 
        if ($image_text_color) {
            ?>
color: <?php 
            echo $image_text_color;
            ?>
;<?php 
        }
        ?>
            }
        </style>
        <?php 
        $ret = ob_get_contents();
        ob_end_clean();
        return $ret;
    }
示例#7
0
文件: Gallery.php 项目: wir/WP-Tiles
 public function do_gallery($atts)
 {
     $post = get_post();
     $gallery_atts = shortcode_atts(array('order' => 'ASC', 'orderby' => 'menu_order ID', 'id' => $post ? $post->ID : 0, 'include' => '', 'exclude' => ''), $atts, 'gallery');
     $id = intval($gallery_atts['id']);
     $order = $gallery_atts['order'];
     $orderby = $gallery_atts['orderby'];
     $include = $gallery_atts['include'];
     $exclude = $gallery_atts['exclude'];
     if ('RAND' == $order) {
         $orderby = 'none';
     }
     if (!empty($include)) {
         $_attachments = get_posts(array('include' => $include, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
         $attachments = array();
         foreach ($_attachments as $key => $val) {
             $attachments[$val->ID] = $_attachments[$key];
         }
     } elseif (!empty($exclude)) {
         $attachments = get_children(array('post_parent' => $id, 'exclude' => $exclude, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     } else {
         $attachments = get_children(array('post_parent' => $id, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => $order, 'orderby' => $orderby));
     }
     // Set Gallery specific defaults
     $link = wp_tiles()->options->get_option('link');
     if (class_exists('No_Jetpack_Carousel') || class_exists('Jetpack_Carousel') && !apply_filters('jp_carousel_maybe_disable', false)) {
         $link = 'carousel';
     }
     $atts = wp_parse_args($atts, array('byline_template' => '<h4 class="wp-tiles-byline-title">%excerpt%</h4>', 'hide_title' => 'true', 'link' => $link));
     if ('attachment' == $atts['link']) {
         $atts['link'] = 'post';
     }
     // Get rest of shortcode options
     $options = Shortcode::get_options($atts);
     $ret = wp_tiles()->get_tiles($attachments, $options);
     return $ret;
 }
示例#8
0
 public static function on_plugin_activation()
 {
     wp_tiles()->register_post_type();
     Admin\GridTemplates::install_default_templates();
 }
示例#9
0
文件: Legacy.php 项目: wir/WP-Tiles
 public static function get_options($atts_array)
 {
     return shortcode_atts(wp_tiles()->options->get_options(), self::convert_option_array($atts_array));
 }
示例#10
0
文件: Controls.php 项目: wir/WP-Tiles
 public static function tile_designer()
 {
     return array(array('type' => 'color', 'name' => 'byline_color', 'label' => __('Byline Background Color', 'wp-tiles'), 'description' => __('To use the same set of colors as the tiles without text, leave this option empty.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_color'), 'format' => 'hex'), array('type' => 'slider', 'name' => 'byline_opacity', 'label' => __('Byline Opacity (0 to 1)', 'wp-tiles'), 'description' => __('Set the opacity for the background of the byline on top of the image. 0 is completely transparent, 1 fully opaque.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_opacity'), 'min' => '0', 'max' => '1', 'step' => '0.01'), array('type' => 'toggle', 'name' => 'byline_height_auto', 'label' => __('Automatic Byline Height?', 'wp-tiles'), 'description' => __('Should the height of the byline be determined by its content?', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_height_auto')), array('type' => 'slider', 'name' => 'byline_height', 'label' => __('Byline Height (%)', 'wp-tiles'), 'description' => __('Set the height of the byline on image tiles. 100% means fully covered, 0% means invisible. If byline height is set to auto, this is the maximum height.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_height'), 'min' => '0', 'max' => '100', 'step' => '1'), array('type' => 'radiobutton', 'name' => 'byline_effect', 'label' => __('Byline Effect', 'wp-tiles'), 'description' => __('Select the effect you want to use for the byline to appear when you hover over the tile.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_effect'), 'items' => apply_filters('wp_tiles_byline_effect_items', array(array('label' => __('None', 'wp-tiles'), 'value' => 'none'), array('label' => __('Slide Up', 'wp-tiles'), 'value' => 'slide-up'), array('label' => __('Slide Down', 'wp-tiles'), 'value' => 'slide-down'), array('label' => __('Slide Left', 'wp-tiles'), 'value' => 'slide-left'), array('label' => __('Slide Right', 'wp-tiles'), 'value' => 'slide-right'), array('label' => __('Fade In', 'wp-tiles'), 'value' => 'fade-in')))), array('type' => 'radiobutton', 'name' => 'byline_align', 'label' => __('Byline Vertical Alignment', 'wp-tiles'), 'description' => __('Align the byline to the top or bottom of the tile. Nb. This option has no effect if slide effect is up or down, or if tile is 100% high.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('byline_align'), 'items' => array(array('label' => __('Top', 'wp-tiles'), 'value' => 'top'), array('label' => __('Bottom', 'wp-tiles'), 'value' => 'bottom'))), array('type' => 'radiobutton', 'name' => 'image_effect', 'label' => __('Image Effect', 'wp-tiles'), 'description' => __('Select the effect you want to use for the image when you hover over the tile.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('image_effect'), 'items' => apply_filters('wp_tiles_image_effect_items', array(array('label' => __('None', 'wp-tiles'), 'value' => 'none'), array('label' => __('Scale Up', 'wp-tiles'), 'value' => 'scale-up'), array('label' => __('Scale Down', 'wp-tiles'), 'value' => 'scale-down'), array('label' => __('Saturate', 'wp-tiles'), 'value' => 'saturate'), array('label' => __('Desaturate', 'wp-tiles'), 'value' => 'desaturate'), array('label' => __('Color Overlay', 'wp-tiles'), 'value' => 'color-overlay')))), array('type' => 'color', 'name' => 'image_text_color', 'label' => __('Text Color Image Tiles', 'wp-tiles'), 'description' => __('Select the color for text on tiles with background image', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('image_text_color'), 'format' => 'hex'), array('type' => 'color', 'name' => 'text_color', 'label' => __('Text Color Text-Only Tiles', 'wp-tiles'), 'description' => __('Select the color for text on tiles without background image', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('text_color'), 'format' => 'hex'), array('type' => 'toggle', 'name' => 'legacy_styles', 'label' => __('Use Legacy (pre-1.0) Styles', 'wp-tiles'), 'description' => __('Check this box to enable the old CSS styles for WP Tiles. Not recommended, unless you need to ensure compatibility with your own custom styles from the pre-1.0 era.', 'wp-tiles'), 'default' => wp_tiles()->options->get_defaults('legacy_styles')));
 }
示例#11
0
<?php

// Experimental Features - include into your theme manually
/**
 * Use WP Tiles instead of header image - tested on TwentyTwelve
 */
add_filter('theme_mod_header_image', function () {
    wp_tiles()->display_tiles(array('posts_per_page' => 9, 'post_type' => 'page'), array('padding' => 0, 'grids' => array('Mixed'), 'pagination' => false));
    return 'remove-header';
});
示例#12
0
 public static function get_default_template()
 {
     return wp_tiles()->format_grid(self::$_default_template);
 }