Send array as shortcode argument for a plugin
-
Hi fellow WordPress programmers,
I am developing embed-wistia-video plugin and they have implemented “chapters” for video, which is great.
So the chapters take 2 inputs, title and time.
I am thinking the best way to do this via shortcode is with an array, but I can’t seem to access the array correctly.Some help with formatting I think please:
my shortcode:
[wistiavid id=ro4t5bq4y0 postrolltext="this is a test" postrollurl=#anchor chapters="'title' => 'test title', 'tme' => '05'" ]
The print_r of the £args array:Array ( [id] => ro4t5bq4y0 [postrolltext] => this is a test [postrollurl] => #anchor [chapters] => 'title' => 'test title', 'tme' => '05' )the print_r of the $chapters array:
Array ( [0] => 'title' => 'test title', 'tme' => '05' )my function to get the sub array out:
function ChaptersArrayRet($chapters) { $chaparray[] = array($chapters); $ret = ""; $chapNo = 1; $comma = ""; print_r($chaparray); foreach($chaparray as $chap) { $ret .= "ch_".$chapNo."_title: \"".$chap[0][title]."\","; $ret .= "ch_".$chapNo."_time: \"".$chap[0][tme]."\"".$comma; $chapNo ++; $comma = ","; } return $ret; }
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
The topic ‘Send array as shortcode argument for a plugin’ is closed to new replies.