PluginProbe ʕ •ᴥ•ʔ
Pods – Custom Content Types and Fields / 3.3.2
Pods – Custom Content Types and Fields v3.3.2
trunk 1.14.8 2.7.31.3 2.8.23.3 2.9.19.3 3.0.10.3 3.1.4.1 3.2.0 3.2.1 3.2.1.1 3.2.2 3.2.4 3.2.5 3.2.6 3.2.7 3.2.7.1 3.2.8 3.2.8.1 3.2.8.2 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9
pods / src / Pods / Whatsit / Legacy_Object.php
pods / src / Pods / Whatsit Last commit date
Storage 2 years ago Block.php 2 years ago Block_Collection.php 4 years ago Block_Field.php 2 years ago Field.php 2 years ago Group.php 2 years ago Legacy_Object.php 1 year ago Object_Field.php 4 years ago Page.php 4 years ago Pod.php 2 years ago Storage.php 3 years ago Store.php 1 year ago Template.php 4 years ago
Legacy_Object.php
77 lines
1 <?php
2
3 namespace Pods\Whatsit;
4
5 use Pods\Whatsit;
6
7 /**
8 * Legacy Object class.
9 *
10 * @since 2.8.0
11 */
12 class Legacy_Object extends Whatsit {
13
14 /**
15 * {@inheritdoc}
16 */
17 public function get_clean_args() {
18 $args = parent::get_clean_args();
19
20 $old_mapping = [
21 'name' => 'label',
22 'slug' => 'name',
23 'uri' => 'name',
24 'code' => 'description',
25 ];
26
27 $new_args = [];
28
29 foreach ( $old_mapping as $old_arg => $new_arg ) {
30 $new_args[ $old_arg ] = '';
31
32 if ( isset( $args[ $new_arg ] ) ) {
33 $new_args[ $old_arg ] = $args[ $new_arg ];
34
35 unset( $args[ $new_arg ] );
36 }
37 }
38
39 return array_merge( $new_args, $args );
40 }
41
42 /**
43 * {@inheritdoc}
44 */
45 public function get_arg( $arg, $default = null, $strict = false, $raw = false ) {
46 if ( $raw ) {
47 return parent::get_arg( $arg, $default, $strict, $raw );
48 }
49
50 $old_mapping = [
51 'name' => 'label',
52 'slug' => 'name',
53 'uri' => 'name',
54 'code' => 'description',
55 ];
56
57 if ( isset( $old_mapping[ $arg ] ) ) {
58 $arg = $old_mapping[ $arg ];
59 }
60
61 return parent::get_arg( $arg, $default );
62 }
63
64 /**
65 * {@inheritdoc}
66 */
67 public function get_name() {
68 // Map get_name() to the real name, so we have a way to still get to it intentionally.
69 if ( isset( $this->args['name'] ) ) {
70 return $this->args['name'];
71 }
72
73 return null;
74 }
75
76 }
77