PluginProbe
MaxButtons – Create buttons / 7.1
MaxButtons – Create buttons v7.1
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 7.1, at blocks/meta.php

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