Get saved data

@param \WP_Post $post
@return mixed
513159
protected function get_data( \WP_Post $post ){
        switch( $this->name ){
            case 'excerpt':
                return $post->post_excerpt;
                break;
            default:
                if( false !== array_search(Taxonomy::class, class_uses(get_called_class())) ){
                    // This is taxonomy
                    $terms = get_the_terms($post, $this->name);
                    $term_id = 0;
                    if( $terms && !is_wp_error($terms) ){
                        foreach($terms as $term){
                            $term_id = $term->term_id;
                        }
                    }
                    return $term_id;

                }else{
                    // This is post meta
                    return get_post_meta($post->ID, $this->name, true);
                }
                break;
        }
    }
944719
public function save()
    {
        if (!$this->isValidPostSave()) {
            return;
        }

        // Check if post id is valid
        if (!isset($_REQUEST['id']) || empty($_REQUEST['id'])) {
            return trigger_error('Invalid post id. Please contact system administrator.');
        }

        $this->savePost();

        // If this is an ajax post, return "success" as plain text
        if (defined('DOING_AJAX') && DOING_AJAX) {
            echo "success";
            wp_die();
        }

        $this->notice(__('Modules saved', 'modularity'), ['updated']);
    }
453842
public function findByPost(Post $post)
    {
        return $this->createQueryBuilder('t')
            ->innerJoin('t.posts', 'p')
            ->where('p.id = :postId')
            ->setParameter('postId', $post->getId())
            ->getQuery()->getResult();
    }
760588
protected function set_post_data( $data, $post ) {
		$data['post_title'] = $post->post_title;
		$data['post']       = $post;
		if ( $this->user_can( 'read_post' ) ) {
			$data['edit_link'] = get_edit_post_link( $post->ID );
		}

		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$data[ $k ] = $this->sanitize_input( $this->app->utility->array_get( $data, $k ), $v['type'] );
		}

		return $data;
	}
555626
private function get_modules_content( \WP_Post $post ) : string {
		$flexible_content = $this->_flexible_content[ $post->ID ] ?? null;

		if ( empty( $flexible_content ) ) {
			$layouts = $this->get_current_post_layouts( $post );

			foreach ( $layouts as $layout ) {

				if ( ! isset( $layout['acf_fc_layout'] ) || empty( $layout['acf_fc_layout'] ) ) {
					continue;
				}

				ob_start();
				$this->render_module_template( $layout['acf_fc_layout'], $layout );
				$flexible_content .= ob_get_clean();
			}

			/*
			 * Store the flexible content to reuse it if `the_content` is
			 * runned more than once.
			 */
			$this->_flexible_content[ $post->ID ] = $flexible_content;
		}

		return (string) $flexible_content;
	}
1290998
public function getPost($post_id)
    {
        $this->checkId($post_id);

        return $this->adapter->get(sprintf('/post/%d', $post_id));
    }
1345325
function get_fields( $fields, $post_id )
	{
		// global
		global $wpdb;
		
		
		// loaded by PHP already?
		if( !empty($fields) )
		{
			return $fields;	
		}

		
		// get field from postmeta
		$rows = $wpdb->get_results( $wpdb->prepare("SELECT meta_key FROM $wpdb->postmeta WHERE post_id = %d AND meta_key LIKE %s", $post_id, 'field_%'), ARRAY_A);
		
		
		if( $rows )
		{
			foreach( $rows as $row )
			{
				$field = apply_filters('acf/load_field', false, $row['meta_key'], $post_id );
	
			 	$fields[ $field['order_no'] ] = $field;
			}
		 	
		 	// sort
		 	ksort( $fields );
	 	}
	 	
	 	
	 	
	 	// return
		return $fields;
		
	}
1164201
public static function get_all_post_meta( $post ) {
		$tags = [
			[ 'name' => 'description',			'content' => self::get_post_meta_description( $post ) ],
			[ 'property' => 'og:locale',		'content' => get_locale() ],
			[ 'property' => 'og:type',			'content' => 'article' ],
			[ 'property' => 'og:title',			'content' => self::get_post_og_title( $post ) ],
			[ 'property' => 'og:description',	'content' => self::get_post_og_description( $post ) ],
			[ 'property' => 'og:url',			'content' => get_permalink( $post->ID ) ],
			[ 'property' => 'og:site_name',		'content' => get_bloginfo( 'title' ) ],
			[ 'property' => 'og:updated_time',	'content' => get_post_modified_time( 'c', true, $post ) ],
			[ 'name' => 'twitter:card',			'content' => self::get_twitter_card_type() ],
			[ 'name' => 'twitter:title',		'content' => self::get_post_twitter_title( $post ) ],
			[ 'name' => 'twitter:description',	'content' => self::get_post_twitter_description( $post ) ],
		];

		$og_image = self::get_post_og_image( $post );
		$twitter_image = self::get_post_twitter_image( $post );

		if ( ! empty( $og_image ) ) {
			$og_image_size = getimagesize( $og_image );

			$tags = array_merge( $tags, [
				[ 'property' => 'og:image',			'content' => $og_image ],
				[ 'property' => 'og:image:width',	'content' => $og_image_size[0] ],
				[ 'property' => 'og:image:height',	'content' => $og_image_size[1] ],
			] );
		}

		if ( ! empty( $twitter_image ) ) {
			$twitter_image_size = getimagesize( $twitter_image );

			$tags = array_merge( $tags, [
				[ 'name' => 'twitter:image',		'content' => $twitter_image ],
				[ 'name' => 'twitter:image:width',	'content' => $twitter_image_size[0] ],
				[ 'name' => 'twitter:image:height',	'content' => $twitter_image_size[1] ],
			] );
		}

		$tags = array_merge( $tags, Site::webmaster_tools() );

		return [
			'title' => self::get_post_meta_title( $post ),
			'tags' => $tags,
		];
	}
153154
private function postData()
    {
        if (empty($this->post)) {
            return;
        }

        $post = array_filter($this->post);

        return http_build_query($post);
    }
201052
static function consolidatePost( $pid, $post ) {

		if ( false === Book::isBook() || wp_is_post_revision( $pid ) || 'auto-draft' === get_post_status( $pid ) ) {
			return false;
		}

		/** @var $wpdb \wpdb */
		global $wpdb;
		$success = true;

		// if this is a new post, set its order
		if ( empty( $post->menu_order ) ) {
			if ( 'chapter' === $post->post_type ) {
				$new = $wpdb->get_var(
					$wpdb->prepare(
						"SELECT max({$wpdb->posts}.menu_order) + 1
						FROM {$wpdb->posts}
						WHERE {$wpdb->posts}.post_type = %s
						AND NOT {$wpdb->posts}.post_status = 'trash'
						AND {$wpdb->posts}.post_parent = %s ",
						$post->post_type,
						$post->post_parent
					)
				);
			} else {
				$new = $wpdb->get_var(
					$wpdb->prepare(
						"SELECT max({$wpdb->posts}.menu_order) + 1
						FROM {$wpdb->posts}
						WHERE {$wpdb->posts}.post_type = %s
						AND NOT {$wpdb->posts}.post_status = 'trash' ",
						$post->post_type
					)
				);
			}

			if ( empty( $new ) ) {
				$new = 1;
			} else {
				$new = absint( $new );
			}

			$success = $wpdb->query(
				$wpdb->prepare(
					"UPDATE {$wpdb->posts}
					SET {$wpdb->posts}.menu_order = %d
					WHERE {$wpdb->posts}.ID = %d ",
					$new,
					$post->ID
				)
			);
			clean_post_cache( $post );

		}

		return $success ? true : false;
	}
1368366
public static function get_post_meta_title( $post ) {
		$title = get_post_meta( $post->ID, '_yoast_wpseo_title', true );

		if ( empty( $title ) ) {
			if ( (int) get_option( 'page_on_front' ) === $post->ID ) {
				$title = get_bloginfo( 'title' );
			} else {
				$title = $post->post_title . ' - ' . get_bloginfo( 'title' );
			}
		}

		return $title;
	}
96836
private function postData()
    {
        $post =  array(
            'UserName' => $this->options['username'],
            'Password' => $this->options['password']
        );

        $result = $this->urlize(array_merge($post, $this->post));

        return $result;

    }
939903
public function getTerms($post)
    {
        $taxonomies = get_field('taxonomy_display', $this->data['ID']);

        if (empty($taxonomies)) {
            return [];
        }


        $terms = array();
        if (!empty($taxonomies)) {
            foreach ($taxonomies as $taxonomy) {
                $terms = array_merge($terms, get_the_terms($post->ID, $taxonomy));
            }
        }

        return $terms;
    }
929219
public function delete(Post $post)
    {
        $this->authorize(PostsPolicy::PERMISSION_DELETE);

        try {
            $post->trashed() ? $post->forceDelete() : $post->delete();

            return $this->jsonResponseSuccess([
                'message' => $this->transNotification('deleted', ['title' => $post->title], $post->toArray())
            ]);
        }
        catch(\Exception $e) {
            return $this->jsonResponseError(['message' => $e->getMessage()], 500);
        }
    }
135161
public function populate_post_content_for_indexing( \WP_Post $post ) : \WP_Post {

		$module_content = $this->get_modules_content( $post );

		if ( ! empty( $module_content ) ) {
			// Fake fill the post_content with modules before SearchWP indexing.
			$post->post_content = $module_content;
		}

		return $post;
	}
374972
public function callback($post, $args)
    {
        // If autosave...
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
            return isset($post->ID) ? $post->ID : null;
        }

        // Get field
        $fields = isset($args['args']) ? $args['args'] : null;

        // Check if fields are defined
        if (!$fields || empty($fields)) {
            throw new MetaboxException(Translate::t('metabox.errors.no_type_is_defined'));
        }

        $vars = [];

        // Display fields
        foreach ($fields as $field) {
            if (!$field) {
                continue;
            }

            $vars['fields'][] = $field->render([], [
                'template' => 'metabox',
                'post' => $post,
            ], false);
        }

        // Render view
        Render::view('metabox.html.twig', $vars, 'metabox');

        // Return post if it is asked
        return isset($post->ID) ? $post->ID : null;
    }
740612
protected function retrieveConfigPostMetas($post, $postTypeModel)
	{
		$metaKeys = [];
		$metaTaxonomies = [];

		$allKeys = $this->getValidationsKeys($postTypeModel);
		foreach($allKeys as $key => $value){

			$customFieldObject = $this->getCustomFieldObject($postTypeModel, $key);

			if(isset($customFieldObject['type']) && $customFieldObject['type'] == 'taxonomy'){

				// We need to get the values from the taxonomy table
				if(array_key_exists('post_type', $customFieldObject)){

					$customfieldPostTypes = $this->getPostTypeIdentifiers($customFieldObject['post_type']);

					// Lets query the post to retrieve all the connected ids
					$taxonomyIds = $post->taxonomies()->whereIn('post_type', $customfieldPostTypes)
						->get();

					// Lets foreach all the posts because we only need the id
					$ids = [];
					foreach($taxonomyIds as $value){
						array_push($ids, $value->id);
					}

					$ids = json_encode($ids);

					$metaTaxonomies[$key] = [
						'meta_key' => $key,
						'meta_value' => $ids,
					];

				}

			// The other items are default
			} else {

				// Register it to the main array so we can query it later
				array_push($metaKeys, $key);

			}

		}

		// Lets query the database to get only the values where we have registered the meta keys
		$postmetaSimple = $post->postmeta()
			->whereIn('meta_key', $metaKeys)
			->select(['meta_key', 'meta_value'])
			->get()
			->keyBy('meta_key')
			->toArray();

		// Lets attach the default post columns
		$defaultPostData = [];

		$defaultPostData['post_title'] = [
			'meta_key' => 'post_title',
			'meta_value' => $post->post_title,
		];

		$defaultPostData['post_name'] = [
			'meta_key' => 'post_name',
			'meta_value' => $post->post_name,
		];

		// Lets merge all the types of configs
		$postmeta = array_merge($postmetaSimple, $metaTaxonomies, $defaultPostData);

		// Return the post meta's
		return $postmeta;
	}