예제 #1
0
 function __construct()
 {
     maxCollections::checkExpireTrans();
     foreach ($this->uses_blocks as $block_name) {
         $block = maxCollections::getBlock($block_name);
         if ($block) {
             $block->setCollection($this);
             $block->set(array());
             // defaults
             $this->blocks[$block_name] = $block;
         }
     }
 }
예제 #2
0
 static function setupHooks()
 {
     global $wpdb;
     $table = maxUtils::get_collection_table_name();
     $sql = "select collection_id, collection_key, collection_value from {$table} where \n\t\t\t\t collection_key in ('show_homepage','show_page','show_post', 'show_archive') ";
     $results = $wpdb->get_results($sql, ARRAY_A);
     $hook_array = array();
     foreach ($results as $result) {
         $id = $result["collection_id"];
         $key = $result["collection_key"];
         $placement = $result["collection_value"];
         // override - if needed you can specify a different placement for each position
         $placement = apply_filters("mb-collection-{$id}-{$key}-placement", $placement);
         switch ($placement) {
             case "after":
             case "before":
             case "after-before":
                 $show_type = "post";
                 // show on the post loop
                 break;
             case "static-left":
             case "static-right":
             case "static-top":
             case "static-bottom":
                 $show_type = "once";
                 // show once - otherwise for overviews they will be many static buttons.
                 break;
         }
         $hook_array[$show_type][$key][] = array("collection_id" => $id, "placement" => $placement);
     }
     self::$hooks = $hook_array;
     if (isset($hook_array["post"]) && count($hook_array["post"]) > 0) {
         add_filter("the_content", array('maxCollections', "doContentHooks"));
     }
     if (isset($hook_array["once"]) && count($hook_array["once"]) > 0) {
         //self::doFooterHooks(); // the stuff that goes once.
         add_action('wp_head', array('maxCollections', 'doFooterHooks'));
     }
     if (count($hook_array) > 0) {
         return true;
     } else {
         return false;
     }
     // no binds, don't check.
 }
_e("Removing this collection", "maxbuttons");
?>
</span>
<span class="remove_action_text"  style="display:none"><?php 
_e("Are you sure you want to permanently delete this collection?", "maxbuttons");
?>
</span>


<div class='collection_list'>
<?php 
foreach ($collections as $index => $data) {
    $id = $data["collection_id"];
    $name = $maxCol->get_meta($id, "collection_name");
    $name = $name["collection_name"];
    $collection = maxCollections::getCollectionById($id);
    $collection_type = $collection->getType();
    $block_nonce = wp_create_nonce('mbpro_collection_block-' . $id);
    $button_count = 0;
    $picker = $collection->getBlock("picker");
    if ($picker) {
        $picker_data = $picker->get();
        $button_count = count($picker_data["selection"]);
    }
    ?>
	
	 
	<div class='collection collection-<?php 
    echo $id;
    ?>
' data-id="<?php 
 public function collection_shortcode($atts, $content = null)
 {
     $atts = shortcode_atts(array("id" => 0, "name" => '', "nocache" => false, "mode" => "normal"), $atts);
     $id = intval($atts["id"]);
     $name = sanitize_text_field($atts["name"]);
     if ($id > 0) {
         $collection = maxCollections::getCollectionByID($id);
     } elseif ($atts["name"] != '') {
         $collection = maxCollections::getCollectionByName($name);
     }
     if ($collection) {
         return $collection->shortcode($atts, $content);
     }
 }