The popular open-source contract for web professionals by Stuff & Nonsense
- Originally published: 23rd December 2008
- Revised date: March 15th 2016
- Original post
Collection of code blocks for the Trustpilot RSS Reader example. |
Collection of code blocks to create a FormIt Hook for Sweet Captcha. | |
Sweet Captcha - Fun and Human Friendly Captcha: http://sweetcaptcha.com/ (requires no cost account to be set up). | |
01 SwtCaptchaFormItHook.php - Hook to validate Sweet Captcha | |
02 SwtCaptchaHTML.php - Output Sweet Captcha HTML | |
03 sweetcaptcha.php - 01 SwtCaptchaFormItHook.php assumes sweetcaptcha.php is in your web root directory. | |
Note: 03 sweetcaptcha.php requires your account credentials to be defined by updating the placeholders at the |
# Add this before your MODX Friendly URLs RewriteCond's and RewriteRule... | |
RewriteCond /abs/path/to/docroot/statcache%{REQUEST_URI} -f | |
RewriteRule ^(.*)$ /statcache/$1 [L,QSA] |
<?php | |
/** | |
* | |
* Plugin fires OnWebPagePrerender system event, loads Minify HTML by Mr Clay and minifies the requested Resource HTML inc. inline css and js. | |
* | |
* If used in conjunction with StatCache the minified HTML is cached and served as a flat file via IIS Rewrite. | |
* | |
* CREDITS | |
* | |
* http://rtfm.modx.com/revolution/2.x/developing-in-modx/basic-development/plugins |
<?php | |
/** | |
* registerAssets | |
* | |
* DESCRIPTION | |
* | |
* Registers assets to MODX Placeholder. | |
* | |
* Requires call to [[activateAssets]] before closing body tag in template. This grabs files list from the Placeholder and outputs a javascript block | |
* of assets to be injected after page load. |
<?php | |
/** | |
* activateAssets | |
* | |
* DESCRIPTION | |
* | |
* Activates assets registered in placeholder. | |
* | |
* PROPERTIES: | |
* |
<?php | |
/** | |
* Case-insensitive in_array() wrapper. | |
* | |
* @param mixed $needle Value to seek. | |
* @param array $haystack Array to seek in. | |
* | |
* @return bool | |
*/ |
<?php | |
/** | |
* SessionManager | |
* A script that can be used for easy control over your session variables. | |
* Put this script in your core/components/ folder, inside a sessionman/ subdirectory. | |
* | |
* Load this one in your snippets/plugins like; | |
* | |
* $sessman = $modx->getService('session','SessionManager', $modx->getOption('sessman.core_path',null,$modx->getOption('core_path').'components/sessionman/'), $scriptProperties); | |
* if(!($sessman instanceof SessionManager)) { $modx->log(modX::LOG_LEVEL_ERROR, 'Session manager could not be loaded..'); return ''; } |
<?php | |
function send_http_auth_headers(){ | |
header('WWW-Authenticate: Basic realm="Your Website Name Restricted"'); | |
header('HTTP/1.0 401 Unauthorized'); | |
echo 'Please speak to an administrator for access to the this feature.'; | |
exit; | |
} | |
add_action('template_redirect', 'maybe_add_http_auth_basic', 0); | |
function maybe_add_http_auth_basic(){ | |
# Add your specific URI segment (i.e. http://example.com/segment-string/) |