Ecommerce Shopify WordPress Discussion

PHP How does one declare an array in sub class and function? PHP [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 5 days ago. Improve this question I'm digging into someone else's opensource WordPress plugin. I'm not advanced, I know about memory scope for functions and classes, but I am unclear how to grab a parent class array object when it is not declared in the class or in the function being customized. I already completed one step of what I'm trying to because this was easier to do when the $array object was already in use by the function I made a customizations in. Basically I'm customizing the search results so that a BuddyPress profile is included alongside the original permalink return as the functions iterate. I'm stuck because the image URLs are handled differently than the posting title URL links. The class for handling images has its own class and function but is only receiving the post_ID to work with. The developer was trying to save memory. The additional problem is that the WordPress standard method of grabbing the post_author does not consistently work with this plugins custom post type. Sometimes get_the_author_meta comes back blank. So in the easier search result customization I had to use the plugins custom class object function like this and it worked great. $array->get_email(); Long story short how do I grab an array from a parent class, when its not declared in the current class or function? To be honest I also need to check where the array may or may not be iterated because I've never worked with these classes before. class Elements_Image extends Elements { public $key = 'image'; public $label; /** Constructor method */ public function __construct() { // Call the parent constructor parent::__construct(); $this->label = esc_html__('Featured Image', 'objclass'); } public function get($size, $post_id = null) { if(is_null($post_id)) { global $post; $post_id = $post->ID; } // Generate output ob_start(); include lsd_template('elements/featured-image.php'); return $this->content( ob_get_clean(), $this, [ 'post_id' => $post_id, 'size' => $size, 'method' => 'get', ] ); } // THIS IS WHERE I NEED TO GET THE ARRAY PASSED TO public function cover($size = [350, 220], $post_id = null) { if(is_null($post_id)) { global $post; $post_id = $post->ID; } //Generate output ob_start(); include _template('elements/cover-image.php'); return $this->content( ob_get_clean(), $this, [ 'post_id' => $post_id, 'size' => $size, 'method' => 'cover', ] ); } And here the cover-image.php is where I need the array to pass through from within the function <?php no direct access defined('ABSPATH') or die(); /** @var LSD_Skins $shortcode */ /** @var int $post_id */ /** @var array $size */ $shortcode = _Payload::get('shortcode'); Listing Link Method $listing_link_method = ($shortcode ? $shortcode->get_listing_link_method() : 'normal'); Listing Image $image = get_the_post_thumbnail($post_id, $size, (string) _schema()->prop('contentUrl')); ?> <?php if(in_array($listing_link_method, ['normal', 'blank'])): ?> <a class="cover-img-wrapper <?php echo (trim($image) ? 'has-image' : ''); ?>" href="<?php echo esc_url($get_the_permalink($post_id)); ?>" <?php echo ($listing_link_method === 'blank' ? 'target="_blank"' : ''); ?> <?php echo lsd_schema()->url()->scope()->type('https://schema.org/ImageObject'); ?>> <!--get_the_permalink($post_id)--> <?php echo (trim($image) ? Class_Kses::element($image) : '<div class="no-image"><i class="icon fa fa-camera fa-5x"></i></div>'); ?> </a> <?php else: echo (trim($image) ? Class_Kses::element($image) : '<div class="no-image"><i class="icon fa fa-camera fa-5x"></i></div>'); ?> <?php endif; Just to zero in: these lines where a get_the_permalink($post_ID) appears is where I need to pull in the array of parent class, and also, pull in a custom function to grab the post author email, due to the fact that this is a custom post type, regular WP methods are inconsistent on search result iteration. I need to use something like this: $array->get_email(); <a class="cover-img-wrapper <?php echo (trim($image) ? 'has-image' : ''); ?>" href="<?php echo esc_url($get_the_permalink($post_id)); ?>" <?php echo ($listing_link_method === 'blank' ? 'target="_blank"' : ''); ?> <?php echo lsd_schema()->url()->scope()->type('https://schema.org/ImageObject'); ?> I've tried to search the project and find how this array object is called down to sub classes without luck.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.