| | |
| | | protected string|null $object_type; |
| | | protected int $max_file_size = 5242880; |
| | | protected ?string $content = null; |
| | | |
| | | protected ?string $baseKey = null; |
| | | protected \wpdb $wpdb; |
| | | protected array $postFields = [ |
| | | 'post_title', |
| | |
| | | 'description' |
| | | ]; |
| | | |
| | | public function __construct(?int $ID = null, ?string $type = null, ?string $content = null) |
| | | public function __construct(int|string|null $ID = null, ?string $type = null, ?string $content = null) |
| | | { |
| | | global $wpdb; |
| | | $this->wpdb = $wpdb; |
| | | $this->object_id = $ID; |
| | | |
| | | $this->object_id = is_int($ID) ? $ID : null; |
| | | $this->object_type = $type; |
| | | if ($ID) { |
| | | switch ($type) { |
| | |
| | | case 'integrations': |
| | | $this->data = get_user($ID); |
| | | break; |
| | | case 'options': |
| | | $this->baseKey = $ID; |
| | | $this->data = null; |
| | | break; |
| | | default: |
| | | $this->data = null; |
| | | break; |
| | |
| | | case 'integrations': |
| | | return get_user_meta($this->object_id, $meta_key, true); |
| | | case 'options': |
| | | return get_option($meta_key); |
| | | $key = $this->baseKey |
| | | ? BASE . $this->baseKey . '_' . $name |
| | | : BASE . $name; |
| | | return get_option($key); |
| | | default: |
| | | return ''; |
| | | } |
| | |
| | | $result = update_user_meta($this->object_id, $meta_key, $sanitized); |
| | | break; |
| | | case 'options': |
| | | $result = update_option($meta_key, $sanitized); |
| | | $key = $this->baseKey |
| | | ? BASE . $this->baseKey . '_' . $name |
| | | : BASE . $name; |
| | | return update_option($key, $sanitized); |
| | | } |
| | | |
| | | if ($result === false) { |