Server : Apache/2 System : Linux vps.sdns.vn 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 User : phatdatpq ( 1022) PHP Version : 7.2.34 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/phatdatpq/public_html/wp-content/themes/flatsome/inc/builder/core/server/src/Post/ |
Upload File : |
<?php namespace UxBuilder\Post; use WP_Post; class Post { /** * @var WP_Post */ protected $post; public function __construct( WP_Post $post ) { $this->post = $post; } /** * Get the post object. * * @return WP_Post */ public function post() { return $this->post; } /** * Get post permalink or edit url if post is not published. * * @return string */ public function permalink() { $permalink = get_permalink( $this->post ); if ( is_ssl() ) { $permalink = preg_replace( '/^http:/', 'https:', $permalink ); } return $permalink; } /** * Get edit post link. * * @return string */ public function editlink() { return admin_url( 'post.php?post=' . $this->post->ID . '&action=edit' ); } /** * Get all meta data for this post. * * @return array */ public function meta_data() { $meta_data_array = array(); foreach ( get_post_meta( $this->post->ID ) as $key => $value ) { $meta_data_array[$key] = $value[0]; } return $meta_data_array; } /** * Generates an array to be used in the builder data. * * @return array */ public function to_array() { $post_array = new PostArray( $this->post ); $post_options = new PostOptions( $this->post ); return array( 'id' => $this->post->ID, 'type' => $this->post->post_type, 'status' => $this->post->post_status, 'content' => (object) $post_array->get_array(), 'attributes' => (object) $post_options->get_attributes_array(), 'meta' => (object) $post_options->get_meta_array(), ); } }