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

117 lines 3.1 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 if(! isset($data["id"]) || $data["id"] == 0)
68 $created_source = 'editor'; // button born at the editor
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 <input type="hidden" name="is_virtual" value="<?php echo $is_virtual; ?>">
87
88 <?php
89 if (defined("MAXBUTTONS_DEBUG") && MAXBUTTONS_DEBUG):
90
91 ?>
92 <div class="option-container mb_tab">
93 <div class="title"><?php _e('Meta', 'maxbuttons') ?></div>
94 <div class="inside">
95 <?php foreach($data as $key => $val) {
96 if (! is_array($val))
97 {
98 $try_json = json_decode($val);
99 if (! is_null($try_json))
100 $val = $try_json;
101 }
102 echo "<div class='option'> <label>$key</label>";
103 echo "<div>" . print_r($val,true) . "&nbsp;</div></div>";
104 }
105 ?>
106
107
108 </div>
109 </div>
110 <?php
111 endif;
112 } // admin_display
113
114 } // class
115
116 ?>
117