Remove the default meta box from the post editing screen and add our custom meta box.

@param string $object_type The object type (eg. the post type)
@param mixed  $object      The object (eg. a WP_Post object)
@return null
483318
public function meta_boxes( $object_type, $object ) {

		if ( ! is_a( $object, 'WP_Post' ) ) {
			return;
		}

		$post_type = $object_type;
		$post      = $object;
		$taxos     = get_post_taxonomies( $post );

		if ( in_array( $this->taxo->taxonomy, $taxos, true ) ) {

			$tax = get_taxonomy( $this->taxo->taxonomy );

			# Remove default meta box:
			if ( $this->taxo->args['hierarchical'] ) {
				remove_meta_box( "{$this->taxo->taxonomy}div", $post_type, 'side' );
			} else {
				remove_meta_box( "tagsdiv-{$this->taxo->taxonomy}", $post_type, 'side' );
			}

			if ( ! current_user_can( $tax->cap->assign_terms ) ) {
				return;
			}

			if ( $this->args['meta_box'] ) {

				# Set the 'meta_box' argument to the actual meta box callback function name:
				if ( 'simple' === $this->args['meta_box'] ) {
					if ( $this->taxo->args['exclusive'] ) {
						$this->args['meta_box'] = [ $this, 'meta_box_radio' ];
					} else {
						$this->args['meta_box'] = [ $this, 'meta_box_simple' ];
					}
				} elseif ( 'radio' === $this->args['meta_box'] ) {
					$this->taxo->args['exclusive'] = true;
					$this->args['meta_box'] = [ $this, 'meta_box_radio' ];
				} elseif ( 'dropdown' === $this->args['meta_box'] ) {
					$this->taxo->args['exclusive'] = true;
					$this->args['meta_box'] = [ $this, 'meta_box_dropdown' ];
				}

				# Add the meta box, using the plural or singular taxonomy label where relevant:
				if ( $this->taxo->args['exclusive'] ) {
					add_meta_box( "{$this->taxo->taxonomy}div", $tax->labels->singular_name, $this->args['meta_box'], $post_type, 'side' );
				} else {
					add_meta_box( "{$this->taxo->taxonomy}div", $tax->labels->name, $this->args['meta_box'], $post_type, 'side' );
				}
			} elseif ( false !== $this->args['meta_box'] ) {

				# This must be an 'exclusive' taxonomy. Add the radio meta box:
				add_meta_box( "{$this->taxo->taxonomy}div", $tax->labels->singular_name, [ $this, 'meta_box_radio' ], $post_type, 'side' );

			}
		}

	}
375539
public static function add_preview_params($link,$object)
    {
        // Pass through if not logged in
        if(!Member::currentUserID()) {
            return $link;
        }
        $modifiedLink = '';
        $request = Controller::curr()->getRequest();
        if ($request && $request->getVar('CMSPreview')) {
            // Preserve the preview param for further links
            $modifiedLink = HTTP::setGetVar('CMSPreview', 1, $link);
            // Quick fix - multiple uses of setGetVar method double escape the ampersands
            $modifiedLink = str_replace('&amp;','&',$modifiedLink); 
            // Add SubsiteID, if applicable
            if (!empty($object->SubsiteID)) {
                $modifiedLink = HTTP::setGetVar('SubsiteID', $object->SubsiteID, $modifiedLink);
                // Quick fix - multiple uses of setGetVar method double escape the ampersands
                $modifiedLink = str_replace('&amp;','&',$modifiedLink); 
            }
        } 

        return ($modifiedLink) ? $modifiedLink : $link;
    }
1167343
protected function update_meta_value( $object_id, $name, $value ) {
		if ( ! current_user_can( 'edit_post_meta', $object_id, $name ) ) {
			return new WP_Error(
				'rest_cannot_update',
				sprintf( __( 'You do not have permission to edit the %s custom field.' ), $name ),
				array( 'key' => $name, 'status' => rest_authorization_required_code() )
			);
		}

		$meta_type  = $this->get_meta_type();
		$meta_key   = wp_slash( $name );
		$meta_value = wp_slash( $value );

		// Do the exact same check for a duplicate value as in update_metadata() to avoid update_metadata() returning false.
		$old_value = get_metadata( $meta_type, $object_id, $meta_key );
		if ( 1 === count( $old_value ) ) {
			if ( $old_value[0] === $meta_value ) {
				return true;
			}
		}

		if ( ! update_metadata( $meta_type, $object_id, $meta_key, $meta_value ) ) {
			return new WP_Error(
				'rest_meta_database_error',
				__( 'Could not update meta value in database.' ),
				array( 'key' => $name, 'status' => WP_Http::INTERNAL_SERVER_ERROR )
			);
		}

		return true;
	}
1255121
public function post_type_link( $post_link, $post ) {

		if ( empty( $post ) || $this->object_type != $post->post_type ) {
			return $post_link;
		}

		$post_link = get_site_url() . '/';

		if ( false === strpos( $post->post_title, '*' ) ) {
			$post_link .= trim( $post->post_title, '/ ' ) . '/';
		}

		return $post_link;
	}
60987
public static function fd($object, $type = 'log')
    {
        $types = array('log', 'debug', 'info', 'warn', 'error', 'assert');

        if (!\in_array($type, $types, true)) {
            $type = 'log';
        }

        $data = json_encode($object);

        echo '<script type="text/javascript">console.' . $type . '(' . $data . ');</script>';
    }
1022393
protected function update_additional_fields_for_object( $object, $request ) {
		$additional_fields = $this->get_additional_fields();

		foreach ( $additional_fields as $field_name => $field_options ) {
			if ( ! $field_options['update_callback'] ) {
				continue;
			}

			// Don't run the update callbacks if the data wasn't passed in the request.
			if ( ! isset( $request[ $field_name ] ) ) {
				continue;
			}

			$result = call_user_func( $field_options['update_callback'], $request[ $field_name ], $object, $field_name, $request, $this->get_object_type() );
			if ( is_wp_error( $result ) ) {
				return $result;
			}
		}

		return true;
	}
722299
public function delete_wp_object( $object_type, $id, $force_delete = true ) {

		if ( in_array( $object_type, array( 'post_type', 'media' ) ) ) {
			$object_type = 'post';
		}

		if ( 'taxonomy' === $object_type ) {
			$object_type = 'term';
		}

		if ( empty( $id ) ) {
			return false;
		}

		if ( in_array( $object_type, array( 'post' ) ) ) {
			return wp_delete_post( $id, $force_delete );
		}

		if ( function_exists( 'wp_delete_' . $object_type ) ) {
			return call_user_func( 'wp_delete_' . $object_type, $id );
		}

		return false;
	}
882132
public function add_objects( $type, array $objects, $parent = null ) {
		foreach ( $objects as $slug => $struct ) {
			if ( is_array( $struct ) ) {
				$this->add( $type, $slug, $struct, $parent );
			}
		}
	}
222465
public function insert($object, $meta=null)
    {
        $query = new Query\Insert;

        if (is_array($meta)) {
            throw new \BadMethodCallException("Please use insertTable()");
        }

        if ($meta) {
            $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
        } else {
            $meta = $this->mapper->getMeta(get_class($object));
        }

        if (!$meta->canInsert) {
            throw new Exception("Meta {$meta->id} prohibits insert");
        }

        event_before: {
            if (isset($meta->on['beforeInsert'])) {
                foreach ($meta->on['beforeInsert'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['beforeInsert'])) {
                foreach ($this->on['beforeInsert'] as $cb) { $cb($object, $meta); }
            }
        }

        query: {
            $query->values = $this->mapper->mapObjectToRow($object, $meta, 'insert');
            if (!$query->table) {
                $query->table = $meta->table;
            }

            list ($sql, $params, $props) = $query->buildQuery($meta);
            $stmt = $this->getConnector()->prepare($sql);
            $stmt->execute($params);
        }
        
        $lastInsertId = null;

        // we need to be careful with "lastInsertId": SQLite generates one even without a PRIMARY
        if ($object && $meta->primary) {
            $lastInsertId = $this->getConnector()->lastInsertId();
            if ($lastInsertId && $meta->autoinc) {
                $field = $meta->fields[$meta->autoinc];
                $handler = $this->mapper->determineTypeHandler(Mapper::AUTOINC_TYPE);
                if (!$handler) {
                    throw new \UnexpectedValueException();
                }
                $meta->setValue($object, $meta->autoinc, $lastInsertId);
            }
        }
        
        event_after: {
            if (isset($meta->on['afterInsert'])) {
                foreach ($meta->on['afterInsert'] as $cb) { $cb = [$object, $cb]; $cb(); }
            }
            if (isset($this->on['afterInsert'])) {
                foreach ($this->on['afterInsert'] as $cb) { $cb($object, $meta); }
            }
        }

        return $lastInsertId;
    }
936675
public function add($_type = null)
    {
        if (empty($this->Settings['formFields'])) {
            $columns = $this->Model->schema()->columns();
            $filter = Configure::read('PostTypes.FilteredColumns');
            foreach ($columns as $column) {
                if (!in_array($column, $filter)) {
                    $this->Settings['formFields'][$column] = [];
                }
            }
        }

        // setting up an event for the add
        $_event = new Event('Controller.PostTypes.beforeAdd.' . $this->_type, $this, [
        ]);
        $this->eventManager()->dispatch($_event);

        $type = $this->Model->newEntity();
        if ($this->request->is('post')) {
            $type = $this->Model->newEntity($this->request->data);
            if ($this->Model->save($type)) {
                $this->Flash->success(__('The {0} has been saved.', [$this->Settings['type']]));
                return $this->redirect(['action' => 'index', 'type' => $this->_type]);
            } else {
                $this->Flash->error(__('The {0} could not be saved. Please, try again.', [$this->Settings['type']]));
            }
        }
        $this->set(compact('type'));

        // setting up an event for the add
        $_event = new Event('Controller.PostTypes.afterAdd.' . $this->_type, $this, [
        ]);
        $this->eventManager()->dispatch($_event);

        if (!$this->Settings['views']['add']) {
            $this->render(Configure::read('PostTypes.AdminPostTypeViews.add'));
            return;
        }

        $this->render($this->Settings['views']['add']);
    }
357825
public function get_object_label( $object ) {
		if ( ! $this->do_type_label ) {
			return '';
		}

		$post_type_obj = get_post_type_object( $object->post_type );
		$label = isset( $post_type_obj->labels->singular_name ) ? $post_type_obj->labels->singular_name : $post_type_obj->label;

		return ' &mdash; <span class="object-label">'. $label .'</span>';
	}
1120768
protected function get_additional_fields( $object_type = null ) {

		if ( ! $object_type ) {
			$object_type = $this->get_object_type();
		}

		if ( ! $object_type ) {
			return array();
		}

		global $wp_rest_additional_fields;

		if ( ! $wp_rest_additional_fields || ! isset( $wp_rest_additional_fields[ $object_type ] ) ) {
			return array();
		}

		return $wp_rest_additional_fields[ $object_type ];
	}
184611
public function removePostPostType()
    {
        global $wp_post_types;

        if (isset($wp_post_types['post'])) {
            if (function_exists('get_field') && get_field('disable_default_blog_post_type', 'option')) {
                add_action('admin_menu', function () {
                    remove_menu_page('edit.php');
                });

                add_action('wp_before_admin_bar_render', function () {
                    global $wp_admin_bar;
                    $wp_admin_bar->remove_menu('new-post');
                });
            }
        }

        if (isset($wp_post_types['page'])) {
            if (function_exists('get_field') && get_field('disable_default_page_post_type', 'option')) {
                add_action('admin_menu', function () {
                    remove_menu_page('edit.php?post_type=page');
                });

                add_action('wp_before_admin_bar_render', function () {
                    global $wp_admin_bar;
                    $wp_admin_bar->remove_menu('new-page');
                });
            }
        }

        return null;
    }
267471
public function deleteObjectRequest($object_key)
    {
        $operation = array(
            'API' => 'DeleteObject',
            'Method' => 'DELETE',
            'Uri' => '/<bucket-name>/<object-key>',
            'Headers' => array(
                'Host' => $this->properties['zone'] . '.' . $this->config->host,
            ),
            'Params' => array(
            ),
            'Elements' => array(
            ),
            'Properties' => $this->properties,
            'Body' => null
        );
        $operation['Properties']['object-key'] = $object_key;
        $this->deleteObjectValidate($operation);
        $req = new Request($this->config, $operation);
        return $req;
    }
3295
public static function object_get($object, $key, $default = null)
    {
        if (\is_null($key) || trim($key) === '') {
            return $object;
        }

        foreach (explode('.', $key) as $segment) {
            if (! \is_object($object) || ! isset($object->{$segment})) {
                return self::value($default);
            }

            $object = $object->{$segment};
        }

        return $object;
    }
1241174
protected function set_post_type_archive( $post_type_object ) {
		$label = $post_type_object->label;
		$this->set( $label, $this->get_post_type_archive_link( $post_type_object->name ) );
	}
265077
public function get_custom_post_type( $post_type ) {
		if ( ! $this->is_valid_custom_post_type( $post_type ) ) {
			return null;
		}

		$custom_posts = $this->get_custom_posts();

		return $custom_posts[ $post_type ];
	}