PluginProbe
MaxButtons – Create buttons / 6.7
MaxButtons – Create buttons v6.7
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / blocks / meta.php

meta.php in MaxButtons – Create buttons 6.7, at blocks/meta.php

121 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $blockClass["meta"] = "metaBlock";
3 $blockOrder[100][] = "meta";
4
5 class metaBlock extends maxBlock
6 {
7 protected $blockname = "meta";
8 protected $fields = array("created" => array("default" => 0),
9 "modified" => array("default" => 0),
10 "user_created" => array("default" => ''), // user logged in on creation
11 "user_modified" => array("default" => ''),
12 "created_source" => array("default" => 'unknown'), // from editor / pack / collection ?
13 "user_edited" => array("default" => false), // did a user ever edit this button?
14 "in_collections" => array("default" => array() ), // map collections this button is in.
15 "is_virtual" => array("default" => false), // this button is not really in the database
16 );
17
18
19
20 /*function __construct()
21 {
22 parent::__construct();
23
24 } */
25
26 public function save_fields($data, $post)
27 {
28 $data = parent::save_fields($data,$post);
29
30 $blockdata = $data[$this->blockname];
31 $button_id = isset($data["id"]) ? $data["id"] : 0;
32 $user = wp_get_current_user();
33
34
35 if ($button_id == 0)
36 {
37 $blockdata["created"] = time();
38 $blockdata["user_created"] = $user->user_login;
39 }
40
41 $blockdata["modified"] = time();
42 $blockdata["user_modified"] = $user->user_login;
43
44
45 $data[$this->blockname] = $blockdata;
46
47 return $data;
48 }
49
50
51 public function admin_fields()
52 {
53 //return false;
54 $data = (isset($this->data[$this->blockname]) && is_array($this->data[$this->blockname])) ? $this->data[$this->blockname] : array();
55
56 foreach($this->fields as $field => $options)
57 {
58 $default = (isset($options["default"])) ? $options["default"] : '';
59 $$field = (isset($data[$field])) ? $data[$field] : $default;
60 ${$field . "_default"} = $default;
61
62 }
63
64
65 if(! isset($data["id"]) || $data["id"] == 0)
66 $created_source = 'editor'; // button born at the editor
67
68
69 ?>
70 <input type="hidden" name="created" value="<?php echo $created ?>">
71 <input type="hidden" name="user_created" value="<?php echo $user_created ?>">
72
73 <input type='hidden' name='created_source' value="<?php echo $created_source ?>">
74 <input type='hidden' name='user_edited' value='true'>
75
76 <?php if (is_array($in_collections)) {
77 foreach ($in_collections as $collection_id)
78 {
79 ?>
80 <input type="hidden" name="in_collections[]" value="<?php echo $collection_id ?>">
81 <?php
82
83 }
84
85
86 } ?>
87 <input type="hidden" name="is_virtual" value="<?php echo $is_virtual; ?>">
88
89
90
91
92 <?php
93 if (defined("MAXBUTTONS_DEBUG") && MAXBUTTONS_DEBUG):
94
95 ?>
96 <div class="option-container mb_tab">
97 <div class="title"><?php _e('Meta', 'maxbuttons') ?></div>
98 <div class="inside">
99 <?php foreach($data as $key => $val) {
100 if (! is_array($val))
101 {
102 $try_json = json_decode($val);
103 if (! is_null($try_json))
104 $val = $try_json;
105 }
106 echo "<div class='option'> <label>$key</label>";
107 echo "<div>" . print_r($val,true) . "&nbsp;</div></div>";
108 }
109 ?>
110
111
112 </div>
113 </div>
114 <?php
115 endif;
116 } // admin_display
117
118 } // class
119
120 ?>
121