开发者 | digitalpoint |
---|---|
更新时间 | 2015年8月18日 02:08 |
捐献地址: | 去捐款 |
PHP版本: | 2.5 及以上 |
WordPress版本: | 4.3.0 |
版权: | GPLv2 |
版权网址: | 版权信息 |
[callback function="someFunction"]
Example shortcode to include a PHP file (the path is relative to WordPress' ABSPATH), then insert the results of someFunction() where you used the shortcode:
[callback include="custom/filetoinclude.php" function="someFunction"]
Shortcode example that includes a PHP file (the path is relative to WordPress' ABSPATH), then passes a paramter to someFunction() and returns the results where you used the shortcode:
[callback function="someFunction" include="custom/filetoinclude.php" param="something"]
The format to call a class/method with the shortcode is exactly the same as above, except you specify the class::method in the "function" attribute of the shortcode.
[callback function="someClass::someFunction" include="custom/filetoinclude.php" param="something"]
There is an example (with PHP code) over here.
shortcode-callback
folder to the /wp-content/plugins/
directory.I built this plugin primarily because I needed a way to inject the "Daily Yield" and "Total Yield" numbers to my solar power chart page.
[callback function="DigitalPointElectricity::total_output" param="daily" include="custom/Electricity.php"]
custom/DigitalPointElectricity.php
file being called by the shortcode:`<?php class DigitalPointElectricity { public static function total_output($timeframe) { $totals = $GLOBALS['memcache']->get('shawnhogan-pv-total'); if ($timeframe == 'total') { return $totals->Items[2]->TotalYield; } elseif ($timeframe == 'daily') { return $totals->Items[1]->DailyYield; } } }`