PluginProbe
MaxButtons – Create buttons / 6.28
MaxButtons – Create buttons v6.28
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
← All changes | blocks/meta.php +69 -62 7.13.26.28 View file →
@@ -1,91 +1,98 @@
1 1 <?php
2 2 namespace MaxButtons;
3 3 defined('ABSPATH') or die('No direct access permitted');
4 4
5 -$blockClass["meta"] = "metaBlock";
6 -$blockOrder[100][] = "meta";
5 +$blockClass["meta"] = "metaBlock";
6 +$blockOrder[100][] = "meta";
7 7
8 -class metaBlock extends maxBlock
8 +class metaBlock extends maxBlock
9 9 {
10 - protected $blockname = "meta";
11 - protected $fields = array("created" => array("default" => 0),
12 - "modified" => array("default" => 0),
10 + protected $blockname = "meta";
11 + protected $fields = array("created" => array("default" => 0),
12 + "modified" => array("default" => 0),
13 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.
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 18 "is_virtual" => array("default" => false), // this button is not really in the database
19 - );
19 + );
20 +
21 +
20 22
21 -
22 -
23 23 /*function __construct()
24 24 {
25 25 parent::__construct();
26 -
26 +
27 27 } */
28 -
29 - public function save_fields($data, $post)
28 +
29 + public function save_fields($data, $post)
30 30 {
31 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)
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 39 {
40 40 $blockdata["created"] = time();
41 - $blockdata["user_created"] = $user->user_login;
41 + $blockdata["user_created"] = $user->user_login;
42 42 }
43 -
44 - $blockdata["modified"] = time();
43 +
44 + $blockdata["modified"] = time();
45 45 $blockdata["user_modified"] = $user->user_login;
46 +
46 47
47 -
48 - $data[$this->blockname] = $blockdata;
49 -
50 - return $data;
48 + $data[$this->blockname] = $blockdata;
49 +
50 + return $data;
51 51 }
52 52
53 -
54 - public function admin_fields()
53 +
54 + public function admin_fields()
55 55 {
56 - //return false;
57 - $data = (isset($this->data[$this->blockname]) && is_array($this->data[$this->blockname])) ? $this->data[$this->blockname] : array();
58 -
56 + //return false;
57 + $data = (isset($this->data[$this->blockname]) && is_array($this->data[$this->blockname])) ? $this->data[$this->blockname] : array();
58 +
59 59 foreach($this->fields as $field => $options)
60 - {
61 - $default = (isset($options["default"])) ? $options["default"] : '';
60 + {
61 + $default = (isset($options["default"])) ? $options["default"] : '';
62 62 $$field = (isset($data[$field])) ? $data[$field] : $default;
63 - ${$field . "_default"} = $default;
64 -
63 + ${$field . "_default"} = $default;
64 +
65 65 }
66 66
67 - if(! isset($data["id"]) || $data["id"] == 0)
67 +
68 + if(! isset($data["id"]) || $data["id"] == 0)
68 69 $created_source = 'editor'; // button born at the editor
70 +
71 +
69 72 ?>
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 ?>">
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 ?>">
74 77 <input type='hidden' name='user_edited' value='true'>
75 -
78 +
76 79 <?php if (is_array($in_collections)) {
77 - foreach ($in_collections as $collection_id)
80 + foreach ($in_collections as $collection_id)
78 81 {
79 82 ?>
80 - <input type="hidden" name="in_collections[]" value="<?php echo $collection_id ?>">
83 + <input type="hidden" name="in_collections[]" value="<?php echo $collection_id ?>">
81 84 <?php
85 +
86 + }
87 +
88 +
89 + } ?>
90 + <input type="hidden" name="is_virtual" value="<?php echo $is_virtual; ?>">
82 91
83 - }
84 92
85 - } ?>
86 - <input type="hidden" name="is_virtual" value="<?php echo $is_virtual; ?>">
87 93
94 +
88 95 <?php
89 96 if (defined("MAXBUTTONS_DEBUG") && MAXBUTTONS_DEBUG):
90 97
91 98 ?>
@@ -90,27 +97,27 @@
90 97
91 98 ?>
92 99 <div class="option-container mb_tab">
93 100 <div class="title"><?php _e('Meta', 'maxbuttons') ?></div>
94 - <div class="inside">
95 - <?php foreach($data as $key => $val) {
101 + <div class="inside">
102 + <?php foreach($data as $key => $val) {
96 103 if (! is_array($val))
97 104 {
98 105 $try_json = json_decode($val);
99 - if (! is_null($try_json))
106 + if (! is_null($try_json))
100 107 $val = $try_json;
101 108 }
102 - echo "<div class='option'> <label>$key</label>";
103 - echo "<div>" . print_r($val,true) . "&nbsp;</div></div>";
104 - }
109 + echo "<div class='option'> <label>$key</label>";
110 + echo "<div>" . print_r($val,true) . "&nbsp;</div></div>";
111 + }
105 112 ?>
106 113
107 -
114 +
108 115 </div>
109 116 </div>
110 - <?php
111 - endif;
117 + <?php
118 + endif;
112 119 } // admin_display
113 -
114 - } // class
115 -
120 +
121 + } // class
122 +
116 123 ?>