Add meta box in pages of public post type

@param [string] $post_type
@param [WP_Post] $post
@return void
547542
public function _add_meta_boxes( $post_type, $post ) {
		$post_type_object = get_post_type_object( $post_type );
		if ( empty( $post_type_object ) || empty( $post_type_object->public ) ) {
			return;
		}

		add_meta_box(
			'wp-seo',
			__( 'SEO', 'inc2734-wp-seo' ),
			array( $this, '_wp_seo_meta_box' ),
			$post_type,
			'normal'
		);
	}
1030666
public function get_post_type($post_type){
    global $wpdb;

    $query = $wpdb->prepare( "SELECT * FROM ".MF_TABLE_POSTTYPES." WHERE type = %s", array( $post_type ) );

    $post_type = $wpdb->get_row( $query, ARRAY_A );
    if($post_type){
      $post_type_id = $post_type['id'];
      $post_type = unserialize($post_type['arguments']);
      $post_type['core']['id'] = $post_type_id;
      return $post_type;
    }
    return false;
  }
74351
protected function addPostReferences(&$post, $data)
    {
        $typeMap = array(
            'user' => ReferenceType::USER,
            'page' => ReferenceType::PAGE,
            'group' => ReferenceType::GROUP,
            'application' => ReferenceType::APPLICATION,
        );

        if (!isset($data['message_tags'])) {
            return;
        }

        foreach ($data['message_tags'] as $messageTagGroup) {
            if (isset($messageTagGroup['offset'])) {
                $messageTag = $messageTagGroup;
                $reference = new Reference();
                $reference
                    ->setIndices(array($messageTag['offset'], $messageTag['offset'] + $messageTag['length']))
                    //->setType($typeMap[$messageTag['type']])
                    ->setData($messageTag);

                $post->addReference($reference);
            } else {
                foreach ($messageTagGroup as $messageTag) {
                    $reference = new Reference();
                    $reference
                        ->setIndices(array($messageTag['offset'], $messageTag['offset'] + $messageTag['length']))
                        ->setType($typeMap[$messageTag['type']])
                        ->setData($messageTag);

                    $post->addReference($reference);
                }
            }
        }
    }
906788
public function metaboxSave($value, int $post_id)
    {
        $this->setValue($value);

        $previous = get_post_meta($post_id, $this->getName(), true);

        if (is_null($this->getValue()) || empty($this->getValue())) {
            delete_post_meta($post_id, $this->getName());
        } elseif (empty($previous)) {
            add_post_meta($post_id, $this->getName(), $this->getRawValue(), true);
        } else {
            update_post_meta($post_id, $this->getName(), $this->getRawValue(), $previous);
        }
    }
931704
public function metaboxSave($value, int $post_id)
    {
        $this->setValue($value);

        $previous = get_post_meta($post_id, $this->getName(), false);

        if (is_null($value) || empty($value)) {
            delete_post_meta($post_id, $this->getName());
        } elseif (empty($previous) && is_array($value)) {
            array_walk($value, function ($val) use ($post_id) {
                add_post_meta($post_id, $this->getName(), $val, false);
            });
        } else {
            delete_post_meta($post_id, $this->getName());

            array_walk($value, function ($val) use ($post_id, $previous) {
                add_post_meta($post_id, $this->getName(), $val, false);
            });
        }
    }
79916
protected function update_the_post( array $post_data ) {
		global $wpdb;

		if ( ! $this->exists() || empty( $post_data ) ) {
			return;
		}

		if ( doing_action( 'save_post' ) || 0 === strpos( current_action(), 'save_post' ) ) {
			$updated = $wpdb->update( $wpdb->posts, $post_data, [ 'ID' => $this->get_id() ] );
		} else {
			$updated = wp_update_post( array_merge( [ 'ID' => $this->get_id() ], $post_data ) );
		}

		clean_post_cache( $this->get_id() );

		return ( 0 !== $updated && false !== $updated );
	}
204681
public function adminMetaBoxes($post_type, $post){
		if( false !== array_search($post_type, $this->post_types) ){
			switch($this->hook){
				case 'post_submitbox_misc_actions':
				case 'post_submitbox_start':
					add_action($this->hook, function() use ($post){
						if( $this->nonce_key ){
							wp_nonce_field($this->nonce_action, $this->nonce_key);
						}
						$this->editFormX($post);
					}, $this->hook_priority);
					break;
				case 'post_edit_form_tag':
				case 'edit_form_top':
				case 'edit_form_before_permalink':
				case 'edit_form_after_title':
				case 'edit_form_after_editor':
				case 'dbx_post_sidebar':
					add_action($this->hook, function(\WP_Post $post){
						if( $this->nonce_key ){
							wp_nonce_field($this->nonce_action, $this->nonce_key);
						}
						$this->editFormX($post);
					});
					break;
				default:
					$s = explode('\\', get_called_class());
					$name = $this->string->camel_to_hyphen($s[count($s) - 1]);
					add_meta_box("metabox-$name", $this->title, function( \WP_Post $post, array $screen ){
						if( $this->nonce_key ){
							wp_nonce_field($this->nonce_action, $this->nonce_key);
						}
						$this->doMetaBox($post, $screen);
					}, $post_type, $this->context, $this->priority);
					break;
			}
		}

	}
922317
protected function preload($post_type = 'post')
    {
        $args = array(
            'fields'           => 'ids',
            'orderby'          => 'post_date',
            'order'            => 'DESC',
            'post_status'      => 'publish',
            'post_type'        => $post_type,
            'showposts'        => -1,
            'suppress_filters' => true,
        );
        $query = new WP_Query($args);

        if ($query->have_posts()) {
            $posts = apply_filters('staticwp_preload_' . $post_type . '_posts', $query->posts);
            foreach ($posts as $post_id) {
                $this->updateHtml($post_id);
            }
        }
    }
251509
public function display($post_type, $post)
    {
        if (! is_null($this->capability) && ! current_user_can($this->capability)) {
            return;
        }

        if (! $this->hasTemplateForPost($post)) {
            return;
        }

        $this->filter->add('admin_body_class', function ($classes) {
            if (false !== strrpos($classes, 'themosis')) {
                return $classes;
            }

            $classes.= ' themosis';

            return $classes;
        });

        add_meta_box(
            $this->getId(),
            $this->getTitle(),
            [$this, 'render'],
            $this->getScreen(),
            $this->getContext(),
            $this->getPriority(),
            $this->getArguments()
        );
    }
1263031
protected function check_is_post_type_allowed( $post_type ) {
		if ( ! is_object( $post_type ) ) {
			$post_type = get_post_type_object( $post_type );
		}

		if ( ! empty( $post_type ) && ! empty( $post_type->show_in_rest ) ) {
			return true;
		}

		return false;
	}
1314093
protected function handle_status_param( $post_status, $post_type ) {

		switch ( $post_status ) {
			case 'draft':
			case 'pending':
				break;
			case 'private':
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to create private posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
				}
				break;
			case 'publish':
			case 'future':
				if ( ! current_user_can( $post_type->cap->publish_posts ) ) {
					return new WP_Error( 'rest_cannot_publish', __( 'Sorry, you are not allowed to publish posts in this post type.' ), array( 'status' => rest_authorization_required_code() ) );
				}
				break;
			default:
				if ( ! get_post_status_object( $post_status ) ) {
					$post_status = 'draft';
				}
				break;
		}

		return $post_status;
	}
680863
public function register_post_type() {

		if ( ! isset( $this->args['query_var'] ) || ( true === $this->args['query_var'] ) ) {
			$query_var = $this->post_type;
		} else {
			$query_var = $this->args['query_var'];
		}

		$existing = get_post_type_object( $this->post_type );
		$taxonomies = get_taxonomies( [
			'query_var' => $query_var,
		], 'objects' );

		if ( $query_var && count( $taxonomies ) ) {
			// https://core.trac.wordpress.org/ticket/35089
			foreach ( $taxonomies as $tax ) {
				if ( $tax->query_var === $query_var ) {
					trigger_error( esc_html( sprintf(
						/* translators: %s: Post type query variable name */
						__( 'Post type query var "%s" clashes with a taxonomy query var of the same name', 'extended-cpts' ),
						$query_var
					) ), E_USER_ERROR );
				}
			}
		}

		if ( empty( $existing ) ) {

			$cpt = register_post_type( $this->post_type, $this->args );

			if ( is_wp_error( $cpt ) ) {
				trigger_error( esc_html( $cpt->get_error_message() ), E_USER_ERROR );
			}
		} else {

			# This allows us to call `register_extended_post_type()` on an existing post type to add custom functionality
			# to the post type.
			$this->extend( $existing );

		}

	}
38073
function mf_post_add_metaboxes() {
    global $post,$mf_post_values;

    //if the user are going to add a new link
    //the var $post is not defined and we do nothing
    if(!isset($post)) {
      return false;
    }

    $mf_post_values = $this->mf_get_post_values($post->ID);

    //Getting the post types
    $post_types = $this->mf_get_post_types( array(), 'names'  );

    foreach ( $post_types as $post_type ){
      if ( post_type_supports($post_type, 'page-attributes') && $post_type != 'page' ) {
        // If the post type has page-attributes we are going to add
        // the meta box for choice a template by hand
        // this is because wordpress don't let choice a template
        // for any non-page post type
        add_meta_box(
          'mf_template_attribute',
          __('Template'),
          array( &$this, 'mf_metabox_template' ),
          $post_type,
          'side',
          'default'
        );
      }

      if( !mf_custom_fields::has_fields($post_type) ) {
          continue;
      }

      //getting  the groups (each group is a metabox)
      $groups = $this->get_groups_by_post_type($post_type);

      //creating the metaboxes
      foreach( $groups as $group ) {
        if( $this->group_has_fields($group['id'] ) ) {
          add_meta_box(
            'mf_'.$group['id'],
            $group['label'],
            array( &$this, 'mf_metabox_content' ),
            $post_type,
            'normal',
            'default',
            array( 'group_info' => $group)
          );
        }
      }
    }
  }
1244732
public function addPageSummaryMetaBox($postType, $post)
    {
        $allowedPostTypes = get_field('customer_feedback_posttypes', 'option');

        if (!isset($post->ID) || (is_array($allowedPostTypes) && !in_array($postType, $allowedPostTypes))) {
            return;
        }

        $answers = Responses::getResponses($post->ID);

        if (count($answers) === 0) {
            return;
        }

        add_meta_box(
            'customer-feedback-summary-meta',
            __('Customer feedback summary', 'customer-feedback') . ' (' . __('since', 'customer-feedback') . ' ' . get_the_modified_date('Y-m-d H:i') . ')',
            array($this, 'renderSummary'),
            $postType,
            'side',
            'default',
            array(
                'results' => $answers
            )
        );
    }
692724
public function get_meta( $_null, $post_ID = null, $meta_key = null, $single = false ) {

		if ( 'code' === $meta_key ) {
			$post = get_post( $post_ID );

			if ( is_object( $post ) && $this->object_type == $post->post_type ) {
				return $post->post_content;
			}
		}

		return $_null;
	}
46079
protected function addPostMedias(&$post, $data)
    {

        // we fetch standard_resolution image
        $imageData = $data['images']['standard_resolution'];
        $media = new Media();

        $media
            ->setUrl($imageData['url'])
            ->setLink($data['link'])
            ->setWidth($imageData['width'])
            ->setHeight($imageData['height'])
        ;

        $post->addMedia($media);
    }
1182529
public function registered_post_type( string $post_type, WP_Post_Type $post_type_object ) {
		if ( $post_type !== $this->post_type ) {
			return;
		}
		$struct = str_replace( "%{$this->post_type}_slug%", $this->post_slug, $post_type_object->rewrite['permastruct'] );
		$struct = str_replace( '%postname%', "%{$this->post_type}%", $struct );
		add_permastruct( $this->post_type, $struct, $post_type_object->rewrite );
	}