defaults = [ 'id' => 'featured-image-2', 'post_type' => 'page', 'name' => esc_html__( 'Featured Image 2', 'Avada' ), 'label_set' => esc_html__( 'Set featured image 2', 'Avada' ), 'label_remove' => esc_html__( 'Remove featured image 2', 'Avada' ), ]; $this->args = wp_parse_args( $args, $this->defaults ); $this->args['metabox_id'] = $this->args['id'] . '_' . $this->args['post_type']; $this->args['post_meta_key'] = 'kd_' . $this->args['metabox_id'] . '_id'; add_action( 'add_meta_boxes', [ $this, 'add_meta_box' ] ); add_action( 'init', [ $this, 'init_info_meta_box' ] ); } /** * Init admin metabox for an features images info. * * @since 5.2.1 * @access public * @return void */ public function init_info_meta_box() { add_action( 'add_meta_boxes', [ $this, 'add_meta_box_info' ] ); } /** * Add admin metabox for an additional featured image. * * @since 1.1 * @access public * @return void */ public function add_meta_box() { add_meta_box( $this->args['metabox_id'], $this->args['name'], [ $this, 'meta_box_content' ], $this->args['post_type'], 'side', 'low' ); } /** * Add admin metabox for an additional featured images info. * * @since 5.2.1 * @access public * @return void */ public function add_meta_box_info() { add_meta_box( 'fusion_featured_images_info', __( 'Featured images Info', 'Avada' ), [ $this, 'meta_box_info_content' ], $this->args['post_type'], 'side', 'low' ); } /** * Output the metabox content. * * @since 1.1 * @access public * @global object $post * @return void */ public function meta_box_content() { global $post; $image_id = fusion_data()->post_meta( $post->ID )->get( $this->args['post_meta_key'] ); ?>
' . esc_html__( 'Global Options', 'Avada' ) . '' ); } /** * Retrieve the ID of the featured image. * * @since 1.1 * @static * @access public * @global object $post * @param string $image_id Internal ID of the featured image. * @param string $post_type The post type of the post the featured image belongs to. * @param int $post_id A custom post ID. * @return int The featured image ID. */ public static function get_featured_image_id( $image_id, $post_type = null, $post_id = null ) { global $post; if ( is_null( $post_type ) ) { $post_type = get_post_type(); } if ( is_null( $post_id ) ) { $post_id = get_the_ID(); } return apply_filters( 'wpml_object_id', fusion_data()->post_meta( $post_id )->get( 'kd_' . $image_id . '_' . $post_type . '_id' ), 'attachment', true ); } } /* Omit closing PHP tag to avoid "Headers already sent" issues. */