Skip to content

Instantly share code, notes, and snippets.

<?php
/*
snippet: spamFilter
purpose: Check message of email for chinese/russian characters and badwords
usage: add snippet to validate rules and customValidator property
&validate=`message:email:spamFilter:required`
&customValidators=`spamFilter`
*/
@patrickatwsrn
patrickatwsrn / xpdo-where
Created October 11, 2023 20:49 — forked from davidpede/xpdo-where
pdoResources where examples
&where=`{ "template:IN" : [ 1,2,3 ] }
&where=`{ "template:NOT IN" : [ 1,2,3 ] }
&where=`[{"alias:LIKE":"foo%", "OR:alias:LIKE":"%bar"},{"OR:pagetitle:=":"foobar", "AND:description:=":"raboof"}]`
@patrickatwsrn
patrickatwsrn / current-user-role.php
Created July 18, 2023 10:05
wordpress - check user role of current user
<?php
/*
https://developer.wordpress.org/reference/functions/current_user_can/#comment-4083
Contributed by Ahir Hemant(Woo-Expert)
*/
$user = wp_get_current_user();
$allowed_roles = array( 'editor', 'administrator', 'author' );
if ( array_intersect( $allowed_roles, $user->roles ) ) {
@patrickatwsrn
patrickatwsrn / acf-fieldgroup_allergene.json
Last active April 4, 2023 10:57
ACF Allergene und Zusatzstoffe für WooCommerce.
[
{
"key": "group_61e968f1031de",
"title": "Allergene",
"fields": [
{
"show_column_filter": false,
"allow_bulkedit": false,
"allow_quickedit": false,
"show_column": false,
@patrickatwsrn
patrickatwsrn / acf-opening-hours.json
Last active April 4, 2023 10:52
Wordpress ACF Opening hours
/* exported from acf pro */
[
{
"key": "group_642af70225c29",
"title": "Öffnungszeiten",
"fields": [
{
"show_column_filter": false,
"allow_bulkedit": 0,
"allow_quickedit": 0,
<?php
echo dirname(__FILE__)."<br>";
$locales = ["af_NA", "af_ZA", "af", "ak_GH", "ak", "sq_AL", "sq", "am_ET", "am", "ar_DZ", "ar_BH", "ar_EG", "ar_IQ", "ar_JO", "ar_KW", "ar_LB", "ar_LY", "ar_MA", "ar_OM", "ar_QA", "ar_SA", "ar_SD", "ar_SY", "ar_TN", "ar_AE", "ar_YE", "ar", "hy_AM", "hy", "as_IN", "as", "asa_TZ", "asa", "az_Cyrl", "az_Cyrl_AZ", "az_Latn", "az_Latn_AZ", "az", "bm_ML", "bm", "eu_ES", "eu", "be_BY", "be", "bem_ZM", "bem", "bez_TZ", "bez", "bn_BD", "bn_IN", "bn", "bs_BA", "bs", "bg_BG", "bg", "my_MM", "my", "ca_ES", "ca", "tzm_Latn", "tzm_Latn_MA", "tzm", "chr_US", "chr", "cgg_UG", "cgg", "zh_Hans", "zh_Hans_CN", "zh_Hans_HK", "zh_Hans_MO", "zh_Hans_SG", "zh_Hant", "zh_Hant_HK", "zh_Hant_MO", "zh_Hant_TW", "zh", "kw_GB", "kw", "hr_HR", "hr", "cs_CZ", "cs", "da_DK", "da", "nl_BE", "nl_NL", "nl", "ebu_KE", "ebu", "en_AS", "en_AU", "en_BE", "en_BZ", "en_BW", "en_CA", "en_GU", "en_HK", "en_IN", "en_IE", "en_JM", "en_MT", "en_MH", "en_MU", "en_NA", "en_NZ", "en_MP", "en_PK", "en_PH", "en_SG", "en_Z
@patrickatwsrn
patrickatwsrn / modx.memberpages.md
Created July 31, 2022 14:01
Notes on setting up different login ideas for members

Notes on setting up different login ideas for members

Important This is work in progress and FAR away from completed.

Ideas:

  • Login webhook that sends a message to a slack message board.

MODX Extras

  • Login by jako: Loads a simple login/logout form, with password retrieval functionality and a register form snippet.
  • Auth0 by sepiariver - Log in to MODX using any/all of the Identify Providers (IdPs) supported by Auth0, such as Google, Facebook, Twitter, Github, Microsoft, Dropbox, and dozens of others, including enterprise services
@patrickatwsrn
patrickatwsrn / modx.multi-context.md
Last active July 31, 2022 14:09
Notes on setting up a multi context modx page

Notes on setting up a multi context modx page

Important This is work in progress and FAR away from completed.

Scenario one: Multiple subdomains

Use case:

I want to have two contexts:

  • Homepage: resources handling actual content
  • Static: resources handling static content like css, js, layout images.
@patrickatwsrn
patrickatwsrn / modx-setup.md
Last active July 31, 2022 14:02
Basic MODx setup (German localization)

Introduction

My personal notes for an opinionated MODX setup.

What is MODX?

MODX is an honest down to earth CMS with a whole lot of freedom.

Install MODX

MODX should run on most decent servers.

Procedure

@patrickatwsrn
patrickatwsrn / gist:2c174a724a76f1c209109074531abe5b
Created May 13, 2022 07:15 — forked from mythicallage/gist:4514994
MODx Revo snippet. This a snippet is generator a list of possible values ​​from a list of existing values by ​​tv name.
<?php
/*[[newGetTvList? &tvname=`articlestags`]]
* Аналогично:
*@EVAL return $modx->runSnippet('GetTvList',array('tvname'=>'articlestags'));
*
*
*Убирает все пробелы, заменяет ','=>'||'
*Сниппет получает все значения ТВ по tv.name и формирует в список возможных значений
*для tv Множественный выбор, Одиночный выбор.
*/