Plugin Directory

Changeset 1410266


Ignore:
Timestamp:
05/04/2016 11:18:01 AM (10 years ago)
Author:
bortpress
Message:

0.0.1.4
Made the plugin easier to cache and fixed a major bug with including or excluding specific post IDs

Location:
cactus-masonry-plus
Files:
12 added
2 edited

Legend:

Unmodified
Added
Removed
  • cactus-masonry-plus/trunk/cactusMasonry.php

    r1406363 r1410266  
    22/**
    33 * @package Cactus Masonry Plus
    4  * @version 0.0.1.3
     4 * @version 0.0.1.4
    55 */
    66/*
     
    88 * Plugin URI: cactus.cloud
    99 * Description: A highly customizable gallery of post thumbnails.
    10  * Version: 0.0.1.3
     10 * Version: 0.0.1.4
    1111 * Author: cactus.cloud
    1212 * Author URI: http://cactus.cloud/masonryplus
     
    3434   
    3535    private static $a = null;
     36    private static $VERSION = "0.0.1.3";
    3637   
    3738    static public function init() {     
    3839        add_shortcode("cactusMasonry", array(__CLASS__, "cactus_masonry_shortcode_handler"));
    3940        add_shortcode("cactusmasonry", array(__CLASS__, "cactus_masonry_shortcode_handler"));
    40         add_action("wp_enqueue_scripts", array(__CLASS__, "cactus_masonry_scripts"));
     41        add_action("wp_enqueue_scripts", array(__CLASS__, "cactus_masonry_scripts"), 42);
    4142        //ADD JQUERY TO HEAD
    4243        $plugin = plugin_basename(__FILE__);
     
    4546
    4647    static public function cactus_masonry_scripts() {
    47         wp_enqueue_script('jquery');       
     48        if(!wp_script_is("jquery", "enqueued") || !wp_script_is("jquery", "registered")) wp_enqueue_script("jquery", includes_url() . 'js/jquery/jquery.js', array(), false, true);     
     49        wp_enqueue_script('cactusBrickScript', plugin_dir_url(__FILE__) . 'cactusBrick.min.js', array('jquery'), self::$VERSION, true);
     50        wp_enqueue_script('cactusGalleryScript', plugin_dir_url(__FILE__) . 'cactusGallery.min.js', array('jquery', 'cactusBrickScript'), self::$VERSION, true);
     51        wp_enqueue_script('cactusMasonryPlusScript', plugin_dir_url(__FILE__) . 'cactusMasonryPlus.min.js', array('jquery', 'cactusBrickScript', 'cactusGalleryScript'), self::$VERSION, true);
     52        wp_enqueue_style('cactusMasonryPlusStyle', plugin_dir_url(__FILE__) . 'style.css');     
    4853    }
    4954   
     
    5762   
    5863    static public function cactus_masonry_shortcode_handler($atts) {
    59         wp_enqueue_script('cactusBrickScript', plugin_dir_url(__FILE__) . 'cactusBrick.min.js');
    60         wp_enqueue_script('cactusGalleryScript', plugin_dir_url(__FILE__) . 'cactusGallery.min.js');
    61         wp_enqueue_script('cactusMasonryPlusScript', plugin_dir_url(__FILE__) . 'cactusMasonryPlus.min.js');
    62         wp_enqueue_style('cactusMasonryPlusStyle', plugin_dir_url(__FILE__) . 'style.css');
    6364        //Accept input parameters
    6465        $defaultAtts = array(
    6566            //JS
    66             'id'                        =>  "cactus",
     67            'id'                        =>  "cactus" . mt_rand(10000,99999),
    6768           
    6869            //Functionality
     
    177178        }
    178179
    179         $ids_in = self::parse_csv(self::$a["includedpostids"]);
    180         $ids_out = self::parse_csv(self::$a["excludedpostids"]);
    181180       
    182181        $args = array(  "posts_per_page"    => self::$a["pagesize"],
     
    184183                        "offset"            => self::$a["offset"],
    185184                        "category_name"     => self::$a["categoryslug"],
    186                         "meta_query"        => $meta);
     185                        "meta_query"        => $meta
     186                    );
    187187                       
    188188        //Get included ids
    189         if(count($ids_in) > 0) $args['posts__in'] = $ids_in;
    190         if(count($ids_out) > 0) $args['posts__not_in'] = $ids_out;
    191        
     189        if(self::parse_csv(self::$a["includedpostids"]) != "") {
     190            $ids_in = self::parse_csv(self::$a["includedpostids"]);
     191            if($ids_in[0] != "") $args['post__in'] = $ids_in;
     192        }
     193        if(self::parse_csv(self::$a["excludedpostids"])) {
     194            $ids_out = self::parse_csv(self::$a["excludedpostids"]);
     195            if($ids_out[0] != "") $args['post__not_in'] = $ids_out;
     196        }
    192197        $args['meta_key'] = self::$a["metakey"];
    193198       
     
    206211               
    207212        $the_query = new WP_Query($args);
     213       
     214        //DEBUG echo "<p>REQUEST:$the_query->request</p>";
    208215        //For each post:
    209216       
     
    218225            //Set up main JS
    219226            $o .= "<script>";
    220             $o .= "jQuery(document).on(\"ready\", function() {";
     227            $o .= "document.addEventListener(\"DOMContentLoaded\", function() {";
    221228            $o .= "var cmp{$id} = new CactusMasonryPlus();";
    222229            $o .= "cmp{$id}.margin = " . (self::$a['margin']/2) . ";";
  • cactus-masonry-plus/trunk/readme.txt

    r1406399 r1410266  
    55Requires at least: 4.4.2
    66Tested up to: 4.5.1
    7 Stable tag: 0.0.1.3
     7Stable tag: 0.0.1.4
    88License: GNU AGPLv3
    99License URI: http://cactus.cloud/licenses/agpl-3.0.txt
     
    4646
    4747== Changelog ==
     48= 0.0.1.4 =
     49* Fixed a major bug that prevented the 'includedPostIds' and 'excludedPostIds' parameters from functioning
     50* Improved the efficiency of the plugin's filtering of the 'includedPostIds' and 'excludedPostIds' parameters when empty
     51* Moved script tags to the footer for content prioritized page loading and to improve SEO
     52
    4853= 0.0.1.3 =
    4954* Updated WordPress repository tags
     
    6974
    7075== Upgrade Notice ==
    71 
     76= 0.0.1.4 =
     77* Fixed a major bug with included/excluded IDs and made caching easier
    7278
    7379
Note: See TracChangeset for help on using the changeset viewer.