| 1 |
<?php |
| 2 |
defined('ABSPATH') or die('No direct access permitted'); |
| 3 |
$collectionBlock["basic"] = "basicCollectionBlock"; |
| 4 |
|
| 5 |
class basicCollectionBlock extends collectionBlock |
| 6 |
{ |
| 7 |
protected $blockname = "basic"; |
| 8 |
protected $fields = array("name" => array("default" => ""), |
| 9 |
"show_homepage" => array("default" => 0), |
| 10 |
"show_page" => array("default" => 0), |
| 11 |
"show_post" => array("default" => 0), |
| 12 |
"show_archive" => array("default" => 0), |
| 13 |
"placement" => array("default" => "after"), |
| 14 |
|
| 15 |
); |
| 16 |
|
| 17 |
function __construct() |
| 18 |
{ |
| 19 |
$this->fields["name"]["default"] = __("New Collection","maxbuttons"); |
| 20 |
|
| 21 |
} |
| 22 |
|
| 23 |
function parseCSS($css, $args) |
| 24 |
{ |
| 25 |
$css["maxcollection"]["normal"]["display"] = "inline-block"; |
| 26 |
$css["maxcollection"]["normal"]["z-index"] = "9999"; |
| 27 |
|
| 28 |
switch($this->data["placement"]) |
| 29 |
{ |
| 30 |
case "static-left": |
| 31 |
$css["maxcollection"]["normal"]["position"] = "fixed"; |
| 32 |
$css["maxcollection"]["normal"]["left"] = "0"; // these as string otherwise css compiler doens't like it |
| 33 |
$css["maxcollection"]["normal"]["top"] = "0"; |
| 34 |
break; |
| 35 |
case "static-right": |
| 36 |
$css["maxcollection"]["normal"]["position"] = "fixed"; |
| 37 |
$css["maxcollection"]["normal"]["right"] = "0"; |
| 38 |
$css["maxcollection"]["normal"]["top"] = "0"; |
| 39 |
break; |
| 40 |
case "static-top": |
| 41 |
$css["maxcollection"]["normal"]["position"] = "fixed"; |
| 42 |
$css["maxcollection"]["normal"]["left"] = "0"; |
| 43 |
$css["maxcollection"]["normal"]["top"] = "0"; |
| 44 |
break; |
| 45 |
case "static-bottom": |
| 46 |
$css["maxcollection"]["normal"]["position"] = "fixed"; |
| 47 |
$css["maxcollection"]["normal"]["left"] = "0"; |
| 48 |
$css["maxcollection"]["normal"]["bottom"] = "0"; |
| 49 |
break; |
| 50 |
} |
| 51 |
|
| 52 |
if ($args["preview"] == true) |
| 53 |
{ |
| 54 |
if (isset($css["maxcollection"]["normal"]["position"]) && $css["maxcollection"]["normal"]["position"] == "fixed") |
| 55 |
{ |
| 56 |
$css["maxcollection"]["normal"]["position"]= "absolute"; |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
//$css["maxcollection"]["normal"]["background-color"] = "#fff"; |
| 63 |
return $css; |
| 64 |
|
| 65 |
} |
| 66 |
|
| 67 |
public function map_fields($map) |
| 68 |
{ |
| 69 |
$map = parent::map_fields($map); |
| 70 |
$map["collection_name"]["func"] = "updateCollectionName"; |
| 71 |
$map["placement"]["func"] = "updatePlacement"; |
| 72 |
|
| 73 |
|
| 74 |
return $map; |
| 75 |
} |
| 76 |
|
| 77 |
function save_fields($data, $post) |
| 78 |
{ |
| 79 |
$data = parent::save_fields($data, $post); |
| 80 |
$data["collection_name"] = $data[$this->blockname]["name"]; // save as a global meta for searching |
| 81 |
$data["collection_type"] = $this->collection->getType(); |
| 82 |
if ($data[$this->blockname]["show_homepage"] == 1) |
| 83 |
{ |
| 84 |
$data["show_homepage"] = $data[$this->blockname]["placement"]; |
| 85 |
} |
| 86 |
if ($data[$this->blockname]["show_page"] == 1) |
| 87 |
{ |
| 88 |
$data["show_page"] = $data[$this->blockname]["placement"]; |
| 89 |
} |
| 90 |
|
| 91 |
if ($data[$this->blockname]["show_post"] == 1) |
| 92 |
{ |
| 93 |
$data["show_post"] = $data[$this->blockname]["placement"]; |
| 94 |
} |
| 95 |
if ($data[$this->blockname]["show_archive"] == 1) |
| 96 |
{ |
| 97 |
$data["show_archive"] = $data[$this->blockname]["placement"]; |
| 98 |
} |
| 99 |
|
| 100 |
return $data; |
| 101 |
|
| 102 |
} |
| 103 |
|
| 104 |
function admin_fields() |
| 105 |
{ |
| 106 |
|
| 107 |
extract($this->data); // admin data |
| 108 |
|
| 109 |
$placement_options = array( |
| 110 |
"after" => __("After","maxbuttons"), |
| 111 |
"before" => __("Before","maxbuttons"), |
| 112 |
"after-before" => __("Before + After (both)", "maxbuttons"), |
| 113 |
"static-left" => __("Static left","maxbuttons"), |
| 114 |
"static-right" => __("Static right","maxbuttons"), |
| 115 |
"static-top" => __("Static top","maxbuttons"), |
| 116 |
"static-bottom" => __("Static bottom","maxbuttons"), |
| 117 |
); |
| 118 |
?><div class="mb_tab option-container" data-options="settings"> |
| 119 |
<div class="title"> |
| 120 |
<span class="dashicons dashicons-admin-settings"></span> |
| 121 |
<span class="title"><?php _e("Settings","maxbuttons"); ?></span> |
| 122 |
<span class='manual-box'><a href='javascript:void(0)' class='manual-toggle' data-target="settings"> <?php _e("Getting Started","maxbuttons-pro"); ?> </a></span> |
| 123 |
<span class='right'><button name="save" type="submit" data-form='collection_edit' class="button button-primary"><?php _e("Save All","maxbuttons"); ?></button> |
| 124 |
</span> |
| 125 |
</div> |
| 126 |
|
| 127 |
<div class="inside"> |
| 128 |
|
| 129 |
<div class="option"> |
| 130 |
<label for="collection_name"><?php _e("Name"); ?></label> |
| 131 |
<input type="text" id='collection_name' name="name" value="<?php echo esc_attr($name) ?>" /> |
| 132 |
<div class="help fa fa-question-circle"> |
| 133 |
<span><?php _e("The name of your collection. It will not be displayed on the site.", "maxbuttons"); ?> |
| 134 |
</span> |
| 135 |
</div> |
| 136 |
|
| 137 |
</div> |
| 138 |
|
| 139 |
<div class="option"> |
| 140 |
<label for="collection_show"><?php _e("Automatically show on","maxbuttons"); ?></label> |
| 141 |
|
| 142 |
<div class='option-list'> |
| 143 |
<div class="help fa fa-question-circle"> |
| 144 |
<span><?php _e("Auto-display your buttons on the site. Checking the options will display the buttons on the corresponding part.", "maxbuttons"); ?> |
| 145 |
</span> |
| 146 |
</div> |
| 147 |
<input type="checkbox" name="show_homepage" value="1" <?php checked(1, $show_homepage) ?> > |
| 148 |
<?php _e("Homepage","maxbuttons"); ?><br /> |
| 149 |
|
| 150 |
<input type="checkbox" name="show_page" value="1" <?php checked(1, $show_page) ?> > <?php _e("Pages","maxbuttons"); ?><br> |
| 151 |
<input type="checkbox" name="show_post" value="1" <?php checked(1, $show_post) ?> > <?php _e("Posts","maxbuttons"); ?><br> |
| 152 |
<input type="checkbox" name="show_archive" value="1" <?php checked(1,$show_archive) ?> > |
| 153 |
<?php _e("Category / Archives","maxbuttons"); ?> <br> |
| 154 |
|
| 155 |
|
| 156 |
</div> |
| 157 |
</div> |
| 158 |
|
| 159 |
<div class="option"> |
| 160 |
<label for="collection_placement"><?php _e("Placement"); ?></label> |
| 161 |
<?php echo maxUtils::selectify("placement", $placement_options, $placement); ?> |
| 162 |
<div class="help fa fa-question-circle"> |
| 163 |
<span><?php _e("Choose where the buttons will show up.", "maxbuttons"); ?> |
| 164 |
</span> |
| 165 |
</div> |
| 166 |
</div> |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
</div> |
| 171 |
</div> <!-- option container --> |
| 172 |
|
| 173 |
<div class="manual-entry" data-manual="settings"> |
| 174 |
<h3><?php _e("General settings", "maxbuttons"); ?> |
| 175 |
<span class="dashicons dashicons-no window close manual-toggle" data-target="settings"></span> |
| 176 |
</h3> |
| 177 |
|
| 178 |
<p><?php _e("Give a name to your collection of buttons and select which portions and locations on your site you want the collection to appear. Anytime you want to see how your collection is going to look click the Preview tab to open up the Preview tab. We suggest you do this first. ","maxbuttons"); ?></p> |
| 179 |
|
| 180 |
|
| 181 |
</div> |
| 182 |
|
| 183 |
|
| 184 |
<?php |
| 185 |
|
| 186 |
|
| 187 |
} |
| 188 |
|
| 189 |
} |
| 190 |
|
| 191 |
?> |
| 192 |
|