This is more a generic PHP question than anything to do with WordPress, but I’d suggest setting the value in the constructor:
class test {
public $basicCols;
public $optList = array( 'one' => 'One', 'two' => 'Two' );
function __construct() {
$this->basicCols = array(
array( 'title' => 'KEY', 'field' => 'slug', 'options' => $this->optList ),
array( 'title' => 'KEY', 'field' => 'slug' )
);
}
}
Related Posts:
- How to store the_title() into a variable to reutrn the value, not just echo it
- Using a variable in is_page(array())
- Call global variable array() in woocommerce child/template
- How to access or parse key/values that have “string”
- Dynamically adding filters
- Get check box values inside array for use in posting form data
- How do I create a numbered list with PHP? [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- How to put a form with php code into a variable or shortcode?
- How to use array in function to get only value I want
- Apply class to every third list item? [duplicate]
- Error while setting role
- Get categories names as an array to use it in theme settings
- persist a variable set in header.php all the way down to footer.php
- Get access to variable from previous pageview, excluding ajax-calls
- How to get the last category name of a child category?
- How to say if meta_value is greater than 0 in an array?
- How to deal with too many $_POST variable conditions from ajax request at backend? [closed]
- How to use two meta_compare in an array?
- Warning: in_array() null given in PHP function
- What is the alternative code to if (isset ($_POST) && !empty ($_POST) to avoid warnings?
- Foreach loop inside an array_merge
- How to pass a variable to get_template_part that’s updated every time the template part is called?
- Insert page content into another page with a changed variable
- Pass Variables or Variable Place-Holder from Editor to PHP
- Loop over Array and get the distinct ids
- If Array Values Match Another Array’s Values, Then
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Only show first image in foreach loop
- Conditional multidimensional arrays and array_map
- How can I get all values from my array in a loop in php? [closed]
- How Do I Find & Remove H1 From Site-Title-Wrapper? [closed]
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- javascript variable to wordpress php variable
- I’m unable to call img path using single quotes in an array?
- Filter by field with array value in ACF on WP REST API
- extract serialized array to use for wp-query
- get users search not working with array
- Comapare get_user_meta value
- How can get all users by current user meta?
- How to reference PHP in Javascript
- Get the id of all images in a post
- Output category list inside array
- how to make an array of post id’s in is_single
- How can I split my query result in 2 arrays?
- Multidimensional Array
- Separate array output into a
- Store and Change Session variable – PHP SESSION VARIABLE
- array_rand not working correctly?
- How to add post classes?
- Overide Variable in Child Theme
- Get css class of menu item in custom menu structure
- How to edit the styles for the table of pages/post listed in the admin when you click on pages/posts?
- echo var into wp_query
- how can I include some custom variable from functions.php?
- Order a WP_Query by meta value where the value is an array
- WordPress call post-ID in jquery
- Only load certain artists on this page
- add the value of a variable returned in a while loop [closed]
- Update value of a associative array with update_post_meta
- How to make sure relative URL works when site is not on root domain?
- Get URI from PodPress using PHP
- How To Pass Array To get_the_category_by_ID() and Get An Array Back?
- using images in next/previous_post_link [closed]
- Finding and removing duplicates within WP Arrays
- Using multiple variables to assign categories to an array
- PHP variables in a post?
- Custom functions for string data calculations
- Add custom fields from different posts
- WordPress is removing query variables like page, p from the URL of a custom static page
- Repeat a function with 24hrs gap for n number of days
- MySQL Query Returns Array () In Shortcode
- Problem with inserting multiple images in gallery of each WooCommerce product programmatically
- Convert a column of a table containing an Array as response in HTML
- How to send a php var to jQuery Ajax call with two different file
- Unable to display multiple parameters from url by javascript through shortcodes
- Sending simple variable on single page to WP JSON
- Create an array with all the links of the years’ archive (of a custom post type)
- Display just one post from a loop of 5 posts?
- Order users by random not working?
- Redux option doensn’t seem when include from functions.php
- How to check a variable Changes
- in_array not working on dev server but works on localhost
- global $product is empty string when passed into function
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- Custom global variable not working in function
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- WordPress How do I pass a variable from one add_action to another?
- how to separate an array into different arrays and save them into db?
- Best way to use variables in multiple functions?
- Trying to add some custom text into WordPress Post title via function.php
- How to insert multiple rows and columns in database using array
- Display one random image from Media Library
- How to display MySQL table data which is stored as an array?
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- ACF – Get ID of relationship field in flexible content
- How do I fix Undefined variable using $_POST in function?