This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
plugins:tips [2013/02/19 16:16] n00dles101 |
plugins:tips [2014/02/07 10:07] (current) datiswous [Working around the broken sitewide cookies in GS 3.0] |
||
---|---|---|---|
Line 7: | Line 7: | ||
Determining the GetSimple version is not as straight forward as it could be, as the only available function in 2.03 - return_site_ver() - outputs the version in 2.03 and returns it in 3.0b (deprecated here). The easiest way to find out, if a plugin is installed on GetSimple 2.03 or 3.0+ seems to be | Determining the GetSimple version is not as straight forward as it could be, as the only available function in 2.03 - return_site_ver() - outputs the version in 2.03 and returns it in 3.0b (deprecated here). The easiest way to find out, if a plugin is installed on GetSimple 2.03 or 3.0+ seems to be | ||
- | <code> | + | <code php> |
$isV3 = function_exists('get_site_version'); | $isV3 = function_exists('get_site_version'); | ||
</code> | </code> | ||
Line 13: | Line 13: | ||
The probably most correct one is (only use within function, in order not to pollute the global name space!) | The probably most correct one is (only use within function, in order not to pollute the global name space!) | ||
- | <code> | + | <code php> |
include(GSADMININCPATH.'configuration.php'); | include(GSADMININCPATH.'configuration.php'); | ||
$version = GSVERSION; | $version = GSVERSION; | ||
Line 22: | Line 22: | ||
To trigger a function myplugin_function on page deletes in GetSimple 2.03 and 3.0+ use the following code: | To trigger a function myplugin_function on page deletes in GetSimple 2.03 and 3.0+ use the following code: | ||
- | <code> | + | <code php> |
// GetSimple 3.0+ | // GetSimple 3.0+ | ||
add_action('page-delete', 'myplugin_function'); | add_action('page-delete', 'myplugin_function'); | ||
Line 37: | Line 37: | ||
Assume you have 3 variables, ''$isSuccess'', ''$canUndo'' and ''$msg'' holding the message. To display the message for your plugin ''myplugin'', add the following code to your plugin: | Assume you have 3 variables, ''$isSuccess'', ''$canUndo'' and ''$msg'' holding the message. To display the message for your plugin ''myplugin'', add the following code to your plugin: | ||
- | <code> | + | <code php> |
<?php | <?php | ||
if (isset($msg)) { | if (isset($msg)) { | ||
Line 58: | Line 58: | ||
The publication date in the page XML files is stored in an english text format, which can be converted to a UNIX timestamp with | The publication date in the page XML files is stored in an english text format, which can be converted to a UNIX timestamp with | ||
- | <code> | + | <code php> |
$timestamp = strtotime($data->pubDate); | $timestamp = strtotime($data->pubDate); | ||
</code> | </code> | ||
Line 66: | Line 66: | ||
To display a truly localized date, use: | To display a truly localized date, use: | ||
- | <code> | + | <code php> |
$dateLocale = 'de_DE,de,ger,deu'; // or use $LANG or a setting in your plugin, | $dateLocale = 'de_DE,de,ger,deu'; // or use $LANG or a setting in your plugin, | ||
// for OS compatibility multiple locales should be possible | // for OS compatibility multiple locales should be possible | ||
Line 83: | Line 83: | ||
However, if you need it for the backend, e.g. linking to a php somewhere in the plugins folder, you can add the following code to your plugin (e.g. directly after setting up the hooks): | However, if you need it for the backend, e.g. linking to a php somewhere in the plugins folder, you can add the following code to your plugin (e.g. directly after setting up the hooks): | ||
- | <code> | + | <code php> |
if (!myplugin_is_frontend() && myplugin_gsversion() == '3.0') { | if (!myplugin_is_frontend() && myplugin_gsversion() == '3.0') { | ||
// workaround for GetSimple 3.0: | // workaround for GetSimple 3.0: |